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 -alpha artifacts from runtime classpath of stable components #6944

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
4 changes: 1 addition & 3 deletions buildSrc/src/main/kotlin/otel.java-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ tasks {
// https://groups.google.com/forum/#!topic/bazel-discuss/_R3A9TJSoPM
"-Xlint:-processing",
// We suppress the "options" warning because it prevents compilation on modern JDKs
"-Xlint:-options",
// Fail build on any warning
"-Werror",
"-Xlint:-options"
jack-berg marked this conversation as resolved.
Show resolved Hide resolved
),
)
}
Expand Down
2 changes: 1 addition & 1 deletion exporters/otlp/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ dependencies {
protoSource("io.opentelemetry.proto:opentelemetry-proto:${versions["io.opentelemetry.proto"]}")

api(project(":exporters:common"))
implementation(project(":api:incubator"))
jack-berg marked this conversation as resolved.
Show resolved Hide resolved

compileOnly(project(":sdk:metrics"))
compileOnly(project(":sdk:trace"))
Expand All @@ -32,6 +31,7 @@ dependencies {
testImplementation("com.google.guava:guava")
testImplementation("io.opentelemetry.proto:opentelemetry-proto")

jmhImplementation(project(":api:incubator"))
jmhImplementation(project(":sdk:testing"))
jmhImplementation("com.fasterxml.jackson.core:jackson-core")
jmhImplementation("io.opentelemetry.proto:opentelemetry-proto")
Expand Down
7 changes: 6 additions & 1 deletion sdk-extensions/autoconfigure/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies {
api(project(":sdk:all"))
api(project(":sdk-extensions:autoconfigure-spi"))

implementation(project(":api:incubator"))
compileOnly(project(":api:incubator"))

annotationProcessor("com.google.auto.value:auto-value")

Expand All @@ -23,6 +23,11 @@ dependencies {

testing {
suites {
register<JvmTestSuite>("testIncubating") {
dependencies {
implementation(project(":api:incubator"))
}
}
register<JvmTestSuite>("testAutoConfigureOrder") {
targets {
all {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import static java.util.Objects.requireNonNull;

import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.incubator.events.GlobalEventLoggerProvider;
import io.opentelemetry.context.propagation.ContextPropagators;
import io.opentelemetry.context.propagation.TextMapPropagator;
import io.opentelemetry.sdk.OpenTelemetrySdk;
Expand All @@ -26,7 +25,6 @@
import io.opentelemetry.sdk.logs.SdkLoggerProvider;
import io.opentelemetry.sdk.logs.SdkLoggerProviderBuilder;
import io.opentelemetry.sdk.logs.export.LogRecordExporter;
import io.opentelemetry.sdk.logs.internal.SdkEventLoggerProvider;
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
import io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder;
import io.opentelemetry.sdk.metrics.export.MetricExporter;
Expand Down Expand Up @@ -592,8 +590,12 @@ private void maybeSetAsGlobal(OpenTelemetrySdk openTelemetrySdk) {
return;
}
GlobalOpenTelemetry.set(openTelemetrySdk);
GlobalEventLoggerProvider.set(
SdkEventLoggerProvider.create(openTelemetrySdk.getSdkLoggerProvider()));
try {
Class.forName("io.opentelemetry.api.incubator.events.GlobalEventLoggerProvider");
IncubatingUtil.setGlobalEventLoggerProvider(openTelemetrySdk.getSdkLoggerProvider());
} catch (Exception e) {
// do nothing
}
logger.log(
Level.FINE, "Global OpenTelemetry set to {0} by autoconfiguration", openTelemetrySdk);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.sdk.autoconfigure;

import io.opentelemetry.api.incubator.events.GlobalEventLoggerProvider;
import io.opentelemetry.sdk.logs.SdkLoggerProvider;
import io.opentelemetry.sdk.logs.internal.SdkEventLoggerProvider;

final class IncubatingUtil {

private IncubatingUtil() {}

static void setGlobalEventLoggerProvider(SdkLoggerProvider sdkLoggerProvider) {
GlobalEventLoggerProvider.set(SdkEventLoggerProvider.create(sdkLoggerProvider));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import io.github.netmikey.logunit.api.LogCapturer;
import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.incubator.events.GlobalEventLoggerProvider;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.SpanId;
import io.opentelemetry.api.trace.TraceId;
Expand All @@ -49,7 +48,6 @@
import io.opentelemetry.sdk.logs.LogRecordProcessor;
import io.opentelemetry.sdk.logs.SdkLoggerProvider;
import io.opentelemetry.sdk.logs.SdkLoggerProviderBuilder;
import io.opentelemetry.sdk.logs.internal.SdkEventLoggerProvider;
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
import io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder;
import io.opentelemetry.sdk.metrics.export.MetricReader;
Expand Down Expand Up @@ -156,7 +154,6 @@ public SdkLoggerProviderBuilder apply(
@BeforeEach
void resetGlobal() {
GlobalOpenTelemetry.resetForTest();
GlobalEventLoggerProvider.resetForTest();
builder =
AutoConfiguredOpenTelemetrySdk.builder()
.addPropertiesSupplier(disableExportPropertySupplier());
Expand Down Expand Up @@ -456,18 +453,13 @@ void builder_setResultAsGlobalFalse() {
OpenTelemetrySdk openTelemetry = builder.build().getOpenTelemetrySdk();

assertThat(GlobalOpenTelemetry.get()).extracting("delegate").isNotSameAs(openTelemetry);
assertThat(GlobalEventLoggerProvider.get()).isNotSameAs(openTelemetry.getSdkLoggerProvider());
}

@Test
void builder_setResultAsGlobalTrue() {
OpenTelemetrySdk openTelemetry = builder.setResultAsGlobal().build().getOpenTelemetrySdk();

assertThat(GlobalOpenTelemetry.get()).extracting("delegate").isSameAs(openTelemetry);
assertThat(GlobalEventLoggerProvider.get())
.isInstanceOf(SdkEventLoggerProvider.class)
.extracting("delegateLoggerProvider")
.isSameAs(openTelemetry.getSdkLoggerProvider());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.sdk.autoconfigure;

import static org.assertj.core.api.Assertions.assertThat;

import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.incubator.events.GlobalEventLoggerProvider;
import io.opentelemetry.sdk.OpenTelemetrySdk;
import io.opentelemetry.sdk.logs.internal.SdkEventLoggerProvider;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

class AutoconfigureGlobalEventLoggerProviderTest {

private AutoConfiguredOpenTelemetrySdkBuilder builder;

@BeforeEach
void resetGlobal() {
GlobalOpenTelemetry.resetForTest();
GlobalEventLoggerProvider.resetForTest();
builder =
AutoConfiguredOpenTelemetrySdk.builder()
.addPropertiesSupplier(disableExportPropertySupplier());
}

@Test
void builder_setResultAsGlobalFalse() {
GlobalOpenTelemetry.set(OpenTelemetry.noop());

OpenTelemetrySdk openTelemetry = builder.build().getOpenTelemetrySdk();

assertThat(GlobalOpenTelemetry.get()).extracting("delegate").isNotSameAs(openTelemetry);
assertThat(GlobalEventLoggerProvider.get()).isNotSameAs(openTelemetry.getSdkLoggerProvider());
}

@Test
void builder_setResultAsGlobalTrue() {
OpenTelemetrySdk openTelemetry = builder.setResultAsGlobal().build().getOpenTelemetrySdk();

assertThat(GlobalOpenTelemetry.get()).extracting("delegate").isSameAs(openTelemetry);
assertThat(GlobalEventLoggerProvider.get())
.isInstanceOf(SdkEventLoggerProvider.class)
.extracting("delegateLoggerProvider")
.isSameAs(openTelemetry.getSdkLoggerProvider());
}

private static Supplier<Map<String, String>> disableExportPropertySupplier() {
Map<String, String> props = new HashMap<>();
props.put("otel.metrics.exporter", "none");
props.put("otel.traces.exporter", "none");
props.put("otel.logs.exporter", "none");
return () -> props;
}
}
20 changes: 19 additions & 1 deletion sdk/logs/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ otelJava.moduleName.set("io.opentelemetry.sdk.logs")
dependencies {
api(project(":api:all"))
api(project(":sdk:common"))
implementation(project(":api:incubator"))
compileOnly(project(":api:incubator"))

annotationProcessor("com.google.auto.value:auto-value")

Expand All @@ -21,3 +21,21 @@ dependencies {
testImplementation("org.awaitility:awaitility")
testImplementation("com.google.guava:guava")
}

testing {
suites {
register<JvmTestSuite>("testIncubating") {
dependencies {
implementation(project(":sdk:testing"))
implementation(project(":api:incubator"))
implementation("com.google.guava:guava")
}
}
}
}

tasks {
check {
dependsOn(testing.suites)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.sdk.logs;

import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Value;
import io.opentelemetry.api.incubator.logs.ExtendedLogRecordBuilder;
import io.opentelemetry.api.logs.LogRecordBuilder;
import io.opentelemetry.api.logs.Severity;
import io.opentelemetry.context.Context;
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
import java.time.Instant;
import java.util.concurrent.TimeUnit;

/** SDK implementation of {@link ExtendedLogRecordBuilder}. */
final class ExtendedSdkLogRecordBuilder extends SdkLogRecordBuilder
implements ExtendedLogRecordBuilder {

ExtendedSdkLogRecordBuilder(
LoggerSharedState loggerSharedState, InstrumentationScopeInfo instrumentationScopeInfo) {
super(loggerSharedState, instrumentationScopeInfo);
}

@Override
public ExtendedSdkLogRecordBuilder setTimestamp(long timestamp, TimeUnit unit) {
super.setTimestamp(timestamp, unit);
return this;
}

@Override
public ExtendedSdkLogRecordBuilder setTimestamp(Instant instant) {
super.setTimestamp(instant);
return this;

Check warning on line 36 in sdk/logs/src/main/java/io/opentelemetry/sdk/logs/ExtendedSdkLogRecordBuilder.java

View check run for this annotation

Codecov / codecov/patch

sdk/logs/src/main/java/io/opentelemetry/sdk/logs/ExtendedSdkLogRecordBuilder.java#L35-L36

Added lines #L35 - L36 were not covered by tests
}

@Override
public LogRecordBuilder setObservedTimestamp(long timestamp, TimeUnit unit) {
super.setObservedTimestamp(timestamp, unit);
return this;

Check warning on line 42 in sdk/logs/src/main/java/io/opentelemetry/sdk/logs/ExtendedSdkLogRecordBuilder.java

View check run for this annotation

Codecov / codecov/patch

sdk/logs/src/main/java/io/opentelemetry/sdk/logs/ExtendedSdkLogRecordBuilder.java#L41-L42

Added lines #L41 - L42 were not covered by tests
}

@Override
public LogRecordBuilder setObservedTimestamp(Instant instant) {
super.setObservedTimestamp(instant);
return this;

Check warning on line 48 in sdk/logs/src/main/java/io/opentelemetry/sdk/logs/ExtendedSdkLogRecordBuilder.java

View check run for this annotation

Codecov / codecov/patch

sdk/logs/src/main/java/io/opentelemetry/sdk/logs/ExtendedSdkLogRecordBuilder.java#L47-L48

Added lines #L47 - L48 were not covered by tests
}

@Override
public ExtendedSdkLogRecordBuilder setContext(Context context) {
super.setContext(context);
return this;
}

@Override
public ExtendedSdkLogRecordBuilder setSeverity(Severity severity) {
super.setSeverity(severity);
return this;
}

@Override
public ExtendedSdkLogRecordBuilder setSeverityText(String severityText) {
super.setSeverityText(severityText);
return this;

Check warning on line 66 in sdk/logs/src/main/java/io/opentelemetry/sdk/logs/ExtendedSdkLogRecordBuilder.java

View check run for this annotation

Codecov / codecov/patch

sdk/logs/src/main/java/io/opentelemetry/sdk/logs/ExtendedSdkLogRecordBuilder.java#L65-L66

Added lines #L65 - L66 were not covered by tests
}

@Override
public ExtendedSdkLogRecordBuilder setBody(String body) {
super.setBody(body);
return this;
}

@Override
public ExtendedSdkLogRecordBuilder setBody(Value<?> value) {
super.setBody(value);
return this;
}

@Override
public <T> ExtendedSdkLogRecordBuilder setAttribute(AttributeKey<T> key, T value) {
super.setAttribute(key, value);
return this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.sdk.logs;

import io.opentelemetry.api.incubator.logs.ExtendedLogger;
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
import io.opentelemetry.sdk.logs.internal.LoggerConfig;

/** SDK implementation of {@link ExtendedLogger}. */
final class ExtendedSdkLogger extends SdkLogger implements ExtendedLogger {

private final boolean loggerEnabled;

ExtendedSdkLogger(
LoggerSharedState loggerSharedState,
InstrumentationScopeInfo instrumentationScopeInfo,
LoggerConfig loggerConfig) {
super(loggerSharedState, instrumentationScopeInfo, loggerConfig);
this.loggerEnabled = loggerConfig.isEnabled();
}

@Override
public boolean isEnabled() {
return loggerEnabled;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.sdk.logs;

import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
import io.opentelemetry.sdk.logs.internal.LoggerConfig;

final class IncubatingUtil {

private IncubatingUtil() {}

static SdkLogger createIncubatingLogger(
LoggerSharedState sharedState,
InstrumentationScopeInfo instrumentationScopeInfo,
LoggerConfig tracerConfig) {
return new ExtendedSdkLogger(sharedState, instrumentationScopeInfo, tracerConfig);
}

static SdkLogRecordBuilder createIncubatingLogRecordBuilder(
LoggerSharedState loggerSharedState, InstrumentationScopeInfo instrumentationScopeInfo) {
return new ExtendedSdkLogRecordBuilder(loggerSharedState, instrumentationScopeInfo);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Value;
import io.opentelemetry.api.incubator.logs.ExtendedLogRecordBuilder;
import io.opentelemetry.api.logs.LogRecordBuilder;
import io.opentelemetry.api.logs.Severity;
import io.opentelemetry.api.trace.Span;
Expand All @@ -19,7 +18,7 @@
import javax.annotation.Nullable;

/** SDK implementation of {@link LogRecordBuilder}. */
final class SdkLogRecordBuilder implements ExtendedLogRecordBuilder {
class SdkLogRecordBuilder implements LogRecordBuilder {

private final LoggerSharedState loggerSharedState;
private final LogLimits logLimits;
Expand Down
Loading
Loading