Skip to content

refactor#418

Closed
alexgallotta wants to merge 2 commits intojordan.gonzalez/bottlecap/add-composite-propagatorfrom
alexgallotta/bottlecap/propagators
Closed

refactor#418
alexgallotta wants to merge 2 commits intojordan.gonzalez/bottlecap/add-composite-propagatorfrom
alexgallotta/bottlecap/propagators

Conversation

@alexgallotta
Copy link
Copy Markdown
Contributor

Some ideas

fn inject(&self, context: SpanContext, carrier: &mut dyn Injector);
}

impl Propagator for TracePropagationStyle {
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.

propagator could be directly attached to the enum, avoiding one abstraction layer


pub struct DatadogCompositePropagator {
propagators: Vec<Box<dyn Propagator + 'static>>,
propagators: Vec<TracePropagationStyle>,
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.

without the extra abstraction, we can avoid having dynamic dispatching here

for propagator in propagator_style {
if let Some(context) = propagator.extract(carrier) {
contexts.push(context);
styles.push(*propagator);
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.

also avoiding playing with indexes

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.

I agree we could make this simpler

tracestate: tracestate.unwrap_or_default(),
attributes,
});
} else if style == TracePropagationStyle::TraceContext {
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 if's can be probably removed and have the enum containing the logic

fn resolve_contexts(
contexts: Vec<SpanContext>,
styles: Vec<TracePropagationStyle>,
_carrier: &dyn Extractor,
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.

no need to carry around the unused extractor

use lazy_static::lazy_static;
use regex::Regex;
use tracing::{debug, error, warn};

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.

I didn't go through all the implementations (a lot of logic! Impressive work!) but maybe some stuff can be deduplicated

origin: Option<String>,
lower_order_trace_id: Option<String>,
}
fn extract(carrier: &dyn Extractor) -> Option<SpanContext> {
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.

Once there is a enum -> extractor relation, it can be also split in different files so logic is more digestible

pub mod error;
pub mod text_map_propagator;

pub trait Propagator {
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.

no need of trait propagator anymore

None,
}

impl TracePropagationStyle {
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.

Not happy with coupling this into the propagation module which is going to be a crate eventually

@alexgallotta alexgallotta deleted the alexgallotta/bottlecap/propagators branch October 21, 2024 17:39
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.

2 participants