Skip to content

Commit e1e0423

Browse files
committed
update readme doc
1 parent 01edb03 commit e1e0423

File tree

1 file changed

+12
-42
lines changed

1 file changed

+12
-42
lines changed

span-stacktrace/README.md

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,21 @@ This module provides a `SpanProcessor` that captures the [`code.stacktrace`](htt
66
Capturing the stack trace is an expensive operation and does not provide any value on short-lived spans.
77
As a consequence it should only be used when the span duration is known, thus on span end.
88

9-
However, the current SDK API does not allow to modify span attributes on span end, so we have to
10-
introduce other components to make it work as expected.
9+
## Usage and configuration
1110

12-
## Usage
11+
This extension supports autoconfiguration.
1312

14-
This extension does not support autoconfiguration because it needs to wrap the `SimpleSpanExporter`
15-
or `BatchingSpanProcessor` that invokes the `SpanExporter`.
13+
`otel.java.experimental.span-stacktrace.min.duration`:
14+
- allows to configure the minimal duration for which spans have a stacktrace captured
15+
- defaults to 5ms
16+
- a value of zero will include all spans
17+
- a negative value will disable the feature
1618

17-
As a consequence you have to use [Manual SDK setup](#manual-sdk-setup)
18-
section below to configure it.
19-
20-
### Manual SDK setup
21-
22-
Here is an example registration of `StackTraceSpanProcessor` to capture stack trace for all
23-
the spans that have a duration >= 1 ms. The spans that have an `ignorespan` string attribute
24-
will be ignored.
25-
26-
```java
27-
InMemorySpanExporter spansExporter = InMemorySpanExporter.create();
28-
SpanProcessor exportProcessor = SimpleSpanProcessor.create(spansExporter);
29-
30-
Map<String, String> configMap = new HashMap<>();
31-
configMap.put("otel.java.experimental.span-stacktrace.min.duration", "1ms");
32-
ConfigProperties config = DefaultConfigProperties.createFromMap(configMap);
33-
34-
Predicate<ReadableSpan> filterPredicate = readableSpan -> {
35-
if(readableSpan.getAttribute(AttributeKey.stringKey("ignorespan")) != null){
36-
return false;
37-
}
38-
return true;
39-
};
40-
SdkTracerProvider tracerProvider = SdkTracerProvider.builder()
41-
.addSpanProcessor(new StackTraceSpanProcessor(exportProcessor, config, filterPredicate))
42-
.build();
43-
44-
OpenTelemetrySdk sdk = OpenTelemetrySdk.builder().setTracerProvider(tracerProvider).build();
45-
```
46-
47-
### Configuration
48-
49-
The `otel.java.experimental.span-stacktrace.min.duration` configuration option (defaults to 5ms) allows configuring
50-
the minimal duration for which spans should have a stacktrace captured.
51-
52-
Setting `otel.java.experimental.span-stacktrace.min.duration` to zero will include all spans, and using a negative
53-
value will disable the feature.
19+
`otel.java.experimental.span-stacktrace.filter`:
20+
- allows to filter spans to be excluded from stacktrace capture
21+
- defaults to include all spans.
22+
- value is the class name of a class implementing `java.util.function.Predicate<ReadableSpan>`
23+
- filter class must be publicly accessible and provide a no-arg constructor
5424

5525
## Component owners
5626

0 commit comments

Comments
 (0)