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

[Maven-Extension] Use Auto Configure Otel SDK Builder #132

Merged
merged 16 commits into from
Nov 27, 2021

Conversation

cyrille-leclerc
Copy link
Member

@cyrille-leclerc cyrille-leclerc commented Nov 17, 2021

Description:

Simplify Maven Extension configuration code using the new Otel Java SDK Auto Configuration Builder

Existing Issue(s):

Testing:

Unfortunately not yet integration tests on the MAven Extension, I don't know how to do this yet.

Documentation:

No documentation needed

Outstanding items:

  • TODO delayed by a bug of Intellij to load the opentelemetry-java-contrib on Cyrille's laptop

autoConfiguredSdkBuilder.addPropertiesSupplier(
() -> {
Map<String, String> properties = new HashMap<>();
if ((OtelUtils.getSysPropOrEnvVar("otel.traces.exporter") == null)
Copy link
Contributor

Choose a reason for hiding this comment

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

I mentioned it in another comment but how about just default to none regardless of endpoint variable? I think it's reasonable enough to export to localhost, and going from zero to two properties for a remote endpoint isn't that much harder than going from zero to one.

It seems simpler to document, just
The default value for exporter is none
The default value for endpoint is localhost:4317

Instead of

The default value for exporters is none, unless endpoint is explicitly passed in which case it is OTLP.
And endpoint effectively doesn't have a default value.

Former just seems simpler to me, and also fits better with non-otlp exporters which have their own endpoint variables.

Copy link
Member Author

Choose a reason for hiding this comment

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

💯 The change you propose would simplify integration of the Otel SDK in apps like Maven or Jenkins.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I didn't mean changing the default of the OTel SDK itself (which is defined by the OTel spec) but just here, removing this if statement. We have a general stance of avoiding having default values of two variables associated with each other

open-telemetry/opentelemetry-specification#1895 (comment)

Which I think we have here. I don't see the usability drop to be significant enough if a user needs to set both OTEL_TRACES_EXPORTER and OTEL_EXPORTER_OTLP_ENDPOINT to send to a remote backend to not follow this general policy. Is it ok?

Copy link
Member

Choose a reason for hiding this comment

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

I've been trying to figure out from the history but can't seem to.

Is this comment still applicable @anuraaga or was it resolved @cyrille-leclerc?

Happy to review/approve when it's clear

Copy link
Contributor

Choose a reason for hiding this comment

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

Think this comment is still applicable. @cyrille-leclerc what do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry for the delay, I was not sure to understand.

Do you mean that we would change the default behaviour of the "OpenTelemetry SDK Autoconfigure" so that the default value for OTEL_TRACES_EXPORTER who no longer be otlp but be none (official doc here)?

This change would make OTEL_TRACES_EXPORTER behave the same way OTEL_METRICS_EXPORTER behave, correct?

I have few questions please:

  • Is it correct that on the Otel Java agent, OTEL_TRACES_EXPORTER defaults to otlp when OTEL_METRICS_EXPORTER defaults to none making many users missing Java metrics not catching this subtle nuance of default value?
  • Would this be a breaking change for Otel Java Agent with many existing deployments not defining any of OTEL_TRACES_EXPORTER and OTEL_EXPORTER_OTLP_ENDPOINT, these deployments would suddenly loose tracing
  • The duality OTEL_TRACES_EXPORTER / OTEL_METRICS_EXPORTER is probably becoming verbose boilerplate with the rise of Otel metrics, including the rising support of metrics in observability backends (e.g. Jaeger is adding support for metrics via PromQL). This verbosity will even increase with the introduction of OTEL_LOGS_EXPORTER soon. Would it make sense to introduce a generic OTEL_EXPORTER so that the Java SDK exports all the signals it collects to the specified exporter?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry if I wasn't clear - I don't mean to change the behavior of SDK autoconfigure (specifically, code in the opentelemetry-java repo) but just to change the defaults here. I'd like to remove handling of endpoint here so that

  • No settings: No export
  • OTEL_EXPORTER_OTLP_ENDPOINT=opentelemetry.io: No export
  • OTEL_TRACES_EXPORTER=otlp: Exports to default localhost address
  • OTEL_TRACES_EXPORTER=otlp OTEL_EXPORTER_OTLP_ENDPOINT=opentelemetry.io: Exports to opentelemetry.io

I know you are trying to make it simpler to use a remote endpoint, but I believe this provides a more consistent experience with our normal conventions, and don't believe the user experience difference for users of a remote endpoint to be negative enough in practice.

Notably, one issue I find with the current behavior is that
OTEL_TRACES_EXPORTER has a default value of none. Yet these two sets have different behavior

  • OTEL_EXPORTER_OTLP_ENDPONT=opentelemetry.io: Exports
  • OTEL_TRACES_EXPORTER=none OTEL_EXPORTER_OTLP_ENDPOINT=opentelemetry.io: Doesn't export

The behavior shouldn't be different since the default value of OTEL_TRACES_EXPORTER is none - we've just added a confusing caveat that the default is different based on the presence of another variable, something we would like to avoid.

This seems like an inconsistent experience. Does it make sense? I can add a commit directly to the PR if things are still unclear, let me know.

Would it make sense to introduce a generic OTEL_EXPORTER so that the Java SDK exports all the signals it collects to the specified exporter?

This is an interesting topic - it doesn't affect OTel "normally" since exporters all default to the value otlp. There is no value other than otlp that would satisfy OTEL_EXPORTER because zipkin doesn't do metrics, etc. It does affect this sort of use case where it is a good idea to change the normal default of otlp to none - we would need to discuss in spec if that means the OTEL_EXPORTER variable would be good to have for this use case.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for you patience @anuraaga , I hope I understood well your point, please check the updated code, it's greatly simplified.

@cyrille-leclerc cyrille-leclerc marked this pull request as ready for review November 17, 2021 16:32
@cyrille-leclerc cyrille-leclerc requested a review from a team November 17, 2021 16:32
@cyrille-leclerc cyrille-leclerc marked this pull request as draft November 17, 2021 22:15
@cyrille-leclerc cyrille-leclerc marked this pull request as ready for review November 17, 2021 23:12
Copy link
Contributor

@anuraaga anuraaga left a comment

Choose a reason for hiding this comment

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

Thanks! Just a couple small points - I think we can remove the getSysPropOrEnv methods too :)

cyrille-leclerc added a commit to jenkinsci/opentelemetry-plugin that referenced this pull request Nov 26, 2021
AutoConfiguredOpenTelemetrySdk.builder();

// SDK CONFIGURATION PROPERTIES
autoConfiguredSdkBuilder.addPropertiesSupplier(
Copy link
Contributor

Choose a reason for hiding this comment

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

It'll be cool if we can follow with populating this with XML properties from the POM file :)

@anuraaga anuraaga merged commit 92998b6 into open-telemetry:main Nov 27, 2021
@cyrille-leclerc cyrille-leclerc deleted the use-auto-configure-v2 branch November 27, 2021 15:19
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