opentelemetry-java/examples/autoconfigure
John Watson 49ab3be937
remove a todo from an example (#3797)
2021-10-27 09:21:13 -07:00
..
src/main/java/io/opentelemetry/example/autoconfigure remove a todo from an example (#3797) 2021-10-27 09:21:13 -07:00
README.md Add an example that uses auto-configuration (#3003) 2021-03-10 08:13:51 -08:00
build.gradle Add an example that uses auto-configuration (#3003) 2021-03-10 08:13:51 -08:00

README.md

SDK autoconfiguration example

This is a simple example that demonstrates the usage of the OpenTelemetry SDK Autoconfigure module.

Prerequisites

  • Java 1.8

How to run

First build this example application:

../gradlew shadowJar

Then start the example application with the logging exporter configured:

java -Dotel.traces.exporter=logging \
  -cp build/libs/opentelemetry-examples-autoconfigure-0.1.0-SNAPSHOT-all.jar \
  io.opentelemetry.example.autoconfigure.AutoConfigExample

Alternatively, instead of system properties you can use environment variables:

export OTEL_TRACES_EXPORTER=logging

java -cp build/libs/opentelemetry-examples-autoconfigure-0.1.0-SNAPSHOT-all.jar \
  io.opentelemetry.example.autoconfigure.AutoConfigExample

Full documentation of all supported properties can be found in the OpenTelemetry SDK Autoconfigure README.

After running the app you should see the trace printed out in the console:

...
INFO: 'important work' : ca3938a5793f6f9aba5c757f536a50cb b5e826c981112198 INTERNAL [tracer: io.opentelemetry.example.autoconfigure.AutoConfigExample:] AttributesMap{data={foo=42, bar=a string!}, capacity=128, totalAddedValues=2}
...

Congratulations! You are now collecting traces using OpenTelemetry.