-
Notifications
You must be signed in to change notification settings - Fork 20
feat: Support "hits" trace metric #827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
2097d3d
Add debug log
lym953 6c6532a
Send dummy stats
lym953 338273a
...
lym953 0af0f8f
Add more fields
lym953 cb2e790
Can see metrics in metrics explorer
lym953 102cbbe
Add stats concentrator, which pushes data to aggregator
lym953 82d692b
Avoid returning unused trace_tx
lym953 0589583
Move start_stats_agent() inside start_stats_agent()
lym953 1c7bb7c
Make stats aggregator pull from stats concentrator
lym953 03e88cc
Add logging
lym953 e06b1e7
Fix double counting
lym953 92ba7b2
Move ClientStatsPayload construction to StatsConcentrator
lym953 853e955
Create buckets
lym953 b383773
Do not flush the latest two buckets
lym953 c69adb6
Do not use hard coded keys such as yiming_name
lym953 13c2aef
Change _dd.compute_stats from 1 to 0
lym953 609294c
Remove MyStatsProcessor
lym953 39766d6
Remove unused code
lym953 503c07d
Format
lym953 ce2879c
Rename variables and remove unnecessary code
lym953 70f5e07
Fix code style
lym953 029a556
Code style
lym953 abf9372
Add comments
lym953 815e740
Add tests for should_flush_bucket()
lym953 c5770e3
Format
lym953 aa7073c
Move the trigger to trace agent, without grouping by key
lym953 01441c3
Support aggregation keys
lym953 847ec5d
Support duration
lym953 8b103ee
Support errors
lym953 ca42a2c
Support duration
lym953 efe580c
Change http status code from 200 to 0
lym953 2687e00
Remove unused resource param
lym953 c39a4a0
Get service from trace
lym953 d0fa419
Get env from trace
lym953 f298a2e
Support r#type
lym953 2793e41
Add comments
lym953 e8ca422
Use retain()
lym953 45c65d9
Handle error when casting u128 to u64
lym953 6a9a16a
Fix the support for error and duration
lym953 cc0e252
Support top_level_hits
lym953 7026753
Add feature flag
lym953 d0f55e8
Add stats concentrator service to avoid using mutex
lym953 9f58ddb
Remove some debug log
lym953 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| use tokio::sync::mpsc::{self, Receiver, Sender}; | ||
| use tracing::error; | ||
|
|
||
| use super::stats_concentrator_service::StatsConcentratorHandle; | ||
|
|
||
| use super::stats_concentrator::AggregationKey; | ||
| use super::stats_concentrator::Stats; | ||
|
|
||
| #[derive(Clone)] | ||
| pub struct StatsEvent { | ||
| pub time: u64, | ||
| pub aggregation_key: AggregationKey, | ||
| pub stats: Stats, | ||
| } | ||
|
|
||
| #[allow(clippy::module_name_repetitions)] | ||
| pub struct StatsAgent { | ||
| tx: Sender<StatsEvent>, | ||
| rx: Receiver<StatsEvent>, | ||
| concentrator: StatsConcentratorHandle, | ||
| } | ||
|
|
||
| impl StatsAgent { | ||
| #[must_use] | ||
| pub fn new(concentrator: StatsConcentratorHandle) -> StatsAgent { | ||
| let (tx, rx) = mpsc::channel::<StatsEvent>(1000); | ||
| StatsAgent { | ||
| tx, | ||
| rx, | ||
| concentrator, | ||
| } | ||
| } | ||
|
|
||
| pub async fn spin(&mut self) { | ||
| while let Some(event) = self.rx.recv().await { | ||
| if let Err(e) = self.concentrator.add(event) { | ||
| error!("Error adding stats event to the stats concentrator: {e}"); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[must_use] | ||
| pub fn get_sender_copy(&self) -> Sender<StatsEvent> { | ||
| self.tx.clone() | ||
| } | ||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this own the channel it creates and then return the tx through a public method? that way it's not created in the main binary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Will do.