-
Notifications
You must be signed in to change notification settings - Fork 1k
Instrument extended open telemetry #15178
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
Open
zeitlinger
wants to merge
18
commits into
open-telemetry:main
Choose a base branch
from
zeitlinger:instrument-extended-open-telemetry
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
3144a91
add ExtendedOpenTelemetry
zeitlinger 3e8918d
add ExtendedOpenTelemetry
zeitlinger 6631a53
add ExtendedOpenTelemetry
zeitlinger bae78fb
add ExtendedOpenTelemetry
zeitlinger 3755539
add ExtendedOpenTelemetry
zeitlinger 74f027a
add ExtendedOpenTelemetry
zeitlinger ac23181
add ExtendedOpenTelemetry
zeitlinger c0276d9
checkstyle
zeitlinger c0b2f4d
use 1.56
zeitlinger 86bff09
fix
zeitlinger 3626eca
fix
zeitlinger 26df417
fix
zeitlinger 3f448ef
remove unneeded classes
zeitlinger fa352a6
extract method
zeitlinger 27ae2dc
make final
zeitlinger 3c7ecbb
pr review
zeitlinger 3f89d7c
component loader doesn't work
zeitlinger b673cb8
add more tests
zeitlinger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
instrumentation/opentelemetry-api/opentelemetry-api-1.56/javaagent/build.gradle.kts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| plugins { | ||
| id("otel.javaagent-instrumentation") | ||
| } | ||
|
|
||
| dependencies { | ||
| compileOnly(project(":opentelemetry-api-shaded-for-instrumenting", configuration = "v1_56")) | ||
| compileOnly("io.opentelemetry:opentelemetry-api-incubator") | ||
|
|
||
| implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.0:javaagent")) | ||
| implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.27:javaagent")) | ||
| implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.40:javaagent")) | ||
| implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.42:javaagent")) | ||
| implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.47:javaagent")) | ||
| implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.50:javaagent")) | ||
| implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.52:javaagent")) | ||
|
|
||
| testImplementation("io.opentelemetry:opentelemetry-api-incubator") | ||
| } | ||
|
|
||
| tasks.withType<Test>().configureEach { | ||
| jvmArgs( | ||
| "-Dotel.experimental.config.file=$projectDir/src/test/resources/declarative-config.yaml" | ||
| ) | ||
| } |
46 changes: 46 additions & 0 deletions
46
...nstrumentation/opentelemetryapi/v1_56/incubator/ApplicationOpenTelemetry156Incubator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_56.incubator; | ||
|
|
||
| import application.io.opentelemetry.api.OpenTelemetry; | ||
| import application.io.opentelemetry.api.incubator.ExtendedOpenTelemetry; | ||
| import application.io.opentelemetry.api.incubator.config.ConfigProvider; | ||
| import io.opentelemetry.api.GlobalOpenTelemetry; | ||
| import io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_27.ApplicationOpenTelemetry127; | ||
| import io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_56.incubator.config.ApplicationConfigProvider156Incubator; | ||
| import javax.annotation.Nullable; | ||
|
|
||
| public final class ApplicationOpenTelemetry156Incubator extends ApplicationOpenTelemetry127 | ||
| implements ExtendedOpenTelemetry { | ||
|
|
||
| // Accessed with reflection | ||
| @Nullable | ||
| @SuppressWarnings("unused") | ||
| public static final OpenTelemetry INSTANCE = create(); | ||
|
|
||
| private final ConfigProvider configProvider; | ||
|
|
||
| @Nullable | ||
| private static ApplicationOpenTelemetry156Incubator create() { | ||
| io.opentelemetry.api.OpenTelemetry openTelemetry = GlobalOpenTelemetry.get(); | ||
| if (openTelemetry instanceof io.opentelemetry.api.incubator.ExtendedOpenTelemetry) { | ||
| return new ApplicationOpenTelemetry156Incubator( | ||
| ((io.opentelemetry.api.incubator.ExtendedOpenTelemetry) openTelemetry) | ||
| .getConfigProvider()); | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| public ApplicationOpenTelemetry156Incubator( | ||
| io.opentelemetry.api.incubator.config.ConfigProvider configProvider) { | ||
| this.configProvider = new ApplicationConfigProvider156Incubator(configProvider); | ||
| } | ||
|
|
||
| @Override | ||
| public ConfigProvider getConfigProvider() { | ||
| return configProvider; | ||
| } | ||
| } |
41 changes: 41 additions & 0 deletions
41
...tion/opentelemetryapi/v1_56/incubator/OpenTelemetryApiIncubatorInstrumentationModule.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_56.incubator; | ||
|
|
||
| import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; | ||
| import static java.util.Collections.singletonList; | ||
|
|
||
| import com.google.auto.service.AutoService; | ||
| import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; | ||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||
| import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule; | ||
| import java.util.List; | ||
| import net.bytebuddy.matcher.ElementMatcher; | ||
|
|
||
| @AutoService(InstrumentationModule.class) | ||
| public class OpenTelemetryApiIncubatorInstrumentationModule extends InstrumentationModule | ||
| implements ExperimentalInstrumentationModule { | ||
| public OpenTelemetryApiIncubatorInstrumentationModule() { | ||
| super("opentelemetry-api", "opentelemetry-api-1.56", "opentelemetry-api-incubator-1.56"); | ||
| } | ||
|
|
||
| @Override | ||
| public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() { | ||
| return hasClassesNamed( | ||
| "application.io.opentelemetry.api.common.Value", | ||
| "application.io.opentelemetry.api.incubator.ExtendedOpenTelemetry"); | ||
| } | ||
|
|
||
| @Override | ||
| public List<TypeInstrumentation> typeInstrumentations() { | ||
| return singletonList(new OpenTelemetryIncubatorInstrumentation()); | ||
| } | ||
|
|
||
| @Override | ||
| public String getModuleGroup() { | ||
| return "opentelemetry-api-bridge"; | ||
| } | ||
| } |
39 changes: 39 additions & 0 deletions
39
...strumentation/opentelemetryapi/v1_56/incubator/OpenTelemetryIncubatorInstrumentation.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_56.incubator; | ||
|
|
||
| import static net.bytebuddy.matcher.ElementMatchers.named; | ||
| import static net.bytebuddy.matcher.ElementMatchers.none; | ||
|
|
||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; | ||
| import net.bytebuddy.asm.Advice; | ||
| import net.bytebuddy.description.type.TypeDescription; | ||
| import net.bytebuddy.matcher.ElementMatcher; | ||
|
|
||
| public class OpenTelemetryIncubatorInstrumentation implements TypeInstrumentation { | ||
|
|
||
| @Override | ||
| public ElementMatcher<TypeDescription> typeMatcher() { | ||
| return named("application.io.opentelemetry.api.GlobalOpenTelemetry"); | ||
| } | ||
|
|
||
| @Override | ||
| public void transform(TypeTransformer transformer) { | ||
| transformer.applyAdviceToMethod( | ||
| none(), OpenTelemetryIncubatorInstrumentation.class.getName() + "$InitAdvice"); | ||
| } | ||
|
|
||
| @SuppressWarnings({"ReturnValueIgnored", "unused"}) | ||
| public static class InitAdvice { | ||
| @Advice.OnMethodEnter | ||
| public static void init() { | ||
| // the sole purpose of this advice is to ensure that the classes are | ||
| // recognized as helper class and injected into class loader | ||
| ApplicationOpenTelemetry156Incubator.class.getName(); | ||
| } | ||
| } | ||
| } |
28 changes: 28 additions & 0 deletions
28
...tation/opentelemetryapi/v1_56/incubator/config/ApplicationConfigProvider156Incubator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_56.incubator.config; | ||
|
|
||
| import application.io.opentelemetry.api.incubator.config.ConfigProvider; | ||
| import application.io.opentelemetry.api.incubator.config.DeclarativeConfigProperties; | ||
| import javax.annotation.Nullable; | ||
|
|
||
| public final class ApplicationConfigProvider156Incubator implements ConfigProvider { | ||
|
|
||
| private final DeclarativeConfigProperties declarativeConfigProperties; | ||
|
|
||
| public ApplicationConfigProvider156Incubator( | ||
| io.opentelemetry.api.incubator.config.ConfigProvider configProvider) { | ||
| this.declarativeConfigProperties = | ||
| new ApplicationDeclarativeConfigProperties156Incubator( | ||
| configProvider.getInstrumentationConfig()); | ||
| } | ||
|
|
||
| @Nullable | ||
| @Override | ||
| public DeclarativeConfigProperties getInstrumentationConfig() { | ||
| return declarativeConfigProperties; | ||
| } | ||
| } |
124 changes: 124 additions & 0 deletions
124
...lemetryapi/v1_56/incubator/config/ApplicationDeclarativeConfigProperties156Incubator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_56.incubator.config; | ||
|
|
||
| import application.io.opentelemetry.api.incubator.config.DeclarativeConfigException; | ||
| import application.io.opentelemetry.api.incubator.config.DeclarativeConfigProperties; | ||
| import application.io.opentelemetry.common.ComponentLoader; | ||
| import java.util.List; | ||
| import java.util.Set; | ||
| import java.util.stream.Collectors; | ||
| import javax.annotation.Nullable; | ||
|
|
||
| public final class ApplicationDeclarativeConfigProperties156Incubator | ||
| implements DeclarativeConfigProperties { | ||
| private final io.opentelemetry.api.incubator.config.DeclarativeConfigProperties | ||
| instrumentationConfig; | ||
|
|
||
| public ApplicationDeclarativeConfigProperties156Incubator( | ||
| io.opentelemetry.api.incubator.config.DeclarativeConfigProperties instrumentationConfig) { | ||
| this.instrumentationConfig = instrumentationConfig; | ||
| } | ||
|
|
||
| @Nullable | ||
| @Override | ||
| public String getString(String name) { | ||
| return instrumentationConfig.getString(name); | ||
| } | ||
|
|
||
| @Override | ||
| public String getString(String name, String defaultValue) { | ||
| return instrumentationConfig.getString(name, defaultValue); | ||
| } | ||
|
|
||
| @Nullable | ||
| @Override | ||
| public Boolean getBoolean(String name) { | ||
| return instrumentationConfig.getBoolean(name); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean getBoolean(String name, boolean defaultValue) { | ||
| return instrumentationConfig.getBoolean(name, defaultValue); | ||
| } | ||
|
|
||
| @Nullable | ||
| @Override | ||
| public Integer getInt(String name) { | ||
| return instrumentationConfig.getInt(name); | ||
| } | ||
|
|
||
| @Override | ||
| public int getInt(String name, int defaultValue) { | ||
| return instrumentationConfig.getInt(name, defaultValue); | ||
| } | ||
|
|
||
| @Nullable | ||
| @Override | ||
| public Long getLong(String name) { | ||
| return instrumentationConfig.getLong(name); | ||
| } | ||
|
|
||
| @Override | ||
| public long getLong(String name, long defaultValue) { | ||
| return instrumentationConfig.getLong(name, defaultValue); | ||
| } | ||
|
|
||
| @Nullable | ||
| @Override | ||
| public Double getDouble(String name) { | ||
| return instrumentationConfig.getDouble(name); | ||
| } | ||
|
|
||
| @Override | ||
| public double getDouble(String name, double defaultValue) { | ||
| return instrumentationConfig.getDouble(name, defaultValue); | ||
| } | ||
|
|
||
| @Nullable | ||
| @Override | ||
| public <T> List<T> getScalarList(String name, Class<T> scalarType) { | ||
| return instrumentationConfig.getScalarList(name, scalarType); | ||
| } | ||
|
|
||
| @Override | ||
| public <T> List<T> getScalarList(String name, Class<T> scalarType, List<T> defaultValue) { | ||
| return instrumentationConfig.getScalarList(name, scalarType, defaultValue); | ||
| } | ||
|
|
||
| @Nullable | ||
| @Override | ||
| public DeclarativeConfigProperties getStructured(String name) { | ||
| return new ApplicationDeclarativeConfigProperties156Incubator( | ||
| instrumentationConfig.getStructured(name)); | ||
| } | ||
|
|
||
| @Nullable | ||
| @Override | ||
| public List<DeclarativeConfigProperties> getStructuredList(String name) { | ||
| List<io.opentelemetry.api.incubator.config.DeclarativeConfigProperties> structuredList = | ||
| instrumentationConfig.getStructuredList(name); | ||
| if (structuredList == null) { | ||
| return null; | ||
| } | ||
|
|
||
| return structuredList.stream() | ||
| .map(e -> new ApplicationDeclarativeConfigProperties156Incubator(e)) | ||
| .collect(Collectors.toList()); | ||
| } | ||
|
|
||
| @Override | ||
| public Set<String> getPropertyKeys() { | ||
| return instrumentationConfig.getPropertyKeys(); | ||
| } | ||
|
|
||
| @Override | ||
| public ComponentLoader getComponentLoader() { | ||
| throw new DeclarativeConfigException( | ||
| "getComponentLoader is not supported in application code. " | ||
| + "It is only used to set up the OpenTelemetry SDK in the agent."); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.