You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge pull request #221 from nachoBonafonte/fix-custom-request-manipulation
URLSession instrumentation: Fix request modification
Separate the possibility to modify URLRequest to a new callback: injectCustomHeaders
The previous used callback:shouldInjectTracingHeaders cannot modify it anymore, because for the same request it can be called more than once, and if the request was modified there it could end up processing it twice.
This is a breaking change for current users of shouldInjectTracingHeaders, but not for the rest.
Copy file name to clipboardExpand all lines: Sources/Instrumentation/URLSession/README.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,9 @@ This behaviour can be modified or augmented by using the optional callbacks defi
13
13
14
14
`shouldRecordPayload: ((URLSession) -> (Bool)?)?`: Implement if you want the session to record payload data, false by default.
15
15
16
-
`shouldInjectTracingHeaders: ((inout URLRequest) -> (Bool)?)?`: Allows filtering which requests you want to inject headers to follow the trace, true by default. You can also modify the request or add other headers in this method.
16
+
`shouldInjectTracingHeaders: ((URLRequest) -> (Bool)?)?`: Allows filtering which requests you want to inject headers to follow the trace, true by default. You must also return true if you want to inject custom headers.
17
+
18
+
`injectCustomHeaders: ((inout URLRequest, Span?) -> Void)?`: Implement this callback to inject custom headers or modify the request in any other way
17
19
18
20
`nameSpan: ((URLRequest) -> (String)?)?` - Modifies the name for the given request instead of stantard Opentelemetry name
if selector == #selector(URLSession.dataTask(with:completionHandler:)as(URLSession)->(URL,@escaping(Data?,URLResponse?,Error?)->Void)->URLSessionDataTask){
0 commit comments