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

feat: allow to add attributes from grpc metadata in the patched server #3589

Conversation

zombispormedio
Copy link
Contributor

Which problem is this PR solving?

It's not possible to add span attributes using the metadata in the gRPC server side.

The metadataToSpanAttributes config option from opentelemetry-instrumentation-grpc is not working for server calls according to the issue #3534

Short description of the changes

The change allows to configure the metadata keys that have to be added to the span attributes following the same way as client side. The request metadata capturing is done before handle the server and the response metadata capturing is done patching the "sendMetadata" method from the server call.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

In the current opentelemetry-instrumentation-grpc tests, adding the server part in metadataToSpanAttributes config and contemplating the result in the span attributes validation.

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation has been updated

…adataToSpanAttributes

Signed-off-by: Xavier Serrano <zombispormedio007@gmail.com>
@zombispormedio zombispormedio requested a review from a team February 4, 2023 15:52
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Feb 4, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: zombispormedio / name: Xavier Serrano (778012c)

Signed-off-by: Xavier Serrano <zombispormedio007@gmail.com>
@codecov
Copy link

codecov bot commented Feb 6, 2023

Codecov Report

Merging #3589 (06b0d37) into main (cbbdfd3) will increase coverage by 3.08%.
The diff coverage is 100.00%.

❗ Current head 06b0d37 differs from pull request most recent head 9d6257d. Consider uploading reports for the commit 9d6257d to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3589      +/-   ##
==========================================
+ Coverage   90.56%   93.64%   +3.08%     
==========================================
  Files          84      275     +191     
  Lines        1802     8090    +6288     
  Branches      362     1679    +1317     
==========================================
+ Hits         1632     7576    +5944     
- Misses        170      514     +344     
Impacted Files Coverage Δ
...elemetry-instrumentation-grpc/src/grpc-js/index.ts 92.74% <100.00%> (ø)
...entelemetry-instrumentation-grpc/src/grpc/index.ts 94.28% <100.00%> (ø)
api/src/propagation/TextMapPropagator.ts 14.28% <0.00%> (-3.90%) ⬇️
api/src/baggage/utils.ts 100.00% <0.00%> (ø)
...elemetry-exporter-zipkin/src/platform/node/util.ts 96.77% <0.00%> (ø)
...etry-exporter-prometheus/src/PrometheusExporter.ts 96.25% <0.00%> (ø)
...ntal/packages/otlp-grpc-exporter-base/src/types.ts 100.00% <0.00%> (ø)
packages/sdk-metrics/src/Meter.ts 100.00% <0.00%> (ø)
...metry-instrumentation-grpc/src/grpc/clientUtils.ts 89.18% <0.00%> (ø)
...ckages/opentelemetry-browser-detector/src/types.ts 100.00% <0.00%> (ø)
... and 190 more

Copy link
Member

@samimusallam samimusallam left a comment

Choose a reason for hiding this comment

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

Thank you for working on this! Just left a few comments.

@dyladan dyladan merged commit 2f715bd into open-telemetry:main Mar 3, 2023
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.

3 participants