From 73a27a6f44f08d01b201196684e6f9c6652fbbbf Mon Sep 17 00:00:00 2001 From: Konrad Malawski Date: Thu, 9 Oct 2025 08:33:44 +0900 Subject: [PATCH] [Tracing] Default tracer to global bootstrapped tracer The default tracer should be picked up at configuration creation time from the bootstrapped one, so we don't have to manually configure it in the simplest cases. It is possible to disable it by explicitly setting `nil` on the tracing configuration, even if the global tracer was bootstrapped. --- Sources/AsyncHTTPClient/HTTPClient.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/AsyncHTTPClient/HTTPClient.swift b/Sources/AsyncHTTPClient/HTTPClient.swift index fdb453e7e..80df3b946 100644 --- a/Sources/AsyncHTTPClient/HTTPClient.swift +++ b/Sources/AsyncHTTPClient/HTTPClient.swift @@ -1095,7 +1095,11 @@ public final class HTTPClient: Sendable { package var attributeKeys: AttributeKeys public init() { - self._tracer = nil + if #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) { + self._tracer = InstrumentationSystem.tracer + } else { + self._tracer = nil + } self.attributeKeys = .init() }