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

add pomerium_otel tracer extension #1

Merged
merged 5 commits into from
Jan 9, 2025
Merged

add pomerium_otel tracer extension #1

merged 5 commits into from
Jan 9, 2025

Conversation

kralicky
Copy link
Collaborator

@kralicky kralicky commented Jan 8, 2025

This adds a new tracer extension called pomerium_otel, which extends the default opentelemetry tracer and adds a couple of additional pomerium-specific features:

1. Trace ID overriding via header

When starting a span:

  • If the associated HTTP request contains an x-pomerium-traceparent or x-pomerium-traceid header (set in the early header mutation extension), the randomly generated trace ID will be replaced with the trace ID contained in the header value.
  • If the associated HTTP request contains the x-pomerium-sampling-decision header, the sampling decision will be forced on or off, depending on the value of the header ("1" or "0" respectively).

2. Route decorator variables

If configured, Envoy will use a route's decorator as the span operation name for spans created from HTTP requests for that route. This extends the otel Span to override its setOperation with logic to substitute the strings ${path}, ${method}, ${host}, or ${protocol} with the actual values for that request.

// the query parameters are standard and managed by oauth2 clients
const auto state = params.getFirstValue(Envoy::Http::LowerCaseString("state"));
if (state.has_value()) {
const std::string stateDecoded =

Choose a reason for hiding this comment

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

Is the format of the state value documented somewhere? It might be helpful to add a comment here describing the format and/or showing an example value.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Only in the authenticate service here. I can definitely add some comments here and an example.

name_substitutions);

if (auto tp = pomeriumTraceParentHeader().get(trace_context);
tp.has_value() && tp->size() == 55) {

Choose a reason for hiding this comment

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

I'd suggest adding a comment here about where the numbers 55, 3, 32 come from.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, good idea.

@kralicky kralicky merged commit 15a04c1 into main Jan 9, 2025
1 check passed
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