Commit d8e8685
authored
VersionMembershipCache: Metrics and refactorings! (temporalio#8894)
## What changed?
- Added metrics, such as cache hits and cache misses, so that we can
understand if the currently set TTL for this cache (of 1 second) is too
low or too high.
- Also did some re-factorings: While working on this, I realized that it
was much simpler to add a new wrapper with a metrics handler, that
specifically served the use case of understanding cache hits and missed,
rather than use any of the existing implementations of caches that have
a metrics handler attached to them. (See *NewWithMetrics*)
- Thus, I took some inspiration from the way *newEventsCache* was
implemented and came up with this.
## Why?
- Explained above.
## How did you test it?
- [ ] built
- [ ] run locally and tested manually
- [ ] covered by existing tests
- [ ] added new unit test(s)
- [ ] added new functional test(s)
## Potential risks
- None.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Introduces a typed `VersionMembershipCache` wrapper with metrics and
refactors callers to use it.
>
> - New `common/worker_versioning/version_membership_cache.go`: typed
cache API with `Get`/`Put`, emits `cache_requests` and `cache_miss` with
`cache_type=version_membership` and op scopes
`VersionMembershipCacheGet`/`Put`
> - Metrics: add `VersionMembershipCacheTypeTagValue` and new operation
scopes in `metrics/metric_defs.go`
> - Refactor: replace `cache.Cache` with `VersionMembershipCache` in
worker versioning validation and history APIs (`startworkflow`,
`signalwithstartworkflow`, `resetworkflow`, `multioperation`,
`updateworkflowoptions`), update DI to provide wrapped cache in
`service/history/fx.go`
> - History engine constructors and factory updated to accept the new
interface
> - Tests: add lightweight in-memory and noop implementations; update
unit tests to use the new interface
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
1ce3a10. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 32f2b95 commit d8e8685
13 files changed
Lines changed: 251 additions & 107 deletions
File tree
- common
- metrics
- worker_versioning
- service/history
- api
- multioperation
- resetworkflow
- signalwithstartworkflow
- startworkflow
- updateworkflowoptions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
450 | 451 | | |
451 | 452 | | |
452 | 453 | | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
453 | 458 | | |
454 | 459 | | |
455 | 460 | | |
| |||
| 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 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
| |||
530 | 529 | | |
531 | 530 | | |
532 | 531 | | |
533 | | - | |
| 532 | + | |
534 | 533 | | |
535 | 534 | | |
536 | 535 | | |
537 | 536 | | |
538 | 537 | | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
547 | | - | |
548 | | - | |
549 | | - | |
550 | | - | |
551 | | - | |
552 | | - | |
553 | | - | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
554 | 547 | | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
555 | 551 | | |
556 | 552 | | |
557 | 553 | | |
| |||
565 | 561 | | |
566 | 562 | | |
567 | 563 | | |
568 | | - | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
569 | 572 | | |
570 | 573 | | |
571 | 574 | | |
| |||
574 | 577 | | |
575 | 578 | | |
576 | 579 | | |
577 | | - | |
578 | | - | |
579 | | - | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | 580 | | |
586 | 581 | | |
587 | 582 | | |
588 | | - | |
| 583 | + | |
589 | 584 | | |
590 | 585 | | |
591 | 586 | | |
| |||
0 commit comments