OpenTelemetry Swift Configuration
Ship traces from Swift to Opensearch with OpenTelemetry (via https)
Use OpenTelemetry to easily send Swift traces to your Logit.io Stack.
Follow this step by step guide to get 'traces' from your system to Logit.io:
Step 1 - Getting Started
You can get help Getting Started with OpenTelemetry for Swift by referring to the official documentation.
To initialize the trace exporter use the snippet below as a starting point:
import OpenTelemetryApi
import OpenTelemetrySdk
import OpenTelemetryProtocolExporter
let otlpConfiguration = OtlpExporterConfiguration(endpoint: https://<your-opentelemetry-endpoint-address>:<your-opentelemetry-endpoint-port>)
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://<your-opentelemetry-endpoint-address>:<your-opentelemetry-endpoint-port>
OTEL_EXPORTER_OTLP_TRACES_PROTOCOL = <your-opentelemetry-protocol>
OTEL_EXPORTER_OTLP_TRACES_HEADERS = Authorization=Basic <your-encoded-opentelemetry-auth-header-value>
Step 2 - Check Logit.io for your traces
Data should now have been sent to your Stack.
If you don't see traces please take a look at How to diagnose no data in Stack below for how to diagnose common issues.
Step 3 - how to diagnose no data in Stack
If you don't see data appearing in your Stack after following the steps, visit the Help Centre guide for steps to diagnose no data appearing in your Stack or Chat to support now.