Skip to main content
This page covers instrumenting a .NET application with the OpenTelemetry SDK to send logs and traces to Bronto over OTLP/HTTP via a local OTel Collector. Both signals are co-equal: logs are bridged from ILogger — no log statement changes needed — and traces are emitted via a tracer provider.
If you don’t have a Collector and want to export directly from your application to Bronto, see Direct export to Bronto at the bottom of this page.

Prerequisites

Install dependencies

Configure the log bridge

The OTel .NET SDK integrates with Microsoft.Extensions.Logging via AddOpenTelemetry(). Every log record emitted through ILogger is forwarded to the OTel pipeline automatically. For ASP.NET Core or any host using Microsoft.Extensions.Hosting, configure logging in Program.cs:
Program.cs
IncludeFormattedMessage attaches the rendered log message as the OTel record body. IncludeScopes propagates any active ILogger scope values as structured attributes.

Configure the OTLP exporter

Wire the OTLP exporter into the logging pipeline. By default the OTel Collector listens for OTLP/HTTP on port 4318.
Program.cs
If your Collector runs on a different host or port, update the endpoint accordingly.

Set resource attributes

Resource attributes are attached to every log record exported from this process. Two attributes drive how Bronto organises incoming logs: Set them via ConfigureResource on the OpenTelemetryBuilder:
Program.cs

Complete example

The snippet below shows the full Program.cs setup for an ASP.NET Core application.
Program.cs
For non-hosted applications (console apps, workers), use LoggerFactory.Create with the same AddOpenTelemetry and AddOtlpExporter calls instead of builder.Logging.

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.
If no logs appear, check:
  • The OTel Collector is running and reachable at the configured endpoint.
  • The Collector’s pipeline includes a logs pipeline with an otlp receiver and the Bronto exporter — see Connect Open Telemetry to Bronto.
  • The OtlpExportProtocol.HttpProtobuf protocol matches the Collector’s configured receiver.

Traces

For ASP.NET Core, HTTP clients, and Entity Framework Core, add the corresponding NuGet instrumentation packages — OpenTelemetry.Instrumentation.AspNetCore, OpenTelemetry.Instrumentation.Http, OpenTelemetry.Instrumentation.EntityFrameworkCore — then call .AddAspNetCoreInstrumentation(), .AddHttpClientInstrumentation(), etc. inside WithTracing. See .NET instrumentation libraries for the full list.

Configure the tracer provider

No additional packages are needed — OpenTelemetry.Extensions.Hosting and OpenTelemetry.Exporter.OpenTelemetryProtocol already include tracing support. Add WithTracing to the same AddOpenTelemetry call you used for logging:
Program.cs
ConfigureResource applies to both logs and traces — service.name and service.namespace are shared automatically.

Creating spans

Inject ActivitySource and use it to create spans around operations you want to trace:
Any ILogger call made inside an active Activity span will have trace_id and span_id injected automatically.

GenAI semantic conventions

If your application calls an LLM, OpenTelemetry defines GenAI semantic conventions for model, token usage, and prompt/response content.
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.

Auto-instrumentation

Several .NET AI libraries provide GenAI telemetry, but each has its own opt-in:
  • Semantic Kernel: enable SEMANTICKERNEL_EXPERIMENTAL_GENAI_ENABLE_OTEL_DIAGNOSTICS=true, then add its activity source:
  • OpenAI .NET SDK: enable its experimental OpenTelemetry switch with AppContext.SetSwitch("OpenAI.Experimental.EnableOpenTelemetry", true), then add OpenAI.* as a source.
  • Microsoft.Extensions.AI: wrap an IChatClient with UseOpenTelemetry(); set EnableSensitiveData when you intentionally want message content recorded.
  • AWS SDK: OpenTelemetry.Instrumentation.AWS covers Bedrock Runtime and Agent Runtime clients.
Check each library’s current documentation because these APIs are experimental and version-sensitive.

Experimental: capturing prompt and response content

Content capture is configured by the .NET library rather than the cross-language OTel environment variables. For Semantic Kernel, use the sensitive diagnostics opt-in:
Prompt and response content can contain sensitive data. Microsoft.Extensions.AI uses its EnableSensitiveData option instead; the OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT variable used by some JavaScript, Java, and Python instrumentations is not a .NET-wide switch.

Manual spans

See LLM Observability for the full recommended attribute set, including gen_ai.input.messages / gen_ai.output.messages, and how to search and aggregate GenAI fields in Bronto.

Direct export to Bronto

If you are not using an OTel Collector, export directly to Bronto by replacing the exporter endpoints and adding 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.