-
Notifications
You must be signed in to change notification settings - Fork 879
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change default OTLP protocol to http/protobuf (#9993)
Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
- Loading branch information
Showing
6 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...c/main/java/io/opentelemetry/javaagent/tooling/config/OtlpProtocolPropertiesSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.tooling.config; | ||
|
||
import com.google.auto.service.AutoService; | ||
import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizer; | ||
import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizerProvider; | ||
import java.util.Collections; | ||
|
||
@AutoService(AutoConfigurationCustomizerProvider.class) | ||
public class OtlpProtocolPropertiesSupplier implements AutoConfigurationCustomizerProvider { | ||
|
||
@Override | ||
public void customize(AutoConfigurationCustomizer autoConfigurationCustomizer) { | ||
autoConfigurationCustomizer.addPropertiesSupplier( | ||
() -> Collections.singletonMap("otel.exporter.otlp.protocol", "http/protobuf")); | ||
} | ||
|
||
@Override | ||
public int order() { | ||
// make sure it runs BEFORE all the user-provided customizers | ||
return Integer.MIN_VALUE; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...st/java/io/opentelemetry/javaagent/tooling/config/OtlpProtocolPropertiesSupplierTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.tooling.config; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import io.opentelemetry.api.GlobalOpenTelemetry; | ||
import io.opentelemetry.api.events.GlobalEventEmitterProvider; | ||
import io.opentelemetry.javaagent.tooling.OpenTelemetryInstaller; | ||
import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk; | ||
import io.opentelemetry.sdk.autoconfigure.internal.AutoConfigureUtil; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junitpioneer.jupiter.SetSystemProperty; | ||
|
||
class OtlpProtocolPropertiesSupplierTest { | ||
|
||
@AfterEach | ||
void cleanUp() { | ||
GlobalOpenTelemetry.resetForTest(); | ||
GlobalEventEmitterProvider.resetForTest(); | ||
} | ||
|
||
@SetSystemProperty( | ||
key = "otel.exporter.otlp.protocol", | ||
value = "grpc") // user explicitly sets grpc | ||
@Test | ||
void keepUserOtlpProtocolConfiguration() { | ||
// when | ||
AutoConfiguredOpenTelemetrySdk autoConfiguredSdk = | ||
OpenTelemetryInstaller.installOpenTelemetrySdk(this.getClass().getClassLoader()); | ||
|
||
// then | ||
assertThat( | ||
AutoConfigureUtil.getConfig(autoConfiguredSdk).getString("otel.exporter.otlp.protocol")) | ||
.isEqualTo("grpc"); | ||
} | ||
|
||
@Test | ||
void defaultHttpProtobufOtlpProtocolConfiguration() { | ||
// when | ||
AutoConfiguredOpenTelemetrySdk autoConfiguredSdk = | ||
OpenTelemetryInstaller.installOpenTelemetrySdk(this.getClass().getClassLoader()); | ||
|
||
// then | ||
assertThat( | ||
AutoConfigureUtil.getConfig(autoConfiguredSdk).getString("otel.exporter.otlp.protocol")) | ||
.isEqualTo("http/protobuf"); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...A-INF/services/io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizerProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
io.opentelemetry.javaagent.tooling.config.ConfigurationPropertiesSupplier | ||
io.opentelemetry.javaagent.tooling.config.OtlpProtocolPropertiesSupplier | ||
io.opentelemetry.javaagent.tooling.config.ConfigurationPropertiesSupplierTest$UserCustomPropertiesSupplier |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters