Skip to content

Commit

Permalink
Upgrade to otel-java 2.4.0 and otel-sdk 1.38.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vmaleze committed May 27, 2024
1 parent 90ee6a8 commit 8dbb08c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ spec:
# Will drop spans towards health and metrics endpoints
- name: OTEL_DROP_SPANS
value: .*/health,.*/metrics
image: ghcr.io/vmaleze/opentelemetry-java-ignore-spans:2.2.0
image: ghcr.io/vmaleze/opentelemetry-java-ignore-spans:2.4.0
```
## Current versions
* Extension version => [2.2.0](https://github.com/vmaleze/opentelemetry-java-ignore-spans/releases)
* [OpenTelemetry java agent](https://github.com/open-telemetry/opentelemetry-java-instrumentation) => 2.2.0
* [OpenTelemetry SDK](https://github.com/open-telemetry/opentelemetry-java) => 1.36.0
* Extension version => [2.4.0](https://github.com/vmaleze/opentelemetry-java-ignore-spans/releases)
* [OpenTelemetry java agent](https://github.com/open-telemetry/opentelemetry-java-instrumentation) => 2.4.0
* [OpenTelemetry SDK](https://github.com/open-telemetry/opentelemetry-java) => 1.38.0
## References :
* [Embedded extension](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/examples/extension/README.md#embed-extensions-in-the-opentelemetry-agent)
Expand Down
8 changes: 4 additions & 4 deletions extension/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ plugins {

ext {
versions = [
opentelemetrySdk : "1.36.0",
opentelemetryJavaagent : "2.2.0",
opentelemetryJavaagentAlpha: "2.2.0-alpha",
opentelemetryContribAlpha : "1.33.0-alpha",
opentelemetrySdk : "1.38.0",
opentelemetryJavaagent : "2.4.0",
opentelemetryJavaagentAlpha: "2.4.0-alpha",
opentelemetryContribAlpha : "1.35.0-alpha",

junit : "5.9.2"
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
package io.opentelemetry.extensions;

import static io.opentelemetry.api.common.AttributeKey.stringKey;

import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.contrib.sampler.RuleBasedRoutingSampler;
import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizer;
import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizerProvider;
import io.opentelemetry.sdk.trace.samplers.Sampler;
import io.opentelemetry.semconv.SemanticAttributes;

/**
* Note this class is wired into SPI via
* {@code resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizerProvider}
*/
public class DropSpansExtension implements AutoConfigurationCustomizerProvider {

private static final AttributeKey<String> URL_PATH = stringKey("url.path");

@Override
public void customize(AutoConfigurationCustomizer autoConfiguration) {
// Set the sampler to be the default parentbased_always_on, but drop calls listed in the env variable
final var dropSpansEnv = System.getenv("OTEL_DROP_SPANS");
if (dropSpansEnv != null) {
final var dropSpanBuilder = RuleBasedRoutingSampler.builder(SpanKind.SERVER, Sampler.alwaysOn());
for (var span : dropSpansEnv.split(",")) {
dropSpanBuilder.drop(SemanticAttributes.URL_PATH, span);
dropSpanBuilder.drop(URL_PATH, span);
}

autoConfiguration.addTracerProviderCustomizer((sdkTracerProviderBuilder, configProperties) ->
Expand Down

0 comments on commit 8dbb08c

Please sign in to comment.