gsoc-swift-tracing
gsoc-swift-tracing copied to clipboard
Consider tracer.withSpan() { ... } convenience APIs
We can consider tracer.withSpan { ... }
APIs for fluent synchronous usage so calling end is less annoying.
its good to know there is an error but I dont htink theres much user could do about it and logger/tracer should help and not make life difficult
last but not least, I think its good to provide some helpers with closures containing deferred "ends", something like https://github.com/pokryfka/aws-xray-sdk-swift/blob/master/Sources/AWSXRayRecorder/Recorder%2BHelpers.swift
no need to
end
explicitly:recorder.segment(name: "Segment 2", context: context) { segment in try? segment.subsegment(name: "Subsegment 2.1") { segment in _ = segment.subsegment(name: "Subsegment 2.1.1 with Result") { _ -> String in usleep(100_000) return "Result" } try segment.subsegment(name: "Subsegment 2.1.2 with Error") { _ in usleep(200_000) throw ExampleError.test } } }
note that it does not
throw
but it doesrethrow
so no need totry
subsegment "Subsegment 2.1.1 "
Originally posted by @pokryfka in https://github.com/slashmo/gsoc-swift-tracing/issues/96#issuecomment-663831594