Skip to content

Commit

Permalink
mark URLRequest as inout parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
batuhansk committed Dec 20, 2024
1 parent 583407c commit 9e7e791
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public struct URLSessionInstrumentationConfiguration {
receivedResponse: ((URLResponse, DataOrFile?, Span) -> Void)? = nil,
receivedError: ((Error, DataOrFile?, HTTPStatus, Span) -> Void)? = nil,
delegateClassesToInstrument: [AnyClass]? = nil,
baggageProvider: ((URLRequest, Span?) -> (Baggage)?)? = nil)
baggageProvider: ((inout URLRequest, Span?) -> (Baggage)?)? = nil)
{
self.shouldRecordPayload = shouldRecordPayload
self.shouldInstrument = shouldInstrument
Expand Down Expand Up @@ -85,6 +85,6 @@ public struct URLSessionInstrumentationConfiguration {
///
/// Note: The injected baggage depends on the propagator in use (e.g., W3C or custom).
/// Returns: A `Baggage` instance or `nil` if no baggage is needed.
public let baggageProvider: ((URLRequest, Span?) -> (Baggage)?)?
public let baggageProvider: ((inout URLRequest, Span?) -> (Baggage)?)?

}
4 changes: 2 additions & 2 deletions Sources/Instrumentation/URLSession/URLSessionLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,12 @@ class URLSessionLogger {
return nil
}
instrumentation.configuration.injectCustomHeaders?(&request, span)
let customBaggage = instrumentation.configuration.baggageProvider?(&request, span)

var instrumentedRequest = request
objc_setAssociatedObject(instrumentedRequest, URLSessionInstrumentation.instrumentedKey, true, .OBJC_ASSOCIATION_COPY_NONATOMIC)
let propagators = OpenTelemetry.instance.propagators

let customBaggage = instrumentation.configuration.baggageProvider?(request, span)

var traceHeaders = tracePropagationHTTPHeaders(span: span,
customBaggage: customBaggage,
textMapPropagator: propagators.textMapPropagator,
Expand Down

0 comments on commit 9e7e791

Please sign in to comment.