Skip to content

Commit 8a208b0

Browse files
committed
added another span to the example
1 parent dfedfb3 commit 8a208b0

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed
-3.81 KB
Loading

Examples/OTLP Exporter/main.swift

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,22 @@ if #available(macOS 10.14, *) {
4545
}
4646

4747
func createSpan() {
48-
let parentSpan = tracer.spanBuilder(spanName: "Main").setSpanKind(spanKind: .client).startSpan()
49-
parentSpan.setAttribute(key: sampleKey, value: sampleValue)
50-
for _ in 1...10 {
51-
doWork(parentSpan: parentSpan)
48+
let parentSpan1 = tracer.spanBuilder(spanName: "Main").setSpanKind(spanKind: .client).startSpan()
49+
parentSpan1.setAttribute(key: sampleKey, value: sampleValue)
50+
for _ in 1...3 {
51+
doWork(parentSpan: parentSpan1)
5252
}
5353
Thread.sleep(forTimeInterval: 0.5)
54-
parentSpan.end()
54+
parentSpan1.end()
55+
56+
let parentSpan2 = tracer.spanBuilder(spanName: "Another").setSpanKind(spanKind: .client).startSpan()
57+
parentSpan2.setAttribute(key: sampleKey, value: sampleValue)
58+
// do more Work
59+
for _ in 1...3 {
60+
doWork(parentSpan: parentSpan2)
61+
}
62+
Thread.sleep(forTimeInterval: 0.5)
63+
parentSpan2.end()
5564
}
5665

5766
func doWork(parentSpan: Span) {

0 commit comments

Comments
 (0)