Skip to content

smartlook/opentelemetry-swift

This branch is 1 commit ahead of, 86 commits behind open-telemetry/opentelemetry-swift:main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

daa2fd4 · Feb 9, 2024
Jun 16, 2023
Sep 15, 2022
Feb 8, 2024
Sep 28, 2023
Feb 8, 2024
Feb 8, 2024
Jul 27, 2022
Apr 4, 2021
Feb 13, 2023
Jul 9, 2023
Jul 5, 2023
Feb 19, 2020
Jun 16, 2023
Oct 27, 2023
Sep 14, 2023
Jun 6, 2023
Oct 27, 2023
Mar 22, 2023

Repository files navigation

opentelemetry-swift

CI codecov

A swift OpenTelemetry client

Installation

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"]),

or

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

Documentation

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

Current status

API and SDK

Tracing and Baggage are considered stable

Logs are considered beta quality

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

Supported exporters and importers

Traces

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

Metrics

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

Logs

  • Exporters: OpenTelemetry (OTLP) collector

NOTE: OTLP exporters are supported both in GRPC and HTTP, only GRPC is production ready, HTTP is still experimental

Instrumentation libraries

  • URLSession
  • NetworkStatus
  • SDKResourceExtension
  • SignPostIntegration

Examples

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

Releases

No releases published

Packages

No packages published

Languages

  • Swift 99.6%
  • Other 0.4%