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

Remove Binary format and related members. #891

Merged
Merged
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
Expand Up @@ -17,7 +17,6 @@
package io.opentelemetry.correlationcontext;

import io.opentelemetry.context.Scope;
import io.opentelemetry.context.propagation.BinaryFormat;
import io.opentelemetry.context.propagation.HttpTextFormat;
import javax.annotation.concurrent.ThreadSafe;

Expand Down Expand Up @@ -65,45 +64,6 @@ public interface CorrelationContextManager {
*/
Scope withContext(CorrelationContext distContext);

/**
* Returns the {@link BinaryFormat} for this implementation.
*
* <p>Example of usage on the client:
*
* <pre>{@code
* private static final CorrelationContextManager contextManager =
* OpenTelemetry.getCorrelationContextManager();
* private static final BinaryFormat binaryFormat = contextManager.getBinaryFormat();
*
* Request createRequest() {
* Request req = new Request();
* byte[] ctxBuffer = binaryFormat.toByteArray(contextManager.getCurrentContext());
* request.addMetadata("distributedContext", ctxBuffer);
* return request;
* }
* }</pre>
*
* <p>Example of usage on the server:
*
* <pre>{@code
* private static final CorrelationContextManager contextManager =
* OpenTelemetry.getCorrelationContextManager();
* private static final BinaryFormat binaryFormat = contextManager.getBinaryFormat();
*
* void onRequestReceived(Request request) {
* byte[] ctxBuffer = request.getMetadata("distributedContext");
* CorrelationContext distContext = textFormat.fromByteArray(ctxBuffer);
* try (Scope s = contextManager.withContext(distContext)) {
* // Handle request and send response back.
* }
* }
* }</pre>
*
* @return the {@code BinaryFormat} for this implementation.
* @since 0.1.0
*/
BinaryFormat<CorrelationContext> getBinaryFormat();

/**
* Returns the {@link HttpTextFormat} for this implementation.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package io.opentelemetry.correlationcontext;

import io.opentelemetry.context.Scope;
import io.opentelemetry.context.propagation.BinaryFormat;
import io.opentelemetry.context.propagation.HttpTextFormat;
import io.opentelemetry.correlationcontext.unsafe.ContextUtils;
import io.opentelemetry.internal.Utils;
Expand All @@ -35,7 +34,6 @@
public final class DefaultCorrelationContextManager implements CorrelationContextManager {
private static final DefaultCorrelationContextManager INSTANCE =
new DefaultCorrelationContextManager();
private static final BinaryFormat<CorrelationContext> BINARY_FORMAT = new NoopBinaryFormat();
private static final HttpTextFormat<CorrelationContext> HTTP_TEXT_FORMAT =
new NoopHttpTextFormat();

Expand Down Expand Up @@ -66,11 +64,6 @@ public Scope withContext(CorrelationContext distContext) {
return ContextUtils.withCorrelationContext(distContext);
}

@Override
public BinaryFormat<CorrelationContext> getBinaryFormat() {
return BINARY_FORMAT;
}

@Override
public HttpTextFormat<CorrelationContext> getHttpTextFormat() {
return HTTP_TEXT_FORMAT;
Expand Down Expand Up @@ -110,23 +103,6 @@ public CorrelationContext build() {
}
}

@Immutable
private static final class NoopBinaryFormat implements BinaryFormat<CorrelationContext> {
static final byte[] EMPTY_BYTE_ARRAY = {};

@Override
public byte[] toByteArray(CorrelationContext distContext) {
Utils.checkNotNull(distContext, "distContext");
return EMPTY_BYTE_ARRAY;
}

@Override
public CorrelationContext fromByteArray(byte[] bytes) {
Utils.checkNotNull(bytes, "bytes");
return EmptyCorrelationContext.getInstance();
}
}

@Immutable
private static final class NoopHttpTextFormat implements HttpTextFormat<CorrelationContext> {
@Override
Expand Down
8 changes: 0 additions & 8 deletions api/src/main/java/io/opentelemetry/trace/DefaultTracer.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
package io.opentelemetry.trace;

import io.opentelemetry.context.Scope;
import io.opentelemetry.context.propagation.BinaryFormat;
import io.opentelemetry.context.propagation.HttpTextFormat;
import io.opentelemetry.internal.Utils;
import io.opentelemetry.trace.propagation.BinaryTraceContext;
import io.opentelemetry.trace.propagation.HttpTraceContext;
import io.opentelemetry.trace.unsafe.ContextUtils;
import java.util.Map;
Expand All @@ -34,7 +32,6 @@
@ThreadSafe
public final class DefaultTracer implements Tracer {
private static final DefaultTracer INSTANCE = new DefaultTracer();
private static final BinaryFormat<SpanContext> BINARY_FORMAT = new BinaryTraceContext();
private static final HttpTextFormat<SpanContext> HTTP_TEXT_FORMAT = new HttpTraceContext();

/**
Expand Down Expand Up @@ -62,11 +59,6 @@ public Span.Builder spanBuilder(String spanName) {
return NoopSpanBuilder.create(this, spanName);
}

@Override
public BinaryFormat<SpanContext> getBinaryFormat() {
return BINARY_FORMAT;
}

@Override
public HttpTextFormat<SpanContext> getHttpTextFormat() {
return HTTP_TEXT_FORMAT;
Expand Down
51 changes: 0 additions & 51 deletions api/src/main/java/io/opentelemetry/trace/Tracer.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import com.google.errorprone.annotations.MustBeClosed;
import io.opentelemetry.context.Scope;
import io.opentelemetry.context.propagation.BinaryFormat;
import io.opentelemetry.context.propagation.HttpTextFormat;
import io.opentelemetry.trace.propagation.HttpTraceContext;
import javax.annotation.concurrent.ThreadSafe;
Expand Down Expand Up @@ -154,56 +153,6 @@ public interface Tracer {
*/
Span.Builder spanBuilder(String spanName);

/**
* Returns the {@link BinaryFormat} for this tracer implementation.
*
* <p>If no tracer implementation is provided, this defaults to the W3C Trace Context binary
* format. For more details see <a href="https://w3c.github.io/trace-context-binary/">W3C Trace
* Context binary protocol</a>.
*
* <p>Example of usage on the client:
*
* <pre>{@code
* private static final Tracer tracer = OpenTelemetry.getTracer();
* private static final BinaryFormat binaryFormat = tracer.getBinaryFormat();
* void onSendRequest() {
* Span span = tracer.spanBuilder("MyRequest").setSpanKind(Span.Kind.CLIENT).startSpan();
* try (Scope ss = tracer.withSpan(span)) {
* byte[] binaryValue = binaryFormat.toByteArray(tracer.getCurrentContext().context());
* // Send the request including the binaryValue and wait for the response.
* } finally {
* span.end();
* }
* }
* }</pre>
*
* <p>Example of usage on the server:
*
* <pre>{@code
* private static final Tracer tracer = OpenTelemetry.getTracer();
* private static final BinaryFormat binaryFormat = tracer.getBinaryFormat();
* void onRequestReceived() {
* // Get the binaryValue from the request.
* SpanContext spanContext = SpanContext.INVALID;
* if (binaryValue != null) {
* spanContext = binaryFormat.fromByteArray(binaryValue);
* }
* Span span = tracer.spanBuilder("MyRequest")
* .setParent(spanContext)
* .setSpanKind(Span.Kind.SERVER).startSpan();
* try (Scope ss = tracer.withSpan(span)) {
* // Handle request and send response back.
* } finally {
* span.end();
* }
* }
* }</pre>
*
* @return the {@code BinaryFormat} for this implementation.
* @since 0.1.0
*/
BinaryFormat<SpanContext> getBinaryFormat();

/**
* Returns the {@link HttpTextFormat} for this tracer implementation.
*
Expand Down

This file was deleted.

13 changes: 0 additions & 13 deletions api/src/test/java/io/opentelemetry/OpenTelemetryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import static org.junit.Assert.assertTrue;

import io.opentelemetry.context.Scope;
import io.opentelemetry.context.propagation.BinaryFormat;
import io.opentelemetry.context.propagation.HttpTextFormat;
import io.opentelemetry.correlationcontext.CorrelationContext;
import io.opentelemetry.correlationcontext.CorrelationContextManager;
Expand Down Expand Up @@ -268,12 +267,6 @@ public Span.Builder spanBuilder(String spanName) {
return null;
}

@Nullable
@Override
public BinaryFormat<SpanContext> getBinaryFormat() {
return null;
}

@Nullable
@Override
public HttpTextFormat<SpanContext> getHttpTextFormat() {
Expand Down Expand Up @@ -406,12 +399,6 @@ public Scope withContext(CorrelationContext distContext) {
return null;
}

@Nullable
@Override
public BinaryFormat<CorrelationContext> getBinaryFormat() {
return null;
}

@Nullable
@Override
public HttpTextFormat<CorrelationContext> getHttpTextFormat() {
Expand Down
Loading