-
Notifications
You must be signed in to change notification settings - Fork 921
Extended opentelemetry #7496
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
Extended opentelemetry #7496
Changes from all commits
4e5b156
869b4d8
9f9dc92
fb8e571
f182ad2
30c578a
01a9383
fb08d7d
1f00dcb
cfd444b
0e0bc4e
c8bfbd4
e93fceb
96218f7
1147733
1807b62
00829e7
ecd9c7b
802c056
fed1754
6924bf5
fe34bb1
552dea2
92848a4
fa6c704
698b753
612c2c0
41c92ee
7a69952
30a0fe7
f917d9d
c5af0ef
c70b63d
53ec454
f66057c
06590dc
d5f2ce5
2ff74e2
10d7c47
215f832
c3e86da
4b7c986
a719606
c272687
f73aab1
e2584f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.api.incubator; | ||
|
|
||
| import io.opentelemetry.api.OpenTelemetry; | ||
| import io.opentelemetry.api.incubator.config.ConfigProvider; | ||
|
|
||
| /** Extension to {@link OpenTelemetry} with experimental APIs. */ | ||
| public interface ExtendedOpenTelemetry extends OpenTelemetry { | ||
| /** Returns the {@link ConfigProvider} for this {@link OpenTelemetry}. */ | ||
| default ConfigProvider getConfigProvider() { | ||
| return ConfigProvider.noop(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,10 @@ | ||
| Comparing source compatibility of opentelemetry-sdk-1.55.0-SNAPSHOT.jar against opentelemetry-sdk-1.54.0.jar | ||
| No changes. | ||
| *** MODIFIED CLASS: PUBLIC NON_FINAL (<- FINAL) io.opentelemetry.sdk.OpenTelemetrySdk (not serializable) | ||
| === CLASS FILE FORMAT VERSION: 52.0 <- 52.0 | ||
| *** MODIFIED METHOD: PUBLIC FINAL (<- NON_FINAL) io.opentelemetry.api.logs.LoggerProvider getLogsBridge() | ||
| *** MODIFIED METHOD: PUBLIC FINAL (<- NON_FINAL) io.opentelemetry.api.metrics.MeterProvider getMeterProvider() | ||
| *** MODIFIED METHOD: PUBLIC FINAL (<- NON_FINAL) io.opentelemetry.context.propagation.ContextPropagators getPropagators() | ||
| *** MODIFIED METHOD: PUBLIC FINAL (<- NON_FINAL) io.opentelemetry.sdk.logs.SdkLoggerProvider getSdkLoggerProvider() | ||
| *** MODIFIED METHOD: PUBLIC FINAL (<- NON_FINAL) io.opentelemetry.sdk.metrics.SdkMeterProvider getSdkMeterProvider() | ||
| *** MODIFIED METHOD: PUBLIC FINAL (<- NON_FINAL) io.opentelemetry.sdk.trace.SdkTracerProvider getSdkTracerProvider() | ||
| *** MODIFIED METHOD: PUBLIC FINAL (<- NON_FINAL) io.opentelemetry.api.trace.TracerProvider getTracerProvider() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These changes are technically breaking changes, yeah? If someone had implemented their own extension to OpenTelemetrySdk? I don't know how likely that is to be the case, but I could imagine a vendor doing it. How concerned are we about making all of these methods (and the class) final breaking someone's custom implementation?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The class was final before, so it was not possible to extend
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the class itself was final previously
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't that top line in the api diff say it's being made final? Am I reading that wrong?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh! it's the opposite. 🤦🏽
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, this, then, I guess, is the only thing that's possible a concern to think about...now people will be able to extend OpenTelemetrySdk, which could potentially cause future breaking changes, if we add methods and they collide with ones that have been added externally. 🤔
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's true. But I believe we're already exposed to similar risk: Consider the |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.sdk.extension.incubator; | ||
|
|
||
| import io.opentelemetry.api.incubator.ExtendedOpenTelemetry; | ||
| import io.opentelemetry.api.incubator.config.ConfigProvider; | ||
| import io.opentelemetry.api.incubator.config.DeclarativeConfigProperties; | ||
| import io.opentelemetry.sdk.OpenTelemetrySdk; | ||
| import io.opentelemetry.sdk.extension.incubator.fileconfig.SdkConfigProvider; | ||
| import java.io.Closeable; | ||
| import javax.annotation.Nullable; | ||
| import javax.annotation.concurrent.ThreadSafe; | ||
|
|
||
| /** A new interface for creating OpenTelemetrySdk that supports getting {@link ConfigProvider}. */ | ||
| public final class ExtendedOpenTelemetrySdk extends OpenTelemetrySdk | ||
| implements ExtendedOpenTelemetry, Closeable { | ||
|
|
||
| private final OpenTelemetrySdk openTelemetrySdk; | ||
| private final ObfuscatedConfigProvider configProvider; | ||
|
|
||
| private ExtendedOpenTelemetrySdk( | ||
| OpenTelemetrySdk openTelemetrySdk, SdkConfigProvider configProvider) { | ||
| super( | ||
| openTelemetrySdk.getSdkTracerProvider(), | ||
| openTelemetrySdk.getSdkMeterProvider(), | ||
| openTelemetrySdk.getSdkLoggerProvider(), | ||
| openTelemetrySdk.getPropagators()); | ||
| this.openTelemetrySdk = openTelemetrySdk; | ||
| this.configProvider = new ObfuscatedConfigProvider(configProvider); | ||
| } | ||
|
|
||
| public static ExtendedOpenTelemetrySdk create( | ||
| OpenTelemetrySdk openTelemetrySdk, SdkConfigProvider sdkConfigProvider) { | ||
| return new ExtendedOpenTelemetrySdk(openTelemetrySdk, sdkConfigProvider); | ||
| } | ||
|
|
||
| @Override | ||
| public ConfigProvider getConfigProvider() { | ||
| return configProvider; | ||
| } | ||
|
|
||
| /** Returns the {@link SdkConfigProvider} for this {@link ExtendedOpenTelemetrySdk}. */ | ||
| public SdkConfigProvider getSdkConfigProvider() { | ||
| return configProvider.unobfuscate(); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "ExtendedOpenTelemetrySdk{" | ||
| + "openTelemetrySdk=" | ||
| + openTelemetrySdk | ||
| + ", configProvider=" | ||
| + configProvider.unobfuscate() | ||
| + "}"; | ||
| } | ||
|
|
||
| /** | ||
| * This class allows the SDK to unobfuscate an obfuscated provider. | ||
| * | ||
| * <p>Static global providers are obfuscated when they are returned from the API to prevent users | ||
| * from casting them to their SDK specific implementation. For example, we do not want users to | ||
| * use patterns like {@code (SdkConfigProvider) openTelemetry.getConfigProvider()}. | ||
| */ | ||
| @ThreadSafe | ||
| private static class ObfuscatedConfigProvider implements ConfigProvider { | ||
|
|
||
| private final SdkConfigProvider delegate; | ||
|
|
||
| private ObfuscatedConfigProvider(SdkConfigProvider delegate) { | ||
| this.delegate = delegate; | ||
| } | ||
|
|
||
| @Override | ||
| @Nullable | ||
| public DeclarativeConfigProperties getInstrumentationConfig() { | ||
| return delegate.getInstrumentationConfig(); | ||
| } | ||
|
|
||
| private SdkConfigProvider unobfuscate() { | ||
| return delegate; | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |
| import io.opentelemetry.sdk.OpenTelemetrySdk; | ||
| import io.opentelemetry.sdk.autoconfigure.internal.SpiHelper; | ||
| import io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider; | ||
| import io.opentelemetry.sdk.extension.incubator.ExtendedOpenTelemetrySdk; | ||
| import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.OpenTelemetryConfigurationModel; | ||
| import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.SamplerModel; | ||
| import io.opentelemetry.sdk.trace.samplers.Sampler; | ||
|
|
@@ -82,7 +83,7 @@ private DeclarativeConfiguration() {} | |
| * | ||
| * @throws DeclarativeConfigException if unable to parse or interpret | ||
| */ | ||
| public static OpenTelemetrySdk parseAndCreate(InputStream inputStream) { | ||
| public static ExtendedOpenTelemetrySdk parseAndCreate(InputStream inputStream) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is cool - frees up callers from needing to worry about initializing |
||
| OpenTelemetryConfigurationModel configurationModel = parse(inputStream); | ||
| return create(configurationModel); | ||
| } | ||
|
|
@@ -95,7 +96,8 @@ public static OpenTelemetrySdk parseAndCreate(InputStream inputStream) { | |
| * @return the {@link OpenTelemetrySdk} | ||
| * @throws DeclarativeConfigException if unable to interpret | ||
| */ | ||
| public static OpenTelemetrySdk create(OpenTelemetryConfigurationModel configurationModel) { | ||
| public static ExtendedOpenTelemetrySdk create( | ||
| OpenTelemetryConfigurationModel configurationModel) { | ||
| return create(configurationModel, DEFAULT_COMPONENT_LOADER); | ||
| } | ||
|
|
||
|
|
@@ -109,7 +111,7 @@ public static OpenTelemetrySdk create(OpenTelemetryConfigurationModel configurat | |
| * @return the {@link OpenTelemetrySdk} | ||
| * @throws DeclarativeConfigException if unable to interpret | ||
| */ | ||
| public static OpenTelemetrySdk create( | ||
| public static ExtendedOpenTelemetrySdk create( | ||
| OpenTelemetryConfigurationModel configurationModel, ComponentLoader componentLoader) { | ||
| SpiHelper spiHelper = SpiHelper.create(componentLoader); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.