This page covers instrumenting a Swift application with the OpenTelemetry SDK to send logs and traces to Bronto over OTLP/HTTP via a local OTel Collector.Documentation Index
Fetch the complete documentation index at: https://docs.bronto.io/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- Swift 5.7 or later
- Xcode 14 or later, or Swift Package Manager on Linux
- A running OTel Collector configured to forward logs to Bronto — see Connect Open Telemetry to Bronto
- OpenTelemetry Swift SDK repository
Install dependencies
Add theopentelemetry-swift package to your Package.swift:
Package.swift
| Product | Purpose |
|---|---|
OpenTelemetryApi | Core OTel API |
OpenTelemetrySdk | SDK — LoggerProvider, processors |
OtlpHttpExporter | OTLP/HTTP exporter |
ResourceExtension | Helpers for building Resource |
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:| OTel attribute | Bronto concept | Description |
|---|---|---|
service.name | Dataset | Groups logs from one service |
service.namespace | Collection | Groups related services or a team’s services |
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 log collection
After running your application, open the Search page in Bronto. Filter by the dataset name you set inservice.name — your log records should appear within a few seconds.
If no logs appear, check:
- 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
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:| Region | Logs endpoint | Traces endpoint |
|---|---|---|
| EU | https://ingestion.eu.bronto.io/v1/logs | https://ingestion.eu.bronto.io/v1/traces |
| US | https://ingestion.us.bronto.io/v1/logs | https://ingestion.us.bronto.io/v1/traces |

