Skip to content
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

Trevorriles/temp #910

Merged
merged 3 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions baseplate/lib/propagator_redditb3_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,40 @@ def extract(
context = Context()

extracted_trace_id = _extract_first_element(getter.get(carrier, self.TRACE_ID_KEY))
if extracted_trace_id is None:
# try lowercase
extracted_trace_id = _extract_first_element(getter.get(carrier, self.TRACE_ID_KEY.lower()))

logger.debug(
"Extracted trace_id from carrier. [carrier=%s, context=%s, trace_id=%s]",
carrier,
context,
extracted_trace_id,
)
extracted_span_id = _extract_first_element(getter.get(carrier, self.SPAN_ID_KEY))
if extracted_span_id is None:
# try lowercase
extracted_span_id = _extract_first_element(getter.get(carrier, self.SPAN_ID_KEY.lower()))
logger.debug(
"Extracted span_id from carrier. [carrier=%s, context=%s, span_id=%s]",
carrier,
context,
extracted_span_id,
)
sampled = _extract_first_element(getter.get(carrier, self.SAMPLED_KEY), default="0")
if sampled is None:
# try lowercase
sampled = _extract_first_element(getter.get(carrier, self.SAMPLED_KEY.lower()))
logger.debug(
"Extracted sampled from carrier. [carrier=%s, context=%s, sampled=%s]",
carrier,
context,
sampled,
)
flags = _extract_first_element(getter.get(carrier, self.FLAGS_KEY))
if flags is None:
# try lowercase
flags = _extract_first_element(getter.get(carrier, self.FLAGS_KEY.lower()))
logger.debug(
"Extracted flags from carrier. [carrier=%s, context=%s, flags=%s]",
carrier,
Expand Down
3 changes: 2 additions & 1 deletion baseplate/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
from baseplate.lib.log_formatter import CustomJsonFormatter
from baseplate.lib.prometheus_metrics import is_metrics_enabled
from baseplate.lib.propagator_redditb3_http import RedditB3HTTPFormat
from baseplate.lib.propagator_redditb3_thrift import RedditB3ThriftFormat
from baseplate.server import einhorn
from baseplate.server import reloader
from baseplate.server.net import bind_socket
Expand Down Expand Up @@ -275,7 +276,7 @@ def configure_tracing(config: Configuration) -> None:

otlp_exporter = OTLPSpanExporter(endpoint=config.tracing["endpoint"], insecure=insecure)
propagate.set_global_textmap(
CompositePropagator([RedditB3HTTPFormat(), TraceContextTextMapPropagator()])
CompositePropagator([RedditB3ThriftFormat(), RedditB3HTTPFormat(), TraceContextTextMapPropagator()])
)
provider = TracerProvider(sampler=sampler, resource=resource)
provider.add_span_processor(
Expand Down