Skip to content

Commit

Permalink
Move all public APIs to internal
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-berg committed Apr 18, 2024
1 parent 7a82538 commit 1714387
Show file tree
Hide file tree
Showing 26 changed files with 294 additions and 156 deletions.
19 changes: 1 addition & 18 deletions docs/apidiffs/current_vs_latest/opentelemetry-sdk-common.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,2 @@
Comparing source compatibility of against
+++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.ScopeConfigurator (not serializable)
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
GENERIC TEMPLATES: +++ T:java.lang.Object
+++ NEW INTERFACE: java.util.function.Function
+++ NEW SUPERCLASS: java.lang.Object
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.common.ScopeConfiguratorBuilder<T> builder()
GENERIC TEMPLATES: +++ T:java.lang.Object
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.common.ScopeConfiguratorBuilder<T> toBuilder()
+++ NEW ANNOTATION: java.lang.FunctionalInterface
+++ NEW CLASS: PUBLIC(+) FINAL(+) io.opentelemetry.sdk.common.ScopeConfiguratorBuilder (not serializable)
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
GENERIC TEMPLATES: +++ T:java.lang.Object
+++ NEW SUPERCLASS: java.lang.Object
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.common.ScopeConfiguratorBuilder<T> addCondition(java.util.function.Predicate<io.opentelemetry.sdk.common.InstrumentationScopeInfo>, java.lang.Object)
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.common.ScopeConfigurator<T> build()
+++ NEW METHOD: PUBLIC(+) STATIC(+) java.util.function.Predicate<io.opentelemetry.sdk.common.InstrumentationScopeInfo> nameEquals(java.lang.String)
+++ NEW METHOD: PUBLIC(+) STATIC(+) java.util.function.Predicate<io.opentelemetry.sdk.common.InstrumentationScopeInfo> nameMatchesGlob(java.lang.String)
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.common.ScopeConfiguratorBuilder<T> setDefault(java.lang.Object)
No changes.
13 changes: 1 addition & 12 deletions docs/apidiffs/current_vs_latest/opentelemetry-sdk-logs.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,2 @@
Comparing source compatibility of against
+++ NEW CLASS: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.logs.LoggerConfig (not serializable)
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
+++ NEW SUPERCLASS: java.lang.Object
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.common.ScopeConfiguratorBuilder<io.opentelemetry.sdk.logs.LoggerConfig> configuratorBuilder()
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.logs.LoggerConfig defaultConfig()
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.logs.LoggerConfig disabled()
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.logs.LoggerConfig enabled()
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) boolean isEnabled()
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.logs.SdkLoggerProviderBuilder (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.logs.SdkLoggerProviderBuilder addLoggerConfiguratorCondition(java.util.function.Predicate<io.opentelemetry.sdk.common.InstrumentationScopeInfo>, io.opentelemetry.sdk.logs.LoggerConfig)
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.logs.SdkLoggerProviderBuilder setLoggerConfigurator(io.opentelemetry.sdk.common.ScopeConfigurator<io.opentelemetry.sdk.logs.LoggerConfig>)
No changes.
13 changes: 1 addition & 12 deletions docs/apidiffs/current_vs_latest/opentelemetry-sdk-metrics.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,2 @@
Comparing source compatibility of against
+++ NEW CLASS: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.metrics.MeterConfig (not serializable)
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
+++ NEW SUPERCLASS: java.lang.Object
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.common.ScopeConfiguratorBuilder<io.opentelemetry.sdk.metrics.MeterConfig> configuratorBuilder()
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.metrics.MeterConfig defaultConfig()
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.metrics.MeterConfig disabled()
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.metrics.MeterConfig enabled()
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) boolean isEnabled()
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder addMeterConfiguratorCondition(java.util.function.Predicate<io.opentelemetry.sdk.common.InstrumentationScopeInfo>, io.opentelemetry.sdk.metrics.MeterConfig)
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder setMeterConfigurator(io.opentelemetry.sdk.common.ScopeConfigurator<io.opentelemetry.sdk.metrics.MeterConfig>)
No changes.
12 changes: 0 additions & 12 deletions docs/apidiffs/current_vs_latest/opentelemetry-sdk-trace.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,3 @@ Comparing source compatibility of against
*** MODIFIED INTERFACE: PUBLIC ABSTRACT io.opentelemetry.sdk.trace.ReadableSpan (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.api.common.Attributes getAttributes()
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.trace.SdkTracerProviderBuilder (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.trace.SdkTracerProviderBuilder addTracerConfiguratorCondition(java.util.function.Predicate<io.opentelemetry.sdk.common.InstrumentationScopeInfo>, io.opentelemetry.sdk.trace.TracerConfig)
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.trace.SdkTracerProviderBuilder setTracerConfigurator(io.opentelemetry.sdk.common.ScopeConfigurator<io.opentelemetry.sdk.trace.TracerConfig>)
+++ NEW CLASS: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.trace.TracerConfig (not serializable)
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
+++ NEW SUPERCLASS: java.lang.Object
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.common.ScopeConfiguratorBuilder<io.opentelemetry.sdk.trace.TracerConfig> configuratorBuilder()
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.trace.TracerConfig defaultConfig()
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.trace.TracerConfig disabled()
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.trace.TracerConfig enabled()
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) boolean isEnabled()
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package io.opentelemetry.sdk;

import static io.opentelemetry.sdk.common.ScopeConfiguratorBuilder.nameEquals;
import static io.opentelemetry.sdk.internal.ScopeConfiguratorBuilder.nameEquals;
import static org.assertj.core.api.Assertions.assertThat;

import io.opentelemetry.api.OpenTelemetry;
Expand All @@ -15,20 +15,26 @@
import io.opentelemetry.api.trace.Tracer;
import io.opentelemetry.context.Scope;
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
import io.opentelemetry.sdk.logs.LoggerConfig;
import io.opentelemetry.sdk.logs.SdkLoggerProvider;
import io.opentelemetry.sdk.logs.SdkLoggerProviderBuilder;
import io.opentelemetry.sdk.logs.data.LogRecordData;
import io.opentelemetry.sdk.logs.export.SimpleLogRecordProcessor;
import io.opentelemetry.sdk.metrics.MeterConfig;
import io.opentelemetry.sdk.logs.internal.LoggerConfig;
import io.opentelemetry.sdk.logs.internal.SdkLoggerProviderUtil;
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
import io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder;
import io.opentelemetry.sdk.metrics.data.MetricData;
import io.opentelemetry.sdk.metrics.internal.MeterConfig;
import io.opentelemetry.sdk.metrics.internal.SdkMeterProviderUtil;
import io.opentelemetry.sdk.testing.exporter.InMemoryLogRecordExporter;
import io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader;
import io.opentelemetry.sdk.testing.exporter.InMemorySpanExporter;
import io.opentelemetry.sdk.trace.SdkTracerProvider;
import io.opentelemetry.sdk.trace.TracerConfig;
import io.opentelemetry.sdk.trace.SdkTracerProviderBuilder;
import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor;
import io.opentelemetry.sdk.trace.internal.SdkTracerProviderUtil;
import io.opentelemetry.sdk.trace.internal.TracerConfig;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
Expand All @@ -47,25 +53,27 @@ class ScopeConfiguratorTest {
/** Disable "scopeB". All other scopes are enabled by default. */
@Test
void disableScopeB() {
// Configuration ergonomics will improve after APIs stabilize
SdkTracerProviderBuilder tracerProviderBuilder = SdkTracerProvider.builder();
SdkTracerProviderUtil.addTracerConfiguratorCondition(
tracerProviderBuilder, nameEquals(scopeB.getName()), TracerConfig.disabled());
SdkMeterProviderBuilder meterProviderBuilder = SdkMeterProvider.builder();
SdkMeterProviderUtil.addMeterConfiguratorCondition(
meterProviderBuilder, nameEquals(scopeB.getName()), MeterConfig.disabled());
SdkLoggerProviderBuilder loggerProviderBuilder = SdkLoggerProvider.builder();
SdkLoggerProviderUtil.addLoggerConfiguratorCondition(
loggerProviderBuilder, nameEquals(scopeB.getName()), LoggerConfig.disabled());

OpenTelemetrySdk sdk =
OpenTelemetrySdk.builder()
.setTracerProvider(
SdkTracerProvider.builder()
tracerProviderBuilder
.addSpanProcessor(SimpleSpanProcessor.create(spanExporter))
.addTracerConfiguratorCondition(
nameEquals(scopeB.getName()), TracerConfig.disabled())
.build())
.setMeterProvider(
SdkMeterProvider.builder()
.registerMetricReader(metricReader)
.addMeterConfiguratorCondition(
nameEquals(scopeB.getName()), MeterConfig.disabled())
.build())
.setMeterProvider(meterProviderBuilder.registerMetricReader(metricReader).build())
.setLoggerProvider(
SdkLoggerProvider.builder()
loggerProviderBuilder
.addLogRecordProcessor(SimpleLogRecordProcessor.create(logRecordExporter))
.addLoggerConfiguratorCondition(
nameEquals(scopeB.getName()), LoggerConfig.disabled())
.build())
.build();

Expand Down Expand Up @@ -108,34 +116,39 @@ void disableScopeB() {
/** Disable all scopes by default and enable a single scope. */
@Test
void disableAllScopesExceptB() {
// Configuration ergonomics will improve after APIs stabilize
SdkTracerProviderBuilder tracerProviderBuilder = SdkTracerProvider.builder();
SdkTracerProviderUtil.setTracerConfigurator(
tracerProviderBuilder,
TracerConfig.configuratorBuilder()
.setDefault(TracerConfig.disabled())
.addCondition(nameEquals(scopeB.getName()), TracerConfig.enabled())
.build());
SdkMeterProviderBuilder meterProviderBuilder = SdkMeterProvider.builder();
SdkMeterProviderUtil.setMeterConfigurator(
meterProviderBuilder,
MeterConfig.configuratorBuilder()
.setDefault(MeterConfig.disabled())
.addCondition(nameEquals(scopeB.getName()), MeterConfig.enabled())
.build());
SdkLoggerProviderBuilder loggerProviderBuilder = SdkLoggerProvider.builder();
SdkLoggerProviderUtil.setLoggerConfigurator(
loggerProviderBuilder,
LoggerConfig.configuratorBuilder()
.setDefault(LoggerConfig.disabled())
.addCondition(nameEquals(scopeB.getName()), LoggerConfig.enabled())
.build());

OpenTelemetrySdk sdk =
OpenTelemetrySdk.builder()
.setTracerProvider(
SdkTracerProvider.builder()
tracerProviderBuilder
.addSpanProcessor(SimpleSpanProcessor.create(spanExporter))
.setTracerConfigurator(
TracerConfig.configuratorBuilder()
.setDefault(TracerConfig.disabled())
.addCondition(nameEquals(scopeB.getName()), TracerConfig.enabled())
.build())
.build())
.setMeterProvider(
SdkMeterProvider.builder()
.registerMetricReader(metricReader)
.setMeterConfigurator(
MeterConfig.configuratorBuilder()
.setDefault(MeterConfig.disabled())
.addCondition(nameEquals(scopeB.getName()), MeterConfig.enabled())
.build())
.build())
.setMeterProvider(meterProviderBuilder.registerMetricReader(metricReader).build())
.setLoggerProvider(
SdkLoggerProvider.builder()
loggerProviderBuilder
.addLogRecordProcessor(SimpleLogRecordProcessor.create(logRecordExporter))
.setLoggerConfigurator(
LoggerConfig.configuratorBuilder()
.setDefault(LoggerConfig.disabled())
.addCondition(nameEquals(scopeB.getName()), LoggerConfig.enabled())
.build())
.build())
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.sdk.common;
package io.opentelemetry.sdk.internal;

import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
import java.util.function.Function;

/**
* A {@link ScopeConfigurator} computes configuration for a given {@link InstrumentationScopeInfo}.
*
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
@FunctionalInterface
public interface ScopeConfigurator<T> extends Function<InstrumentationScopeInfo, T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.sdk.common;
package io.opentelemetry.sdk.internal;

import io.opentelemetry.sdk.internal.GlobUtil;
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
Expand All @@ -14,6 +14,9 @@
/**
* Builder for {@link ScopeConfigurator}.
*
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*
* @param <T> The scope configuration object, e.g. {@code TracerConfig}, {@code LoggerConfig},
* {@code MeterConfig}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import io.opentelemetry.api.logs.Logger;
import io.opentelemetry.api.logs.LoggerProvider;
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
import io.opentelemetry.sdk.logs.internal.LoggerConfig;

/** SDK implementation of {@link Logger}. */
final class SdkLogger implements Logger {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
import io.opentelemetry.sdk.common.Clock;
import io.opentelemetry.sdk.common.CompletableResultCode;
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
import io.opentelemetry.sdk.common.ScopeConfigurator;
import io.opentelemetry.sdk.internal.ComponentRegistry;
import io.opentelemetry.sdk.internal.ScopeConfigurator;
import io.opentelemetry.sdk.logs.internal.LoggerConfig;
import io.opentelemetry.sdk.resources.Resource;
import java.io.Closeable;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
import io.opentelemetry.context.Context;
import io.opentelemetry.sdk.common.Clock;
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
import io.opentelemetry.sdk.common.ScopeConfigurator;
import io.opentelemetry.sdk.common.ScopeConfiguratorBuilder;
import io.opentelemetry.sdk.internal.ScopeConfigurator;
import io.opentelemetry.sdk.internal.ScopeConfiguratorBuilder;
import io.opentelemetry.sdk.logs.data.LogRecordData;
import io.opentelemetry.sdk.logs.internal.LoggerConfig;
import io.opentelemetry.sdk.resources.Resource;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -115,7 +116,7 @@ public SdkLoggerProviderBuilder setClock(Clock clock) {
*
* @see LoggerConfig#configuratorBuilder()
*/
public SdkLoggerProviderBuilder setLoggerConfigurator(
SdkLoggerProviderBuilder setLoggerConfigurator(
ScopeConfigurator<LoggerConfig> loggerConfigurator) {
this.loggerConfiguratorBuilder = loggerConfigurator.toBuilder();
return this;
Expand All @@ -134,7 +135,7 @@ public SdkLoggerProviderBuilder setLoggerConfigurator(
* @see ScopeConfiguratorBuilder#nameEquals(String)
* @see ScopeConfiguratorBuilder#nameMatchesGlob(String)
*/
public SdkLoggerProviderBuilder addLoggerConfiguratorCondition(
SdkLoggerProviderBuilder addLoggerConfiguratorCondition(
Predicate<InstrumentationScopeInfo> scopeMatcher, LoggerConfig loggerConfig) {
this.loggerConfiguratorBuilder.addCondition(scopeMatcher, loggerConfig);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.sdk.logs;
package io.opentelemetry.sdk.logs.internal;

import com.google.auto.value.AutoValue;
import io.opentelemetry.api.logs.Logger;
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
import io.opentelemetry.sdk.common.ScopeConfigurator;
import io.opentelemetry.sdk.common.ScopeConfiguratorBuilder;
import io.opentelemetry.sdk.internal.ScopeConfigurator;
import io.opentelemetry.sdk.internal.ScopeConfiguratorBuilder;
import io.opentelemetry.sdk.logs.SdkLoggerProviderBuilder;
import java.util.function.Predicate;
import javax.annotation.concurrent.Immutable;

/**
* A collection of configuration options which define the behavior of a {@link Logger}.
*
* @see SdkLoggerProviderBuilder#setLoggerConfigurator(ScopeConfigurator)
* @see SdkLoggerProviderBuilder#addLoggerConfiguratorCondition(Predicate, LoggerConfig)
* @see SdkLoggerProviderUtil#setLoggerConfigurator(SdkLoggerProviderBuilder, ScopeConfigurator)
* @see SdkLoggerProviderUtil#addLoggerConfiguratorCondition(SdkLoggerProviderBuilder, Predicate,
* LoggerConfig)
*/
@AutoValue
@Immutable
Expand All @@ -39,17 +41,16 @@ public static LoggerConfig enabled() {
}

/**
* Returns the default {@link LoggerConfig}, which is used when no {@link
* SdkLoggerProviderBuilder#setLoggerConfigurator(ScopeConfigurator)} is set or when the logger
* configurator returns {@code null} for a {@link InstrumentationScopeInfo}.
* Returns the default {@link LoggerConfig}, which is used when no configurator is set or when the
* logger configurator returns {@code null} for a {@link InstrumentationScopeInfo}.
*/
public static LoggerConfig defaultConfig() {
return DEFAULT_CONFIG;
}

/**
* Create a {@link ScopeConfiguratorBuilder} for configuring {@link
* SdkLoggerProviderBuilder#setLoggerConfigurator(ScopeConfigurator)}.
* SdkLoggerProviderUtil#setLoggerConfigurator(SdkLoggerProviderBuilder, ScopeConfigurator)}.
*/
public static ScopeConfiguratorBuilder<LoggerConfig> configuratorBuilder() {
return ScopeConfigurator.builder();
Expand Down
Loading

0 comments on commit 1714387

Please sign in to comment.