Skip to content

feat(exporters): add user-agent enrichment #4560

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 10 commits into
base: main
Choose a base branch
from

Conversation

david-luna
Copy link

Fixes #4479

Changes

Document that exporters may allow a user-agent option to append a product identifier to the exporter User Agent header. such option is only available via local var (not environment)

For non-trivial changes, follow the change proposal process.

@david-luna david-luna marked this pull request as ready for review June 23, 2025 14:16
@david-luna david-luna requested review from a team as code owners June 23, 2025 14:16
@@ -208,6 +208,21 @@ OTel-OTLP-Exporter-Python/1.2.3

The format of the header SHOULD follow [RFC 7231][rfc-7231]. The conventions used for specifying the OpenTelemetry SDK language and version are available in the [Resource semantic conventions][resource-semconv].

Exporters MAY expose a configuration option to append a product identifier to the User-Agent
header as defined in [RFC 7231][rfc-7231]. Such option should not be available as
Copy link
Contributor

Choose a reason for hiding this comment

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

SHOULD NOT (even MUST NOT?)

Copy link
Author

Choose a reason for hiding this comment

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

I agree with MUST NOT. Thanks @carlosalberto :)

commit d7d96d7

@carlosalberto
Copy link
Contributor

Maybe Collector folks should review this too @mx-psi ?

@mx-psi
Copy link
Member

mx-psi commented Jun 30, 2025

My understanding is that Collector components are not, as a general rule, bound by the spec. I guess we can add this to our coding guidelines in the Collector as well if it gets approved here to make sure it is followed

@david-luna david-luna requested a review from carlosalberto June 30, 2025 18:48
Copy link

github-actions bot commented Jul 8, 2025

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Jul 8, 2025
@trentm
Copy link
Contributor

trentm commented Jul 10, 2025

not stale

@david-luna
Copy link
Author

@open-telemetry/spec-sponsors sorry for the noise but I do not know exactly who to ping for this review

Copy link
Member

@reyang reyang left a comment

Choose a reason for hiding this comment

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

LGTM assuming a changelog entry will be added.

@github-actions github-actions bot removed the Stale label Jul 11, 2025
Copy link

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Jul 18, 2025
@david-luna
Copy link
Author

LGTM assuming a changelog entry will be added.

thanks @reyang for your review. Entry has been added in 3af4d2a

@github-actions github-actions bot removed the Stale label Jul 23, 2025
@david-luna
Copy link
Author

@david-luna
Copy link
Author

Comment on lines +213 to +216
Exporters MAY expose a configuration option to append a product identifier to the User-Agent
header as defined in [RFC 7231][rfc-7231]. Such option MUST NOT be available as
an environment variable since is meant to be used by [distributions][opentelemetry-distribution]
to append their product identifier along with the exporter's one.
Copy link
Member

Choose a reason for hiding this comment

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

Seems odd to me to explicitly call out no env vars but make this configurable in code. I assume the idea behind disallowing env support is to prevent users from setting this or overriding the distro, but if it's a config they can do that anyway. Should this be hidden entirely from users by e.g. making it a protected class property that a distro would override in a subclass?

Copy link
Member

Choose a reason for hiding this comment

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

even if Env variable exists, it cannot override the code based setting, as code wins over env variable in almost all OTel implementations.

Copy link
Author

Choose a reason for hiding this comment

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

This decision comes from the discussion in #4230

At the time of creating the issue in opentelemetry-js it was possible to override the user agent header and we concluded it was not a good idea let the user control completely it's value via en vars.

Copy link

@xrmx xrmx Aug 14, 2025

Choose a reason for hiding this comment

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

Maybe instead of being precise about how people can interact with that (e.g. references to environment variables) we can just say that users (distro developers / end users) MAY change the user agent but the updated one MUST SHOULD be a superset of the OTel one?

above example would report the following:

```
OTel-OTLP-Exporter-Python/1.2.3 MyDistribution/x.y.z
Copy link
Member

Choose a reason for hiding this comment

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

Should this be MyDistribution/x.y.z OTel-OTLP-Exporter-Python/1.2.3 instead? The distribution (user's application) is typically more significant for identification than the underlying exporter library.

Also suggested here - https://www.rfc-editor.org/rfc/rfc9110#name-user-agents

User-Agent: CERN-LineMode/2.15 libwww/2.17b3

the first one is the application (browser), and second one is the library used by it.

Copy link
Author

Choose a reason for hiding this comment

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

I agree. I'll change it when I get back from vacation.

an environment variable since is meant to be used by [distributions][opentelemetry-distribution]
to append their product identifier along with the exporter's one.

SDKs MAY expose a similar configuration option if exporters have it. This configuration
Copy link
Member

Choose a reason for hiding this comment

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

Not sure of the reasoning behind this being an SDK feature... this looks quite specific to the OTLP Exporter...Could you clarify why SDK is mentioned here?

Copy link
Author

Choose a reason for hiding this comment

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

Is not mandatory but quite convenient to not to have to provide the default processors and exporters just to append a value in the headers. It's just for making the setup shorter. I'm totally fine removing that part

to append their product identifier along with the exporter's one.

SDKs MAY expose a similar configuration option if exporters have it. This configuration
MUST be overridable by a signal specific option.
Copy link
Member

Choose a reason for hiding this comment

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

signal specific option - need some clarity on this is referring to..

Copy link
Author

Choose a reason for hiding this comment

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

I can add an example if we finally decide to have the option for sdks.

@carlosalberto
Copy link
Contributor

Ping @david-luna

@david-luna
Copy link
Author

@carlosalberto sorry for the delay but I'm on vacation with limited connection. I did answer the comments the best I could from my phone and will resume work when back on the 18th

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.

[protocol/exporter] allow SDK users to enrich the user-agent header in exporters
9 participants