From 029cf8c46e7fa756efe41129d6ec103de7bfdece Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Fri, 1 Sep 2023 17:04:55 -0400 Subject: [PATCH] [Tracing Framework] Add proper API annotations Signed-off-by: Andriy Redko --- libs/telemetry/build.gradle | 2 ++ .../src/main/java/org/opensearch/telemetry/Telemetry.java | 4 +++- .../org/opensearch/telemetry/metrics/MetricsTelemetry.java | 5 +++++ .../org/opensearch/telemetry/tracing/AbstractSpan.java | 3 +++ .../opensearch/telemetry/tracing/DefaultScopedSpan.java | 5 ++++- .../org/opensearch/telemetry/tracing/DefaultSpanScope.java | 7 ++++++- .../org/opensearch/telemetry/tracing/DefaultTracer.java | 3 +++ .../java/org/opensearch/telemetry/tracing/ScopedSpan.java | 4 ++++ .../main/java/org/opensearch/telemetry/tracing/Span.java | 5 ++++- .../java/org/opensearch/telemetry/tracing/SpanContext.java | 5 +++++ .../opensearch/telemetry/tracing/SpanCreationContext.java | 4 ++++ .../org/opensearch/telemetry/tracing/SpanReference.java | 3 +++ .../java/org/opensearch/telemetry/tracing/SpanScope.java | 4 ++++ .../main/java/org/opensearch/telemetry/tracing/Tracer.java | 4 ++++ .../opensearch/telemetry/tracing/TracerContextStorage.java | 3 +++ .../telemetry/tracing/TracingContextPropagator.java | 5 ++++- .../org/opensearch/telemetry/tracing/TracingTelemetry.java | 4 +++- .../telemetry/tracing/attributes/Attributes.java | 5 +++++ .../telemetry/tracing/attributes/package-info.java | 2 +- .../org/opensearch/telemetry/tracing/http/HttpTracer.java | 4 ++++ .../opensearch/telemetry/tracing/noop/NoopScopedSpan.java | 2 ++ .../org/opensearch/telemetry/tracing/noop/NoopSpan.java | 4 ++++ .../opensearch/telemetry/tracing/noop/NoopSpanScope.java | 4 ++++ .../org/opensearch/telemetry/tracing/noop/NoopTracer.java | 2 ++ .../java/org/opensearch/telemetry/tracing/OTelSpan.java | 6 +++--- .../telemetry/tracing/sampler/ProbabilisticSampler.java | 4 ++-- .../main/java/org/opensearch/plugins/TelemetryPlugin.java | 4 ++++ .../java/org/opensearch/telemetry/TelemetrySettings.java | 6 +++++- .../org/opensearch/telemetry/tracing/AttributeNames.java | 7 ++++++- .../opensearch/telemetry/tracing/NoopTracerFactory.java | 2 ++ .../java/org/opensearch/telemetry/tracing/SpanBuilder.java | 4 ++++ .../tracing/ThreadContextBasedTracerContextStorage.java | 2 ++ .../org/opensearch/telemetry/tracing/TracerFactory.java | 4 ++++ .../org/opensearch/telemetry/tracing/WrappedTracer.java | 2 ++ 34 files changed, 120 insertions(+), 14 deletions(-) diff --git a/libs/telemetry/build.gradle b/libs/telemetry/build.gradle index ce94698836b4f..f8499482a6093 100644 --- a/libs/telemetry/build.gradle +++ b/libs/telemetry/build.gradle @@ -10,6 +10,8 @@ */ dependencies { + api project(':libs:opensearch-common') + testImplementation "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}" testImplementation "junit:junit:${versions.junit}" testImplementation "org.hamcrest:hamcrest:${versions.hamcrest}" diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/Telemetry.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/Telemetry.java index 65c974a0d0c36..0f973f50fc640 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/Telemetry.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/Telemetry.java @@ -8,14 +8,16 @@ package org.opensearch.telemetry; +import org.opensearch.common.annotation.ExperimentalApi; import org.opensearch.telemetry.metrics.MetricsTelemetry; import org.opensearch.telemetry.tracing.TracingTelemetry; /** * Interface defining telemetry * - * @opensearch.internal + * @opensearch.experimental */ +@ExperimentalApi public interface Telemetry { /** diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/metrics/MetricsTelemetry.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/metrics/MetricsTelemetry.java index fa3b7fd192f1a..0bf9482fe58d8 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/metrics/MetricsTelemetry.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/metrics/MetricsTelemetry.java @@ -8,9 +8,14 @@ package org.opensearch.telemetry.metrics; +import org.opensearch.common.annotation.ExperimentalApi; + /** * Interface for metrics telemetry providers + * + * @opensearch.experimental */ +@ExperimentalApi public interface MetricsTelemetry { } diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/AbstractSpan.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/AbstractSpan.java index 150a32b14d0f8..6919995e0ef65 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/AbstractSpan.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/AbstractSpan.java @@ -8,11 +8,14 @@ package org.opensearch.telemetry.tracing; +import org.opensearch.common.annotation.InternalApi; + /** * Base span * * @opensearch.internal */ +@InternalApi public abstract class AbstractSpan implements Span { /** diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/DefaultScopedSpan.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/DefaultScopedSpan.java index 87802b1f1931d..dc1a775839adb 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/DefaultScopedSpan.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/DefaultScopedSpan.java @@ -8,6 +8,8 @@ package org.opensearch.telemetry.tracing; +import org.opensearch.common.annotation.InternalApi; + import java.util.Objects; /** @@ -15,6 +17,7 @@ * * @opensearch.internal */ +@InternalApi final class DefaultScopedSpan implements ScopedSpan { private final Span span; @@ -73,7 +76,7 @@ public void close() { /** * Returns span. - * @return + * @return the span associated with this scope */ Span getSpan() { return span; diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/DefaultSpanScope.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/DefaultSpanScope.java index 037309da0bc30..a5d515443b54d 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/DefaultSpanScope.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/DefaultSpanScope.java @@ -8,12 +8,17 @@ package org.opensearch.telemetry.tracing; +import org.opensearch.common.annotation.InternalApi; + import java.util.Objects; /** * Default implementation for {@link SpanScope} + * + * @opensearch.internal */ -public class DefaultSpanScope implements SpanScope { +@InternalApi +class DefaultSpanScope implements SpanScope { private final Span span; private final SpanScope previousSpanScope; private static final ThreadLocal spanScopeThreadLocal = new ThreadLocal<>(); diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/DefaultTracer.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/DefaultTracer.java index b75d761fc240c..009cc673058d3 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/DefaultTracer.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/DefaultTracer.java @@ -8,6 +8,7 @@ package org.opensearch.telemetry.tracing; +import org.opensearch.common.annotation.InternalApi; import org.opensearch.telemetry.tracing.attributes.Attributes; import java.io.Closeable; @@ -23,6 +24,7 @@ * * @opensearch.internal */ +@InternalApi class DefaultTracer implements Tracer { static final String THREAD_NAME = "th_name"; @@ -77,6 +79,7 @@ private Span getCurrentSpanInternal() { return tracerContextStorage.get(TracerContextStorage.CURRENT_SPAN); } + @Override public SpanContext getCurrentSpan() { final Span currentSpan = tracerContextStorage.get(TracerContextStorage.CURRENT_SPAN); return (currentSpan == null) ? null : new SpanContext(currentSpan); diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/ScopedSpan.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/ScopedSpan.java index 833a85ef27baf..b320bc415de29 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/ScopedSpan.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/ScopedSpan.java @@ -8,12 +8,16 @@ package org.opensearch.telemetry.tracing; +import org.opensearch.common.annotation.ExperimentalApi; import org.opensearch.telemetry.tracing.noop.NoopScopedSpan; /** * An auto-closeable that represents scoped span. * It provides interface for all the span operations. + * + * @opensearch.experimental */ +@ExperimentalApi public interface ScopedSpan extends AutoCloseable { /** * No-op Scope implementation diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/Span.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/Span.java index 6cb1c8234f3de..00b64492c281e 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/Span.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/Span.java @@ -8,13 +8,16 @@ package org.opensearch.telemetry.tracing; +import org.opensearch.common.annotation.ExperimentalApi; + /** * An interface that represents a tracing span. * Spans are created by the Tracer.startSpan method. * Span must be ended by calling SpanScope.close which internally calls Span's endSpan. * - * @opensearch.internal + * @opensearch.experimental */ +@ExperimentalApi public interface Span { /** diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanContext.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanContext.java index b849869afdc03..f9af611553aff 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanContext.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanContext.java @@ -8,10 +8,15 @@ package org.opensearch.telemetry.tracing; +import org.opensearch.common.annotation.ExperimentalApi; + /** * Wrapped Span will be exposed to the code outside of tracing package for sharing the {@link Span} without having access to * its properties. + * + * @opensearch.experimental */ +@ExperimentalApi public final class SpanContext { private final Span span; diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanCreationContext.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanCreationContext.java index 0f91eb448deb5..10cb665e83b01 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanCreationContext.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanCreationContext.java @@ -8,11 +8,15 @@ package org.opensearch.telemetry.tracing; +import org.opensearch.common.annotation.ExperimentalApi; import org.opensearch.telemetry.tracing.attributes.Attributes; /** * Context for span details. + * + * @opensearch.experimental */ +@ExperimentalApi public final class SpanCreationContext { private final String spanName; private final Attributes attributes; diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanReference.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanReference.java index 180136ecf7a57..945682c3df390 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanReference.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanReference.java @@ -8,11 +8,14 @@ package org.opensearch.telemetry.tracing; +import org.opensearch.common.annotation.InternalApi; + /** * Wrapper class to hold reference of Span * * @opensearch.internal */ +@InternalApi final class SpanReference { private Span span; diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanScope.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanScope.java index 99c27b72fe1c7..8bccd5774a340 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanScope.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanScope.java @@ -8,11 +8,15 @@ package org.opensearch.telemetry.tracing; +import org.opensearch.common.annotation.ExperimentalApi; import org.opensearch.telemetry.tracing.noop.NoopSpanScope; /** * An auto-closeable that represents scope of the span. + * + * @opensearch.experimental */ +@ExperimentalApi public interface SpanScope extends AutoCloseable { /** diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/Tracer.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/Tracer.java index dc247e45d77f6..19ffc68a62df0 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/Tracer.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/Tracer.java @@ -8,6 +8,7 @@ package org.opensearch.telemetry.tracing; +import org.opensearch.common.annotation.ExperimentalApi; import org.opensearch.telemetry.tracing.attributes.Attributes; import org.opensearch.telemetry.tracing.http.HttpTracer; @@ -18,7 +19,10 @@ * It automatically handles the context propagation between threads, tasks, nodes etc. * * All methods on the Tracer object are multi-thread safe. + * + * @opensearch.experimental */ +@ExperimentalApi public interface Tracer extends HttpTracer, Closeable { /** * Starts the {@link Span} with given {@link SpanCreationContext} diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/TracerContextStorage.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/TracerContextStorage.java index d85b404b0ce41..958d054948483 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/TracerContextStorage.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/TracerContextStorage.java @@ -8,6 +8,8 @@ package org.opensearch.telemetry.tracing; +import org.opensearch.common.annotation.InternalApi; + /** * Storage interface used for storing tracing context * @param key type @@ -15,6 +17,7 @@ * * @opensearch.internal */ +@InternalApi public interface TracerContextStorage { /** * Key for storing current span diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/TracingContextPropagator.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/TracingContextPropagator.java index 52e272afcd07f..5fbc5d329e227 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/TracingContextPropagator.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/TracingContextPropagator.java @@ -8,6 +8,8 @@ package org.opensearch.telemetry.tracing; +import org.opensearch.common.annotation.ExperimentalApi; + import java.util.List; import java.util.Map; import java.util.Optional; @@ -16,8 +18,9 @@ /** * Interface defining the tracing related context propagation * - * @opensearch.internal + * @opensearch.experimental */ +@ExperimentalApi public interface TracingContextPropagator { /** diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/TracingTelemetry.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/TracingTelemetry.java index 895e14da69f7f..e1811e85f8890 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/TracingTelemetry.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/TracingTelemetry.java @@ -8,6 +8,7 @@ package org.opensearch.telemetry.tracing; +import org.opensearch.common.annotation.ExperimentalApi; import org.opensearch.telemetry.tracing.attributes.Attributes; import java.io.Closeable; @@ -15,8 +16,9 @@ /** * Interface for tracing telemetry providers * - * @opensearch.internal + * @opensearch.experimental */ +@ExperimentalApi public interface TracingTelemetry extends Closeable { /** diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/attributes/Attributes.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/attributes/Attributes.java index fc002224c08dd..6dcc9c5468b38 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/attributes/Attributes.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/attributes/Attributes.java @@ -8,6 +8,8 @@ package org.opensearch.telemetry.tracing.attributes; +import org.opensearch.common.annotation.ExperimentalApi; + import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -15,7 +17,10 @@ /** * Class to create attributes for a span. + * + * @opensearch.experimental */ +@ExperimentalApi public class Attributes { private final Map attributesMap; /** diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/attributes/package-info.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/attributes/package-info.java index 91d1c3291a4a5..ccd56786f63ef 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/attributes/package-info.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/attributes/package-info.java @@ -7,6 +7,6 @@ */ /** - * Contains No-op implementations + * Contains attributes management */ package org.opensearch.telemetry.tracing.attributes; diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/http/HttpTracer.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/http/HttpTracer.java index 8027291d5480b..cb2bf73775564 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/http/HttpTracer.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/http/HttpTracer.java @@ -8,6 +8,7 @@ package org.opensearch.telemetry.tracing.http; +import org.opensearch.common.annotation.ExperimentalApi; import org.opensearch.telemetry.tracing.Span; import org.opensearch.telemetry.tracing.attributes.Attributes; @@ -19,7 +20,10 @@ * from the HttpRequest header and propagate the span accordingly. * * All methods on the Tracer object are multi-thread safe. + * + * @opensearch.experimental */ +@ExperimentalApi public interface HttpTracer { /** * Start the span with propagating the tracing info from the HttpRequest header. diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/noop/NoopScopedSpan.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/noop/NoopScopedSpan.java index 22ee7e7ccb6fb..fc296d3689645 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/noop/NoopScopedSpan.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/noop/NoopScopedSpan.java @@ -8,6 +8,7 @@ package org.opensearch.telemetry.tracing.noop; +import org.opensearch.common.annotation.InternalApi; import org.opensearch.telemetry.tracing.ScopedSpan; /** @@ -15,6 +16,7 @@ * * @opensearch.internal */ +@InternalApi public final class NoopScopedSpan implements ScopedSpan { /** diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/noop/NoopSpan.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/noop/NoopSpan.java index e053e6576fcea..f41e11017d155 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/noop/NoopSpan.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/noop/NoopSpan.java @@ -8,11 +8,15 @@ package org.opensearch.telemetry.tracing.noop; +import org.opensearch.common.annotation.InternalApi; import org.opensearch.telemetry.tracing.Span; /** * No-op implementation of {@link org.opensearch.telemetry.tracing.Span} + * + * @opensearch.internal */ +@InternalApi public class NoopSpan implements Span { /** diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/noop/NoopSpanScope.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/noop/NoopSpanScope.java index a9b72adeeda0e..bb04a67657d6e 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/noop/NoopSpanScope.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/noop/NoopSpanScope.java @@ -8,12 +8,16 @@ package org.opensearch.telemetry.tracing.noop; +import org.opensearch.common.annotation.InternalApi; import org.opensearch.telemetry.tracing.Span; import org.opensearch.telemetry.tracing.SpanScope; /** * No-op implementation of {@link SpanScope} + * + * @opensearch.internal */ +@InternalApi public class NoopSpanScope implements SpanScope { /** * Constructor. diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/noop/NoopTracer.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/noop/NoopTracer.java index a9eee725b4f1c..96a969369c3a9 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/noop/NoopTracer.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/noop/NoopTracer.java @@ -8,6 +8,7 @@ package org.opensearch.telemetry.tracing.noop; +import org.opensearch.common.annotation.InternalApi; import org.opensearch.telemetry.tracing.ScopedSpan; import org.opensearch.telemetry.tracing.Span; import org.opensearch.telemetry.tracing.SpanContext; @@ -24,6 +25,7 @@ * * @opensearch.internal */ +@InternalApi public class NoopTracer implements Tracer { /** diff --git a/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/tracing/OTelSpan.java b/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/tracing/OTelSpan.java index 7653a56cbb740..8ad03d807d9da 100644 --- a/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/tracing/OTelSpan.java +++ b/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/tracing/OTelSpan.java @@ -21,9 +21,9 @@ class OTelSpan extends AbstractSpan { /** * Constructor - * @param spanName - * @param span - * @param parentSpan + * @param spanName span name + * @param span the delegate span + * @param parentSpan the parent span */ public OTelSpan(String spanName, Span span, org.opensearch.telemetry.tracing.Span parentSpan) { super(spanName, parentSpan); diff --git a/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/tracing/sampler/ProbabilisticSampler.java b/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/tracing/sampler/ProbabilisticSampler.java index cab7b1a4af2e6..774070aa39df6 100644 --- a/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/tracing/sampler/ProbabilisticSampler.java +++ b/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/tracing/sampler/ProbabilisticSampler.java @@ -35,12 +35,12 @@ public class ProbabilisticSampler implements Sampler { */ public ProbabilisticSampler(TelemetrySettings telemetrySettings) { this.telemetrySettings = Objects.requireNonNull(telemetrySettings); - this.samplingRatio = telemetrySettings.getTracerHeadSamplerSamplingRatio(); + this.samplingRatio = telemetrySettings.getSamplingProbability(); this.defaultSampler = Sampler.traceIdRatioBased(samplingRatio); } Sampler getSampler() { - double newSamplingRatio = telemetrySettings.getTracerHeadSamplerSamplingRatio(); + double newSamplingRatio = telemetrySettings.getSamplingProbability(); if (isSamplingRatioChanged(newSamplingRatio)) { synchronized (this) { this.samplingRatio = newSamplingRatio; diff --git a/server/src/main/java/org/opensearch/plugins/TelemetryPlugin.java b/server/src/main/java/org/opensearch/plugins/TelemetryPlugin.java index 66033df394d9f..3fc28713b63d5 100644 --- a/server/src/main/java/org/opensearch/plugins/TelemetryPlugin.java +++ b/server/src/main/java/org/opensearch/plugins/TelemetryPlugin.java @@ -8,6 +8,7 @@ package org.opensearch.plugins; +import org.opensearch.common.annotation.ExperimentalApi; import org.opensearch.telemetry.Telemetry; import org.opensearch.telemetry.TelemetrySettings; @@ -15,7 +16,10 @@ /** * Plugin for extending telemetry related classes + * + * @opensearch.experimental */ +@ExperimentalApi public interface TelemetryPlugin { Optional getTelemetry(TelemetrySettings telemetrySettings); diff --git a/server/src/main/java/org/opensearch/telemetry/TelemetrySettings.java b/server/src/main/java/org/opensearch/telemetry/TelemetrySettings.java index aa11a2879e4d7..dc0b04244296f 100644 --- a/server/src/main/java/org/opensearch/telemetry/TelemetrySettings.java +++ b/server/src/main/java/org/opensearch/telemetry/TelemetrySettings.java @@ -8,13 +8,17 @@ package org.opensearch.telemetry; +import org.opensearch.common.annotation.ExperimentalApi; import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Setting; import org.opensearch.common.settings.Settings; /** * Wrapper class to encapsulate tracing related settings + * + * @opensearch.experimental */ +@ExperimentalApi public class TelemetrySettings { public static final Setting TRACER_ENABLED_SETTING = Setting.boolSetting( "telemetry.tracer.enabled", @@ -65,7 +69,7 @@ public void setSamplingProbability(double samplingProbability) { /** * Get sampling ratio */ - public double getTracerHeadSamplerSamplingRatio() { + public double getSamplingProbability() { return samplingProbability; } } diff --git a/server/src/main/java/org/opensearch/telemetry/tracing/AttributeNames.java b/server/src/main/java/org/opensearch/telemetry/tracing/AttributeNames.java index 073009ce12128..e86b21ae0fd3b 100644 --- a/server/src/main/java/org/opensearch/telemetry/tracing/AttributeNames.java +++ b/server/src/main/java/org/opensearch/telemetry/tracing/AttributeNames.java @@ -8,9 +8,14 @@ package org.opensearch.telemetry.tracing; +import org.opensearch.common.annotation.ExperimentalApi; + /** - * Hold the Attribute names to avoid the duplication and consistensy. + * Hold the Attribute names to avoid the duplication and consistency. + * + * @opensearch.experimental */ +@ExperimentalApi public final class AttributeNames { /** diff --git a/server/src/main/java/org/opensearch/telemetry/tracing/NoopTracerFactory.java b/server/src/main/java/org/opensearch/telemetry/tracing/NoopTracerFactory.java index f82a390dc1754..87762f342a653 100644 --- a/server/src/main/java/org/opensearch/telemetry/tracing/NoopTracerFactory.java +++ b/server/src/main/java/org/opensearch/telemetry/tracing/NoopTracerFactory.java @@ -8,6 +8,7 @@ package org.opensearch.telemetry.tracing; +import org.opensearch.common.annotation.InternalApi; import org.opensearch.telemetry.tracing.noop.NoopTracer; import java.util.Optional; @@ -17,6 +18,7 @@ * * @opensearch.internal */ +@InternalApi public class NoopTracerFactory extends TracerFactory { public NoopTracerFactory() { super(null, Optional.empty(), null); diff --git a/server/src/main/java/org/opensearch/telemetry/tracing/SpanBuilder.java b/server/src/main/java/org/opensearch/telemetry/tracing/SpanBuilder.java index 78924febd3af5..80ac811591198 100644 --- a/server/src/main/java/org/opensearch/telemetry/tracing/SpanBuilder.java +++ b/server/src/main/java/org/opensearch/telemetry/tracing/SpanBuilder.java @@ -8,6 +8,7 @@ package org.opensearch.telemetry.tracing; +import org.opensearch.common.annotation.InternalApi; import org.opensearch.core.common.Strings; import org.opensearch.http.HttpRequest; import org.opensearch.rest.RestRequest; @@ -19,7 +20,10 @@ /** * Utility class, helps in creating the {@link SpanCreationContext} for span. + * + * @opensearch.internal */ +@InternalApi public final class SpanBuilder { private static final List HEADERS_TO_BE_ADDED_AS_ATTRIBUTES = Arrays.asList(AttributeNames.TRACE); diff --git a/server/src/main/java/org/opensearch/telemetry/tracing/ThreadContextBasedTracerContextStorage.java b/server/src/main/java/org/opensearch/telemetry/tracing/ThreadContextBasedTracerContextStorage.java index 8e50dac169efd..d631d6ac01dd0 100644 --- a/server/src/main/java/org/opensearch/telemetry/tracing/ThreadContextBasedTracerContextStorage.java +++ b/server/src/main/java/org/opensearch/telemetry/tracing/ThreadContextBasedTracerContextStorage.java @@ -8,6 +8,7 @@ package org.opensearch.telemetry.tracing; +import org.opensearch.common.annotation.InternalApi; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.common.util.concurrent.ThreadContextStatePropagator; @@ -21,6 +22,7 @@ * * @opensearch.internal */ +@InternalApi public class ThreadContextBasedTracerContextStorage implements TracerContextStorage, ThreadContextStatePropagator { private final ThreadContext threadContext; diff --git a/server/src/main/java/org/opensearch/telemetry/tracing/TracerFactory.java b/server/src/main/java/org/opensearch/telemetry/tracing/TracerFactory.java index d8fe812c82f53..1cb73e0247c3a 100644 --- a/server/src/main/java/org/opensearch/telemetry/tracing/TracerFactory.java +++ b/server/src/main/java/org/opensearch/telemetry/tracing/TracerFactory.java @@ -10,6 +10,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.opensearch.common.annotation.InternalApi; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.telemetry.Telemetry; import org.opensearch.telemetry.TelemetrySettings; @@ -24,7 +25,10 @@ *

* The Tracer singleton object can be retrieved using tracerManager.getTracer(). The TracerManager object * is created during class initialization and cannot subsequently be changed. + * + * @opensearch.internal */ +@InternalApi public class TracerFactory implements Closeable { private static final Logger logger = LogManager.getLogger(TracerFactory.class); diff --git a/server/src/main/java/org/opensearch/telemetry/tracing/WrappedTracer.java b/server/src/main/java/org/opensearch/telemetry/tracing/WrappedTracer.java index 1fb1eed98f5bb..b58bbf08f9f9b 100644 --- a/server/src/main/java/org/opensearch/telemetry/tracing/WrappedTracer.java +++ b/server/src/main/java/org/opensearch/telemetry/tracing/WrappedTracer.java @@ -8,6 +8,7 @@ package org.opensearch.telemetry.tracing; +import org.opensearch.common.annotation.InternalApi; import org.opensearch.telemetry.TelemetrySettings; import org.opensearch.telemetry.tracing.attributes.Attributes; import org.opensearch.telemetry.tracing.noop.NoopTracer; @@ -21,6 +22,7 @@ * * @opensearch.internal */ +@InternalApi final class WrappedTracer implements Tracer { private final Tracer defaultTracer;