Drop opentelemetry-sdk-extension-jfr-events, which moved to opentelemetry-java-contrib (#4703)
This commit is contained in:
parent
2bc88f45c6
commit
def1c85b60
|
@ -276,7 +276,6 @@ dependency as follows, replacing `{{artifact-id}}` with the value from the "Arti
|
|||
| [SDK Resources Extension](./sdk-extensions/resources) | Resource providers, including container, host, os, and process | `opentelemetry-sdk-extension-resources` | <!--VERSION_STABLE-->1.17.0<!--/VERSION_STABLE--> |
|
||||
| [SDK AWS Extension](./sdk-extensions/aws) | AWS resource providers, including beanstalk, ec2, ecs, eks, and lambda | `opentelemetry-sdk-extension-aws` | <!--VERSION_STABLE-->1.17.0<!--/VERSION_STABLE--> |
|
||||
| [SDK Jaeger Remote Sampler Extension](./sdk-extensions/jaeger-remote-sampler) | Sampler which obtains sampling configuration from remote Jaeger server | `opentelemetry-sdk-extension-jaeger-remote-sampler` | <!--VERSION_STABLE-->1.17.0<!--/VERSION_STABLE--> |
|
||||
| [SDK JFR Events Extension](./sdk-extensions/jfr-events) | SpanProcessor which records spans as JFR events | `opentelemetry-sdk-extension-jfr-events` | <!--VERSION_UNSTABLE-->1.17.0-alpha<!--/VERSION_UNSTABLE--> |
|
||||
| [SDK Incubator](./sdk-extensions/incubator) | SDK incubator, including YAML based view configuration, LeakDetectingSpanProcessor, and zPages | `opentelemetry-sdk-extension-incubator` | TODO: add version when published |
|
||||
|
||||
### Shims
|
||||
|
|
|
@ -8,10 +8,10 @@ otelJava.moduleName.set("io.opentelemetry.all")
|
|||
tasks {
|
||||
// We don't compile much here, just some API boundary tests. This project is mostly for
|
||||
// aggregating jacoco reports and it doesn't work if this isn't at least as high as the
|
||||
// highest supported Java version in any of our projects. Most of our projects target
|
||||
// Java 8, except for jfr-events.
|
||||
// highest supported Java version in any of our projects. All of our projects target
|
||||
// Java 8.
|
||||
withType(JavaCompile::class) {
|
||||
options.release.set(11)
|
||||
options.release.set(8)
|
||||
}
|
||||
|
||||
val testJavaVersion: String? by project
|
||||
|
@ -83,9 +83,7 @@ tasks.named<JacocoReport>("jacocoTestReport") {
|
|||
!it.absolutePath.contains("io/opentelemetry/exporter/jaeger/internal/protobuf/") &&
|
||||
!it.absolutePath.contains("io/opentelemetry/sdk/extension/trace/jaeger/proto/") &&
|
||||
!it.absolutePath.contains("io/opentelemetry/semconv/trace/attributes/") &&
|
||||
!it.absolutePath.contains("AutoValue_") &&
|
||||
// TODO(anuraaga): Remove exclusion after enabling coverage for jfr-events
|
||||
!it.absolutePath.contains("io/opentelemetry/sdk/extension/jfr")
|
||||
!it.absolutePath.contains("AutoValue_")
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ class SdkDesignTest {
|
|||
}
|
||||
|
||||
static DescribedPredicate<? super JavaMethod> implementOrOverride() {
|
||||
return new DescribedPredicate<>("implement or override a method") {
|
||||
return new DescribedPredicate<JavaMethod>("implement or override a method") {
|
||||
@Override
|
||||
public boolean apply(JavaMethod input) {
|
||||
List<JavaClass> params = input.getRawParameterTypes();
|
||||
|
@ -78,7 +78,7 @@ class SdkDesignTest {
|
|||
}
|
||||
|
||||
static DescribedPredicate<? super JavaClass> inPackage(String... requiredPackages) {
|
||||
return new DescribedPredicate<>("are in " + Arrays.toString(requiredPackages)) {
|
||||
return new DescribedPredicate<JavaClass>("are in " + Arrays.toString(requiredPackages)) {
|
||||
@Override
|
||||
public boolean apply(JavaClass member) {
|
||||
for (String requiredPackage : requiredPackages) {
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
# OpenTelemetry SDK Extension Java Flight Recorder (JFR) Events
|
||||
|
||||
[![Javadocs][javadoc-image]][javadoc-url]
|
||||
|
||||
Create JFR events that can be recorded and viewed in Java Mission Control (JMC).
|
||||
* Creates Open Telemetry Tracing/Span events for spans
|
||||
* The thread and stracktrace will be of the thead ending the span which might be different than the thread creating the span.
|
||||
* Has the fields
|
||||
* Operation Name
|
||||
* Trace ID
|
||||
* Parent Span ID
|
||||
* Span ID
|
||||
* Creates Open Telemetry Tracing/Scope events for scopes
|
||||
* Thread will match the thread the scope was active in and the stacktrace will be when scope was closed
|
||||
* Multiple scopes might be collected for a single span
|
||||
* Has the fields
|
||||
* Trace ID
|
||||
* Span ID
|
||||
* Supports the Open Source version of JFR in Java 11.
|
||||
* Might support back port to OpenJDK 8, but not tested and classes are built with JDK 11 bytecode.
|
||||
|
||||
[javadoc-image]: https://www.javadoc.io/badge/io.opentelemetry/opentelemetry-sdk-extension-jfr-events.svg
|
||||
[javadoc-url]: https://www.javadoc.io/doc/io.opentelemetry/opentelemetry-sdk-extension-jfr-events
|
|
@ -1,30 +0,0 @@
|
|||
plugins {
|
||||
id("otel.java-conventions")
|
||||
id("otel.publish-conventions")
|
||||
}
|
||||
|
||||
description = "OpenTelemetry SDK Extension JFR"
|
||||
otelJava.moduleName.set("io.opentelemetry.sdk.extension.jfr")
|
||||
|
||||
dependencies {
|
||||
implementation(project(":api:all"))
|
||||
implementation(project(":sdk:all"))
|
||||
}
|
||||
|
||||
tasks {
|
||||
withType(JavaCompile::class) {
|
||||
options.release.set(11)
|
||||
}
|
||||
|
||||
test {
|
||||
val testJavaVersion: String? by project
|
||||
if (testJavaVersion == "8") {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
// Disabled due to https://bugs.openjdk.java.net/browse/JDK-8245283
|
||||
configure<JacocoTaskExtension> {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
otel.release=alpha
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.sdk.extension.jfr;
|
||||
|
||||
import io.opentelemetry.api.trace.Span;
|
||||
import io.opentelemetry.context.Context;
|
||||
import io.opentelemetry.context.ContextStorage;
|
||||
import io.opentelemetry.context.Scope;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class JfrContextStorageWrapper implements ContextStorage {
|
||||
|
||||
private final ContextStorage wrapped;
|
||||
|
||||
public JfrContextStorageWrapper(ContextStorage wrapped) {
|
||||
this.wrapped = wrapped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Scope attach(Context toAttach) {
|
||||
Scope scope = wrapped.attach(toAttach);
|
||||
ScopeEvent event = new ScopeEvent(Span.fromContext(toAttach).getSpanContext());
|
||||
event.begin();
|
||||
return () -> {
|
||||
if (event.shouldCommit()) {
|
||||
event.commit();
|
||||
}
|
||||
scope.close();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Context current() {
|
||||
return wrapped.current();
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.sdk.extension.jfr;
|
||||
|
||||
import io.opentelemetry.api.trace.SpanContext;
|
||||
import io.opentelemetry.context.Context;
|
||||
import io.opentelemetry.context.internal.shaded.WeakConcurrentMap;
|
||||
import io.opentelemetry.sdk.common.CompletableResultCode;
|
||||
import io.opentelemetry.sdk.trace.ReadWriteSpan;
|
||||
import io.opentelemetry.sdk.trace.ReadableSpan;
|
||||
import io.opentelemetry.sdk.trace.SpanProcessor;
|
||||
|
||||
/**
|
||||
* Span processor to create new JFR events for the Span as they are started, and commit on end.
|
||||
*
|
||||
* <p>NOTE: The JfrSpanProcessor measures the timing of spans, avoid if possible to wrap it with any
|
||||
* other SpanProcessor which may affect timings. When possible, register it first before any other
|
||||
* processors to allow the most accurate measurements.
|
||||
*/
|
||||
public final class JfrSpanProcessor implements SpanProcessor {
|
||||
|
||||
private final WeakConcurrentMap<SpanContext, SpanEvent> spanEvents =
|
||||
new WeakConcurrentMap.WithInlinedExpunction<>();
|
||||
|
||||
private volatile boolean closed;
|
||||
|
||||
@Override
|
||||
public void onStart(Context parentContext, ReadWriteSpan span) {
|
||||
if (closed) {
|
||||
return;
|
||||
}
|
||||
if (span.getSpanContext().isValid()) {
|
||||
SpanEvent event = new SpanEvent(span.toSpanData());
|
||||
event.begin();
|
||||
spanEvents.put(span.getSpanContext(), event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStartRequired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnd(ReadableSpan rs) {
|
||||
SpanEvent event = spanEvents.remove(rs.getSpanContext());
|
||||
if (!closed && event != null && event.shouldCommit()) {
|
||||
event.commit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEndRequired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableResultCode shutdown() {
|
||||
closed = true;
|
||||
return CompletableResultCode.ofSuccess();
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.sdk.extension.jfr;
|
||||
|
||||
import io.opentelemetry.api.trace.SpanContext;
|
||||
import jdk.jfr.Category;
|
||||
import jdk.jfr.Description;
|
||||
import jdk.jfr.Event;
|
||||
import jdk.jfr.Label;
|
||||
import jdk.jfr.Name;
|
||||
|
||||
@Name("io.opentelemetry.context.Scope")
|
||||
@Label("Scope")
|
||||
@Category("Open Telemetry Tracing")
|
||||
@Description(
|
||||
"Open Telemetry trace event corresponding to the span currently "
|
||||
+ "in scope/active on this thread.")
|
||||
class ScopeEvent extends Event {
|
||||
|
||||
private final String traceId;
|
||||
private final String spanId;
|
||||
|
||||
ScopeEvent(SpanContext spanContext) {
|
||||
this.traceId = spanContext.getTraceId();
|
||||
this.spanId = spanContext.getSpanId();
|
||||
}
|
||||
|
||||
@Label("Trace Id")
|
||||
public String getTraceId() {
|
||||
return traceId;
|
||||
}
|
||||
|
||||
@Label("Span Id")
|
||||
public String getSpanId() {
|
||||
return spanId;
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.sdk.extension.jfr;
|
||||
|
||||
import io.opentelemetry.sdk.trace.data.SpanData;
|
||||
import jdk.jfr.Category;
|
||||
import jdk.jfr.Description;
|
||||
import jdk.jfr.Event;
|
||||
import jdk.jfr.Label;
|
||||
import jdk.jfr.Name;
|
||||
|
||||
@Label("Span")
|
||||
@Name("io.opentelemetry.trace.Span")
|
||||
@Category("Open Telemetry Tracing")
|
||||
@Description("Open Telemetry trace event corresponding to a span.")
|
||||
class SpanEvent extends Event {
|
||||
|
||||
private final String operationName;
|
||||
private final String traceId;
|
||||
private final String spanId;
|
||||
private final String parentId;
|
||||
|
||||
SpanEvent(SpanData spanData) {
|
||||
this.operationName = spanData.getName();
|
||||
this.traceId = spanData.getTraceId();
|
||||
this.spanId = spanData.getSpanId();
|
||||
this.parentId = spanData.getParentSpanId();
|
||||
}
|
||||
|
||||
@Label("Operation Name")
|
||||
public String getOperationName() {
|
||||
return operationName;
|
||||
}
|
||||
|
||||
@Label("Trace Id")
|
||||
public String getTraceId() {
|
||||
return traceId;
|
||||
}
|
||||
|
||||
@Label("Span Id")
|
||||
public String getSpanId() {
|
||||
return spanId;
|
||||
}
|
||||
|
||||
@Label("Parent Id")
|
||||
public String getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Capture Spans and Scopes as events in JFR recordings.
|
||||
*
|
||||
* @see io.opentelemetry.sdk.extension.jfr.JfrSpanProcessor
|
||||
*/
|
||||
@ParametersAreNonnullByDefault
|
||||
package io.opentelemetry.sdk.extension.jfr;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
|
@ -1,127 +0,0 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.sdk.extension.jfr;
|
||||
|
||||
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
|
||||
|
||||
import io.opentelemetry.api.trace.Span;
|
||||
import io.opentelemetry.api.trace.Tracer;
|
||||
import io.opentelemetry.context.ContextStorage;
|
||||
import io.opentelemetry.context.Scope;
|
||||
import io.opentelemetry.sdk.trace.SdkTracerProvider;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import jdk.jfr.Recording;
|
||||
import jdk.jfr.consumer.RecordedEvent;
|
||||
import jdk.jfr.consumer.RecordingFile;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class JfrSpanProcessorTest {
|
||||
|
||||
private static final String OPERATION_NAME = "Test Span";
|
||||
|
||||
private SdkTracerProvider sdkTracerProvider;
|
||||
private Tracer tracer;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
sdkTracerProvider =
|
||||
SdkTracerProvider.builder().addSpanProcessor(new JfrSpanProcessor()).build();
|
||||
tracer = sdkTracerProvider.get("JfrSpanProcessorTest");
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void tearDown() {
|
||||
sdkTracerProvider.shutdown();
|
||||
}
|
||||
|
||||
static {
|
||||
ContextStorage.addWrapper(JfrContextStorageWrapper::new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test basic single span.
|
||||
*
|
||||
* @throws java.io.IOException on io error
|
||||
*/
|
||||
@Test
|
||||
public void basicSpan() throws IOException {
|
||||
Path output = Files.createTempFile("test-basic-span", ".jfr");
|
||||
|
||||
try {
|
||||
Recording recording = new Recording();
|
||||
recording.start();
|
||||
Span span;
|
||||
|
||||
try (recording) {
|
||||
|
||||
span = tracer.spanBuilder(OPERATION_NAME).setNoParent().startSpan();
|
||||
span.end();
|
||||
|
||||
recording.dump(output);
|
||||
}
|
||||
|
||||
List<RecordedEvent> events = RecordingFile.readAllEvents(output);
|
||||
assertThat(events).hasSize(1);
|
||||
assertThat(events)
|
||||
.extracting(e -> e.getValue("traceId"))
|
||||
.isEqualTo(span.getSpanContext().getTraceId());
|
||||
assertThat(events)
|
||||
.extracting(e -> e.getValue("spanId"))
|
||||
.isEqualTo(span.getSpanContext().getSpanId());
|
||||
assertThat(events).extracting(e -> e.getValue("operationName")).isEqualTo(OPERATION_NAME);
|
||||
} finally {
|
||||
Files.delete(output);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test basic single span with a scope.
|
||||
*
|
||||
* @throws java.io.IOException on io error
|
||||
* @throws java.lang.InterruptedException interrupted sleep
|
||||
*/
|
||||
@Test
|
||||
public void basicSpanWithScope() throws IOException, InterruptedException {
|
||||
Path output = Files.createTempFile("test-basic-span-with-scope", ".jfr");
|
||||
|
||||
try {
|
||||
Recording recording = new Recording();
|
||||
recording.start();
|
||||
Span span;
|
||||
|
||||
try (recording) {
|
||||
span = tracer.spanBuilder(OPERATION_NAME).setNoParent().startSpan();
|
||||
try (Scope s = span.makeCurrent()) {
|
||||
Thread.sleep(10);
|
||||
}
|
||||
span.end();
|
||||
|
||||
recording.dump(output);
|
||||
}
|
||||
|
||||
List<RecordedEvent> events = RecordingFile.readAllEvents(output);
|
||||
assertThat(events).hasSize(2);
|
||||
assertThat(events)
|
||||
.extracting(e -> e.getValue("traceId"))
|
||||
.isEqualTo(span.getSpanContext().getTraceId());
|
||||
assertThat(events)
|
||||
.extracting(e -> e.getValue("spanId"))
|
||||
.isEqualTo(span.getSpanContext().getSpanId());
|
||||
assertThat(events)
|
||||
.filteredOn(e -> "Span".equals(e.getEventType().getLabel()))
|
||||
.extracting(e -> e.getValue("operationName"))
|
||||
.isEqualTo(OPERATION_NAME);
|
||||
|
||||
} finally {
|
||||
Files.delete(output);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -67,7 +67,6 @@ include(":sdk-extensions:aws")
|
|||
include(":sdk-extensions:resources")
|
||||
include(":sdk-extensions:incubator")
|
||||
include(":sdk-extensions:jaeger-remote-sampler")
|
||||
include(":sdk-extensions:jfr-events")
|
||||
include(":testing-internal")
|
||||
|
||||
val isCI = System.getenv("CI") != null
|
||||
|
|
Loading…
Reference in New Issue