Skip to content

feature(bottlecap): add trace context extractor#401

Merged
astuyve merged 9 commits intojordan.gonzalez/bottlecap/universal-instrumentationfrom
jordan.gonzalez/bottlecap/add-trace-propagator
Oct 9, 2024
Merged

feature(bottlecap): add trace context extractor#401
astuyve merged 9 commits intojordan.gonzalez/bottlecap/universal-instrumentationfrom
jordan.gonzalez/bottlecap/add-trace-propagator

Conversation

@duncanista
Copy link
Copy Markdown
Contributor

@duncanista duncanista commented Sep 27, 2024

What?

Adds an implementation of trace context propagator, currently only focusing on extraction.

Motivation

Inferred spans and SVLS-5289

Notes

@duncanista duncanista changed the base branch from main to jordan.gonzalez/bottlecap/universal-instrumentation September 27, 2024 17:39
…to jordan.gonzalez/bottlecap/add-trace-propagator
Copy link
Copy Markdown
Contributor

@alexgallotta alexgallotta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks amazing! Great job! Left 2 comments on some stuff that might be removed and avoid some extra code/layering

pub struct TraceparentPropagator;

impl TextMapPropagator for TraceparentPropagator {
fn extract(&self, carrier: &dyn Extractor) -> SpanContext {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need struct + trait + methods here for traceparent and tracestate propagators?
Can we get away with extract_parent and extract_state?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

traceparent and tracestate propagators
Do you mean The Traceparent propagator which includse the extraction of the tracestate + traceparent?

If so, I tried using this struct + trait + methods in order to make the code easier to maintain, and also following the current OTel implemenetation, which I think was simple enough to understand, what do you think?

/// Injector provides an interface for a carrier to be used
/// with a Propagator to inject a Context into the carrier.
///
pub trait Injector {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for these 2. Can we avoid/postpone creating extra traits?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows us to directly implement this traits for carriers which we might not have control of, for example, here I tend to convert hyper::HeaderMap into a HashMap so I can use the extract and inject methods on the struct right away.

At the top of the file I explain that I directly copied this from the OTel rust implementation for extractor/injectors.

I think this would help us whenever we have to expand, and its also very generic, what do you think of this?

Copy link
Copy Markdown
Contributor

@astuyve astuyve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple todos but nothing looks particularly wrong to me here

}

fn inject(&self, _context: SpanContext, _carrier: &mut dyn Injector) {
todo!();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this ones i'm not going to particularly adress in this PR, since we don't care about injection yet, maybe I mark them as that they're going to panic since they are not implemented?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope this is totally fine

@astuyve astuyve marked this pull request as ready for review October 9, 2024 18:58
@astuyve astuyve requested a review from a team as a code owner October 9, 2024 18:58
@astuyve astuyve merged commit 0f196d2 into jordan.gonzalez/bottlecap/universal-instrumentation Oct 9, 2024
@astuyve astuyve deleted the jordan.gonzalez/bottlecap/add-trace-propagator branch October 9, 2024 18:59
alexgallotta pushed a commit that referenced this pull request Nov 4, 2024
* add `thiserror` and `lazystatic`

* add Span/Trace `context`

* update `mod.rs`

* add `propagation` module

* add `propagation::Error`

* add interface for `carrier` and `HashMap` implementation

* add `text_map_propagator`

added `Datadog` and `Tracecontext` implementations

* update `LICENSE-3rdparty.yml`
duncanista added a commit that referenced this pull request Nov 15, 2024
* add `thiserror` and `lazystatic`

* add Span/Trace `context`

* update `mod.rs`

* add `propagation` module

* add `propagation::Error`

* add interface for `carrier` and `HashMap` implementation

* add `text_map_propagator`

added `Datadog` and `Tracecontext` implementations

* update `LICENSE-3rdparty.yml`
duncanista added a commit that referenced this pull request Nov 19, 2024
* add `thiserror` and `lazystatic`

* add Span/Trace `context`

* update `mod.rs`

* add `propagation` module

* add `propagation::Error`

* add interface for `carrier` and `HashMap` implementation

* add `text_map_propagator`

added `Datadog` and `Tracecontext` implementations

* update `LICENSE-3rdparty.yml`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants