OpenTelemetry Collector Dev Service
A service providing an OpenTelemetry Collector for development and testing purposes.
It works with Spring Boot libraries that support OpenTelemetry, including:
|
This Dev Service is mutually exclusive with other OpenTelemetry dev services. If more than one is active at the same time, the application will fail at startup with a clear error message. Disable all but one by setting |
Dependencies
First, you need to add the Dev Service dependency to your project.
-
Gradle
-
Maven
dependencies {
testAndDevelopmentOnly "io.arconia:arconia-dev-services-otel-collector"
}
<dependency>
<groupId>io.arconia</groupId>
<artifactId>arconia-dev-services-otel-collector</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
You can optionally include the Spring Boot DevTools dependency to enable live reload of your application during development.
-
Gradle
-
Maven
dependencies {
developmentOnly "org.springframework.boot:spring-boot-devtools"
}
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
|
When you use the Spring Boot DevTools in your project and run the application in dev mode, Arconia keeps the Dev Services running while you make changes to your code instead of restarting them with the application. This allows you to see the changes in real-time without having to restart the Dev Services. Changes to the configuration of a Dev Service take effect once you stop and start the application again. |
Running the Application
When using the Arconia Dev Services, you can keep running your application as you normally would. The Dev Services will automatically start when you run your application.
-
Gradle
-
Maven
-
CLI
./gradlew bootRun
./mvnw spring-boot:run
arconia dev
Unlike the lower-level Testcontainers support in Spring Boot, Arconia doesn’t require special tasks to run your application when using Dev Services (./gradlew bootTestRun or ./mvnw spring-boot:test-run) nor requires you to define a separate @SpringBootApplication class for configuring Testcontainers.
|
In test mode, the Dev Service is skipped by default, since most tests have no use for a telemetry backend. For the tests that verify the telemetry the application exports, set arconia.dev.services.otel-collector.skip-in-tests to false, preferably in a configuration shared by those tests, such as an application-test.yml file, so that they share one application context and one container (see Dev Services in Test Mode).
By default, when running the application in dev mode, multiple applications running simultaneously use the same OpenTelemetry Collector Dev Service: the application connects to a running OpenTelemetry Collector Dev Service started by another application if available, or else starts its own that other applications can discover in turn. To always start a container for the application alone, set the arconia.dev.services.otel-collector.reuse-strategy property to none. Learn more about Reusing Dev Services.
Exploring the Telemetry
The application logs will show you the URLs where the OpenTelemetry Collector is accepting logs, metrics, and traces.
...i.a.d.s.startup : Dev Service 'otel-collector' is ready in container <container-id> (otel/opentelemetry-collector-contrib, localhost:<port>, reuse-strategy: framework)
...i.a.d.s.startup : Dev Service 'otel-collector' links: OTLP/gRPC: http://localhost:<port>, OTLP/HTTP: http://localhost:<port>
By default, logs, metrics, and traces are exported via OTLP using the HTTP/Protobuf format.
|
The Dev Service runs the image’s built-in default configuration, whose pipeline only exports the received telemetry to the collector’s own debug exporter, visible in the collector container logs (see Troubleshooting to stream them into the application log). It is meant for locally inspecting what your application emits, not for forwarding telemetry to another backend. To route telemetry elsewhere, supply a custom collector configuration as described in the next section. |
Customizing the Collector Configuration
To go beyond the built-in default configuration, for example to forward telemetry to another backend, you can supply your own collector configuration file and copy it into the container via the resources property (see Resource Mappings). Each mapping requires two values:
-
Source path: Location of the resource on the classpath or filesystem;
-
Container path: Destination path inside the container.
The OpenTelemetry Collector reads its configuration from /etc/otelcol-contrib/config.yaml, so copying your file to that path replaces the default configuration.
arconia:
dev:
services:
otel-collector:
resources:
- source-path: otel-collector-config.yml
container-path: /etc/otelcol-contrib/config.yaml
|
Make sure your configuration keeps the OTLP receiver listening on the default ports ( |
Configuring the Dev Service
You can configure the Dev Service via configuration properties.
| Property | Default | Description |
|---|---|---|
|
|
Whether the dev service is enabled. |
|
|
Full name of the container image used in the dev service. |
|
|
Environment variables to set in the service. |
|
|
Additional hostnames the dev service container is reachable by on the shared network, next to the name of the dev service. Only applicable when the shared network is enabled. |
|
|
Fixed port for exposing the OTLP HTTP port to the host. When it’s 0 (default), a random available port is assigned dynamically. |
|
|
Resources from the classpath or host filesystem to copy into the container. They can be files or directories that will be copied to the specified destination path inside the container at startup and are immutable (read-only). |
|
|
Strategy for reusing a running container for the dev service across applications or restarts. Only applicable in dev mode. See Reusing Dev Services. |
|
|
Maximum waiting time for the service to start, counted from the container start. |
|
|
Files or directories to mount from the host filesystem into the container. They are mounted at the specified destination path inside the container at startup and are mutable (read-write). Changes in either the host or the container will be immediately reflected in the other. |
|
|
Whether the dev service is skipped in test mode, where the application rarely needs a telemetry backend. Set it to false for tests that verify the telemetry the application exports. |
|
|
Fixed port for exposing the OTLP gRPC port to the host. When it’s 0 (default), a random available port is assigned dynamically. |
|
|
Whether to enable SSL support for the dev service. |
|
Location or content of the certificate or certificate chain in PEM format. |
|
|
Location or content of the private key in PEM format. |
|
|
Password used to decrypt an encrypted private key. |
|
|
The alias that identifies the key in the key store. |
|
|
The password used to access the key in the key store. |
|
|
|
SSL Protocol to use. |
|
Supported SSL ciphers. |
|
|
Enabled SSL protocols. |
|
|
Location of the resource containing the store content. |
|
|
Password used to access the store. |
|
|
Type of the store to create, e.g. JKS. |
|
|
Provider for the store. |
|
|
The alias that identifies the key in the key store. |
|
|
The password used to access the key in the key store. |
|
|
|
SSL Protocol to use. |
|
Supported SSL ciphers. |
|
|
Enabled SSL protocols. |
Using SSL
The Dev Service can serve SSL, so that an application connecting to the real service over SSL does the same in dev and test, and its SSL support is developed and tested against the Dev Service. Set the arconia.dev.services.otel-collector.ssl.enabled property to true and configure the certificate and private key the Dev Service presents, in PEM form or in a Java keystore, with the same properties as a Spring Boot SSL bundle:
arconia:
dev:
services:
otel-collector:
ssl:
enabled: true
pem:
keystore:
certificate: "classpath:certs/otel-collector.crt"
private-key: "classpath:certs/otel-collector.key"
The container is configured to serve SSL with that certificate, and the application is configured to trust it through the Spring Boot service connection, so no client configuration is needed. The certificate must be valid for the host the application connects to, such as localhost. The ssl.pem and ssl.jks properties take the keystore, key, options, and protocol keys of a spring.ssl.bundle definition. Learn more about SSL with Dev Services, including the certificate requirements.
The OTLP receiver then serves both its gRPC and HTTP ports over SSL only, and clients are not asked for a certificate. The certificate and key are set from the command line, on top of the configuration file, so they also apply to a custom configuration that defines the otlp receiver with both protocols. The OTLP links reported at startup still use http.
Disabling the Dev Service
Set the arconia.dev.services.otel-collector.enabled property to false to disable the Dev Service. To disable it in one mode only, use the profile Arconia activates for that mode (see Profiles), for example in an application-test.yml file to disable it in tests:
arconia:
dev:
services:
otel-collector:
enabled: false
To disable it for a single test class, set the property with @SpringBootTest(properties = …) or @TestPropertySource. To disable all the Dev Services at once, set arconia.dev.services.enabled to false.