-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhancement(observability): add fixed tag option to `RegisteredEventC…
…ache` (#17814) @bruceg highlighted the fact that there was no straight forward way to add fixed tags to the `RegisteredEventCache`. This adds the option to do that. Very quickly, supposing the `TaggedEventsSent` had two tags, `something` and `service`. `something` never changes so can be passed in when the event cache is first created. The code for this would look similar to: ```rust crate::registered_event!( TaggedEventsSent { something: String, service: OptionalTag<String>, } => { events: Counter = { register_counter!("component_sent_events_total", &make_tags(&self.something, &self.service)) }, event_bytes: Counter = { register_counter!("component_sent_event_bytes_total", &make_tags(&self.something, &self.service)) }, } fn emit(&self, data: CountByteSize) { ... } fn register(something: String, tags: EventCountTags) { super::register(TaggedEventsSent::new( something, tags, )) } ); ... let events_sent = RegisteredEventCache::default(String::from("something")); .... events_sent.emit(service, *size); ``` --------- Signed-off-by: Stephen Wakely <[email protected]>
- Loading branch information
1 parent
911477a
commit bc86222
Showing
5 changed files
with
73 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters