Skip to main content
This page covers instrumenting a Java 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 via the Logback or Log4j2 appender — 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

Use the OpenTelemetry BOM to manage all SDK versions in one place and avoid version conflicts.
Using Log4j2 instead of Logback? Replace the appender dependency with opentelemetry-log4j-appender-2.17 from io.opentelemetry.instrumentation.

Configure the log bridge

Add the OpenTelemetryAppender to your logback.xml. Every log record Logback handles will be forwarded to the OTel pipeline.
logback.xml
captureExperimentalAttributes includes thread name and logger name as OTel attributes. captureCodeAttributes includes the source file, class, method, and line number.

Configure the OTLP exporter

Create an OpenTelemetrySdk instance with a SdkLoggerProvider and install it as the global instance. Call OpenTelemetryAppender.install() to wire the Logback appender to the SDK.
OtelConfig.java
Call OtelConfig.configure() once at application startup, before the first log statement.

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.create() in the SDK configuration above.

Complete example

Main.java
Existing SLF4J / Logback log statements require no changes.

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.
  • OpenTelemetryAppender.install() is called before the first log statement.
  • BatchLogRecordProcessor exports on a background thread — for short-lived programs, add a shutdown hook: loggerProvider.shutdown().

Traces

The OpenTelemetry Java Agent provides zero-code auto-instrumentation for Spring, Hibernate, gRPC, Kafka, JDBC, and many more frameworks. Download the jar and attach it at startup with -javaagent:opentelemetry-javaagent.jar — no SDK code changes are needed. It is the recommended starting point for most Java applications.

Configure the tracer provider

No additional packages are needed — opentelemetry-sdk and opentelemetry-exporter-otlp already include tracing support. Create a SdkTracerProvider and combine it with the SdkLoggerProvider in the same OpenTelemetrySdk builder:
OtelConfig.java
The shared resource ensures service.name and service.namespace are identical on both logs and traces.

Creating spans

Get a tracer from the global instance and use it to create spans:
Any Logback or Log4j2 statement inside an active span will automatically have trace_id and span_id attached.

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

The OpenTelemetry Java Agent includes GenAI instrumentation for the OpenAI Java client and AWS SDK v2 Bedrock calls — no extra instrumentation dependency is needed. Model calls carry gen_ai.provider.name, gen_ai.request.model, and token-usage attributes instead of only a plain HTTP client span.
GenAI instrumentation coverage in the Java agent is newer and narrower than Python’s — check the agent’s supported libraries list for your provider/framework. If it isn’t covered, use manual spans below.

Experimental: capturing prompt and response content

For the Java agent’s OpenAI and AWS SDK instrumentations, content capture is off by default:
Captured content may be emitted as OTel log events rather than span attributes, depending on the instrumented client and agent version. It then travels through the logs pipeline and is not queryable on the trace span itself.To make it searchable, also emit it as a structured log record correlated by trace_id, using the log bridge configured above. See LLM Observability for the recommended attribute names, a worked logging example, and Bronto search queries.

Manual spans

Where the agent doesn’t cover your provider or framework, set the gen_ai.* attributes yourself:
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 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.