Skip to content

Commit 4a6a3e0

Browse files
authored
document span stacktrace (#1301)
1 parent 64285c2 commit 4a6a3e0

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

span-stacktrace/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,37 @@ As a consequence it should only be used when the span duration is known, thus on
99
However, the current SDK API does not allow to modify span attributes on span end, so we have to
1010
introduce other components to make it work as expected.
1111

12+
## Usage
13+
14+
This extension does not support autoconfiguration because it needs to wrap the `SimpleSpanExporter`
15+
or `BatchingSpanProcessor` that invokes the `SpanExporter`.
16+
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 >= 1000 ns. 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+
Predicate<ReadableSpan> filterPredicate = readableSpan -> {
31+
if(readableSpan.getAttribute(AttributeKey.stringKey("ignorespan")) != null){
32+
return false;
33+
}
34+
return true;
35+
};
36+
SdkTracerProvider tracerProvider = SdkTracerProvider.builder()
37+
.addSpanProcessor(new StackTraceSpanProcessor(exportProcessor, 1000, filterPredicate))
38+
.build();
39+
40+
OpenTelemetrySdk sdk = OpenTelemetrySdk.builder().setTracerProvider(tracerProvider).build();
41+
```
42+
1243
## Component owners
1344

1445
- [Jack Shirazi](https://github.com/jackshirazi), Elastic

0 commit comments

Comments
 (0)