open-telemetry / opentelemetry-java-instrumentation

OpenTelemetry auto-instrumentation and instrumentation libraries for Java
https://opentelemetry.io
Apache License 2.0
1.79k stars 782 forks source link

re-use logic for http client configuration #11620

Closed zeitlinger closed 1 week ago

zeitlinger commented 1 week ago

doesn't cover add libraries yet - but is already usable as is

Trimmed down version of https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/11605

zeitlinger commented 1 week ago

@trask thanks for the review - nothing I feel strongly about, so I'm fine with adjusting if you feel it makes it clearer

trask commented 1 week ago

@trask thanks for the review - nothing I feel strongly about, so I'm fine with adjusting if you feel it makes it clearer

let's try to land this as a nice proposal on its own to eliminate the error prone copy-paste and deal with future concerns in follow-up

zeitlinger commented 1 week ago

@trask thanks for the review - nothing I feel strongly about, so I'm fine with adjusting if you feel it makes it clearer

let's try to land this as a nice proposal on its own to eliminate the error prone copy-paste and deal with future concerns in follow-up

ok, changed accordingly

trask commented 1 week ago

I tried out a couple of renames that helped a bit I think: https://github.com/zeitlinger/opentelemetry-java-instrumentation/pull/3

laurit commented 1 week ago

This PR introduces breaking changes to library instrumentations (code compiled against old library instrumentation will fail with new version). Is this ok?

trask commented 1 week ago

This PR introduces breaking changes to library instrumentations (code compiled against old library instrumentation will fail with new version). Is this ok?

is this because we moved the methods up to super class? (i.e. it's a source compatible change but not a binary compatible change?)

I did want to at least discuss the option of interface (with delegation) instead of abstract base class (as @breedx-splk has this always in my mind now)

zeitlinger commented 1 week ago

This PR introduces breaking changes to library instrumentations (code compiled against old library instrumentation will fail with new version). Is this ok?

is this because we moved the methods up to super class? (i.e. it's a source compatible change but not a binary compatible change?)

yes

I did want to at least discuss the option of interface (with delegation) instead of abstract base class (as @breedx-splk has this always in my mind now)

I thought about it. I don't like the big amount of copy-paste that this means - but it would work.

Lombok can automate that, but I think wo don't use it: https://projectlombok.org/features/experimental/Delegate

laurit commented 1 week ago

I did want to at least discuss the option of interface (with delegation) instead of abstract base class (as @breedx-splk has this always in my mind now)

Delegation would allow handling telemetry builders that configure both a http server and client like https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaTelemetryBuilder.java

zeitlinger commented 1 week ago

I did want to at least discuss the option of interface (with delegation) instead of abstract base class (as @breedx-splk has this always in my mind now)

Delegation would allow handling telemetry builders that configure both a http server and client like https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaTelemetryBuilder.java

unfortunately not, because some properties have different names, e.g. setClientSpanNameExtractor vs setSpanNameExtractor

zeitlinger commented 1 week ago

changed to delegation as discussed - wasn't too bad actually :smile:

zeitlinger commented 1 week ago

I think with the two suggestions below, then there will be no new public API and this will be easy to merge, and will be easier to review the follow-up changes

@trask done