Remove remaining 0.14.0 deprecated stuff. (#2544)
This commit is contained in:
parent
6dc33fe634
commit
adbed0c0fd
|
|
@ -11,7 +11,6 @@ import io.opentelemetry.api.trace.TracerProvider;
|
|||
import io.opentelemetry.context.propagation.ContextPropagators;
|
||||
|
||||
/** Builder class for {@link DefaultOpenTelemetry}. */
|
||||
@SuppressWarnings("deprecation") // Remove after deleting OpenTelemetry SPI
|
||||
public final class DefaultOpenTelemetryBuilder {
|
||||
private ContextPropagators propagators = ContextPropagators.noop();
|
||||
private TracerProvider tracerProvider = TracerProvider.getDefault();
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import javax.annotation.Nullable;
|
|||
* @see TracerProvider
|
||||
* @see ContextPropagators
|
||||
*/
|
||||
@SuppressWarnings("deprecation") // Remove after deleting OpenTelemetry SPI
|
||||
public final class GlobalOpenTelemetry {
|
||||
|
||||
private static final OpenTelemetry NOOP = DefaultOpenTelemetry.builder().build();
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import org.junit.jupiter.api.AfterEach;
|
|||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@SuppressWarnings("deprecation") // Remove after deleting OpenTelemetry SPI
|
||||
class OpenTelemetryTest {
|
||||
|
||||
@BeforeAll
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import org.mockito.Mock;
|
|||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@SuppressWarnings("deprecation") // we're testing deprecated stuff in here.
|
||||
class MultiTextMapPropagatorTest {
|
||||
|
||||
@Mock private TextMapPropagator propagator1;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import io.opentelemetry.api.trace.SpanId;
|
|||
import io.opentelemetry.api.trace.StatusCode;
|
||||
import io.opentelemetry.api.trace.TraceId;
|
||||
import io.opentelemetry.exporter.jaeger.proto.api_v2.Model;
|
||||
import io.opentelemetry.sdk.extension.otproto.TraceProtoUtils;
|
||||
import io.opentelemetry.sdk.trace.data.EventData;
|
||||
import io.opentelemetry.sdk.trace.data.LinkData;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData;
|
||||
|
|
@ -63,7 +62,6 @@ final class Adapter {
|
|||
* @param span the span to be converted
|
||||
* @return the Jaeger span
|
||||
*/
|
||||
@SuppressWarnings("deprecation") // Remove after TraceProtoUtils made package-private
|
||||
static Model.Span toJaeger(SpanData span) {
|
||||
Model.Span.Builder target = Model.Span.newBuilder();
|
||||
|
||||
|
|
@ -83,8 +81,8 @@ final class Adapter {
|
|||
if (span.getParentSpanContext().isValid()) {
|
||||
target.addReferences(
|
||||
Model.SpanRef.newBuilder()
|
||||
.setTraceId(TraceProtoUtils.toProtoTraceId(span.getTraceId()))
|
||||
.setSpanId(TraceProtoUtils.toProtoSpanId(span.getParentSpanId()))
|
||||
.setTraceId(ByteString.copyFrom(TraceId.bytesFromHex(span.getTraceId(), 0)))
|
||||
.setSpanId(ByteString.copyFrom(SpanId.bytesFromHex(span.getParentSpanId(), 0)))
|
||||
.setRefType(Model.SpanRefType.CHILD_OF));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import java.util.logging.Logger;
|
|||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@SuppressWarnings("deprecation") // Remove after StringUtils is made package-private
|
||||
final class B3PropagatorExtractorMultipleHeaders implements B3PropagatorExtractor {
|
||||
private static final Logger logger =
|
||||
Logger.getLogger(B3PropagatorExtractorMultipleHeaders.class.getName());
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import java.util.logging.Logger;
|
|||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@SuppressWarnings("deprecation") // Remove after StringUtils is made package-private
|
||||
final class B3PropagatorExtractorSingleHeader implements B3PropagatorExtractor {
|
||||
private static final Logger logger =
|
||||
Logger.getLogger(B3PropagatorExtractorSingleHeader.class.getName());
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import javax.annotation.concurrent.Immutable;
|
|||
* B3Propagator.
|
||||
*/
|
||||
@Immutable
|
||||
@SuppressWarnings("deprecation") // Remove after StringUtils is made package-private
|
||||
final class Common {
|
||||
private static final Logger logger = Logger.getLogger(Common.class.getName());
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ import javax.annotation.concurrent.Immutable;
|
|||
* Format</a>.
|
||||
*/
|
||||
@Immutable
|
||||
@SuppressWarnings("deprecation") // Remove after StringUtils is made package-private
|
||||
public final class JaegerPropagator implements TextMapPropagator {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(JaegerPropagator.class.getName());
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import javax.annotation.concurrent.Immutable;
|
|||
* TextMapPropagator</a>.
|
||||
*/
|
||||
@Immutable
|
||||
@SuppressWarnings("deprecation") // Remove after StringUtils is made package-private
|
||||
public final class OtTracerPropagator implements TextMapPropagator {
|
||||
|
||||
static final String TRACE_ID_HEADER = "ot-tracer-traceid";
|
||||
|
|
|
|||
|
|
@ -14,14 +14,9 @@ package io.opentelemetry.extension.trace.propagation;
|
|||
import java.util.Objects;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
/**
|
||||
* Utilities for working with strings.
|
||||
*
|
||||
* @deprecated Will be removed without a replacement
|
||||
*/
|
||||
/** Utilities for working with strings. */
|
||||
@Immutable
|
||||
@Deprecated
|
||||
public final class StringUtils {
|
||||
final class StringUtils {
|
||||
|
||||
/**
|
||||
* Returns a string, of length at least {@code minLength}, consisting of {@code string} prepended
|
||||
|
|
@ -43,9 +38,7 @@ public final class StringUtils {
|
|||
* @param padChar the character to insert at the beginning of the result until the minimum length
|
||||
* is reached
|
||||
* @return the padded string
|
||||
* @deprecated Will be removed without a replacement
|
||||
*/
|
||||
@Deprecated
|
||||
public static String padStart(String string, int minLength, char padChar) {
|
||||
Objects.requireNonNull(string);
|
||||
if (string.length() >= minLength) {
|
||||
|
|
@ -67,9 +60,7 @@ public final class StringUtils {
|
|||
*
|
||||
* @param string a string reference to check
|
||||
* @return {@code true} if the string is null or is the empty string
|
||||
* @deprecated Will be removed without a replacement
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isNullOrEmpty(String string) {
|
||||
return string == null || string.isEmpty();
|
||||
}
|
||||
|
|
@ -81,9 +72,7 @@ public final class StringUtils {
|
|||
* @param minLength the minimum length the resulting padded string must have. Can be zero or
|
||||
* negative, in which case the input string is always returned.
|
||||
* @return the padded string
|
||||
* @deprecated Will be removed without a replacement
|
||||
*/
|
||||
@Deprecated
|
||||
public static String padLeft(String value, int minLength) {
|
||||
return padStart(value, minLength, '0');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,149 +0,0 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.extension.trace.propagation;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.opentelemetry.api.trace.Span;
|
||||
import io.opentelemetry.context.Context;
|
||||
import io.opentelemetry.context.propagation.TextMapPropagator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
/**
|
||||
* A propagator designed to inject and extract multiple trace {@code TextMapPropagator} propagators,
|
||||
* intended for backwards compatibility with existing services using different formats. It works in
|
||||
* a stack-fashion, starting with the last registered propagator, to the first one.
|
||||
*
|
||||
* <p>The propagation fields retrieved from all registered propagators are de-duplicated.
|
||||
*
|
||||
* <p>Upon injection, this propagator invokes {@code TextMapPropagator#inject()} for every
|
||||
* registered trace propagator. This will result in the carrier containing all the registered
|
||||
* formats.
|
||||
*
|
||||
* <p>Upon extraction, this propagator invokes {@code TextMapPropagator#extract()} for every
|
||||
* registered trace propagator, returning immediately when a successful extraction happened.
|
||||
*
|
||||
* <pre>{@code
|
||||
* TextMapPropagator traceFormats = TraceMultiPropagator.create(
|
||||
* new HttpTraceContext(), new JaegerPropagator(), new MyCustomTracePropagator())
|
||||
* // Register it in the global propagators:
|
||||
* OpenTelemetry.setPropagators(
|
||||
* DefaultContextPropagators.builder()
|
||||
* .addTextMapPropagator(traceFormats)
|
||||
* .build());
|
||||
* ...
|
||||
* // Extraction will be performed in reverse order, i.e. starting with the last
|
||||
* // registered propagator (HttpTraceContext in this example).
|
||||
* Context context = OpenTelemetry.getPropagators().getTextMapPropagator()
|
||||
* .extract(context, carrier, carrierGetter);
|
||||
* }</pre>
|
||||
*
|
||||
* <p>This class is @deprecated and will be removed in 0.14.0. Users should migrate to the
|
||||
* MultiTextMapPropagator in the api.
|
||||
*
|
||||
* @deprecated Use {@link TextMapPropagator#composite}
|
||||
*/
|
||||
@Immutable
|
||||
@Deprecated
|
||||
public final class TraceMultiPropagator implements TextMapPropagator {
|
||||
|
||||
/** Returns a {@link TraceMultiPropagator} for the given {@code propagators}. */
|
||||
public static TextMapPropagator create(TextMapPropagator... propagators) {
|
||||
return create(Arrays.asList(propagators));
|
||||
}
|
||||
|
||||
/** Returns a {@link TraceMultiPropagator} for the given {@code propagators}. */
|
||||
public static TextMapPropagator create(Iterable<TextMapPropagator> propagators) {
|
||||
List<TextMapPropagator> propagatorsList = new ArrayList<>();
|
||||
for (TextMapPropagator propagator : propagators) {
|
||||
requireNonNull(propagator, "propagator");
|
||||
propagatorsList.add(propagator);
|
||||
}
|
||||
if (propagatorsList.isEmpty()) {
|
||||
return TextMapPropagator.noop();
|
||||
}
|
||||
if (propagatorsList.size() == 1) {
|
||||
return propagatorsList.get(0);
|
||||
}
|
||||
return new TraceMultiPropagator(propagatorsList);
|
||||
}
|
||||
|
||||
private final TextMapPropagator[] propagators;
|
||||
private final Collection<String> propagatorsFields;
|
||||
|
||||
private TraceMultiPropagator(List<TextMapPropagator> propagatorList) {
|
||||
this.propagators = new TextMapPropagator[propagatorList.size()];
|
||||
propagatorList.toArray(this.propagators);
|
||||
|
||||
Set<String> fields = new LinkedHashSet<>();
|
||||
for (TextMapPropagator propagator : propagators) {
|
||||
fields.addAll(propagator.fields());
|
||||
}
|
||||
this.propagatorsFields = Collections.unmodifiableList(new ArrayList<>(fields));
|
||||
}
|
||||
|
||||
/**
|
||||
* The propagation fields defined in all the registered propagators. The returned list will be
|
||||
* read-only.
|
||||
*
|
||||
* @return list of fields defined in all the registered propagators.
|
||||
*/
|
||||
@Override
|
||||
public Collection<String> fields() {
|
||||
return propagatorsFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Injects the value downstream invoking all the registered propagators, starting with the last
|
||||
* one.
|
||||
*
|
||||
* @param context the {@code Context} containing the value to be injected.
|
||||
* @param carrier holds propagation fields. For example, an outgoing message or http request.
|
||||
* @param setter invoked for each propagation key to add or remove.
|
||||
* @param <C> carrier of propagation fields, such as an http request
|
||||
*/
|
||||
@Override
|
||||
public <C> void inject(Context context, C carrier, Setter<C> setter) {
|
||||
for (int i = propagators.length - 1; i >= 0; i--) {
|
||||
propagators[i].inject(context, carrier, setter);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the value from upstream invoking all the registered propagators, starting with the
|
||||
* last one. Iterating over the propagators will stop and return immediately upon the first
|
||||
* successful extraction.
|
||||
*
|
||||
* @param context the {@code Context} used to store the extracted value.
|
||||
* @param carrier holds propagation fields. For example, an outgoing message or http request.
|
||||
* @param getter invoked for each propagation key to get.
|
||||
* @param <C> carrier of propagation fields, such as an http request.
|
||||
* @return the {@code Context} containing the extracted value.
|
||||
*/
|
||||
@Override
|
||||
public <C> Context extract(Context context, @Nullable C carrier, Getter<C> getter) {
|
||||
for (int i = propagators.length - 1; i >= 0; i--) {
|
||||
context = propagators[i].extract(context, carrier, getter);
|
||||
if (isSpanContextExtracted(context)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
private static boolean isSpanContextExtracted(Context context) {
|
||||
return Span.fromContextOrNull(context) != null;
|
||||
}
|
||||
}
|
||||
|
|
@ -26,7 +26,6 @@ import javax.annotation.Nullable;
|
|||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link B3Propagator}. */
|
||||
@SuppressWarnings("deprecation") // Remove after StringUtils is made package-private
|
||||
class B3PropagatorTest {
|
||||
|
||||
private static final TraceState TRACE_STATE_DEFAULT = TraceState.builder().build();
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
|||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@SuppressWarnings("deprecation") // Remove after StringUtils is made package-private
|
||||
class StringUtilsTest {
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -1,192 +0,0 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.extension.trace.propagation;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
|
||||
import io.opentelemetry.api.trace.Span;
|
||||
import io.opentelemetry.api.trace.SpanContext;
|
||||
import io.opentelemetry.api.trace.SpanId;
|
||||
import io.opentelemetry.api.trace.TraceFlags;
|
||||
import io.opentelemetry.api.trace.TraceId;
|
||||
import io.opentelemetry.api.trace.TraceState;
|
||||
import io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator;
|
||||
import io.opentelemetry.context.Context;
|
||||
import io.opentelemetry.context.propagation.TextMapPropagator;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@SuppressWarnings("deprecation") // the class under test will go away soon
|
||||
class TraceMultiPropagatorTest {
|
||||
private static final TextMapPropagator PROPAGATOR1 = B3Propagator.getInstance();
|
||||
private static final TextMapPropagator PROPAGATOR2 =
|
||||
B3Propagator.builder().injectMultipleHeaders().build();
|
||||
private static final TextMapPropagator PROPAGATOR3 = W3CTraceContextPropagator.getInstance();
|
||||
|
||||
private static final TextMapPropagator.Getter<Map<String, String>> getter =
|
||||
new TextMapPropagator.Getter<Map<String, String>>() {
|
||||
@Override
|
||||
public Iterable<String> keys(Map<String, String> carrier) {
|
||||
return carrier.keySet();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String get(Map<String, String> carrier, String key) {
|
||||
return carrier.get(key);
|
||||
}
|
||||
};
|
||||
|
||||
private static final Span SPAN =
|
||||
Span.wrap(
|
||||
SpanContext.createFromRemoteParent(
|
||||
TraceId.fromLongs(1245, 67890),
|
||||
SpanId.fromLong(12345),
|
||||
TraceFlags.getDefault(),
|
||||
TraceState.getDefault()));
|
||||
|
||||
@Test
|
||||
void addPropagator_null() {
|
||||
assertThatThrownBy(() -> TraceMultiPropagator.create((TextMapPropagator) null))
|
||||
.isInstanceOf(NullPointerException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void fields() {
|
||||
TextMapPropagator prop =
|
||||
TraceMultiPropagator.create(
|
||||
new EmptyPropagator("foo", "bar"), new EmptyPropagator("hello", "world"));
|
||||
|
||||
Collection<String> fields = prop.fields();
|
||||
assertThat(fields).containsExactly("foo", "bar", "hello", "world");
|
||||
}
|
||||
|
||||
@Test
|
||||
void fields_duplicates() {
|
||||
TextMapPropagator prop =
|
||||
TraceMultiPropagator.create(
|
||||
new EmptyPropagator("foo", "bar", "foo"),
|
||||
new EmptyPropagator("hello", "world", "world", "bar"));
|
||||
|
||||
Collection<String> fields = prop.fields();
|
||||
assertThat(fields).containsExactly("foo", "bar", "hello", "world");
|
||||
}
|
||||
|
||||
@Test
|
||||
void fields_readOnly() {
|
||||
TextMapPropagator prop =
|
||||
TraceMultiPropagator.create(
|
||||
new EmptyPropagator("foo", "bar"), new EmptyPropagator("hello", "world"));
|
||||
|
||||
Collection<String> fields = prop.fields();
|
||||
assertThatThrownBy(() -> fields.add("hi")).isInstanceOf(UnsupportedOperationException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void inject_noPropagators() {
|
||||
TextMapPropagator prop = TraceMultiPropagator.create();
|
||||
Map<String, String> carrier = new HashMap<>();
|
||||
|
||||
Context context = Context.current();
|
||||
prop.inject(context, carrier, Map::put);
|
||||
assertThat(carrier).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void inject_allFormats() {
|
||||
TextMapPropagator prop = TraceMultiPropagator.create(PROPAGATOR1, PROPAGATOR2, PROPAGATOR3);
|
||||
|
||||
Map<String, String> carrier = new HashMap<>();
|
||||
prop.inject(Context.current().with(SPAN), carrier, Map::put);
|
||||
|
||||
assertThat(
|
||||
Span.fromContext(PROPAGATOR1.extract(Context.current(), carrier, getter))
|
||||
.getSpanContext())
|
||||
.isEqualTo(SPAN.getSpanContext());
|
||||
assertThat(
|
||||
Span.fromContext(PROPAGATOR2.extract(Context.current(), carrier, getter))
|
||||
.getSpanContext())
|
||||
.isEqualTo(SPAN.getSpanContext());
|
||||
assertThat(
|
||||
Span.fromContext(PROPAGATOR3.extract(Context.current(), carrier, getter))
|
||||
.getSpanContext())
|
||||
.isEqualTo(SPAN.getSpanContext());
|
||||
}
|
||||
|
||||
@Test
|
||||
void extract_noPropagators() {
|
||||
TextMapPropagator prop = TraceMultiPropagator.create();
|
||||
Map<String, String> carrier = new HashMap<>();
|
||||
|
||||
Context context = Context.current();
|
||||
Context resContext = prop.extract(context, carrier, getter);
|
||||
assertThat(context).isSameAs(resContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
void extract_found() {
|
||||
TextMapPropagator prop = TraceMultiPropagator.create(PROPAGATOR1, PROPAGATOR2, PROPAGATOR3);
|
||||
|
||||
Map<String, String> carrier = new HashMap<>();
|
||||
PROPAGATOR2.inject(Context.current().with(SPAN), carrier, Map::put);
|
||||
assertThat(Span.fromContext(prop.extract(Context.current(), carrier, getter)).getSpanContext())
|
||||
.isEqualTo(SPAN.getSpanContext());
|
||||
}
|
||||
|
||||
@Test
|
||||
void extract_notFound() {
|
||||
TextMapPropagator prop = TraceMultiPropagator.create(PROPAGATOR1);
|
||||
|
||||
Map<String, String> carrier = new HashMap<>();
|
||||
PROPAGATOR3.inject(Context.current().with(SPAN), carrier, Map::put);
|
||||
assertThat(prop.extract(Context.current(), carrier, getter)).isEqualTo(Context.current());
|
||||
}
|
||||
|
||||
@Test
|
||||
void extract_stopWhenFound() {
|
||||
TextMapPropagator mockPropagator = Mockito.mock(TextMapPropagator.class);
|
||||
TextMapPropagator prop = TraceMultiPropagator.create(mockPropagator, PROPAGATOR3);
|
||||
|
||||
Map<String, String> carrier = new HashMap<>();
|
||||
PROPAGATOR3.inject(Context.current().with(SPAN), carrier, Map::put);
|
||||
assertThat(Span.fromContext(prop.extract(Context.current(), carrier, getter)).getSpanContext())
|
||||
.isEqualTo(SPAN.getSpanContext());
|
||||
verify(mockPropagator).fields();
|
||||
verifyNoMoreInteractions(mockPropagator);
|
||||
}
|
||||
|
||||
private static class EmptyPropagator implements TextMapPropagator {
|
||||
Collection<String> fields;
|
||||
|
||||
public EmptyPropagator(String... fields) {
|
||||
this.fields = Arrays.asList(fields);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> fields() {
|
||||
return fields;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <C> void inject(Context context, C carrier, Setter<C> c) {}
|
||||
|
||||
@Override
|
||||
public <C> Context extract(Context context, C carrier, Getter<C> c) {
|
||||
return context;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -51,11 +51,5 @@ public final class AwsXrayIdGenerator implements IdGenerator {
|
|||
return TraceId.fromLongs(timestampSecs << 32 | hiRandom, lowRandom);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@link AwsXrayIdGenerator}.
|
||||
*
|
||||
* @deprecated Use {@link #getInstance()}
|
||||
*/
|
||||
@Deprecated
|
||||
public AwsXrayIdGenerator() {}
|
||||
private AwsXrayIdGenerator() {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,6 @@ public final class SpanAdapter {
|
|||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation") // Remove after TraceProtoUtils made package-private
|
||||
static Span toProtoSpan(SpanData spanData) {
|
||||
final Span.Builder builder = Span.newBuilder();
|
||||
builder.setTraceId(TraceProtoUtils.toProtoTraceId(spanData.getTraceId()));
|
||||
|
|
@ -142,7 +141,6 @@ public final class SpanAdapter {
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation") // Remove after TraceProtoUtils made package-private
|
||||
static Span.Link toProtoSpanLink(LinkData link) {
|
||||
final Span.Link.Builder builder = Span.Link.newBuilder();
|
||||
builder.setTraceId(
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import io.opentelemetry.sdk.trace.config.TraceConfig;
|
|||
import io.opentelemetry.sdk.trace.samplers.Sampler;
|
||||
|
||||
/** Utilities for converting various objects to protobuf representations. */
|
||||
public final class TraceProtoUtils {
|
||||
final class TraceProtoUtils {
|
||||
private TraceProtoUtils() {}
|
||||
|
||||
/**
|
||||
|
|
@ -21,9 +21,7 @@ public final class TraceProtoUtils {
|
|||
*
|
||||
* @param spanId the spanId to convert.
|
||||
* @return a ByteString representation.
|
||||
* @deprecated Will be removed without replacement
|
||||
*/
|
||||
@Deprecated
|
||||
public static ByteString toProtoSpanId(String spanId) {
|
||||
return ByteString.copyFrom(SpanId.bytesFromHex(spanId, 0));
|
||||
}
|
||||
|
|
@ -33,9 +31,7 @@ public final class TraceProtoUtils {
|
|||
*
|
||||
* @param traceId the traceId to convert.
|
||||
* @return a ByteString representation.
|
||||
* @deprecated Will be removed without replacement
|
||||
*/
|
||||
@Deprecated
|
||||
public static ByteString toProtoTraceId(String traceId) {
|
||||
return ByteString.copyFrom(TraceId.bytesFromHex(traceId, 0));
|
||||
}
|
||||
|
|
@ -45,9 +41,7 @@ public final class TraceProtoUtils {
|
|||
*
|
||||
* @param traceConfigProto proto format {@code TraceConfig}.
|
||||
* @return a {@code TraceConfig}.
|
||||
* @deprecated Will be removed without replacement
|
||||
*/
|
||||
@Deprecated
|
||||
public static TraceConfig traceConfigFromProto(
|
||||
io.opentelemetry.proto.trace.v1.TraceConfig traceConfigProto) {
|
||||
return TraceConfig.builder()
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import io.opentelemetry.sdk.trace.config.TraceConfig;
|
|||
import io.opentelemetry.sdk.trace.samplers.Sampler;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@SuppressWarnings("deprecation") // Remove after TraceProtoUtils made package-private
|
||||
class TraceProtoUtilsTest {
|
||||
private static final io.opentelemetry.proto.trace.v1.TraceConfig TRACE_CONFIG_PROTO =
|
||||
io.opentelemetry.proto.trace.v1.TraceConfig.newBuilder()
|
||||
|
|
|
|||
|
|
@ -57,20 +57,6 @@ public final class IntervalMetricReader {
|
|||
return new IntervalMetricReaderBuilder(InternalState.builder());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link IntervalMetricReaderBuilder} for {@link IntervalMetricReader} reading the
|
||||
* configuration values from the environment and from system properties. System properties
|
||||
* override values defined in the environment. If a configuration value is missing, it uses the
|
||||
* default value.
|
||||
*
|
||||
* @return a new {@link IntervalMetricReaderBuilder} for {@link IntervalMetricReader}.
|
||||
* @deprecated Use {@link #builder()}
|
||||
*/
|
||||
@Deprecated
|
||||
public static IntervalMetricReaderBuilder builderFromDefaultSources() {
|
||||
return builder();
|
||||
}
|
||||
|
||||
@SuppressWarnings("FutureReturnValueIgnored")
|
||||
IntervalMetricReader(InternalState internalState) {
|
||||
this.exporter = new Exporter(internalState);
|
||||
|
|
|
|||
|
|
@ -51,28 +51,4 @@ public interface StatusData {
|
|||
*/
|
||||
@Nullable
|
||||
String getDescription();
|
||||
|
||||
/**
|
||||
* Returns {@code true} if this {@code Status} is UNSET, i.e., not an error.
|
||||
*
|
||||
* @return {@code true} if this {@code Status} is UNSET.
|
||||
* @deprecated Compare {@link #getStatusCode()} with {@link StatusCode#UNSET}
|
||||
*/
|
||||
// TODO: Consider to remove this in a future PR. Avoid too many changes in the initial PR.
|
||||
@Deprecated
|
||||
default boolean isUnset() {
|
||||
return StatusCode.UNSET == getStatusCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if this {@code Status} is ok, i.e., status is not set, or has been
|
||||
* overridden to be ok by an operator.
|
||||
*
|
||||
* @return {@code true} if this {@code Status} is OK or UNSET.
|
||||
* @deprecated Compare {@link #getStatusCode()} with {@link StatusCode#ERROR}
|
||||
*/
|
||||
@Deprecated
|
||||
default boolean isOk() {
|
||||
return isUnset() || StatusCode.OK == getStatusCode();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,22 +82,6 @@ public final class BatchSpanProcessorBuilder {
|
|||
return setScheduleDelay(delay.toNanos(), TimeUnit.NANOSECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the delay interval between two consecutive exports. The actual interval may be shorter if
|
||||
* the batch size is getting larger than {@code maxQueuedSpans / 2}.
|
||||
*
|
||||
* <p>Default value is {@code 5000}ms.
|
||||
*
|
||||
* @param scheduleDelayMillis the delay interval between two consecutive exports.
|
||||
* @return this.
|
||||
* @see BatchSpanProcessorBuilder#DEFAULT_SCHEDULE_DELAY_MILLIS
|
||||
* @deprecated Use {@link #setScheduleDelay(long, TimeUnit)}
|
||||
*/
|
||||
@Deprecated
|
||||
public BatchSpanProcessorBuilder setScheduleDelayMillis(long scheduleDelayMillis) {
|
||||
return setScheduleDelay(Duration.ofMillis(scheduleDelayMillis));
|
||||
}
|
||||
|
||||
// Visible for testing
|
||||
long getScheduleDelayNanos() {
|
||||
return scheduleDelayNanos;
|
||||
|
|
@ -123,21 +107,6 @@ public final class BatchSpanProcessorBuilder {
|
|||
return setExporterTimeout(timeout.toNanos(), TimeUnit.NANOSECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum time an exporter will be allowed to run before being cancelled.
|
||||
*
|
||||
* <p>Default value is {@code 30000}ms
|
||||
*
|
||||
* @param exporterTimeoutMillis the timeout for exports in milliseconds.
|
||||
* @return this
|
||||
* @see BatchSpanProcessorBuilder#DEFAULT_EXPORT_TIMEOUT_MILLIS
|
||||
* @deprecated Use {@link #setExporterTimeout(long, TimeUnit)}
|
||||
*/
|
||||
@Deprecated
|
||||
public BatchSpanProcessorBuilder setExporterTimeoutMillis(int exporterTimeoutMillis) {
|
||||
return setExporterTimeout(Duration.ofMillis(exporterTimeoutMillis));
|
||||
}
|
||||
|
||||
// Visible for testing
|
||||
long getExporterTimeoutNanos() {
|
||||
return exporterTimeoutNanos;
|
||||
|
|
|
|||
|
|
@ -44,10 +44,7 @@ import org.mockito.quality.Strictness;
|
|||
/** Unit tests for {@link SimpleSpanProcessor}. */
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
// TODO(anuraaga): Remove after builder() is removed.
|
||||
@SuppressWarnings("deprecation")
|
||||
class SimpleSpanProcessorTest {
|
||||
private static final long MAX_SCHEDULE_DELAY_MILLIS = 500;
|
||||
private static final String SPAN_NAME = "MySpanName";
|
||||
@Mock private ReadableSpan readableSpan;
|
||||
@Mock private ReadWriteSpan readWriteSpan;
|
||||
|
|
@ -127,10 +124,7 @@ class SimpleSpanProcessorTest {
|
|||
new AtomicReference<>(TraceConfig.builder().setSampler(Sampler.alwaysOff()).build());
|
||||
SdkTracerProvider sdkTracerProvider =
|
||||
SdkTracerProvider.builder()
|
||||
.addSpanProcessor(
|
||||
BatchSpanProcessor.builder(waitingSpanExporter)
|
||||
.setScheduleDelayMillis(MAX_SCHEDULE_DELAY_MILLIS)
|
||||
.build())
|
||||
.addSpanProcessor(SimpleSpanProcessor.create(waitingSpanExporter))
|
||||
.setTraceConfig(traceConfig::get)
|
||||
.build();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue