How danvega/ot works
Purpose and runtime
This is a Java 17+ Spring Boot 4 demo of the official OpenTelemetry starter. It exposes simple HTTP endpoints while demonstrating automatic OTLP export of traces, metrics, and logs to a vendor-neutral observability backend. Maven is the build/runtime entry point; the application is launched through src/main/java/dev/danvega/ot/Application.java.
HTTP application surface
HomeController is the primary business-facing boundary, serving GET /, GET /greet/{name}, and GET /slow. The greeting and delayed paths create observable request work and application logs, allowing generated telemetry to be inspected end-to-end.
• src/main/java/dev/danvega/ot/HomeController.java
• src/main/java/dev/danvega/ot/Application.java
Spring Boot observability pipeline
Spring Boot auto-configuration, driven by the OpenTelemetry starter declared in pom.xml, instruments inbound HTTP requests and integrates Micrometer tracing with OpenTelemetry. Requests become traces/spans; framework/application metrics are emitted through OTLP; trace context is made available to logging.
• pom.xml
• src/main/resources/application.yaml
Logging-to-OTLP bridge
Logback writes both normal console output and events to the OpenTelemetry Logback appender. The appender requires the Spring-managed OpenTelemetry SDK instance, so a lifecycle bean installs that instance after context initialization. This is the explicit custom integration required beyond starter auto-configuration.
• src/main/resources/logback-spring.xml
• src/main/java/dev/danvega/ot/InstallOpenTelemetryAppender.java
Telemetry configuration boundary
application.yaml establishes the application identity and telemetry behavior, including full development trace sampling and OTLP exporter configuration when not supplied by Compose integration. The key boundary is OTLP/HTTP: metrics, traces, and logs leave the process through collector endpoints rather than application-specific vendor SDKs.
• src/main/resources/application.yaml
Local infrastructure and external services
compose.yaml provides the local Grafana LGTM observability stack. Spring Boot Docker Compose integration can detect this service and configure OTLP connectivity automatically. Grafana is the visualization entry point; its backing components are Loki for logs, Tempo for traces, and Mimir/Prometheus-compatible metrics storage.
• compose.yaml
• pom.xml
End-to-end control flow
1. Spring starts Application, creates the web server, OpenTelemetry SDK, exporters, and the appender installation bean.
2. An HTTP request reaches HomeController; automatic server instrumentation creates request spans and timing metrics.
3. Controller logs inherit active trace/span context; Logback sends them to console and the OTEL appender.
4. OTLP exporters transmit traces, metrics, and logs to the LGTM collector.
5. Grafana queries Tempo, Loki, and metrics storage for correlated inspection by service and trace identifiers.
Main entry points: compose.yaml LGTM collector · pom.xml Boot observability auto-config · application.yaml OTLP/HTTP export · Application.java Application
Components 15
Spring Boot application
- Application · Bootstraps the application context and web server.
src/main/java/dev/danvega/ot/Application.java - HomeController · Serves /, /greet/{name}, and /slow.
src/main/java/dev/danvega/ot/HomeController.java - Application telemetry config · Defines service identity, sampling, and OTLP behavior.
src/main/resources/application.yaml
OpenTelemetry pipeline
- Boot observability auto-config · Creates HTTP spans, metrics, and trace-aware logging context.
pom.xml - OpenTelemetry SDK · Spring-managed SDK used by instrumentation and exporters.
- Appender installer · Installs the Spring-managed SDK into the Logback appender.
src/main/java/dev/danvega/ot/InstallOpenTelemetryAppender.java - Logback OTEL appender · Writes application logs to console and OpenTelemetry.
src/main/resources/logback-spring.xml - OTLP/HTTP export · Exports traces, metrics, and logs without a vendor SDK.
src/main/resources/application.yaml
Local LGTM stack
- Docker Compose integration · Provides and discovers the local observability service.
compose.yaml - LGTM collector · Receives process telemetry for the local stack.
compose.yaml - Grafana · Correlates telemetry by service and trace identifiers.
compose.yaml - Tempo
compose.yaml - Loki
compose.yaml - Mimir metrics store · Prometheus-compatible metrics storage.
compose.yaml
Other components
- Maven build & runtime · Supplies Spring Boot and OpenTelemetry starter dependencies.
pom.xml
Connections 22
- Maven build & runtime → Application: launches
- Maven build & runtime → Boot observability auto-config: declares starter
- Application → HomeController: routes HTTP requests
- Application → Appender installer: creates lifecycle bean
- Application telemetry config → Boot observability auto-config: configures
- Application telemetry config → OTLP/HTTP export: sets identity and endpoints
- Boot observability auto-config → OpenTelemetry SDK: creates and uses
- HomeController → Boot observability auto-config: request instrumentation
- HomeController → Logback OTEL appender: application logs
- Appender installer → Logback OTEL appender: installs SDK
- OpenTelemetry SDK → Appender installer: provides SDK instance
- Boot observability auto-config → OTLP/HTTP export: traces and metrics
- Logback OTEL appender → OTLP/HTTP export: log events
- Docker Compose integration → LGTM collector: provisions
- Docker Compose integration → OTLP/HTTP export: may supply connectivity
- OTLP/HTTP export → LGTM collector: OTLP traces, metrics, logs
- LGTM collector → Tempo: stores traces
- LGTM collector → Loki: stores logs
- LGTM collector → Mimir metrics store: stores metrics
- Grafana → Tempo: queries
- Grafana → Loki: queries
- Grafana → Mimir metrics store: queries