Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate semconv module #5786

Merged
merged 5 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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--> | [![Javadocs](https://www.javadoc.io/badge/io.opentelemetry/opentelemetry-api.svg)](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--> | [![Javadocs](https://www.javadoc.io/badge/io.opentelemetry/opentelemetry-api-events.svg)](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--> | [![Javadocs](https://www.javadoc.io/badge/io.opentelemetry/opentelemetry-context.svg)](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--> | [![Javadocs](https://www.javadoc.io/badge/io.opentelemetry/opentelemetry-semconv.svg)](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--> | [![Javadocs](https://www.javadoc.io/badge/io.opentelemetry/opentelemetry-api.svg)](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--> | [![Javadocs](https://www.javadoc.io/badge/io.opentelemetry/opentelemetry-api-events.svg)](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--> | [![Javadocs](https://www.javadoc.io/badge/io.opentelemetry/opentelemetry-context.svg)](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--> | [![Javadocs](https://www.javadoc.io/badge/io.opentelemetry/opentelemetry-semconv.svg)](https://www.javadoc.io/doc/io.opentelemetry/opentelemetry-semconv) |

### API Extensions

Expand Down
4 changes: 3 additions & 1 deletion bom-alpha/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import java.util.function.Consumer
jack-berg marked this conversation as resolved.
Show resolved Hide resolved

plugins {
id("otel.bom-conventions")
}
Expand All @@ -14,4 +16,4 @@ javaPlatform.allowDependencies()
dependencies {
// Add dependency on opentelemetry-bom to ensure synchronization between alpha and stable artifacts
api(platform(project(":bom")))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/otel.bom-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ afterEvaluate {
}
}
}
otelBom.fallbacks.forEach { fallback ->
otelBom.additionalDependencies.forEach { dependency ->
dependencies {
constraints {
api(fallback)
api(dependency)
}
}
}
Expand Down
1 change: 0 additions & 1 deletion exporters/jaeger-thrift/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
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;
Expand All @@ -40,6 +40,8 @@
@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";
Expand Down Expand Up @@ -121,9 +123,9 @@ public CompletableResultCode export(Collection<SpanData> spans) {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.semconv.resource.attributes.ResourceAttributes;
import java.time.Duration;
import okhttp3.OkHttpClient;
import okhttp3.Request;
Expand Down Expand Up @@ -84,7 +85,7 @@ private static OpenTelemetry initOpenTelemetry(boolean udp) {
.addSpanProcessor(SimpleSpanProcessor.create(jaegerExporter.build()))
.setResource(
Resource.getDefault().toBuilder()
.put(ResourceAttributes.SERVICE_NAME, SERVICE_NAME)
.put(stringKey("service.name"), SERVICE_NAME)
.build())
.build())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -17,7 +18,6 @@
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;
Expand All @@ -30,7 +30,6 @@
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;
Expand Down Expand Up @@ -79,9 +78,9 @@ void testExport() throws SenderException, UnknownHostException {
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,
Expand Down Expand Up @@ -140,9 +139,9 @@ void testExportMultipleResources() throws SenderException, UnknownHostException
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,
Expand All @@ -152,9 +151,9 @@ void testExportMultipleResources() throws SenderException, UnknownHostException
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,
Expand Down
1 change: 0 additions & 1 deletion exporters/jaeger/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -17,7 +18,6 @@
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;
Expand All @@ -38,7 +38,6 @@
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;
Expand Down Expand Up @@ -127,9 +126,9 @@ void testExport() throws Exception {
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");

Expand Down Expand Up @@ -161,19 +160,19 @@ void testExportMultipleResources() throws Exception {
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");

SpanData span2 =
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");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -15,7 +17,6 @@
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;
Expand Down Expand Up @@ -67,7 +68,7 @@ private static OpenTelemetry initOpenTelemetry() {
.addSpanProcessor(SimpleSpanProcessor.create(jaegerExporter))
.setResource(
Resource.getDefault().toBuilder()
.put(ResourceAttributes.SERVICE_NAME, SERVICE_NAME)
.put(stringKey("service.name"), SERVICE_NAME)
.build())
.build())
.build();
Expand Down
2 changes: 0 additions & 2 deletions exporters/prometheus/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -29,7 +30,6 @@
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;
Expand Down Expand Up @@ -139,20 +139,19 @@ void endToEnd() {
// 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 =
Expand Down
1 change: 0 additions & 1 deletion exporters/zipkin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down