mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2026-10-28 16:18:23 +08:00
Rename the service-name placeholder from <MY_SERVICE_NAME> to <YOUR_SERVICE_NAME> across the SDK pages and the validator allowlist, matching the <YOUR_...> convention of the other standardized placeholders.
76 lines
2.9 KiB
Plaintext
76 lines
2.9 KiB
Plaintext
---
|
|
slug: /use-cases/observability/clickstack/sdks/java
|
|
description: 'Java SDK for ClickStack - The ClickHouse Observability Stack'
|
|
title: 'Java'
|
|
doc_type: 'guide'
|
|
keywords: ['Java SDK ClickStack', 'Java OpenTelemetry ClickStack', 'Java observability SDK', 'ClickStack Java integration', 'Java application monitoring']
|
|
---
|
|
|
|
import { ClickStackIntegrates } from '/snippets/components/ClickStackIntegrates/ClickStackIntegrates.jsx'
|
|
|
|
ClickStack uses the OpenTelemetry standard for collecting telemetry data (logs and
|
|
traces). Traces are auto-generated with automatic instrumentation, so manual
|
|
instrumentation isn't required to get value out of tracing.
|
|
|
|
<ClickStackIntegrates signals={['logs', 'metrics', 'traces']} />
|
|
|
|
## Getting started {#getting-started}
|
|
|
|
<Note>
|
|
At present, the integration is compatible exclusively with **Java 8+**
|
|
</Note>
|
|
|
|
### Download OpenTelemetry Java agent {#download-opentelemetry-java-agent}
|
|
|
|
Download [`opentelemetry-javaagent.jar`](https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar)
|
|
and place the JAR in your preferred directory. The JAR file contains the agent
|
|
and instrumentation libraries. You can also use the following command to
|
|
download the agent:
|
|
|
|
```shell
|
|
curl -L -O https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar
|
|
```
|
|
|
|
### Configure environment variables {#configure-environment-variables}
|
|
|
|
Afterwards you'll need to configure the following environment variables in your shell to ship telemetry to ClickStack via the OpenTelemetry collector:
|
|
|
|
<Tabs>
|
|
<Tab title="Managed ClickStack">
|
|
|
|
```shell
|
|
export JAVA_TOOL_OPTIONS="-javaagent:PATH/TO/opentelemetry-javaagent.jar" \
|
|
OTEL_EXPORTER_OTLP_ENDPOINT=<YOUR_OTEL_COLLECTOR_HTTP_ENDPOINT> \
|
|
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf \
|
|
OTEL_LOGS_EXPORTER=otlp \
|
|
OTEL_SERVICE_NAME='<YOUR_SERVICE_NAME>'
|
|
```
|
|
|
|
</Tab>
|
|
|
|
<Tab title="ClickStack Open Source">
|
|
|
|
```shell
|
|
export JAVA_TOOL_OPTIONS="-javaagent:PATH/TO/opentelemetry-javaagent.jar" \
|
|
OTEL_EXPORTER_OTLP_ENDPOINT=<YOUR_OTEL_COLLECTOR_HTTP_ENDPOINT> \
|
|
OTEL_EXPORTER_OTLP_HEADERS='authorization=<YOUR_INGESTION_API_KEY>' \
|
|
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf \
|
|
OTEL_LOGS_EXPORTER=otlp \
|
|
OTEL_SERVICE_NAME='<YOUR_SERVICE_NAME>'
|
|
```
|
|
|
|
</Tab>
|
|
</Tabs>
|
|
|
|
_The `OTEL_SERVICE_NAME` environment variable is used to identify your service in the HyperDX app, it can be any name you want._
|
|
|
|
The `OTEL_EXPORTER_OTLP_HEADERS` environment variable contains the API Key available via HyperDX app in `Team Settings → API Keys`.
|
|
|
|
### Run the application with OpenTelemetry Java agent {#run-the-application-with-otel-java-agent}
|
|
|
|
```shell
|
|
java -jar target/<APPLICATION_JAR_FILE>
|
|
```
|
|
<br/>
|
|
Read more about Java OpenTelemetry instrumentation here: [https://opentelemetry.io/docs/instrumentation/java/](https://opentelemetry.io/docs/instrumentation/java/)
|