Prerequisites
- Swift 5.7 or later
- Xcode 14 or later, or Swift Package Manager on Linux
- A running OTel Collector configured to forward logs and traces to Bronto — see Connect Open Telemetry to Bronto
- OpenTelemetry Swift SDK repository
Install dependencies
Add theopentelemetry-swift package to your Package.swift:
Package.swift
Configure the log bridge
Set up aLoggerProvider with an OTLP exporter and register it as the global OTel logs provider.
OtelLogging.swift
configureOtelLogging() once at application startup, before the first log emission.
Configure the OTLP exporter
TheexporterEndpoint in the snippet above connects to the OTel Collector on localhost:4318. If your Collector runs on a different host or port, update the URL accordingly.
Set resource attributes
Resource attributes are attached to every log record exported from this process. Two attributes drive how Bronto organises incoming logs:
These are set via
Resource(attributes:) in the setup above.
Complete example
main.swift
A direct bridge to Apple’s
os.Logger (Unified Logging) is not yet available in the official SDK. The example above emits log records via the OTel Logs API directly. For apps targeting Apple platforms, you can emit to both os.Logger and OTel from a thin wrapper function.Verify delivery
After running your application, check both signals in Bronto:- Logs: open the Search page and filter by the dataset name you set in
service.name— your log records should appear within a few seconds. - Traces: open the Explore Traces page and filter by the same
service.name— your spans should appear within a few seconds.
- The OTel Collector is running and reachable at the configured endpoint.
- The Collector’s pipeline includes a
logspipeline with anotlpreceiver and the Bronto exporter — see Connect Open Telemetry to Bronto. configureOtelLogging()is called before the first log emission.- The
BatchLogRecordProcessorexports on a background timer — ensure your process does not exit before the first flush interval.
Traces
Install tracing dependencies
AddStdoutExporter or OtlpHttpTraceExporter from the same opentelemetry-swift package — no additional Swift Package Manager entries are needed. Add OpenTracingShim if you need OpenTracing compatibility:
Package.swift
Configure the tracer provider
OtelTracing.swift
resource used for logging so both signals share service.name and service.namespace.
Creating spans
GenAI semantic conventions
If your application calls an LLM, OpenTelemetry defines GenAI semantic conventions. There is no first-party GenAI auto-instrumentation package for Swift yet — set the attributes yourself around each LLM call:This page was verified on July 17, 2026. GenAI libraries and semantic conventions are evolving rapidly, so package configuration and emitted attributes can change between releases. Keep your instrumentation current and verify the fields emitted by the version you deploy.
Message content (
gen_ai.input.messages / gen_ai.output.messages) is opt-in by convention in languages with auto-instrumentation, off by default. Since you’re setting attributes by hand here, apply the same discipline — gate prompt/response content behind your own config flag rather than always sending it.Direct export to Bronto
If you are not using an OTel Collector, export directly to Bronto by replacing the exporter configurations with the Bronto OTLP endpoints and your API key:
See API Keys for how to create a key with ingestion permissions. No other changes to the rest of the setup are required.

