-
Notifications
You must be signed in to change notification settings - Fork 773
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
Instrumentation.AspNetCore for gRPC services omits ALL rpc.* attributes under certain conditions #1740
Comments
@utpilla Can you investigate this? |
I have created a PR #1876 to add a failing unit test for this scenario. I see these four options to fix this issue. I have created a Draft PR for three of them:
@pcwiese @cijothomas Thoughts? Which of these options seems the best to go forward with? |
I think I like option 3 the best because it continues to rely on the same side-effect of the library adding tags to a specific Activity. I'm intrigued by option 1, because it seems to move away from relying on the library's side-effect. Though, I haven't studied this enough to know if relying on the request's ContentType and Path will be reliable. Also, as you've noted, still not sure how to handle status code. Side note, I'm a bit embarrassed to say, but I'm still a little unclear on why we create sibling Activity in some circumstances... |
These libraries (asp.net core etc), creates Activities and sets its parent as the ones extracted from traceparent header (hardcoded). |
I would agree that Option 3 also sounds the most appealing and it is the path I took to patch a private version of this assembly that our team is using. |
Bug Report
NuGet package(s):
Runtimes:
Symptom
rpc.* attributes required for RPC Spans are not added to the created gRPC server Span under particular circumstances. All I see are http.* attributes. This happens when using a composite text map propagator made up of B3 and W3C in that order (B3 takes precedence if there). We have nginx and linkerd services sitting in front of these netcore gRPC services which understand and augment traces via the B3 headers before passing through to the gRPC service. Existing traceparent headers are treated as opaque data and forwarded unmodified as intended. The gRPC instrumentation correctly extracts the context from the B3 headers but still fails to output the rpc attributes.
This is happening because a new Activity is created in this block:
opentelemetry-dotnet/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs
Line 86 in ccc191f
The otel instrumentation looks for the presence of that grpc.method tag before adding the rpc.* tags.
What is the expected behavior?
rpc.* attributes are present according to https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/rpc.md
Repro
Add a composite propagator to the Examples.Grpc.Service. See the last commit on my test branch: pcwiese@6cc33a1
Start the Examples.Grpc.Service and hit it with a grpcurl request similar to this one:
The trace ids match between the traceparent header and B3 headers but the span ids do not. When you make the request you should see the rpc.* attributes outputted from the service but they aren't there.
Possible fix
Given that the Grpc.AspNetCore.Server NuGet package requires the Activity to be a certain name, we could simply create the Activity as we do now in the instrumentation library, but use the incoming Activity's OperationName instead of ActivityCreatedByHttpInListener. I tried this out locally and it does work but I'm sure what the implication of that is elsewhere.
The text was updated successfully, but these errors were encountered: