Commit 923425d
Nest dynamic telemetry events (#8357)
This pull request introduces a mechanism for handling dynamic telemetry
fields in performance events, allowing for more flexible and scalable
telemetry data collection. The main change is the addition of an `ext`
sub-object to the `PerformanceEvent` type, which stores fields whose
names are constructed at runtime. The pull request also updates relevant
methods and tests to support this new structure, and adds a lint rule to
enforce correct usage.
Dynamic telemetry fields support:
* Added an `ext` property to the `PerformanceEvent` type to store
dynamically-named fields, such as call counts and sub-measurement
durations. These fields are routed to `ext` using the `"ext."` prefix
when calling `addFields` or `incrementFields`.
(`lib/msal-common/src/telemetry/performance/PerformanceEvent.ts`,
[lib/msal-common/src/telemetry/performance/PerformanceEvent.tsR354-R364](diffhunk://#diff-2f63a38227d7a354d8c67987de2d283da038557a987db95576a08fe16cc60354R354-R364))
* Introduced the `EXT_FIELD_PREFIX` constant and updated
`PerformanceClient` methods (`addFields`, `incrementFields`) to
automatically route fields with this prefix to the `ext` sub-object,
ensuring separation between static and dynamic fields.
(`lib/msal-common/src/telemetry/performance/PerformanceEvent.ts`,
[[1]](diffhunk://#diff-2f63a38227d7a354d8c67987de2d283da038557a987db95576a08fe16cc60354R379-R385);
`lib/msal-common/src/telemetry/performance/PerformanceClient.ts`,
[[2]](diffhunk://#diff-5c2e3cc078d85a3fa0eb4b4596ecee70cc03689d6ac7ab96c69b8628fd8e055fL524-R561)
[[3]](diffhunk://#diff-5c2e3cc078d85a3fa0eb4b4596ecee70cc03689d6ac7ab96c69b8628fd8e055fR582-R606)
[[4]](diffhunk://#diff-5c2e3cc078d85a3fa0eb4b4596ecee70cc03689d6ac7ab96c69b8628fd8e055fL456-R466)
Code and test updates for dynamic fields:
* Updated function wrappers to increment API call counts using the
dynamic field mechanism, storing them in `ext` instead of as top-level
properties. (`lib/msal-common/src/utils/FunctionWrappers.ts`,
[[1]](diffhunk://#diff-71662df5e90583aee6710b2dbac9fe829522000bf6b03e1ab1bed5f5a6f64932L36-R39)
[[2]](diffhunk://#diff-71662df5e90583aee6710b2dbac9fe829522000bf6b03e1ab1bed5f5a6f64932L92-R97)
* Refactored tests to assert dynamic fields are correctly stored in
`event.ext`, and added new tests to verify merging, routing, and absence
of the `ext` object when not used.
(`lib/msal-common/test/telemetry/PerformanceClient.spec.ts`,
[[1]](diffhunk://#diff-a1c469f9aa50bb3cf9652bb95ab570e63f3445cc854ec1c098e7e7b45f824bd0L129-R129)
[[2]](diffhunk://#diff-a1c469f9aa50bb3cf9652bb95ab570e63f3445cc854ec1c098e7e7b45f824bd0L215-R222)
[[3]](diffhunk://#diff-a1c469f9aa50bb3cf9652bb95ab570e63f3445cc854ec1c098e7e7b45f824bd0L356-R366)
[[4]](diffhunk://#diff-a1c469f9aa50bb3cf9652bb95ab570e63f3445cc854ec1c098e7e7b45f824bd0L406-R410)
[[5]](diffhunk://#diff-a1c469f9aa50bb3cf9652bb95ab570e63f3445cc854ec1c098e7e7b45f824bd0L454-R460)
[[6]](diffhunk://#diff-a1c469f9aa50bb3cf9652bb95ab570e63f3445cc854ec1c098e7e7b45f824bd0R1497-R1623)
Linting and documentation:
* Added a custom ESLint rule to enforce no dynamic telemetry fields at
the top level, ensuring dynamic fields are always routed to `ext`.
(`shared-configs/eslint-config-msal/index.js`,
[shared-configs/eslint-config-msal/index.jsR88](diffhunk://#diff-2b30170ea2355b0ba1b936931fa57a0703830fa262c9ac8e5a64904d58245478R88))
* Updated API review and documentation comments to reflect the new
structure and dynamic field handling.
(`lib/msal-common/apiReview/msal-common.api.md`,
[[1]](diffhunk://#diff-09087b913ebbfa828e5f36b7476a400328e0a7131db84f622cc5f6994759a117R3491)
[[2]](diffhunk://#diff-09087b913ebbfa828e5f36b7476a400328e0a7131db84f622cc5f6994759a117L4794-R4800)
[[3]](diffhunk://#diff-09087b913ebbfa828e5f36b7476a400328e0a7131db84f622cc5f6994759a117R4883-R4887)
These changes provide a scalable foundation for telemetry data
collection, making it easier to add new dynamic fields without bloating
the top-level event structure.
---------
Co-authored-by: Sameera Gajjarapu <sameera.gajjarapu@microsoft.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>1 parent ed8afbb commit 923425d
11 files changed
Lines changed: 939 additions & 38 deletions
File tree
- change
- lib
- msal-browser/test/app
- msal-common
- apiReview
- src
- telemetry/performance
- utils
- test/telemetry
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
786 | 786 | | |
787 | 787 | | |
788 | 788 | | |
789 | | - | |
| 789 | + | |
790 | 790 | | |
791 | | - | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
792 | 794 | | |
793 | 795 | | |
794 | 796 | | |
| |||
941 | 943 | | |
942 | 944 | | |
943 | 945 | | |
944 | | - | |
| 946 | + | |
945 | 947 | | |
946 | 948 | | |
947 | | - | |
| 949 | + | |
948 | 950 | | |
949 | 951 | | |
950 | 952 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3474 | 3474 | | |
3475 | 3475 | | |
3476 | 3476 | | |
| 3477 | + | |
3477 | 3478 | | |
3478 | 3479 | | |
3479 | 3480 | | |
| |||
3487 | 3488 | | |
3488 | 3489 | | |
3489 | 3490 | | |
| 3491 | + | |
| 3492 | + | |
| 3493 | + | |
| 3494 | + | |
| 3495 | + | |
3490 | 3496 | | |
| 3497 | + | |
| 3498 | + | |
| 3499 | + | |
| 3500 | + | |
| 3501 | + | |
| 3502 | + | |
| 3503 | + | |
| 3504 | + | |
| 3505 | + | |
| 3506 | + | |
| 3507 | + | |
| 3508 | + | |
| 3509 | + | |
| 3510 | + | |
| 3511 | + | |
| 3512 | + | |
| 3513 | + | |
| 3514 | + | |
| 3515 | + | |
| 3516 | + | |
| 3517 | + | |
| 3518 | + | |
| 3519 | + | |
| 3520 | + | |
| 3521 | + | |
| 3522 | + | |
| 3523 | + | |
| 3524 | + | |
| 3525 | + | |
3491 | 3526 | | |
3492 | 3527 | | |
3493 | 3528 | | |
| |||
4788 | 4823 | | |
4789 | 4824 | | |
4790 | 4825 | | |
4791 | | - | |
4792 | | - | |
4793 | | - | |
4794 | | - | |
4795 | | - | |
4796 | | - | |
| 4826 | + | |
| 4827 | + | |
| 4828 | + | |
| 4829 | + | |
| 4830 | + | |
| 4831 | + | |
4797 | 4832 | | |
4798 | 4833 | | |
4799 | 4834 | | |
| |||
4873 | 4908 | | |
4874 | 4909 | | |
4875 | 4910 | | |
4876 | | - | |
4877 | | - | |
4878 | | - | |
| 4911 | + | |
| 4912 | + | |
| 4913 | + | |
4879 | 4914 | | |
4880 | 4915 | | |
Lines changed: 62 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
453 | 454 | | |
454 | 455 | | |
455 | 456 | | |
456 | | - | |
| 457 | + | |
457 | 458 | | |
458 | | - | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
459 | 466 | | |
460 | 467 | | |
461 | 468 | | |
| |||
521 | 528 | | |
522 | 529 | | |
523 | 530 | | |
524 | | - | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
525 | 550 | | |
526 | | - | |
527 | | - | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
528 | 561 | | |
529 | 562 | | |
530 | 563 | | |
| |||
545 | 578 | | |
546 | 579 | | |
547 | 580 | | |
548 | | - | |
549 | | - | |
550 | | - | |
551 | | - | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
552 | 603 | | |
553 | | - | |
554 | 604 | | |
555 | 605 | | |
556 | 606 | | |
| |||
674 | 724 | | |
675 | 725 | | |
676 | 726 | | |
| 727 | + | |
677 | 728 | | |
678 | 729 | | |
679 | 730 | | |
| 731 | + | |
680 | 732 | | |
681 | 733 | | |
682 | 734 | | |
| |||
Lines changed: 110 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
| 324 | + | |
| 325 | + | |
324 | 326 | | |
325 | 327 | | |
326 | 328 | | |
| |||
344 | 346 | | |
345 | 347 | | |
346 | 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 | + | |
347 | 374 | | |
348 | 375 | | |
349 | 376 | | |
350 | 377 | | |
351 | 378 | | |
352 | 379 | | |
353 | 380 | | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
354 | 457 | | |
355 | 458 | | |
356 | 459 | | |
| |||
365 | 468 | | |
366 | 469 | | |
367 | 470 | | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
368 | 478 | | |
369 | 479 | | |
370 | 480 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| |||
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
92 | | - | |
93 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
94 | 98 | | |
95 | 99 | | |
96 | 100 | | |
| |||
0 commit comments