Skip to content

opentelemetry-exporter-otlp-proto-grpc: set grpc user agent properly #4658

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

xrmx
Copy link
Contributor

@xrmx xrmx commented Jun 25, 2025

Description

It looks like metadata is not used for setting http User-agent header when using the grpc exporter and instead we should set the grpc.primary_user_agent channel option instead. User-agent will change from:

grpc-python/1.71.0 grpc-c/46.0.0 (linux; chttp2)

to:

OTel-OTLP-Exporter-Python/1.34.1 grpc-python/1.71.0 grpc-c/46.0.0 (linux; chttp2)

Fixes #4657

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?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A

Does This PR Require a Contrib Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

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

@xrmx xrmx force-pushed the fix-otlp-grpc-exporter-user-agent branch from 0553378 to bed8002 Compare June 26, 2025 08:21
@xrmx xrmx changed the title opentelemetry-exporter-otlp-proto-grpc: set user agent properly opentelemetry-exporter-otlp-proto-grpc: set grpc user agent properly Jun 26, 2025
@xrmx xrmx marked this pull request as ready for review June 26, 2025 09:07
@xrmx xrmx requested a review from a team as a code owner June 26, 2025 09:07
@@ -60,6 +60,7 @@ def __init__(
] = None,
timeout: Optional[float] = None,
compression: Optional[Compression] = None,
channel_options: Optional[TypingSequence[Tuple[str, str]]] = None,
Copy link
Member

Choose a reason for hiding this comment

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

Seems fine to me. I guess the alternative is allowing to pass a gRPC channel directly, but then the user has to configure all the other options.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't expect enduser to play with this, I've opened this for being able to pass exporter params from sdk configuration #4659

Copy link
Member

Choose a reason for hiding this comment

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

Not blocking just a callout

Copy link
Contributor Author

@xrmx xrmx Jun 26, 2025

Choose a reason for hiding this comment

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

Thinking about http though maybe it makes more sense to use a shared way for providing the user agent? OTOH it may useful to tune some other grpc options

@@ -73,4 +73,9 @@
from .version import __version__

_USER_AGENT_HEADER_VALUE = "OTel-OTLP-Exporter-Python/" + __version__
# these will be sent as grpc metadata
_OTLP_GRPC_HEADERS = [("user-agent", _USER_AGENT_HEADER_VALUE)]
Copy link
Member

Choose a reason for hiding this comment

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

I think the user-agent entry here is maybe a no-op and could be removed. IIRC gRPC C++ unconditionally overwrites this metadata key which is why we need to pass it through the channel options.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, that's the case, removed.

xrmx added 3 commits June 27, 2025 14:40
It looks like metadata is ignored and instead we should set the
grpc.primary_user_agent channel option instead. User-agent will change
from:
grpc-python/1.71.0 grpc-c/46.0.0 (linux; chttp2)

to:
OTel-OTLP-Exporter-Python/1.34.1 grpc-python/1.71.0 grpc-c/46.0.0 (linux; chttp2)
@xrmx xrmx force-pushed the fix-otlp-grpc-exporter-user-agent branch from 649b5e8 to 3f4f7bd Compare June 27, 2025 13:00
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.

Send the exporter user agent in the grpc exporter
2 participants