[monitoring] Add telemetry in router #1391
Open
the-glu wants to merge 6 commits intointeruss:masterfrom
Open
Conversation
This was referenced Mar 11, 2026
mickmis
reviewed
Mar 11, 2026
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) |
Contributor
There was a problem hiding this comment.
I don't fully understand what this is doing:
- shouldn't we prevent calling
tracer.Startif 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'
Contributor
Author
There was a problem hiding this comment.
- No need for that, the api take care of handling it in the back.
IsRecordingcheck 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".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add telemetry directly in router, providing clean tracenames.
Follow #1390 and #1365
Example server tested with
./run_example.shand still working as expected.Name has been removed from default handler, meaning unknown route or
/healthywill just be named 'http', but that probably ok.Router set parent trace name to the path + start a span for actual processing.
Example traces: