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] Add Tracer instrumentationVersion (ie otel.library.version) #191

Merged

Conversation

cyrille-leclerc
Copy link
Member

Description:

Add Tracer instrumentationVersion (ie otel.library.version attribute).

Existing Issue(s):

Testing:

Tested manually.
No unit test because algorithm relies on the jar manifest implementationVersion that is not available during the unit tests.

Documentation:

None

Outstanding items:

None

if (otelMavenExtensionVersion != null) {
tracerBuilder.setInstrumentationVersion(otelMavenExtensionVersion);
}
this.tracer = tracerBuilder.build();
Copy link
Member

Choose a reason for hiding this comment

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

Do we need the null check? From looking at the implementation it appears we can go with:

this.tracer = this.openTelemetry.getTracer("io.opentelemetry.contrib.maven", this.getClass().getPackage().getImplementationVersion());

Copy link
Member Author

@cyrille-leclerc cyrille-leclerc Jan 14, 2022

Choose a reason for hiding this comment

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

I initially started like this as implementationVersion will only be null in unit tests.

However, I hardened the code because null is a violation of the contractOpenTelemetry#getTracer(@Nonnull instrumentationName, @Nonnull instrumentationVersion).

It's probably an acceptable violation of the contract as the implementation supports null and we would not be afraid of regressions if the implementation starts rejecting null instrumentationVersion because it would fail in unit tests.

So if you are ok with this light violation, I'm happy to simplify the code and adopt your proposal.

Copy link
Member Author

Choose a reason for hiding this comment

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

@kenfinnigan please review the proposed code change. Slightly different from your suggestion in order to also output the otel maven extension version in the logs.

Copy link
Member

@kenfinnigan kenfinnigan left a comment

Choose a reason for hiding this comment

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

I'm ok with this approach as VERSION should only be null if there was a problem of some kind

@trask trask merged commit be003da into open-telemetry:main Jan 14, 2022
@@ -25,6 +25,9 @@
@Component(role = OpenTelemetrySdkService.class, hint = "opentelemetry-service")
public final class OpenTelemetrySdkService implements Initializable, Disposable {

public static final String VERSION =
OpenTelemetrySdkService.class.getPackage().getImplementationVersion();
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we want to expose this as a public field

Copy link
Member

Choose a reason for hiding this comment

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

Good point @anuraaga, I'd missed that.

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, PR created #198

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants