Better naming around around shaded/unshaded (#953)
This commit is contained in:
parent
bf9c160570
commit
622ab27ae8
|
@ -87,6 +87,6 @@ shadowJar {
|
||||||
relocate "io.grpc.Context", "io.opentelemetry.auto.shaded.io.grpc.Context"
|
relocate "io.grpc.Context", "io.opentelemetry.auto.shaded.io.grpc.Context"
|
||||||
|
|
||||||
// this is for instrumentation on opentelemetry-api itself
|
// this is for instrumentation on opentelemetry-api itself
|
||||||
relocate "unshaded.io.opentelemetry", "io.opentelemetry"
|
relocate "application.io.opentelemetry", "io.opentelemetry"
|
||||||
relocate "unshaded.io.grpc", "io.grpc"
|
relocate "application.io.grpc", "io.grpc"
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,12 +13,12 @@ dependencies {
|
||||||
// the "temporarily shaded" OpenTelemetry API is unshaded, so that it will apply to the
|
// the "temporarily shaded" OpenTelemetry API is unshaded, so that it will apply to the
|
||||||
// OpenTelemetry API that the user brings
|
// OpenTelemetry API that the user brings
|
||||||
//
|
//
|
||||||
// so in the code "unshaded.io.opentelemetry.*" refers to the (unshaded) OpenTelemetry API that
|
// so in the code "application.io.opentelemetry.*" refers to the (unshaded) OpenTelemetry API that
|
||||||
// the user brings (as those references will be translated during the build to remove the
|
// the application brings (as those references will be translated during the build to remove the
|
||||||
// "unshaded." prefix)
|
// "application." prefix)
|
||||||
//
|
//
|
||||||
// and in the code "io.opentelemetry.*" refers to the (shaded) OpenTelemetry API that is in the
|
// and in the code "io.opentelemetry.*" refers to the (shaded) OpenTelemetry API that is used by
|
||||||
// bootstrap class loader (as those references will later be shaded)
|
// the agent (as those references will later be shaded)
|
||||||
compileOnly project(path: ':opentelemetry-api-beta-shaded-for-instrumenting', configuration: 'shadow')
|
compileOnly project(path: ':opentelemetry-api-beta-shaded-for-instrumenting', configuration: 'shadow')
|
||||||
compileOnly project(path: ':opentelemetry-auto-annotations-beta-shaded-for-instrumenting', configuration: 'shadow')
|
compileOnly project(path: ':opentelemetry-auto-annotations-beta-shaded-for-instrumenting', configuration: 'shadow')
|
||||||
|
|
||||||
|
|
|
@ -30,73 +30,75 @@ public abstract class AbstractInstrumentation extends Instrumenter.Default {
|
||||||
public String[] helperClassNames() {
|
public String[] helperClassNames() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
packageName + ".context.ContextUtils",
|
packageName + ".context.ContextUtils",
|
||||||
packageName + ".context.UnshadedScope",
|
packageName + ".context.ApplicationScope",
|
||||||
packageName + ".context.NoopScope",
|
packageName + ".context.NoopScope",
|
||||||
packageName + ".context.propagation.UnshadedContextPropagators",
|
packageName + ".context.propagation.ApplicationContextPropagators",
|
||||||
packageName + ".context.propagation.UnshadedHttpTextFormat",
|
packageName + ".context.propagation.ApplicationHttpTextFormat",
|
||||||
packageName + ".context.propagation.UnshadedHttpTextFormat$UnshadedSetter",
|
packageName + ".context.propagation.ApplicationHttpTextFormat$AgentSetter",
|
||||||
packageName + ".context.propagation.UnshadedHttpTextFormat$UnshadedGetter",
|
packageName + ".context.propagation.ApplicationHttpTextFormat$AgentGetter",
|
||||||
packageName + ".metrics.UnshadedBatchRecorder",
|
packageName + ".metrics.ApplicationBatchRecorder",
|
||||||
packageName + ".metrics.UnshadedDoubleCounter",
|
packageName + ".metrics.ApplicationDoubleCounter",
|
||||||
packageName + ".metrics.UnshadedDoubleCounter$BoundInstrument",
|
packageName + ".metrics.ApplicationDoubleCounter$BoundInstrument",
|
||||||
packageName + ".metrics.UnshadedDoubleCounter$Builder",
|
packageName + ".metrics.ApplicationDoubleCounter$Builder",
|
||||||
packageName + ".metrics.UnshadedDoubleSumObserver",
|
packageName + ".metrics.ApplicationDoubleSumObserver",
|
||||||
packageName + ".metrics.UnshadedDoubleSumObserver$Builder",
|
packageName + ".metrics.ApplicationDoubleSumObserver$Builder",
|
||||||
packageName + ".metrics.UnshadedDoubleSumObserver$ShadedResultDoubleSumObserver",
|
packageName + ".metrics.ApplicationDoubleSumObserver$AgentResultDoubleSumObserver",
|
||||||
packageName + ".metrics.UnshadedDoubleSumObserver$UnshadedResultDoubleSumObserver",
|
packageName + ".metrics.ApplicationDoubleSumObserver$ApplicationResultDoubleSumObserver",
|
||||||
packageName + ".metrics.UnshadedDoubleUpDownCounter",
|
packageName + ".metrics.ApplicationDoubleUpDownCounter",
|
||||||
packageName + ".metrics.UnshadedDoubleUpDownCounter$BoundInstrument",
|
packageName + ".metrics.ApplicationDoubleUpDownCounter$BoundInstrument",
|
||||||
packageName + ".metrics.UnshadedDoubleUpDownCounter$Builder",
|
packageName + ".metrics.ApplicationDoubleUpDownCounter$Builder",
|
||||||
packageName + ".metrics.UnshadedDoubleUpDownSumObserver",
|
packageName + ".metrics.ApplicationDoubleUpDownSumObserver",
|
||||||
packageName + ".metrics.UnshadedDoubleUpDownSumObserver$Builder",
|
packageName + ".metrics.ApplicationDoubleUpDownSumObserver$Builder",
|
||||||
packageName + ".metrics.UnshadedDoubleUpDownSumObserver$ShadedResultDoubleUpDownSumObserver",
|
|
||||||
packageName
|
packageName
|
||||||
+ ".metrics.UnshadedDoubleUpDownSumObserver$UnshadedResultDoubleUpDownSumObserver",
|
+ ".metrics.ApplicationDoubleUpDownSumObserver$AgentResultDoubleUpDownSumObserver",
|
||||||
packageName + ".metrics.UnshadedDoubleValueObserver",
|
packageName
|
||||||
packageName + ".metrics.UnshadedDoubleValueObserver$Builder",
|
+ ".metrics.ApplicationDoubleUpDownSumObserver$ApplicationResultDoubleUpDownSumObserver",
|
||||||
packageName + ".metrics.UnshadedDoubleValueObserver$ShadedResultDoubleValueObserver",
|
packageName + ".metrics.ApplicationDoubleValueObserver",
|
||||||
packageName + ".metrics.UnshadedDoubleValueObserver$UnshadedResultDoubleValueObserver",
|
packageName + ".metrics.ApplicationDoubleValueObserver$Builder",
|
||||||
packageName + ".metrics.UnshadedDoubleValueRecorder",
|
packageName + ".metrics.ApplicationDoubleValueObserver$AgentResultDoubleValueObserver",
|
||||||
packageName + ".metrics.UnshadedDoubleValueRecorder$BoundInstrument",
|
packageName + ".metrics.ApplicationDoubleValueObserver$ApplicationResultDoubleValueObserver",
|
||||||
packageName + ".metrics.UnshadedDoubleValueRecorder$Builder",
|
packageName + ".metrics.ApplicationDoubleValueRecorder",
|
||||||
packageName + ".metrics.UnshadedLongCounter",
|
packageName + ".metrics.ApplicationDoubleValueRecorder$BoundInstrument",
|
||||||
packageName + ".metrics.UnshadedLongCounter$BoundInstrument",
|
packageName + ".metrics.ApplicationDoubleValueRecorder$Builder",
|
||||||
packageName + ".metrics.UnshadedLongCounter$Builder",
|
packageName + ".metrics.ApplicationLongCounter",
|
||||||
packageName + ".metrics.UnshadedLongSumObserver",
|
packageName + ".metrics.ApplicationLongCounter$BoundInstrument",
|
||||||
packageName + ".metrics.UnshadedLongSumObserver$Builder",
|
packageName + ".metrics.ApplicationLongCounter$Builder",
|
||||||
packageName + ".metrics.UnshadedLongSumObserver$ShadedResultLongSumObserver",
|
packageName + ".metrics.ApplicationLongSumObserver",
|
||||||
packageName + ".metrics.UnshadedLongSumObserver$UnshadedResultLongSumObserver",
|
packageName + ".metrics.ApplicationLongSumObserver$Builder",
|
||||||
packageName + ".metrics.UnshadedLongUpDownCounter",
|
packageName + ".metrics.ApplicationLongSumObserver$AgentResultLongSumObserver",
|
||||||
packageName + ".metrics.UnshadedLongUpDownCounter$BoundInstrument",
|
packageName + ".metrics.ApplicationLongSumObserver$ApplicationResultLongSumObserver",
|
||||||
packageName + ".metrics.UnshadedLongUpDownCounter$Builder",
|
packageName + ".metrics.ApplicationLongUpDownCounter",
|
||||||
packageName + ".metrics.UnshadedLongUpDownSumObserver",
|
packageName + ".metrics.ApplicationLongUpDownCounter$BoundInstrument",
|
||||||
packageName + ".metrics.UnshadedLongUpDownSumObserver$Builder",
|
packageName + ".metrics.ApplicationLongUpDownCounter$Builder",
|
||||||
packageName + ".metrics.UnshadedLongUpDownSumObserver$ShadedResultLongUpDownSumObserver",
|
packageName + ".metrics.ApplicationLongUpDownSumObserver",
|
||||||
packageName + ".metrics.UnshadedLongUpDownSumObserver$UnshadedResultLongUpDownSumObserver",
|
packageName + ".metrics.ApplicationLongUpDownSumObserver$Builder",
|
||||||
packageName + ".metrics.UnshadedLongValueObserver",
|
packageName + ".metrics.ApplicationLongUpDownSumObserver$AgentResultLongUpDownSumObserver",
|
||||||
packageName + ".metrics.UnshadedLongValueObserver$Builder",
|
packageName
|
||||||
packageName + ".metrics.UnshadedLongValueObserver$ShadedResultLongValueObserver",
|
+ ".metrics.ApplicationLongUpDownSumObserver$ApplicationResultLongUpDownSumObserver",
|
||||||
packageName + ".metrics.UnshadedLongValueObserver$UnshadedResultLongValueObserver",
|
packageName + ".metrics.ApplicationLongValueObserver",
|
||||||
packageName + ".metrics.UnshadedLongValueRecorder",
|
packageName + ".metrics.ApplicationLongValueObserver$Builder",
|
||||||
packageName + ".metrics.UnshadedLongValueRecorder$BoundInstrument",
|
packageName + ".metrics.ApplicationLongValueObserver$AgentResultLongValueObserver",
|
||||||
packageName + ".metrics.UnshadedLongValueRecorder$Builder",
|
packageName + ".metrics.ApplicationLongValueObserver$ApplicationResultLongValueObserver",
|
||||||
packageName + ".metrics.UnshadedMeter",
|
packageName + ".metrics.ApplicationLongValueRecorder",
|
||||||
packageName + ".metrics.UnshadedMeterProvider",
|
packageName + ".metrics.ApplicationLongValueRecorder$BoundInstrument",
|
||||||
|
packageName + ".metrics.ApplicationLongValueRecorder$Builder",
|
||||||
|
packageName + ".metrics.ApplicationMeter",
|
||||||
|
packageName + ".metrics.ApplicationMeterProvider",
|
||||||
packageName + ".trace.Bridging",
|
packageName + ".trace.Bridging",
|
||||||
packageName + ".trace.Bridging$1",
|
packageName + ".trace.Bridging$1",
|
||||||
packageName + ".trace.Bridging$2",
|
packageName + ".trace.Bridging$2",
|
||||||
packageName + ".trace.TracingContextUtils",
|
packageName + ".trace.TracingContextUtils",
|
||||||
packageName + ".trace.UnshadedSpan",
|
packageName + ".trace.ApplicationSpan",
|
||||||
packageName + ".trace.UnshadedSpan$Builder",
|
packageName + ".trace.ApplicationSpan$Builder",
|
||||||
packageName + ".trace.UnshadedTracer",
|
packageName + ".trace.ApplicationTracer",
|
||||||
packageName + ".trace.UnshadedTracerProvider",
|
packageName + ".trace.ApplicationTracerProvider",
|
||||||
packageName + ".LabelsShader",
|
packageName + ".LabelBridging",
|
||||||
packageName + ".LabelsShader$Consumer"
|
packageName + ".LabelBridging$Consumer"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> contextStore() {
|
public Map<String, String> contextStore() {
|
||||||
return singletonMap("unshaded.io.grpc.Context", "io.grpc.Context");
|
return singletonMap("application.io.grpc.Context", "io.grpc.Context");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,8 @@ import static net.bytebuddy.matcher.ElementMatchers.isStatic;
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
|
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
|
||||||
|
|
||||||
|
import application.io.grpc.Context;
|
||||||
|
import application.io.opentelemetry.context.Scope;
|
||||||
import com.google.auto.service.AutoService;
|
import com.google.auto.service.AutoService;
|
||||||
import io.opentelemetry.auto.instrumentation.opentelemetryapi.context.ContextUtils;
|
import io.opentelemetry.auto.instrumentation.opentelemetryapi.context.ContextUtils;
|
||||||
import io.opentelemetry.auto.tooling.Instrumenter;
|
import io.opentelemetry.auto.tooling.Instrumenter;
|
||||||
|
@ -33,15 +35,13 @@ import net.bytebuddy.asm.Advice;
|
||||||
import net.bytebuddy.description.method.MethodDescription;
|
import net.bytebuddy.description.method.MethodDescription;
|
||||||
import net.bytebuddy.description.type.TypeDescription;
|
import net.bytebuddy.description.type.TypeDescription;
|
||||||
import net.bytebuddy.matcher.ElementMatcher;
|
import net.bytebuddy.matcher.ElementMatcher;
|
||||||
import unshaded.io.grpc.Context;
|
|
||||||
import unshaded.io.opentelemetry.context.Scope;
|
|
||||||
|
|
||||||
@AutoService(Instrumenter.class)
|
@AutoService(Instrumenter.class)
|
||||||
public class ContextUtilsInstrumentation extends AbstractInstrumentation {
|
public class ContextUtilsInstrumentation extends AbstractInstrumentation {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ElementMatcher<? super TypeDescription> typeMatcher() {
|
public ElementMatcher<? super TypeDescription> typeMatcher() {
|
||||||
return named("unshaded.io.opentelemetry.context.ContextUtils");
|
return named("application.io.opentelemetry.context.ContextUtils");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -66,11 +66,12 @@ public class ContextUtilsInstrumentation extends AbstractInstrumentation {
|
||||||
|
|
||||||
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||||
public static void methodExit(
|
public static void methodExit(
|
||||||
@Advice.Argument(0) final Context context, @Advice.Return(readOnly = false) Scope scope) {
|
@Advice.Argument(0) final Context applicationContext,
|
||||||
|
@Advice.Return(readOnly = false) Scope applicationScope) {
|
||||||
|
|
||||||
ContextStore<Context, io.grpc.Context> contextStore =
|
ContextStore<Context, io.grpc.Context> contextStore =
|
||||||
InstrumentationContext.get(Context.class, io.grpc.Context.class);
|
InstrumentationContext.get(Context.class, io.grpc.Context.class);
|
||||||
scope = ContextUtils.withScopedContext(context, contextStore);
|
applicationScope = ContextUtils.withScopedContext(applicationContext, contextStore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.isStatic;
|
import static net.bytebuddy.matcher.ElementMatchers.isStatic;
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||||
|
|
||||||
|
import application.io.opentelemetry.trace.Span;
|
||||||
import com.google.auto.service.AutoService;
|
import com.google.auto.service.AutoService;
|
||||||
import io.opentelemetry.auto.instrumentation.opentelemetryapi.trace.Bridging;
|
import io.opentelemetry.auto.instrumentation.opentelemetryapi.trace.Bridging;
|
||||||
import io.opentelemetry.auto.tooling.Instrumenter;
|
import io.opentelemetry.auto.tooling.Instrumenter;
|
||||||
|
@ -36,7 +37,7 @@ import net.bytebuddy.matcher.ElementMatcher;
|
||||||
public class DefaultSpanInstrumentation extends AbstractInstrumentation {
|
public class DefaultSpanInstrumentation extends AbstractInstrumentation {
|
||||||
@Override
|
@Override
|
||||||
public ElementMatcher<? super TypeDescription> typeMatcher() {
|
public ElementMatcher<? super TypeDescription> typeMatcher() {
|
||||||
return named("unshaded.io.opentelemetry.trace.DefaultSpan");
|
return named("application.io.opentelemetry.trace.DefaultSpan");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -48,9 +49,10 @@ public class DefaultSpanInstrumentation extends AbstractInstrumentation {
|
||||||
|
|
||||||
public static class CreateAdvice {
|
public static class CreateAdvice {
|
||||||
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||||
public static void methodExit(
|
public static void methodExit(@Advice.Return(readOnly = false) Span applicationSpan) {
|
||||||
@Advice.Return(readOnly = false) unshaded.io.opentelemetry.trace.Span span) {
|
applicationSpan =
|
||||||
span = Bridging.toUnshaded(DefaultSpan.create(Bridging.toShaded(span.getContext())));
|
Bridging.toApplication(
|
||||||
|
DefaultSpan.create(Bridging.toAgent(applicationSpan.getContext())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import static net.bytebuddy.matcher.ElementMatchers.isStatic;
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
|
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
|
||||||
|
|
||||||
|
import application.io.grpc.Context;
|
||||||
import com.google.auto.service.AutoService;
|
import com.google.auto.service.AutoService;
|
||||||
import io.opentelemetry.auto.instrumentation.opentelemetryapi.context.ContextUtils;
|
import io.opentelemetry.auto.instrumentation.opentelemetryapi.context.ContextUtils;
|
||||||
import io.opentelemetry.auto.tooling.Instrumenter;
|
import io.opentelemetry.auto.tooling.Instrumenter;
|
||||||
|
@ -33,14 +34,13 @@ import net.bytebuddy.asm.Advice;
|
||||||
import net.bytebuddy.description.method.MethodDescription;
|
import net.bytebuddy.description.method.MethodDescription;
|
||||||
import net.bytebuddy.description.type.TypeDescription;
|
import net.bytebuddy.description.type.TypeDescription;
|
||||||
import net.bytebuddy.matcher.ElementMatcher;
|
import net.bytebuddy.matcher.ElementMatcher;
|
||||||
import unshaded.io.grpc.Context;
|
|
||||||
|
|
||||||
@AutoService(Instrumenter.class)
|
@AutoService(Instrumenter.class)
|
||||||
public class GrpcContextInstrumentation extends AbstractInstrumentation {
|
public class GrpcContextInstrumentation extends AbstractInstrumentation {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ElementMatcher<? super TypeDescription> typeMatcher() {
|
public ElementMatcher<? super TypeDescription> typeMatcher() {
|
||||||
return named("unshaded.io.grpc.Context");
|
return named("application.io.grpc.Context");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -55,10 +55,10 @@ public class GrpcContextInstrumentation extends AbstractInstrumentation {
|
||||||
public static class CurrentAdvice {
|
public static class CurrentAdvice {
|
||||||
|
|
||||||
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||||
public static void methodExit(@Advice.Return final unshaded.io.grpc.Context context) {
|
public static void methodExit(@Advice.Return final Context applicationContext) {
|
||||||
ContextStore<Context, io.grpc.Context> contextStore =
|
ContextStore<Context, io.grpc.Context> contextStore =
|
||||||
InstrumentationContext.get(Context.class, io.grpc.Context.class);
|
InstrumentationContext.get(Context.class, io.grpc.Context.class);
|
||||||
contextStore.put(context, io.grpc.Context.current());
|
contextStore.put(applicationContext, io.grpc.Context.current());
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is to make muzzle think we need ContextUtils to make sure we do not apply this
|
// this is to make muzzle think we need ContextUtils to make sure we do not apply this
|
||||||
|
|
|
@ -16,20 +16,21 @@
|
||||||
|
|
||||||
package io.opentelemetry.auto.instrumentation.opentelemetryapi;
|
package io.opentelemetry.auto.instrumentation.opentelemetryapi;
|
||||||
|
|
||||||
|
import application.io.opentelemetry.common.ReadableKeyValuePairs.KeyValueConsumer;
|
||||||
import io.opentelemetry.common.Labels;
|
import io.opentelemetry.common.Labels;
|
||||||
import io.opentelemetry.common.Labels.Builder;
|
import io.opentelemetry.common.Labels.Builder;
|
||||||
import unshaded.io.opentelemetry.common.ReadableKeyValuePairs.KeyValueConsumer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class converts between Labels class that user brings and Labels class that agent has.
|
* This class converts between Labels class that application brings and Labels class that agent
|
||||||
|
* uses.
|
||||||
*
|
*
|
||||||
* <p>TODO probably not the most performant solution...
|
* <p>TODO probably not the most performant solution...
|
||||||
*/
|
*/
|
||||||
public class LabelsShader {
|
public class LabelBridging {
|
||||||
|
|
||||||
public static Labels shade(unshaded.io.opentelemetry.common.Labels labels) {
|
public static Labels toAgent(application.io.opentelemetry.common.Labels applicationLabels) {
|
||||||
io.opentelemetry.common.Labels.Builder builder = io.opentelemetry.common.Labels.newBuilder();
|
io.opentelemetry.common.Labels.Builder builder = io.opentelemetry.common.Labels.newBuilder();
|
||||||
labels.forEach(new Consumer(builder));
|
applicationLabels.forEach(new Consumer(builder));
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,10 +21,13 @@ import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
|
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
|
||||||
|
|
||||||
|
import application.io.grpc.Context;
|
||||||
|
import application.io.opentelemetry.context.propagation.ContextPropagators;
|
||||||
|
import application.io.opentelemetry.metrics.MeterProvider;
|
||||||
import com.google.auto.service.AutoService;
|
import com.google.auto.service.AutoService;
|
||||||
import io.opentelemetry.auto.instrumentation.opentelemetryapi.context.propagation.UnshadedContextPropagators;
|
import io.opentelemetry.auto.instrumentation.opentelemetryapi.context.propagation.ApplicationContextPropagators;
|
||||||
import io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics.UnshadedMeterProvider;
|
import io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics.ApplicationMeterProvider;
|
||||||
import io.opentelemetry.auto.instrumentation.opentelemetryapi.trace.UnshadedTracerProvider;
|
import io.opentelemetry.auto.instrumentation.opentelemetryapi.trace.ApplicationTracerProvider;
|
||||||
import io.opentelemetry.auto.tooling.Instrumenter;
|
import io.opentelemetry.auto.tooling.Instrumenter;
|
||||||
import io.opentelemetry.instrumentation.auto.api.ContextStore;
|
import io.opentelemetry.instrumentation.auto.api.ContextStore;
|
||||||
import io.opentelemetry.instrumentation.auto.api.InstrumentationContext;
|
import io.opentelemetry.instrumentation.auto.api.InstrumentationContext;
|
||||||
|
@ -34,14 +37,13 @@ import net.bytebuddy.asm.Advice;
|
||||||
import net.bytebuddy.description.method.MethodDescription;
|
import net.bytebuddy.description.method.MethodDescription;
|
||||||
import net.bytebuddy.description.type.TypeDescription;
|
import net.bytebuddy.description.type.TypeDescription;
|
||||||
import net.bytebuddy.matcher.ElementMatcher;
|
import net.bytebuddy.matcher.ElementMatcher;
|
||||||
import unshaded.io.grpc.Context;
|
|
||||||
|
|
||||||
@AutoService(Instrumenter.class)
|
@AutoService(Instrumenter.class)
|
||||||
public class OpenTelemetryApiInstrumentation extends AbstractInstrumentation {
|
public class OpenTelemetryApiInstrumentation extends AbstractInstrumentation {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ElementMatcher<? super TypeDescription> typeMatcher() {
|
public ElementMatcher<? super TypeDescription> typeMatcher() {
|
||||||
return named("unshaded.io.opentelemetry.OpenTelemetry");
|
return named("application.io.opentelemetry.OpenTelemetry");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -64,10 +66,11 @@ public class OpenTelemetryApiInstrumentation extends AbstractInstrumentation {
|
||||||
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||||
public static void methodExit(
|
public static void methodExit(
|
||||||
@Advice.Return(readOnly = false)
|
@Advice.Return(readOnly = false)
|
||||||
unshaded.io.opentelemetry.trace.TracerProvider tracerProvider) {
|
application.io.opentelemetry.trace.TracerProvider applicationTracerProvider) {
|
||||||
ContextStore<Context, io.grpc.Context> contextStore =
|
ContextStore<Context, io.grpc.Context> contextStore =
|
||||||
InstrumentationContext.get(Context.class, io.grpc.Context.class);
|
InstrumentationContext.get(Context.class, io.grpc.Context.class);
|
||||||
tracerProvider = new UnshadedTracerProvider(contextStore, tracerProvider);
|
applicationTracerProvider =
|
||||||
|
new ApplicationTracerProvider(contextStore, applicationTracerProvider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,9 +78,8 @@ public class OpenTelemetryApiInstrumentation extends AbstractInstrumentation {
|
||||||
|
|
||||||
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||||
public static void methodExit(
|
public static void methodExit(
|
||||||
@Advice.Return(readOnly = false)
|
@Advice.Return(readOnly = false) MeterProvider applicationMeterProvider) {
|
||||||
unshaded.io.opentelemetry.metrics.MeterProvider meterProvider) {
|
applicationMeterProvider = new ApplicationMeterProvider();
|
||||||
meterProvider = new UnshadedMeterProvider();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,11 +87,10 @@ public class OpenTelemetryApiInstrumentation extends AbstractInstrumentation {
|
||||||
|
|
||||||
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||||
public static void methodExit(
|
public static void methodExit(
|
||||||
@Advice.Return(readOnly = false)
|
@Advice.Return(readOnly = false) ContextPropagators applicationContextPropagators) {
|
||||||
unshaded.io.opentelemetry.context.propagation.ContextPropagators contextPropagators) {
|
|
||||||
ContextStore<Context, io.grpc.Context> contextStore =
|
ContextStore<Context, io.grpc.Context> contextStore =
|
||||||
InstrumentationContext.get(Context.class, io.grpc.Context.class);
|
InstrumentationContext.get(Context.class, io.grpc.Context.class);
|
||||||
contextPropagators = new UnshadedContextPropagators(contextStore);
|
applicationContextPropagators = new ApplicationContextPropagators(contextStore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,9 @@ import static net.bytebuddy.matcher.ElementMatchers.isStatic;
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
|
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
|
||||||
|
|
||||||
|
import application.io.grpc.Context;
|
||||||
|
import application.io.opentelemetry.context.Scope;
|
||||||
|
import application.io.opentelemetry.trace.Span;
|
||||||
import com.google.auto.service.AutoService;
|
import com.google.auto.service.AutoService;
|
||||||
import io.opentelemetry.auto.instrumentation.opentelemetryapi.trace.TracingContextUtils;
|
import io.opentelemetry.auto.instrumentation.opentelemetryapi.trace.TracingContextUtils;
|
||||||
import io.opentelemetry.auto.tooling.Instrumenter;
|
import io.opentelemetry.auto.tooling.Instrumenter;
|
||||||
|
@ -33,16 +36,13 @@ import net.bytebuddy.asm.Advice;
|
||||||
import net.bytebuddy.description.method.MethodDescription;
|
import net.bytebuddy.description.method.MethodDescription;
|
||||||
import net.bytebuddy.description.type.TypeDescription;
|
import net.bytebuddy.description.type.TypeDescription;
|
||||||
import net.bytebuddy.matcher.ElementMatcher;
|
import net.bytebuddy.matcher.ElementMatcher;
|
||||||
import unshaded.io.grpc.Context;
|
|
||||||
import unshaded.io.opentelemetry.context.Scope;
|
|
||||||
import unshaded.io.opentelemetry.trace.Span;
|
|
||||||
|
|
||||||
@AutoService(Instrumenter.class)
|
@AutoService(Instrumenter.class)
|
||||||
public class TracingContextUtilsInstrumentation extends AbstractInstrumentation {
|
public class TracingContextUtilsInstrumentation extends AbstractInstrumentation {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ElementMatcher<? super TypeDescription> typeMatcher() {
|
public ElementMatcher<? super TypeDescription> typeMatcher() {
|
||||||
return named("unshaded.io.opentelemetry.trace.TracingContextUtils");
|
return named("application.io.opentelemetry.trace.TracingContextUtils");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -87,13 +87,14 @@ public class TracingContextUtilsInstrumentation extends AbstractInstrumentation
|
||||||
|
|
||||||
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||||
public static void methodExit(
|
public static void methodExit(
|
||||||
@Advice.Argument(0) final Span span,
|
@Advice.Argument(0) final Span applicationSpan,
|
||||||
@Advice.Argument(1) final Context context,
|
@Advice.Argument(1) final Context applicationContext,
|
||||||
@Advice.Return(readOnly = false) Context updatedContext) {
|
@Advice.Return(readOnly = false) Context applicationUpdatedContext) {
|
||||||
|
|
||||||
ContextStore<Context, io.grpc.Context> contextStore =
|
ContextStore<Context, io.grpc.Context> contextStore =
|
||||||
InstrumentationContext.get(Context.class, io.grpc.Context.class);
|
InstrumentationContext.get(Context.class, io.grpc.Context.class);
|
||||||
updatedContext = TracingContextUtils.withSpan(span, context, contextStore);
|
applicationUpdatedContext =
|
||||||
|
TracingContextUtils.withSpan(applicationSpan, applicationContext, contextStore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,8 +106,8 @@ public class TracingContextUtilsInstrumentation extends AbstractInstrumentation
|
||||||
}
|
}
|
||||||
|
|
||||||
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||||
public static void methodExit(@Advice.Return(readOnly = false) Span span) {
|
public static void methodExit(@Advice.Return(readOnly = false) Span applicationSpan) {
|
||||||
span = TracingContextUtils.getCurrentSpan();
|
applicationSpan = TracingContextUtils.getCurrentSpan();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,11 +120,12 @@ public class TracingContextUtilsInstrumentation extends AbstractInstrumentation
|
||||||
|
|
||||||
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||||
public static void methodExit(
|
public static void methodExit(
|
||||||
@Advice.Argument(0) final Context context, @Advice.Return(readOnly = false) Span span) {
|
@Advice.Argument(0) final Context context,
|
||||||
|
@Advice.Return(readOnly = false) Span applicationSpan) {
|
||||||
|
|
||||||
ContextStore<Context, io.grpc.Context> contextStore =
|
ContextStore<Context, io.grpc.Context> contextStore =
|
||||||
InstrumentationContext.get(Context.class, io.grpc.Context.class);
|
InstrumentationContext.get(Context.class, io.grpc.Context.class);
|
||||||
span = TracingContextUtils.getSpan(context, contextStore);
|
applicationSpan = TracingContextUtils.getSpan(context, contextStore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,11 +138,12 @@ public class TracingContextUtilsInstrumentation extends AbstractInstrumentation
|
||||||
|
|
||||||
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||||
public static void methodExit(
|
public static void methodExit(
|
||||||
@Advice.Argument(0) final Context context, @Advice.Return(readOnly = false) Span span) {
|
@Advice.Argument(0) final Context context,
|
||||||
|
@Advice.Return(readOnly = false) Span applicationSpan) {
|
||||||
|
|
||||||
ContextStore<Context, io.grpc.Context> contextStore =
|
ContextStore<Context, io.grpc.Context> contextStore =
|
||||||
InstrumentationContext.get(Context.class, io.grpc.Context.class);
|
InstrumentationContext.get(Context.class, io.grpc.Context.class);
|
||||||
span = TracingContextUtils.getSpanWithoutDefault(context, contextStore);
|
applicationSpan = TracingContextUtils.getSpanWithoutDefault(context, contextStore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,8 +156,9 @@ public class TracingContextUtilsInstrumentation extends AbstractInstrumentation
|
||||||
|
|
||||||
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||||
public static void methodExit(
|
public static void methodExit(
|
||||||
@Advice.Argument(0) final Span span, @Advice.Return(readOnly = false) Scope scope) {
|
@Advice.Argument(0) final Span applicationSpan,
|
||||||
scope = TracingContextUtils.currentContextWith(span);
|
@Advice.Return(readOnly = false) Scope applicationScope) {
|
||||||
|
applicationScope = TracingContextUtils.currentContextWith(applicationSpan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,15 +16,14 @@
|
||||||
|
|
||||||
package io.opentelemetry.auto.instrumentation.opentelemetryapi.anotations;
|
package io.opentelemetry.auto.instrumentation.opentelemetryapi.anotations;
|
||||||
|
|
||||||
|
import application.io.opentelemetry.extensions.auto.annotations.WithSpan;
|
||||||
|
import application.io.opentelemetry.trace.Span;
|
||||||
import io.opentelemetry.OpenTelemetry;
|
import io.opentelemetry.OpenTelemetry;
|
||||||
import io.opentelemetry.instrumentation.api.decorator.BaseDecorator;
|
import io.opentelemetry.instrumentation.api.decorator.BaseDecorator;
|
||||||
import io.opentelemetry.trace.Span;
|
|
||||||
import io.opentelemetry.trace.Tracer;
|
import io.opentelemetry.trace.Tracer;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import unshaded.io.opentelemetry.extensions.auto.annotations.WithSpan;
|
|
||||||
import unshaded.io.opentelemetry.trace.Span.Kind;
|
|
||||||
|
|
||||||
public class TraceDecorator extends BaseDecorator {
|
public class TraceDecorator extends BaseDecorator {
|
||||||
public static final TraceDecorator DECORATE = new TraceDecorator();
|
public static final TraceDecorator DECORATE = new TraceDecorator();
|
||||||
|
@ -40,24 +39,25 @@ public class TraceDecorator extends BaseDecorator {
|
||||||
* tries to derive name from its {@code value} attribute. Otherwise delegates to {@link
|
* tries to derive name from its {@code value} attribute. Otherwise delegates to {@link
|
||||||
* #spanNameForMethod(Method)}.
|
* #spanNameForMethod(Method)}.
|
||||||
*/
|
*/
|
||||||
public String spanNameForMethodWithAnnotation(WithSpan annotation, Method method) {
|
public String spanNameForMethodWithAnnotation(WithSpan applicationAnnotation, Method method) {
|
||||||
if (annotation != null && !annotation.value().isEmpty()) {
|
if (applicationAnnotation != null && !applicationAnnotation.value().isEmpty()) {
|
||||||
return annotation.value();
|
return applicationAnnotation.value();
|
||||||
}
|
}
|
||||||
return spanNameForMethod(method);
|
return spanNameForMethod(method);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Span.Kind extractSpanKind(WithSpan annotation) {
|
public io.opentelemetry.trace.Span.Kind extractSpanKind(WithSpan applicationAnnotation) {
|
||||||
Kind unshadedKind = annotation != null ? annotation.kind() : Kind.INTERNAL;
|
Span.Kind applicationKind =
|
||||||
return toShadedOrNull(unshadedKind);
|
applicationAnnotation != null ? applicationAnnotation.kind() : Span.Kind.INTERNAL;
|
||||||
|
return toAgentOrNull(applicationKind);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static io.opentelemetry.trace.Span.Kind toShadedOrNull(
|
public static io.opentelemetry.trace.Span.Kind toAgentOrNull(
|
||||||
final unshaded.io.opentelemetry.trace.Span.Kind unshadedSpanKind) {
|
final Span.Kind applicationSpanKind) {
|
||||||
try {
|
try {
|
||||||
return io.opentelemetry.trace.Span.Kind.valueOf(unshadedSpanKind.name());
|
return io.opentelemetry.trace.Span.Kind.valueOf(applicationSpanKind.name());
|
||||||
} catch (final IllegalArgumentException e) {
|
} catch (final IllegalArgumentException e) {
|
||||||
log.debug("unexpected span kind: {}", unshadedSpanKind.name());
|
log.debug("unexpected span kind: {}", applicationSpanKind.name());
|
||||||
return io.opentelemetry.trace.Span.Kind.INTERNAL;
|
return io.opentelemetry.trace.Span.Kind.INTERNAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,11 +20,11 @@ import static io.opentelemetry.auto.instrumentation.opentelemetryapi.anotations.
|
||||||
import static io.opentelemetry.auto.instrumentation.opentelemetryapi.anotations.TraceDecorator.TRACER;
|
import static io.opentelemetry.auto.instrumentation.opentelemetryapi.anotations.TraceDecorator.TRACER;
|
||||||
import static io.opentelemetry.trace.TracingContextUtils.currentContextWith;
|
import static io.opentelemetry.trace.TracingContextUtils.currentContextWith;
|
||||||
|
|
||||||
|
import application.io.opentelemetry.extensions.auto.annotations.WithSpan;
|
||||||
import io.opentelemetry.instrumentation.auto.api.SpanWithScope;
|
import io.opentelemetry.instrumentation.auto.api.SpanWithScope;
|
||||||
import io.opentelemetry.trace.Span;
|
import io.opentelemetry.trace.Span;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import net.bytebuddy.asm.Advice;
|
import net.bytebuddy.asm.Advice;
|
||||||
import unshaded.io.opentelemetry.extensions.auto.annotations.WithSpan;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instrumentation for methods annotated with {@link
|
* Instrumentation for methods annotated with {@link
|
||||||
|
@ -36,12 +36,12 @@ public class WithSpanAdvice {
|
||||||
|
|
||||||
@Advice.OnMethodEnter(suppress = Throwable.class)
|
@Advice.OnMethodEnter(suppress = Throwable.class)
|
||||||
public static SpanWithScope onEnter(@Advice.Origin final Method method) {
|
public static SpanWithScope onEnter(@Advice.Origin final Method method) {
|
||||||
WithSpan annotation = method.getAnnotation(WithSpan.class);
|
WithSpan applicationAnnotation = method.getAnnotation(WithSpan.class);
|
||||||
|
|
||||||
Span span =
|
Span span =
|
||||||
TRACER
|
TRACER
|
||||||
.spanBuilder(DECORATE.spanNameForMethodWithAnnotation(annotation, method))
|
.spanBuilder(DECORATE.spanNameForMethodWithAnnotation(applicationAnnotation, method))
|
||||||
.setSpanKind(DECORATE.extractSpanKind(annotation))
|
.setSpanKind(DECORATE.extractSpanKind(applicationAnnotation))
|
||||||
.startSpan();
|
.startSpan();
|
||||||
DECORATE.afterStart(span);
|
DECORATE.afterStart(span);
|
||||||
return new SpanWithScope(span, currentContextWith(span));
|
return new SpanWithScope(span, currentContextWith(span));
|
||||||
|
|
|
@ -47,7 +47,7 @@ public final class WithSpanAnnotationInstrumentation
|
||||||
public WithSpanAnnotationInstrumentation() {
|
public WithSpanAnnotationInstrumentation() {
|
||||||
super("trace", "with-span-annotation");
|
super("trace", "with-span-annotation");
|
||||||
annotatedMethodMatcher =
|
annotatedMethodMatcher =
|
||||||
isAnnotatedWith(named("unshaded.io.opentelemetry.extensions.auto.annotations.WithSpan"));
|
isAnnotatedWith(named("application.io.opentelemetry.extensions.auto.annotations.WithSpan"));
|
||||||
excludedMethodsMatcher = configureExcludedMethods();
|
excludedMethodsMatcher = configureExcludedMethods();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,18 +16,18 @@
|
||||||
|
|
||||||
package io.opentelemetry.auto.instrumentation.opentelemetryapi.context;
|
package io.opentelemetry.auto.instrumentation.opentelemetryapi.context;
|
||||||
|
|
||||||
import unshaded.io.opentelemetry.context.Scope;
|
import application.io.opentelemetry.context.Scope;
|
||||||
|
|
||||||
public class UnshadedScope implements Scope {
|
public class ApplicationScope implements Scope {
|
||||||
|
|
||||||
private final io.opentelemetry.context.Scope shadedScope;
|
private final io.opentelemetry.context.Scope agentScope;
|
||||||
|
|
||||||
public UnshadedScope(final io.opentelemetry.context.Scope shadedScope) {
|
public ApplicationScope(final io.opentelemetry.context.Scope agentScope) {
|
||||||
this.shadedScope = shadedScope;
|
this.agentScope = agentScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
shadedScope.close();
|
agentScope.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,11 +16,11 @@
|
||||||
|
|
||||||
package io.opentelemetry.auto.instrumentation.opentelemetryapi.context;
|
package io.opentelemetry.auto.instrumentation.opentelemetryapi.context;
|
||||||
|
|
||||||
|
import application.io.grpc.Context;
|
||||||
|
import application.io.opentelemetry.context.Scope;
|
||||||
import io.opentelemetry.instrumentation.auto.api.ContextStore;
|
import io.opentelemetry.instrumentation.auto.api.ContextStore;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import unshaded.io.grpc.Context;
|
|
||||||
import unshaded.io.opentelemetry.context.Scope;
|
|
||||||
|
|
||||||
public class ContextUtils {
|
public class ContextUtils {
|
||||||
|
|
||||||
|
@ -28,16 +28,16 @@ public class ContextUtils {
|
||||||
|
|
||||||
public static Scope withScopedContext(
|
public static Scope withScopedContext(
|
||||||
final Context context, final ContextStore<Context, io.grpc.Context> contextStore) {
|
final Context context, final ContextStore<Context, io.grpc.Context> contextStore) {
|
||||||
io.grpc.Context shadedContext = contextStore.get(context);
|
io.grpc.Context agentContext = contextStore.get(context);
|
||||||
if (shadedContext == null) {
|
if (agentContext == null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("unexpected context: {}", context, new Exception("unexpected context"));
|
log.debug("unexpected context: {}", context, new Exception("unexpected context"));
|
||||||
}
|
}
|
||||||
return NoopScope.getInstance();
|
return NoopScope.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
io.opentelemetry.context.Scope scope =
|
io.opentelemetry.context.Scope agentScope =
|
||||||
io.opentelemetry.context.ContextUtils.withScopedContext(shadedContext);
|
io.opentelemetry.context.ContextUtils.withScopedContext(agentContext);
|
||||||
return new UnshadedScope(scope);
|
return new ApplicationScope(agentScope);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
package io.opentelemetry.auto.instrumentation.opentelemetryapi.context;
|
package io.opentelemetry.auto.instrumentation.opentelemetryapi.context;
|
||||||
|
|
||||||
import unshaded.io.opentelemetry.context.Scope;
|
import application.io.opentelemetry.context.Scope;
|
||||||
|
|
||||||
/** A {@link Scope} that does nothing when it is created or closed. */
|
/** A {@link Scope} that does nothing when it is created or closed. */
|
||||||
public final class NoopScope implements Scope {
|
public final class NoopScope implements Scope {
|
||||||
|
|
|
@ -16,24 +16,24 @@
|
||||||
|
|
||||||
package io.opentelemetry.auto.instrumentation.opentelemetryapi.context.propagation;
|
package io.opentelemetry.auto.instrumentation.opentelemetryapi.context.propagation;
|
||||||
|
|
||||||
|
import application.io.grpc.Context;
|
||||||
|
import application.io.opentelemetry.context.propagation.ContextPropagators;
|
||||||
|
import application.io.opentelemetry.context.propagation.HttpTextFormat;
|
||||||
import io.opentelemetry.OpenTelemetry;
|
import io.opentelemetry.OpenTelemetry;
|
||||||
import io.opentelemetry.instrumentation.auto.api.ContextStore;
|
import io.opentelemetry.instrumentation.auto.api.ContextStore;
|
||||||
import unshaded.io.grpc.Context;
|
|
||||||
import unshaded.io.opentelemetry.context.propagation.ContextPropagators;
|
|
||||||
import unshaded.io.opentelemetry.context.propagation.HttpTextFormat;
|
|
||||||
|
|
||||||
public class UnshadedContextPropagators implements ContextPropagators {
|
public class ApplicationContextPropagators implements ContextPropagators {
|
||||||
|
|
||||||
private final UnshadedHttpTextFormat unshadedHttpTextFormat;
|
private final ApplicationHttpTextFormat applicationHttpTextFormat;
|
||||||
|
|
||||||
public UnshadedContextPropagators(final ContextStore<Context, io.grpc.Context> contextStore) {
|
public ApplicationContextPropagators(final ContextStore<Context, io.grpc.Context> contextStore) {
|
||||||
unshadedHttpTextFormat =
|
applicationHttpTextFormat =
|
||||||
new UnshadedHttpTextFormat(
|
new ApplicationHttpTextFormat(
|
||||||
OpenTelemetry.getPropagators().getHttpTextFormat(), contextStore);
|
OpenTelemetry.getPropagators().getHttpTextFormat(), contextStore);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HttpTextFormat getHttpTextFormat() {
|
public HttpTextFormat getHttpTextFormat() {
|
||||||
return unshadedHttpTextFormat;
|
return applicationHttpTextFormat;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,112 @@
|
||||||
|
/*
|
||||||
|
* Copyright The OpenTelemetry Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.opentelemetry.auto.instrumentation.opentelemetryapi.context.propagation;
|
||||||
|
|
||||||
|
import application.io.grpc.Context;
|
||||||
|
import application.io.opentelemetry.context.propagation.HttpTextFormat;
|
||||||
|
import io.opentelemetry.instrumentation.auto.api.ContextStore;
|
||||||
|
import java.util.List;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
class ApplicationHttpTextFormat implements HttpTextFormat {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(ApplicationHttpTextFormat.class);
|
||||||
|
|
||||||
|
private final io.opentelemetry.context.propagation.HttpTextFormat agentHttpTextFormat;
|
||||||
|
private final ContextStore<Context, io.grpc.Context> contextStore;
|
||||||
|
|
||||||
|
ApplicationHttpTextFormat(
|
||||||
|
final io.opentelemetry.context.propagation.HttpTextFormat agentHttpTextFormat,
|
||||||
|
final ContextStore<Context, io.grpc.Context> contextStore) {
|
||||||
|
this.agentHttpTextFormat = agentHttpTextFormat;
|
||||||
|
this.contextStore = contextStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> fields() {
|
||||||
|
return agentHttpTextFormat.fields();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <C> Context extract(
|
||||||
|
final Context applicationContext,
|
||||||
|
final C carrier,
|
||||||
|
final HttpTextFormat.Getter<C> applicationGetter) {
|
||||||
|
io.grpc.Context agentContext = contextStore.get(applicationContext);
|
||||||
|
if (agentContext == null) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug(
|
||||||
|
"unexpected context: {}", applicationContext, new Exception("unexpected context"));
|
||||||
|
}
|
||||||
|
return applicationContext;
|
||||||
|
}
|
||||||
|
io.grpc.Context agentUpdatedContext =
|
||||||
|
agentHttpTextFormat.extract(agentContext, carrier, new AgentGetter<>(applicationGetter));
|
||||||
|
if (agentUpdatedContext == agentContext) {
|
||||||
|
return applicationContext;
|
||||||
|
}
|
||||||
|
contextStore.put(applicationContext, agentUpdatedContext);
|
||||||
|
return applicationContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <C> void inject(
|
||||||
|
final Context applicationContext,
|
||||||
|
final C carrier,
|
||||||
|
final HttpTextFormat.Setter<C> applicationSetter) {
|
||||||
|
io.grpc.Context agentContext = contextStore.get(applicationContext);
|
||||||
|
if (agentContext == null) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug(
|
||||||
|
"unexpected context: {}", applicationContext, new Exception("unexpected context"));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
agentHttpTextFormat.inject(agentContext, carrier, new AgentSetter<>(applicationSetter));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class AgentGetter<C>
|
||||||
|
implements io.opentelemetry.context.propagation.HttpTextFormat.Getter<C> {
|
||||||
|
|
||||||
|
private final HttpTextFormat.Getter<C> applicationGetter;
|
||||||
|
|
||||||
|
AgentGetter(final HttpTextFormat.Getter<C> applicationGetter) {
|
||||||
|
this.applicationGetter = applicationGetter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String get(final C carrier, final String key) {
|
||||||
|
return applicationGetter.get(carrier, key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class AgentSetter<C>
|
||||||
|
implements io.opentelemetry.context.propagation.HttpTextFormat.Setter<C> {
|
||||||
|
|
||||||
|
private final HttpTextFormat.Setter<C> applicationSetter;
|
||||||
|
|
||||||
|
AgentSetter(final Setter<C> applicationSetter) {
|
||||||
|
this.applicationSetter = applicationSetter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void set(final C carrier, final String key, final String value) {
|
||||||
|
applicationSetter.set(carrier, key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,106 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright The OpenTelemetry Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.opentelemetry.auto.instrumentation.opentelemetryapi.context.propagation;
|
|
||||||
|
|
||||||
import io.opentelemetry.instrumentation.auto.api.ContextStore;
|
|
||||||
import java.util.List;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import unshaded.io.grpc.Context;
|
|
||||||
import unshaded.io.opentelemetry.context.propagation.HttpTextFormat;
|
|
||||||
|
|
||||||
class UnshadedHttpTextFormat implements HttpTextFormat {
|
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(UnshadedHttpTextFormat.class);
|
|
||||||
|
|
||||||
private final io.opentelemetry.context.propagation.HttpTextFormat shadedHttpTextFormat;
|
|
||||||
private final ContextStore<Context, io.grpc.Context> contextStore;
|
|
||||||
|
|
||||||
UnshadedHttpTextFormat(
|
|
||||||
final io.opentelemetry.context.propagation.HttpTextFormat shadedHttpTextFormat,
|
|
||||||
final ContextStore<Context, io.grpc.Context> contextStore) {
|
|
||||||
this.shadedHttpTextFormat = shadedHttpTextFormat;
|
|
||||||
this.contextStore = contextStore;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> fields() {
|
|
||||||
return shadedHttpTextFormat.fields();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <C> Context extract(
|
|
||||||
final Context context, final C carrier, final HttpTextFormat.Getter<C> getter) {
|
|
||||||
io.grpc.Context shadedContext = contextStore.get(context);
|
|
||||||
if (shadedContext == null) {
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("unexpected context: {}", context, new Exception("unexpected context"));
|
|
||||||
}
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
io.grpc.Context updatedShadedContext =
|
|
||||||
shadedHttpTextFormat.extract(shadedContext, carrier, new UnshadedGetter<>(getter));
|
|
||||||
if (updatedShadedContext == shadedContext) {
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
contextStore.put(context, updatedShadedContext);
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <C> void inject(
|
|
||||||
final Context context, final C carrier, final HttpTextFormat.Setter<C> setter) {
|
|
||||||
io.grpc.Context shadedContext = contextStore.get(context);
|
|
||||||
if (shadedContext == null) {
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("unexpected context: {}", context, new Exception("unexpected context"));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
shadedHttpTextFormat.inject(shadedContext, carrier, new UnshadedSetter<>(setter));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class UnshadedGetter<C>
|
|
||||||
implements io.opentelemetry.context.propagation.HttpTextFormat.Getter<C> {
|
|
||||||
|
|
||||||
private final HttpTextFormat.Getter<C> shadedGetter;
|
|
||||||
|
|
||||||
UnshadedGetter(final HttpTextFormat.Getter<C> shadedGetter) {
|
|
||||||
this.shadedGetter = shadedGetter;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String get(final C carrier, final String key) {
|
|
||||||
return shadedGetter.get(carrier, key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class UnshadedSetter<C>
|
|
||||||
implements io.opentelemetry.context.propagation.HttpTextFormat.Setter<C> {
|
|
||||||
|
|
||||||
private final HttpTextFormat.Setter<C> shadedSetter;
|
|
||||||
|
|
||||||
UnshadedSetter(final Setter<C> shadedSetter) {
|
|
||||||
this.shadedSetter = shadedSetter;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void set(final C carrier, final String key, final String value) {
|
|
||||||
shadedSetter.set(carrier, key, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -16,31 +16,31 @@
|
||||||
|
|
||||||
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
||||||
|
|
||||||
|
import application.io.opentelemetry.metrics.BatchRecorder;
|
||||||
|
import application.io.opentelemetry.metrics.DoubleCounter;
|
||||||
|
import application.io.opentelemetry.metrics.DoubleUpDownCounter;
|
||||||
|
import application.io.opentelemetry.metrics.DoubleValueRecorder;
|
||||||
|
import application.io.opentelemetry.metrics.LongCounter;
|
||||||
|
import application.io.opentelemetry.metrics.LongUpDownCounter;
|
||||||
|
import application.io.opentelemetry.metrics.LongValueRecorder;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import unshaded.io.opentelemetry.metrics.BatchRecorder;
|
|
||||||
import unshaded.io.opentelemetry.metrics.DoubleCounter;
|
|
||||||
import unshaded.io.opentelemetry.metrics.DoubleUpDownCounter;
|
|
||||||
import unshaded.io.opentelemetry.metrics.DoubleValueRecorder;
|
|
||||||
import unshaded.io.opentelemetry.metrics.LongCounter;
|
|
||||||
import unshaded.io.opentelemetry.metrics.LongUpDownCounter;
|
|
||||||
import unshaded.io.opentelemetry.metrics.LongValueRecorder;
|
|
||||||
|
|
||||||
class UnshadedBatchRecorder implements BatchRecorder {
|
class ApplicationBatchRecorder implements BatchRecorder {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(UnshadedBatchRecorder.class);
|
private static final Logger log = LoggerFactory.getLogger(ApplicationBatchRecorder.class);
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.BatchRecorder shadedBatchRecorder;
|
private final io.opentelemetry.metrics.BatchRecorder agentBatchRecorder;
|
||||||
|
|
||||||
UnshadedBatchRecorder(final io.opentelemetry.metrics.BatchRecorder shadedBatchRecorder) {
|
ApplicationBatchRecorder(final io.opentelemetry.metrics.BatchRecorder agentBatchRecorder) {
|
||||||
this.shadedBatchRecorder = shadedBatchRecorder;
|
this.agentBatchRecorder = agentBatchRecorder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BatchRecorder put(final LongValueRecorder measure, final long value) {
|
public BatchRecorder put(final LongValueRecorder measure, final long value) {
|
||||||
if (measure instanceof UnshadedLongValueRecorder) {
|
if (measure instanceof ApplicationLongValueRecorder) {
|
||||||
shadedBatchRecorder.put(
|
agentBatchRecorder.put(
|
||||||
((UnshadedLongValueRecorder) measure).getShadedLongValueRecorder(), value);
|
((ApplicationLongValueRecorder) measure).getAgentLongValueRecorder(), value);
|
||||||
} else {
|
} else {
|
||||||
log.debug("unexpected measure: {}", measure);
|
log.debug("unexpected measure: {}", measure);
|
||||||
}
|
}
|
||||||
|
@ -49,9 +49,9 @@ class UnshadedBatchRecorder implements BatchRecorder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BatchRecorder put(final DoubleValueRecorder measure, final double value) {
|
public BatchRecorder put(final DoubleValueRecorder measure, final double value) {
|
||||||
if (measure instanceof UnshadedDoubleValueRecorder) {
|
if (measure instanceof ApplicationDoubleValueRecorder) {
|
||||||
shadedBatchRecorder.put(
|
agentBatchRecorder.put(
|
||||||
((UnshadedDoubleValueRecorder) measure).getShadedDoubleValueRecorder(), value);
|
((ApplicationDoubleValueRecorder) measure).getAgentDoubleValueRecorder(), value);
|
||||||
} else {
|
} else {
|
||||||
log.debug("unexpected measure: {}", measure);
|
log.debug("unexpected measure: {}", measure);
|
||||||
}
|
}
|
||||||
|
@ -60,8 +60,8 @@ class UnshadedBatchRecorder implements BatchRecorder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BatchRecorder put(final LongCounter counter, final long value) {
|
public BatchRecorder put(final LongCounter counter, final long value) {
|
||||||
if (counter instanceof UnshadedLongCounter) {
|
if (counter instanceof ApplicationLongCounter) {
|
||||||
shadedBatchRecorder.put(((UnshadedLongCounter) counter).getShadedLongCounter(), value);
|
agentBatchRecorder.put(((ApplicationLongCounter) counter).getAgentLongCounter(), value);
|
||||||
} else {
|
} else {
|
||||||
log.debug("unexpected counter: {}", counter);
|
log.debug("unexpected counter: {}", counter);
|
||||||
}
|
}
|
||||||
|
@ -70,8 +70,8 @@ class UnshadedBatchRecorder implements BatchRecorder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BatchRecorder put(final DoubleCounter counter, final double value) {
|
public BatchRecorder put(final DoubleCounter counter, final double value) {
|
||||||
if (counter instanceof UnshadedDoubleCounter) {
|
if (counter instanceof ApplicationDoubleCounter) {
|
||||||
shadedBatchRecorder.put(((UnshadedDoubleCounter) counter).getShadedDoubleCounter(), value);
|
agentBatchRecorder.put(((ApplicationDoubleCounter) counter).getAgentDoubleCounter(), value);
|
||||||
} else {
|
} else {
|
||||||
log.debug("unexpected counter: {}", counter);
|
log.debug("unexpected counter: {}", counter);
|
||||||
}
|
}
|
||||||
|
@ -80,9 +80,9 @@ class UnshadedBatchRecorder implements BatchRecorder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BatchRecorder put(final LongUpDownCounter counter, final long value) {
|
public BatchRecorder put(final LongUpDownCounter counter, final long value) {
|
||||||
if (counter instanceof UnshadedLongUpDownCounter) {
|
if (counter instanceof ApplicationLongUpDownCounter) {
|
||||||
shadedBatchRecorder.put(
|
agentBatchRecorder.put(
|
||||||
((UnshadedLongUpDownCounter) counter).getShadedLongUpDownCounter(), value);
|
((ApplicationLongUpDownCounter) counter).getAgentLongUpDownCounter(), value);
|
||||||
} else {
|
} else {
|
||||||
log.debug("unexpected counter: {}", counter);
|
log.debug("unexpected counter: {}", counter);
|
||||||
}
|
}
|
||||||
|
@ -91,9 +91,9 @@ class UnshadedBatchRecorder implements BatchRecorder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BatchRecorder put(final DoubleUpDownCounter counter, final double value) {
|
public BatchRecorder put(final DoubleUpDownCounter counter, final double value) {
|
||||||
if (counter instanceof UnshadedDoubleUpDownCounter) {
|
if (counter instanceof ApplicationDoubleUpDownCounter) {
|
||||||
shadedBatchRecorder.put(
|
agentBatchRecorder.put(
|
||||||
((UnshadedDoubleUpDownCounter) counter).getShadedDoubleUpDownCounter(), value);
|
((ApplicationDoubleUpDownCounter) counter).getAgentDoubleUpDownCounter(), value);
|
||||||
} else {
|
} else {
|
||||||
log.debug("unexpected counter: {}", counter);
|
log.debug("unexpected counter: {}", counter);
|
||||||
}
|
}
|
||||||
|
@ -102,6 +102,6 @@ class UnshadedBatchRecorder implements BatchRecorder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void record() {
|
public void record() {
|
||||||
shadedBatchRecorder.record();
|
agentBatchRecorder.record();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,82 +16,81 @@
|
||||||
|
|
||||||
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
||||||
|
|
||||||
import io.opentelemetry.auto.instrumentation.opentelemetryapi.LabelsShader;
|
import application.io.opentelemetry.common.Labels;
|
||||||
import unshaded.io.opentelemetry.common.Labels;
|
import application.io.opentelemetry.metrics.DoubleCounter;
|
||||||
import unshaded.io.opentelemetry.metrics.DoubleCounter;
|
import io.opentelemetry.auto.instrumentation.opentelemetryapi.LabelBridging;
|
||||||
|
|
||||||
class UnshadedDoubleCounter implements DoubleCounter {
|
class ApplicationDoubleCounter implements DoubleCounter {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.DoubleCounter shadedDoubleCounter;
|
private final io.opentelemetry.metrics.DoubleCounter agentDoubleCounter;
|
||||||
|
|
||||||
UnshadedDoubleCounter(final io.opentelemetry.metrics.DoubleCounter shadedDoubleCounter) {
|
ApplicationDoubleCounter(final io.opentelemetry.metrics.DoubleCounter agentDoubleCounter) {
|
||||||
this.shadedDoubleCounter = shadedDoubleCounter;
|
this.agentDoubleCounter = agentDoubleCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
io.opentelemetry.metrics.DoubleCounter getShadedDoubleCounter() {
|
io.opentelemetry.metrics.DoubleCounter getAgentDoubleCounter() {
|
||||||
return shadedDoubleCounter;
|
return agentDoubleCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(final double delta, final Labels labels) {
|
public void add(final double delta, final Labels labels) {
|
||||||
shadedDoubleCounter.add(delta, LabelsShader.shade(labels));
|
agentDoubleCounter.add(delta, LabelBridging.toAgent(labels));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BoundDoubleCounter bind(final Labels labels) {
|
public BoundDoubleCounter bind(final Labels labels) {
|
||||||
return new BoundInstrument(shadedDoubleCounter.bind(LabelsShader.shade(labels)));
|
return new BoundInstrument(agentDoubleCounter.bind(LabelBridging.toAgent(labels)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static class BoundInstrument implements DoubleCounter.BoundDoubleCounter {
|
static class BoundInstrument implements DoubleCounter.BoundDoubleCounter {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.DoubleCounter.BoundDoubleCounter
|
private final io.opentelemetry.metrics.DoubleCounter.BoundDoubleCounter agentBoundDoubleCounter;
|
||||||
shadedBoundDoubleCounter;
|
|
||||||
|
|
||||||
BoundInstrument(
|
BoundInstrument(
|
||||||
final io.opentelemetry.metrics.DoubleCounter.BoundDoubleCounter shadedBoundDoubleCounter) {
|
final io.opentelemetry.metrics.DoubleCounter.BoundDoubleCounter agentBoundDoubleCounter) {
|
||||||
this.shadedBoundDoubleCounter = shadedBoundDoubleCounter;
|
this.agentBoundDoubleCounter = agentBoundDoubleCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(final double delta) {
|
public void add(final double delta) {
|
||||||
shadedBoundDoubleCounter.add(delta);
|
agentBoundDoubleCounter.add(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unbind() {
|
public void unbind() {
|
||||||
shadedBoundDoubleCounter.unbind();
|
agentBoundDoubleCounter.unbind();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Builder implements DoubleCounter.Builder {
|
static class Builder implements DoubleCounter.Builder {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.DoubleCounter.Builder shadedBuilder;
|
private final io.opentelemetry.metrics.DoubleCounter.Builder agentBuilder;
|
||||||
|
|
||||||
Builder(final io.opentelemetry.metrics.DoubleCounter.Builder shadedBuilder) {
|
Builder(final io.opentelemetry.metrics.DoubleCounter.Builder agentBuilder) {
|
||||||
this.shadedBuilder = shadedBuilder;
|
this.agentBuilder = agentBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DoubleCounter.Builder setDescription(final String description) {
|
public DoubleCounter.Builder setDescription(final String description) {
|
||||||
shadedBuilder.setDescription(description);
|
agentBuilder.setDescription(description);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DoubleCounter.Builder setUnit(final String unit) {
|
public DoubleCounter.Builder setUnit(final String unit) {
|
||||||
shadedBuilder.setUnit(unit);
|
agentBuilder.setUnit(unit);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DoubleCounter.Builder setConstantLabels(final Labels constantLabels) {
|
public DoubleCounter.Builder setConstantLabels(final Labels constantLabels) {
|
||||||
shadedBuilder.setConstantLabels(LabelsShader.shade(constantLabels));
|
agentBuilder.setConstantLabels(LabelBridging.toAgent(constantLabels));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DoubleCounter build() {
|
public DoubleCounter build() {
|
||||||
return new UnshadedDoubleCounter(shadedBuilder.build());
|
return new ApplicationDoubleCounter(agentBuilder.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,87 +16,87 @@
|
||||||
|
|
||||||
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
||||||
|
|
||||||
import io.opentelemetry.auto.instrumentation.opentelemetryapi.LabelsShader;
|
import application.io.opentelemetry.common.Labels;
|
||||||
|
import application.io.opentelemetry.metrics.DoubleSumObserver;
|
||||||
|
import io.opentelemetry.auto.instrumentation.opentelemetryapi.LabelBridging;
|
||||||
import io.opentelemetry.metrics.AsynchronousInstrument;
|
import io.opentelemetry.metrics.AsynchronousInstrument;
|
||||||
import unshaded.io.opentelemetry.common.Labels;
|
|
||||||
import unshaded.io.opentelemetry.metrics.DoubleSumObserver;
|
|
||||||
|
|
||||||
class UnshadedDoubleSumObserver implements DoubleSumObserver {
|
class ApplicationDoubleSumObserver implements DoubleSumObserver {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.DoubleSumObserver shadedDoubleSumObserver;
|
private final io.opentelemetry.metrics.DoubleSumObserver agentDoubleSumObserver;
|
||||||
|
|
||||||
protected UnshadedDoubleSumObserver(
|
protected ApplicationDoubleSumObserver(
|
||||||
final io.opentelemetry.metrics.DoubleSumObserver shadedDoubleSumObserver) {
|
final io.opentelemetry.metrics.DoubleSumObserver agentDoubleSumObserver) {
|
||||||
this.shadedDoubleSumObserver = shadedDoubleSumObserver;
|
this.agentDoubleSumObserver = agentDoubleSumObserver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCallback(final Callback<DoubleResult> metricUpdater) {
|
public void setCallback(final Callback<DoubleResult> metricUpdater) {
|
||||||
shadedDoubleSumObserver.setCallback(new ShadedResultDoubleSumObserver(metricUpdater));
|
agentDoubleSumObserver.setCallback(new AgentResultDoubleSumObserver(metricUpdater));
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ShadedResultDoubleSumObserver
|
static class AgentResultDoubleSumObserver
|
||||||
implements AsynchronousInstrument.Callback<
|
implements AsynchronousInstrument.Callback<
|
||||||
io.opentelemetry.metrics.DoubleSumObserver.DoubleResult> {
|
io.opentelemetry.metrics.DoubleSumObserver.DoubleResult> {
|
||||||
|
|
||||||
private final Callback<DoubleResult> metricUpdater;
|
private final Callback<DoubleResult> metricUpdater;
|
||||||
|
|
||||||
protected ShadedResultDoubleSumObserver(final Callback<DoubleResult> metricUpdater) {
|
protected AgentResultDoubleSumObserver(final Callback<DoubleResult> metricUpdater) {
|
||||||
this.metricUpdater = metricUpdater;
|
this.metricUpdater = metricUpdater;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(final io.opentelemetry.metrics.DoubleSumObserver.DoubleResult result) {
|
public void update(final io.opentelemetry.metrics.DoubleSumObserver.DoubleResult result) {
|
||||||
metricUpdater.update(new UnshadedResultDoubleSumObserver(result));
|
metricUpdater.update(new ApplicationResultDoubleSumObserver(result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class UnshadedResultDoubleSumObserver implements DoubleResult {
|
static class ApplicationResultDoubleSumObserver implements DoubleResult {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.DoubleSumObserver.DoubleResult
|
private final io.opentelemetry.metrics.DoubleSumObserver.DoubleResult
|
||||||
shadedResultDoubleSumObserver;
|
agentResultDoubleSumObserver;
|
||||||
|
|
||||||
public UnshadedResultDoubleSumObserver(
|
public ApplicationResultDoubleSumObserver(
|
||||||
final io.opentelemetry.metrics.DoubleSumObserver.DoubleResult
|
final io.opentelemetry.metrics.DoubleSumObserver.DoubleResult
|
||||||
shadedResultDoubleSumObserver) {
|
agentResultDoubleSumObserver) {
|
||||||
this.shadedResultDoubleSumObserver = shadedResultDoubleSumObserver;
|
this.agentResultDoubleSumObserver = agentResultDoubleSumObserver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void observe(final double value, final Labels labels) {
|
public void observe(final double value, final Labels labels) {
|
||||||
shadedResultDoubleSumObserver.observe(value, LabelsShader.shade(labels));
|
agentResultDoubleSumObserver.observe(value, LabelBridging.toAgent(labels));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Builder implements DoubleSumObserver.Builder {
|
static class Builder implements DoubleSumObserver.Builder {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.DoubleSumObserver.Builder shadedBuilder;
|
private final io.opentelemetry.metrics.DoubleSumObserver.Builder agentBuilder;
|
||||||
|
|
||||||
protected Builder(final io.opentelemetry.metrics.DoubleSumObserver.Builder shadedBuilder) {
|
protected Builder(final io.opentelemetry.metrics.DoubleSumObserver.Builder agentBuilder) {
|
||||||
this.shadedBuilder = shadedBuilder;
|
this.agentBuilder = agentBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DoubleSumObserver.Builder setDescription(final String description) {
|
public DoubleSumObserver.Builder setDescription(final String description) {
|
||||||
shadedBuilder.setDescription(description);
|
agentBuilder.setDescription(description);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DoubleSumObserver.Builder setUnit(final String unit) {
|
public DoubleSumObserver.Builder setUnit(final String unit) {
|
||||||
shadedBuilder.setUnit(unit);
|
agentBuilder.setUnit(unit);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DoubleSumObserver.Builder setConstantLabels(final Labels constantLabels) {
|
public DoubleSumObserver.Builder setConstantLabels(final Labels constantLabels) {
|
||||||
shadedBuilder.setConstantLabels(LabelsShader.shade(constantLabels));
|
agentBuilder.setConstantLabels(LabelBridging.toAgent(constantLabels));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DoubleSumObserver build() {
|
public DoubleSumObserver build() {
|
||||||
return new UnshadedDoubleSumObserver(shadedBuilder.build());
|
return new ApplicationDoubleSumObserver(agentBuilder.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,84 +16,84 @@
|
||||||
|
|
||||||
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
||||||
|
|
||||||
import io.opentelemetry.auto.instrumentation.opentelemetryapi.LabelsShader;
|
import application.io.opentelemetry.common.Labels;
|
||||||
import unshaded.io.opentelemetry.common.Labels;
|
import application.io.opentelemetry.metrics.DoubleUpDownCounter;
|
||||||
import unshaded.io.opentelemetry.metrics.DoubleUpDownCounter;
|
import io.opentelemetry.auto.instrumentation.opentelemetryapi.LabelBridging;
|
||||||
|
|
||||||
class UnshadedDoubleUpDownCounter implements DoubleUpDownCounter {
|
class ApplicationDoubleUpDownCounter implements DoubleUpDownCounter {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.DoubleUpDownCounter shadedDoubleUpDownCounter;
|
private final io.opentelemetry.metrics.DoubleUpDownCounter agentDoubleUpDownCounter;
|
||||||
|
|
||||||
UnshadedDoubleUpDownCounter(
|
ApplicationDoubleUpDownCounter(
|
||||||
final io.opentelemetry.metrics.DoubleUpDownCounter shadedDoubleUpDownCounter) {
|
final io.opentelemetry.metrics.DoubleUpDownCounter agentDoubleUpDownCounter) {
|
||||||
this.shadedDoubleUpDownCounter = shadedDoubleUpDownCounter;
|
this.agentDoubleUpDownCounter = agentDoubleUpDownCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
io.opentelemetry.metrics.DoubleUpDownCounter getShadedDoubleUpDownCounter() {
|
io.opentelemetry.metrics.DoubleUpDownCounter getAgentDoubleUpDownCounter() {
|
||||||
return shadedDoubleUpDownCounter;
|
return agentDoubleUpDownCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(final double delta, final Labels labels) {
|
public void add(final double delta, final Labels labels) {
|
||||||
shadedDoubleUpDownCounter.add(delta, LabelsShader.shade(labels));
|
agentDoubleUpDownCounter.add(delta, LabelBridging.toAgent(labels));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BoundDoubleUpDownCounter bind(final Labels labels) {
|
public BoundDoubleUpDownCounter bind(final Labels labels) {
|
||||||
return new BoundInstrument(shadedDoubleUpDownCounter.bind(LabelsShader.shade(labels)));
|
return new BoundInstrument(agentDoubleUpDownCounter.bind(LabelBridging.toAgent(labels)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static class BoundInstrument implements BoundDoubleUpDownCounter {
|
static class BoundInstrument implements BoundDoubleUpDownCounter {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.DoubleUpDownCounter.BoundDoubleUpDownCounter
|
private final io.opentelemetry.metrics.DoubleUpDownCounter.BoundDoubleUpDownCounter
|
||||||
shadedBoundDoubleUpDownCounter;
|
agentBoundDoubleUpDownCounter;
|
||||||
|
|
||||||
BoundInstrument(
|
BoundInstrument(
|
||||||
final io.opentelemetry.metrics.DoubleUpDownCounter.BoundDoubleUpDownCounter
|
final io.opentelemetry.metrics.DoubleUpDownCounter.BoundDoubleUpDownCounter
|
||||||
shadedBoundDoubleUpDownCounter) {
|
agentBoundDoubleUpDownCounter) {
|
||||||
this.shadedBoundDoubleUpDownCounter = shadedBoundDoubleUpDownCounter;
|
this.agentBoundDoubleUpDownCounter = agentBoundDoubleUpDownCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(final double delta) {
|
public void add(final double delta) {
|
||||||
shadedBoundDoubleUpDownCounter.add(delta);
|
agentBoundDoubleUpDownCounter.add(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unbind() {
|
public void unbind() {
|
||||||
shadedBoundDoubleUpDownCounter.unbind();
|
agentBoundDoubleUpDownCounter.unbind();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Builder implements DoubleUpDownCounter.Builder {
|
static class Builder implements DoubleUpDownCounter.Builder {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.DoubleUpDownCounter.Builder shadedBuilder;
|
private final io.opentelemetry.metrics.DoubleUpDownCounter.Builder agentBuilder;
|
||||||
|
|
||||||
Builder(final io.opentelemetry.metrics.DoubleUpDownCounter.Builder shadedBuilder) {
|
Builder(final io.opentelemetry.metrics.DoubleUpDownCounter.Builder agentBuilder) {
|
||||||
this.shadedBuilder = shadedBuilder;
|
this.agentBuilder = agentBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DoubleUpDownCounter.Builder setDescription(final String description) {
|
public DoubleUpDownCounter.Builder setDescription(final String description) {
|
||||||
shadedBuilder.setDescription(description);
|
agentBuilder.setDescription(description);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DoubleUpDownCounter.Builder setUnit(final String unit) {
|
public DoubleUpDownCounter.Builder setUnit(final String unit) {
|
||||||
shadedBuilder.setUnit(unit);
|
agentBuilder.setUnit(unit);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DoubleUpDownCounter.Builder setConstantLabels(final Labels constantLabels) {
|
public DoubleUpDownCounter.Builder setConstantLabels(final Labels constantLabels) {
|
||||||
shadedBuilder.setConstantLabels(LabelsShader.shade(constantLabels));
|
agentBuilder.setConstantLabels(LabelBridging.toAgent(constantLabels));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DoubleUpDownCounter build() {
|
public DoubleUpDownCounter build() {
|
||||||
return new UnshadedDoubleUpDownCounter(shadedBuilder.build());
|
return new ApplicationDoubleUpDownCounter(agentBuilder.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,89 +16,87 @@
|
||||||
|
|
||||||
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
||||||
|
|
||||||
import io.opentelemetry.auto.instrumentation.opentelemetryapi.LabelsShader;
|
import application.io.opentelemetry.common.Labels;
|
||||||
|
import application.io.opentelemetry.metrics.DoubleUpDownSumObserver;
|
||||||
|
import io.opentelemetry.auto.instrumentation.opentelemetryapi.LabelBridging;
|
||||||
import io.opentelemetry.metrics.AsynchronousInstrument;
|
import io.opentelemetry.metrics.AsynchronousInstrument;
|
||||||
import unshaded.io.opentelemetry.common.Labels;
|
|
||||||
import unshaded.io.opentelemetry.metrics.DoubleUpDownSumObserver;
|
|
||||||
|
|
||||||
class UnshadedDoubleUpDownSumObserver implements DoubleUpDownSumObserver {
|
class ApplicationDoubleUpDownSumObserver implements DoubleUpDownSumObserver {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.DoubleUpDownSumObserver shadedDoubleUpDownSumObserver;
|
private final io.opentelemetry.metrics.DoubleUpDownSumObserver agentDoubleUpDownSumObserver;
|
||||||
|
|
||||||
protected UnshadedDoubleUpDownSumObserver(
|
protected ApplicationDoubleUpDownSumObserver(
|
||||||
final io.opentelemetry.metrics.DoubleUpDownSumObserver shadedDoubleUpDownSumObserver) {
|
final io.opentelemetry.metrics.DoubleUpDownSumObserver agentDoubleUpDownSumObserver) {
|
||||||
this.shadedDoubleUpDownSumObserver = shadedDoubleUpDownSumObserver;
|
this.agentDoubleUpDownSumObserver = agentDoubleUpDownSumObserver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCallback(final Callback<DoubleResult> metricUpdater) {
|
public void setCallback(final Callback<DoubleResult> metricUpdater) {
|
||||||
shadedDoubleUpDownSumObserver.setCallback(
|
agentDoubleUpDownSumObserver.setCallback(new AgentResultDoubleUpDownSumObserver(metricUpdater));
|
||||||
new ShadedResultDoubleUpDownSumObserver(metricUpdater));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ShadedResultDoubleUpDownSumObserver
|
static class AgentResultDoubleUpDownSumObserver
|
||||||
implements AsynchronousInstrument.Callback<
|
implements AsynchronousInstrument.Callback<
|
||||||
io.opentelemetry.metrics.DoubleUpDownSumObserver.DoubleResult> {
|
io.opentelemetry.metrics.DoubleUpDownSumObserver.DoubleResult> {
|
||||||
|
|
||||||
private final Callback<DoubleResult> metricUpdater;
|
private final Callback<DoubleResult> metricUpdater;
|
||||||
|
|
||||||
protected ShadedResultDoubleUpDownSumObserver(final Callback<DoubleResult> metricUpdater) {
|
protected AgentResultDoubleUpDownSumObserver(final Callback<DoubleResult> metricUpdater) {
|
||||||
this.metricUpdater = metricUpdater;
|
this.metricUpdater = metricUpdater;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(final io.opentelemetry.metrics.DoubleUpDownSumObserver.DoubleResult result) {
|
public void update(final io.opentelemetry.metrics.DoubleUpDownSumObserver.DoubleResult result) {
|
||||||
metricUpdater.update(new UnshadedResultDoubleUpDownSumObserver(result));
|
metricUpdater.update(new ApplicationResultDoubleUpDownSumObserver(result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class UnshadedResultDoubleUpDownSumObserver implements DoubleResult {
|
static class ApplicationResultDoubleUpDownSumObserver implements DoubleResult {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.DoubleUpDownSumObserver.DoubleResult
|
private final io.opentelemetry.metrics.DoubleUpDownSumObserver.DoubleResult
|
||||||
shadedResultDoubleUpDownSumObserver;
|
agentResultDoubleUpDownSumObserver;
|
||||||
|
|
||||||
public UnshadedResultDoubleUpDownSumObserver(
|
public ApplicationResultDoubleUpDownSumObserver(
|
||||||
final io.opentelemetry.metrics.DoubleUpDownSumObserver.DoubleResult
|
final io.opentelemetry.metrics.DoubleUpDownSumObserver.DoubleResult
|
||||||
shadedResultDoubleUpDownSumObserver) {
|
agentResultDoubleUpDownSumObserver) {
|
||||||
this.shadedResultDoubleUpDownSumObserver = shadedResultDoubleUpDownSumObserver;
|
this.agentResultDoubleUpDownSumObserver = agentResultDoubleUpDownSumObserver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void observe(final double value, final Labels labels) {
|
public void observe(final double value, final Labels labels) {
|
||||||
shadedResultDoubleUpDownSumObserver.observe(value, LabelsShader.shade(labels));
|
agentResultDoubleUpDownSumObserver.observe(value, LabelBridging.toAgent(labels));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Builder implements DoubleUpDownSumObserver.Builder {
|
static class Builder implements DoubleUpDownSumObserver.Builder {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.DoubleUpDownSumObserver.Builder shadedBuilder;
|
private final io.opentelemetry.metrics.DoubleUpDownSumObserver.Builder agentBuilder;
|
||||||
|
|
||||||
protected Builder(
|
protected Builder(final io.opentelemetry.metrics.DoubleUpDownSumObserver.Builder agentBuilder) {
|
||||||
final io.opentelemetry.metrics.DoubleUpDownSumObserver.Builder shadedBuilder) {
|
this.agentBuilder = agentBuilder;
|
||||||
this.shadedBuilder = shadedBuilder;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DoubleUpDownSumObserver.Builder setDescription(final String description) {
|
public DoubleUpDownSumObserver.Builder setDescription(final String description) {
|
||||||
shadedBuilder.setDescription(description);
|
agentBuilder.setDescription(description);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DoubleUpDownSumObserver.Builder setUnit(final String unit) {
|
public DoubleUpDownSumObserver.Builder setUnit(final String unit) {
|
||||||
shadedBuilder.setUnit(unit);
|
agentBuilder.setUnit(unit);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DoubleUpDownSumObserver.Builder setConstantLabels(final Labels constantLabels) {
|
public DoubleUpDownSumObserver.Builder setConstantLabels(final Labels constantLabels) {
|
||||||
shadedBuilder.setConstantLabels(LabelsShader.shade(constantLabels));
|
agentBuilder.setConstantLabels(LabelBridging.toAgent(constantLabels));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DoubleUpDownSumObserver build() {
|
public DoubleUpDownSumObserver build() {
|
||||||
return new UnshadedDoubleUpDownSumObserver(shadedBuilder.build());
|
return new ApplicationDoubleUpDownSumObserver(agentBuilder.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,87 +16,87 @@
|
||||||
|
|
||||||
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
||||||
|
|
||||||
import io.opentelemetry.auto.instrumentation.opentelemetryapi.LabelsShader;
|
import application.io.opentelemetry.common.Labels;
|
||||||
|
import application.io.opentelemetry.metrics.DoubleValueObserver;
|
||||||
|
import io.opentelemetry.auto.instrumentation.opentelemetryapi.LabelBridging;
|
||||||
import io.opentelemetry.metrics.AsynchronousInstrument;
|
import io.opentelemetry.metrics.AsynchronousInstrument;
|
||||||
import unshaded.io.opentelemetry.common.Labels;
|
|
||||||
import unshaded.io.opentelemetry.metrics.DoubleValueObserver;
|
|
||||||
|
|
||||||
class UnshadedDoubleValueObserver implements DoubleValueObserver {
|
class ApplicationDoubleValueObserver implements DoubleValueObserver {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.DoubleValueObserver shadedDoubleValueObserver;
|
private final io.opentelemetry.metrics.DoubleValueObserver agentDoubleValueObserver;
|
||||||
|
|
||||||
protected UnshadedDoubleValueObserver(
|
protected ApplicationDoubleValueObserver(
|
||||||
final io.opentelemetry.metrics.DoubleValueObserver shadedDoubleValueObserver) {
|
final io.opentelemetry.metrics.DoubleValueObserver agentDoubleValueObserver) {
|
||||||
this.shadedDoubleValueObserver = shadedDoubleValueObserver;
|
this.agentDoubleValueObserver = agentDoubleValueObserver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCallback(final Callback<DoubleResult> metricUpdater) {
|
public void setCallback(final Callback<DoubleResult> metricUpdater) {
|
||||||
shadedDoubleValueObserver.setCallback(new ShadedResultDoubleValueObserver(metricUpdater));
|
agentDoubleValueObserver.setCallback(new AgentResultDoubleValueObserver(metricUpdater));
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ShadedResultDoubleValueObserver
|
static class AgentResultDoubleValueObserver
|
||||||
implements AsynchronousInstrument.Callback<
|
implements AsynchronousInstrument.Callback<
|
||||||
io.opentelemetry.metrics.DoubleValueObserver.DoubleResult> {
|
io.opentelemetry.metrics.DoubleValueObserver.DoubleResult> {
|
||||||
|
|
||||||
private final Callback<DoubleResult> metricUpdater;
|
private final Callback<DoubleResult> metricUpdater;
|
||||||
|
|
||||||
protected ShadedResultDoubleValueObserver(final Callback<DoubleResult> metricUpdater) {
|
protected AgentResultDoubleValueObserver(final Callback<DoubleResult> metricUpdater) {
|
||||||
this.metricUpdater = metricUpdater;
|
this.metricUpdater = metricUpdater;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(final io.opentelemetry.metrics.DoubleValueObserver.DoubleResult result) {
|
public void update(final io.opentelemetry.metrics.DoubleValueObserver.DoubleResult result) {
|
||||||
metricUpdater.update(new UnshadedResultDoubleValueObserver(result));
|
metricUpdater.update(new ApplicationResultDoubleValueObserver(result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class UnshadedResultDoubleValueObserver implements DoubleResult {
|
static class ApplicationResultDoubleValueObserver implements DoubleResult {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.DoubleValueObserver.DoubleResult
|
private final io.opentelemetry.metrics.DoubleValueObserver.DoubleResult
|
||||||
shadedResultDoubleValueObserver;
|
agentResultDoubleValueObserver;
|
||||||
|
|
||||||
public UnshadedResultDoubleValueObserver(
|
public ApplicationResultDoubleValueObserver(
|
||||||
final io.opentelemetry.metrics.DoubleValueObserver.DoubleResult
|
final io.opentelemetry.metrics.DoubleValueObserver.DoubleResult
|
||||||
shadedResultDoubleValueObserver) {
|
agentResultDoubleValueObserver) {
|
||||||
this.shadedResultDoubleValueObserver = shadedResultDoubleValueObserver;
|
this.agentResultDoubleValueObserver = agentResultDoubleValueObserver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void observe(final double value, final Labels labels) {
|
public void observe(final double value, final Labels labels) {
|
||||||
shadedResultDoubleValueObserver.observe(value, LabelsShader.shade(labels));
|
agentResultDoubleValueObserver.observe(value, LabelBridging.toAgent(labels));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Builder implements DoubleValueObserver.Builder {
|
static class Builder implements DoubleValueObserver.Builder {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.DoubleValueObserver.Builder shadedBuilder;
|
private final io.opentelemetry.metrics.DoubleValueObserver.Builder agentBuilder;
|
||||||
|
|
||||||
protected Builder(final io.opentelemetry.metrics.DoubleValueObserver.Builder shadedBuilder) {
|
protected Builder(final io.opentelemetry.metrics.DoubleValueObserver.Builder agentBuilder) {
|
||||||
this.shadedBuilder = shadedBuilder;
|
this.agentBuilder = agentBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DoubleValueObserver.Builder setDescription(final String description) {
|
public DoubleValueObserver.Builder setDescription(final String description) {
|
||||||
shadedBuilder.setDescription(description);
|
agentBuilder.setDescription(description);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DoubleValueObserver.Builder setUnit(final String unit) {
|
public DoubleValueObserver.Builder setUnit(final String unit) {
|
||||||
shadedBuilder.setUnit(unit);
|
agentBuilder.setUnit(unit);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DoubleValueObserver.Builder setConstantLabels(final Labels constantLabels) {
|
public DoubleValueObserver.Builder setConstantLabels(final Labels constantLabels) {
|
||||||
shadedBuilder.setConstantLabels(LabelsShader.shade(constantLabels));
|
agentBuilder.setConstantLabels(LabelBridging.toAgent(constantLabels));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DoubleValueObserver build() {
|
public DoubleValueObserver build() {
|
||||||
return new UnshadedDoubleValueObserver(shadedBuilder.build());
|
return new ApplicationDoubleValueObserver(agentBuilder.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,84 +16,84 @@
|
||||||
|
|
||||||
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
||||||
|
|
||||||
import io.opentelemetry.auto.instrumentation.opentelemetryapi.LabelsShader;
|
import application.io.opentelemetry.common.Labels;
|
||||||
import unshaded.io.opentelemetry.common.Labels;
|
import application.io.opentelemetry.metrics.DoubleValueRecorder;
|
||||||
import unshaded.io.opentelemetry.metrics.DoubleValueRecorder;
|
import io.opentelemetry.auto.instrumentation.opentelemetryapi.LabelBridging;
|
||||||
|
|
||||||
class UnshadedDoubleValueRecorder implements DoubleValueRecorder {
|
class ApplicationDoubleValueRecorder implements DoubleValueRecorder {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.DoubleValueRecorder shadedDoubleValueRecorder;
|
private final io.opentelemetry.metrics.DoubleValueRecorder agentDoubleValueRecorder;
|
||||||
|
|
||||||
protected UnshadedDoubleValueRecorder(
|
protected ApplicationDoubleValueRecorder(
|
||||||
final io.opentelemetry.metrics.DoubleValueRecorder shadedDoubleValueRecorder) {
|
final io.opentelemetry.metrics.DoubleValueRecorder agentDoubleValueRecorder) {
|
||||||
this.shadedDoubleValueRecorder = shadedDoubleValueRecorder;
|
this.agentDoubleValueRecorder = agentDoubleValueRecorder;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected io.opentelemetry.metrics.DoubleValueRecorder getShadedDoubleValueRecorder() {
|
protected io.opentelemetry.metrics.DoubleValueRecorder getAgentDoubleValueRecorder() {
|
||||||
return shadedDoubleValueRecorder;
|
return agentDoubleValueRecorder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void record(final double delta, final Labels labels) {
|
public void record(final double delta, final Labels labels) {
|
||||||
shadedDoubleValueRecorder.record(delta, LabelsShader.shade(labels));
|
agentDoubleValueRecorder.record(delta, LabelBridging.toAgent(labels));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BoundDoubleValueRecorder bind(final Labels labels) {
|
public BoundDoubleValueRecorder bind(final Labels labels) {
|
||||||
return new BoundInstrument(shadedDoubleValueRecorder.bind(LabelsShader.shade(labels)));
|
return new BoundInstrument(agentDoubleValueRecorder.bind(LabelBridging.toAgent(labels)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static class BoundInstrument implements DoubleValueRecorder.BoundDoubleValueRecorder {
|
static class BoundInstrument implements DoubleValueRecorder.BoundDoubleValueRecorder {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.DoubleValueRecorder.BoundDoubleValueRecorder
|
private final io.opentelemetry.metrics.DoubleValueRecorder.BoundDoubleValueRecorder
|
||||||
shadedBoundDoubleMeasure;
|
agentBoundDoubleMeasure;
|
||||||
|
|
||||||
public BoundInstrument(
|
public BoundInstrument(
|
||||||
final io.opentelemetry.metrics.DoubleValueRecorder.BoundDoubleValueRecorder
|
final io.opentelemetry.metrics.DoubleValueRecorder.BoundDoubleValueRecorder
|
||||||
shadedBoundDoubleMeasure) {
|
agentBoundDoubleMeasure) {
|
||||||
this.shadedBoundDoubleMeasure = shadedBoundDoubleMeasure;
|
this.agentBoundDoubleMeasure = agentBoundDoubleMeasure;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void record(final double delta) {
|
public void record(final double delta) {
|
||||||
shadedBoundDoubleMeasure.record(delta);
|
agentBoundDoubleMeasure.record(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unbind() {
|
public void unbind() {
|
||||||
shadedBoundDoubleMeasure.unbind();
|
agentBoundDoubleMeasure.unbind();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Builder implements DoubleValueRecorder.Builder {
|
static class Builder implements DoubleValueRecorder.Builder {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.DoubleValueRecorder.Builder shadedBuilder;
|
private final io.opentelemetry.metrics.DoubleValueRecorder.Builder agentBuilder;
|
||||||
|
|
||||||
public Builder(final io.opentelemetry.metrics.DoubleValueRecorder.Builder shadedBuilder) {
|
public Builder(final io.opentelemetry.metrics.DoubleValueRecorder.Builder agentBuilder) {
|
||||||
this.shadedBuilder = shadedBuilder;
|
this.agentBuilder = agentBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DoubleValueRecorder.Builder setDescription(final String description) {
|
public DoubleValueRecorder.Builder setDescription(final String description) {
|
||||||
shadedBuilder.setDescription(description);
|
agentBuilder.setDescription(description);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DoubleValueRecorder.Builder setUnit(final String unit) {
|
public DoubleValueRecorder.Builder setUnit(final String unit) {
|
||||||
shadedBuilder.setUnit(unit);
|
agentBuilder.setUnit(unit);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DoubleValueRecorder.Builder setConstantLabels(final Labels constantLabels) {
|
public DoubleValueRecorder.Builder setConstantLabels(final Labels constantLabels) {
|
||||||
shadedBuilder.setConstantLabels(LabelsShader.shade(constantLabels));
|
agentBuilder.setConstantLabels(LabelBridging.toAgent(constantLabels));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DoubleValueRecorder build() {
|
public DoubleValueRecorder build() {
|
||||||
return new UnshadedDoubleValueRecorder(shadedBuilder.build());
|
return new ApplicationDoubleValueRecorder(agentBuilder.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,81 +16,81 @@
|
||||||
|
|
||||||
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
||||||
|
|
||||||
import io.opentelemetry.auto.instrumentation.opentelemetryapi.LabelsShader;
|
import application.io.opentelemetry.common.Labels;
|
||||||
import unshaded.io.opentelemetry.common.Labels;
|
import application.io.opentelemetry.metrics.LongCounter;
|
||||||
import unshaded.io.opentelemetry.metrics.LongCounter;
|
import io.opentelemetry.auto.instrumentation.opentelemetryapi.LabelBridging;
|
||||||
|
|
||||||
class UnshadedLongCounter implements LongCounter {
|
class ApplicationLongCounter implements LongCounter {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.LongCounter shadedLongCounter;
|
private final io.opentelemetry.metrics.LongCounter agentLongCounter;
|
||||||
|
|
||||||
UnshadedLongCounter(final io.opentelemetry.metrics.LongCounter shadedLongCounter) {
|
ApplicationLongCounter(final io.opentelemetry.metrics.LongCounter agentLongCounter) {
|
||||||
this.shadedLongCounter = shadedLongCounter;
|
this.agentLongCounter = agentLongCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
io.opentelemetry.metrics.LongCounter getShadedLongCounter() {
|
io.opentelemetry.metrics.LongCounter getAgentLongCounter() {
|
||||||
return shadedLongCounter;
|
return agentLongCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(final long delta, final Labels labels) {
|
public void add(final long delta, final Labels labels) {
|
||||||
shadedLongCounter.add(delta, LabelsShader.shade(labels));
|
agentLongCounter.add(delta, LabelBridging.toAgent(labels));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BoundLongCounter bind(final Labels labels) {
|
public BoundLongCounter bind(final Labels labels) {
|
||||||
return new BoundInstrument(shadedLongCounter.bind(LabelsShader.shade(labels)));
|
return new BoundInstrument(agentLongCounter.bind(LabelBridging.toAgent(labels)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static class BoundInstrument implements LongCounter.BoundLongCounter {
|
static class BoundInstrument implements LongCounter.BoundLongCounter {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.LongCounter.BoundLongCounter shadedBoundLongCounter;
|
private final io.opentelemetry.metrics.LongCounter.BoundLongCounter agentBoundLongCounter;
|
||||||
|
|
||||||
BoundInstrument(
|
BoundInstrument(
|
||||||
final io.opentelemetry.metrics.LongCounter.BoundLongCounter shadedBoundLongCounter) {
|
final io.opentelemetry.metrics.LongCounter.BoundLongCounter agentBoundLongCounter) {
|
||||||
this.shadedBoundLongCounter = shadedBoundLongCounter;
|
this.agentBoundLongCounter = agentBoundLongCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(final long delta) {
|
public void add(final long delta) {
|
||||||
shadedBoundLongCounter.add(delta);
|
agentBoundLongCounter.add(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unbind() {
|
public void unbind() {
|
||||||
shadedBoundLongCounter.unbind();
|
agentBoundLongCounter.unbind();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Builder implements LongCounter.Builder {
|
static class Builder implements LongCounter.Builder {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.LongCounter.Builder shadedBuilder;
|
private final io.opentelemetry.metrics.LongCounter.Builder agentBuilder;
|
||||||
|
|
||||||
Builder(final io.opentelemetry.metrics.LongCounter.Builder shadedBuilder) {
|
Builder(final io.opentelemetry.metrics.LongCounter.Builder agentBuilder) {
|
||||||
this.shadedBuilder = shadedBuilder;
|
this.agentBuilder = agentBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongCounter.Builder setDescription(final String description) {
|
public LongCounter.Builder setDescription(final String description) {
|
||||||
shadedBuilder.setDescription(description);
|
agentBuilder.setDescription(description);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongCounter.Builder setUnit(final String unit) {
|
public LongCounter.Builder setUnit(final String unit) {
|
||||||
shadedBuilder.setUnit(unit);
|
agentBuilder.setUnit(unit);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongCounter.Builder setConstantLabels(final Labels constantLabels) {
|
public LongCounter.Builder setConstantLabels(final Labels constantLabels) {
|
||||||
shadedBuilder.setConstantLabels(LabelsShader.shade(constantLabels));
|
agentBuilder.setConstantLabels(LabelBridging.toAgent(constantLabels));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongCounter build() {
|
public LongCounter build() {
|
||||||
return new UnshadedLongCounter(shadedBuilder.build());
|
return new ApplicationLongCounter(agentBuilder.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,85 +16,85 @@
|
||||||
|
|
||||||
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
||||||
|
|
||||||
import io.opentelemetry.auto.instrumentation.opentelemetryapi.LabelsShader;
|
import application.io.opentelemetry.common.Labels;
|
||||||
|
import application.io.opentelemetry.metrics.LongSumObserver;
|
||||||
|
import io.opentelemetry.auto.instrumentation.opentelemetryapi.LabelBridging;
|
||||||
import io.opentelemetry.metrics.AsynchronousInstrument;
|
import io.opentelemetry.metrics.AsynchronousInstrument;
|
||||||
import unshaded.io.opentelemetry.common.Labels;
|
|
||||||
import unshaded.io.opentelemetry.metrics.LongSumObserver;
|
|
||||||
|
|
||||||
class UnshadedLongSumObserver implements LongSumObserver {
|
class ApplicationLongSumObserver implements LongSumObserver {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.LongSumObserver shadedLongSumObserver;
|
private final io.opentelemetry.metrics.LongSumObserver agentLongSumObserver;
|
||||||
|
|
||||||
protected UnshadedLongSumObserver(
|
protected ApplicationLongSumObserver(
|
||||||
final io.opentelemetry.metrics.LongSumObserver shadedLongSumObserver) {
|
final io.opentelemetry.metrics.LongSumObserver agentLongSumObserver) {
|
||||||
this.shadedLongSumObserver = shadedLongSumObserver;
|
this.agentLongSumObserver = agentLongSumObserver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCallback(final Callback<LongResult> metricUpdater) {
|
public void setCallback(final Callback<LongResult> metricUpdater) {
|
||||||
shadedLongSumObserver.setCallback(new ShadedResultLongSumObserver(metricUpdater));
|
agentLongSumObserver.setCallback(new AgentResultLongSumObserver(metricUpdater));
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ShadedResultLongSumObserver
|
static class AgentResultLongSumObserver
|
||||||
implements AsynchronousInstrument.Callback<
|
implements AsynchronousInstrument.Callback<
|
||||||
io.opentelemetry.metrics.LongSumObserver.LongResult> {
|
io.opentelemetry.metrics.LongSumObserver.LongResult> {
|
||||||
|
|
||||||
private final Callback<LongResult> metricUpdater;
|
private final Callback<LongResult> metricUpdater;
|
||||||
|
|
||||||
protected ShadedResultLongSumObserver(final Callback<LongResult> metricUpdater) {
|
protected AgentResultLongSumObserver(final Callback<LongResult> metricUpdater) {
|
||||||
this.metricUpdater = metricUpdater;
|
this.metricUpdater = metricUpdater;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(final io.opentelemetry.metrics.LongSumObserver.LongResult result) {
|
public void update(final io.opentelemetry.metrics.LongSumObserver.LongResult result) {
|
||||||
metricUpdater.update(new UnshadedResultLongSumObserver(result));
|
metricUpdater.update(new ApplicationResultLongSumObserver(result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class UnshadedResultLongSumObserver implements LongResult {
|
static class ApplicationResultLongSumObserver implements LongResult {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.LongSumObserver.LongResult shadedResultLongSumObserver;
|
private final io.opentelemetry.metrics.LongSumObserver.LongResult agentResultLongSumObserver;
|
||||||
|
|
||||||
public UnshadedResultLongSumObserver(
|
public ApplicationResultLongSumObserver(
|
||||||
final io.opentelemetry.metrics.LongSumObserver.LongResult shadedResultLongSumObserver) {
|
final io.opentelemetry.metrics.LongSumObserver.LongResult agentResultLongSumObserver) {
|
||||||
this.shadedResultLongSumObserver = shadedResultLongSumObserver;
|
this.agentResultLongSumObserver = agentResultLongSumObserver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void observe(final long value, final Labels labels) {
|
public void observe(final long value, final Labels labels) {
|
||||||
shadedResultLongSumObserver.observe(value, LabelsShader.shade(labels));
|
agentResultLongSumObserver.observe(value, LabelBridging.toAgent(labels));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Builder implements LongSumObserver.Builder {
|
static class Builder implements LongSumObserver.Builder {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.LongSumObserver.Builder shadedBuilder;
|
private final io.opentelemetry.metrics.LongSumObserver.Builder agentBuilder;
|
||||||
|
|
||||||
protected Builder(final io.opentelemetry.metrics.LongSumObserver.Builder shadedBuilder) {
|
protected Builder(final io.opentelemetry.metrics.LongSumObserver.Builder agentBuilder) {
|
||||||
this.shadedBuilder = shadedBuilder;
|
this.agentBuilder = agentBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongSumObserver.Builder setDescription(final String description) {
|
public LongSumObserver.Builder setDescription(final String description) {
|
||||||
shadedBuilder.setDescription(description);
|
agentBuilder.setDescription(description);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongSumObserver.Builder setUnit(final String unit) {
|
public LongSumObserver.Builder setUnit(final String unit) {
|
||||||
shadedBuilder.setUnit(unit);
|
agentBuilder.setUnit(unit);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongSumObserver.Builder setConstantLabels(final Labels constantLabels) {
|
public LongSumObserver.Builder setConstantLabels(final Labels constantLabels) {
|
||||||
shadedBuilder.setConstantLabels(LabelsShader.shade(constantLabels));
|
agentBuilder.setConstantLabels(LabelBridging.toAgent(constantLabels));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongSumObserver build() {
|
public LongSumObserver build() {
|
||||||
return new UnshadedLongSumObserver(shadedBuilder.build());
|
return new ApplicationLongSumObserver(agentBuilder.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,84 +16,84 @@
|
||||||
|
|
||||||
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
||||||
|
|
||||||
import io.opentelemetry.auto.instrumentation.opentelemetryapi.LabelsShader;
|
import application.io.opentelemetry.common.Labels;
|
||||||
import unshaded.io.opentelemetry.common.Labels;
|
import application.io.opentelemetry.metrics.LongUpDownCounter;
|
||||||
import unshaded.io.opentelemetry.metrics.LongUpDownCounter;
|
import io.opentelemetry.auto.instrumentation.opentelemetryapi.LabelBridging;
|
||||||
|
|
||||||
class UnshadedLongUpDownCounter implements LongUpDownCounter {
|
class ApplicationLongUpDownCounter implements LongUpDownCounter {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.LongUpDownCounter shadedLongUpDownCounter;
|
private final io.opentelemetry.metrics.LongUpDownCounter agentLongUpDownCounter;
|
||||||
|
|
||||||
UnshadedLongUpDownCounter(
|
ApplicationLongUpDownCounter(
|
||||||
final io.opentelemetry.metrics.LongUpDownCounter shadedLongUpDownCounter) {
|
final io.opentelemetry.metrics.LongUpDownCounter agentLongUpDownCounter) {
|
||||||
this.shadedLongUpDownCounter = shadedLongUpDownCounter;
|
this.agentLongUpDownCounter = agentLongUpDownCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
io.opentelemetry.metrics.LongUpDownCounter getShadedLongUpDownCounter() {
|
io.opentelemetry.metrics.LongUpDownCounter getAgentLongUpDownCounter() {
|
||||||
return shadedLongUpDownCounter;
|
return agentLongUpDownCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(final long delta, final Labels labels) {
|
public void add(final long delta, final Labels labels) {
|
||||||
shadedLongUpDownCounter.add(delta, LabelsShader.shade(labels));
|
agentLongUpDownCounter.add(delta, LabelBridging.toAgent(labels));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BoundLongUpDownCounter bind(final Labels labels) {
|
public BoundLongUpDownCounter bind(final Labels labels) {
|
||||||
return new BoundInstrument(shadedLongUpDownCounter.bind(LabelsShader.shade(labels)));
|
return new BoundInstrument(agentLongUpDownCounter.bind(LabelBridging.toAgent(labels)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static class BoundInstrument implements BoundLongUpDownCounter {
|
static class BoundInstrument implements BoundLongUpDownCounter {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.LongUpDownCounter.BoundLongUpDownCounter
|
private final io.opentelemetry.metrics.LongUpDownCounter.BoundLongUpDownCounter
|
||||||
shadedBoundLongUpDownCounter;
|
agentBoundLongUpDownCounter;
|
||||||
|
|
||||||
BoundInstrument(
|
BoundInstrument(
|
||||||
final io.opentelemetry.metrics.LongUpDownCounter.BoundLongUpDownCounter
|
final io.opentelemetry.metrics.LongUpDownCounter.BoundLongUpDownCounter
|
||||||
shadedBoundLongUpDownCounter) {
|
agentBoundLongUpDownCounter) {
|
||||||
this.shadedBoundLongUpDownCounter = shadedBoundLongUpDownCounter;
|
this.agentBoundLongUpDownCounter = agentBoundLongUpDownCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(final long delta) {
|
public void add(final long delta) {
|
||||||
shadedBoundLongUpDownCounter.add(delta);
|
agentBoundLongUpDownCounter.add(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unbind() {
|
public void unbind() {
|
||||||
shadedBoundLongUpDownCounter.unbind();
|
agentBoundLongUpDownCounter.unbind();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Builder implements LongUpDownCounter.Builder {
|
static class Builder implements LongUpDownCounter.Builder {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.LongUpDownCounter.Builder shadedBuilder;
|
private final io.opentelemetry.metrics.LongUpDownCounter.Builder agentBuilder;
|
||||||
|
|
||||||
Builder(final io.opentelemetry.metrics.LongUpDownCounter.Builder shadedBuilder) {
|
Builder(final io.opentelemetry.metrics.LongUpDownCounter.Builder agentBuilder) {
|
||||||
this.shadedBuilder = shadedBuilder;
|
this.agentBuilder = agentBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongUpDownCounter.Builder setDescription(final String description) {
|
public LongUpDownCounter.Builder setDescription(final String description) {
|
||||||
shadedBuilder.setDescription(description);
|
agentBuilder.setDescription(description);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongUpDownCounter.Builder setUnit(final String unit) {
|
public LongUpDownCounter.Builder setUnit(final String unit) {
|
||||||
shadedBuilder.setUnit(unit);
|
agentBuilder.setUnit(unit);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongUpDownCounter.Builder setConstantLabels(final Labels constantLabels) {
|
public LongUpDownCounter.Builder setConstantLabels(final Labels constantLabels) {
|
||||||
shadedBuilder.setConstantLabels(LabelsShader.shade(constantLabels));
|
agentBuilder.setConstantLabels(LabelBridging.toAgent(constantLabels));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongUpDownCounter build() {
|
public LongUpDownCounter build() {
|
||||||
return new UnshadedLongUpDownCounter(shadedBuilder.build());
|
return new ApplicationLongUpDownCounter(agentBuilder.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,87 +16,87 @@
|
||||||
|
|
||||||
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
||||||
|
|
||||||
import io.opentelemetry.auto.instrumentation.opentelemetryapi.LabelsShader;
|
import application.io.opentelemetry.common.Labels;
|
||||||
|
import application.io.opentelemetry.metrics.LongUpDownSumObserver;
|
||||||
|
import io.opentelemetry.auto.instrumentation.opentelemetryapi.LabelBridging;
|
||||||
import io.opentelemetry.metrics.AsynchronousInstrument;
|
import io.opentelemetry.metrics.AsynchronousInstrument;
|
||||||
import unshaded.io.opentelemetry.common.Labels;
|
|
||||||
import unshaded.io.opentelemetry.metrics.LongUpDownSumObserver;
|
|
||||||
|
|
||||||
class UnshadedLongUpDownSumObserver implements LongUpDownSumObserver {
|
class ApplicationLongUpDownSumObserver implements LongUpDownSumObserver {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.LongUpDownSumObserver shadedLongUpDownSumObserver;
|
private final io.opentelemetry.metrics.LongUpDownSumObserver agentLongUpDownSumObserver;
|
||||||
|
|
||||||
protected UnshadedLongUpDownSumObserver(
|
protected ApplicationLongUpDownSumObserver(
|
||||||
final io.opentelemetry.metrics.LongUpDownSumObserver shadedLongUpDownSumObserver) {
|
final io.opentelemetry.metrics.LongUpDownSumObserver agentLongUpDownSumObserver) {
|
||||||
this.shadedLongUpDownSumObserver = shadedLongUpDownSumObserver;
|
this.agentLongUpDownSumObserver = agentLongUpDownSumObserver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCallback(final Callback<LongResult> metricUpdater) {
|
public void setCallback(final Callback<LongResult> metricUpdater) {
|
||||||
shadedLongUpDownSumObserver.setCallback(new ShadedResultLongUpDownSumObserver(metricUpdater));
|
agentLongUpDownSumObserver.setCallback(new AgentResultLongUpDownSumObserver(metricUpdater));
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ShadedResultLongUpDownSumObserver
|
static class AgentResultLongUpDownSumObserver
|
||||||
implements AsynchronousInstrument.Callback<
|
implements AsynchronousInstrument.Callback<
|
||||||
io.opentelemetry.metrics.LongUpDownSumObserver.LongResult> {
|
io.opentelemetry.metrics.LongUpDownSumObserver.LongResult> {
|
||||||
|
|
||||||
private final Callback<LongResult> metricUpdater;
|
private final Callback<LongResult> metricUpdater;
|
||||||
|
|
||||||
protected ShadedResultLongUpDownSumObserver(final Callback<LongResult> metricUpdater) {
|
protected AgentResultLongUpDownSumObserver(final Callback<LongResult> metricUpdater) {
|
||||||
this.metricUpdater = metricUpdater;
|
this.metricUpdater = metricUpdater;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(final io.opentelemetry.metrics.LongUpDownSumObserver.LongResult result) {
|
public void update(final io.opentelemetry.metrics.LongUpDownSumObserver.LongResult result) {
|
||||||
metricUpdater.update(new UnshadedResultLongUpDownSumObserver(result));
|
metricUpdater.update(new ApplicationResultLongUpDownSumObserver(result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class UnshadedResultLongUpDownSumObserver implements LongResult {
|
static class ApplicationResultLongUpDownSumObserver implements LongResult {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.LongUpDownSumObserver.LongResult
|
private final io.opentelemetry.metrics.LongUpDownSumObserver.LongResult
|
||||||
shadedResultLongUpDownSumObserver;
|
agentResultLongUpDownSumObserver;
|
||||||
|
|
||||||
public UnshadedResultLongUpDownSumObserver(
|
public ApplicationResultLongUpDownSumObserver(
|
||||||
final io.opentelemetry.metrics.LongUpDownSumObserver.LongResult
|
final io.opentelemetry.metrics.LongUpDownSumObserver.LongResult
|
||||||
shadedResultLongUpDownSumObserver) {
|
agentResultLongUpDownSumObserver) {
|
||||||
this.shadedResultLongUpDownSumObserver = shadedResultLongUpDownSumObserver;
|
this.agentResultLongUpDownSumObserver = agentResultLongUpDownSumObserver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void observe(final long value, final Labels labels) {
|
public void observe(final long value, final Labels labels) {
|
||||||
shadedResultLongUpDownSumObserver.observe(value, LabelsShader.shade(labels));
|
agentResultLongUpDownSumObserver.observe(value, LabelBridging.toAgent(labels));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Builder implements LongUpDownSumObserver.Builder {
|
static class Builder implements LongUpDownSumObserver.Builder {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.LongUpDownSumObserver.Builder shadedBuilder;
|
private final io.opentelemetry.metrics.LongUpDownSumObserver.Builder agentBuilder;
|
||||||
|
|
||||||
protected Builder(final io.opentelemetry.metrics.LongUpDownSumObserver.Builder shadedBuilder) {
|
protected Builder(final io.opentelemetry.metrics.LongUpDownSumObserver.Builder agentBuilder) {
|
||||||
this.shadedBuilder = shadedBuilder;
|
this.agentBuilder = agentBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongUpDownSumObserver.Builder setDescription(final String description) {
|
public LongUpDownSumObserver.Builder setDescription(final String description) {
|
||||||
shadedBuilder.setDescription(description);
|
agentBuilder.setDescription(description);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongUpDownSumObserver.Builder setUnit(final String unit) {
|
public LongUpDownSumObserver.Builder setUnit(final String unit) {
|
||||||
shadedBuilder.setUnit(unit);
|
agentBuilder.setUnit(unit);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongUpDownSumObserver.Builder setConstantLabels(final Labels constantLabels) {
|
public LongUpDownSumObserver.Builder setConstantLabels(final Labels constantLabels) {
|
||||||
shadedBuilder.setConstantLabels(LabelsShader.shade(constantLabels));
|
agentBuilder.setConstantLabels(LabelBridging.toAgent(constantLabels));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongUpDownSumObserver build() {
|
public LongUpDownSumObserver build() {
|
||||||
return new UnshadedLongUpDownSumObserver(shadedBuilder.build());
|
return new ApplicationLongUpDownSumObserver(agentBuilder.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,85 +16,85 @@
|
||||||
|
|
||||||
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
||||||
|
|
||||||
import io.opentelemetry.auto.instrumentation.opentelemetryapi.LabelsShader;
|
import application.io.opentelemetry.common.Labels;
|
||||||
import unshaded.io.opentelemetry.common.Labels;
|
import application.io.opentelemetry.metrics.LongValueObserver;
|
||||||
import unshaded.io.opentelemetry.metrics.LongValueObserver;
|
import io.opentelemetry.auto.instrumentation.opentelemetryapi.LabelBridging;
|
||||||
|
|
||||||
class UnshadedLongValueObserver implements LongValueObserver {
|
class ApplicationLongValueObserver implements LongValueObserver {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.LongValueObserver shadedLongValueObserver;
|
private final io.opentelemetry.metrics.LongValueObserver agentLongValueObserver;
|
||||||
|
|
||||||
public UnshadedLongValueObserver(
|
public ApplicationLongValueObserver(
|
||||||
final io.opentelemetry.metrics.LongValueObserver shadedLongValueObserver) {
|
final io.opentelemetry.metrics.LongValueObserver agentLongValueObserver) {
|
||||||
this.shadedLongValueObserver = shadedLongValueObserver;
|
this.agentLongValueObserver = agentLongValueObserver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCallback(final Callback<LongResult> metricUpdater) {
|
public void setCallback(final Callback<LongResult> metricUpdater) {
|
||||||
shadedLongValueObserver.setCallback(new ShadedResultLongValueObserver(metricUpdater));
|
agentLongValueObserver.setCallback(new AgentResultLongValueObserver(metricUpdater));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ShadedResultLongValueObserver
|
public static class AgentResultLongValueObserver
|
||||||
implements io.opentelemetry.metrics.AsynchronousInstrument.Callback<
|
implements io.opentelemetry.metrics.AsynchronousInstrument.Callback<
|
||||||
io.opentelemetry.metrics.LongValueObserver.LongResult> {
|
io.opentelemetry.metrics.LongValueObserver.LongResult> {
|
||||||
|
|
||||||
private final Callback<LongResult> metricUpdater;
|
private final Callback<LongResult> metricUpdater;
|
||||||
|
|
||||||
public ShadedResultLongValueObserver(final Callback<LongResult> metricUpdater) {
|
public AgentResultLongValueObserver(final Callback<LongResult> metricUpdater) {
|
||||||
this.metricUpdater = metricUpdater;
|
this.metricUpdater = metricUpdater;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(final io.opentelemetry.metrics.LongValueObserver.LongResult result) {
|
public void update(final io.opentelemetry.metrics.LongValueObserver.LongResult result) {
|
||||||
metricUpdater.update(new UnshadedResultLongValueObserver(result));
|
metricUpdater.update(new ApplicationResultLongValueObserver(result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class UnshadedResultLongValueObserver implements LongResult {
|
public static class ApplicationResultLongValueObserver implements LongResult {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.LongValueObserver.LongResult
|
private final io.opentelemetry.metrics.LongValueObserver.LongResult
|
||||||
shadedResultLongValueObserver;
|
agentResultLongValueObserver;
|
||||||
|
|
||||||
public UnshadedResultLongValueObserver(
|
public ApplicationResultLongValueObserver(
|
||||||
final io.opentelemetry.metrics.LongValueObserver.LongResult shadedResultLongValueObserver) {
|
final io.opentelemetry.metrics.LongValueObserver.LongResult agentResultLongValueObserver) {
|
||||||
this.shadedResultLongValueObserver = shadedResultLongValueObserver;
|
this.agentResultLongValueObserver = agentResultLongValueObserver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void observe(final long value, final Labels labels) {
|
public void observe(final long value, final Labels labels) {
|
||||||
shadedResultLongValueObserver.observe(value, LabelsShader.shade(labels));
|
agentResultLongValueObserver.observe(value, LabelBridging.toAgent(labels));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Builder implements LongValueObserver.Builder {
|
static class Builder implements LongValueObserver.Builder {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.LongValueObserver.Builder shadedBuilder;
|
private final io.opentelemetry.metrics.LongValueObserver.Builder agentBuilder;
|
||||||
|
|
||||||
public Builder(final io.opentelemetry.metrics.LongValueObserver.Builder shadedBuilder) {
|
public Builder(final io.opentelemetry.metrics.LongValueObserver.Builder agentBuilder) {
|
||||||
this.shadedBuilder = shadedBuilder;
|
this.agentBuilder = agentBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongValueObserver.Builder setDescription(final String description) {
|
public LongValueObserver.Builder setDescription(final String description) {
|
||||||
shadedBuilder.setDescription(description);
|
agentBuilder.setDescription(description);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongValueObserver.Builder setUnit(final String unit) {
|
public LongValueObserver.Builder setUnit(final String unit) {
|
||||||
shadedBuilder.setUnit(unit);
|
agentBuilder.setUnit(unit);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongValueObserver.Builder setConstantLabels(final Labels constantLabels) {
|
public LongValueObserver.Builder setConstantLabels(final Labels constantLabels) {
|
||||||
shadedBuilder.setConstantLabels(LabelsShader.shade(constantLabels));
|
agentBuilder.setConstantLabels(LabelBridging.toAgent(constantLabels));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongValueObserver build() {
|
public LongValueObserver build() {
|
||||||
return new UnshadedLongValueObserver(shadedBuilder.build());
|
return new ApplicationLongValueObserver(agentBuilder.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,84 +16,84 @@
|
||||||
|
|
||||||
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
||||||
|
|
||||||
import io.opentelemetry.auto.instrumentation.opentelemetryapi.LabelsShader;
|
import application.io.opentelemetry.common.Labels;
|
||||||
import unshaded.io.opentelemetry.common.Labels;
|
import application.io.opentelemetry.metrics.LongValueRecorder;
|
||||||
import unshaded.io.opentelemetry.metrics.LongValueRecorder;
|
import io.opentelemetry.auto.instrumentation.opentelemetryapi.LabelBridging;
|
||||||
|
|
||||||
class UnshadedLongValueRecorder implements LongValueRecorder {
|
class ApplicationLongValueRecorder implements LongValueRecorder {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.LongValueRecorder shadedLongValueRecorder;
|
private final io.opentelemetry.metrics.LongValueRecorder agentLongValueRecorder;
|
||||||
|
|
||||||
protected UnshadedLongValueRecorder(
|
protected ApplicationLongValueRecorder(
|
||||||
final io.opentelemetry.metrics.LongValueRecorder shadedLongValueRecorder) {
|
final io.opentelemetry.metrics.LongValueRecorder agentLongValueRecorder) {
|
||||||
this.shadedLongValueRecorder = shadedLongValueRecorder;
|
this.agentLongValueRecorder = agentLongValueRecorder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public io.opentelemetry.metrics.LongValueRecorder getShadedLongValueRecorder() {
|
public io.opentelemetry.metrics.LongValueRecorder getAgentLongValueRecorder() {
|
||||||
return shadedLongValueRecorder;
|
return agentLongValueRecorder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void record(final long delta, final Labels labels) {
|
public void record(final long delta, final Labels labels) {
|
||||||
shadedLongValueRecorder.record(delta, LabelsShader.shade(labels));
|
agentLongValueRecorder.record(delta, LabelBridging.toAgent(labels));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BoundLongValueRecorder bind(final Labels labels) {
|
public BoundLongValueRecorder bind(final Labels labels) {
|
||||||
return new BoundInstrument(shadedLongValueRecorder.bind(LabelsShader.shade(labels)));
|
return new BoundInstrument(agentLongValueRecorder.bind(LabelBridging.toAgent(labels)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static class BoundInstrument implements LongValueRecorder.BoundLongValueRecorder {
|
static class BoundInstrument implements LongValueRecorder.BoundLongValueRecorder {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.LongValueRecorder.BoundLongValueRecorder
|
private final io.opentelemetry.metrics.LongValueRecorder.BoundLongValueRecorder
|
||||||
shadedBoundLongValueRecorder;
|
agentBoundLongValueRecorder;
|
||||||
|
|
||||||
protected BoundInstrument(
|
protected BoundInstrument(
|
||||||
final io.opentelemetry.metrics.LongValueRecorder.BoundLongValueRecorder
|
final io.opentelemetry.metrics.LongValueRecorder.BoundLongValueRecorder
|
||||||
shadedBoundLongValueRecorder) {
|
agentBoundLongValueRecorder) {
|
||||||
this.shadedBoundLongValueRecorder = shadedBoundLongValueRecorder;
|
this.agentBoundLongValueRecorder = agentBoundLongValueRecorder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void record(final long delta) {
|
public void record(final long delta) {
|
||||||
shadedBoundLongValueRecorder.record(delta);
|
agentBoundLongValueRecorder.record(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unbind() {
|
public void unbind() {
|
||||||
shadedBoundLongValueRecorder.unbind();
|
agentBoundLongValueRecorder.unbind();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Builder implements LongValueRecorder.Builder {
|
static class Builder implements LongValueRecorder.Builder {
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.LongValueRecorder.Builder shadedBuilder;
|
private final io.opentelemetry.metrics.LongValueRecorder.Builder agentBuilder;
|
||||||
|
|
||||||
protected Builder(final io.opentelemetry.metrics.LongValueRecorder.Builder shadedBuilder) {
|
protected Builder(final io.opentelemetry.metrics.LongValueRecorder.Builder agentBuilder) {
|
||||||
this.shadedBuilder = shadedBuilder;
|
this.agentBuilder = agentBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongValueRecorder.Builder setDescription(final String description) {
|
public LongValueRecorder.Builder setDescription(final String description) {
|
||||||
shadedBuilder.setDescription(description);
|
agentBuilder.setDescription(description);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongValueRecorder.Builder setUnit(final String unit) {
|
public LongValueRecorder.Builder setUnit(final String unit) {
|
||||||
shadedBuilder.setUnit(unit);
|
agentBuilder.setUnit(unit);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongValueRecorder.Builder setConstantLabels(final Labels constantLabels) {
|
public LongValueRecorder.Builder setConstantLabels(final Labels constantLabels) {
|
||||||
shadedBuilder.setConstantLabels(LabelsShader.shade(constantLabels));
|
agentBuilder.setConstantLabels(LabelBridging.toAgent(constantLabels));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongValueRecorder build() {
|
public LongValueRecorder build() {
|
||||||
return new UnshadedLongValueRecorder(shadedBuilder.build());
|
return new ApplicationLongValueRecorder(agentBuilder.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,108 @@
|
||||||
|
/*
|
||||||
|
* Copyright The OpenTelemetry Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
||||||
|
|
||||||
|
import application.io.opentelemetry.metrics.BatchRecorder;
|
||||||
|
import application.io.opentelemetry.metrics.DoubleCounter;
|
||||||
|
import application.io.opentelemetry.metrics.DoubleSumObserver;
|
||||||
|
import application.io.opentelemetry.metrics.DoubleUpDownCounter;
|
||||||
|
import application.io.opentelemetry.metrics.DoubleUpDownSumObserver;
|
||||||
|
import application.io.opentelemetry.metrics.DoubleValueObserver;
|
||||||
|
import application.io.opentelemetry.metrics.DoubleValueRecorder;
|
||||||
|
import application.io.opentelemetry.metrics.LongCounter;
|
||||||
|
import application.io.opentelemetry.metrics.LongSumObserver;
|
||||||
|
import application.io.opentelemetry.metrics.LongUpDownCounter;
|
||||||
|
import application.io.opentelemetry.metrics.LongUpDownSumObserver;
|
||||||
|
import application.io.opentelemetry.metrics.LongValueObserver;
|
||||||
|
import application.io.opentelemetry.metrics.LongValueRecorder;
|
||||||
|
import application.io.opentelemetry.metrics.Meter;
|
||||||
|
|
||||||
|
class ApplicationMeter implements Meter {
|
||||||
|
|
||||||
|
private final io.opentelemetry.metrics.Meter agentMeter;
|
||||||
|
|
||||||
|
ApplicationMeter(final io.opentelemetry.metrics.Meter agentMeter) {
|
||||||
|
this.agentMeter = agentMeter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DoubleCounter.Builder doubleCounterBuilder(final String name) {
|
||||||
|
return new ApplicationDoubleCounter.Builder(agentMeter.doubleCounterBuilder(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LongCounter.Builder longCounterBuilder(final String name) {
|
||||||
|
return new ApplicationLongCounter.Builder(agentMeter.longCounterBuilder(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DoubleUpDownCounter.Builder doubleUpDownCounterBuilder(final String name) {
|
||||||
|
return new ApplicationDoubleUpDownCounter.Builder(agentMeter.doubleUpDownCounterBuilder(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LongUpDownCounter.Builder longUpDownCounterBuilder(final String name) {
|
||||||
|
return new ApplicationLongUpDownCounter.Builder(agentMeter.longUpDownCounterBuilder(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DoubleValueRecorder.Builder doubleValueRecorderBuilder(final String name) {
|
||||||
|
return new ApplicationDoubleValueRecorder.Builder(agentMeter.doubleValueRecorderBuilder(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LongValueRecorder.Builder longValueRecorderBuilder(final String name) {
|
||||||
|
return new ApplicationLongValueRecorder.Builder(agentMeter.longValueRecorderBuilder(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DoubleSumObserver.Builder doubleSumObserverBuilder(final String name) {
|
||||||
|
return new ApplicationDoubleSumObserver.Builder(agentMeter.doubleSumObserverBuilder(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LongSumObserver.Builder longSumObserverBuilder(final String name) {
|
||||||
|
return new ApplicationLongSumObserver.Builder(agentMeter.longSumObserverBuilder(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DoubleUpDownSumObserver.Builder doubleUpDownSumObserverBuilder(final String name) {
|
||||||
|
return new ApplicationDoubleUpDownSumObserver.Builder(
|
||||||
|
agentMeter.doubleUpDownSumObserverBuilder(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LongUpDownSumObserver.Builder longUpDownSumObserverBuilder(final String name) {
|
||||||
|
return new ApplicationLongUpDownSumObserver.Builder(
|
||||||
|
agentMeter.longUpDownSumObserverBuilder(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DoubleValueObserver.Builder doubleValueObserverBuilder(final String name) {
|
||||||
|
return new ApplicationDoubleValueObserver.Builder(agentMeter.doubleValueObserverBuilder(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LongValueObserver.Builder longValueObserverBuilder(final String name) {
|
||||||
|
return new ApplicationLongValueObserver.Builder(agentMeter.longValueObserverBuilder(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BatchRecorder newBatchRecorder(final String... keyValuePairs) {
|
||||||
|
return new ApplicationBatchRecorder(agentMeter.newBatchRecorder(keyValuePairs));
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,20 +16,20 @@
|
||||||
|
|
||||||
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
||||||
|
|
||||||
import unshaded.io.opentelemetry.metrics.Meter;
|
import application.io.opentelemetry.metrics.Meter;
|
||||||
import unshaded.io.opentelemetry.metrics.MeterProvider;
|
import application.io.opentelemetry.metrics.MeterProvider;
|
||||||
|
|
||||||
public class UnshadedMeterProvider implements MeterProvider {
|
public class ApplicationMeterProvider implements MeterProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Meter get(final String instrumentationName) {
|
public Meter get(final String instrumentationName) {
|
||||||
return new UnshadedMeter(
|
return new ApplicationMeter(
|
||||||
io.opentelemetry.OpenTelemetry.getMeterProvider().get(instrumentationName));
|
io.opentelemetry.OpenTelemetry.getMeterProvider().get(instrumentationName));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Meter get(final String instrumentationName, final String instrumentationVersion) {
|
public Meter get(final String instrumentationName, final String instrumentationVersion) {
|
||||||
return new UnshadedMeter(
|
return new ApplicationMeter(
|
||||||
io.opentelemetry.OpenTelemetry.getMeterProvider()
|
io.opentelemetry.OpenTelemetry.getMeterProvider()
|
||||||
.get(instrumentationName, instrumentationVersion));
|
.get(instrumentationName, instrumentationVersion));
|
||||||
}
|
}
|
|
@ -1,108 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright The OpenTelemetry Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.opentelemetry.auto.instrumentation.opentelemetryapi.metrics;
|
|
||||||
|
|
||||||
import unshaded.io.opentelemetry.metrics.BatchRecorder;
|
|
||||||
import unshaded.io.opentelemetry.metrics.DoubleCounter;
|
|
||||||
import unshaded.io.opentelemetry.metrics.DoubleSumObserver;
|
|
||||||
import unshaded.io.opentelemetry.metrics.DoubleUpDownCounter;
|
|
||||||
import unshaded.io.opentelemetry.metrics.DoubleUpDownSumObserver;
|
|
||||||
import unshaded.io.opentelemetry.metrics.DoubleValueObserver;
|
|
||||||
import unshaded.io.opentelemetry.metrics.DoubleValueRecorder;
|
|
||||||
import unshaded.io.opentelemetry.metrics.LongCounter;
|
|
||||||
import unshaded.io.opentelemetry.metrics.LongSumObserver;
|
|
||||||
import unshaded.io.opentelemetry.metrics.LongUpDownCounter;
|
|
||||||
import unshaded.io.opentelemetry.metrics.LongUpDownSumObserver;
|
|
||||||
import unshaded.io.opentelemetry.metrics.LongValueObserver;
|
|
||||||
import unshaded.io.opentelemetry.metrics.LongValueRecorder;
|
|
||||||
import unshaded.io.opentelemetry.metrics.Meter;
|
|
||||||
|
|
||||||
class UnshadedMeter implements Meter {
|
|
||||||
|
|
||||||
private final io.opentelemetry.metrics.Meter shadedMeter;
|
|
||||||
|
|
||||||
UnshadedMeter(final io.opentelemetry.metrics.Meter shadedMeter) {
|
|
||||||
this.shadedMeter = shadedMeter;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DoubleCounter.Builder doubleCounterBuilder(final String name) {
|
|
||||||
return new UnshadedDoubleCounter.Builder(shadedMeter.doubleCounterBuilder(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LongCounter.Builder longCounterBuilder(final String name) {
|
|
||||||
return new UnshadedLongCounter.Builder(shadedMeter.longCounterBuilder(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DoubleUpDownCounter.Builder doubleUpDownCounterBuilder(final String name) {
|
|
||||||
return new UnshadedDoubleUpDownCounter.Builder(shadedMeter.doubleUpDownCounterBuilder(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LongUpDownCounter.Builder longUpDownCounterBuilder(final String name) {
|
|
||||||
return new UnshadedLongUpDownCounter.Builder(shadedMeter.longUpDownCounterBuilder(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DoubleValueRecorder.Builder doubleValueRecorderBuilder(final String name) {
|
|
||||||
return new UnshadedDoubleValueRecorder.Builder(shadedMeter.doubleValueRecorderBuilder(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LongValueRecorder.Builder longValueRecorderBuilder(final String name) {
|
|
||||||
return new UnshadedLongValueRecorder.Builder(shadedMeter.longValueRecorderBuilder(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DoubleSumObserver.Builder doubleSumObserverBuilder(final String name) {
|
|
||||||
return new UnshadedDoubleSumObserver.Builder(shadedMeter.doubleSumObserverBuilder(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LongSumObserver.Builder longSumObserverBuilder(final String name) {
|
|
||||||
return new UnshadedLongSumObserver.Builder(shadedMeter.longSumObserverBuilder(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DoubleUpDownSumObserver.Builder doubleUpDownSumObserverBuilder(final String name) {
|
|
||||||
return new UnshadedDoubleUpDownSumObserver.Builder(
|
|
||||||
shadedMeter.doubleUpDownSumObserverBuilder(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LongUpDownSumObserver.Builder longUpDownSumObserverBuilder(final String name) {
|
|
||||||
return new UnshadedLongUpDownSumObserver.Builder(
|
|
||||||
shadedMeter.longUpDownSumObserverBuilder(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DoubleValueObserver.Builder doubleValueObserverBuilder(final String name) {
|
|
||||||
return new UnshadedDoubleValueObserver.Builder(shadedMeter.doubleValueObserverBuilder(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LongValueObserver.Builder longValueObserverBuilder(final String name) {
|
|
||||||
return new UnshadedLongValueObserver.Builder(shadedMeter.longValueObserverBuilder(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BatchRecorder newBatchRecorder(final String... keyValuePairs) {
|
|
||||||
return new UnshadedBatchRecorder(shadedMeter.newBatchRecorder(keyValuePairs));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,268 @@
|
||||||
|
/*
|
||||||
|
* Copyright The OpenTelemetry Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.opentelemetry.auto.instrumentation.opentelemetryapi.trace;
|
||||||
|
|
||||||
|
import static io.opentelemetry.auto.instrumentation.opentelemetryapi.trace.Bridging.toAgent;
|
||||||
|
import static io.opentelemetry.auto.instrumentation.opentelemetryapi.trace.Bridging.toAgentOrNull;
|
||||||
|
|
||||||
|
import application.io.grpc.Context;
|
||||||
|
import application.io.opentelemetry.common.AttributeValue;
|
||||||
|
import application.io.opentelemetry.common.Attributes;
|
||||||
|
import application.io.opentelemetry.trace.EndSpanOptions;
|
||||||
|
import application.io.opentelemetry.trace.Event;
|
||||||
|
import application.io.opentelemetry.trace.Link;
|
||||||
|
import application.io.opentelemetry.trace.Span;
|
||||||
|
import application.io.opentelemetry.trace.SpanContext;
|
||||||
|
import application.io.opentelemetry.trace.Status;
|
||||||
|
import io.opentelemetry.instrumentation.auto.api.ContextStore;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
class ApplicationSpan implements Span {
|
||||||
|
|
||||||
|
private final io.opentelemetry.trace.Span agentSpan;
|
||||||
|
|
||||||
|
ApplicationSpan(final io.opentelemetry.trace.Span agentSpan) {
|
||||||
|
this.agentSpan = agentSpan;
|
||||||
|
}
|
||||||
|
|
||||||
|
io.opentelemetry.trace.Span getAgentSpan() {
|
||||||
|
return agentSpan;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAttribute(final String key, final String value) {
|
||||||
|
agentSpan.setAttribute(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAttribute(final String key, final long value) {
|
||||||
|
agentSpan.setAttribute(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAttribute(final String key, final double value) {
|
||||||
|
agentSpan.setAttribute(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAttribute(final String key, final boolean value) {
|
||||||
|
agentSpan.setAttribute(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAttribute(final String key, final AttributeValue applicationValue) {
|
||||||
|
io.opentelemetry.common.AttributeValue agentValue = Bridging.toAgentOrNull(applicationValue);
|
||||||
|
if (agentValue != null) {
|
||||||
|
agentSpan.setAttribute(key, agentValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addEvent(final String name) {
|
||||||
|
agentSpan.addEvent(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addEvent(final String name, final long timestamp) {
|
||||||
|
agentSpan.addEvent(name, timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addEvent(final String name, final Attributes applicationAttributes) {
|
||||||
|
agentSpan.addEvent(name, Bridging.toAgent(applicationAttributes));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addEvent(
|
||||||
|
final String name, final Attributes applicationAttributes, final long timestamp) {
|
||||||
|
agentSpan.addEvent(name, Bridging.toAgent(applicationAttributes), timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addEvent(final Event applicationEvent) {
|
||||||
|
addEvent(applicationEvent.getName(), applicationEvent.getAttributes());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addEvent(final Event applicationEvent, final long timestamp) {
|
||||||
|
addEvent(applicationEvent.getName(), applicationEvent.getAttributes(), timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setStatus(final Status applicationStatus) {
|
||||||
|
io.opentelemetry.trace.Status agentStatus = Bridging.toAgentOrNull(applicationStatus);
|
||||||
|
if (agentStatus != null) {
|
||||||
|
agentSpan.setStatus(agentStatus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void recordException(Throwable throwable) {
|
||||||
|
agentSpan.recordException(throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateName(final String name) {
|
||||||
|
agentSpan.updateName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void end() {
|
||||||
|
agentSpan.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void end(final EndSpanOptions applicationEndOptions) {
|
||||||
|
agentSpan.end(toAgent(applicationEndOptions));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SpanContext getContext() {
|
||||||
|
return Bridging.toApplication(agentSpan.getContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isRecording() {
|
||||||
|
return agentSpan.isRecording();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object other) {
|
||||||
|
if (!(other instanceof ApplicationSpan)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return agentSpan.equals(((ApplicationSpan) other).agentSpan);
|
||||||
|
}
|
||||||
|
|
||||||
|
static class Builder implements Span.Builder {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(Builder.class);
|
||||||
|
|
||||||
|
private final io.opentelemetry.trace.Span.Builder agentBuilder;
|
||||||
|
private final ContextStore<Context, io.grpc.Context> contextStore;
|
||||||
|
|
||||||
|
Builder(
|
||||||
|
final io.opentelemetry.trace.Span.Builder agentBuilder,
|
||||||
|
ContextStore<Context, io.grpc.Context> contextStore) {
|
||||||
|
this.agentBuilder = agentBuilder;
|
||||||
|
this.contextStore = contextStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Span.Builder setParent(final Span applicationParent) {
|
||||||
|
if (applicationParent instanceof ApplicationSpan) {
|
||||||
|
agentBuilder.setParent(((ApplicationSpan) applicationParent).getAgentSpan());
|
||||||
|
} else {
|
||||||
|
log.debug("unexpected parent span: {}", applicationParent);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Span.Builder setParent(final SpanContext applicationRemoteParent) {
|
||||||
|
agentBuilder.setParent(Bridging.toAgent(applicationRemoteParent));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Span.Builder setParent(Context applicationContext) {
|
||||||
|
agentBuilder.setParent(contextStore.get(applicationContext));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Span.Builder setNoParent() {
|
||||||
|
agentBuilder.setNoParent();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Span.Builder addLink(final SpanContext applicationSpanContext) {
|
||||||
|
agentBuilder.addLink(Bridging.toAgent(applicationSpanContext));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Span.Builder addLink(
|
||||||
|
final SpanContext applicationSpanContext, final Attributes applicationAttributes) {
|
||||||
|
agentBuilder.addLink(Bridging.toAgent(applicationSpanContext));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Span.Builder addLink(final Link applicationLink) {
|
||||||
|
agentBuilder.addLink(
|
||||||
|
Bridging.toAgent(applicationLink.getContext()),
|
||||||
|
Bridging.toAgent(applicationLink.getAttributes()));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Span.Builder setAttribute(final String key, final String value) {
|
||||||
|
agentBuilder.setAttribute(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Span.Builder setAttribute(final String key, final long value) {
|
||||||
|
agentBuilder.setAttribute(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Span.Builder setAttribute(final String key, final double value) {
|
||||||
|
agentBuilder.setAttribute(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Span.Builder setAttribute(final String key, final boolean value) {
|
||||||
|
agentBuilder.setAttribute(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Span.Builder setAttribute(final String key, final AttributeValue applicationValue) {
|
||||||
|
io.opentelemetry.common.AttributeValue agentValue = Bridging.toAgentOrNull(applicationValue);
|
||||||
|
if (agentValue != null) {
|
||||||
|
agentBuilder.setAttribute(key, agentValue);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Span.Builder setSpanKind(final Span.Kind applicationSpanKind) {
|
||||||
|
io.opentelemetry.trace.Span.Kind agentSpanKind = toAgentOrNull(applicationSpanKind);
|
||||||
|
if (agentSpanKind != null) {
|
||||||
|
agentBuilder.setSpanKind(agentSpanKind);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Span.Builder setStartTimestamp(final long startTimestamp) {
|
||||||
|
agentBuilder.setStartTimestamp(startTimestamp);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Span startSpan() {
|
||||||
|
return new ApplicationSpan(agentBuilder.startSpan());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,36 +16,36 @@
|
||||||
|
|
||||||
package io.opentelemetry.auto.instrumentation.opentelemetryapi.trace;
|
package io.opentelemetry.auto.instrumentation.opentelemetryapi.trace;
|
||||||
|
|
||||||
|
import application.io.grpc.Context;
|
||||||
|
import application.io.opentelemetry.context.Scope;
|
||||||
|
import application.io.opentelemetry.trace.Span;
|
||||||
|
import application.io.opentelemetry.trace.Tracer;
|
||||||
import io.opentelemetry.instrumentation.auto.api.ContextStore;
|
import io.opentelemetry.instrumentation.auto.api.ContextStore;
|
||||||
import unshaded.io.grpc.Context;
|
|
||||||
import unshaded.io.opentelemetry.context.Scope;
|
|
||||||
import unshaded.io.opentelemetry.trace.Span;
|
|
||||||
import unshaded.io.opentelemetry.trace.Tracer;
|
|
||||||
|
|
||||||
class UnshadedTracer implements Tracer {
|
class ApplicationTracer implements Tracer {
|
||||||
|
|
||||||
private final io.opentelemetry.trace.Tracer shadedTracer;
|
private final io.opentelemetry.trace.Tracer agentTracer;
|
||||||
private final ContextStore<Context, io.grpc.Context> contextStore;
|
private final ContextStore<Context, io.grpc.Context> contextStore;
|
||||||
|
|
||||||
UnshadedTracer(
|
ApplicationTracer(
|
||||||
final io.opentelemetry.trace.Tracer shadedTracer,
|
final io.opentelemetry.trace.Tracer agentTracer,
|
||||||
ContextStore<Context, io.grpc.Context> contextStore) {
|
ContextStore<Context, io.grpc.Context> contextStore) {
|
||||||
this.shadedTracer = shadedTracer;
|
this.agentTracer = agentTracer;
|
||||||
this.contextStore = contextStore;
|
this.contextStore = contextStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Span getCurrentSpan() {
|
public Span getCurrentSpan() {
|
||||||
return Bridging.toUnshaded(shadedTracer.getCurrentSpan());
|
return Bridging.toApplication(agentTracer.getCurrentSpan());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Scope withSpan(final Span span) {
|
public Scope withSpan(final Span applicationSpan) {
|
||||||
return TracingContextUtils.currentContextWith(span);
|
return TracingContextUtils.currentContextWith(applicationSpan);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Span.Builder spanBuilder(final String spanName) {
|
public Span.Builder spanBuilder(final String spanName) {
|
||||||
return new UnshadedSpan.Builder(shadedTracer.spanBuilder(spanName), contextStore);
|
return new ApplicationSpan.Builder(agentTracer.spanBuilder(spanName), contextStore);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,39 +16,40 @@
|
||||||
|
|
||||||
package io.opentelemetry.auto.instrumentation.opentelemetryapi.trace;
|
package io.opentelemetry.auto.instrumentation.opentelemetryapi.trace;
|
||||||
|
|
||||||
|
import application.io.grpc.Context;
|
||||||
|
import application.io.opentelemetry.internal.Obfuscated;
|
||||||
|
import application.io.opentelemetry.trace.Tracer;
|
||||||
|
import application.io.opentelemetry.trace.TracerProvider;
|
||||||
import io.opentelemetry.instrumentation.auto.api.ContextStore;
|
import io.opentelemetry.instrumentation.auto.api.ContextStore;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import unshaded.io.grpc.Context;
|
|
||||||
import unshaded.io.opentelemetry.internal.Obfuscated;
|
|
||||||
import unshaded.io.opentelemetry.trace.Tracer;
|
|
||||||
import unshaded.io.opentelemetry.trace.TracerProvider;
|
|
||||||
|
|
||||||
public class UnshadedTracerProvider implements TracerProvider, Obfuscated {
|
public class ApplicationTracerProvider implements TracerProvider, Obfuscated {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(UnshadedTracerProvider.class);
|
private static final Logger log = LoggerFactory.getLogger(ApplicationTracerProvider.class);
|
||||||
|
|
||||||
private static final AtomicBoolean messageAlreadyLogged = new AtomicBoolean();
|
private static final AtomicBoolean messageAlreadyLogged = new AtomicBoolean();
|
||||||
|
|
||||||
private final ContextStore<Context, io.grpc.Context> contextStore;
|
private final ContextStore<Context, io.grpc.Context> contextStore;
|
||||||
private final TracerProvider originalTracerProvider;
|
private final TracerProvider applicationOriginalTracerProvider;
|
||||||
|
|
||||||
public UnshadedTracerProvider(
|
public ApplicationTracerProvider(
|
||||||
ContextStore<Context, io.grpc.Context> contextStore, TracerProvider originalTracerProvider) {
|
ContextStore<Context, io.grpc.Context> contextStore,
|
||||||
|
TracerProvider applicationOriginalTracerProvider) {
|
||||||
this.contextStore = contextStore;
|
this.contextStore = contextStore;
|
||||||
this.originalTracerProvider = originalTracerProvider;
|
this.applicationOriginalTracerProvider = applicationOriginalTracerProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Tracer get(final String instrumentationName) {
|
public Tracer get(final String instrumentationName) {
|
||||||
return new UnshadedTracer(
|
return new ApplicationTracer(
|
||||||
io.opentelemetry.OpenTelemetry.getTracerProvider().get(instrumentationName), contextStore);
|
io.opentelemetry.OpenTelemetry.getTracerProvider().get(instrumentationName), contextStore);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Tracer get(final String instrumentationName, final String instrumentationVersion) {
|
public Tracer get(final String instrumentationName, final String instrumentationVersion) {
|
||||||
return new UnshadedTracer(
|
return new ApplicationTracer(
|
||||||
io.opentelemetry.OpenTelemetry.getTracerProvider()
|
io.opentelemetry.OpenTelemetry.getTracerProvider()
|
||||||
.get(instrumentationName, instrumentationVersion),
|
.get(instrumentationName, instrumentationVersion),
|
||||||
contextStore);
|
contextStore);
|
||||||
|
@ -69,6 +70,6 @@ public class UnshadedTracerProvider implements TracerProvider, Obfuscated {
|
||||||
log.info(message);
|
log.info(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ((Obfuscated<?>) originalTracerProvider).unobfuscate();
|
return ((Obfuscated<?>) applicationOriginalTracerProvider).unobfuscate();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,32 +16,31 @@
|
||||||
|
|
||||||
package io.opentelemetry.auto.instrumentation.opentelemetryapi.trace;
|
package io.opentelemetry.auto.instrumentation.opentelemetryapi.trace;
|
||||||
|
|
||||||
import io.opentelemetry.common.Attributes.Builder;
|
import application.io.opentelemetry.common.AttributeValue;
|
||||||
|
import application.io.opentelemetry.common.Attributes;
|
||||||
|
import application.io.opentelemetry.common.ReadableKeyValuePairs.KeyValueConsumer;
|
||||||
|
import application.io.opentelemetry.trace.DefaultSpan;
|
||||||
|
import application.io.opentelemetry.trace.EndSpanOptions;
|
||||||
|
import application.io.opentelemetry.trace.Span;
|
||||||
|
import application.io.opentelemetry.trace.SpanContext;
|
||||||
|
import application.io.opentelemetry.trace.SpanId;
|
||||||
|
import application.io.opentelemetry.trace.Status;
|
||||||
|
import application.io.opentelemetry.trace.TraceFlags;
|
||||||
|
import application.io.opentelemetry.trace.TraceId;
|
||||||
|
import application.io.opentelemetry.trace.TraceState;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import unshaded.io.opentelemetry.common.AttributeValue;
|
|
||||||
import unshaded.io.opentelemetry.common.Attributes;
|
|
||||||
import unshaded.io.opentelemetry.common.ReadableKeyValuePairs.KeyValueConsumer;
|
|
||||||
import unshaded.io.opentelemetry.trace.DefaultSpan;
|
|
||||||
import unshaded.io.opentelemetry.trace.EndSpanOptions;
|
|
||||||
import unshaded.io.opentelemetry.trace.Span;
|
|
||||||
import unshaded.io.opentelemetry.trace.SpanContext;
|
|
||||||
import unshaded.io.opentelemetry.trace.SpanId;
|
|
||||||
import unshaded.io.opentelemetry.trace.Status;
|
|
||||||
import unshaded.io.opentelemetry.trace.TraceFlags;
|
|
||||||
import unshaded.io.opentelemetry.trace.TraceId;
|
|
||||||
import unshaded.io.opentelemetry.trace.TraceState;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class translates between the (unshaded) OpenTelemetry API that the user brings and the
|
* This class translates between the (unshaded) OpenTelemetry API that the application brings and
|
||||||
* (shaded) OpenTelemetry API that is in the bootstrap class loader and used to report telemetry to
|
* the (shaded) OpenTelemetry API that is used by the agent.
|
||||||
* the agent.
|
|
||||||
*
|
*
|
||||||
* <p>"unshaded.io.opentelemetry.*" refers to the (unshaded) OpenTelemetry API that the user brings
|
* <p>"application.io.opentelemetry.*" refers to the (unshaded) OpenTelemetry API that the
|
||||||
* (as those references will be translated during the build to remove the "unshaded." prefix).
|
* application brings (as those references will be translated during the build to remove the
|
||||||
|
* "application." prefix).
|
||||||
*
|
*
|
||||||
* <p>"io.opentelemetry.*" refers to the (shaded) OpenTelemetry API that is in the bootstrap class
|
* <p>"io.opentelemetry.*" refers to the (shaded) OpenTelemetry API that is used by the agent (as
|
||||||
* loader (as those references will later be shaded).
|
* those references will later be shaded).
|
||||||
*
|
*
|
||||||
* <p>Also see comments in this module's gradle file.
|
* <p>Also see comments in this module's gradle file.
|
||||||
*/
|
*/
|
||||||
|
@ -52,169 +51,173 @@ public class Bridging {
|
||||||
// this is just an optimization to save some byte array allocations
|
// this is just an optimization to save some byte array allocations
|
||||||
public static final ThreadLocal<byte[]> BUFFER = new ThreadLocal<>();
|
public static final ThreadLocal<byte[]> BUFFER = new ThreadLocal<>();
|
||||||
|
|
||||||
public static Span toUnshaded(final io.opentelemetry.trace.Span shadedSpan) {
|
public static Span toApplication(final io.opentelemetry.trace.Span agentSpan) {
|
||||||
if (!shadedSpan.getContext().isValid()) {
|
if (!agentSpan.getContext().isValid()) {
|
||||||
// no need to wrap
|
// no need to wrap
|
||||||
return DefaultSpan.getInvalid();
|
return DefaultSpan.getInvalid();
|
||||||
} else {
|
} else {
|
||||||
return new UnshadedSpan(shadedSpan);
|
return new ApplicationSpan(agentSpan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static io.opentelemetry.trace.Span toShadedOrNull(final Span unshadedSpan) {
|
public static io.opentelemetry.trace.Span toAgentOrNull(final Span applicationSpan) {
|
||||||
if (!unshadedSpan.getContext().isValid()) {
|
if (!applicationSpan.getContext().isValid()) {
|
||||||
// no need to wrap
|
// no need to wrap
|
||||||
return io.opentelemetry.trace.DefaultSpan.getInvalid();
|
return io.opentelemetry.trace.DefaultSpan.getInvalid();
|
||||||
} else if (unshadedSpan instanceof UnshadedSpan) {
|
} else if (applicationSpan instanceof ApplicationSpan) {
|
||||||
return ((UnshadedSpan) unshadedSpan).getShadedSpan();
|
return ((ApplicationSpan) applicationSpan).getAgentSpan();
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SpanContext toUnshaded(final io.opentelemetry.trace.SpanContext shadedContext) {
|
public static SpanContext toApplication(final io.opentelemetry.trace.SpanContext agentContext) {
|
||||||
if (shadedContext.isRemote()) {
|
if (agentContext.isRemote()) {
|
||||||
return SpanContext.createFromRemoteParent(
|
return SpanContext.createFromRemoteParent(
|
||||||
toUnshaded(shadedContext.getTraceId()),
|
toApplication(agentContext.getTraceId()),
|
||||||
toUnshaded(shadedContext.getSpanId()),
|
toApplication(agentContext.getSpanId()),
|
||||||
toUnshaded(shadedContext.getTraceFlags()),
|
toApplication(agentContext.getTraceFlags()),
|
||||||
toUnshaded(shadedContext.getTraceState()));
|
toApplication(agentContext.getTraceState()));
|
||||||
} else {
|
} else {
|
||||||
return SpanContext.create(
|
return SpanContext.create(
|
||||||
toUnshaded(shadedContext.getTraceId()),
|
toApplication(agentContext.getTraceId()),
|
||||||
toUnshaded(shadedContext.getSpanId()),
|
toApplication(agentContext.getSpanId()),
|
||||||
toUnshaded(shadedContext.getTraceFlags()),
|
toApplication(agentContext.getTraceFlags()),
|
||||||
toUnshaded(shadedContext.getTraceState()));
|
toApplication(agentContext.getTraceState()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static io.opentelemetry.trace.SpanContext toShaded(final SpanContext unshadedContext) {
|
public static io.opentelemetry.trace.SpanContext toAgent(final SpanContext applicationContext) {
|
||||||
if (unshadedContext.isRemote()) {
|
if (applicationContext.isRemote()) {
|
||||||
return io.opentelemetry.trace.SpanContext.createFromRemoteParent(
|
return io.opentelemetry.trace.SpanContext.createFromRemoteParent(
|
||||||
toShaded(unshadedContext.getTraceId()),
|
toAgent(applicationContext.getTraceId()),
|
||||||
toShaded(unshadedContext.getSpanId()),
|
toAgent(applicationContext.getSpanId()),
|
||||||
toShaded(unshadedContext.getTraceFlags()),
|
toAgent(applicationContext.getTraceFlags()),
|
||||||
toShaded(unshadedContext.getTraceState()));
|
toAgent(applicationContext.getTraceState()));
|
||||||
} else {
|
} else {
|
||||||
return io.opentelemetry.trace.SpanContext.create(
|
return io.opentelemetry.trace.SpanContext.create(
|
||||||
toShaded(unshadedContext.getTraceId()),
|
toAgent(applicationContext.getTraceId()),
|
||||||
toShaded(unshadedContext.getSpanId()),
|
toAgent(applicationContext.getSpanId()),
|
||||||
toShaded(unshadedContext.getTraceFlags()),
|
toAgent(applicationContext.getTraceFlags()),
|
||||||
toShaded(unshadedContext.getTraceState()));
|
toAgent(applicationContext.getTraceState()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static io.opentelemetry.common.Attributes toShaded(final Attributes unshadedAttributes) {
|
public static io.opentelemetry.common.Attributes toAgent(final Attributes applicationAttributes) {
|
||||||
final Builder builder = io.opentelemetry.common.Attributes.newBuilder();
|
final io.opentelemetry.common.Attributes.Builder agentAttributes =
|
||||||
unshadedAttributes.forEach(
|
io.opentelemetry.common.Attributes.newBuilder();
|
||||||
|
applicationAttributes.forEach(
|
||||||
new KeyValueConsumer<AttributeValue>() {
|
new KeyValueConsumer<AttributeValue>() {
|
||||||
@Override
|
@Override
|
||||||
public void consume(String key, AttributeValue attributeValue) {
|
public void consume(String key, AttributeValue attributeValue) {
|
||||||
io.opentelemetry.common.AttributeValue shadedValue = toShadedOrNull(attributeValue);
|
io.opentelemetry.common.AttributeValue agentValue = toAgentOrNull(attributeValue);
|
||||||
if (shadedValue != null) {
|
if (agentValue != null) {
|
||||||
builder.setAttribute(key, shadedValue);
|
agentAttributes.setAttribute(key, agentValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return builder.build();
|
return agentAttributes.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static io.opentelemetry.common.AttributeValue toShadedOrNull(
|
public static io.opentelemetry.common.AttributeValue toAgentOrNull(
|
||||||
final AttributeValue unshadedValue) {
|
final AttributeValue applicationValue) {
|
||||||
switch (unshadedValue.getType()) {
|
switch (applicationValue.getType()) {
|
||||||
case STRING:
|
case STRING:
|
||||||
return io.opentelemetry.common.AttributeValue.stringAttributeValue(
|
return io.opentelemetry.common.AttributeValue.stringAttributeValue(
|
||||||
unshadedValue.getStringValue());
|
applicationValue.getStringValue());
|
||||||
case LONG:
|
case LONG:
|
||||||
return io.opentelemetry.common.AttributeValue.longAttributeValue(
|
return io.opentelemetry.common.AttributeValue.longAttributeValue(
|
||||||
unshadedValue.getLongValue());
|
applicationValue.getLongValue());
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
return io.opentelemetry.common.AttributeValue.booleanAttributeValue(
|
return io.opentelemetry.common.AttributeValue.booleanAttributeValue(
|
||||||
unshadedValue.getBooleanValue());
|
applicationValue.getBooleanValue());
|
||||||
case DOUBLE:
|
case DOUBLE:
|
||||||
return io.opentelemetry.common.AttributeValue.doubleAttributeValue(
|
return io.opentelemetry.common.AttributeValue.doubleAttributeValue(
|
||||||
unshadedValue.getDoubleValue());
|
applicationValue.getDoubleValue());
|
||||||
default:
|
default:
|
||||||
log.debug("unexpected attribute type: {}", unshadedValue.getType());
|
log.debug("unexpected attribute type: {}", applicationValue.getType());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static io.opentelemetry.trace.Status toShadedOrNull(final Status unshadedStatus) {
|
public static io.opentelemetry.trace.Status toAgentOrNull(final Status applicationStatus) {
|
||||||
io.opentelemetry.trace.Status.CanonicalCode canonicalCode;
|
io.opentelemetry.trace.Status.CanonicalCode agentCanonicalCode;
|
||||||
try {
|
try {
|
||||||
canonicalCode =
|
agentCanonicalCode =
|
||||||
io.opentelemetry.trace.Status.CanonicalCode.valueOf(
|
io.opentelemetry.trace.Status.CanonicalCode.valueOf(
|
||||||
unshadedStatus.getCanonicalCode().name());
|
applicationStatus.getCanonicalCode().name());
|
||||||
} catch (final IllegalArgumentException e) {
|
} catch (final IllegalArgumentException e) {
|
||||||
log.debug("unexpected status canonical code: {}", unshadedStatus.getCanonicalCode().name());
|
log.debug(
|
||||||
|
"unexpected status canonical code: {}", applicationStatus.getCanonicalCode().name());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return canonicalCode.toStatus().withDescription(unshadedStatus.getDescription());
|
return agentCanonicalCode.toStatus().withDescription(applicationStatus.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static io.opentelemetry.trace.Span.Kind toShadedOrNull(final Span.Kind unshadedSpanKind) {
|
public static io.opentelemetry.trace.Span.Kind toAgentOrNull(
|
||||||
|
final Span.Kind applicationSpanKind) {
|
||||||
try {
|
try {
|
||||||
return io.opentelemetry.trace.Span.Kind.valueOf(unshadedSpanKind.name());
|
return io.opentelemetry.trace.Span.Kind.valueOf(applicationSpanKind.name());
|
||||||
} catch (final IllegalArgumentException e) {
|
} catch (final IllegalArgumentException e) {
|
||||||
log.debug("unexpected span kind: {}", unshadedSpanKind.name());
|
log.debug("unexpected span kind: {}", applicationSpanKind.name());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static io.opentelemetry.trace.EndSpanOptions toShaded(
|
public static io.opentelemetry.trace.EndSpanOptions toAgent(
|
||||||
final EndSpanOptions unshadedEndSpanOptions) {
|
final EndSpanOptions applicationEndSpanOptions) {
|
||||||
return io.opentelemetry.trace.EndSpanOptions.builder()
|
return io.opentelemetry.trace.EndSpanOptions.builder()
|
||||||
.setEndTimestamp(unshadedEndSpanOptions.getEndTimestamp())
|
.setEndTimestamp(applicationEndSpanOptions.getEndTimestamp())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TraceId toUnshaded(final io.opentelemetry.trace.TraceId shadedTraceId) {
|
private static TraceId toApplication(final io.opentelemetry.trace.TraceId agentTraceId) {
|
||||||
byte[] bytes = getBuffer();
|
byte[] bytes = getBuffer();
|
||||||
shadedTraceId.copyBytesTo(bytes, 0);
|
agentTraceId.copyBytesTo(bytes, 0);
|
||||||
return TraceId.fromBytes(bytes, 0);
|
return TraceId.fromBytes(bytes, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SpanId toUnshaded(final io.opentelemetry.trace.SpanId shadedSpanId) {
|
private static SpanId toApplication(final io.opentelemetry.trace.SpanId agentSpanId) {
|
||||||
byte[] bytes = getBuffer();
|
byte[] bytes = getBuffer();
|
||||||
shadedSpanId.copyBytesTo(bytes, 0);
|
agentSpanId.copyBytesTo(bytes, 0);
|
||||||
return SpanId.fromBytes(bytes, 0);
|
return SpanId.fromBytes(bytes, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TraceFlags toUnshaded(final io.opentelemetry.trace.TraceFlags shadedTraceFlags) {
|
private static TraceFlags toApplication(final io.opentelemetry.trace.TraceFlags agentTraceFlags) {
|
||||||
return TraceFlags.fromByte(shadedTraceFlags.getByte());
|
return TraceFlags.fromByte(agentTraceFlags.getByte());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TraceState toUnshaded(final io.opentelemetry.trace.TraceState shadedTraceState) {
|
private static TraceState toApplication(final io.opentelemetry.trace.TraceState agentTraceState) {
|
||||||
TraceState.Builder builder = TraceState.builder();
|
TraceState.Builder applicationTraceState = TraceState.builder();
|
||||||
for (io.opentelemetry.trace.TraceState.Entry entry : shadedTraceState.getEntries()) {
|
for (io.opentelemetry.trace.TraceState.Entry entry : agentTraceState.getEntries()) {
|
||||||
builder.set(entry.getKey(), entry.getValue());
|
applicationTraceState.set(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
return builder.build();
|
return applicationTraceState.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static io.opentelemetry.trace.TraceId toShaded(final TraceId unshadedTraceId) {
|
private static io.opentelemetry.trace.TraceId toAgent(final TraceId applicationTraceId) {
|
||||||
byte[] bytes = getBuffer();
|
byte[] bytes = getBuffer();
|
||||||
unshadedTraceId.copyBytesTo(bytes, 0);
|
applicationTraceId.copyBytesTo(bytes, 0);
|
||||||
return io.opentelemetry.trace.TraceId.fromBytes(bytes, 0);
|
return io.opentelemetry.trace.TraceId.fromBytes(bytes, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static io.opentelemetry.trace.SpanId toShaded(final SpanId unshadedSpanId) {
|
private static io.opentelemetry.trace.SpanId toAgent(final SpanId applicationSpanId) {
|
||||||
byte[] bytes = getBuffer();
|
byte[] bytes = getBuffer();
|
||||||
unshadedSpanId.copyBytesTo(bytes, 0);
|
applicationSpanId.copyBytesTo(bytes, 0);
|
||||||
return io.opentelemetry.trace.SpanId.fromBytes(bytes, 0);
|
return io.opentelemetry.trace.SpanId.fromBytes(bytes, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static io.opentelemetry.trace.TraceFlags toShaded(final TraceFlags unshadedTraceFlags) {
|
private static io.opentelemetry.trace.TraceFlags toAgent(final TraceFlags applicationTraceFlags) {
|
||||||
return io.opentelemetry.trace.TraceFlags.fromByte(unshadedTraceFlags.getByte());
|
return io.opentelemetry.trace.TraceFlags.fromByte(applicationTraceFlags.getByte());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static io.opentelemetry.trace.TraceState toShaded(final TraceState unshadedTraceState) {
|
private static io.opentelemetry.trace.TraceState toAgent(final TraceState applicationTraceState) {
|
||||||
io.opentelemetry.trace.TraceState.Builder builder = io.opentelemetry.trace.TraceState.builder();
|
io.opentelemetry.trace.TraceState.Builder agentTraceState =
|
||||||
for (final TraceState.Entry entry : unshadedTraceState.getEntries()) {
|
io.opentelemetry.trace.TraceState.builder();
|
||||||
builder.set(entry.getKey(), entry.getValue());
|
for (final TraceState.Entry entry : applicationTraceState.getEntries()) {
|
||||||
|
agentTraceState.set(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
return builder.build();
|
return agentTraceState.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] getBuffer() {
|
private static byte[] getBuffer() {
|
||||||
|
|
|
@ -16,92 +16,94 @@
|
||||||
|
|
||||||
package io.opentelemetry.auto.instrumentation.opentelemetryapi.trace;
|
package io.opentelemetry.auto.instrumentation.opentelemetryapi.trace;
|
||||||
|
|
||||||
import static io.opentelemetry.auto.instrumentation.opentelemetryapi.trace.Bridging.toShadedOrNull;
|
import static io.opentelemetry.auto.instrumentation.opentelemetryapi.trace.Bridging.toApplication;
|
||||||
import static io.opentelemetry.auto.instrumentation.opentelemetryapi.trace.Bridging.toUnshaded;
|
|
||||||
|
|
||||||
|
import application.io.grpc.Context;
|
||||||
|
import application.io.opentelemetry.context.Scope;
|
||||||
|
import application.io.opentelemetry.trace.DefaultSpan;
|
||||||
|
import application.io.opentelemetry.trace.Span;
|
||||||
|
import io.opentelemetry.auto.instrumentation.opentelemetryapi.context.ApplicationScope;
|
||||||
import io.opentelemetry.auto.instrumentation.opentelemetryapi.context.NoopScope;
|
import io.opentelemetry.auto.instrumentation.opentelemetryapi.context.NoopScope;
|
||||||
import io.opentelemetry.auto.instrumentation.opentelemetryapi.context.UnshadedScope;
|
|
||||||
import io.opentelemetry.instrumentation.auto.api.ContextStore;
|
import io.opentelemetry.instrumentation.auto.api.ContextStore;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import unshaded.io.grpc.Context;
|
|
||||||
import unshaded.io.opentelemetry.context.Scope;
|
|
||||||
import unshaded.io.opentelemetry.trace.DefaultSpan;
|
|
||||||
import unshaded.io.opentelemetry.trace.Span;
|
|
||||||
|
|
||||||
public class TracingContextUtils {
|
public class TracingContextUtils {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(TracingContextUtils.class);
|
private static final Logger log = LoggerFactory.getLogger(TracingContextUtils.class);
|
||||||
|
|
||||||
public static Context withSpan(
|
public static Context withSpan(
|
||||||
final Span span,
|
final Span applicationSpan,
|
||||||
final Context context,
|
final Context applicationContext,
|
||||||
final ContextStore<Context, io.grpc.Context> contextStore) {
|
final ContextStore<Context, io.grpc.Context> contextStore) {
|
||||||
io.opentelemetry.trace.Span shadedSpan = toShadedOrNull(span);
|
io.opentelemetry.trace.Span agentSpan = Bridging.toAgentOrNull(applicationSpan);
|
||||||
if (shadedSpan == null) {
|
if (agentSpan == null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("unexpected span: {}", span, new Exception("unexpected span"));
|
log.debug("unexpected span: {}", applicationSpan, new Exception("unexpected span"));
|
||||||
}
|
}
|
||||||
return context;
|
return applicationContext;
|
||||||
}
|
}
|
||||||
io.grpc.Context shadedContext = contextStore.get(context);
|
io.grpc.Context agentContext = contextStore.get(applicationContext);
|
||||||
if (shadedContext == null) {
|
if (agentContext == null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("unexpected context: {}", context, new Exception("unexpected context"));
|
log.debug(
|
||||||
|
"unexpected context: {}", applicationContext, new Exception("unexpected context"));
|
||||||
}
|
}
|
||||||
return context;
|
return applicationContext;
|
||||||
}
|
}
|
||||||
io.grpc.Context updatedShadedContext =
|
io.grpc.Context agentUpdatedContext =
|
||||||
io.opentelemetry.trace.TracingContextUtils.withSpan(shadedSpan, shadedContext);
|
io.opentelemetry.trace.TracingContextUtils.withSpan(agentSpan, agentContext);
|
||||||
Context updatedContext = context.fork();
|
Context applicationUpdatedContext = applicationContext.fork();
|
||||||
contextStore.put(updatedContext, updatedShadedContext);
|
contextStore.put(applicationUpdatedContext, agentUpdatedContext);
|
||||||
return updatedContext;
|
return applicationUpdatedContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Span getCurrentSpan() {
|
public static Span getCurrentSpan() {
|
||||||
return toUnshaded(io.opentelemetry.trace.TracingContextUtils.getCurrentSpan());
|
return toApplication(io.opentelemetry.trace.TracingContextUtils.getCurrentSpan());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Span getSpan(
|
public static Span getSpan(
|
||||||
final Context context, final ContextStore<Context, io.grpc.Context> contextStore) {
|
final Context applicationContext, final ContextStore<Context, io.grpc.Context> contextStore) {
|
||||||
io.grpc.Context shadedContext = contextStore.get(context);
|
io.grpc.Context agentContext = contextStore.get(applicationContext);
|
||||||
if (shadedContext == null) {
|
if (agentContext == null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("unexpected context: {}", context, new Exception("unexpected context"));
|
log.debug(
|
||||||
|
"unexpected context: {}", applicationContext, new Exception("unexpected context"));
|
||||||
}
|
}
|
||||||
return DefaultSpan.getInvalid();
|
return DefaultSpan.getInvalid();
|
||||||
}
|
}
|
||||||
return toUnshaded(io.opentelemetry.trace.TracingContextUtils.getSpan(shadedContext));
|
return toApplication(io.opentelemetry.trace.TracingContextUtils.getSpan(agentContext));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Span getSpanWithoutDefault(
|
public static Span getSpanWithoutDefault(
|
||||||
final Context context, final ContextStore<Context, io.grpc.Context> contextStore) {
|
final Context applicationContext, final ContextStore<Context, io.grpc.Context> contextStore) {
|
||||||
io.grpc.Context shadedContext = contextStore.get(context);
|
io.grpc.Context agentContext = contextStore.get(applicationContext);
|
||||||
if (shadedContext == null) {
|
if (agentContext == null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("unexpected context: {}", context, new Exception("unexpected context"));
|
log.debug(
|
||||||
|
"unexpected context: {}", applicationContext, new Exception("unexpected context"));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
io.opentelemetry.trace.Span shadedSpan =
|
io.opentelemetry.trace.Span agentSpan =
|
||||||
io.opentelemetry.trace.TracingContextUtils.getSpanWithoutDefault(shadedContext);
|
io.opentelemetry.trace.TracingContextUtils.getSpanWithoutDefault(agentContext);
|
||||||
return shadedSpan == null ? null : toUnshaded(shadedSpan);
|
return agentSpan == null ? null : toApplication(agentSpan);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Scope currentContextWith(final Span span) {
|
public static Scope currentContextWith(final Span applicationSpan) {
|
||||||
if (!span.getContext().isValid()) {
|
if (!applicationSpan.getContext().isValid()) {
|
||||||
// this supports direct usage of unshaded DefaultSpan.getInvalid()
|
// this supports direct usage of DefaultSpan.getInvalid()
|
||||||
return new UnshadedScope(
|
return new ApplicationScope(
|
||||||
io.opentelemetry.trace.TracingContextUtils.currentContextWith(
|
io.opentelemetry.trace.TracingContextUtils.currentContextWith(
|
||||||
io.opentelemetry.trace.DefaultSpan.getInvalid()));
|
io.opentelemetry.trace.DefaultSpan.getInvalid()));
|
||||||
}
|
}
|
||||||
if (span instanceof UnshadedSpan) {
|
if (applicationSpan instanceof ApplicationSpan) {
|
||||||
return new UnshadedScope(
|
return new ApplicationScope(
|
||||||
io.opentelemetry.trace.TracingContextUtils.currentContextWith(
|
io.opentelemetry.trace.TracingContextUtils.currentContextWith(
|
||||||
((UnshadedSpan) span).getShadedSpan()));
|
((ApplicationSpan) applicationSpan).getAgentSpan()));
|
||||||
}
|
}
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("unexpected span: {}", span, new Exception("unexpected span"));
|
log.debug("unexpected span: {}", applicationSpan, new Exception("unexpected span"));
|
||||||
}
|
}
|
||||||
return NoopScope.getInstance();
|
return NoopScope.getInstance();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,264 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright The OpenTelemetry Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.opentelemetry.auto.instrumentation.opentelemetryapi.trace;
|
|
||||||
|
|
||||||
import static io.opentelemetry.auto.instrumentation.opentelemetryapi.trace.Bridging.toShaded;
|
|
||||||
import static io.opentelemetry.auto.instrumentation.opentelemetryapi.trace.Bridging.toShadedOrNull;
|
|
||||||
|
|
||||||
import io.opentelemetry.instrumentation.auto.api.ContextStore;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import unshaded.io.grpc.Context;
|
|
||||||
import unshaded.io.opentelemetry.common.AttributeValue;
|
|
||||||
import unshaded.io.opentelemetry.common.Attributes;
|
|
||||||
import unshaded.io.opentelemetry.trace.EndSpanOptions;
|
|
||||||
import unshaded.io.opentelemetry.trace.Event;
|
|
||||||
import unshaded.io.opentelemetry.trace.Link;
|
|
||||||
import unshaded.io.opentelemetry.trace.Span;
|
|
||||||
import unshaded.io.opentelemetry.trace.SpanContext;
|
|
||||||
import unshaded.io.opentelemetry.trace.Status;
|
|
||||||
|
|
||||||
class UnshadedSpan implements Span {
|
|
||||||
|
|
||||||
private final io.opentelemetry.trace.Span shadedSpan;
|
|
||||||
|
|
||||||
UnshadedSpan(final io.opentelemetry.trace.Span shadedSpan) {
|
|
||||||
this.shadedSpan = shadedSpan;
|
|
||||||
}
|
|
||||||
|
|
||||||
io.opentelemetry.trace.Span getShadedSpan() {
|
|
||||||
return shadedSpan;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setAttribute(final String key, final String value) {
|
|
||||||
shadedSpan.setAttribute(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setAttribute(final String key, final long value) {
|
|
||||||
shadedSpan.setAttribute(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setAttribute(final String key, final double value) {
|
|
||||||
shadedSpan.setAttribute(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setAttribute(final String key, final boolean value) {
|
|
||||||
shadedSpan.setAttribute(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setAttribute(final String key, final AttributeValue value) {
|
|
||||||
io.opentelemetry.common.AttributeValue convertedValue = Bridging.toShadedOrNull(value);
|
|
||||||
if (convertedValue != null) {
|
|
||||||
shadedSpan.setAttribute(key, convertedValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addEvent(final String name) {
|
|
||||||
shadedSpan.addEvent(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addEvent(final String name, final long timestamp) {
|
|
||||||
shadedSpan.addEvent(name, timestamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addEvent(final String name, final Attributes attributes) {
|
|
||||||
shadedSpan.addEvent(name, toShaded(attributes));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addEvent(final String name, final Attributes attributes, final long timestamp) {
|
|
||||||
shadedSpan.addEvent(name, toShaded(attributes), timestamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addEvent(final Event event) {
|
|
||||||
addEvent(event.getName(), event.getAttributes());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addEvent(final Event event, final long timestamp) {
|
|
||||||
addEvent(event.getName(), event.getAttributes(), timestamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setStatus(final Status status) {
|
|
||||||
io.opentelemetry.trace.Status shadedStatus = toShadedOrNull(status);
|
|
||||||
if (shadedStatus != null) {
|
|
||||||
shadedSpan.setStatus(shadedStatus);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void recordException(Throwable throwable) {
|
|
||||||
shadedSpan.recordException(throwable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateName(final String name) {
|
|
||||||
shadedSpan.updateName(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void end() {
|
|
||||||
shadedSpan.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void end(final EndSpanOptions endOptions) {
|
|
||||||
shadedSpan.end(toShaded(endOptions));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SpanContext getContext() {
|
|
||||||
return Bridging.toUnshaded(shadedSpan.getContext());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isRecording() {
|
|
||||||
return shadedSpan.isRecording();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(final Object other) {
|
|
||||||
if (!(other instanceof UnshadedSpan)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return shadedSpan.equals(((UnshadedSpan) other).shadedSpan);
|
|
||||||
}
|
|
||||||
|
|
||||||
static class Builder implements Span.Builder {
|
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(Builder.class);
|
|
||||||
|
|
||||||
private final io.opentelemetry.trace.Span.Builder shadedBuilder;
|
|
||||||
private final ContextStore<Context, io.grpc.Context> contextStore;
|
|
||||||
|
|
||||||
Builder(
|
|
||||||
final io.opentelemetry.trace.Span.Builder shadedBuilder,
|
|
||||||
ContextStore<Context, io.grpc.Context> contextStore) {
|
|
||||||
this.shadedBuilder = shadedBuilder;
|
|
||||||
this.contextStore = contextStore;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Span.Builder setParent(final Span parent) {
|
|
||||||
if (parent instanceof UnshadedSpan) {
|
|
||||||
shadedBuilder.setParent(((UnshadedSpan) parent).getShadedSpan());
|
|
||||||
} else {
|
|
||||||
log.debug("unexpected parent span: {}", parent);
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Span.Builder setParent(final SpanContext remoteParent) {
|
|
||||||
shadedBuilder.setParent(toShaded(remoteParent));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Span.Builder setParent(Context context) {
|
|
||||||
shadedBuilder.setParent(contextStore.get(context));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Span.Builder setNoParent() {
|
|
||||||
shadedBuilder.setNoParent();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Span.Builder addLink(final SpanContext spanContext) {
|
|
||||||
shadedBuilder.addLink(toShaded(spanContext));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Span.Builder addLink(final SpanContext spanContext, final Attributes attributes) {
|
|
||||||
shadedBuilder.addLink(toShaded(spanContext));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Span.Builder addLink(final Link link) {
|
|
||||||
shadedBuilder.addLink(toShaded(link.getContext()), toShaded(link.getAttributes()));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Span.Builder setAttribute(final String key, final String value) {
|
|
||||||
shadedBuilder.setAttribute(key, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Span.Builder setAttribute(final String key, final long value) {
|
|
||||||
shadedBuilder.setAttribute(key, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Span.Builder setAttribute(final String key, final double value) {
|
|
||||||
shadedBuilder.setAttribute(key, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Span.Builder setAttribute(final String key, final boolean value) {
|
|
||||||
shadedBuilder.setAttribute(key, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Span.Builder setAttribute(final String key, final AttributeValue value) {
|
|
||||||
io.opentelemetry.common.AttributeValue convertedValue = Bridging.toShadedOrNull(value);
|
|
||||||
if (convertedValue != null) {
|
|
||||||
shadedBuilder.setAttribute(key, convertedValue);
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Span.Builder setSpanKind(final Span.Kind spanKind) {
|
|
||||||
io.opentelemetry.trace.Span.Kind shadedSpanKind = toShadedOrNull(spanKind);
|
|
||||||
if (shadedSpanKind != null) {
|
|
||||||
shadedBuilder.setSpanKind(shadedSpanKind);
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Span.Builder setStartTimestamp(final long startTimestamp) {
|
|
||||||
shadedBuilder.setStartTimestamp(startTimestamp);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Span startSpan() {
|
|
||||||
return new UnshadedSpan(shadedBuilder.startSpan());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -14,12 +14,12 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import application.io.opentelemetry.OpenTelemetry
|
||||||
|
import application.io.opentelemetry.common.Labels
|
||||||
|
import application.io.opentelemetry.metrics.AsynchronousInstrument
|
||||||
import io.opentelemetry.auto.test.AgentTestRunner
|
import io.opentelemetry.auto.test.AgentTestRunner
|
||||||
import io.opentelemetry.sdk.OpenTelemetrySdk
|
import io.opentelemetry.sdk.OpenTelemetrySdk
|
||||||
import io.opentelemetry.sdk.metrics.data.MetricData
|
import io.opentelemetry.sdk.metrics.data.MetricData
|
||||||
import unshaded.io.opentelemetry.OpenTelemetry
|
|
||||||
import unshaded.io.opentelemetry.common.Labels
|
|
||||||
import unshaded.io.opentelemetry.metrics.AsynchronousInstrument
|
|
||||||
|
|
||||||
import static io.opentelemetry.sdk.metrics.data.MetricData.Descriptor.Type.MONOTONIC_DOUBLE
|
import static io.opentelemetry.sdk.metrics.data.MetricData.Descriptor.Type.MONOTONIC_DOUBLE
|
||||||
import static io.opentelemetry.sdk.metrics.data.MetricData.Descriptor.Type.MONOTONIC_LONG
|
import static io.opentelemetry.sdk.metrics.data.MetricData.Descriptor.Type.MONOTONIC_LONG
|
||||||
|
|
|
@ -14,17 +14,17 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import application.io.opentelemetry.sdk.OpenTelemetrySdk
|
||||||
|
import application.io.opentelemetry.sdk.trace.TracerSdkProvider
|
||||||
import io.opentelemetry.auto.test.AgentTestRunner
|
import io.opentelemetry.auto.test.AgentTestRunner
|
||||||
import unshaded.io.opentelemetry.sdk.OpenTelemetrySdk
|
|
||||||
import unshaded.io.opentelemetry.sdk.trace.TracerSdkProvider
|
|
||||||
|
|
||||||
class TracerSdkTest extends AgentTestRunner {
|
class TracerSdkTest extends AgentTestRunner {
|
||||||
|
|
||||||
def "direct access to sdk should not fail"() {
|
def "direct access to sdk should not fail"() {
|
||||||
when:
|
when:
|
||||||
def provider = OpenTelemetrySdk.getTracerProvider()
|
def provider = OpenTelemetrySdk.getTracerProvider()
|
||||||
|
|
||||||
then:
|
then:
|
||||||
provider instanceof TracerSdkProvider
|
provider instanceof TracerSdkProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,21 +14,21 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import application.io.grpc.Context
|
||||||
|
import application.io.opentelemetry.OpenTelemetry
|
||||||
|
import application.io.opentelemetry.context.Scope
|
||||||
|
import application.io.opentelemetry.trace.DefaultSpan
|
||||||
|
import application.io.opentelemetry.trace.Span
|
||||||
|
import application.io.opentelemetry.trace.Status
|
||||||
import io.opentelemetry.auto.test.AgentTestRunner
|
import io.opentelemetry.auto.test.AgentTestRunner
|
||||||
import io.opentelemetry.trace.attributes.SemanticAttributes
|
import io.opentelemetry.trace.attributes.SemanticAttributes
|
||||||
import unshaded.io.grpc.Context
|
|
||||||
import unshaded.io.opentelemetry.OpenTelemetry
|
|
||||||
import unshaded.io.opentelemetry.context.Scope
|
|
||||||
import unshaded.io.opentelemetry.trace.DefaultSpan
|
|
||||||
import unshaded.io.opentelemetry.trace.Span
|
|
||||||
import unshaded.io.opentelemetry.trace.Status
|
|
||||||
|
|
||||||
import static unshaded.io.opentelemetry.context.ContextUtils.withScopedContext
|
import static application.io.opentelemetry.context.ContextUtils.withScopedContext
|
||||||
import static unshaded.io.opentelemetry.trace.Span.Kind.PRODUCER
|
import static application.io.opentelemetry.trace.Span.Kind.PRODUCER
|
||||||
import static unshaded.io.opentelemetry.trace.TracingContextUtils.currentContextWith
|
import static application.io.opentelemetry.trace.TracingContextUtils.currentContextWith
|
||||||
import static unshaded.io.opentelemetry.trace.TracingContextUtils.getCurrentSpan
|
import static application.io.opentelemetry.trace.TracingContextUtils.getCurrentSpan
|
||||||
import static unshaded.io.opentelemetry.trace.TracingContextUtils.getSpan
|
import static application.io.opentelemetry.trace.TracingContextUtils.getSpan
|
||||||
import static unshaded.io.opentelemetry.trace.TracingContextUtils.withSpan
|
import static application.io.opentelemetry.trace.TracingContextUtils.withSpan
|
||||||
|
|
||||||
class TracerTest extends AgentTestRunner {
|
class TracerTest extends AgentTestRunner {
|
||||||
|
|
||||||
|
|
|
@ -14,14 +14,14 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import application.io.grpc.Context
|
||||||
import io.opentelemetry.auto.test.AgentTestRunner
|
import io.opentelemetry.auto.test.AgentTestRunner
|
||||||
import unshaded.io.grpc.Context
|
|
||||||
|
|
||||||
import static unshaded.io.opentelemetry.OpenTelemetry.getTracerProvider
|
import static application.io.opentelemetry.OpenTelemetry.getTracerProvider
|
||||||
import static unshaded.io.opentelemetry.trace.TracingContextUtils.currentContextWith
|
import static application.io.opentelemetry.trace.TracingContextUtils.currentContextWith
|
||||||
import static unshaded.io.opentelemetry.trace.TracingContextUtils.getCurrentSpan
|
import static application.io.opentelemetry.trace.TracingContextUtils.getCurrentSpan
|
||||||
import static unshaded.io.opentelemetry.trace.TracingContextUtils.getSpan
|
import static application.io.opentelemetry.trace.TracingContextUtils.getSpan
|
||||||
import static unshaded.io.opentelemetry.trace.TracingContextUtils.getSpanWithoutDefault
|
import static application.io.opentelemetry.trace.TracingContextUtils.getSpanWithoutDefault
|
||||||
|
|
||||||
class TracingContextUtilsTest extends AgentTestRunner {
|
class TracingContextUtilsTest extends AgentTestRunner {
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,10 @@
|
||||||
|
|
||||||
package io.opentelemetry.test.annotation;
|
package io.opentelemetry.test.annotation;
|
||||||
|
|
||||||
|
import application.io.opentelemetry.extensions.auto.annotations.WithSpan;
|
||||||
|
import application.io.opentelemetry.trace.Span.Kind;
|
||||||
import io.opentelemetry.OpenTelemetry;
|
import io.opentelemetry.OpenTelemetry;
|
||||||
import io.opentelemetry.trace.Tracer;
|
import io.opentelemetry.trace.Tracer;
|
||||||
import unshaded.io.opentelemetry.extensions.auto.annotations.WithSpan;
|
|
||||||
import unshaded.io.opentelemetry.trace.Span.Kind;
|
|
||||||
|
|
||||||
public class TracedWithSpan {
|
public class TracedWithSpan {
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,6 @@ dependencies {
|
||||||
// (see more explanation in opentelemetry-api-beta.gradle)
|
// (see more explanation in opentelemetry-api-beta.gradle)
|
||||||
shadowJar {
|
shadowJar {
|
||||||
|
|
||||||
relocate "io.opentelemetry", "unshaded.io.opentelemetry"
|
relocate "io.opentelemetry", "application.io.opentelemetry"
|
||||||
relocate "io.grpc", "unshaded.io.grpc"
|
relocate "io.grpc", "application.io.grpc"
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,5 +13,5 @@ dependencies {
|
||||||
// (see more explanation in opentelemetry-api-beta.gradle)
|
// (see more explanation in opentelemetry-api-beta.gradle)
|
||||||
shadowJar {
|
shadowJar {
|
||||||
|
|
||||||
relocate "io.opentelemetry", "unshaded.io.opentelemetry"
|
relocate "io.opentelemetry", "application.io.opentelemetry"
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ dependencies {
|
||||||
shadowJar {
|
shadowJar {
|
||||||
|
|
||||||
mergeServiceFiles()
|
mergeServiceFiles()
|
||||||
|
|
||||||
relocate "io.opentelemetry", "unshaded.io.opentelemetry"
|
relocate "io.opentelemetry", "application.io.opentelemetry"
|
||||||
relocate "io.grpc", "unshaded.io.grpc"
|
relocate "io.grpc", "application.io.grpc"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue