Java App Instrumentation
Follow the steps below to auto-instrument your Java service. When completed, your service will appear in the Cardinal Service Catalog, and Chip will begin monitoring it.
Local Testing
- Get a Cardinal API key:
Sign in to your Cardinal account, and get an API key from the Organization Settings > API Keys section.
- Download the OpenTelemetry Java Auto-Instrumentation Agent:
wget https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar
- Export the following environment variables:
export OTEL_SERVICE_NAME="your-service-name"
export OTEL_RESOURCE_ATTRIBUTES="deployment.environment.name=local" # local/dev/staging/prod
export OTEL_METRICS_EXPORTER="otlp"
export OTEL_LOGS_EXPORTER="otlp"
export OTEL_TRACES_EXPORTER="otlp"
export OTEL_EXPORTER_OTLP_ENDPOINT="https://otelhttp.intake.us-east-2.aws.cardinalhq.io"
export OTEL_EXPORTER_OTLP_HEADERS="x-cardinalhq-api-key=<your-api-key>"
export JAVA_TOOL_OPTIONS="-javaagent:path/to/opentelemetry-javaagent.jar"
- Run your application:
java -jar <your-app.jar>
- Validate that Cardinal is receiving data:
Exercise the service by calling some API endpoints, or causing some logs or metrics to be emitted. Wait for a few minutes, then visit the Service Catalog in the Cardinal UI to check that your service appears in the list.
Docker
Set the environment variables outlined above in your Docker container runtime configuration.
- Update
OTEL_RESOURCE_ATTRIBUTES
to set thedeployment.environment.name
value to your environment. - If you run an OpenTelemetry Collector, set the
OTEL_EXPORTER_OTLP_ENDPOINT
to your Collector's OTLP Receiver endpoint, and follow the steps in the OTLP Export to Cardinal section to forward data to Cardinal.
Kubernetes
Set the environment variables outlined above in your Deployment
or StatefulSet
manifest.
- Update
OTEL_RESOURCE_ATTRIBUTES
to set thedeployment.environment.name
value to your environment. - If you run an OpenTelemetry Collector, set the
OTEL_EXPORTER_OTLP_ENDPOINT
to your Collector's OTLP Receiver endpoint, and follow the steps in the OTLP Export to Cardinal section to forward data to Cardinal.