-
Notifications
You must be signed in to change notification settings - Fork 856
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bridge incubator metrics apis (#9884)
- Loading branch information
Showing
29 changed files
with
1,074 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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
16 changes: 16 additions & 0 deletions
16
instrumentation/opentelemetry-api/opentelemetry-api-1.31/javaagent/build.gradle.kts
This file contains 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,16 @@ | ||
plugins { | ||
id("otel.javaagent-instrumentation") | ||
} | ||
|
||
dependencies { | ||
compileOnly(project(":opentelemetry-api-shaded-for-instrumenting", configuration = "v1_31")) | ||
compileOnly("io.opentelemetry:opentelemetry-extension-incubator") | ||
|
||
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.0:javaagent")) | ||
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.4:javaagent")) | ||
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.10:javaagent")) | ||
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.15:javaagent")) | ||
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.27:javaagent")) | ||
|
||
testImplementation("io.opentelemetry:opentelemetry-extension-incubator") | ||
} |
30 changes: 30 additions & 0 deletions
30
...vaagent/instrumentation/opentelemetryapi/v1_31/OpenTelemetryApiInstrumentationModule.java
This file contains 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,30 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_31; | ||
|
||
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 java.util.List; | ||
|
||
@AutoService(InstrumentationModule.class) | ||
public class OpenTelemetryApiInstrumentationModule extends InstrumentationModule { | ||
public OpenTelemetryApiInstrumentationModule() { | ||
super("opentelemetry-api", "opentelemetry-api-1.31"); | ||
} | ||
|
||
@Override | ||
public boolean isIndyModule() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public List<TypeInstrumentation> typeInstrumentations() { | ||
return singletonList(new OpenTelemetryInstrumentation()); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...emetry/javaagent/instrumentation/opentelemetryapi/v1_31/OpenTelemetryInstrumentation.java
This file contains 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,40 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_31; | ||
|
||
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 io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_31.metrics.ApplicationMeterFactory131; | ||
import net.bytebuddy.asm.Advice; | ||
import net.bytebuddy.description.type.TypeDescription; | ||
import net.bytebuddy.matcher.ElementMatcher; | ||
|
||
public class OpenTelemetryInstrumentation implements TypeInstrumentation { | ||
|
||
@Override | ||
public ElementMatcher<TypeDescription> typeMatcher() { | ||
return named("application.io.opentelemetry.api.GlobalOpenTelemetry"); | ||
} | ||
|
||
@Override | ||
public void transform(TypeTransformer transformer) { | ||
transformer.applyAdviceToMethod( | ||
none(), OpenTelemetryInstrumentation.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 ApplicationMeterFactory131 is recognized | ||
// as helper class and injected into class loader | ||
ApplicationMeterFactory131.class.getName(); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...nt/instrumentation/opentelemetryapi/v1_31/metrics/ApplicationDoubleCounterBuilder131.java
This file contains 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,31 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_31.metrics; | ||
|
||
import application.io.opentelemetry.api.common.AttributeKey; | ||
import application.io.opentelemetry.extension.incubator.metrics.ExtendedDoubleCounterBuilder; | ||
import io.opentelemetry.javaagent.instrumentation.opentelemetryapi.trace.Bridging; | ||
import io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_10.metrics.ApplicationDoubleCounterBuilder; | ||
import java.util.List; | ||
|
||
final class ApplicationDoubleCounterBuilder131 extends ApplicationDoubleCounterBuilder | ||
implements ExtendedDoubleCounterBuilder { | ||
|
||
private final io.opentelemetry.api.metrics.DoubleCounterBuilder agentBuilder; | ||
|
||
ApplicationDoubleCounterBuilder131( | ||
io.opentelemetry.api.metrics.DoubleCounterBuilder agentBuilder) { | ||
super(agentBuilder); | ||
this.agentBuilder = agentBuilder; | ||
} | ||
|
||
@Override | ||
public ExtendedDoubleCounterBuilder setAttributesAdvice(List<AttributeKey<?>> attributes) { | ||
((io.opentelemetry.extension.incubator.metrics.ExtendedDoubleCounterBuilder) agentBuilder) | ||
.setAttributesAdvice(Bridging.toAgent(attributes)); | ||
return this; | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
...gent/instrumentation/opentelemetryapi/v1_31/metrics/ApplicationDoubleGaugeBuilder131.java
This file contains 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,57 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_31.metrics; | ||
|
||
import application.io.opentelemetry.api.common.AttributeKey; | ||
import application.io.opentelemetry.api.common.Attributes; | ||
import application.io.opentelemetry.api.metrics.LongGaugeBuilder; | ||
import application.io.opentelemetry.extension.incubator.metrics.DoubleGauge; | ||
import application.io.opentelemetry.extension.incubator.metrics.ExtendedDoubleGaugeBuilder; | ||
import io.opentelemetry.javaagent.instrumentation.opentelemetryapi.trace.Bridging; | ||
import io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_10.metrics.ApplicationDoubleGaugeBuilder; | ||
import java.util.List; | ||
|
||
final class ApplicationDoubleGaugeBuilder131 extends ApplicationDoubleGaugeBuilder | ||
implements ExtendedDoubleGaugeBuilder { | ||
|
||
private final io.opentelemetry.api.metrics.DoubleGaugeBuilder agentBuilder; | ||
|
||
ApplicationDoubleGaugeBuilder131(io.opentelemetry.api.metrics.DoubleGaugeBuilder agentBuilder) { | ||
super(agentBuilder); | ||
this.agentBuilder = agentBuilder; | ||
} | ||
|
||
@Override | ||
public LongGaugeBuilder ofLongs() { | ||
return new ApplicationLongGaugeBuilder131(agentBuilder.ofLongs()); | ||
} | ||
|
||
@Override | ||
public DoubleGauge build() { | ||
io.opentelemetry.extension.incubator.metrics.DoubleGauge agentDoubleGauge = | ||
((io.opentelemetry.extension.incubator.metrics.ExtendedDoubleGaugeBuilder) agentBuilder) | ||
.build(); | ||
return new DoubleGauge() { | ||
|
||
@Override | ||
public void set(double value) { | ||
agentDoubleGauge.set(value); | ||
} | ||
|
||
@Override | ||
public void set(double value, Attributes attributes) { | ||
agentDoubleGauge.set(value, Bridging.toAgent(attributes)); | ||
} | ||
}; | ||
} | ||
|
||
@Override | ||
public ExtendedDoubleGaugeBuilder setAttributesAdvice(List<AttributeKey<?>> attributes) { | ||
((io.opentelemetry.extension.incubator.metrics.ExtendedDoubleGaugeBuilder) agentBuilder) | ||
.setAttributesAdvice(Bridging.toAgent(attributes)); | ||
return this; | ||
} | ||
} |
Oops, something went wrong.