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

add span stacktrace config option #1414

Merged
merged 16 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 8 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
16 changes: 16 additions & 0 deletions span-stacktrace/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ SdkTracerProvider tracerProvider = SdkTracerProvider.builder()
OpenTelemetrySdk sdk = OpenTelemetrySdk.builder().setTracerProvider(tracerProvider).build();
```

### Configuration

Even if autoconfiguration is not yet supported, usages of this module must use the
`otel.span.stacktrace.min.duration` configuration option (defaults to 5ms) to
allow consistent configuration across usages.

The following constants are provided as a convenience:

- `StackTraceSpanProcessor.CONFIG_MIN_DURATION`
- `StackTraceSpanProcessor.CONFIG_MIN_DURATION_DEFAULT`

This means the default for this feature will capture a stacktrace for all spans that last 5ms or more,
disabling it must be allowed by setting a negative value to `otel.span.stacktrace.min.duration`.
Setting `otel.span.stacktrace.min.duration` to zero means a stacktrace will be captured for all
spans.
SylvainJuge marked this conversation as resolved.
Show resolved Hide resolved

## Component owners

- [Jack Shirazi](https://github.com/jackshirazi), Elastic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@
import io.opentelemetry.sdk.trace.SpanProcessor;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.time.Duration;
import java.util.function.Predicate;
import java.util.logging.Level;
import java.util.logging.Logger;

public class StackTraceSpanProcessor extends AbstractSimpleChainingSpanProcessor {

public static final String CONFIG_MIN_DURATION = "otel.span.stacktrace.min.duration";
public static final Duration CONFIG_MIN_DURATION_DEFAULT = Duration.ofMillis(5);

// inlined incubating attribute to prevent direct dependency on incubating semconv
private static final AttributeKey<String> SPAN_STACKTRACE =
AttributeKey.stringKey("code.stacktrace");
Expand Down
Loading