base on OpenTelemetry API for Swift # <img src="https://opentelemetry.io/img/logos/opentelemetry-logo-nav.png" alt="OpenTelemetry Icon" width="45" height=""> opentelemetry-swift [![CI](https://github.com/open-telemetry/opentelemetry-swift/actions/workflows/BuildAndTest.yml/badge.svg)](https://github.com/open-telemetry/opentelemetry-swift/actions/workflows/BuildAndTest.yml?query=branch%3Amain+) [![codecov](https://codecov.io/gh/open-telemetry/opentelemetry-swift/branch/master/graph/badge.svg)](https://codecov.io/gh/open-telemetry/opentelemetry-swift) ## About The repository contains the Swift [OpenTelemetry](https://opentelemetry.io/) client ## Getting Started This package includes several libraries. The `OpenTelemetryApi` library includes protocols and no-op implementations that comprise the OpenTelemetry API following the [specification](https://github.com/open-telemetry/opentelemetry-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 dependencies in your `Package.swift`: ```swift .package(url: "https://github.com/open-telemetry/opentelemetry-swift", from: "2.2.0"), .package(url: "https://github.com/open-telemetry/opentelemetry-swift-core.git", from: "2.2.0") ``` and to your application/library target, add `OpenTelemetryApi` or `OpenTelemetrySdk`to your `dependencies`, e.g. like this: ```swift .target( name: "ExampleTelemetryProducerApp", dependencies: [ .product(name: "OpenTelemetryApi", package: "opentelemetry-swift-core") ]) ``` or ```swift .target( name: "ExampleApp", dependencies: [ .product(name: "OpenTelemetrySdk", package: "opentelemetry-swift-core") ]) ``` ### Cocoapods As of version 1.11.0, OpenTelemetry-Swift support cocoapods. Two pods are provided: - `OpenTelemetry-Swift-Api` - `OpenTelemetry-Swift-Sdk` `OpenTelemetry-Swift-Api` is a dependency of `OpenTelemetry-Swift-Sdk`. Most users will want to add the following to their pod file: `pod 'OpenTelemetry-Swift-Sdk'` This will add both the API and SDK. If you're only interesting in Adding the API add the following: `pod 'OpenTelemetry-Swift-Api'` ## Documentation Official documentation for the library can be found in the official opentelemetry [documentation page](https://opentelemetry.io/docs/instrumentation/swift/), including: * Documentation about installation and [manual instrumentation](https://opentelemetry.io/docs/instrumentation/swift/manual/) * [Libraries](https://opentelemetry.io/docs/instrumentation/swift/libraries/) that provide automatic instrumentation ## 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` * `SessionsEventInstrumentation` ### Third-party exporters In addition to the specified OpenTelemetry exporters, some third-party exporters have been contributed and can be found in the following repos: * [Grafana/faro](https://github.com/grafana/faro-otel-swift-exporter) ## 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 ## Contributing We'd love your help! Use labels [![help wanted](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-swift?query=is%3Aissue%20is%3Aopen%20label%3A%22help%20wanted%22&label=help%20wanted&color=rgb(0%2C%20134%2C%20114)&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-swift/issues?q=state%3Aopen%20label%3A%22help%20wanted%22) and [![good first issue](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-swift?query=is%3Aissue%20is%3Aopen%20label%3A%22good%20first%20issue%22&label=good%20first%20issue&color=rgb(112%2C%2087%2C%20255)&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-swift/issues?q=state%3Aopen%20label%3A%22good%20first%20issue%22) to get started with the project. For an overview of how to contribute, see the contributing guide in [CONTRIBUTING.md](CONTRIBUTING.md). We have a weekly SIG meeting! See the [community page](https://github.com/open-telemetry/community#swift-sdk) for meeting details and notes. We are also available in the [#otel-swift](https://cloud-native.slack.com/archives/C01NCHR19SB) channel in the [CNCF slack](https://slack.cncf.io/). Please join us there for OTel Swift discussions. ### Maintainers - [Ariel Demarco](https://github.com/arieldemarco), Embrace - [Bryce Buchanan](https://github.com/bryce-b), Elastic - [Ignacio Bonafonte](https://github.com/nachobonafonte), Independent For more information about the maintainer role, see the [community repository](https://github.com/open-telemetry/community/blob/main/guides/contributor/membership.md#maintainer). ### Approvers - [Austin Emmons](https://github.com/atreat), Embrace - [Vinod Vydier](https://github.com/vvydier), Independent For more information about the approver role, see the [community repository](https://github.com/open-telemetry/community/blob/main/guides/contributor/membership.md#approver). ### Triager ([@open-telemetry/swift-triagers](https://github.com/orgs/open-telemetry/teams/swift-triagers)) - [Alolita Sharma](https://github.com/alolita), Apple - [Billy Zhou](https://github.com/williazz), AWS For more information about the triager role, see the [community repository](https://github.com/open-telemetry/community/blob/main/community-membership.md#triager). ", Assign "at most 3 tags" to the expected json: {"id":"12104","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"