Swiftpack.co - open-telemetry/opentelemetry-swift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by open-telemetry.
open-telemetry/opentelemetry-swift 1.4.0
OpenTelemetry API for Swift
⭐️ 125
🕓 1 week ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/open-telemetry/opentelemetry-swift.git", from: "1.4.0")


CI codecov

A swift OpenTelemetry client


This package includes several libraries. The OpenTelemetryApi library includes protocols and no-op implementations that comprise the OpenTelemetry API following the specification. The OpenTelemetrySdk library is the reference implementation of the API.

Libraries that produce telemetry data should only depend on OpenTelemetryApi, and defer the choice of the SDK to the application developer. Applications may depend on OpenTelemetrySdk or another package that implements the API.

Adding the dependency

opentelemetry-swift is designed for Swift 5. To depend on the opentelemetry-swift package, you need to declare your dependency in your Package.swift:

.package(url: "https://github.com/open-telemetry/opentelemetry-swift", from: "1.0.0"),

and to your application/library target, add OpenTelemetryApi or OpenTelemetrySdkto your dependencies, e.g. like this:

.target(name: "ExampleTelemetryProducerApp", dependencies: ["OpenTelemetryApi"]),


.target(name: "ExampleApp", dependencies: ["OpenTelemetrySdk"]),


Official documentation for the library can be found in the official opentelemetry documentation page, including:

Current status


Tracing and Baggage should be considered stable

Metrics is implemented using an outdated spec, is fully functional but will change in the future

Logs are currently in development

Supported exporters, importers and instrumentation libraries


  • Exporters: Stdout, Jaeger, Zipkin, Datadog and OpenTelemetry (OTLP) collector
  • Importers: OpenTracingShim


  • Exporters: Prometheus, Datadog, and OpenTelemetry (OTLP) collector
  • Importers: SwiftMetricsShim

Instrumentation libraries

  • URLSession
  • NetworkStatus
  • SDKResourceExtension
  • SignPostIntegration


The package includes some example projects with basic functionality:

  • Datadog Sample - Shows the Datadog exporter used with a Simple Exporter, showing how to configure for sending.
  • Logging Tracer - Simple api implementation of a Tracer that logs every api call
  • Network Tracer - Shows how to use the URLSessionInstrumentation instrumentation in your application
  • Simple Exporter - Shows the Jaeger an Stdout exporters in action using a MultiSpanExporter. Can be easily modified for other exporters
  • Prometheus Sample - Shows the Prometheus exporter reporting metrics to a Prometheus instance
  • OTLP Exporter - Shows the OTLP exporter reporting traces to Zipkin and metrics to a Prometheus via the otel-collector


Stars: 125
Last commit: 13 minutes ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

1 week ago



Network Instrumentation


  • Updated Examples to register the tracer properly (as explained in the documentation)

Full Changelog: https://github.com/open-telemetry/opentelemetry-swift/compare/1.3.1...1.4.0

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics