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

Configurable span attributes based on gRPC Metadata keys #6979

Closed
fujin opened this issue Oct 26, 2022 · 3 comments
Closed

Configurable span attributes based on gRPC Metadata keys #6979

fujin opened this issue Oct 26, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@fujin
Copy link

fujin commented Oct 26, 2022

Describe the solution you'd like
I would like to be able to specify certain gRPC Custom Metadata keys from which Span Attributes should be set on the span for the RPC.

Similar to https://opentelemetry.io/docs/instrumentation/java/automatic/agent-config/#capturing-http-request-and-response-headers

Describe alternatives you've considered

  • Manually propagating the value out of the grpc metadata
  • Trying something like the CustomAttributesExtractor here:
    private static class CustomAttributesExtractor
    implements AttributesExtractor<GrpcRequest, Status> {
    @Override
    public void onStart(
    AttributesBuilder attributes, Context parentContext, GrpcRequest grpcRequest) {}
    @Override
    public void onEnd(
    AttributesBuilder attributes,
    Context context,
    GrpcRequest grpcRequest,
    @Nullable Status status,
    @Nullable Throwable error) {
    Metadata metadata = grpcRequest.getMetadata();
    if (metadata != null && metadata.containsKey(CUSTOM_METADATA_KEY)) {
    String value = metadata.get(CUSTOM_METADATA_KEY);
    if (value != null) {
    attributes.put(CUSTOM_KEY, value);
    }
    }
    }

edit: Severin Neumann in the CNCF slack pointed out open-telemetry/opentelemetry-specification#2843

@fujin fujin added the enhancement New feature or request label Oct 26, 2022
@Tavh
Copy link
Contributor

Tavh commented Oct 30, 2022

Recently opened and started working on this issue: #6991
Isn't it pretty much the same?

@Tavh
Copy link
Contributor

Tavh commented Oct 31, 2022

You're welcome to check out my PR in this subject

#7011

@fujin
Copy link
Author

fujin commented Oct 31, 2022

@Tavh I suppose this should be closed then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants