|
1 | 1 | ---
|
2 | 2 | title: Instrumentation Libraries
|
3 | 3 | linkTitle: Libraries
|
4 |
| -description: How to use Swift instrumentation libraries |
5 | 4 | weight: 40
|
6 | 5 | cSpell:ignore: darwin inout iphone NSURL wifi
|
7 | 6 | ---
|
8 | 7 |
|
9 | 8 | <!-- markdownlint-disable no-duplicate-heading -->
|
10 | 9 |
|
11 |
| -OpenTelemetry-Swift provides several instrumentation libraries that generate |
12 |
| -instrumentation for you when they're installed and initialized. |
| 10 | +{{% docs/languages/libraries-intro "Swift" %}} |
| 11 | + |
| 12 | +## Use instrumentation libraries |
| 13 | + |
| 14 | +OpenTelemetry-Swift provides several |
| 15 | +[instrumentation libraries](/docs/specs/otel/glossary/#instrumentation-library) |
| 16 | +that generate instrumentation for you when they're installed and initialized. |
| 17 | + |
| 18 | +For example, |
| 19 | +[the NSURLSession instrumentation](https://github.com/open-telemetry/opentelemetry-swift/tree/main/Sources/Instrumentation/URLSession) |
| 20 | +automatically creates [spans](/docs/concepts/signals/traces/#spans) for all |
| 21 | +network requests made with NSURLSessions. |
| 22 | + |
| 23 | +## Setup |
| 24 | + |
| 25 | +All instrumentation libraries are available in OpenTelemetry Swift. To turn on |
| 26 | +an instrumentation, follow its usage instructions. |
13 | 27 |
|
14 | 28 | ## `SDKResourceExtension`
|
15 | 29 |
|
@@ -57,7 +71,7 @@ values to the appropriate
|
57 | 71 | | `os.version` | `15.4.0` | `ProcessInfo.processInfo.operatingSystemVersion` |
|
58 | 72 | | `os.description` | `iOS Version 15.4 (Build 19E240)` | A combination of os name, version and build. |
|
59 | 73 |
|
60 |
| -## `NSURLSession` Instrumentation |
| 74 | +## `NSURLSession` instrumentation |
61 | 75 |
|
62 | 76 | This instrumentation creates spans for all network requests made with
|
63 | 77 | NSURLSessions. It also injects distributed tracing headers in instrumented
|
@@ -147,10 +161,26 @@ events. This functionality is shown in `Simple Exporter` example.
|
147 | 161 |
|
148 | 162 | ### Usage
|
149 | 163 |
|
150 |
| -Just add SignpostIntegration as any other Span Processor (see the |
| 164 | +Add SignpostIntegration as any other Span Processor (see the |
151 | 165 | [manual instrumentation](../instrumentation/)) docs for details on configuring
|
152 | 166 | your providers:
|
153 | 167 |
|
154 | 168 | ```swift
|
155 | 169 | OpenTelemetry.instance.tracerProvider.addSpanProcessor(SignPostIntegration())
|
156 | 170 | ```
|
| 171 | + |
| 172 | +## Available instrumentation libraries |
| 173 | + |
| 174 | +A full list of instrumentation libraries produced by OpenTelemetry is available |
| 175 | +from the |
| 176 | +[opentelemetry-swift](https://github.com/open-telemetry/opentelemetry-swift/tree/main/Sources/Instrumentation) |
| 177 | +repository. |
| 178 | + |
| 179 | +You can also find more instrumentations available in the |
| 180 | +[registry](/ecosystem/registry/?language=swift&component=instrumentation). |
| 181 | + |
| 182 | +## Next steps |
| 183 | + |
| 184 | +After you have set up instrumentation libraries, you might want to add your own |
| 185 | +[instrumentation](/docs/languages/swift/instrumentation) to your code, to |
| 186 | +collect custom telemetry data. |
0 commit comments