File tree Expand file tree Collapse file tree 3 files changed +18
-6
lines changed
Sources/Exporters/OpenTelemetryProtocol Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -19,9 +19,13 @@ public class OtlpHttpLogExporter : LogRecordExporter {
1919 private let httpClient : HTTPClient
2020 var pendingLogRecords : [ ReadableLogRecord ] = [ ]
2121
22- public init ( endpoint: URL = defaultOltpHttpLoggingEndpoint ( ) ) {
22+ public init ( endpoint: URL = defaultOltpHttpLoggingEndpoint ( ) , useSession : URLSession ? = nil ) {
2323 self . endpoint = endpoint
24- self . httpClient = HTTPClient ( )
24+ if let providedSession = useSession {
25+ self . httpClient = HTTPClient ( session: providedSession)
26+ } else {
27+ self . httpClient = HTTPClient ( )
28+ }
2529 }
2630
2731 public func export( logRecords: [ OpenTelemetrySdk . ReadableLogRecord ] ) -> OpenTelemetrySdk . ExportResult {
Original file line number Diff line number Diff line change @@ -15,9 +15,13 @@ public class OtlpHttpMetricExporter: MetricExporter {
1515 private let httpClient : HTTPClient
1616 var pendingMetrics : [ Metric ] = [ ]
1717
18- public init ( endpoint: URL = defaultOltpHTTPMetricsEndpoint ( ) ) {
18+ public init ( endpoint: URL = defaultOltpHTTPMetricsEndpoint ( ) , useSession : URLSession ? = nil ) {
1919 self . endpoint = endpoint
20- self . httpClient = HTTPClient ( ) ;
20+ if let providedSession = useSession {
21+ self . httpClient = HTTPClient ( session: providedSession)
22+ } else {
23+ self . httpClient = HTTPClient ( )
24+ }
2125 }
2226
2327 public func export( metrics: [ Metric ] , shouldCancel: ( ( ) -> Bool ) ? ) -> MetricExporterResultCode {
Original file line number Diff line number Diff line change @@ -15,9 +15,13 @@ public class OtlpHttpTraceExporter: SpanExporter {
1515 private let httpClient : HTTPClient
1616 var pendingSpans : [ SpanData ] = [ ]
1717
18- public init ( endpoint: URL = defaultOltpHttpTracesEndpoint ( ) ) {
18+ public init ( endpoint: URL = defaultOltpHttpTracesEndpoint ( ) , useSession : URLSession ? = nil ) {
1919 self . endpoint = endpoint
20- self . httpClient = HTTPClient ( )
20+ if let providedSession = useSession {
21+ self . httpClient = HTTPClient ( session: providedSession)
22+ } else {
23+ self . httpClient = HTTPClient ( )
24+ }
2125 }
2226
2327 public func export( spans: [ SpanData ] ) -> SpanExporterResultCode {
You can’t perform that action at this time.
0 commit comments