Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
Comparing source compatibility of opentelemetry-exporter-zipkin-1.59.0-SNAPSHOT.jar against opentelemetry-exporter-zipkin-1.58.0.jar
No changes.
=== UNCHANGED CLASS: PUBLIC FINAL io.opentelemetry.exporter.zipkin.ZipkinSpanExporter (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW ANNOTATION: java.lang.Deprecated
=== UNCHANGED CLASS: PUBLIC FINAL io.opentelemetry.exporter.zipkin.ZipkinSpanExporterBuilder (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW ANNOTATION: java.lang.Deprecated
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

package io.opentelemetry.exporter.zipkin;

import io.opentelemetry.api.internal.InstrumentationUtil;
import io.opentelemetry.api.metrics.MeterProvider;
import io.opentelemetry.exporter.internal.metrics.ExporterInstrumentation;
import io.opentelemetry.exporter.zipkin.internal.copied.ComponentId;
import io.opentelemetry.exporter.zipkin.internal.copied.ExporterInstrumentation;
import io.opentelemetry.exporter.zipkin.internal.copied.InstrumentationUtil;
import io.opentelemetry.exporter.zipkin.internal.copied.StandardComponentId;
import io.opentelemetry.exporter.zipkin.internal.copied.ThrottlingLogger;
import io.opentelemetry.sdk.common.CompletableResultCode;
import io.opentelemetry.sdk.common.InternalTelemetryVersion;
import io.opentelemetry.sdk.internal.ComponentId;
import io.opentelemetry.sdk.internal.StandardComponentId;
import io.opentelemetry.sdk.internal.ThrottlingLogger;
import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.sdk.trace.export.SpanExporter;
import java.io.IOException;
Expand All @@ -32,7 +32,12 @@
* This class was based on the <a
* href="https://github.com/census-instrumentation/opencensus-java/tree/c960b19889de5e4a7b25f90919d28b066590d4f0/exporters/trace/zipkin">OpenCensus
* zipkin exporter</a> code.
*
* @deprecated Zipkin exporter is deprecated in OpenTelemetry spec (see the <a
* href="https://github.com/open-telemetry/opentelemetry-specification/pull/4715">PR</a>).
* Expect this artifact to no longer be published in approximately 6 months (mid 2026).
*/
@Deprecated
public final class ZipkinSpanExporter implements SpanExporter {

public static final Logger baseLogger = Logger.getLogger(ZipkinSpanExporter.class.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

package io.opentelemetry.exporter.zipkin;

import static io.opentelemetry.api.internal.Utils.checkArgument;
import static java.util.Objects.requireNonNull;

import io.opentelemetry.api.GlobalOpenTelemetry;
Expand All @@ -23,7 +22,14 @@
import zipkin2.reporter.SpanBytesEncoder;
import zipkin2.reporter.okhttp3.OkHttpSender;

/** Builder class for {@link ZipkinSpanExporter}. */
/**
* Builder class for {@link ZipkinSpanExporter}.
*
* @deprecated Zipkin exporter is deprecated in OpenTelemetry spec (see the <a
* href="https://github.com/open-telemetry/opentelemetry-specification/pull/4715">PR</a>).
* Expect this artifact to no longer be published in approximately 6 months (mid 2026).
*/
@Deprecated
public final class ZipkinSpanExporterBuilder {
private BytesEncoder<Span> encoder = SpanBytesEncoder.JSON_V2;
private Supplier<InetAddress> localIpAddressSupplier = LocalInetAddressSupplier.getInstance();
Expand Down Expand Up @@ -243,4 +249,12 @@ public ZipkinSpanExporter build() {
endpoint,
transformer);
}

// Copied from io.opentelemetry.api.internal.Utils to remove internal dependencies as part of
// https://github.com/open-telemetry/opentelemetry-java/issues/7863
private static void checkArgument(boolean isValid, String errorMessage) {
if (!isValid) {
throw new IllegalArgumentException(errorMessage);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@

package io.opentelemetry.exporter.zipkin.internal;

import io.opentelemetry.exporter.zipkin.ZipkinSpanExporter;
import io.opentelemetry.exporter.zipkin.ZipkinSpanExporterBuilder;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider;
import io.opentelemetry.sdk.trace.export.SpanExporter;
import java.time.Duration;

/**
* {@link SpanExporter} SPI implementation for {@link ZipkinSpanExporter}.
* {@link SpanExporter} SPI implementation for {@link
* io.opentelemetry.exporter.zipkin.ZipkinSpanExporter}.
*
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
@SuppressWarnings("deprecation")
public class ZipkinSpanExporterProvider implements ConfigurableSpanExporterProvider {
@Override
public String getName() {
Expand All @@ -26,7 +26,8 @@ public String getName() {

@Override
public SpanExporter createExporter(ConfigProperties config) {
ZipkinSpanExporterBuilder builder = ZipkinSpanExporter.builder();
io.opentelemetry.exporter.zipkin.ZipkinSpanExporterBuilder builder =
io.opentelemetry.exporter.zipkin.ZipkinSpanExporter.builder();

String endpoint = config.getString("otel.exporter.zipkin.endpoint");
if (endpoint != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.exporter.zipkin.internal.copied;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import javax.annotation.Nullable;

/**
* The component id used for SDK health metrics. This corresponds to the otel.component.name and
* otel.component.id semconv attributes.
*
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
public abstract class ComponentId {

private ComponentId() {}

public abstract String getTypeName();

public abstract String getComponentName();

static class Lazy extends ComponentId {

private static final Map<String, AtomicInteger> nextIdCounters = new ConcurrentHashMap<>();

private final String componentType;
@Nullable private volatile String componentName = null;

Lazy(String componentType) {
this.componentType = componentType;
}

@Override
public String getTypeName() {
return componentType;
}

@Override
public String getComponentName() {
if (componentName == null) {
synchronized (this) {
if (componentName == null) {
int id =
nextIdCounters
.computeIfAbsent(componentType, k -> new AtomicInteger(0))
.getAndIncrement();
componentName = componentType + "/" + id;
}
}
}
return componentName;
}
}

public static ComponentId generateLazy(String componentType) {
return new Lazy(componentType);
}

public static StandardComponentId generateLazy(StandardComponentId.ExporterType exporterType) {
return new StandardComponentId(exporterType);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.exporter.zipkin.internal.copied;

import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.api.metrics.MeterProvider;
import io.opentelemetry.sdk.common.InternalTelemetryVersion;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.function.Supplier;
import javax.annotation.Nullable;

/**
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
* any time.
*/
public class ExporterInstrumentation {

private final ExporterMetrics implementation;

public ExporterInstrumentation(
InternalTelemetryVersion schema,
Supplier<MeterProvider> meterProviderSupplier,
StandardComponentId componentId,
String endpoint) {

Signal signal = componentId.getStandardType().signal();
switch (schema) {
case LEGACY:
implementation =
LegacyExporterMetrics.isSupportedType(componentId.getStandardType())
? new LegacyExporterMetrics(meterProviderSupplier, componentId.getStandardType())
: NoopExporterMetrics.INSTANCE;
break;
case LATEST:
implementation =
signal == Signal.PROFILE
? NoopExporterMetrics.INSTANCE
: new SemConvExporterMetrics(
meterProviderSupplier, signal, componentId, extractServerAttributes(endpoint));
break;
default:
throw new IllegalStateException("Unhandled case: " + schema);
}
}

// visible for testing
static Attributes extractServerAttributes(String httpEndpoint) {
try {
URI parsed = new URI(httpEndpoint);
AttributesBuilder builder = Attributes.builder();
String host = parsed.getHost();
if (host != null) {
builder.put(SemConvAttributes.SERVER_ADDRESS, host);
}
int port = parsed.getPort();
if (port == -1) {
String scheme = parsed.getScheme();
if ("https".equals(scheme)) {
port = 443;
} else if ("http".equals(scheme)) {
port = 80;
}
}
if (port != -1) {
builder.put(SemConvAttributes.SERVER_PORT, port);
}
return builder.build();
} catch (URISyntaxException e) {
return Attributes.empty();
}
}

public Recording startRecordingExport(int itemCount) {
return new Recording(implementation.startRecordingExport(itemCount));
}

/**
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
* any time.
*/
public static class Recording {

private final ExporterMetrics.Recording delegate;
@Nullable private Long httpStatusCode;
@Nullable private Long grpcStatusCode;

private Recording(ExporterMetrics.Recording delegate) {
this.delegate = delegate;
}

public void setHttpStatusCode(long httpStatusCode) {
if (grpcStatusCode != null) {
throw new IllegalStateException(
"gRPC status code already set, can only set either gRPC or HTTP");
}
this.httpStatusCode = httpStatusCode;
}

public void setGrpcStatusCode(long grpcStatusCode) {
if (httpStatusCode != null) {
throw new IllegalStateException(
"HTTP status code already set, can only set either gRPC or HTTP");
}
this.grpcStatusCode = grpcStatusCode;
}

/** Callback to notify that the export was successful. */
public void finishSuccessful() {
delegate.finishSuccessful(buildRequestAttributes());
}

/**
* Callback to notify that the export has failed with the given {@link Throwable} as failure
* cause.
*
* @param failureCause the cause of the failure
*/
public void finishFailed(Throwable failureCause) {
finishFailed(failureCause.getClass().getName());
}

/**
* Callback to notify that the export has failed.
*
* @param errorType a failure reason suitable for the error.type attribute
*/
public void finishFailed(String errorType) {
delegate.finishFailed(errorType, buildRequestAttributes());
}

private Attributes buildRequestAttributes() {
if (httpStatusCode != null) {
return Attributes.of(SemConvAttributes.HTTP_RESPONSE_STATUS_CODE, httpStatusCode);
}
if (grpcStatusCode != null) {
return Attributes.of(SemConvAttributes.RPC_GRPC_STATUS_CODE, grpcStatusCode);
}
return Attributes.empty();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.exporter.zipkin.internal.copied;

import io.opentelemetry.api.common.Attributes;
import javax.annotation.Nullable;

/**
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
* any time.
*/
public interface ExporterMetrics {

Recording startRecordingExport(int itemCount);

/**
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
* any time.
*/
abstract class Recording {

private boolean alreadyEnded = false;

protected Recording() {}

public final void finishSuccessful(Attributes requestAttributes) {
ensureEndedOnce();
doFinish(null, requestAttributes);
}

public final void finishFailed(String errorType, Attributes requestAttributes) {
ensureEndedOnce();
if (errorType == null || errorType.isEmpty()) {
throw new IllegalArgumentException("The export failed but no failure reason was provided");
}
doFinish(errorType, requestAttributes);
}

private void ensureEndedOnce() {
if (alreadyEnded) {
throw new IllegalStateException("Recording already ended");
}
alreadyEnded = true;
}

/**
* Invoked when the export has finished, either successfully or failed.
*
* @param errorType null if the export was successful, otherwise a failure reason suitable for
* the error.type attribute
* @param requestAttributes additional attributes to add to request metrics
*/
protected abstract void doFinish(@Nullable String errorType, Attributes requestAttributes);
}
}
Loading
Loading