Commit 5a6cf33
Add SDKStats module with Azure Monitor bridge for feature/instrumentation reporting (#89)
* Add SDKStats module with Azure Monitor bridge for feature/instrumentation reporting
- New _sdkstats package: state management, observable metrics, and manager
for SDK self-telemetry (feature flags and instrumentation bitmasks)
- Feature bits aligned with Azure Monitor exporter statsbeat encoding:
bits 1-64 match exporter, bits 128+ are distro-specific
(A365_EXPORT, OTLP_EXPORT, CONSOLE_EXPORT, SPECTRA_EXPORT)
- When Azure Monitor is enabled: bridge distro bits into exporter's
statsbeat via _StatsbeatMetrics._FEATURE_ATTRIBUTES and
_INSTRUMENTATIONS_BIT_MASK (single pipeline, no duplication)
- When Azure Monitor is disabled: standalone SdkStatsManager runs its
own AzureMonitorMetricExporter(is_sdkstats=True) pipeline
- Distro records feature flags for each enabled exporter target and
instrumentation bits for each activated library
- 37 tests covering state, metrics, manager, bridge, and thread safety
* Address Copilot review: metric naming, env parsing, error handling, dead code
- Use lowercase metric names ('feature', 'feature.instrumentations') to
match exporter convention and test assertions; remove unused
_ATTACH_METRIC_NAME constant
- Add 'on' to is_sdkstats_enabled() disable values for consistency with
_env_bool()
- Split bare except in snippet_injector into ImportError (silent) vs
Exception (debug-logged) for diagnosability
- Remove unused _DEFAULT_EXPORT_INTERVAL_SECS constant from _manager.py
- Add test_disabled_by_on test case
* Address comments
* Address comments
* Bring back env set line
---------
Co-authored-by: Radhika Gupta <guptaradhika@microsoft.com>1 parent 910330c commit 5a6cf33
7 files changed
Lines changed: 1106 additions & 5 deletions
File tree
- src/microsoft/opentelemetry
- _azure_monitor/_browser_sdk_loader
- _sdkstats
- tests
Lines changed: 22 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
45 | 64 | | |
46 | 65 | | |
47 | 66 | | |
48 | 67 | | |
49 | 68 | | |
50 | 69 | | |
51 | 70 | | |
52 | | - | |
53 | | - | |
54 | 71 | | |
55 | | - | |
56 | 72 | | |
57 | 73 | | |
58 | 74 | | |
59 | 75 | | |
60 | 76 | | |
61 | 77 | | |
| 78 | + | |
| 79 | + | |
62 | 80 | | |
63 | 81 | | |
64 | 82 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
67 | 75 | | |
68 | 76 | | |
69 | 77 | | |
70 | 78 | | |
71 | 79 | | |
72 | 80 | | |
73 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
74 | 87 | | |
75 | 88 | | |
76 | 89 | | |
| |||
177 | 190 | | |
178 | 191 | | |
179 | 192 | | |
180 | | - | |
| 193 | + | |
181 | 194 | | |
182 | 195 | | |
183 | 196 | | |
| |||
219 | 232 | | |
220 | 233 | | |
221 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
222 | 238 | | |
223 | 239 | | |
| 240 | + | |
| 241 | + | |
224 | 242 | | |
225 | 243 | | |
226 | 244 | | |
| |||
252 | 270 | | |
253 | 271 | | |
254 | 272 | | |
| 273 | + | |
| 274 | + | |
255 | 275 | | |
256 | 276 | | |
257 | 277 | | |
| |||
293 | 313 | | |
294 | 314 | | |
295 | 315 | | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
296 | 319 | | |
297 | 320 | | |
298 | 321 | | |
| |||
305 | 328 | | |
306 | 329 | | |
307 | 330 | | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
308 | 377 | | |
309 | 378 | | |
310 | 379 | | |
| |||
367 | 436 | | |
368 | 437 | | |
369 | 438 | | |
| 439 | + | |
| 440 | + | |
370 | 441 | | |
371 | 442 | | |
372 | 443 | | |
| |||
448 | 519 | | |
449 | 520 | | |
450 | 521 | | |
| 522 | + | |
| 523 | + | |
451 | 524 | | |
452 | 525 | | |
453 | 526 | | |
| |||
619 | 692 | | |
620 | 693 | | |
621 | 694 | | |
| 695 | + | |
622 | 696 | | |
623 | 697 | | |
624 | 698 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
0 commit comments