-
Notifications
You must be signed in to change notification settings - Fork 843
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
don't throw class cast exception when we have a noop tracer, meter, logger #6617
don't throw class cast exception when we have a noop tracer, meter, logger #6617
Conversation
You can't make the api depend on the incubator; that introduces a circular dependency, since the incubator depends on the api. |
right - this is real problem because of opentelemetry-java/api/all/src/main/java/io/opentelemetry/api/trace/TracerProvider.java Lines 23 to 25 in 963bc38
we could deprecate the method BTW, the same issue applies to all "Extended..." apis |
53a4bf2
to
34d8759
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6617 +/- ##
============================================
+ Coverage 89.99% 90.09% +0.10%
- Complexity 6358 6390 +32
============================================
Files 703 711 +8
Lines 19147 19333 +186
Branches 1889 1891 +2
============================================
+ Hits 17231 17418 +187
+ Misses 1337 1335 -2
- Partials 579 580 +1 ☔ View full report in Codecov by Sentry. |
@jack-berg can you check? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems pretty reasonable but I wonder about:
- Code reuse by moving existing default implementations to internal package and removing the
final
modifier. - Testing graal both with and without the incubating artifact on the class path
api/all/src/main/java/io/opentelemetry/api/DefaultOpenTelemetry.java
Outdated
Show resolved
Hide resolved
api/all/src/testFixtures/java/io/opentelemetry/api/logs/AbstractDefaultLoggerTest.java
Show resolved
Hide resolved
api/all/src/testFixtures/java/io/opentelemetry/api/metrics/AbstractDefaultMeterTest.java
Show resolved
Hide resolved
api/all/src/testFixtures/java/io/opentelemetry/api/AbstractOpenTelemetryTest.java
Show resolved
Hide resolved
testFixturesApi(project(":testing-internal")) | ||
testFixturesApi("junit:junit") | ||
testFixturesApi("org.assertj:assertj-core") | ||
testFixturesApi("org.mockito:mockito-core") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the first usage of java-test-fixtures in this repo. I kind of like it, but would be good to update otel.java-conventions.gradle.kts
to include all the standard test dependencies:
https://github.com/open-telemetry/opentelemetry-java/blob/main/buildSrc/src/main/kotlin/otel.java-conventions.gradle.kts#L237-L270
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you give me a hint how to do that? fixtures {
or similar doesn't exist
|
||
/** No-op implementation of {@link ExtendedTracer}. */ | ||
@ThreadSafe | ||
final class ExtendedDefaultTracer implements ExtendedTracer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about restructuring the existing default implementations to allow subclassing:
final class ExtendedDefaultTracer implements ExtendedTracer { | |
final class ExtendedDefaultTracer extends DefaultTracer implements ExtendedTracer { |
Would have to make them public in an internal package, and more, but the payoff would be the ability to reuse code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it wouldn't help because the extended span builder has to return it's own (ExtendedSpanBuilder) type, so we have to implement all methods
api/incubator/src/test/java/io/opentelemetry/api/incubator/trace/ExtendedDefaultTracerTest.java
Outdated
Show resolved
Hide resolved
can you elaborate? |
added |
4dba428
to
a83b06c
Compare
a83b06c
to
a95e6ff
Compare
…y-java into avoid-class-cast-exception
thanks @jack-berg |
similar to open-telemetry/opentelemetry-java-instrumentation#11934