Skip to content

[monitoring] Add telemetry in router #1391

Open
the-glu wants to merge 6 commits intointeruss:masterfrom
Orbitalize:openapi_add_telemetry
Open

[monitoring] Add telemetry in router #1391
the-glu wants to merge 6 commits intointeruss:masterfrom
Orbitalize:openapi_add_telemetry

Conversation

@the-glu
Copy link
Contributor

@the-glu the-glu commented Mar 11, 2026

Add telemetry directly in router, providing clean tracenames.

Follow #1390 and #1365

Example server tested with ./run_example.sh and still working as expected.

Name has been removed from default handler, meaning unknown route or /healthy will just be named 'http', but that probably ok.

image_2026-03-11_10-40-38

Router set parent trace name to the path + start a span for actual processing.
Example traces:

image_2026-03-11_10-37-40 image_2026-03-11_10-38-11

Copy link
Contributor

@mickmis mickmis left a comment

Choose a reason for hiding this comment

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

Reviewed dd31308

Comment on lines +18 to +27
span := trace.SpanFromContext(r.Context())

if span.IsRecording() {
// Current span is the one from the otelhttp handler
span.SetName(fmt.Sprintf("%s %s", r.Method, route.Path))
}

ctx, span := tracer.Start(r.Context(), route.Name)
defer span.End()
r = r.WithContext(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't fully understand what this is doing:

  • shouldn't we prevent calling tracer.Start if tracing is disabled? no check is done here
  • except if that is the intent with IsRecording? but I don't understand what this returns exactly, what does it mean to be recording? this seems to hint at the fact this this is not exactly equivalent to 'is tracing enabled'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • No need for that, the api take care of handling it in the back.
  • IsRecording check if we can edit the current span name. Should no handler be attached, a dummy span will be returned and we cannot edit it name (or for some reason, the span form otelhttp is not editable). But basically, it come down to "can we set it name".

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