Deprecate semconv module (#5786)
This commit is contained in:
parent
0660781ed2
commit
a438127c37
13
README.md
13
README.md
|
@ -221,12 +221,13 @@ dependency as follows, replacing `{{artifact-id}}` with the value from the "Arti
|
|||
|
||||
### API
|
||||
|
||||
| Component | Description | Artifact ID | Version | Javadoc |
|
||||
|-----------------------------------|--------------------------------------------------------------------------------------------------------------------------------|----------------------------|-------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| [API](./api/all) | OpenTelemetry API, including metrics, traces, baggage, context | `opentelemetry-api` | <!--VERSION_STABLE-->1.29.0<!--/VERSION_STABLE--> | [](https://www.javadoc.io/doc/io.opentelemetry/opentelemetry-api) |
|
||||
| [Events API](./api/events) | OpenTelemetry Event API for emitting events. | `opentelemetry-api-events` | <!--VERSION_UNSTABLE-->1.29.0-alpha<!--/VERSION_UNSTABLE--> | [](https://www.javadoc.io/doc/io.opentelemetry/opentelemetry-api-events) |
|
||||
| [Context API](./context) | OpenTelemetry context API | `opentelemetry-context` | <!--VERSION_STABLE-->1.29.0<!--/VERSION_STABLE--> | [](https://www.javadoc.io/doc/io.opentelemetry/opentelemetry-context) |
|
||||
| [Semantic Conventions](./semconv) | Generated code for OpenTelemetry semantic conventions | `opentelemetry-semconv` | <!--VERSION_UNSTABLE-->1.29.0-alpha<!--/VERSION_UNSTABLE--> | [](https://www.javadoc.io/doc/io.opentelemetry/opentelemetry-semconv) |
|
||||
|
||||
| Component | Description | Artifact ID | Version | Javadoc |
|
||||
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- | ----------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [API](./api/all) | OpenTelemetry API, including metrics, traces, baggage, context | `opentelemetry-api` | <!--VERSION_STABLE-->1.29.0<!--/VERSION_STABLE--> | [](https://www.javadoc.io/doc/io.opentelemetry/opentelemetry-api) |
|
||||
| [Events API](./api/events) | OpenTelemetry Event API for emitting events. | `opentelemetry-api-events` | <!--VERSION_UNSTABLE-->1.29.0-alpha<!--/VERSION_UNSTABLE--> | [](https://www.javadoc.io/doc/io.opentelemetry/opentelemetry-api-events) |
|
||||
| [Context API](./context) | OpenTelemetry context API | `opentelemetry-context` | <!--VERSION_STABLE-->1.29.0<!--/VERSION_STABLE--> | [](https://www.javadoc.io/doc/io.opentelemetry/opentelemetry-context) |
|
||||
| [Semantic Conventions](./semconv) | Generated code for OpenTelemetry semantic conventions (deprecated, moved to [open-telemetry/semantic-conventions-java](https://github.com/open-telemetry/semantic-conventions-java)) | `opentelemetry-semconv` | <!--VERSION_UNSTABLE-->1.29.0-alpha<!--/VERSION_UNSTABLE--> | [](https://www.javadoc.io/doc/io.opentelemetry/opentelemetry-semconv) |
|
||||
|
||||
### API Extensions
|
||||
|
||||
|
|
|
@ -14,4 +14,4 @@ javaPlatform.allowDependencies()
|
|||
dependencies {
|
||||
// Add dependency on opentelemetry-bom to ensure synchronization between alpha and stable artifacts
|
||||
api(platform(project(":bom")))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,15 +6,18 @@
|
|||
package io.opentelemetry.gradle
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.model.ObjectFactory
|
||||
import org.gradle.api.provider.Property
|
||||
import java.util.function.Predicate
|
||||
|
||||
abstract class OtelBomExtension {
|
||||
abstract val projectFilter: Property<Predicate<Project>>
|
||||
val fallbacks: MutableSet<String> = hashSetOf()
|
||||
val additionalDependencies: MutableSet<String> = hashSetOf()
|
||||
|
||||
fun addFallback(artifactId: String, version: String) {
|
||||
this.fallbacks.add("io.opentelemetry:" + artifactId + ":" + version)
|
||||
this.additionalDependencies.add("io.opentelemetry:" + artifactId + ":" + version)
|
||||
}
|
||||
}
|
||||
|
||||
fun addExtra(groupId: String, artifactId: String, version: String) {
|
||||
this.additionalDependencies.add(groupId + ":" + artifactId + ":" + version)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,10 +61,10 @@ afterEvaluate {
|
|||
}
|
||||
}
|
||||
}
|
||||
otelBom.fallbacks.forEach { fallback ->
|
||||
otelBom.additionalDependencies.forEach { dependency ->
|
||||
dependencies {
|
||||
constraints {
|
||||
api(fallback)
|
||||
api(dependency)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ dependencies {
|
|||
api(project(":sdk:all"))
|
||||
|
||||
implementation(project(":sdk:all"))
|
||||
implementation(project(":semconv"))
|
||||
|
||||
implementation("com.fasterxml.jackson.jr:jackson-jr-objects")
|
||||
implementation("io.jaegertracing:jaeger-client") {
|
||||
|
|
|
@ -11,12 +11,12 @@ import io.jaegertracing.thriftjava.Process;
|
|||
import io.jaegertracing.thriftjava.Span;
|
||||
import io.jaegertracing.thriftjava.Tag;
|
||||
import io.jaegertracing.thriftjava.TagType;
|
||||
import io.opentelemetry.api.common.AttributeKey;
|
||||
import io.opentelemetry.sdk.common.CompletableResultCode;
|
||||
import io.opentelemetry.sdk.internal.ThrottlingLogger;
|
||||
import io.opentelemetry.sdk.resources.Resource;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData;
|
||||
import io.opentelemetry.sdk.trace.export.SpanExporter;
|
||||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -40,6 +40,8 @@ import javax.annotation.concurrent.ThreadSafe;
|
|||
@Deprecated
|
||||
public final class JaegerThriftSpanExporter implements SpanExporter {
|
||||
|
||||
private static final AttributeKey<String> SERVICE_NAME = AttributeKey.stringKey("service.name");
|
||||
|
||||
static final String DEFAULT_ENDPOINT = "http://localhost:14268/api/traces";
|
||||
|
||||
private static final String DEFAULT_HOST_NAME = "unknown";
|
||||
|
@ -121,9 +123,9 @@ public final class JaegerThriftSpanExporter implements SpanExporter {
|
|||
private Process createProcess(Resource resource) {
|
||||
Process result = new Process(this.process);
|
||||
|
||||
String serviceName = resource.getAttribute(ResourceAttributes.SERVICE_NAME);
|
||||
String serviceName = resource.getAttribute(SERVICE_NAME);
|
||||
if (serviceName == null || serviceName.isEmpty()) {
|
||||
serviceName = Resource.getDefault().getAttribute(ResourceAttributes.SERVICE_NAME);
|
||||
serviceName = Resource.getDefault().getAttribute(SERVICE_NAME);
|
||||
}
|
||||
// In practice should never be null unless the default Resource spec is changed.
|
||||
if (serviceName != null) {
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
package io.opentelemetry.exporter.jaeger.thrift;
|
||||
|
||||
import static io.opentelemetry.api.common.AttributeKey.stringKey;
|
||||
|
||||
import com.fasterxml.jackson.core.TreeNode;
|
||||
import com.fasterxml.jackson.jr.ob.JSON;
|
||||
import com.fasterxml.jackson.jr.stree.JacksonJrsTreeCodec;
|
||||
|
@ -15,7 +17,6 @@ import io.opentelemetry.sdk.OpenTelemetrySdk;
|
|||
import io.opentelemetry.sdk.resources.Resource;
|
||||
import io.opentelemetry.sdk.trace.SdkTracerProvider;
|
||||
import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor;
|
||||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
|
||||
import java.time.Duration;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
|
@ -84,7 +85,7 @@ class JaegerThriftIntegrationTest {
|
|||
.addSpanProcessor(SimpleSpanProcessor.create(jaegerExporter.build()))
|
||||
.setResource(
|
||||
Resource.getDefault().toBuilder()
|
||||
.put(ResourceAttributes.SERVICE_NAME, SERVICE_NAME)
|
||||
.put(stringKey("service.name"), SERVICE_NAME)
|
||||
.build())
|
||||
.build())
|
||||
.build();
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
package io.opentelemetry.exporter.jaeger.thrift;
|
||||
|
||||
import static io.opentelemetry.api.common.AttributeKey.stringKey;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
|
@ -17,7 +18,6 @@ import io.jaegertracing.thriftjava.SpanRef;
|
|||
import io.jaegertracing.thriftjava.SpanRefType;
|
||||
import io.jaegertracing.thriftjava.Tag;
|
||||
import io.jaegertracing.thriftjava.TagType;
|
||||
import io.opentelemetry.api.common.AttributeKey;
|
||||
import io.opentelemetry.api.common.Attributes;
|
||||
import io.opentelemetry.api.trace.SpanContext;
|
||||
import io.opentelemetry.api.trace.SpanKind;
|
||||
|
@ -30,7 +30,6 @@ import io.opentelemetry.sdk.resources.Resource;
|
|||
import io.opentelemetry.sdk.testing.trace.TestSpanData;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData;
|
||||
import io.opentelemetry.sdk.trace.data.StatusData;
|
||||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.time.Duration;
|
||||
|
@ -79,9 +78,9 @@ class JaegerThriftSpanExporterTest {
|
|||
testSpanData(
|
||||
Resource.create(
|
||||
Attributes.of(
|
||||
ResourceAttributes.SERVICE_NAME,
|
||||
stringKey("service.name"),
|
||||
"myServiceName",
|
||||
AttributeKey.stringKey("resource-attr-key"),
|
||||
stringKey("resource-attr-key"),
|
||||
"resource-attr-value")),
|
||||
"GET /api/endpoint",
|
||||
SPAN_CONTEXT,
|
||||
|
@ -140,9 +139,9 @@ class JaegerThriftSpanExporterTest {
|
|||
testSpanData(
|
||||
Resource.create(
|
||||
Attributes.of(
|
||||
ResourceAttributes.SERVICE_NAME,
|
||||
stringKey("service.name"),
|
||||
"myServiceName1",
|
||||
AttributeKey.stringKey("resource-attr-key-1"),
|
||||
stringKey("resource-attr-key-1"),
|
||||
"resource-attr-value-1")),
|
||||
"GET /api/endpoint/1",
|
||||
SPAN_CONTEXT,
|
||||
|
@ -152,9 +151,9 @@ class JaegerThriftSpanExporterTest {
|
|||
testSpanData(
|
||||
Resource.create(
|
||||
Attributes.of(
|
||||
ResourceAttributes.SERVICE_NAME,
|
||||
stringKey("service.name"),
|
||||
"myServiceName2",
|
||||
AttributeKey.stringKey("resource-attr-key-2"),
|
||||
stringKey("resource-attr-key-2"),
|
||||
"resource-attr-value-2")),
|
||||
"GET /api/endpoint/2",
|
||||
SPAN_CONTEXT_2,
|
||||
|
|
|
@ -17,7 +17,6 @@ dependencies {
|
|||
|
||||
implementation(project(":exporters:common"))
|
||||
implementation(project(":exporters:sender:okhttp"))
|
||||
implementation(project(":semconv"))
|
||||
implementation(project(":sdk-extensions:autoconfigure-spi"))
|
||||
|
||||
compileOnly("io.grpc:grpc-stub")
|
||||
|
|
|
@ -5,24 +5,26 @@
|
|||
|
||||
package io.opentelemetry.exporter.jaeger;
|
||||
|
||||
import io.opentelemetry.api.common.AttributeKey;
|
||||
import io.opentelemetry.exporter.internal.marshal.MarshalerUtil;
|
||||
import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize;
|
||||
import io.opentelemetry.exporter.internal.marshal.Serializer;
|
||||
import io.opentelemetry.exporter.jaeger.proto.api_v2.internal.Process;
|
||||
import io.opentelemetry.sdk.resources.Resource;
|
||||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
final class ProcessMarshaler extends MarshalerWithSize {
|
||||
|
||||
private static final AttributeKey<String> SERVICE_NAME = AttributeKey.stringKey("service.name");
|
||||
|
||||
private final byte[] serviceNameUtf8;
|
||||
private final List<KeyValueMarshaler> tags;
|
||||
|
||||
static ProcessMarshaler create(Resource resource) {
|
||||
String serviceName = resource.getAttribute(ResourceAttributes.SERVICE_NAME);
|
||||
String serviceName = resource.getAttribute(SERVICE_NAME);
|
||||
if (serviceName == null || serviceName.isEmpty()) {
|
||||
serviceName = Resource.getDefault().getAttribute(ResourceAttributes.SERVICE_NAME);
|
||||
serviceName = Resource.getDefault().getAttribute(SERVICE_NAME);
|
||||
}
|
||||
|
||||
return new ProcessMarshaler(
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
package io.opentelemetry.exporter.jaeger;
|
||||
|
||||
import static io.opentelemetry.api.common.AttributeKey.stringKey;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatCode;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
@ -17,7 +18,6 @@ import com.linecorp.armeria.server.grpc.protocol.AbstractUnaryGrpcService;
|
|||
import com.linecorp.armeria.testing.junit5.server.SelfSignedCertificateExtension;
|
||||
import com.linecorp.armeria.testing.junit5.server.ServerExtension;
|
||||
import io.github.netmikey.logunit.api.LogCapturer;
|
||||
import io.opentelemetry.api.common.AttributeKey;
|
||||
import io.opentelemetry.api.common.Attributes;
|
||||
import io.opentelemetry.api.metrics.MeterProvider;
|
||||
import io.opentelemetry.api.trace.SpanContext;
|
||||
|
@ -38,7 +38,6 @@ import io.opentelemetry.sdk.testing.trace.TestSpanData;
|
|||
import io.opentelemetry.sdk.trace.IdGenerator;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData;
|
||||
import io.opentelemetry.sdk.trace.data.StatusData;
|
||||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
|
||||
import java.net.InetAddress;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -127,9 +126,9 @@ class JaegerGrpcSpanExporterTest {
|
|||
testSpanData(
|
||||
Resource.create(
|
||||
Attributes.of(
|
||||
ResourceAttributes.SERVICE_NAME,
|
||||
stringKey("service.name"),
|
||||
"myServiceName",
|
||||
AttributeKey.stringKey("resource-attr-key"),
|
||||
stringKey("resource-attr-key"),
|
||||
"resource-attr-value")),
|
||||
"GET /api/endpoint");
|
||||
|
||||
|
@ -161,9 +160,9 @@ class JaegerGrpcSpanExporterTest {
|
|||
testSpanData(
|
||||
Resource.create(
|
||||
Attributes.of(
|
||||
ResourceAttributes.SERVICE_NAME,
|
||||
stringKey("service.name"),
|
||||
"myServiceName1",
|
||||
AttributeKey.stringKey("resource-attr-key-1"),
|
||||
stringKey("resource-attr-key-1"),
|
||||
"resource-attr-value-1")),
|
||||
"GET /api/endpoint/1");
|
||||
|
||||
|
@ -171,9 +170,9 @@ class JaegerGrpcSpanExporterTest {
|
|||
testSpanData(
|
||||
Resource.create(
|
||||
Attributes.of(
|
||||
ResourceAttributes.SERVICE_NAME,
|
||||
stringKey("service.name"),
|
||||
"myServiceName2",
|
||||
AttributeKey.stringKey("resource-attr-key-2"),
|
||||
stringKey("resource-attr-key-2"),
|
||||
"resource-attr-value-2")),
|
||||
"GET /api/endpoint/2");
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
package io.opentelemetry.exporter.jaeger;
|
||||
|
||||
import static io.opentelemetry.api.common.AttributeKey.stringKey;
|
||||
|
||||
import com.fasterxml.jackson.core.TreeNode;
|
||||
import com.fasterxml.jackson.jr.ob.JSON;
|
||||
import com.fasterxml.jackson.jr.stree.JacksonJrsTreeCodec;
|
||||
|
@ -15,7 +17,6 @@ import io.opentelemetry.sdk.resources.Resource;
|
|||
import io.opentelemetry.sdk.trace.SdkTracerProvider;
|
||||
import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor;
|
||||
import io.opentelemetry.sdk.trace.export.SpanExporter;
|
||||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
|
||||
import java.time.Duration;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
|
@ -67,7 +68,7 @@ class JaegerIntegrationTest {
|
|||
.addSpanProcessor(SimpleSpanProcessor.create(jaegerExporter))
|
||||
.setResource(
|
||||
Resource.getDefault().toBuilder()
|
||||
.put(ResourceAttributes.SERVICE_NAME, SERVICE_NAME)
|
||||
.put(stringKey("service.name"), SERVICE_NAME)
|
||||
.build())
|
||||
.build())
|
||||
.build();
|
||||
|
|
|
@ -18,8 +18,6 @@ dependencies {
|
|||
|
||||
annotationProcessor("com.google.auto.value:auto-value")
|
||||
|
||||
testImplementation(project(":semconv"))
|
||||
|
||||
testImplementation("io.opentelemetry.proto:opentelemetry-proto")
|
||||
|
||||
testImplementation("com.google.guava:guava")
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
package io.opentelemetry.exporter.prometheus;
|
||||
|
||||
import static io.opentelemetry.api.common.AttributeKey.stringKey;
|
||||
import static java.util.concurrent.CompletableFuture.completedFuture;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.awaitility.Awaitility.await;
|
||||
|
@ -29,7 +30,6 @@ import io.opentelemetry.proto.metrics.v1.ScopeMetrics;
|
|||
import io.opentelemetry.proto.metrics.v1.Sum;
|
||||
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
|
||||
import io.opentelemetry.sdk.resources.Resource;
|
||||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
|
@ -139,20 +139,19 @@ class CollectorIntegrationTest {
|
|||
// Resource attributes from the metric SDK resource translated to target_info
|
||||
stringKeyValue(
|
||||
"service_name",
|
||||
Objects.requireNonNull(
|
||||
resource.getAttributes().get(ResourceAttributes.SERVICE_NAME))),
|
||||
Objects.requireNonNull(resource.getAttributes().get(stringKey("service.name")))),
|
||||
stringKeyValue(
|
||||
"telemetry_sdk_name",
|
||||
Objects.requireNonNull(
|
||||
resource.getAttributes().get(ResourceAttributes.TELEMETRY_SDK_NAME))),
|
||||
resource.getAttributes().get(stringKey("telemetry.sdk.name")))),
|
||||
stringKeyValue(
|
||||
"telemetry_sdk_language",
|
||||
Objects.requireNonNull(
|
||||
resource.getAttributes().get(ResourceAttributes.TELEMETRY_SDK_LANGUAGE))),
|
||||
resource.getAttributes().get(stringKey("telemetry.sdk.language")))),
|
||||
stringKeyValue(
|
||||
"telemetry_sdk_version",
|
||||
Objects.requireNonNull(
|
||||
resource.getAttributes().get(ResourceAttributes.TELEMETRY_SDK_VERSION))));
|
||||
resource.getAttributes().get(stringKey("telemetry.sdk.version")))));
|
||||
|
||||
assertThat(resourceMetrics.getScopeMetricsCount()).isEqualTo(2);
|
||||
ScopeMetrics testScopeMetrics =
|
||||
|
|
|
@ -14,7 +14,6 @@ dependencies {
|
|||
api("io.zipkin.reporter2:zipkin-reporter")
|
||||
|
||||
implementation(project(":exporters:common"))
|
||||
implementation(project(":semconv"))
|
||||
implementation(project(":sdk-extensions:autoconfigure-spi"))
|
||||
|
||||
implementation("io.zipkin.reporter2:zipkin-sender-okhttp3")
|
||||
|
|
|
@ -5,10 +5,8 @@
|
|||
|
||||
package io.opentelemetry.exporter.zipkin;
|
||||
|
||||
import static io.opentelemetry.api.common.AttributeKey.longKey;
|
||||
import static io.opentelemetry.api.common.AttributeKey.stringKey;
|
||||
import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NET_PEER_PORT;
|
||||
import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NET_SOCK_PEER_ADDR;
|
||||
import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.PEER_SERVICE;
|
||||
import static java.util.concurrent.TimeUnit.NANOSECONDS;
|
||||
|
||||
import io.opentelemetry.api.common.AttributeKey;
|
||||
|
@ -21,7 +19,6 @@ import io.opentelemetry.sdk.resources.Resource;
|
|||
import io.opentelemetry.sdk.trace.data.EventData;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData;
|
||||
import io.opentelemetry.sdk.trace.data.StatusData;
|
||||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
|
||||
import java.net.InetAddress;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
@ -36,6 +33,12 @@ import zipkin2.Span;
|
|||
*/
|
||||
final class OtelToZipkinSpanTransformer {
|
||||
|
||||
private static final AttributeKey<String> SERVICE_NAME = AttributeKey.stringKey("service.name");
|
||||
private static final AttributeKey<String> PEER_SERVICE = stringKey("peer.service");
|
||||
private static final AttributeKey<String> SERVER_SOCKET_ADDRESS =
|
||||
stringKey("server.socket.address");
|
||||
private static final AttributeKey<Long> SERVER_SOCKET_PORT = longKey("server.socket.port");
|
||||
|
||||
static final String KEY_INSTRUMENTATION_SCOPE_NAME = "otel.scope.name";
|
||||
static final String KEY_INSTRUMENTATION_SCOPE_VERSION = "otel.scope.version";
|
||||
static final String KEY_INSTRUMENTATION_LIBRARY_NAME = "otel.library.name";
|
||||
|
@ -151,9 +154,9 @@ final class OtelToZipkinSpanTransformer {
|
|||
endpoint.ip(ipAddressSupplier.get());
|
||||
|
||||
// use the service.name from the Resource, if it's been set.
|
||||
String serviceNameValue = resourceAttributes.get(ResourceAttributes.SERVICE_NAME);
|
||||
String serviceNameValue = resourceAttributes.get(SERVICE_NAME);
|
||||
if (serviceNameValue == null) {
|
||||
serviceNameValue = Resource.getDefault().getAttribute(ResourceAttributes.SERVICE_NAME);
|
||||
serviceNameValue = Resource.getDefault().getAttribute(SERVICE_NAME);
|
||||
}
|
||||
// In practice should never be null unless the default Resource spec is changed.
|
||||
if (serviceNameValue != null) {
|
||||
|
@ -173,8 +176,8 @@ final class OtelToZipkinSpanTransformer {
|
|||
if (serviceName != null) {
|
||||
Endpoint.Builder endpoint = Endpoint.newBuilder();
|
||||
endpoint.serviceName(serviceName);
|
||||
endpoint.ip(attributes.get(NET_SOCK_PEER_ADDR));
|
||||
Long port = attributes.get(NET_PEER_PORT);
|
||||
endpoint.ip(attributes.get(SERVER_SOCKET_ADDRESS));
|
||||
Long port = attributes.get(SERVER_SOCKET_PORT);
|
||||
if (port != null) {
|
||||
endpoint.port(port.intValue());
|
||||
}
|
||||
|
|
|
@ -16,9 +16,6 @@ import static io.opentelemetry.api.common.AttributeKey.stringKey;
|
|||
import static io.opentelemetry.exporter.zipkin.ZipkinTestUtil.spanBuilder;
|
||||
import static io.opentelemetry.exporter.zipkin.ZipkinTestUtil.zipkinSpan;
|
||||
import static io.opentelemetry.exporter.zipkin.ZipkinTestUtil.zipkinSpanBuilder;
|
||||
import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NET_PEER_PORT;
|
||||
import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NET_SOCK_PEER_ADDR;
|
||||
import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.PEER_SERVICE;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
|
@ -29,8 +26,6 @@ import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
|
|||
import io.opentelemetry.sdk.resources.Resource;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData;
|
||||
import io.opentelemetry.sdk.trace.data.StatusData;
|
||||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
|
||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
||||
import java.net.InetAddress;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
@ -138,7 +133,7 @@ class OtelToZipkinSpanTransformerTest {
|
|||
@Test
|
||||
void generateSpan_ResourceServiceNameMapping() {
|
||||
Resource resource =
|
||||
Resource.create(Attributes.of(ResourceAttributes.SERVICE_NAME, "super-zipkin-service"));
|
||||
Resource.create(Attributes.of(stringKey("service.name"), "super-zipkin-service"));
|
||||
SpanData data = spanBuilder().setResource(resource).build();
|
||||
|
||||
Endpoint expectedLocalEndpoint =
|
||||
|
@ -157,7 +152,7 @@ class OtelToZipkinSpanTransformerTest {
|
|||
|
||||
Endpoint expectedLocalEndpoint =
|
||||
Endpoint.newBuilder()
|
||||
.serviceName(Resource.getDefault().getAttribute(ResourceAttributes.SERVICE_NAME))
|
||||
.serviceName(Resource.getDefault().getAttribute(stringKey("service.name")))
|
||||
.ip(localIp)
|
||||
.build();
|
||||
Span expectedZipkinSpan =
|
||||
|
@ -175,9 +170,9 @@ class OtelToZipkinSpanTransformerTest {
|
|||
void generateSpan_RemoteEndpointMapping(SpanKind spanKind) {
|
||||
Attributes attributes =
|
||||
Attributes.builder()
|
||||
.put(PEER_SERVICE, "remote-test-service")
|
||||
.put(NET_SOCK_PEER_ADDR, "8.8.8.8")
|
||||
.put(NET_PEER_PORT, 42L)
|
||||
.put(stringKey("peer.service"), "remote-test-service")
|
||||
.put(stringKey("server.socket.address"), "8.8.8.8")
|
||||
.put(longKey("server.socket.port"), 42L)
|
||||
.build();
|
||||
|
||||
SpanData spanData =
|
||||
|
@ -189,7 +184,7 @@ class OtelToZipkinSpanTransformerTest {
|
|||
|
||||
Endpoint expectedLocalEndpoint =
|
||||
Endpoint.newBuilder()
|
||||
.serviceName(Resource.getDefault().getAttribute(ResourceAttributes.SERVICE_NAME))
|
||||
.serviceName(Resource.getDefault().getAttribute(stringKey("service.name")))
|
||||
.ip(localIp)
|
||||
.build();
|
||||
|
||||
|
@ -200,9 +195,9 @@ class OtelToZipkinSpanTransformerTest {
|
|||
zipkinSpan(toZipkinSpanKind(spanKind), localIp).toBuilder()
|
||||
.localEndpoint(expectedLocalEndpoint)
|
||||
.remoteEndpoint(expectedRemoteEndpoint)
|
||||
.putTag(PEER_SERVICE.getKey(), "remote-test-service")
|
||||
.putTag(NET_SOCK_PEER_ADDR.getKey(), "8.8.8.8")
|
||||
.putTag(NET_PEER_PORT.getKey(), "42")
|
||||
.putTag("peer.service", "remote-test-service")
|
||||
.putTag("server.socket.address", "8.8.8.8")
|
||||
.putTag("server.socket.port", "42")
|
||||
.putTag(OtelToZipkinSpanTransformer.OTEL_STATUS_CODE, "OK")
|
||||
.build();
|
||||
|
||||
|
@ -216,9 +211,9 @@ class OtelToZipkinSpanTransformerTest {
|
|||
void generateSpan_RemoteEndpointMappingWhenKindIsNotClientOrProducer(SpanKind spanKind) {
|
||||
Attributes attributes =
|
||||
Attributes.builder()
|
||||
.put(PEER_SERVICE, "remote-test-service")
|
||||
.put(NET_SOCK_PEER_ADDR, "8.8.8.8")
|
||||
.put(NET_PEER_PORT, 42L)
|
||||
.put("peer.service", "remote-test-service")
|
||||
.put("server.socket.address", "8.8.8.8")
|
||||
.put("server.socket.port", 42L)
|
||||
.build();
|
||||
|
||||
SpanData spanData =
|
||||
|
@ -230,7 +225,7 @@ class OtelToZipkinSpanTransformerTest {
|
|||
|
||||
Endpoint expectedLocalEndpoint =
|
||||
Endpoint.newBuilder()
|
||||
.serviceName(Resource.getDefault().getAttribute(ResourceAttributes.SERVICE_NAME))
|
||||
.serviceName(Resource.getDefault().getAttribute(stringKey("service.name")))
|
||||
.ip(localIp)
|
||||
.build();
|
||||
|
||||
|
@ -238,9 +233,9 @@ class OtelToZipkinSpanTransformerTest {
|
|||
zipkinSpan(toZipkinSpanKind(spanKind), localIp).toBuilder()
|
||||
.localEndpoint(expectedLocalEndpoint)
|
||||
.remoteEndpoint(null)
|
||||
.putTag(PEER_SERVICE.getKey(), "remote-test-service")
|
||||
.putTag(NET_SOCK_PEER_ADDR.getKey(), "8.8.8.8")
|
||||
.putTag(NET_PEER_PORT.getKey(), "42")
|
||||
.putTag("peer.service", "remote-test-service")
|
||||
.putTag("server.socket.address", "8.8.8.8")
|
||||
.putTag("server.socket.port", "42")
|
||||
.putTag(OtelToZipkinSpanTransformer.OTEL_STATUS_CODE, "OK")
|
||||
.build();
|
||||
|
||||
|
@ -253,7 +248,10 @@ class OtelToZipkinSpanTransformerTest {
|
|||
names = {"CLIENT", "PRODUCER"})
|
||||
void generateSpan_RemoteEndpointMappingWhenServiceNameIsMissing(SpanKind spanKind) {
|
||||
Attributes attributes =
|
||||
Attributes.builder().put(NET_SOCK_PEER_ADDR, "8.8.8.8").put(NET_PEER_PORT, 42L).build();
|
||||
Attributes.builder()
|
||||
.put("server.socket.address", "8.8.8.8")
|
||||
.put("server.socket.port", 42L)
|
||||
.build();
|
||||
|
||||
SpanData spanData =
|
||||
spanBuilder()
|
||||
|
@ -264,7 +262,7 @@ class OtelToZipkinSpanTransformerTest {
|
|||
|
||||
Endpoint expectedLocalEndpoint =
|
||||
Endpoint.newBuilder()
|
||||
.serviceName(Resource.getDefault().getAttribute(ResourceAttributes.SERVICE_NAME))
|
||||
.serviceName(Resource.getDefault().getAttribute(stringKey("service.name")))
|
||||
.ip(localIp)
|
||||
.build();
|
||||
|
||||
|
@ -272,8 +270,8 @@ class OtelToZipkinSpanTransformerTest {
|
|||
zipkinSpan(toZipkinSpanKind(spanKind), localIp).toBuilder()
|
||||
.localEndpoint(expectedLocalEndpoint)
|
||||
.remoteEndpoint(null)
|
||||
.putTag(NET_SOCK_PEER_ADDR.getKey(), "8.8.8.8")
|
||||
.putTag(NET_PEER_PORT.getKey(), "42")
|
||||
.putTag("server.socket.address", "8.8.8.8")
|
||||
.putTag("server.socket.port", "42")
|
||||
.putTag(OtelToZipkinSpanTransformer.OTEL_STATUS_CODE, "OK")
|
||||
.build();
|
||||
|
||||
|
@ -287,8 +285,8 @@ class OtelToZipkinSpanTransformerTest {
|
|||
void generateSpan_RemoteEndpointMappingWhenPortIsMissing(SpanKind spanKind) {
|
||||
Attributes attributes =
|
||||
Attributes.builder()
|
||||
.put(PEER_SERVICE, "remote-test-service")
|
||||
.put(NET_SOCK_PEER_ADDR, "8.8.8.8")
|
||||
.put("peer.service", "remote-test-service")
|
||||
.put("server.socket.address", "8.8.8.8")
|
||||
.build();
|
||||
|
||||
SpanData spanData =
|
||||
|
@ -300,7 +298,7 @@ class OtelToZipkinSpanTransformerTest {
|
|||
|
||||
Endpoint expectedLocalEndpoint =
|
||||
Endpoint.newBuilder()
|
||||
.serviceName(Resource.getDefault().getAttribute(ResourceAttributes.SERVICE_NAME))
|
||||
.serviceName(Resource.getDefault().getAttribute(stringKey("service.name")))
|
||||
.ip(localIp)
|
||||
.build();
|
||||
|
||||
|
@ -311,8 +309,8 @@ class OtelToZipkinSpanTransformerTest {
|
|||
zipkinSpan(toZipkinSpanKind(spanKind), localIp).toBuilder()
|
||||
.localEndpoint(expectedLocalEndpoint)
|
||||
.remoteEndpoint(expectedRemoteEndpoint)
|
||||
.putTag(PEER_SERVICE.getKey(), "remote-test-service")
|
||||
.putTag(NET_SOCK_PEER_ADDR.getKey(), "8.8.8.8")
|
||||
.putTag("peer.service", "remote-test-service")
|
||||
.putTag("server.socket.address", "8.8.8.8")
|
||||
.putTag(OtelToZipkinSpanTransformer.OTEL_STATUS_CODE, "OK")
|
||||
.build();
|
||||
|
||||
|
@ -324,7 +322,7 @@ class OtelToZipkinSpanTransformerTest {
|
|||
value = SpanKind.class,
|
||||
names = {"CLIENT", "PRODUCER"})
|
||||
void generateSpan_RemoteEndpointMappingWhenIpAndPortAreMissing(SpanKind spanKind) {
|
||||
Attributes attributes = Attributes.builder().put(PEER_SERVICE, "remote-test-service").build();
|
||||
Attributes attributes = Attributes.builder().put("peer.service", "remote-test-service").build();
|
||||
|
||||
SpanData spanData =
|
||||
spanBuilder()
|
||||
|
@ -335,7 +333,7 @@ class OtelToZipkinSpanTransformerTest {
|
|||
|
||||
Endpoint expectedLocalEndpoint =
|
||||
Endpoint.newBuilder()
|
||||
.serviceName(Resource.getDefault().getAttribute(ResourceAttributes.SERVICE_NAME))
|
||||
.serviceName(Resource.getDefault().getAttribute(stringKey("service.name")))
|
||||
.ip(localIp)
|
||||
.build();
|
||||
|
||||
|
@ -346,7 +344,7 @@ class OtelToZipkinSpanTransformerTest {
|
|||
zipkinSpan(toZipkinSpanKind(spanKind), localIp).toBuilder()
|
||||
.localEndpoint(expectedLocalEndpoint)
|
||||
.remoteEndpoint(expectedRemoteEndpoint)
|
||||
.putTag(PEER_SERVICE.getKey(), "remote-test-service")
|
||||
.putTag("peer.service", "remote-test-service")
|
||||
.putTag(OtelToZipkinSpanTransformer.OTEL_STATUS_CODE, "OK")
|
||||
.build();
|
||||
|
||||
|
@ -417,7 +415,10 @@ class OtelToZipkinSpanTransformerTest {
|
|||
void generateSpan_AlreadyHasHttpStatusInfo() {
|
||||
Attributes attributes =
|
||||
Attributes.of(
|
||||
SemanticAttributes.HTTP_STATUS_CODE, 404L, stringKey("error"), "A user provided error");
|
||||
longKey("http.response.status.code"),
|
||||
404L,
|
||||
stringKey("error"),
|
||||
"A user provided error");
|
||||
SpanData data =
|
||||
spanBuilder()
|
||||
.setAttributes(attributes)
|
||||
|
@ -430,7 +431,7 @@ class OtelToZipkinSpanTransformerTest {
|
|||
.isEqualTo(
|
||||
zipkinSpan(Span.Kind.CLIENT, localIp).toBuilder()
|
||||
.clearTags()
|
||||
.putTag(SemanticAttributes.HTTP_STATUS_CODE.getKey(), "404")
|
||||
.putTag("http.response.status.code", "404")
|
||||
.putTag(OtelToZipkinSpanTransformer.OTEL_STATUS_CODE, "ERROR")
|
||||
.putTag("error", "A user provided error")
|
||||
.build());
|
||||
|
@ -438,7 +439,7 @@ class OtelToZipkinSpanTransformerTest {
|
|||
|
||||
@Test
|
||||
void generateSpan_WithRpcTimeoutErrorStatus_WithTimeoutErrorDescription() {
|
||||
Attributes attributes = Attributes.of(SemanticAttributes.RPC_SERVICE, "my service name");
|
||||
Attributes attributes = Attributes.of(stringKey("rpc.service"), "my service name");
|
||||
|
||||
String errorMessage = "timeout";
|
||||
|
||||
|
@ -452,7 +453,7 @@ class OtelToZipkinSpanTransformerTest {
|
|||
assertThat(transformer.generateSpan(data))
|
||||
.isEqualTo(
|
||||
zipkinSpan(Span.Kind.SERVER, localIp).toBuilder()
|
||||
.putTag(SemanticAttributes.RPC_SERVICE.getKey(), "my service name")
|
||||
.putTag("rpc.service", "my service name")
|
||||
.putTag(OtelToZipkinSpanTransformer.OTEL_STATUS_CODE, "ERROR")
|
||||
.putTag(OtelToZipkinSpanTransformer.STATUS_ERROR.getKey(), errorMessage)
|
||||
.build());
|
||||
|
@ -460,7 +461,7 @@ class OtelToZipkinSpanTransformerTest {
|
|||
|
||||
@Test
|
||||
void generateSpan_WithRpcErrorStatus_WithEmptyErrorDescription() {
|
||||
Attributes attributes = Attributes.of(SemanticAttributes.RPC_SERVICE, "my service name");
|
||||
Attributes attributes = Attributes.of(stringKey("rpc.service"), "my service name");
|
||||
|
||||
SpanData data =
|
||||
spanBuilder()
|
||||
|
@ -472,7 +473,7 @@ class OtelToZipkinSpanTransformerTest {
|
|||
assertThat(transformer.generateSpan(data))
|
||||
.isEqualTo(
|
||||
zipkinSpan(Span.Kind.SERVER, localIp).toBuilder()
|
||||
.putTag(SemanticAttributes.RPC_SERVICE.getKey(), "my service name")
|
||||
.putTag("rpc.service", "my service name")
|
||||
.putTag(OtelToZipkinSpanTransformer.OTEL_STATUS_CODE, "ERROR")
|
||||
.putTag(OtelToZipkinSpanTransformer.STATUS_ERROR.getKey(), "")
|
||||
.build());
|
||||
|
@ -480,7 +481,7 @@ class OtelToZipkinSpanTransformerTest {
|
|||
|
||||
@Test
|
||||
void generateSpan_WithRpcUnsetStatus() {
|
||||
Attributes attributes = Attributes.of(SemanticAttributes.RPC_SERVICE, "my service name");
|
||||
Attributes attributes = Attributes.of(stringKey("rpc.service"), "my service name");
|
||||
|
||||
SpanData data =
|
||||
spanBuilder()
|
||||
|
@ -492,7 +493,7 @@ class OtelToZipkinSpanTransformerTest {
|
|||
assertThat(transformer.generateSpan(data))
|
||||
.isEqualTo(
|
||||
zipkinSpan(Span.Kind.SERVER, localIp).toBuilder()
|
||||
.putTag(SemanticAttributes.RPC_SERVICE.getKey(), "my service name")
|
||||
.putTag("rpc.service", "my service name")
|
||||
.build());
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
package io.opentelemetry.exporter.zipkin;
|
||||
|
||||
import static io.opentelemetry.api.common.AttributeKey.stringKey;
|
||||
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
|
@ -30,7 +31,6 @@ import io.opentelemetry.sdk.trace.IdGenerator;
|
|||
import io.opentelemetry.sdk.trace.data.EventData;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData;
|
||||
import io.opentelemetry.sdk.trace.data.StatusData;
|
||||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
|
||||
import java.net.InetAddress;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
@ -219,7 +219,7 @@ class ZipkinSpanExporterEndToEndHttpTest {
|
|||
.setLinks(Collections.emptyList())
|
||||
.setEndEpochNanos(END_EPOCH_NANOS)
|
||||
.setHasEnded(true)
|
||||
.setResource(Resource.create(Attributes.of(ResourceAttributes.SERVICE_NAME, SERVICE_NAME)));
|
||||
.setResource(Resource.create(Attributes.of(stringKey("service.name"), SERVICE_NAME)));
|
||||
}
|
||||
|
||||
private static Span buildZipkinSpan(InetAddress localAddress, String traceId) {
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
package io.opentelemetry.exporter.zipkin;
|
||||
|
||||
import static io.opentelemetry.api.common.AttributeKey.stringKey;
|
||||
|
||||
import io.opentelemetry.api.common.Attributes;
|
||||
import io.opentelemetry.api.trace.SpanContext;
|
||||
import io.opentelemetry.api.trace.SpanKind;
|
||||
|
@ -14,7 +16,6 @@ import io.opentelemetry.sdk.resources.Resource;
|
|||
import io.opentelemetry.sdk.testing.trace.TestSpanData;
|
||||
import io.opentelemetry.sdk.trace.data.EventData;
|
||||
import io.opentelemetry.sdk.trace.data.StatusData;
|
||||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
|
||||
import java.net.InetAddress;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
@ -47,7 +48,7 @@ class ZipkinTestUtil {
|
|||
TRACE_ID, PARENT_SPAN_ID, TraceFlags.getDefault(), TraceState.getDefault()))
|
||||
.setResource(
|
||||
Resource.create(
|
||||
Attributes.builder().put(ResourceAttributes.SERVICE_NAME, "tweetiebird").build()))
|
||||
Attributes.builder().put(stringKey("service.name"), "tweetiebird").build()))
|
||||
.setStatus(StatusData.ok())
|
||||
.setKind(SpanKind.SERVER)
|
||||
.setName("Recv.helloworld.Greeter.SayHello")
|
||||
|
|
|
@ -10,7 +10,6 @@ dependencies {
|
|||
|
||||
implementation(project(":exporters:otlp:all"))
|
||||
implementation(project(":api:events"))
|
||||
implementation(project(":semconv"))
|
||||
|
||||
compileOnly("com.google.errorprone:error_prone_annotations")
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import com.linecorp.armeria.server.grpc.protocol.AbstractUnaryGrpcService;
|
|||
import com.linecorp.armeria.testing.junit5.server.SelfSignedCertificateExtension;
|
||||
import com.linecorp.armeria.testing.junit5.server.ServerExtension;
|
||||
import io.opentelemetry.api.GlobalOpenTelemetry;
|
||||
import io.opentelemetry.api.common.AttributeKey;
|
||||
import io.opentelemetry.api.common.Attributes;
|
||||
import io.opentelemetry.api.events.EventEmitter;
|
||||
import io.opentelemetry.api.logs.Logger;
|
||||
|
@ -71,7 +72,6 @@ import io.opentelemetry.sdk.trace.IdGenerator;
|
|||
import io.opentelemetry.sdk.trace.SdkTracerProvider;
|
||||
import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor;
|
||||
import io.opentelemetry.sdk.trace.export.SpanExporter;
|
||||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
|
@ -106,6 +106,8 @@ import org.testcontainers.utility.MountableFile;
|
|||
@Testcontainers(disabledWithoutDocker = true)
|
||||
abstract class OtlpExporterIntegrationTest {
|
||||
|
||||
private static final AttributeKey<String> SERVICE_NAME = AttributeKey.stringKey("service.name");
|
||||
|
||||
private static final String COLLECTOR_IMAGE =
|
||||
"ghcr.io/open-telemetry/opentelemetry-java/otel-collector";
|
||||
private static final Integer COLLECTOR_OTLP_GRPC_PORT = 4317;
|
||||
|
@ -114,9 +116,7 @@ abstract class OtlpExporterIntegrationTest {
|
|||
private static final Integer COLLECTOR_OTLP_HTTP_MTLS_PORT = 5318;
|
||||
private static final Integer COLLECTOR_HEALTH_CHECK_PORT = 13133;
|
||||
private static final Resource RESOURCE =
|
||||
Resource.getDefault().toBuilder()
|
||||
.put(ResourceAttributes.SERVICE_NAME, "integration test")
|
||||
.build();
|
||||
Resource.getDefault().toBuilder().put(SERVICE_NAME, "integration test").build();
|
||||
|
||||
@RegisterExtension
|
||||
static final SelfSignedCertificateExtension serverTls = new SelfSignedCertificateExtension();
|
||||
|
@ -285,7 +285,7 @@ abstract class OtlpExporterIntegrationTest {
|
|||
assertThat(resourceSpans.getResource().getAttributesList())
|
||||
.contains(
|
||||
KeyValue.newBuilder()
|
||||
.setKey(ResourceAttributes.SERVICE_NAME.getKey())
|
||||
.setKey(SERVICE_NAME.getKey())
|
||||
.setValue(AnyValue.newBuilder().setStringValue("integration test").build())
|
||||
.build());
|
||||
assertThat(resourceSpans.getScopeSpansCount()).isEqualTo(1);
|
||||
|
@ -414,7 +414,7 @@ abstract class OtlpExporterIntegrationTest {
|
|||
assertThat(resourceMetrics.getResource().getAttributesList())
|
||||
.contains(
|
||||
KeyValue.newBuilder()
|
||||
.setKey(ResourceAttributes.SERVICE_NAME.getKey())
|
||||
.setKey(SERVICE_NAME.getKey())
|
||||
.setValue(AnyValue.newBuilder().setStringValue("integration test").build())
|
||||
.build());
|
||||
assertThat(resourceMetrics.getScopeMetricsCount()).isEqualTo(1);
|
||||
|
@ -562,7 +562,7 @@ abstract class OtlpExporterIntegrationTest {
|
|||
assertThat(resourceLogs.getResource().getAttributesList())
|
||||
.contains(
|
||||
KeyValue.newBuilder()
|
||||
.setKey(ResourceAttributes.SERVICE_NAME.getKey())
|
||||
.setKey(SERVICE_NAME.getKey())
|
||||
.setValue(AnyValue.newBuilder().setStringValue("integration test").build())
|
||||
.build());
|
||||
assertThat(resourceLogs.getScopeLogsCount()).isEqualTo(1);
|
||||
|
|
|
@ -13,7 +13,6 @@ dependencies {
|
|||
api(project(":api:all"))
|
||||
|
||||
api("io.opentracing:opentracing-api")
|
||||
implementation(project(":semconv"))
|
||||
implementation("io.opentracing:opentracing-noop:0.33.0")
|
||||
|
||||
annotationProcessor("com.google.auto.value:auto-value")
|
||||
|
|
|
@ -18,7 +18,6 @@ import io.opentelemetry.api.common.Attributes;
|
|||
import io.opentelemetry.api.trace.StatusCode;
|
||||
import io.opentelemetry.api.trace.Tracer;
|
||||
import io.opentelemetry.context.Context;
|
||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
||||
import io.opentracing.References;
|
||||
import io.opentracing.Span;
|
||||
import io.opentracing.SpanContext;
|
||||
|
@ -34,14 +33,15 @@ import javax.annotation.concurrent.Immutable;
|
|||
|
||||
final class SpanBuilderShim implements SpanBuilder {
|
||||
|
||||
private static final AttributeKey<String> OPENTRACING_REF_TYPE =
|
||||
stringKey("opentracing.ref_type");
|
||||
private static final String OPEN_TRACING_REF_TYPE_CHILD_OF = "child_of";
|
||||
private static final String OPEN_TRACING_REF_TYPE_FOLLOWS_FROM = "follows_from";
|
||||
|
||||
private static final Attributes CHILD_OF_ATTR =
|
||||
Attributes.of(
|
||||
SemanticAttributes.OPENTRACING_REF_TYPE,
|
||||
SemanticAttributes.OpentracingRefTypeValues.CHILD_OF);
|
||||
Attributes.of(OPENTRACING_REF_TYPE, OPEN_TRACING_REF_TYPE_CHILD_OF);
|
||||
private static final Attributes FOLLOWS_FROM_ATTR =
|
||||
Attributes.of(
|
||||
SemanticAttributes.OPENTRACING_REF_TYPE,
|
||||
SemanticAttributes.OpentracingRefTypeValues.FOLLOWS_FROM);
|
||||
Attributes.of(OPENTRACING_REF_TYPE, OPEN_TRACING_REF_TYPE_FOLLOWS_FROM);
|
||||
|
||||
private final Tracer tracer;
|
||||
private final String spanName;
|
||||
|
|
|
@ -18,7 +18,6 @@ import io.opentelemetry.api.trace.StatusCode;
|
|||
import io.opentelemetry.context.Context;
|
||||
import io.opentelemetry.context.ContextKey;
|
||||
import io.opentelemetry.context.ImplicitContextKeyed;
|
||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
||||
import io.opentracing.Span;
|
||||
import io.opentracing.SpanContext;
|
||||
import io.opentracing.log.Fields;
|
||||
|
@ -34,6 +33,15 @@ import javax.annotation.Nullable;
|
|||
* link OTel's Span and OT Span/SpanContext.
|
||||
*/
|
||||
final class SpanShim implements Span, ImplicitContextKeyed {
|
||||
|
||||
private static final AttributeKey<String> EXCEPTION_TYPE =
|
||||
AttributeKey.stringKey("exception.type");
|
||||
private static final AttributeKey<String> EXCEPTION_MESSAGE =
|
||||
AttributeKey.stringKey("exception.message");
|
||||
private static final AttributeKey<String> EXCEPTION_STACKTRACE =
|
||||
AttributeKey.stringKey("exception.stacktrace");
|
||||
private static final String EXCEPTION_EVENT_NAME = "exception";
|
||||
|
||||
private static final String DEFAULT_EVENT_NAME = "log";
|
||||
private static final String ERROR = "error";
|
||||
private static final ContextKey<SpanShim> SPAN_SHIM_KEY =
|
||||
|
@ -203,7 +211,7 @@ final class SpanShim implements Span, ImplicitContextKeyed {
|
|||
throwable = findThrowable(fields);
|
||||
isError = true;
|
||||
if (throwable == null) {
|
||||
name = SemanticAttributes.EXCEPTION_EVENT_NAME;
|
||||
name = EXCEPTION_EVENT_NAME;
|
||||
}
|
||||
}
|
||||
Attributes attributes = convertToAttributes(fields, isError, throwable != null);
|
||||
|
@ -253,11 +261,11 @@ final class SpanShim implements Span, ImplicitContextKeyed {
|
|||
AttributeKey<String> attributeKey = null;
|
||||
if (isError && !isRecordingException) {
|
||||
if (key.equals(Fields.ERROR_KIND)) {
|
||||
attributeKey = SemanticAttributes.EXCEPTION_TYPE;
|
||||
attributeKey = EXCEPTION_TYPE;
|
||||
} else if (key.equals(Fields.MESSAGE)) {
|
||||
attributeKey = SemanticAttributes.EXCEPTION_MESSAGE;
|
||||
attributeKey = EXCEPTION_MESSAGE;
|
||||
} else if (key.equals(Fields.STACK)) {
|
||||
attributeKey = SemanticAttributes.EXCEPTION_STACKTRACE;
|
||||
attributeKey = EXCEPTION_STACKTRACE;
|
||||
}
|
||||
}
|
||||
if (isRecordingException && key.equals(Fields.ERROR_OBJECT)) {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
package io.opentelemetry.opentracingshim;
|
||||
|
||||
import static io.opentelemetry.api.common.AttributeKey.stringKey;
|
||||
import static io.opentelemetry.opentracingshim.TestUtils.getBaggageMap;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
@ -23,7 +24,6 @@ import io.opentelemetry.sdk.trace.data.SpanData;
|
|||
import io.opentelemetry.sdk.trace.data.StatusData;
|
||||
import io.opentelemetry.sdk.trace.samplers.Sampler;
|
||||
import io.opentelemetry.sdk.trace.samplers.SamplingResult;
|
||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
||||
import io.opentracing.References;
|
||||
import io.opentracing.noop.NoopSpan;
|
||||
import io.opentracing.tag.Tags;
|
||||
|
@ -169,12 +169,12 @@ class SpanBuilderShimTest {
|
|||
assertThat(links.get(0).getSpanContext()).isEqualTo(parentSpan1.getSpan().getSpanContext());
|
||||
assertThat(links.get(1).getSpanContext()).isEqualTo(parentSpan2.getSpan().getSpanContext());
|
||||
assertThat(links.get(2).getSpanContext()).isEqualTo(parentSpan3.getSpan().getSpanContext());
|
||||
assertThat(links.get(0).getAttributes().get(SemanticAttributes.OPENTRACING_REF_TYPE))
|
||||
.isEqualTo(SemanticAttributes.OpentracingRefTypeValues.FOLLOWS_FROM);
|
||||
assertThat(links.get(1).getAttributes().get(SemanticAttributes.OPENTRACING_REF_TYPE))
|
||||
.isEqualTo(SemanticAttributes.OpentracingRefTypeValues.CHILD_OF);
|
||||
assertThat(links.get(2).getAttributes().get(SemanticAttributes.OPENTRACING_REF_TYPE))
|
||||
.isEqualTo(SemanticAttributes.OpentracingRefTypeValues.FOLLOWS_FROM);
|
||||
assertThat(links.get(0).getAttributes().get(stringKey("opentracing.ref_type")))
|
||||
.isEqualTo("follows_from");
|
||||
assertThat(links.get(1).getAttributes().get(stringKey("opentracing.ref_type")))
|
||||
.isEqualTo("child_of");
|
||||
assertThat(links.get(2).getAttributes().get(stringKey("opentracing.ref_type")))
|
||||
.isEqualTo("follows_from");
|
||||
|
||||
} finally {
|
||||
childSpan.finish();
|
||||
|
@ -372,7 +372,7 @@ class SpanBuilderShimTest {
|
|||
try {
|
||||
SpanData spanData = ((ReadableSpan) span.getSpan()).toSpanData();
|
||||
assertThat(spanData.getAttributes().size()).isEqualTo(1);
|
||||
assertThat(spanData.getAttributes().get(AttributeKey.stringKey("foo"))).isEqualTo("10");
|
||||
assertThat(spanData.getAttributes().get(stringKey("foo"))).isEqualTo("10");
|
||||
} finally {
|
||||
span.finish();
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
package io.opentelemetry.opentracingshim;
|
||||
|
||||
import static io.opentelemetry.api.common.AttributeKey.stringKey;
|
||||
import static io.opentelemetry.opentracingshim.TestUtils.getBaggageMap;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
@ -16,7 +17,6 @@ import io.opentelemetry.sdk.trace.SdkTracerProvider;
|
|||
import io.opentelemetry.sdk.trace.data.EventData;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData;
|
||||
import io.opentelemetry.sdk.trace.data.StatusData;
|
||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
||||
import io.opentracing.log.Fields;
|
||||
import io.opentracing.tag.Tags;
|
||||
import java.math.BigInteger;
|
||||
|
@ -93,7 +93,7 @@ class SpanShimTest {
|
|||
|
||||
SpanData spanData = ((ReadableSpan) span).toSpanData();
|
||||
assertThat(spanData.getAttributes().size()).isEqualTo(1);
|
||||
assertThat(spanData.getAttributes().get(AttributeKey.stringKey("foo"))).isEqualTo("1");
|
||||
assertThat(spanData.getAttributes().get(stringKey("foo"))).isEqualTo("1");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -275,28 +275,15 @@ class SpanShimTest {
|
|||
|
||||
EventData eventData = spanData.getEvents().get(0);
|
||||
assertThat(eventData.getName()).isEqualTo("exception");
|
||||
assertThat(
|
||||
eventData
|
||||
.getAttributes()
|
||||
.get(AttributeKey.stringKey(SemanticAttributes.EXCEPTION_TYPE.getKey())))
|
||||
.isEqualTo("kind");
|
||||
assertThat(
|
||||
eventData
|
||||
.getAttributes()
|
||||
.get(AttributeKey.stringKey(SemanticAttributes.EXCEPTION_MESSAGE.getKey())))
|
||||
.isEqualTo("message");
|
||||
assertThat(
|
||||
eventData
|
||||
.getAttributes()
|
||||
.get(AttributeKey.stringKey(SemanticAttributes.EXCEPTION_STACKTRACE.getKey())))
|
||||
.isEqualTo("stack");
|
||||
assertThat(eventData.getAttributes().get(stringKey("exception.type"))).isEqualTo("kind");
|
||||
assertThat(eventData.getAttributes().get(stringKey("exception.message"))).isEqualTo("message");
|
||||
assertThat(eventData.getAttributes().get(stringKey("exception.stacktrace"))).isEqualTo("stack");
|
||||
|
||||
verifyAttributes(eventData);
|
||||
}
|
||||
|
||||
private static void verifyAttributes(EventData eventData) {
|
||||
assertThat(eventData.getAttributes().get(AttributeKey.stringKey("keyForString")))
|
||||
.isEqualTo("value");
|
||||
assertThat(eventData.getAttributes().get(stringKey("keyForString"))).isEqualTo("value");
|
||||
assertThat(eventData.getAttributes().get(AttributeKey.longKey("keyForInt"))).isEqualTo(1);
|
||||
assertThat(eventData.getAttributes().get(AttributeKey.doubleKey("keyForDouble")))
|
||||
.isEqualTo(1.0);
|
||||
|
|
|
@ -11,7 +11,6 @@ dependencies {
|
|||
implementation(project(":sdk:testing"))
|
||||
implementation(project(":exporters:otlp:all"))
|
||||
implementation(project(":exporters:logging"))
|
||||
implementation(project(":semconv"))
|
||||
|
||||
implementation("eu.rekawek.toxiproxy:toxiproxy-java")
|
||||
implementation("org.testcontainers:junit-jupiter")
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
package io.opentelemetry.perf;
|
||||
|
||||
import static io.opentelemetry.api.common.AttributeKey.stringKey;
|
||||
|
||||
import eu.rekawek.toxiproxy.Proxy;
|
||||
import eu.rekawek.toxiproxy.ToxiproxyClient;
|
||||
import eu.rekawek.toxiproxy.model.ToxicDirection;
|
||||
|
@ -25,7 +27,6 @@ import io.opentelemetry.sdk.resources.Resource;
|
|||
import io.opentelemetry.sdk.testing.exporter.InMemoryMetricExporter;
|
||||
import io.opentelemetry.sdk.trace.SdkTracerProvider;
|
||||
import io.opentelemetry.sdk.trace.export.BatchSpanProcessor;
|
||||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
@ -241,8 +242,8 @@ public class OtlpPipelineStressTest {
|
|||
Resource resource =
|
||||
Resource.create(
|
||||
Attributes.builder()
|
||||
.put(ResourceAttributes.SERVICE_NAME, "PerfTester")
|
||||
.put(ResourceAttributes.SERVICE_VERSION, "1.0.1-RC-1")
|
||||
.put(stringKey("service.name"), "PerfTester")
|
||||
.put(stringKey("service.version"), "1.0.1-RC-1")
|
||||
.build());
|
||||
|
||||
// set up the metric exporter and wire it into the SDK and a timed reader.
|
||||
|
|
|
@ -11,7 +11,6 @@ dependencies {
|
|||
api(project(":sdk-extensions:autoconfigure-spi"))
|
||||
|
||||
implementation(project(":api:events"))
|
||||
implementation(project(":semconv"))
|
||||
|
||||
annotationProcessor("com.google.auto.value:auto-value")
|
||||
|
||||
|
@ -36,10 +35,6 @@ testing {
|
|||
}
|
||||
}
|
||||
register<JvmTestSuite>("testConditionalResourceProvider") {
|
||||
dependencies {
|
||||
implementation(project(":semconv"))
|
||||
}
|
||||
|
||||
targets {
|
||||
all {
|
||||
testTask {
|
||||
|
@ -63,7 +58,6 @@ testing {
|
|||
implementation(project(":sdk:testing"))
|
||||
implementation(project(":sdk:trace-shaded-deps"))
|
||||
implementation(project(":sdk-extensions:jaeger-remote-sampler"))
|
||||
implementation(project(":semconv"))
|
||||
|
||||
implementation("com.google.guava:guava")
|
||||
implementation("io.opentelemetry.proto:opentelemetry-proto")
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
package io.opentelemetry.sdk.autoconfigure;
|
||||
|
||||
import io.opentelemetry.api.common.AttributeKey;
|
||||
import io.opentelemetry.api.common.Attributes;
|
||||
import io.opentelemetry.api.common.AttributesBuilder;
|
||||
import io.opentelemetry.sdk.autoconfigure.internal.SpiHelper;
|
||||
|
@ -15,7 +16,6 @@ import io.opentelemetry.sdk.autoconfigure.spi.internal.ConditionalResourceProvid
|
|||
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
|
||||
import io.opentelemetry.sdk.resources.Resource;
|
||||
import io.opentelemetry.sdk.resources.ResourceBuilder;
|
||||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
@ -32,6 +32,9 @@ import java.util.function.BiFunction;
|
|||
*/
|
||||
public final class ResourceConfiguration {
|
||||
|
||||
private static final AttributeKey<String> SERVICE_NAME = AttributeKey.stringKey("service.name");
|
||||
private static final String SCHEMA_URL = "https://opentelemetry.io/schemas/1.21.0";
|
||||
|
||||
// Visible for testing
|
||||
static final String ATTRIBUTE_PROPERTY = "otel.resource.attributes";
|
||||
static final String SERVICE_NAME_PROPERTY = "otel.service.name";
|
||||
|
@ -73,10 +76,10 @@ public final class ResourceConfiguration {
|
|||
}
|
||||
String serviceName = config.getString(SERVICE_NAME_PROPERTY);
|
||||
if (serviceName != null) {
|
||||
resourceAttributes.put(ResourceAttributes.SERVICE_NAME, serviceName);
|
||||
resourceAttributes.put(SERVICE_NAME, serviceName);
|
||||
}
|
||||
|
||||
return Resource.create(resourceAttributes.build(), ResourceAttributes.SCHEMA_URL);
|
||||
return Resource.create(resourceAttributes.build(), SCHEMA_URL);
|
||||
}
|
||||
|
||||
static Resource configureResource(
|
||||
|
|
|
@ -52,7 +52,6 @@ import io.opentelemetry.sdk.trace.data.SpanData;
|
|||
import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor;
|
||||
import io.opentelemetry.sdk.trace.export.SpanExporter;
|
||||
import io.opentelemetry.sdk.trace.samplers.Sampler;
|
||||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
|
@ -276,7 +275,7 @@ class AutoConfiguredOpenTelemetrySdkTest {
|
|||
.addPropertiesSupplier(() -> singletonMap("otel.service.name", "test-service"))
|
||||
.build();
|
||||
|
||||
assertThat(autoConfigured.getResource().getAttribute(ResourceAttributes.SERVICE_NAME))
|
||||
assertThat(autoConfigured.getResource().getAttribute(stringKey("service.name")))
|
||||
.isEqualTo("test-service");
|
||||
assertThat(autoConfigured.getConfig().getString("key")).isEqualTo("value");
|
||||
assertThat(autoConfigured.getConfig().getString("otel.key")).isEqualTo("otel-value");
|
||||
|
@ -301,7 +300,7 @@ class AutoConfiguredOpenTelemetrySdkTest {
|
|||
config -> singletonMap("some-key", config.getString("some-key", "") + "-2"))
|
||||
.build();
|
||||
|
||||
assertThat(autoConfigured.getResource().getAttribute(ResourceAttributes.SERVICE_NAME))
|
||||
assertThat(autoConfigured.getResource().getAttribute(stringKey("service.name")))
|
||||
.isEqualTo("overridden-service-name");
|
||||
assertThat(autoConfigured.getConfig().getString("some-key")).isEqualTo("override-2");
|
||||
assertThat(autoConfigured.getConfig().getString("some.key")).isEqualTo("override-2");
|
||||
|
|
|
@ -5,18 +5,17 @@
|
|||
|
||||
package io.opentelemetry.sdk.autoconfigure;
|
||||
|
||||
import static io.opentelemetry.api.common.AttributeKey.stringKey;
|
||||
import static io.opentelemetry.sdk.autoconfigure.ResourceConfiguration.DISABLED_ATTRIBUTE_KEYS;
|
||||
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
|
||||
import static java.util.Collections.singletonMap;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import io.opentelemetry.api.common.AttributeKey;
|
||||
import io.opentelemetry.api.common.Attributes;
|
||||
import io.opentelemetry.sdk.autoconfigure.internal.SpiHelper;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
|
||||
import io.opentelemetry.sdk.resources.Resource;
|
||||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -41,10 +40,10 @@ class ResourceConfigurationTest {
|
|||
(r, c) -> r))
|
||||
.isEqualTo(
|
||||
Resource.getDefault().toBuilder()
|
||||
.put(ResourceAttributes.SERVICE_NAME, "test-service")
|
||||
.put(stringKey("service.name"), "test-service")
|
||||
.put("food", "cheesecake")
|
||||
.put("shape", "square")
|
||||
.setSchemaUrl(ResourceAttributes.SCHEMA_URL)
|
||||
.setSchemaUrl("https://opentelemetry.io/schemas/1.21.0")
|
||||
.build());
|
||||
}
|
||||
|
||||
|
@ -67,7 +66,7 @@ class ResourceConfigurationTest {
|
|||
|
||||
assertThat(attributes)
|
||||
.hasSize(2)
|
||||
.containsEntry(ResourceAttributes.SERVICE_NAME, "myService")
|
||||
.containsEntry(stringKey("service.name"), "myService")
|
||||
.containsEntry("appName", "MyApp");
|
||||
}
|
||||
|
||||
|
@ -79,7 +78,7 @@ class ResourceConfigurationTest {
|
|||
singletonMap(ResourceConfiguration.SERVICE_NAME_PROPERTY, "myService")))
|
||||
.getAttributes();
|
||||
|
||||
assertThat(attributes).hasSize(1).containsEntry(ResourceAttributes.SERVICE_NAME, "myService");
|
||||
assertThat(attributes).hasSize(1).containsEntry(stringKey("service.name"), "myService");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -96,7 +95,7 @@ class ResourceConfigurationTest {
|
|||
|
||||
assertThat(attributes)
|
||||
.hasSize(2)
|
||||
.containsEntry(ResourceAttributes.SERVICE_NAME, "ReallyMyService")
|
||||
.containsEntry(stringKey("service.name"), "ReallyMyService")
|
||||
.containsEntry("appName", "MyApp");
|
||||
}
|
||||
|
||||
|
@ -126,8 +125,8 @@ class ResourceConfigurationTest {
|
|||
resource -> {
|
||||
assertThat(resource.getSchemaUrl()).isNull();
|
||||
assertThat(resource.getAttributes()).containsEntry("baz", "val");
|
||||
assertThat(resource.getAttributes().get(AttributeKey.stringKey("foo"))).isNull();
|
||||
assertThat(resource.getAttributes().get(AttributeKey.stringKey("bar"))).isNull();
|
||||
assertThat(resource.getAttributes().get(stringKey("foo"))).isNull();
|
||||
assertThat(resource.getAttributes().get(stringKey("bar"))).isNull();
|
||||
});
|
||||
|
||||
assertThat(ResourceConfiguration.filterAttributes(resourceWithSchema, configProperties))
|
||||
|
@ -135,8 +134,8 @@ class ResourceConfigurationTest {
|
|||
resource -> {
|
||||
assertThat(resource.getSchemaUrl()).isEqualTo("http://example.com");
|
||||
assertThat(resource.getAttributes()).containsEntry("baz", "val");
|
||||
assertThat(resource.getAttributes().get(AttributeKey.stringKey("foo"))).isNull();
|
||||
assertThat(resource.getAttributes().get(AttributeKey.stringKey("bar"))).isNull();
|
||||
assertThat(resource.getAttributes().get(stringKey("foo"))).isNull();
|
||||
assertThat(resource.getAttributes().get(stringKey("bar"))).isNull();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
|
||||
package io.opentelemetry.sdk.autoconfigure;
|
||||
|
||||
import static io.opentelemetry.api.common.AttributeKey.stringKey;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.entry;
|
||||
|
||||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class ConditionalResourceProviderTest {
|
||||
|
@ -19,7 +19,7 @@ class ConditionalResourceProviderTest {
|
|||
AutoConfiguredOpenTelemetrySdk sdk = AutoConfiguredOpenTelemetrySdk.builder().build();
|
||||
|
||||
assertThat(sdk.getResource().getAttributes().asMap())
|
||||
.contains(entry(ResourceAttributes.SERVICE_NAME, "test-service"));
|
||||
.contains(entry(stringKey("service.name"), "test-service"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -30,6 +30,6 @@ class ConditionalResourceProviderTest {
|
|||
.build();
|
||||
|
||||
assertThat(sdk.getResource().getAttributes().asMap())
|
||||
.contains(entry(ResourceAttributes.SERVICE_NAME, "test-service-2"));
|
||||
.contains(entry(stringKey("service.name"), "test-service-2"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,17 +5,18 @@
|
|||
|
||||
package io.opentelemetry.sdk.autoconfigure.provider;
|
||||
|
||||
import static io.opentelemetry.api.common.AttributeKey.stringKey;
|
||||
|
||||
import io.opentelemetry.api.common.Attributes;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.internal.ConditionalResourceProvider;
|
||||
import io.opentelemetry.sdk.resources.Resource;
|
||||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
|
||||
|
||||
public class FirstResourceProvider implements ConditionalResourceProvider {
|
||||
|
||||
@Override
|
||||
public Resource createResource(ConfigProperties config) {
|
||||
return Resource.create(Attributes.of(ResourceAttributes.SERVICE_NAME, "test-service"));
|
||||
return Resource.create(Attributes.of(stringKey("service.name"), "test-service"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,17 +5,18 @@
|
|||
|
||||
package io.opentelemetry.sdk.autoconfigure.provider;
|
||||
|
||||
import static io.opentelemetry.api.common.AttributeKey.stringKey;
|
||||
|
||||
import io.opentelemetry.api.common.Attributes;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.internal.ConditionalResourceProvider;
|
||||
import io.opentelemetry.sdk.resources.Resource;
|
||||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
|
||||
|
||||
public class SecondResourceProvider implements ConditionalResourceProvider {
|
||||
|
||||
@Override
|
||||
public Resource createResource(ConfigProperties config) {
|
||||
return Resource.create(Attributes.of(ResourceAttributes.SERVICE_NAME, "test-service-2"));
|
||||
return Resource.create(Attributes.of(stringKey("service.name"), "test-service-2"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,7 +26,7 @@ public class SecondResourceProvider implements ConditionalResourceProvider {
|
|||
|
||||
@Override
|
||||
public boolean shouldApply(ConfigProperties config, Resource existing) {
|
||||
String serviceName = existing.getAttribute(ResourceAttributes.SERVICE_NAME);
|
||||
String serviceName = existing.getAttribute(stringKey("service.name"));
|
||||
return serviceName == null || "unknown_service:java".equals(serviceName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ dependencies {
|
|||
implementation("com.fasterxml.jackson.core:jackson-databind")
|
||||
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml")
|
||||
implementation(project(":sdk-extensions:autoconfigure"))
|
||||
implementation(project(":semconv"))
|
||||
|
||||
testImplementation(project(":sdk:testing"))
|
||||
testImplementation(project(":sdk-extensions:autoconfigure"))
|
||||
|
|
|
@ -5,12 +5,13 @@
|
|||
|
||||
package io.opentelemetry.sdk.extension.incubator.fileconfig;
|
||||
|
||||
import static io.opentelemetry.api.common.AttributeKey.stringKey;
|
||||
|
||||
import io.opentelemetry.api.common.AttributeKey;
|
||||
import io.opentelemetry.api.common.AttributesBuilder;
|
||||
import io.opentelemetry.sdk.autoconfigure.internal.SpiHelper;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
|
||||
import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.Attributes;
|
||||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
|
||||
import java.io.Closeable;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -37,7 +38,7 @@ final class AttributesFactory
|
|||
|
||||
String serviceName = model.getServiceName();
|
||||
if (serviceName != null) {
|
||||
builder.put(ResourceAttributes.SERVICE_NAME, serviceName);
|
||||
builder.put(stringKey("service.name"), serviceName);
|
||||
}
|
||||
|
||||
model
|
||||
|
|
|
@ -12,7 +12,6 @@ import static org.mockito.Mockito.mock;
|
|||
import io.opentelemetry.sdk.autoconfigure.internal.SpiHelper;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
|
||||
import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.Attributes;
|
||||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.stream.Stream;
|
||||
|
@ -82,7 +81,7 @@ class AttributesFactoryTest {
|
|||
Collections.emptyList()))
|
||||
.isEqualTo(
|
||||
io.opentelemetry.api.common.Attributes.builder()
|
||||
.put(ResourceAttributes.SERVICE_NAME, "my-service")
|
||||
.put("service.name", "my-service")
|
||||
.put("strKey", "val")
|
||||
.put("longKey", 1L)
|
||||
.put("intKey", 2)
|
||||
|
|
|
@ -53,7 +53,6 @@ import io.opentelemetry.sdk.metrics.SdkMeterProvider;
|
|||
import io.opentelemetry.sdk.metrics.View;
|
||||
import io.opentelemetry.sdk.trace.SdkTracerProvider;
|
||||
import io.opentelemetry.sdk.trace.SpanLimits;
|
||||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
|
||||
import java.io.Closeable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -159,7 +158,7 @@ class OpenTelemetryConfigurationFactoryTest {
|
|||
List<Closeable> closeables = new ArrayList<>();
|
||||
io.opentelemetry.sdk.resources.Resource expectedResource =
|
||||
io.opentelemetry.sdk.resources.Resource.getDefault().toBuilder()
|
||||
.put(ResourceAttributes.SERVICE_NAME, "my-service")
|
||||
.put("service.name", "my-service")
|
||||
.put("key", "val")
|
||||
.build();
|
||||
OpenTelemetrySdk expectedSdk =
|
||||
|
|
|
@ -11,7 +11,6 @@ import static org.mockito.Mockito.mock;
|
|||
import io.opentelemetry.sdk.autoconfigure.internal.SpiHelper;
|
||||
import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.Attributes;
|
||||
import io.opentelemetry.sdk.resources.Resource;
|
||||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
|
||||
import java.util.Collections;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -40,7 +39,7 @@ class ResourceFactoryTest {
|
|||
Collections.emptyList()))
|
||||
.isEqualTo(
|
||||
Resource.getDefault().toBuilder()
|
||||
.put(ResourceAttributes.SERVICE_NAME, "my-service")
|
||||
.put("service.name", "my-service")
|
||||
.put("key", "val")
|
||||
.build());
|
||||
}
|
||||
|
|
|
@ -15,8 +15,6 @@ val mrJarVersions = listOf(9)
|
|||
dependencies {
|
||||
api(project(":api:all"))
|
||||
|
||||
implementation(project(":semconv"))
|
||||
|
||||
annotationProcessor("com.google.auto.value:auto-value")
|
||||
|
||||
testAnnotationProcessor("com.google.auto.value:auto-value")
|
||||
|
|
|
@ -5,11 +5,6 @@
|
|||
|
||||
package io.opentelemetry.sdk.resources;
|
||||
|
||||
import static io.opentelemetry.semconv.resource.attributes.ResourceAttributes.SERVICE_NAME;
|
||||
import static io.opentelemetry.semconv.resource.attributes.ResourceAttributes.TELEMETRY_SDK_LANGUAGE;
|
||||
import static io.opentelemetry.semconv.resource.attributes.ResourceAttributes.TELEMETRY_SDK_NAME;
|
||||
import static io.opentelemetry.semconv.resource.attributes.ResourceAttributes.TELEMETRY_SDK_VERSION;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import io.opentelemetry.api.common.AttributeKey;
|
||||
import io.opentelemetry.api.common.Attributes;
|
||||
|
@ -31,6 +26,14 @@ import javax.annotation.concurrent.Immutable;
|
|||
public abstract class Resource {
|
||||
private static final Logger logger = Logger.getLogger(Resource.class.getName());
|
||||
|
||||
private static final AttributeKey<String> SERVICE_NAME = AttributeKey.stringKey("service.name");
|
||||
private static final AttributeKey<String> TELEMETRY_SDK_LANGUAGE =
|
||||
AttributeKey.stringKey("telemetry.sdk.language");
|
||||
private static final AttributeKey<String> TELEMETRY_SDK_NAME =
|
||||
AttributeKey.stringKey("telemetry.sdk.name");
|
||||
private static final AttributeKey<String> TELEMETRY_SDK_VERSION =
|
||||
AttributeKey.stringKey("telemetry.sdk.version");
|
||||
|
||||
private static final int MAX_LENGTH = 255;
|
||||
private static final String ERROR_MESSAGE_INVALID_CHARS =
|
||||
" should be a ASCII string with a length greater than 0 and not exceed "
|
||||
|
|
|
@ -21,7 +21,6 @@ import io.opentelemetry.api.common.AttributeKey;
|
|||
import io.opentelemetry.api.common.AttributeType;
|
||||
import io.opentelemetry.api.common.Attributes;
|
||||
import io.opentelemetry.api.common.AttributesBuilder;
|
||||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
@ -238,12 +237,10 @@ class ResourceTest {
|
|||
@Test
|
||||
void testDefaultResources() {
|
||||
Resource resource = Resource.getDefault();
|
||||
assertThat(resource.getAttribute(ResourceAttributes.SERVICE_NAME))
|
||||
.isEqualTo("unknown_service:java");
|
||||
assertThat(resource.getAttribute(ResourceAttributes.TELEMETRY_SDK_NAME))
|
||||
.isEqualTo("opentelemetry");
|
||||
assertThat(resource.getAttribute(ResourceAttributes.TELEMETRY_SDK_LANGUAGE)).isEqualTo("java");
|
||||
assertThat(resource.getAttribute(ResourceAttributes.TELEMETRY_SDK_VERSION))
|
||||
assertThat(resource.getAttribute(stringKey("service.name"))).isEqualTo("unknown_service:java");
|
||||
assertThat(resource.getAttribute(stringKey("telemetry.sdk.name"))).isEqualTo("opentelemetry");
|
||||
assertThat(resource.getAttribute(stringKey("telemetry.sdk.language"))).isEqualTo("java");
|
||||
assertThat(resource.getAttribute(stringKey("telemetry.sdk.version")))
|
||||
.isEqualTo(System.getProperty("otel.test.project-version"));
|
||||
}
|
||||
|
||||
|
@ -257,7 +254,7 @@ class ResourceTest {
|
|||
|
||||
// then no exception is thrown
|
||||
// and
|
||||
assertThat(builder.build().getAttribute(ResourceAttributes.SERVICE_NAME))
|
||||
assertThat(builder.build().getAttribute(stringKey("service.name")))
|
||||
.isEqualTo("unknown_service:java");
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,6 @@ dependencies {
|
|||
|
||||
annotationProcessor("com.google.auto.value:auto-value")
|
||||
|
||||
implementation(project(":semconv"))
|
||||
|
||||
testImplementation("junit:junit")
|
||||
testImplementation("org.junit.vintage:junit-vintage-engine")
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ import io.opentelemetry.sdk.trace.data.EventData;
|
|||
import io.opentelemetry.sdk.trace.data.LinkData;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData;
|
||||
import io.opentelemetry.sdk.trace.data.StatusData;
|
||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -33,6 +32,14 @@ import org.assertj.core.api.AbstractAssert;
|
|||
/** Assertions for an exported {@link SpanData}. */
|
||||
public final class SpanDataAssert extends AbstractAssert<SpanDataAssert, SpanData> {
|
||||
|
||||
private static final AttributeKey<String> EXCEPTION_TYPE =
|
||||
AttributeKey.stringKey("exception.type");
|
||||
private static final AttributeKey<String> EXCEPTION_MESSAGE =
|
||||
AttributeKey.stringKey("exception.message");
|
||||
private static final AttributeKey<String> EXCEPTION_STACKTRACE =
|
||||
AttributeKey.stringKey("exception.stacktrace");
|
||||
private static final String EXCEPTION_EVENT_NAME = "exception";
|
||||
|
||||
SpanDataAssert(@Nullable SpanData actual) {
|
||||
super(actual, SpanDataAssert.class);
|
||||
}
|
||||
|
@ -377,7 +384,7 @@ public final class SpanDataAssert extends AbstractAssert<SpanDataAssert, SpanDat
|
|||
public SpanDataAssert hasException(Throwable exception) {
|
||||
EventData exceptionEvent =
|
||||
actual.getEvents().stream()
|
||||
.filter(event -> event.getName().equals(SemanticAttributes.EXCEPTION_EVENT_NAME))
|
||||
.filter(event -> event.getName().equals(EXCEPTION_EVENT_NAME))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
|
@ -391,16 +398,16 @@ public final class SpanDataAssert extends AbstractAssert<SpanDataAssert, SpanDat
|
|||
|
||||
assertThat(exceptionEvent.getAttributes())
|
||||
.as("exception.type")
|
||||
.containsEntry(SemanticAttributes.EXCEPTION_TYPE, exception.getClass().getCanonicalName());
|
||||
.containsEntry(EXCEPTION_TYPE, exception.getClass().getCanonicalName());
|
||||
if (exception.getMessage() != null) {
|
||||
assertThat(exceptionEvent.getAttributes())
|
||||
.as("exception.message")
|
||||
.containsEntry(SemanticAttributes.EXCEPTION_MESSAGE, exception.getMessage());
|
||||
.containsEntry(EXCEPTION_MESSAGE, exception.getMessage());
|
||||
}
|
||||
|
||||
// Exceptions used in assertions always have a different stack trace, just confirm it was
|
||||
// recorded.
|
||||
String stackTrace = exceptionEvent.getAttributes().get(SemanticAttributes.EXCEPTION_STACKTRACE);
|
||||
String stackTrace = exceptionEvent.getAttributes().get(EXCEPTION_STACKTRACE);
|
||||
assertThat(stackTrace).as("exception.stacktrace").isNotNull();
|
||||
|
||||
return this;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
package io.opentelemetry.sdk.testing.assertj;
|
||||
|
||||
import static io.opentelemetry.api.common.AttributeKey.stringKey;
|
||||
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
|
||||
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.attributeEntry;
|
||||
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
|
||||
|
@ -27,7 +28,6 @@ import io.opentelemetry.sdk.trace.data.EventData;
|
|||
import io.opentelemetry.sdk.trace.data.LinkData;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData;
|
||||
import io.opentelemetry.sdk.trace.data.StatusData;
|
||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -48,9 +48,9 @@ class TraceAssertionsTest {
|
|||
private static final InstrumentationScopeInfo INSTRUMENTATION_SCOPE_INFO =
|
||||
InstrumentationScopeInfo.builder("opentelemetry").setVersion("1.0").build();
|
||||
|
||||
private static final AttributeKey<String> DOG = AttributeKey.stringKey("dog");
|
||||
private static final AttributeKey<String> BEAR = AttributeKey.stringKey("bear");
|
||||
private static final AttributeKey<String> CAT = AttributeKey.stringKey("cat");
|
||||
private static final AttributeKey<String> DOG = stringKey("dog");
|
||||
private static final AttributeKey<String> BEAR = stringKey("bear");
|
||||
private static final AttributeKey<String> CAT = stringKey("cat");
|
||||
private static final AttributeKey<Boolean> WARM = AttributeKey.booleanKey("warm");
|
||||
private static final AttributeKey<Long> TEMPERATURE = AttributeKey.longKey("temperature");
|
||||
private static final AttributeKey<Double> LENGTH = AttributeKey.doubleKey("length");
|
||||
|
@ -59,7 +59,7 @@ class TraceAssertionsTest {
|
|||
AttributeKey.booleanArrayKey("conditions");
|
||||
private static final AttributeKey<List<Long>> SCORES = AttributeKey.longArrayKey("scores");
|
||||
private static final AttributeKey<List<Double>> COINS = AttributeKey.doubleArrayKey("coins");
|
||||
private static final AttributeKey<String> UNSET = AttributeKey.stringKey("unset");
|
||||
private static final AttributeKey<String> UNSET = stringKey("unset");
|
||||
|
||||
private static final Attributes ATTRIBUTES =
|
||||
Attributes.builder()
|
||||
|
@ -78,11 +78,11 @@ class TraceAssertionsTest {
|
|||
EventData.create(20, "event2", Attributes.builder().put("cookie monster", "yum").build()),
|
||||
EventData.create(
|
||||
30,
|
||||
SemanticAttributes.EXCEPTION_EVENT_NAME,
|
||||
"exception",
|
||||
Attributes.builder()
|
||||
.put(SemanticAttributes.EXCEPTION_TYPE, "java.lang.IllegalArgumentException")
|
||||
.put(SemanticAttributes.EXCEPTION_MESSAGE, "bad argument")
|
||||
.put(SemanticAttributes.EXCEPTION_STACKTRACE, "some obfuscated stack")
|
||||
.put(stringKey("exception.type"), "java.lang.IllegalArgumentException")
|
||||
.put(stringKey("exception.message"), "bad argument")
|
||||
.put(stringKey("exception.stacktrace"), "some obfuscated stack")
|
||||
.build()));
|
||||
private static final List<LinkData> LINKS =
|
||||
Arrays.asList(
|
||||
|
@ -155,7 +155,7 @@ class TraceAssertionsTest {
|
|||
attributes ->
|
||||
assertThat(attributes)
|
||||
.hasSize(2)
|
||||
.containsEntry(AttributeKey.stringKey("dog"), "bark")
|
||||
.containsEntry(stringKey("dog"), "bark")
|
||||
.hasEntrySatisfying(DOG, value -> assertThat(value).hasSize(4))
|
||||
.hasEntrySatisfying(
|
||||
AttributeKey.booleanKey("dog is cute"),
|
||||
|
@ -224,9 +224,8 @@ class TraceAssertionsTest {
|
|||
attributes ->
|
||||
assertThat(attributes)
|
||||
.hasSize(8)
|
||||
.containsEntry(AttributeKey.stringKey("bear"), "mya")
|
||||
.hasEntrySatisfying(
|
||||
AttributeKey.stringKey("bear"), value -> assertThat(value).hasSize(3))
|
||||
.containsEntry(stringKey("bear"), "mya")
|
||||
.hasEntrySatisfying(stringKey("bear"), value -> assertThat(value).hasSize(3))
|
||||
.containsEntry("bear", "mya")
|
||||
.containsEntry("warm", true)
|
||||
.containsEntry("temperature", 30)
|
||||
|
@ -241,9 +240,9 @@ class TraceAssertionsTest {
|
|||
.containsEntryWithLongValuesOf("scores", Arrays.asList(0L, 1L))
|
||||
.containsEntry("coins", 0.01, 0.05, 0.1)
|
||||
.containsEntryWithDoubleValuesOf("coins", Arrays.asList(0.01, 0.05, 0.1))
|
||||
.containsKey(AttributeKey.stringKey("bear"))
|
||||
.containsKey(stringKey("bear"))
|
||||
.containsKey("bear")
|
||||
.doesNotContainKey(AttributeKey.stringKey("cat"))
|
||||
.doesNotContainKey(stringKey("cat"))
|
||||
.doesNotContainKey("cat")
|
||||
.containsOnly(
|
||||
attributeEntry("bear", "mya"),
|
||||
|
@ -270,18 +269,16 @@ class TraceAssertionsTest {
|
|||
.hasAttributesSatisfying(attributes -> assertThat(attributes).isEmpty());
|
||||
assertThat(events.get(2))
|
||||
.hasAttributesSatisfying(
|
||||
equalTo(
|
||||
SemanticAttributes.EXCEPTION_TYPE, "java.lang.IllegalArgumentException"))
|
||||
equalTo(stringKey("exception.type"), "java.lang.IllegalArgumentException"))
|
||||
.hasAttributesSatisfyingExactly(
|
||||
equalTo(
|
||||
SemanticAttributes.EXCEPTION_TYPE, "java.lang.IllegalArgumentException"),
|
||||
equalTo(SemanticAttributes.EXCEPTION_MESSAGE, "bad argument"),
|
||||
equalTo(SemanticAttributes.EXCEPTION_STACKTRACE, "some obfuscated stack"));
|
||||
equalTo(stringKey("exception.type"), "java.lang.IllegalArgumentException"),
|
||||
equalTo(stringKey("exception.message"), "bad argument"),
|
||||
equalTo(stringKey("exception.stacktrace"), "some obfuscated stack"));
|
||||
})
|
||||
.hasEventsSatisfyingExactly(
|
||||
event -> event.hasName("event"),
|
||||
event -> event.hasName("event2"),
|
||||
event -> event.hasName(SemanticAttributes.EXCEPTION_EVENT_NAME))
|
||||
event -> event.hasName("exception"))
|
||||
.hasException(new IllegalArgumentException("bad argument"))
|
||||
.hasLinks(LINKS)
|
||||
.hasLinks(LINKS.toArray(new LinkData[0]))
|
||||
|
@ -358,7 +355,7 @@ class TraceAssertionsTest {
|
|||
resource.hasAttributesSatisfying(
|
||||
attributes ->
|
||||
assertThat(attributes)
|
||||
.containsEntry(AttributeKey.stringKey("dog"), "meow"))))
|
||||
.containsEntry(stringKey("dog"), "meow"))))
|
||||
.isInstanceOf(AssertionError.class);
|
||||
assertThatThrownBy(
|
||||
() ->
|
||||
|
@ -404,7 +401,7 @@ class TraceAssertionsTest {
|
|||
.isInstanceOf(AssertionError.class);
|
||||
assertThatThrownBy(() -> assertThat(SPAN1).startsAt(Instant.EPOCH))
|
||||
.isInstanceOf(AssertionError.class);
|
||||
assertThatThrownBy(() -> assertThat(SPAN1).hasAttribute(AttributeKey.stringKey("foo"), "bar"))
|
||||
assertThatThrownBy(() -> assertThat(SPAN1).hasAttribute(stringKey("foo"), "bar"))
|
||||
.isInstanceOf(AssertionError.class);
|
||||
assertThatThrownBy(() -> assertThat(SPAN1).hasAttributes(Attributes.empty()))
|
||||
.isInstanceOf(AssertionError.class);
|
||||
|
@ -462,8 +459,7 @@ class TraceAssertionsTest {
|
|||
() ->
|
||||
assertThat(SPAN1)
|
||||
.hasAttributesSatisfying(
|
||||
attributes ->
|
||||
assertThat(attributes).containsKey(AttributeKey.stringKey("cat"))))
|
||||
attributes -> assertThat(attributes).containsKey(stringKey("cat"))))
|
||||
.isInstanceOf(AssertionError.class);
|
||||
assertThatThrownBy(
|
||||
() ->
|
||||
|
@ -475,9 +471,7 @@ class TraceAssertionsTest {
|
|||
() ->
|
||||
assertThat(SPAN1)
|
||||
.hasAttributesSatisfying(
|
||||
attributes ->
|
||||
assertThat(attributes)
|
||||
.doesNotContainKey(AttributeKey.stringKey("bear"))))
|
||||
attributes -> assertThat(attributes).doesNotContainKey(stringKey("bear"))))
|
||||
.isInstanceOf(AssertionError.class);
|
||||
assertThatThrownBy(
|
||||
() ->
|
||||
|
@ -502,8 +496,7 @@ class TraceAssertionsTest {
|
|||
attributes ->
|
||||
assertThat(attributes)
|
||||
.hasEntrySatisfying(
|
||||
AttributeKey.stringKey("bear"),
|
||||
value -> assertThat(value).hasSize(2))))
|
||||
stringKey("bear"), value -> assertThat(value).hasSize(2))))
|
||||
.isInstanceOf(AssertionError.class);
|
||||
assertThatThrownBy(() -> assertThat(SPAN1).hasEvents()).isInstanceOf(AssertionError.class);
|
||||
assertThatThrownBy(() -> assertThat(SPAN1).hasEvents(Collections.emptyList()))
|
||||
|
@ -561,9 +554,9 @@ class TraceAssertionsTest {
|
|||
assertThat(events.get(2))
|
||||
.hasAttributesSatisfyingExactly(
|
||||
equalTo(
|
||||
SemanticAttributes.EXCEPTION_TYPE,
|
||||
stringKey("exception.type"),
|
||||
"java.lang.IllegalArgumentException"),
|
||||
equalTo(SemanticAttributes.EXCEPTION_MESSAGE, "bad argument"))))
|
||||
equalTo(stringKey("exception.message"), "bad argument"))))
|
||||
.isInstanceOf(AssertionError.class);
|
||||
assertThatThrownBy(
|
||||
() -> assertThat(SPAN1).hasException(new IllegalStateException("bad argument")))
|
||||
|
@ -608,14 +601,11 @@ class TraceAssertionsTest {
|
|||
assertThatThrownBy(
|
||||
() ->
|
||||
assertThat(RESOURCE.getAttributes())
|
||||
.containsOnly(
|
||||
entry(AttributeKey.stringKey("dog"), "bark"),
|
||||
entry(AttributeKey.stringKey("cat"), "meow")))
|
||||
.containsOnly(entry(stringKey("dog"), "bark"), entry(stringKey("cat"), "meow")))
|
||||
.isInstanceOf(AssertionError.class);
|
||||
assertThatThrownBy(
|
||||
() ->
|
||||
assertThat(RESOURCE.getAttributes())
|
||||
.containsOnly(entry(AttributeKey.stringKey("cat"), "meow")))
|
||||
assertThat(RESOURCE.getAttributes()).containsOnly(entry(stringKey("cat"), "meow")))
|
||||
.isInstanceOf(AssertionError.class);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,8 +24,6 @@ dependencies {
|
|||
|
||||
compileOnly(project(":sdk:trace-shaded-deps"))
|
||||
|
||||
implementation(project(":semconv"))
|
||||
|
||||
annotationProcessor("com.google.auto.value:auto-value")
|
||||
|
||||
testAnnotationProcessor("com.google.auto.value:auto-value")
|
||||
|
|
|
@ -7,11 +7,11 @@ package io.opentelemetry.sdk.trace.internal.data;
|
|||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.auto.value.extension.memoized.Memoized;
|
||||
import io.opentelemetry.api.common.AttributeKey;
|
||||
import io.opentelemetry.api.common.Attributes;
|
||||
import io.opentelemetry.api.common.AttributesBuilder;
|
||||
import io.opentelemetry.sdk.internal.AttributeUtil;
|
||||
import io.opentelemetry.sdk.trace.SpanLimits;
|
||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
@ -21,6 +21,14 @@ import javax.annotation.concurrent.Immutable;
|
|||
@Immutable
|
||||
abstract class ImmutableExceptionEventData implements ExceptionEventData {
|
||||
|
||||
private static final AttributeKey<String> EXCEPTION_TYPE =
|
||||
AttributeKey.stringKey("exception.type");
|
||||
private static final AttributeKey<String> EXCEPTION_MESSAGE =
|
||||
AttributeKey.stringKey("exception.message");
|
||||
private static final AttributeKey<String> EXCEPTION_STACKTRACE =
|
||||
AttributeKey.stringKey("exception.stacktrace");
|
||||
private static final String EXCEPTION_EVENT_NAME = "exception";
|
||||
|
||||
/**
|
||||
* Returns a new immutable {@code Event}.
|
||||
*
|
||||
|
@ -46,7 +54,7 @@ abstract class ImmutableExceptionEventData implements ExceptionEventData {
|
|||
|
||||
@Override
|
||||
public final String getName() {
|
||||
return SemanticAttributes.EXCEPTION_EVENT_NAME;
|
||||
return EXCEPTION_EVENT_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,18 +64,17 @@ abstract class ImmutableExceptionEventData implements ExceptionEventData {
|
|||
Attributes additionalAttributes = getAdditionalAttributes();
|
||||
AttributesBuilder attributesBuilder = Attributes.builder();
|
||||
|
||||
attributesBuilder.put(
|
||||
SemanticAttributes.EXCEPTION_TYPE, exception.getClass().getCanonicalName());
|
||||
attributesBuilder.put(EXCEPTION_TYPE, exception.getClass().getCanonicalName());
|
||||
String message = exception.getMessage();
|
||||
if (message != null) {
|
||||
attributesBuilder.put(SemanticAttributes.EXCEPTION_MESSAGE, message);
|
||||
attributesBuilder.put(EXCEPTION_MESSAGE, message);
|
||||
}
|
||||
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
try (PrintWriter printWriter = new PrintWriter(stringWriter)) {
|
||||
exception.printStackTrace(printWriter);
|
||||
}
|
||||
attributesBuilder.put(SemanticAttributes.EXCEPTION_STACKTRACE, stringWriter.toString());
|
||||
attributesBuilder.put(EXCEPTION_STACKTRACE, stringWriter.toString());
|
||||
attributesBuilder.putAll(additionalAttributes);
|
||||
|
||||
SpanLimits spanLimits = getSpanLimits();
|
||||
|
|
|
@ -38,7 +38,6 @@ import io.opentelemetry.sdk.trace.data.LinkData;
|
|||
import io.opentelemetry.sdk.trace.data.SpanData;
|
||||
import io.opentelemetry.sdk.trace.data.StatusData;
|
||||
import io.opentelemetry.sdk.trace.internal.data.ExceptionEventData;
|
||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.time.Duration;
|
||||
|
@ -745,10 +744,10 @@ class SdkSpanTest {
|
|||
assertThat(events).hasSize(1);
|
||||
EventData event = events.get(0);
|
||||
assertThat(event.getName()).isEqualTo("exception");
|
||||
assertThat(event.getAttributes().get(SemanticAttributes.EXCEPTION_TYPE))
|
||||
assertThat(event.getAttributes().get(stringKey("exception.type")))
|
||||
.isEqualTo("java.lang.IllegalStateException".substring(0, maxLength));
|
||||
assertThat(event.getAttributes().get(SemanticAttributes.EXCEPTION_MESSAGE)).isEqualTo(strVal);
|
||||
assertThat(event.getAttributes().get(SemanticAttributes.EXCEPTION_STACKTRACE).length())
|
||||
assertThat(event.getAttributes().get(stringKey("exception.message"))).isEqualTo(strVal);
|
||||
assertThat(event.getAttributes().get(stringKey("exception.stacktrace")).length())
|
||||
.isLessThanOrEqualTo(maxLength);
|
||||
} finally {
|
||||
span.end();
|
||||
|
@ -918,9 +917,9 @@ class SdkSpanTest {
|
|||
assertThat(event.getAttributes())
|
||||
.isEqualTo(
|
||||
Attributes.builder()
|
||||
.put(SemanticAttributes.EXCEPTION_TYPE, "java.lang.IllegalStateException")
|
||||
.put(SemanticAttributes.EXCEPTION_MESSAGE, "there was an exception")
|
||||
.put(SemanticAttributes.EXCEPTION_STACKTRACE, stacktrace)
|
||||
.put("exception.type", "java.lang.IllegalStateException")
|
||||
.put("exception.message", "there was an exception")
|
||||
.put("exception.stacktrace", stacktrace)
|
||||
.build());
|
||||
|
||||
assertThat(event)
|
||||
|
@ -942,7 +941,7 @@ class SdkSpanTest {
|
|||
List<EventData> events = span.toSpanData().getEvents();
|
||||
assertThat(events).hasSize(1);
|
||||
EventData event = events.get(0);
|
||||
assertThat(event.getAttributes().get(SemanticAttributes.EXCEPTION_MESSAGE)).isNull();
|
||||
assertThat(event.getAttributes().get(stringKey("exception.message"))).isNull();
|
||||
}
|
||||
|
||||
private static class InnerClassException extends Exception {}
|
||||
|
@ -957,7 +956,7 @@ class SdkSpanTest {
|
|||
List<EventData> events = span.toSpanData().getEvents();
|
||||
assertThat(events).hasSize(1);
|
||||
EventData event = events.get(0);
|
||||
assertThat(event.getAttributes().get(SemanticAttributes.EXCEPTION_TYPE))
|
||||
assertThat(event.getAttributes().get(stringKey("exception.type")))
|
||||
.isEqualTo("io.opentelemetry.sdk.trace.SdkSpanTest.InnerClassException");
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
package io.opentelemetry.sdk.trace;
|
||||
|
||||
import static io.opentelemetry.api.common.AttributeKey.stringKey;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
@ -19,7 +20,6 @@ import io.opentelemetry.sdk.common.CompletableResultCode;
|
|||
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
|
||||
import io.opentelemetry.sdk.resources.Resource;
|
||||
import io.opentelemetry.sdk.trace.samplers.Sampler;
|
||||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
|
||||
import java.util.function.Supplier;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -82,7 +82,7 @@ class SdkTracerProviderTest {
|
|||
@Test
|
||||
void builder_serviceNameProvided() {
|
||||
Resource resource =
|
||||
Resource.create(Attributes.of(ResourceAttributes.SERVICE_NAME, "mySpecialService"));
|
||||
Resource.create(Attributes.of(stringKey("service.name"), "mySpecialService"));
|
||||
|
||||
SdkTracerProvider tracerProvider =
|
||||
SdkTracerProvider.builder()
|
||||
|
|
|
@ -14,7 +14,6 @@ import io.opentelemetry.api.common.Attributes;
|
|||
import io.opentelemetry.api.common.AttributesBuilder;
|
||||
import io.opentelemetry.api.trace.SpanKind;
|
||||
import io.opentelemetry.sdk.testing.trace.TestSpanData;
|
||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
||||
import org.assertj.core.api.recursive.comparison.RecursiveComparisonConfiguration;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -35,7 +34,7 @@ class DelegatingSpanDataTest {
|
|||
private SpanDataWithClientType(SpanData delegate) {
|
||||
super(delegate);
|
||||
String clientType;
|
||||
String userAgent = delegate.getAttributes().get(SemanticAttributes.USER_AGENT_ORIGINAL);
|
||||
String userAgent = delegate.getAttributes().get(stringKey("user_agent.original"));
|
||||
if (userAgent != null) {
|
||||
clientType = parseUserAgent(userAgent);
|
||||
} else {
|
||||
|
|
|
@ -13,6 +13,12 @@ import static io.opentelemetry.api.common.AttributeKey.stringKey;
|
|||
import io.opentelemetry.api.common.AttributeKey;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@code io.opentelemetry.semconv.ResourceAttributes} from <a
|
||||
* href="https://github.com/open-telemetry/semantic-conventions-java">io.opentelemetry.semconv:opentelemetry-semconv:{{version}}</a>
|
||||
* instead.
|
||||
*/
|
||||
@Deprecated
|
||||
// DO NOT EDIT, this is an Auto-generated file from
|
||||
// buildscripts/semantic-convention/templates/SemanticAttributes.java.j2
|
||||
@SuppressWarnings("unused")
|
||||
|
|
|
@ -14,6 +14,12 @@ import static io.opentelemetry.api.common.AttributeKey.stringKey;
|
|||
import io.opentelemetry.api.common.AttributeKey;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@code io.opentelemetry.semconv.SemanticAttributes} from <a
|
||||
* href="https://github.com/open-telemetry/semantic-conventions-java">io.opentelemetry.semconv:opentelemetry-semconv:{{version}}</a>
|
||||
* instead.
|
||||
*/
|
||||
@Deprecated
|
||||
// DO NOT EDIT, this is an Auto-generated file from
|
||||
// buildscripts/semantic-convention/templates/SemanticAttributes.java.j2
|
||||
@SuppressWarnings("unused")
|
||||
|
|
Loading…
Reference in New Issue