-
Notifications
You must be signed in to change notification settings - Fork 20
feat(bottlecap): Add Composite Trace Propagator #413
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
Merged
duncanista
merged 10 commits into
jordan.gonzalez/bottlecap/universal-instrumentation
from
jordan.gonzalez/bottlecap/add-composite-propagator
Oct 21, 2024
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
98b278e
add `trace_propagation_style.rs`
duncanista 4eb30b9
add Trace Propagation to `config.rs`
duncanista 9e29964
add `links` to `SpanContext`
duncanista d2b9b24
add composite propagator
duncanista 523a650
update `TextMapPropagator`s to comply with interface
duncanista 5290f1a
fmt
duncanista 7d48149
add unit testing for `config.rs`
duncanista a2757e5
add `PartialEq` to `SpanContext`
duncanista 2a49451
correct logic from `text_map_propagator.rs`
duncanista 0209456
add unit tests for `DatadogCompositePropagator`
duncanista 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| use std::{fmt::Display, str::FromStr}; | ||
|
|
||
| use serde::{Deserialize, Deserializer}; | ||
|
|
||
| #[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
| pub enum TracePropagationStyle { | ||
| Datadog, | ||
| B3Multi, | ||
| B3, | ||
| TraceContext, | ||
| None, | ||
| } | ||
|
|
||
| impl FromStr for TracePropagationStyle { | ||
| type Err = String; | ||
|
|
||
| fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
| match s.to_lowercase().as_str() { | ||
| "datadog" => Ok(TracePropagationStyle::Datadog), | ||
| "b3multi" => Ok(TracePropagationStyle::B3Multi), | ||
| "b3" => Ok(TracePropagationStyle::B3), | ||
| "tracecontext" => Ok(TracePropagationStyle::TraceContext), | ||
| "none" => Ok(TracePropagationStyle::None), | ||
| _ => Err(format!("Unknown trace propagation style: {s}")), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl Display for TracePropagationStyle { | ||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
| let style = match self { | ||
| TracePropagationStyle::Datadog => "datadog", | ||
| TracePropagationStyle::B3Multi => "b3multi", | ||
| TracePropagationStyle::B3 => "b3", | ||
| TracePropagationStyle::TraceContext => "tracecontext", | ||
| TracePropagationStyle::None => "none", | ||
| }; | ||
| write!(f, "{style}") | ||
| } | ||
| } | ||
|
|
||
| #[allow(clippy::module_name_repetitions)] | ||
| pub fn deserialize_trace_propagation_style<'de, D>( | ||
| deserializer: D, | ||
| ) -> Result<Vec<TracePropagationStyle>, D::Error> | ||
| where | ||
| D: Deserializer<'de>, | ||
| { | ||
| let s: String = String::deserialize(deserializer)?; | ||
|
|
||
| s.split(',') | ||
| .map(|style| { | ||
| TracePropagationStyle::from_str(style.trim()).map_err(|e| { | ||
| serde::de::Error::custom(format!("Failed to deserialize propagation style: {e}")) | ||
| }) | ||
| }) | ||
| .collect() | ||
| } |
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 |
|---|---|---|
| @@ -1,17 +1,20 @@ | ||
| use std::collections::HashMap; | ||
|
|
||
| #[derive(Copy, Clone, Default, Debug)] | ||
| use datadog_trace_protobuf::pb::SpanLink; | ||
|
|
||
| #[derive(Copy, Clone, Default, Debug, PartialEq)] | ||
| pub struct Sampling { | ||
| pub priority: Option<i8>, | ||
| pub mechanism: Option<u8>, | ||
| } | ||
|
|
||
| #[derive(Clone, Default, Debug)] | ||
| #[derive(Clone, Default, Debug, PartialEq)] | ||
| #[allow(clippy::module_name_repetitions)] | ||
| pub struct SpanContext { | ||
| pub trace_id: u64, | ||
| pub span_id: u64, | ||
| pub sampling: Option<Sampling>, | ||
| pub origin: Option<String>, | ||
| pub tags: HashMap<String, String>, | ||
| pub links: Vec<SpanLink>, | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.