Update to latest snapshot. (#1304)
This commit is contained in:
parent
57ead9532a
commit
f2194a928c
|
@ -60,8 +60,8 @@ public class AutoInstrumentationPlugin implements Plugin<Project> {
|
|||
"io.opentelemetry.instrumentation.api",
|
||||
"io.opentelemetry.OpenTelemetry", // OpenTelemetry API
|
||||
"io.opentelemetry.common", // OpenTelemetry API
|
||||
"io.opentelemetry.baggage", // OpenTelemetry API
|
||||
"io.opentelemetry.context", // OpenTelemetry API (context prop)
|
||||
"io.opentelemetry.correlationcontext", // OpenTelemetry API
|
||||
"io.opentelemetry.internal", // OpenTelemetry API
|
||||
"io.opentelemetry.metrics", // OpenTelemetry API
|
||||
"io.opentelemetry.trace", // OpenTelemetry API
|
||||
|
|
|
@ -11,9 +11,10 @@ ext {
|
|||
// Check https://oss.jfrog.org/libs-snapshot/io/opentelemetry/ for latest snapshot version.
|
||||
// Snapshot versions are often split across versions (based on jfrog's whim and relative age of
|
||||
// each module), best to keep these separate until GA
|
||||
opentelemetry : '0.9.0-20200925.025016-49',
|
||||
opentelemetryOther : '0.9.0-20200925.025016-49',
|
||||
opentelemetryAnother: '0.9.0-20200925.025016-49',
|
||||
opentelemetry : '0.9.0-20201002.015754-70',
|
||||
opentelemetryOther : '0.9.0-20201002.015754-71',
|
||||
opentelemetryAnother: '0.9.0-20201002.015754-69',
|
||||
opentelemetryBaggage: '0.9.0-20201002.015754-19',
|
||||
|
||||
slf4j : "1.7.30",
|
||||
guava : "20.0", // Last version to support Java 7
|
||||
|
@ -37,15 +38,15 @@ ext {
|
|||
deps = [
|
||||
// OpenTelemetry
|
||||
opentelemetryApi : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-api', version: versions.opentelemetry),
|
||||
opentelemetryContextProp : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-context-prop', version: versions.opentelemetryOther),
|
||||
opentelemetryContextProp : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-context-prop', version: versions.opentelemetryAnother),
|
||||
opentelemetryAutoAnnotations: dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-extension-auto-annotations', version: versions.opentelemetryOther),
|
||||
opentelemetryTraceProps : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-extension-trace-propagators', version: versions.opentelemetryOther),
|
||||
opentelemetrySdk : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-sdk', version: versions.opentelemetryOther),
|
||||
opentelemetryTraceProps : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-extension-trace-propagators', version: versions.opentelemetry),
|
||||
opentelemetrySdk : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-sdk', version: versions.opentelemetry),
|
||||
opentelemetryJaeger : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-exporters-jaeger', version: versions.opentelemetry),
|
||||
opentelemetryOtlp : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-exporters-otlp', version: versions.opentelemetry),
|
||||
opentelemetryZipkin : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-exporters-zipkin', version: versions.opentelemetryOther),
|
||||
opentelemetryOtlp : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-exporters-otlp', version: versions.opentelemetryAnother),
|
||||
opentelemetryZipkin : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-exporters-zipkin', version: versions.opentelemetry),
|
||||
opentelemetryLogging : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-exporters-logging', version: versions.opentelemetry),
|
||||
opentelemetryProto : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-proto', version: versions.opentelemetryOther),
|
||||
opentelemetryProto : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-proto', version: versions.opentelemetry),
|
||||
|
||||
// General
|
||||
slf4j : "org.slf4j:slf4j-api:${versions.slf4j}",
|
||||
|
|
|
@ -118,12 +118,15 @@ dependencies {
|
|||
// need to pin the opentelemetry-sdk transitive dependency versions explicitly, otherwise the
|
||||
// latest snapshots are used, because the opentelemetry-sdk snapshot pom references these
|
||||
// transitive dependencies using the generic SNAPSHOT instead of a specific snapshot
|
||||
implementation group: 'io.opentelemetry', name: 'opentelemetry-api', version: versions.opentelemetry
|
||||
implementation group: 'io.opentelemetry', name: 'opentelemetry-context-prop', version: versions.opentelemetryAnother
|
||||
implementation group: 'io.opentelemetry', name: 'opentelemetry-sdk', version: versions.opentelemetry
|
||||
implementation group: 'io.opentelemetry', name: 'opentelemetry-sdk-common', version: versions.opentelemetryAnother
|
||||
implementation group: 'io.opentelemetry', name: 'opentelemetry-sdk-correlation-context', version: versions.opentelemetryAnother
|
||||
implementation group: 'io.opentelemetry', name: 'opentelemetry-proto', version: versions.opentelemetryOther
|
||||
implementation group: 'io.opentelemetry', name: 'opentelemetry-sdk-metrics', version: versions.opentelemetryAnother
|
||||
implementation group: 'io.opentelemetry', name: 'opentelemetry-sdk-tracing', version: versions.opentelemetryAnother
|
||||
implementation group: 'io.opentelemetry', name: 'opentelemetry-sdk-baggage', version: versions.opentelemetryBaggage
|
||||
implementation group: 'io.opentelemetry', name: 'opentelemetry-sdk-common', version: versions.opentelemetry
|
||||
implementation group: 'io.opentelemetry', name: 'opentelemetry-proto', version: versions.opentelemetry
|
||||
implementation group: 'io.opentelemetry', name: 'opentelemetry-sdk-extension-otproto', version: versions.opentelemetryOther
|
||||
implementation group: 'io.opentelemetry', name: 'opentelemetry-sdk-metrics', version: versions.opentelemetryOther
|
||||
implementation group: 'io.opentelemetry', name: 'opentelemetry-sdk-tracing', version: versions.opentelemetry
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -292,6 +295,10 @@ tasks.withType(Test).configureEach {
|
|||
reports {
|
||||
junitXml.outputPerTestCase = true
|
||||
}
|
||||
|
||||
testLogging {
|
||||
exceptionFormat = 'full'
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(AbstractArchiveTask) {
|
||||
|
|
|
@ -56,7 +56,7 @@ public abstract class BaseDecorator {
|
|||
public Span onError(Span span, Throwable throwable) {
|
||||
assert span != null;
|
||||
if (throwable != null) {
|
||||
onComplete(span, Status.UNKNOWN, throwable);
|
||||
onComplete(span, Status.ERROR, throwable);
|
||||
}
|
||||
return span;
|
||||
}
|
||||
|
|
|
@ -23,37 +23,10 @@ public final class HttpStatusConverter {
|
|||
// https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/http.md#status
|
||||
public static Status statusFromHttpStatus(int httpStatus) {
|
||||
if (httpStatus >= 100 && httpStatus < 400) {
|
||||
return Status.OK;
|
||||
return Status.UNSET;
|
||||
}
|
||||
|
||||
switch (httpStatus) {
|
||||
case 401:
|
||||
return Status.UNAUTHENTICATED;
|
||||
case 403:
|
||||
return Status.PERMISSION_DENIED;
|
||||
case 404:
|
||||
return Status.NOT_FOUND;
|
||||
case 429:
|
||||
return Status.RESOURCE_EXHAUSTED;
|
||||
case 501:
|
||||
return Status.UNIMPLEMENTED;
|
||||
case 503:
|
||||
return Status.UNAVAILABLE;
|
||||
case 504:
|
||||
return Status.DEADLINE_EXCEEDED;
|
||||
default:
|
||||
// fall through
|
||||
}
|
||||
|
||||
if (httpStatus >= 400 && httpStatus < 500) {
|
||||
return Status.INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
if (httpStatus >= 500 && httpStatus < 600) {
|
||||
return Status.INTERNAL;
|
||||
}
|
||||
|
||||
return Status.UNKNOWN;
|
||||
return Status.ERROR;
|
||||
}
|
||||
|
||||
private HttpStatusConverter() {}
|
||||
|
|
|
@ -136,7 +136,7 @@ public abstract class BaseTracer {
|
|||
}
|
||||
|
||||
public void endExceptionally(Span span, Throwable throwable, long endTimeNanos) {
|
||||
span.setStatus(Status.INTERNAL);
|
||||
span.setStatus(Status.ERROR);
|
||||
onError(span, unwrapThrowable(throwable));
|
||||
end(span, endTimeNanos);
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ public abstract class DatabaseClientTracer<CONNECTION, QUERY> extends BaseTracer
|
|||
@Override
|
||||
protected void onError(Span span, Throwable throwable) {
|
||||
if (throwable != null) {
|
||||
span.setStatus(Status.UNKNOWN);
|
||||
span.setStatus(Status.ERROR);
|
||||
addThrowable(
|
||||
span, throwable instanceof ExecutionException ? throwable.getCause() : throwable);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ package io.opentelemetry.instrumentation.api.typedspan;
|
|||
import io.opentelemetry.common.AttributeKey;
|
||||
import io.opentelemetry.common.Attributes;
|
||||
import io.opentelemetry.trace.EndSpanOptions;
|
||||
import io.opentelemetry.trace.Event;
|
||||
import io.opentelemetry.trace.Span;
|
||||
import io.opentelemetry.trace.SpanContext;
|
||||
import io.opentelemetry.trace.Status;
|
||||
|
@ -76,16 +75,6 @@ public class DelegatingSpan implements Span {
|
|||
delegate.addEvent(name, attributes, timestamp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEvent(Event event) {
|
||||
delegate.addEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEvent(Event event, long timestamp) {
|
||||
delegate.addEvent(event, timestamp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStatus(Status status) {
|
||||
delegate.setStatus(status);
|
||||
|
|
|
@ -98,7 +98,7 @@ class BaseDecoratorTest extends Specification {
|
|||
|
||||
then:
|
||||
if (error) {
|
||||
1 * span.setStatus(Status.UNKNOWN)
|
||||
1 * span.setStatus(Status.ERROR)
|
||||
1 * span.recordException(error)
|
||||
}
|
||||
0 * _
|
||||
|
@ -120,7 +120,7 @@ class BaseDecoratorTest extends Specification {
|
|||
|
||||
where:
|
||||
error | status
|
||||
new Exception() | Status.INTERNAL
|
||||
new Exception() | Status.ERROR
|
||||
null | Status.OK
|
||||
}
|
||||
|
||||
|
|
|
@ -31,75 +31,75 @@ class HttpStatusConverterTest extends Specification {
|
|||
// https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
|
||||
where:
|
||||
httpStatus | expectedStatus
|
||||
100 | Status.OK
|
||||
101 | Status.OK
|
||||
102 | Status.OK
|
||||
103 | Status.OK
|
||||
100 | Status.UNSET
|
||||
101 | Status.UNSET
|
||||
102 | Status.UNSET
|
||||
103 | Status.UNSET
|
||||
|
||||
200 | Status.OK
|
||||
201 | Status.OK
|
||||
202 | Status.OK
|
||||
203 | Status.OK
|
||||
204 | Status.OK
|
||||
205 | Status.OK
|
||||
206 | Status.OK
|
||||
207 | Status.OK
|
||||
208 | Status.OK
|
||||
226 | Status.OK
|
||||
200 | Status.UNSET
|
||||
201 | Status.UNSET
|
||||
202 | Status.UNSET
|
||||
203 | Status.UNSET
|
||||
204 | Status.UNSET
|
||||
205 | Status.UNSET
|
||||
206 | Status.UNSET
|
||||
207 | Status.UNSET
|
||||
208 | Status.UNSET
|
||||
226 | Status.UNSET
|
||||
|
||||
300 | Status.OK
|
||||
301 | Status.OK
|
||||
302 | Status.OK
|
||||
303 | Status.OK
|
||||
304 | Status.OK
|
||||
305 | Status.OK
|
||||
306 | Status.OK
|
||||
307 | Status.OK
|
||||
308 | Status.OK
|
||||
300 | Status.UNSET
|
||||
301 | Status.UNSET
|
||||
302 | Status.UNSET
|
||||
303 | Status.UNSET
|
||||
304 | Status.UNSET
|
||||
305 | Status.UNSET
|
||||
306 | Status.UNSET
|
||||
307 | Status.UNSET
|
||||
308 | Status.UNSET
|
||||
|
||||
400 | Status.INVALID_ARGUMENT
|
||||
401 | Status.UNAUTHENTICATED
|
||||
403 | Status.PERMISSION_DENIED
|
||||
404 | Status.NOT_FOUND
|
||||
405 | Status.INVALID_ARGUMENT
|
||||
406 | Status.INVALID_ARGUMENT
|
||||
407 | Status.INVALID_ARGUMENT
|
||||
408 | Status.INVALID_ARGUMENT
|
||||
409 | Status.INVALID_ARGUMENT
|
||||
410 | Status.INVALID_ARGUMENT
|
||||
411 | Status.INVALID_ARGUMENT
|
||||
412 | Status.INVALID_ARGUMENT
|
||||
413 | Status.INVALID_ARGUMENT
|
||||
414 | Status.INVALID_ARGUMENT
|
||||
415 | Status.INVALID_ARGUMENT
|
||||
416 | Status.INVALID_ARGUMENT
|
||||
417 | Status.INVALID_ARGUMENT
|
||||
418 | Status.INVALID_ARGUMENT
|
||||
421 | Status.INVALID_ARGUMENT
|
||||
422 | Status.INVALID_ARGUMENT
|
||||
423 | Status.INVALID_ARGUMENT
|
||||
424 | Status.INVALID_ARGUMENT
|
||||
425 | Status.INVALID_ARGUMENT
|
||||
426 | Status.INVALID_ARGUMENT
|
||||
428 | Status.INVALID_ARGUMENT
|
||||
429 | Status.RESOURCE_EXHAUSTED
|
||||
431 | Status.INVALID_ARGUMENT
|
||||
451 | Status.INVALID_ARGUMENT
|
||||
400 | Status.ERROR
|
||||
401 | Status.ERROR
|
||||
403 | Status.ERROR
|
||||
404 | Status.ERROR
|
||||
405 | Status.ERROR
|
||||
406 | Status.ERROR
|
||||
407 | Status.ERROR
|
||||
408 | Status.ERROR
|
||||
409 | Status.ERROR
|
||||
410 | Status.ERROR
|
||||
411 | Status.ERROR
|
||||
412 | Status.ERROR
|
||||
413 | Status.ERROR
|
||||
414 | Status.ERROR
|
||||
415 | Status.ERROR
|
||||
416 | Status.ERROR
|
||||
417 | Status.ERROR
|
||||
418 | Status.ERROR
|
||||
421 | Status.ERROR
|
||||
422 | Status.ERROR
|
||||
423 | Status.ERROR
|
||||
424 | Status.ERROR
|
||||
425 | Status.ERROR
|
||||
426 | Status.ERROR
|
||||
428 | Status.ERROR
|
||||
429 | Status.ERROR
|
||||
431 | Status.ERROR
|
||||
451 | Status.ERROR
|
||||
|
||||
500 | Status.INTERNAL
|
||||
501 | Status.UNIMPLEMENTED
|
||||
502 | Status.INTERNAL
|
||||
503 | Status.UNAVAILABLE
|
||||
504 | Status.DEADLINE_EXCEEDED
|
||||
505 | Status.INTERNAL
|
||||
506 | Status.INTERNAL
|
||||
507 | Status.INTERNAL
|
||||
508 | Status.INTERNAL
|
||||
510 | Status.INTERNAL
|
||||
511 | Status.INTERNAL
|
||||
500 | Status.ERROR
|
||||
501 | Status.ERROR
|
||||
502 | Status.ERROR
|
||||
503 | Status.ERROR
|
||||
504 | Status.ERROR
|
||||
505 | Status.ERROR
|
||||
506 | Status.ERROR
|
||||
507 | Status.ERROR
|
||||
508 | Status.ERROR
|
||||
510 | Status.ERROR
|
||||
511 | Status.ERROR
|
||||
|
||||
// Don't exist
|
||||
99 | Status.UNKNOWN
|
||||
600 | Status.UNKNOWN
|
||||
99 | Status.ERROR
|
||||
600 | Status.ERROR
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ public abstract class TracingRequestHandler<I, O> implements RequestHandler<I, O
|
|||
} else {
|
||||
tracer.end(span);
|
||||
}
|
||||
OpenTelemetrySdk.getTracerProvider().forceFlush().join(1, TimeUnit.SECONDS);
|
||||
OpenTelemetrySdk.getTracerManagement().forceFlush().join(1, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ public abstract class TracingSQSEventHandler extends TracingRequestHandler<SQSEv
|
|||
} else {
|
||||
tracer.end(span);
|
||||
}
|
||||
OpenTelemetrySdk.getTracerProvider().forceFlush().join(1, TimeUnit.SECONDS);
|
||||
OpenTelemetrySdk.getTracerManagement().forceFlush().join(1, TimeUnit.SECONDS);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ public final class DropwizardViewInstrumentation extends Instrumenter.Default {
|
|||
}
|
||||
Span span = spanWithScope.getSpan();
|
||||
if (throwable != null) {
|
||||
span.setStatus(Status.UNKNOWN);
|
||||
span.setStatus(Status.ERROR);
|
||||
BaseDecorator.addThrowable(span, throwable);
|
||||
}
|
||||
span.end();
|
||||
|
|
|
@ -127,7 +127,7 @@ public class GoogleHttpClientInstrumentation extends Instrumenter.Default {
|
|||
// If HttpRequest.setThrowExceptionOnExecuteError is set to false, there are no exceptions
|
||||
// for a failed request. Thus, check the response code
|
||||
if (response != null && !response.isSuccessStatusCode()) {
|
||||
span.setStatus(Status.UNKNOWN);
|
||||
span.setStatus(Status.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,23 +32,22 @@ public final class GrpcHelper {
|
|||
|
||||
static {
|
||||
EnumMap<Code, CanonicalCode> codeMap = new EnumMap<>(Code.class);
|
||||
codeMap.put(Code.OK, CanonicalCode.OK);
|
||||
codeMap.put(Code.CANCELLED, CanonicalCode.CANCELLED);
|
||||
codeMap.put(Code.INVALID_ARGUMENT, CanonicalCode.INVALID_ARGUMENT);
|
||||
codeMap.put(Code.DEADLINE_EXCEEDED, CanonicalCode.DEADLINE_EXCEEDED);
|
||||
codeMap.put(Code.NOT_FOUND, CanonicalCode.NOT_FOUND);
|
||||
codeMap.put(Code.ALREADY_EXISTS, CanonicalCode.ALREADY_EXISTS);
|
||||
codeMap.put(Code.PERMISSION_DENIED, CanonicalCode.PERMISSION_DENIED);
|
||||
codeMap.put(Code.RESOURCE_EXHAUSTED, CanonicalCode.RESOURCE_EXHAUSTED);
|
||||
codeMap.put(Code.FAILED_PRECONDITION, CanonicalCode.FAILED_PRECONDITION);
|
||||
codeMap.put(Code.ABORTED, CanonicalCode.ABORTED);
|
||||
codeMap.put(Code.OUT_OF_RANGE, CanonicalCode.OUT_OF_RANGE);
|
||||
codeMap.put(Code.UNIMPLEMENTED, CanonicalCode.UNIMPLEMENTED);
|
||||
codeMap.put(Code.INTERNAL, CanonicalCode.INTERNAL);
|
||||
codeMap.put(Code.UNAVAILABLE, CanonicalCode.UNAVAILABLE);
|
||||
codeMap.put(Code.DATA_LOSS, CanonicalCode.DATA_LOSS);
|
||||
codeMap.put(Code.UNAUTHENTICATED, CanonicalCode.UNAUTHENTICATED);
|
||||
codeMap.put(Code.UNKNOWN, CanonicalCode.UNKNOWN);
|
||||
codeMap.put(Code.CANCELLED, CanonicalCode.ERROR);
|
||||
codeMap.put(Code.INVALID_ARGUMENT, CanonicalCode.ERROR);
|
||||
codeMap.put(Code.DEADLINE_EXCEEDED, CanonicalCode.ERROR);
|
||||
codeMap.put(Code.NOT_FOUND, CanonicalCode.ERROR);
|
||||
codeMap.put(Code.ALREADY_EXISTS, CanonicalCode.ERROR);
|
||||
codeMap.put(Code.PERMISSION_DENIED, CanonicalCode.ERROR);
|
||||
codeMap.put(Code.RESOURCE_EXHAUSTED, CanonicalCode.ERROR);
|
||||
codeMap.put(Code.FAILED_PRECONDITION, CanonicalCode.ERROR);
|
||||
codeMap.put(Code.ABORTED, CanonicalCode.ERROR);
|
||||
codeMap.put(Code.OUT_OF_RANGE, CanonicalCode.ERROR);
|
||||
codeMap.put(Code.UNIMPLEMENTED, CanonicalCode.ERROR);
|
||||
codeMap.put(Code.INTERNAL, CanonicalCode.ERROR);
|
||||
codeMap.put(Code.UNAVAILABLE, CanonicalCode.ERROR);
|
||||
codeMap.put(Code.DATA_LOSS, CanonicalCode.ERROR);
|
||||
codeMap.put(Code.UNAUTHENTICATED, CanonicalCode.ERROR);
|
||||
codeMap.put(Code.UNKNOWN, CanonicalCode.ERROR);
|
||||
CODE_MAP = Collections.unmodifiableMap(codeMap);
|
||||
}
|
||||
|
||||
|
@ -88,7 +87,7 @@ public final class GrpcHelper {
|
|||
|
||||
private static CanonicalCode codeFromGrpcCode(Code grpcCode) {
|
||||
CanonicalCode code = CODE_MAP.get(grpcCode);
|
||||
return code != null ? code : CanonicalCode.UNKNOWN;
|
||||
return code != null ? code : CanonicalCode.UNSET;
|
||||
}
|
||||
|
||||
private GrpcHelper() {}
|
||||
|
|
|
@ -27,7 +27,6 @@ import io.grpc.ServerBuilder
|
|||
import io.grpc.stub.StreamObserver
|
||||
import io.opentelemetry.auto.test.AgentTestRunner
|
||||
import io.opentelemetry.auto.test.utils.PortUtils
|
||||
import io.opentelemetry.trace.Status
|
||||
import io.opentelemetry.trace.attributes.SemanticAttributes
|
||||
import java.util.concurrent.CopyOnWriteArrayList
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
@ -119,7 +118,6 @@ class GrpcStreamingTest extends AgentTestRunner {
|
|||
spanKind CLIENT
|
||||
parent()
|
||||
errored false
|
||||
status(Status.OK)
|
||||
attributes {
|
||||
"${SemanticAttributes.RPC_SYSTEM.key()}" "grpc"
|
||||
"${SemanticAttributes.RPC_SERVICE.key()}" "example.Greeter"
|
||||
|
@ -143,7 +141,6 @@ class GrpcStreamingTest extends AgentTestRunner {
|
|||
spanKind SERVER
|
||||
childOf span(0)
|
||||
errored false
|
||||
status(Status.OK)
|
||||
attributes {
|
||||
"${SemanticAttributes.RPC_SYSTEM.key()}" "grpc"
|
||||
"${SemanticAttributes.RPC_SERVICE.key()}" "example.Greeter"
|
||||
|
|
|
@ -77,7 +77,6 @@ class GrpcTest extends AgentTestRunner {
|
|||
spanKind CLIENT
|
||||
childOf span(0)
|
||||
errored false
|
||||
status(io.opentelemetry.trace.Status.OK)
|
||||
event(0) {
|
||||
eventName "message"
|
||||
attributes {
|
||||
|
@ -98,7 +97,6 @@ class GrpcTest extends AgentTestRunner {
|
|||
spanKind SERVER
|
||||
childOf span(1)
|
||||
errored false
|
||||
status(io.opentelemetry.trace.Status.OK)
|
||||
event(0) {
|
||||
eventName "message"
|
||||
attributes {
|
||||
|
@ -249,7 +247,6 @@ class GrpcTest extends AgentTestRunner {
|
|||
errored true
|
||||
// NB: Exceptions thrown on the server don't appear to be propagated to the client, at
|
||||
// least for the version we test against.
|
||||
status(io.opentelemetry.trace.Status.UNKNOWN)
|
||||
attributes {
|
||||
"${SemanticAttributes.RPC_SYSTEM.key()}" "grpc"
|
||||
"${SemanticAttributes.RPC_SERVICE.key()}" "example.Greeter"
|
||||
|
|
|
@ -26,7 +26,11 @@ class GrpcHelperTest extends Specification {
|
|||
def status = GrpcHelper.statusFromGrpcStatus(grpcStatus)
|
||||
|
||||
then:
|
||||
status.canonicalCode.name() == grpcStatus.code.name()
|
||||
if (grpcStatus == Status.OK) {
|
||||
status.canonicalCode == io.opentelemetry.trace.Status.CanonicalCode.UNSET
|
||||
} else {
|
||||
status.canonicalCode == io.opentelemetry.trace.Status.CanonicalCode.ERROR
|
||||
}
|
||||
status.description == null
|
||||
|
||||
// Considering history of status, if we compare all values of the gRPC status by name, we will
|
||||
|
@ -40,7 +44,7 @@ class GrpcHelperTest extends Specification {
|
|||
def status = GrpcHelper.statusFromGrpcStatus(Status.INVALID_ARGUMENT.withDescription("bad argument"))
|
||||
|
||||
then:
|
||||
status.canonicalCode == io.opentelemetry.trace.Status.CanonicalCode.INVALID_ARGUMENT
|
||||
status.canonicalCode == io.opentelemetry.trace.Status.CanonicalCode.ERROR
|
||||
status.description == "bad argument"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,8 +77,8 @@ shadowJar {
|
|||
// relocate OpenTelemetry API usage
|
||||
relocate "io.opentelemetry.OpenTelemetry", "io.opentelemetry.javaagent.shaded.io.opentelemetry.OpenTelemetry"
|
||||
relocate "io.opentelemetry.common", "io.opentelemetry.javaagent.shaded.io.opentelemetry.common"
|
||||
relocate "io.opentelemetry.baggage", "io.opentelemetry.javaagent.shaded.io.opentelemetry.baggage"
|
||||
relocate "io.opentelemetry.context", "io.opentelemetry.javaagent.shaded.io.opentelemetry.context"
|
||||
relocate "io.opentelemetry.correlationcontext", "io.opentelemetry.javaagent.shaded.io.opentelemetry.correlationcontext"
|
||||
relocate "io.opentelemetry.internal", "io.opentelemetry.javaagent.shaded.io.opentelemetry.internal"
|
||||
relocate "io.opentelemetry.metrics", "io.opentelemetry.javaagent.shaded.io.opentelemetry.metrics"
|
||||
relocate "io.opentelemetry.trace", "io.opentelemetry.javaagent.shaded.io.opentelemetry.trace"
|
||||
|
|
|
@ -39,8 +39,7 @@ public abstract class LettuceAbstractDatabaseClientTracer<QUERY>
|
|||
@Override
|
||||
public Span onConnection(Span span, RedisURI connection) {
|
||||
if (connection != null && connection.getDatabase() != 0) {
|
||||
span.setAttribute(
|
||||
SemanticAttributes.REDIS_DATABASE_INDEX, String.valueOf(connection.getDatabase()));
|
||||
span.setAttribute(SemanticAttributes.REDIS_DATABASE_INDEX, connection.getDatabase());
|
||||
}
|
||||
return super.onConnection(span, connection);
|
||||
}
|
||||
|
|
|
@ -43,8 +43,7 @@ public abstract class LettuceAbstractDatabaseClientTracer<QUERY>
|
|||
@Override
|
||||
public Span onConnection(Span span, RedisURI connection) {
|
||||
if (connection != null && connection.getDatabase() != 0) {
|
||||
span.setAttribute(
|
||||
SemanticAttributes.REDIS_DATABASE_INDEX, String.valueOf(connection.getDatabase()));
|
||||
span.setAttribute(SemanticAttributes.REDIS_DATABASE_INDEX, connection.getDatabase());
|
||||
}
|
||||
return super.onConnection(span, connection);
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ public enum OpenTelemetryTracing implements Tracing {
|
|||
|
||||
@Nullable private List<Object> events;
|
||||
|
||||
@Nullable private Status status;
|
||||
@Nullable private Throwable error;
|
||||
|
||||
@Nullable private Span span;
|
||||
|
||||
|
@ -208,9 +208,10 @@ public enum OpenTelemetryTracing implements Tracing {
|
|||
events = null;
|
||||
}
|
||||
|
||||
if (status != null) {
|
||||
span.setStatus(status);
|
||||
status = null;
|
||||
if (error != null) {
|
||||
span.setStatus(Status.ERROR);
|
||||
span.recordException(error);
|
||||
error = null;
|
||||
}
|
||||
|
||||
return this;
|
||||
|
@ -247,13 +248,10 @@ public enum OpenTelemetryTracing implements Tracing {
|
|||
|
||||
@Override
|
||||
public synchronized Tracer.Span error(Throwable throwable) {
|
||||
// TODO(anuraaga): Check if any lettuce exceptions map well to a Status and try mapping.
|
||||
Status status =
|
||||
Status.UNKNOWN.withDescription(throwable.getClass() + ": " + throwable.getMessage());
|
||||
if (span != null) {
|
||||
span.setStatus(status);
|
||||
span.recordException(throwable);
|
||||
} else {
|
||||
this.status = status;
|
||||
this.error = throwable;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -23,8 +23,8 @@ import static net.bytebuddy.matcher.ElementMatchers.named;
|
|||
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
|
||||
|
||||
import application.io.grpc.Context;
|
||||
import application.io.opentelemetry.correlationcontext.CorrelationContext;
|
||||
import com.google.auto.service.AutoService;
|
||||
import io.opentelemetry.baggage.Baggage;
|
||||
import io.opentelemetry.javaagent.tooling.Instrumenter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -33,30 +33,26 @@ import net.bytebuddy.description.method.MethodDescription;
|
|||
import net.bytebuddy.description.type.TypeDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
|
||||
// TODO: Actually bridge correlation context. We currently just stub out withCorrelationContext
|
||||
// TODO: Actually bridge correlation context. We currently just stub out withBaggage
|
||||
// to have minimum functionality with SDK shim implementations.
|
||||
// https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/973
|
||||
@AutoService(Instrumenter.class)
|
||||
public class CorrelationsContextUtilsInstrumentation extends AbstractInstrumentation {
|
||||
public class BaggageUtilsInstrumentation extends AbstractInstrumentation {
|
||||
@Override
|
||||
public ElementMatcher<? super TypeDescription> typeMatcher() {
|
||||
return named("application.io.opentelemetry.correlationcontext.CorrelationsContextUtils");
|
||||
return named("application.io.opentelemetry.baggage.BaggageUtils");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
|
||||
Map<ElementMatcher<? super MethodDescription>, String> transformers = new HashMap<>();
|
||||
transformers.put(
|
||||
isMethod()
|
||||
.and(isPublic())
|
||||
.and(isStatic())
|
||||
.and(named("withCorrelationContext"))
|
||||
.and(takesArguments(2)),
|
||||
CorrelationsContextUtilsInstrumentation.class.getName() + "$WithCorrelationContextAdvice");
|
||||
isMethod().and(isPublic()).and(isStatic()).and(named("withBaggage")).and(takesArguments(2)),
|
||||
BaggageUtilsInstrumentation.class.getName() + "$WithBaggageAdvice");
|
||||
return transformers;
|
||||
}
|
||||
|
||||
public static class WithCorrelationContextAdvice {
|
||||
public static class WithBaggageAdvice {
|
||||
|
||||
@Advice.OnMethodEnter(skipOn = Advice.OnDefaultValue.class)
|
||||
public static Object onEnter() {
|
||||
|
@ -65,7 +61,7 @@ public class CorrelationsContextUtilsInstrumentation extends AbstractInstrumenta
|
|||
|
||||
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||
public static void methodExit(
|
||||
@Advice.Argument(0) CorrelationContext applicationCorrelationContext,
|
||||
@Advice.Argument(0) Baggage applicationBaggage,
|
||||
@Advice.Argument(1) Context applicationContext,
|
||||
@Advice.Return(readOnly = false) Context applicationUpdatedContext) {
|
||||
applicationUpdatedContext = applicationContext;
|
|
@ -23,8 +23,6 @@ import application.io.grpc.Context;
|
|||
import application.io.opentelemetry.common.AttributeKey;
|
||||
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;
|
||||
|
@ -92,16 +90,6 @@ class ApplicationSpan implements Span {
|
|||
agentSpan.addEvent(name, Bridging.toAgent(applicationAttributes), timestamp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEvent(Event applicationEvent) {
|
||||
addEvent(applicationEvent.getName(), applicationEvent.getAttributes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEvent(Event applicationEvent, long timestamp) {
|
||||
addEvent(applicationEvent.getName(), applicationEvent.getAttributes(), timestamp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStatus(Status applicationStatus) {
|
||||
io.opentelemetry.trace.Status agentStatus = Bridging.toAgentOrNull(applicationStatus);
|
||||
|
@ -192,14 +180,6 @@ class ApplicationSpan implements Span {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Span.Builder addLink(Link applicationLink) {
|
||||
agentBuilder.addLink(
|
||||
Bridging.toAgent(applicationLink.getContext()),
|
||||
Bridging.toAgent(applicationLink.getAttributes()));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Span.Builder setAttribute(String key, String value) {
|
||||
agentBuilder.setAttribute(key, value);
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
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.NON_MONOTONIC_DOUBLE
|
||||
import static io.opentelemetry.sdk.metrics.data.MetricData.Descriptor.Type.NON_MONOTONIC_LONG
|
||||
import static io.opentelemetry.sdk.metrics.data.MetricData.Descriptor.Type.SUMMARY
|
||||
import static io.opentelemetry.sdk.metrics.data.MetricData.Type.MONOTONIC_DOUBLE
|
||||
import static io.opentelemetry.sdk.metrics.data.MetricData.Type.MONOTONIC_LONG
|
||||
import static io.opentelemetry.sdk.metrics.data.MetricData.Type.NON_MONOTONIC_DOUBLE
|
||||
import static io.opentelemetry.sdk.metrics.data.MetricData.Type.NON_MONOTONIC_LONG
|
||||
import static io.opentelemetry.sdk.metrics.data.MetricData.Type.SUMMARY
|
||||
|
||||
import application.io.opentelemetry.OpenTelemetry
|
||||
import application.io.opentelemetry.common.Labels
|
||||
|
@ -54,9 +54,9 @@ class MeterTest extends AgentTestRunner {
|
|||
then:
|
||||
def metricData = findMetric(OpenTelemetrySdk.getMeterProvider().getMetricProducer().collectAllMetrics(), instrumentationName, "test")
|
||||
metricData != null
|
||||
metricData.descriptor.description == "d"
|
||||
metricData.descriptor.unit == "u"
|
||||
metricData.descriptor.type == expectedType
|
||||
metricData.description == "d"
|
||||
metricData.unit == "u"
|
||||
metricData.type == expectedType
|
||||
metricData.instrumentationLibraryInfo.name == instrumentationName
|
||||
metricData.instrumentationLibraryInfo.version == "1.2.3"
|
||||
metricData.points.size() == 1
|
||||
|
@ -105,9 +105,9 @@ class MeterTest extends AgentTestRunner {
|
|||
then:
|
||||
def metricData = findMetric(OpenTelemetrySdk.getMeterProvider().getMetricProducer().collectAllMetrics(), instrumentationName, "test")
|
||||
metricData != null
|
||||
metricData.descriptor.description == "d"
|
||||
metricData.descriptor.unit == "u"
|
||||
metricData.descriptor.type == SUMMARY
|
||||
metricData.description == "d"
|
||||
metricData.unit == "u"
|
||||
metricData.type == SUMMARY
|
||||
metricData.instrumentationLibraryInfo.name == instrumentationName
|
||||
metricData.instrumentationLibraryInfo.version == "1.2.3"
|
||||
metricData.points.size() == 1
|
||||
|
@ -186,9 +186,9 @@ class MeterTest extends AgentTestRunner {
|
|||
then:
|
||||
def metricData = findMetric(OpenTelemetrySdk.getMeterProvider().getMetricProducer().collectAllMetrics(), instrumentationName, "test")
|
||||
metricData != null
|
||||
metricData.descriptor.description == "d"
|
||||
metricData.descriptor.unit == "u"
|
||||
metricData.descriptor.type == expectedType
|
||||
metricData.description == "d"
|
||||
metricData.unit == "u"
|
||||
metricData.type == expectedType
|
||||
metricData.instrumentationLibraryInfo.name == instrumentationName
|
||||
metricData.instrumentationLibraryInfo.version == "1.2.3"
|
||||
metricData.points.size() == 1
|
||||
|
@ -238,9 +238,9 @@ class MeterTest extends AgentTestRunner {
|
|||
then:
|
||||
def metricData = findMetric(allMetrics, instrumentationName, "test")
|
||||
metricData != null
|
||||
metricData.descriptor.description == "d"
|
||||
metricData.descriptor.unit == "u"
|
||||
metricData.descriptor.type == MONOTONIC_LONG
|
||||
metricData.description == "d"
|
||||
metricData.unit == "u"
|
||||
metricData.type == MONOTONIC_LONG
|
||||
metricData.instrumentationLibraryInfo.name == instrumentationName
|
||||
metricData.instrumentationLibraryInfo.version == "1.2.3"
|
||||
metricData.points.size() == 1
|
||||
|
@ -250,9 +250,9 @@ class MeterTest extends AgentTestRunner {
|
|||
|
||||
def metricData2 = findMetric(allMetrics, instrumentationName, "test2")
|
||||
metricData2 != null
|
||||
metricData2.descriptor.description == "d"
|
||||
metricData2.descriptor.unit == "u"
|
||||
metricData2.descriptor.type == SUMMARY
|
||||
metricData2.description == "d"
|
||||
metricData2.unit == "u"
|
||||
metricData2.type == SUMMARY
|
||||
metricData2.instrumentationLibraryInfo.name == instrumentationName
|
||||
metricData2.instrumentationLibraryInfo.version == "1.2.3"
|
||||
metricData2.points.size() == 1
|
||||
|
@ -264,7 +264,7 @@ class MeterTest extends AgentTestRunner {
|
|||
|
||||
def findMetric(Collection<MetricData> allMetrics, instrumentationName, metricName) {
|
||||
for (def metric : allMetrics) {
|
||||
if (metric.instrumentationLibraryInfo.name == instrumentationName && metric.descriptor.name == metricName) {
|
||||
if (metric.instrumentationLibraryInfo.name == instrumentationName && metric.name == metricName) {
|
||||
return metric
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ class TracerSdkTest extends AgentTestRunner {
|
|||
|
||||
def "direct access to sdk should not fail"() {
|
||||
when:
|
||||
def provider = OpenTelemetrySdk.getTracerProvider()
|
||||
def provider = OpenTelemetrySdk.getTracerManagement()
|
||||
|
||||
then:
|
||||
provider instanceof TracerSdkProvider
|
||||
|
|
|
@ -41,7 +41,7 @@ class TracerTest extends AgentTestRunner {
|
|||
testSpan.setAttribute("long", 2)
|
||||
testSpan.setAttribute("double", 3.0)
|
||||
testSpan.setAttribute("boolean", true)
|
||||
testSpan.setStatus(Status.UNKNOWN)
|
||||
testSpan.setStatus(Status.ERROR)
|
||||
testSpan.end()
|
||||
|
||||
then:
|
||||
|
@ -51,7 +51,7 @@ class TracerTest extends AgentTestRunner {
|
|||
operationName "test"
|
||||
spanKind io.opentelemetry.trace.Span.Kind.PRODUCER
|
||||
parent()
|
||||
status io.opentelemetry.trace.Status.UNKNOWN
|
||||
status io.opentelemetry.trace.Status.ERROR
|
||||
attributes {
|
||||
"string" "1"
|
||||
"long" 2
|
||||
|
|
|
@ -31,7 +31,7 @@ public class ErrorHandlerAdvice {
|
|||
Optional<Span> span = ctx.maybeGet(Span.class);
|
||||
if (span.isPresent()) {
|
||||
// TODO this emulates old behaviour of BaseDecorator. Has to review
|
||||
span.get().setStatus(Status.UNKNOWN);
|
||||
span.get().setStatus(Status.ERROR);
|
||||
TRACER.addThrowable(span.get(), throwable);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public class Servlet3HttpServerTracer extends ServletHttpServerTracer<HttpServle
|
|||
}
|
||||
|
||||
public void onTimeout(Span span, long timeout) {
|
||||
span.setStatus(Status.DEADLINE_EXCEEDED);
|
||||
span.setStatus(Status.ERROR);
|
||||
span.setAttribute("timeout", timeout);
|
||||
span.end();
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ public class OtelConfig {
|
|||
Tracer tracer = OpenTelemetry.getTracer(tracerName);
|
||||
|
||||
SpanProcessor logProcessor = SimpleSpanProcessor.newBuilder(new LoggingSpanExporter()).build();
|
||||
OpenTelemetrySdk.getTracerProvider().addSpanProcessor(logProcessor);
|
||||
OpenTelemetrySdk.getTracerManagement().addSpanProcessor(logProcessor);
|
||||
|
||||
return tracer;
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ SpanProcessor jaegerProcessor = SimpleSpanProcessor
|
|||
.setChannel(ManagedChannelBuilder.forAddress("localhost", 14250).usePlaintext().build())
|
||||
.build())
|
||||
.build();
|
||||
OpenTelemetrySdk.getTracerProvider().addSpanProcessor(jaegerProcessor);
|
||||
OpenTelemetrySdk.getTracerManagement().addSpanProcessor(jaegerProcessor);
|
||||
```
|
||||
|
||||
### Project Background
|
||||
|
|
|
@ -36,8 +36,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
/**
|
||||
* Create {@link io.opentelemetry.trace.Tracer} bean if bean is missing.
|
||||
*
|
||||
* <p>Adds span exporter beans to the active tracer provider {@code
|
||||
* OpenTelemetrySdk.getTracerProvider()}
|
||||
* <p>Adds span exporter beans to the active tracer provider.
|
||||
*
|
||||
* <p>Updates the sampler probability in the active {@link TraceConfig}
|
||||
*/
|
||||
|
@ -69,18 +68,18 @@ public class TracerAutoConfiguration {
|
|||
.map(spanExporter -> SimpleSpanProcessor.newBuilder(spanExporter).build())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
OpenTelemetrySdk.getTracerProvider()
|
||||
OpenTelemetrySdk.getTracerManagement()
|
||||
.addSpanProcessor(MultiSpanProcessor.create(spanProcessors));
|
||||
}
|
||||
|
||||
private void setSampler(TracerProperties tracerProperties) {
|
||||
TraceConfig updatedTraceConfig =
|
||||
OpenTelemetrySdk.getTracerProvider()
|
||||
OpenTelemetrySdk.getTracerManagement()
|
||||
.getActiveTraceConfig()
|
||||
.toBuilder()
|
||||
.setSampler(Samplers.traceIdRatioBased(tracerProperties.getSamplerProbability()))
|
||||
.build();
|
||||
|
||||
OpenTelemetrySdk.getTracerProvider().updateActiveTraceConfig(updatedTraceConfig);
|
||||
OpenTelemetrySdk.getTracerManagement().updateActiveTraceConfig(updatedTraceConfig);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class WithSpanAspect {
|
|||
try (Scope scope = tracer.withSpan(span)) {
|
||||
return pjp.proceed();
|
||||
} catch (Throwable t) {
|
||||
span.setStatus(Status.INTERNAL);
|
||||
span.setStatus(Status.ERROR);
|
||||
span.recordException(t);
|
||||
throw t;
|
||||
} finally {
|
||||
|
|
|
@ -91,7 +91,7 @@ public class AdviceUtils {
|
|||
if (context != null) {
|
||||
Span span = TracingContextUtils.getSpan(context);
|
||||
if (throwable != null) {
|
||||
span.setStatus(Status.UNKNOWN);
|
||||
span.setStatus(Status.ERROR);
|
||||
BaseDecorator.addThrowable(span, throwable);
|
||||
}
|
||||
span.end();
|
||||
|
|
|
@ -58,8 +58,8 @@ shadowJar {
|
|||
// relocate OpenTelemetry API usage
|
||||
relocate "io.opentelemetry.OpenTelemetry", "io.opentelemetry.javaagent.shaded.io.opentelemetry.OpenTelemetry"
|
||||
relocate "io.opentelemetry.common", "io.opentelemetry.javaagent.shaded.io.opentelemetry.common"
|
||||
relocate "io.opentelemetry.baggage", "io.opentelemetry.javaagent.shaded.io.opentelemetry.baggage"
|
||||
relocate "io.opentelemetry.context", "io.opentelemetry.javaagent.shaded.io.opentelemetry.context"
|
||||
relocate "io.opentelemetry.correlationcontext", "io.opentelemetry.javaagent.shaded.io.opentelemetry.correlationcontext"
|
||||
relocate "io.opentelemetry.internal", "io.opentelemetry.javaagent.shaded.io.opentelemetry.internal"
|
||||
relocate "io.opentelemetry.metrics", "io.opentelemetry.javaagent.shaded.io.opentelemetry.metrics"
|
||||
relocate "io.opentelemetry.trace", "io.opentelemetry.javaagent.shaded.io.opentelemetry.trace"
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package io.opentelemetry.javaagent.spi;
|
||||
|
||||
import io.opentelemetry.context.propagation.ContextPropagators;
|
||||
import io.opentelemetry.sdk.trace.TracerSdkManagement;
|
||||
import io.opentelemetry.sdk.trace.TracerSdkProvider;
|
||||
import io.opentelemetry.sdk.trace.config.TraceConfig;
|
||||
|
||||
|
@ -35,5 +36,5 @@ import io.opentelemetry.sdk.trace.config.TraceConfig;
|
|||
public interface TracerCustomizer {
|
||||
|
||||
/** Callback executed after the initial {@link TracerSdkProvider} has been initialized. */
|
||||
void configure(TracerSdkProvider tracerSdkProvider);
|
||||
void configure(TracerSdkManagement tracerManagement);
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ public class AgentInstaller {
|
|||
new ForceFlusher() {
|
||||
@Override
|
||||
public void run(int timeout, TimeUnit unit) {
|
||||
OpenTelemetrySdk.getTracerProvider().forceFlush().join(timeout, unit);
|
||||
OpenTelemetrySdk.getTracerManagement().forceFlush().join(timeout, unit);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -46,12 +46,12 @@ public class ExporterClassLoader extends URLClassLoader {
|
|||
rule(
|
||||
"#io.opentelemetry.common",
|
||||
"#io.opentelemetry.javaagent.shaded.io.opentelemetry.common"),
|
||||
rule(
|
||||
"#io.opentelemetry.baggage",
|
||||
"#io.opentelemetry.javaagent.shaded.io.opentelemetry.baggage"),
|
||||
rule(
|
||||
"#io.opentelemetry.context",
|
||||
"#io.opentelemetry.javaagent.shaded.io.opentelemetry.context"),
|
||||
rule(
|
||||
"#io.opentelemetry.correlationcontext",
|
||||
"#io.opentelemetry.javaagent.shaded.io.opentelemetry.correlationcontext"),
|
||||
rule(
|
||||
"#io.opentelemetry.internal",
|
||||
"#io.opentelemetry.javaagent.shaded.io.opentelemetry.internal"),
|
||||
|
|
|
@ -58,6 +58,12 @@ public class PropagatorsInitializer {
|
|||
public static void initializePropagators(List<String> propagators) {
|
||||
/* Only override the default propagators *if* the user specified any. */
|
||||
if (propagators.size() == 0) {
|
||||
// TODO this is probably temporary until default propagators are supplied by SDK
|
||||
// https://github.com/open-telemetry/opentelemetry-java/issues/1742
|
||||
OpenTelemetry.setPropagators(
|
||||
DefaultContextPropagators.builder()
|
||||
.addTextMapPropagator(HttpTraceContext.getInstance())
|
||||
.build());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import io.opentelemetry.javaagent.spi.exporter.SpanExporterFactory;
|
|||
import io.opentelemetry.sdk.OpenTelemetrySdk;
|
||||
import io.opentelemetry.sdk.metrics.export.IntervalMetricReader;
|
||||
import io.opentelemetry.sdk.metrics.export.MetricExporter;
|
||||
import io.opentelemetry.sdk.trace.TracerSdkProvider;
|
||||
import io.opentelemetry.sdk.trace.TracerSdkManagement;
|
||||
import io.opentelemetry.sdk.trace.config.TraceConfig;
|
||||
import io.opentelemetry.sdk.trace.export.BatchSpanProcessor;
|
||||
import io.opentelemetry.sdk.trace.export.SpanExporter;
|
||||
|
@ -166,7 +166,7 @@ public class TracerInstaller {
|
|||
SpanExporter spanExporter = spanExporterFactory.fromConfig(config);
|
||||
BatchSpanProcessor spanProcessor =
|
||||
BatchSpanProcessor.newBuilder(spanExporter).readProperties(config).build();
|
||||
OpenTelemetrySdk.getTracerProvider().addSpanProcessor(spanProcessor);
|
||||
OpenTelemetrySdk.getTracerManagement().addSpanProcessor(spanProcessor);
|
||||
log.info("Installed span exporter: " + spanExporter.getClass().getName());
|
||||
}
|
||||
|
||||
|
@ -186,21 +186,21 @@ public class TracerInstaller {
|
|||
}
|
||||
|
||||
private static void configure(Properties config) {
|
||||
TracerSdkProvider tracerSdkProvider = OpenTelemetrySdk.getTracerProvider();
|
||||
TracerSdkManagement tracerManagement = OpenTelemetrySdk.getTracerManagement();
|
||||
|
||||
// Register additional thread details logging span processor
|
||||
tracerSdkProvider.addSpanProcessor(new AddThreadDetailsSpanProcessor());
|
||||
tracerManagement.addSpanProcessor(new AddThreadDetailsSpanProcessor());
|
||||
|
||||
// Execute any user-provided (usually vendor-provided) configuration logic.
|
||||
ServiceLoader<TracerCustomizer> serviceLoader =
|
||||
ServiceLoader.load(TracerCustomizer.class, TracerInstaller.class.getClassLoader());
|
||||
for (TracerCustomizer customizer : serviceLoader) {
|
||||
customizer.configure(tracerSdkProvider);
|
||||
customizer.configure(tracerManagement);
|
||||
}
|
||||
|
||||
/* Update trace config from env vars or sys props */
|
||||
TraceConfig activeTraceConfig = tracerSdkProvider.getActiveTraceConfig();
|
||||
tracerSdkProvider.updateActiveTraceConfig(
|
||||
TraceConfig activeTraceConfig = tracerManagement.getActiveTraceConfig();
|
||||
tracerManagement.updateActiveTraceConfig(
|
||||
activeTraceConfig.toBuilder().readProperties(config).build());
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ package io.opentelemetry.javaagent.typed.base;
|
|||
import io.opentelemetry.common.AttributeKey;
|
||||
import io.opentelemetry.common.Attributes;
|
||||
import io.opentelemetry.trace.EndSpanOptions;
|
||||
import io.opentelemetry.trace.Event;
|
||||
import io.opentelemetry.trace.Span;
|
||||
import io.opentelemetry.trace.SpanContext;
|
||||
import io.opentelemetry.trace.Status;
|
||||
|
@ -77,16 +76,6 @@ public class DelegatingSpan implements Span {
|
|||
delegate.addEvent(name, attributes, timestamp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEvent(Event event) {
|
||||
delegate.addEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEvent(Event event, long timestamp) {
|
||||
delegate.addEvent(event, timestamp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStatus(Status status) {
|
||||
delegate.setStatus(status);
|
||||
|
|
|
@ -89,8 +89,8 @@ tasks.withType(ShadowJar).configureEach {
|
|||
// relocate OpenTelemetry API
|
||||
relocate "io.opentelemetry.OpenTelemetry", "io.opentelemetry.javaagent.shaded.io.opentelemetry.OpenTelemetry"
|
||||
relocate "io.opentelemetry.common", "io.opentelemetry.javaagent.shaded.io.opentelemetry.common"
|
||||
relocate "io.opentelemetry.baggage", "io.opentelemetry.javaagent.shaded.io.opentelemetry.baggage"
|
||||
relocate "io.opentelemetry.context", "io.opentelemetry.javaagent.shaded.io.opentelemetry.context"
|
||||
relocate "io.opentelemetry.correlationcontext", "io.opentelemetry.javaagent.shaded.io.opentelemetry.correlationcontext"
|
||||
relocate "io.opentelemetry.internal", "io.opentelemetry.javaagent.shaded.io.opentelemetry.internal"
|
||||
relocate "io.opentelemetry.metrics", "io.opentelemetry.javaagent.shaded.io.opentelemetry.metrics"
|
||||
relocate "io.opentelemetry.trace", "io.opentelemetry.javaagent.shaded.io.opentelemetry.trace"
|
||||
|
|
|
@ -27,6 +27,7 @@ import groovy.transform.stc.ClosureParams;
|
|||
import groovy.transform.stc.SimpleType;
|
||||
import io.opentelemetry.OpenTelemetry;
|
||||
import io.opentelemetry.auto.test.asserts.InMemoryExporterAssert;
|
||||
import io.opentelemetry.context.propagation.DefaultContextPropagators;
|
||||
import io.opentelemetry.javaagent.tooling.AgentInstaller;
|
||||
import io.opentelemetry.javaagent.tooling.Instrumenter;
|
||||
import io.opentelemetry.javaagent.tooling.config.ConfigInitializer;
|
||||
|
@ -34,6 +35,7 @@ import io.opentelemetry.javaagent.tooling.matcher.AdditionalLibraryIgnoresMatche
|
|||
import io.opentelemetry.sdk.OpenTelemetrySdk;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData;
|
||||
import io.opentelemetry.trace.Tracer;
|
||||
import io.opentelemetry.trace.propagation.HttpTraceContext;
|
||||
import java.lang.instrument.ClassFileTransformer;
|
||||
import java.lang.instrument.Instrumentation;
|
||||
import java.util.ArrayList;
|
||||
|
@ -108,7 +110,21 @@ public abstract class AgentTestRunner extends Specification {
|
|||
((Logger) LoggerFactory.getLogger("io.opentelemetry")).setLevel(Level.DEBUG);
|
||||
|
||||
TEST_WRITER = new InMemoryExporter();
|
||||
OpenTelemetrySdk.getTracerProvider().addSpanProcessor(TEST_WRITER);
|
||||
// TODO this is probably temporary until default propagators are supplied by SDK
|
||||
// https://github.com/open-telemetry/opentelemetry-java/issues/1742
|
||||
// currently checking against no-op implementation so that it won't override aws-lambda
|
||||
// propagator configuration
|
||||
if (OpenTelemetry.getPropagators()
|
||||
.getTextMapPropagator()
|
||||
.getClass()
|
||||
.getSimpleName()
|
||||
.equals("NoopTextMapPropagator")) {
|
||||
OpenTelemetry.setPropagators(
|
||||
DefaultContextPropagators.builder()
|
||||
.addTextMapPropagator(HttpTraceContext.getInstance())
|
||||
.build());
|
||||
}
|
||||
OpenTelemetrySdk.getTracerManagement().addSpanProcessor(TEST_WRITER);
|
||||
TEST_TRACER = OpenTelemetry.getTracer("io.opentelemetry.auto");
|
||||
}
|
||||
|
||||
|
|
|
@ -20,9 +20,12 @@ import com.google.common.base.Predicate
|
|||
import com.google.common.base.Predicates
|
||||
import groovy.transform.stc.ClosureParams
|
||||
import groovy.transform.stc.SimpleType
|
||||
import io.opentelemetry.OpenTelemetry
|
||||
import io.opentelemetry.auto.test.asserts.InMemoryExporterAssert
|
||||
import io.opentelemetry.context.propagation.DefaultContextPropagators
|
||||
import io.opentelemetry.sdk.OpenTelemetrySdk
|
||||
import io.opentelemetry.sdk.trace.data.SpanData
|
||||
import io.opentelemetry.trace.propagation.HttpTraceContext
|
||||
import org.junit.Before
|
||||
import spock.lang.Specification
|
||||
|
||||
|
@ -36,7 +39,16 @@ abstract class InstrumentationTestRunner extends Specification {
|
|||
|
||||
static {
|
||||
TEST_WRITER = new InMemoryExporter()
|
||||
OpenTelemetrySdk.getTracerProvider().addSpanProcessor(TEST_WRITER)
|
||||
// TODO this is probably temporary until default propagators are supplied by SDK
|
||||
// https://github.com/open-telemetry/opentelemetry-java/issues/1742
|
||||
// currently checking against no-op implementation so that it won't override aws-lambda
|
||||
// propagator configuration
|
||||
if (OpenTelemetry.getPropagators().getTextMapPropagator().getClass().getSimpleName() == "NoopTextMapPropagator") {
|
||||
OpenTelemetry.setPropagators(DefaultContextPropagators.builder()
|
||||
.addTextMapPropagator(HttpTraceContext.getInstance())
|
||||
.build())
|
||||
}
|
||||
OpenTelemetrySdk.getTracerManagement().addSpanProcessor(TEST_WRITER)
|
||||
}
|
||||
|
||||
@Before
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
package io.opentelemetry.auto.test.asserts
|
||||
|
||||
import static AttributesAssert.assertAttributes
|
||||
import static io.opentelemetry.sdk.trace.data.SpanData.Event
|
||||
|
||||
import groovy.transform.stc.ClosureParams
|
||||
import groovy.transform.stc.SimpleType
|
||||
import io.opentelemetry.common.AttributeConsumer
|
||||
import io.opentelemetry.common.AttributeKey
|
||||
import io.opentelemetry.common.Attributes
|
||||
import io.opentelemetry.trace.Event
|
||||
|
||||
class EventAssert {
|
||||
private final Event event
|
||||
|
|
|
@ -140,9 +140,10 @@ class SpanAssert {
|
|||
|
||||
def errored(boolean errored) {
|
||||
if (errored) {
|
||||
assert span.status != Status.OK
|
||||
// comparing only canonical code, since description may be different
|
||||
assert span.status.canonicalCode == Status.CanonicalCode.ERROR
|
||||
} else {
|
||||
assert span.status == Status.OK
|
||||
assert span.status == Status.UNSET
|
||||
}
|
||||
checked.status = true
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue