-
Notifications
You must be signed in to change notification settings - Fork 121
User Tracing #223
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
Open
mar-cf
wants to merge
7
commits into
cloudflare:main
Choose a base branch
from
mar-cf:user-tracing-7
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,972
−18
Open
User Tracing #223
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
22aa5ce
Make SharedSpan construction explicit
mar-cf 47cd747
Add core user-tracing span API
mar-cf 8dad0e4
Propagate user spans through TelemetryContext
mar-cf e646eae
Add user-span ergonomic instrumentation
mar-cf cc6279b
Temporarily patch cf-rustracing to the routing branch
mar-cf 1624510
Add user-tracing pipeline and span routing
mar-cf 0b7d4e8
Add W3C trace propagation for user spans
mar-cf 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| use std::num::NonZeroUsize; | ||
|
|
||
| #[cfg(feature = "settings")] | ||
| use crate::settings::settings; | ||
|
|
||
| /// Distributed user tracing settings. | ||
| #[cfg_attr(feature = "settings", settings(crate_path = "crate"))] | ||
| #[cfg_attr(not(feature = "settings"), derive(Clone, Debug, serde::Deserialize))] | ||
| pub struct UserTracingSettings { | ||
| /// Enables user tracing. | ||
| #[serde(default = "UserTracingSettings::default_enabled")] | ||
| pub enabled: bool, | ||
|
|
||
| /// Maximum number of spans to buffer for output. Any spans above | ||
| /// this limit will be dropped until the queue regains capacity. | ||
| /// | ||
| /// The default is to buffer up to 1 million spans in memory. This protects | ||
| /// services from out-of-memory errors when the output gets heavily backed up. | ||
| /// To disable the limit entirely, set this setting to `None`. | ||
| #[serde(default = "UserTracingSettings::default_max_queue_size")] | ||
| pub max_queue_size: Option<NonZeroUsize>, | ||
|
|
||
| /// The output for the collected user traces. | ||
| pub output: UserTracesOutput, | ||
| } | ||
|
|
||
| #[cfg(not(feature = "settings"))] | ||
| impl Default for UserTracingSettings { | ||
| fn default() -> Self { | ||
| Self { | ||
| enabled: UserTracingSettings::default_enabled(), | ||
| max_queue_size: UserTracingSettings::default_max_queue_size(), | ||
| output: Default::default(), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl UserTracingSettings { | ||
| fn default_enabled() -> bool { | ||
| true | ||
| } | ||
|
|
||
| const fn default_max_queue_size() -> Option<NonZeroUsize> { | ||
| Some(const { NonZeroUsize::new(1_000_000).expect("1_000_000 is not zero") }) | ||
| } | ||
| } | ||
|
|
||
| /// The output for the collected user traces. | ||
| #[cfg_attr( | ||
| feature = "settings", | ||
| settings(crate_path = "crate", impl_default = false) | ||
| )] | ||
| #[cfg_attr(not(feature = "settings"), derive(Clone, Debug, serde::Deserialize))] | ||
| pub enum UserTracesOutput { | ||
| /// Send user tracing spans as OTLP over a Unix domain socket to an OTLP endpoint. | ||
| OtlpUds(OtlpUdsOutputSettings), | ||
| } | ||
|
|
||
| impl Default for UserTracesOutput { | ||
| fn default() -> Self { | ||
| Self::OtlpUds(Default::default()) | ||
| } | ||
| } | ||
|
|
||
| /// [OTLP over UDS] output settings for user tracing. | ||
| /// | ||
| /// Sends trace data as protobuf-encoded OTLP over HTTP to a Unix domain socket. | ||
| #[cfg_attr(feature = "settings", settings(crate_path = "crate"))] | ||
| #[cfg_attr(not(feature = "settings"), derive(Clone, Debug, serde::Deserialize))] | ||
| pub struct OtlpUdsOutputSettings { | ||
| /// Path to the Unix domain socket for the OTLP endpoint. | ||
| pub socket_path: String, | ||
|
|
||
| /// Number of concurrent worker tasks for user trace export. | ||
| /// | ||
| /// # Default | ||
| /// | ||
| /// Default value is `2`. | ||
| #[serde(default = "OtlpUdsOutputSettings::default_num_tasks")] | ||
| pub num_tasks: usize, | ||
|
|
||
| /// Maximum number of spans to drain per batch. | ||
| /// | ||
| /// # Default | ||
| /// | ||
| /// Default value is `512`. | ||
| #[serde(default = "OtlpUdsOutputSettings::default_max_batch_size")] | ||
| pub max_batch_size: usize, | ||
| } | ||
|
|
||
| #[cfg(not(feature = "settings"))] | ||
| impl Default for OtlpUdsOutputSettings { | ||
| fn default() -> Self { | ||
| Self { | ||
| socket_path: String::new(), | ||
| num_tasks: OtlpUdsOutputSettings::default_num_tasks(), | ||
| max_batch_size: OtlpUdsOutputSettings::default_max_batch_size(), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl OtlpUdsOutputSettings { | ||
| const fn default_num_tasks() -> usize { | ||
| 2 | ||
| } | ||
|
|
||
| const fn default_max_batch_size() -> usize { | ||
| 512 | ||
| } | ||
| } |
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.
cloudflare/rustracing#11