OpenTelemetry Swift Configuration

Ship traces from Swift to OpenSearch with OpenTelemetry

Use OpenTelemetry to easily send Swift traces to your Logit.io Stack.

Install Integration

Please click on the Install Integration button to configure your stack for this source.

Getting Started

You can get help Getting Started with OpenTelemetry for Swift by referring to the official documentation (opens in a new tab).

To initialize the trace exporter use the snippet below as a starting point:

import OpenTelemetryApi
import OpenTelemetrySdk
import OpenTelemetryProtocolExporter
 
let otlpConfiguration = OtlpExporterConfiguration(
  endpoint: "https://@opentelemetry.endpointAddress:@opentelemetry.httpsPort/v1/traces")
  
let traceExporter = OtlpHttpTraceExporter(config: otlpConfiguration)
 
OpenTelemetry.registerTracerProvider(tracerProvider: TracerProviderBuilder()
    .add(spanProcessor:SimpleSpanProcessor(spanExporter: traceExporter))
    .with(resource: Resource())
    .build())

You can also configure various settings by specifying the appropriate Environment variables, for example:

OTEL_TRACES_EXPORTER = otlp
OTEL_EXPORTER_OTLP_ENDPOINT = https://@opentelemetry.endpointAddress:@port
OTEL_EXPORTER_OTLP_TRACES_PROTOCOL = @protocol
OTEL_EXPORTER_OTLP_TRACES_HEADERS = Authorization=Basic @opentelemetry.base64encodedAuthString

Launch Logit.io to view your traces

Data should now have been sent to your Stack.

View My Data

If you don't see take a look at How to diagnose no data in Stack below for how to diagnose common issues.

How to diagnose no data in Stack

If you don't see data appearing in your stack after following this integration, take a look at the troubleshooting guide for steps to diagnose and resolve the problem or contact our support team and we'll be happy to assist.