Skip to content

Commit

Permalink
span stacktraces config (without aligning with upstream) (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
SylvainJuge authored Sep 2, 2024
1 parent 120c26b commit e3243bd
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ The agent captures the stacktraces of spans to help identify code paths that tri

The stacktrace is stored in the [`code.stacktrace`](https://opentelemetry.io/docs/specs/semconv/attributes-registry/code/) attribute.

The minimum span duration can be configured with `elastic.otel.span.stack.trace.min.duration` (in milliseconds, defaults to 5ms).
The minimum span duration can be configured with `elastic.otel.java.span-stacktrace.min.duration` (defaults to `5ms`).

Implementation has been contributed upstream in the [opentelemetry-java-contrib](https://github.com/open-telemetry/opentelemetry-java-contrib) repository,
in the [`span-stacktrace`](https://github.com/open-telemetry/opentelemetry-java-contrib/tree/main/span-stacktrace) folder.

### Runtime metrics

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
@AutoService(ChainingSpanProcessorAutoConfiguration.class)
public class SpanStackTraceProcessorAutoConfig implements ChainingSpanProcessorAutoConfiguration {

static final String MIN_DURATION_CONFIG_OPTION = "elastic.otel.span.stack.trace.min.duration";
// TODO replace this with upstream config once it's stable
static final String MIN_DURATION_CONFIG_OPTION = "elastic.otel.java.span-stacktrace.min.duration";

@Override
public void registerSpanProcessors(
Expand Down
2 changes: 1 addition & 1 deletion docs/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ EDOT Java includes several OpenTelemetry extensions from the [OpenTelemetry Java
|---|---|---|
| `OTEL_SERVICE_NAME` | [Resource providers](https://github.com/open-telemetry/opentelemetry-java-contrib/tree/main/resource-providers) | This can be [set as usual](https://opentelemetry.io/docs/languages/sdk-configuration/general/#otel_service_name), but if not set the value will be inferred when the EDOT Java agent is running in various application servers. |
| `OTEL_INFERRED_SPANS_*` | [Inferred Spans](https://github.com/open-telemetry/opentelemetry-java-contrib/tree/main/inferred-spans) | Generates additional spans using profiling instead of instrumentation. |
| `OTEL_SPAN_STACK_TRACE_MIN_DURATION` | [Span stacktrace capture](https://github.com/open-telemetry/opentelemetry-java-contrib/tree/main/span-stacktrace) | Define the minimum duration (in milliseconds) for attaching stack traces to spans. Defaults to 5ms. |

### Configuration options that are _only_ available in EDOT Java

Expand All @@ -110,6 +109,7 @@ _Currently there are no additional `OTEL_` options waiting to be contributed ups
| Option(s) | Extension | Description |
|---|---|---|
| `ELASTIC_OTEL_UNIVERSAL_PROFILING_INTEGRATION_*` | [Universal profiling integration](https://github.com/elastic/elastic-otel-java/tree/main/universal-profiling-integration) | Correlates traces with profiling data from the Elastic universal profiler. |
| `ELASTIC_OTEL_JAVA_SPAN_STACKTRACE_MIN_DURATION` | [Span stacktrace capture](https://github.com/open-telemetry/opentelemetry-java-contrib/tree/main/span-stacktrace) | Define the minimum duration for attaching stack traces to spans. Defaults to 5ms. |

<!-- ✅ List auth methods -->
## Authentication methods
Expand Down
3 changes: 1 addition & 2 deletions inferred-spans/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ SdkTracerProvider tracerProvider = SdkTracerProvider.builder()
.addSpanProcessor(BatchSpanProcessor.builder(OtlpGrpcSpanExporter.builder()
.setEndpoint("https://<clusterid>.apm.europe-west3.gcp.cloud.es.io:443")
.addHeader("Authorization", "Bearer <secrettoken>>")
.build()))
.build();
.build())).build();
inferredSpans.setTracerProvider(tracerProvider);
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class AgentFeaturesSmokeTest extends TestAppSmokeTest {
@BeforeAll
public static void start() {
startTestApp(
(container) -> container.addEnv("ELASTIC_OTEL_SPAN_STACK_TRACE_MIN_DURATION", "0ms"));
(container) -> container.addEnv("ELASTIC_OTEL_JAVA_SPAN_STACKTRACE_MIN_DURATION", "0ms"));
}

@AfterAll
Expand Down

0 comments on commit e3243bd

Please sign in to comment.