-
Notifications
You must be signed in to change notification settings - Fork 916
Remove component provider generic type #7606
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
Remove component provider generic type #7606
Conversation
696ddc4 to
03ea864
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7606 +/- ##
============================================
- Coverage 90.18% 90.16% -0.03%
+ Complexity 7226 7225 -1
============================================
Files 820 820
Lines 21790 21794 +4
Branches 2135 2136 +1
============================================
- Hits 19651 19650 -1
- Misses 1468 1472 +4
- Partials 671 672 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
391e7a6 to
d25ee3c
Compare
|
|
||
| assertThat(exporter.toString()).isEqualTo(expectedExporter.toString()); | ||
|
|
||
| assertThat(exporter.toString()).isEqualTo(expectedExporter.toString()); |
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 just removing an existing duplicative line
|
|
||
| assertThat(exporter.toString()).isEqualTo(expectedExporter.toString()); | ||
|
|
||
| assertThat(exporter.toString()).isEqualTo(expectedExporter.toString()); |
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 just removing an existing duplicative line
c3590d0 to
6c64fe5
Compare
6c64fe5 to
5a22503
Compare
breedx-splk
left a comment
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.
Thanks, this looks good to me.
Java generics strike again..... 🙈
| OtlpHttpSpanExporter expectedExporter = OtlpHttpSpanExporter.getDefault(); | ||
| OtlpHttpSpanExporter expectedExporter = | ||
| OtlpHttpSpanExporter.getDefault().toBuilder() | ||
| .setComponentLoader(capturingComponentLoader) // needed for the toString() check to pass |
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.
bummer, but yeah ok.
.../test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/CapturingComponentLoader.java
Show resolved
Hide resolved
|
I'm fine with it. Don't know if we want to wait for @jack-berg or ask for forgiveness if he hates the change? |
| // TODO (jack-berg): consider dynamic configuration use case before stabilizing in case that | ||
| // affects any API decisions | ||
| T create(DeclarativeConfigProperties config); | ||
| Object create(DeclarativeConfigProperties config); |
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.
that feels very odd to me - like deliberately defeating the type checker
|
I don't think this is a good idea - in makes the API less clear than it is now |
|
It is great you attempted to solve this coding issue, however I'd say that old implementation has some important strengths that are missing in new generic-less approach. Maybe it's just me, but in my opinion this API becomes somehow "fragile" now. |
|
This will cause disruption on PPL implementing their own exporters. |
|
I'd support this. In instrumentation repo after changing a module that contains a |
|
@jack-berg @jkwatson reopening because this is two problems now that this generic type is causing for downstream consumers |
…ovider-generic-type
ugh, this just bit me today |
jack-berg
left a comment
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.
I don't hate this. Its a bit more error prone than the generic version, but a bit more user friendly because it avoids errors with autoservice tooling. Its weird that autoservice throws this error given how popular generic types are for other common autoservice use cases like DAOs. 🤷
**Sorry wrote this review on 10/28 but apparently forgot to hit the submit button 🤦 **
.../test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/CapturingComponentLoader.java
Show resolved
Hide resolved
...lemetry/sdk/extension/incubator/fileconfig/component/LogRecordExporterComponentProvider.java
Show resolved
Hide resolved
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.
I think we need to add an additional check here to check if create returns the same type as getType().
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.
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.
great - that restores the type safety (even though only at runtime)
The generic type makes it awkward to use with
@AutoService, because it requires you to useSuppressWarnings("rawtypes")(some background at google/auto#870), e.g.https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/c7dd76454f5af080a1c385fdb7fda2c6bace68f5/instrumentation/resources/library/src/main/java/io/opentelemetry/instrumentation/resources/internal/ProcessResourceComponentProvider.java#L19-L20
Plus, it doesn't seem like we lose much by removing the generic type (in fact it ends up being slightly less code).