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
This example shows the `URLSessionInstrumentation` in action.
4
+
It only shows the minimum configuration: Just by initializing the class, all network request that happen after it will be captured by Opentelemetry as Spans. Check [`URLSessionInstrumentation` README](Sources/Instrumentation/URLSession/README.md) for more information.
Apple have created their own metrics API which has been adopted by a number of other packages including, but not limited to, Vapor - a prominent Server Side Swift platform.
4
+
5
+
This shim essentially redirects the data to the OpenTelemetry API functions.
6
+
7
+
```
8
+
let meter: Meter = // ... Your existing code to create a meter
9
+
let metrics = OpenTelemetrySwiftMetrics(meter: meter)
This package captures the network calls produced by URLSession.
4
+
5
+
6
+
## Usage
7
+
8
+
Initialize the class with `URLSessionInstrumentation(configuration: URLSessionInstrumentationConfiguration())` to automatically capture all network calls.
9
+
10
+
This behaviour can be modified or augmented by using the optional callbacks defined in `URLSessionInstrumentationConfiguration` :
11
+
12
+
`shouldInstrument: ((URLRequest) -> (Bool)?)?` : Filter which requests you want to instrument, all by default
13
+
14
+
`shouldRecordPayload: ((URLSession) -> (Bool)?)?`: Implement if you want the session to record payload data, false by default.
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.
17
+
18
+
`nameSpan: ((URLRequest) -> (String)?)?` - Modifies the name for the given request instead of stantard Opentelemetry name
19
+
20
+
`createdRequest: ((URLRequest, Span) -> Void)?` - Called after request is created, it allows to add extra information to the Span
21
+
22
+
`receivedResponse: ((URLResponse, DataOrFile?, Span) -> Void)?`- Called after response is received, it allows to add extra information to the Span
23
+
24
+
`receivedError: ((Error, DataOrFile?, HTTPStatus, Span) -> Void)?` - Called after an errror is received, it allows to add extra information to the Span
0 commit comments