Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 128 additions & 1 deletion data/docs/instrumentation/opentelemetry-java.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,134 @@ In case you encounter an issue where all applications do not get listed in the s
</Tabs>

</TabItem>
<TabItem value="Docker" label="Docker">

There are two ways to send data to SigNoz Cloud. You can containerize the images in both the cases.

- [Send traces directly to SigNoz Cloud](#send-traces-directly-to-signoz-cloud-1)
- [Send traces via OTel Collector binary](#send-traces-via-otel-collector-binary-1) (recommended)

#### Send traces directly to SigNoz Cloud

**Step 1.** Configure OpenTelemetry to run in Docker Container

Add the following in your Dockerfile.

```bash
...

# Download OpenTelemetry Java Agent
RUN wget -O opentelemetry-javaagent.jar \
https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar

...

# Set environment variables for OTEL
ENV OTEL_RESOURCE_ATTRIBUTES="service.name=<service_name>"
ENV OTEL_EXPORTER_OTLP_HEADERS="signoz-ingestion-key=<your-ingestion-key>"
ENV OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.<region>.signoz.cloud:443"

...

# Run the application with instrumentation
ENTRYPOINT ["java", "-javaagent:/opentelemetry-javaagent.jar", "-jar", "app.jar"]
```

- Set the `<region>` to match your SigNoz Cloud [region](https://signoz.io/docs/ingestion/signoz-cloud/overview/#endpoint)
- Replace `<your-ingestion-key>` with your SigNoz [ingestion key](https://signoz.io/docs/ingestion/signoz-cloud/keys/)
- `<service_name>` is name of your service

The above steps install OpenTelemetry dependencies directly inside the Docker container & sets environment variables to export the traces.

**Step 2.** Run your Docker container

Here's how you can run your docker container:

```bash
docker build -t <image-name> . && docker run -d -p <host-port>:<container-port> <image-name>
```

- Replace `<image-name>`, `<host-port>`, and `<container-port>` with values for your application.

- `-d` runs the container in detached mode
- `-p` maps a host port to a container port


**Step 3.** Validate if your application is sending traces to SigNoz cloud by following the instructions [here](#validating-instrumentation-by-checking-for-traces).

In case you encounter an issue where all applications do not get listed in the services section then please refer to the [troubleshooting section](#troubleshooting-your-signoz-installation).

---

#### Send traces via OTel Collector binary

**Step 1.** Configure OpenTelemetry to run in Docker Container

Add the following in your Dockerfile.

```bash
# -------- Stage 1: Get OpenTelemetry Collector --------
FROM otel/opentelemetry-collector-contrib:0.131.0 AS otel

...

# Download OpenTelemetry Java Agent
RUN wget -O opentelemetry-javaagent.jar \
https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar

...

# Copy OpenTelemetry Collector binary + config from first stage
COPY --from=otel /otelcol-contrib /otelcol-contrib
COPY --from=otel /etc/otelcol-contrib /etc/otelcol-contrib
COPY config.yaml /etc/otelcol-contrib/config.yaml

# Expose ports (App + Collector)
EXPOSE <APP_PORT> 4317 4318

...

# Environment variables (point PHP to local Collector)
ENV OTEL_SERVICE_NAME="<service_name>"
ENV OTEL_TRACES_EXPORTER="otlp"
ENV OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf"
ENV OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4318"
ENV OTEL_PROPAGATORS="baggage,tracecontext"


# Run both Collector and Java app in the same container
CMD sh -c "/otelcol-contrib --config=/etc/otelcol-contrib/config.yaml & \
java -javaagent:/opentelemetry-javaagent.jar -jar /app/app.jar"
```

Make sure you have `config.yaml` in `root` of the application. This config.yaml should be copied from third step of [this](https://signoz.io/docs/collection-agents/docker/install/#step-2-create-collector-configuration)

- Replace `<run_command>` with the command to run your application
- `<service_name>` is name of your service


**Step 2.** Run your Docker container

Run your docker container to start exporting.

```bash
docker build -t <image-name> . && docker run -d -p <host-port>:<container-port> <image-name>
```

- Replace `<image-name>`, `<host-port>`, and `<container-port>` with values for your application.

- `-d` runs the container in detached mode

- `-p` maps a host port to a container port


**Step 3.** You can validate if your application is sending traces to SigNoz cloud by following the instructions [here](#validating-instrumentation-by-checking-for-traces).

In case you encounter an issue where all applications do not get listed in the services section then please refer to the [troubleshooting section](#troubleshooting-your-signoz-installation).

</TabItem>

</Tabs>
<TabItem value='self-host' label='Self-Host'>
## Send Traces to Self-Hosted SigNoz

Expand Down Expand Up @@ -403,7 +531,6 @@ You can use OpenTelemetry Java to send your traces directly to SigNoz. OpenTelem

In case you encounter an issue where all applications do not get listed in the services section then please refer to the [troubleshooting section](#troubleshooting-your-installation).
</TabItem>
</Tabs>
</TabItem>
</Tabs>

Expand Down
127 changes: 127 additions & 0 deletions data/docs/instrumentation/opentelemetry-springboot.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,133 @@ java -javaagent:$PWD/opentelemetry-javaagent.jar -jar <myapp>.jar
In case you encounter an issue where all applications do not get listed in the services section then please refer to the [troubleshooting section](#troubleshooting-your-installation).

</TabItem>
<TabItem value="Docker" label="Docker">

There are two ways to send data to SigNoz Cloud. You can containerize the images in both the cases.

- [Send traces directly to SigNoz Cloud](#send-traces-directly-to-signoz-cloud-1)
- [Send traces via OTel Collector binary](#send-traces-via-otel-collector-binary-1) (recommended)

#### Send traces directly to SigNoz Cloud

**Step 1.** Configure OpenTelemetry to run in Docker Container

Add the following in your Dockerfile.

```bash
...

# Download OpenTelemetry Java Agent
RUN wget -O opentelemetry-javaagent.jar \
https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar

...

# Set environment variables for OTEL
ENV OTEL_RESOURCE_ATTRIBUTES="service.name=<service_name>"
ENV OTEL_EXPORTER_OTLP_HEADERS="signoz-ingestion-key=<your-ingestion-key>"
ENV OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.<region>.signoz.cloud:443"

...

# Run the application with instrumentation
ENTRYPOINT ["java", "-javaagent:/opentelemetry-javaagent.jar", "-jar", "app.jar"]
```

- Set the `<region>` to match your SigNoz Cloud [region](https://signoz.io/docs/ingestion/signoz-cloud/overview/#endpoint)
- Replace `<your-ingestion-key>` with your SigNoz [ingestion key](https://signoz.io/docs/ingestion/signoz-cloud/keys/)
- `<service_name>` is name of your service

The above steps install OpenTelemetry dependencies directly inside the Docker container & sets environment variables to export the traces.

**Step 2.** Run your Docker container

Here's how you can run your docker container:

```bash
docker build -t <image-name> . && docker run -d -p <host-port>:<container-port> <image-name>
```

- Replace `<image-name>`, `<host-port>`, and `<container-port>` with values for your application.

- `-d` runs the container in detached mode
- `-p` maps a host port to a container port


**Step 3.** Validate if your application is sending traces to SigNoz cloud by following the instructions [here](#validating-instrumentation-by-checking-for-traces).

In case you encounter an issue where all applications do not get listed in the services section then please refer to the [troubleshooting section](#troubleshooting-your-signoz-installation).

---

#### Send traces via OTel Collector binary

**Step 1.** Configure OpenTelemetry to run in Docker Container

Add the following in your Dockerfile.

```bash
# -------- Stage 1: Get OpenTelemetry Collector --------
FROM otel/opentelemetry-collector-contrib:0.131.0 AS otel

...

# Download OpenTelemetry Java Agent
RUN wget -O opentelemetry-javaagent.jar \
https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar

...

# Copy OpenTelemetry Collector binary + config from first stage
COPY --from=otel /otelcol-contrib /otelcol-contrib
COPY --from=otel /etc/otelcol-contrib /etc/otelcol-contrib
COPY config.yaml /etc/otelcol-contrib/config.yaml

# Expose ports (App + Collector)
EXPOSE <APP_PORT> 4317 4318

...

# Environment variables (point PHP to local Collector)
ENV OTEL_SERVICE_NAME="<service_name>"
ENV OTEL_TRACES_EXPORTER="otlp"
ENV OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf"
ENV OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4318"
ENV OTEL_PROPAGATORS="baggage,tracecontext"


# Run both Collector and Java app in the same container
CMD sh -c "/otelcol-contrib --config=/etc/otelcol-contrib/config.yaml & \
java -javaagent:/opentelemetry-javaagent.jar -jar /app/app.jar"
```

Make sure you have `config.yaml` in `root` of the application. This config.yaml should be copied from third step of [this](https://signoz.io/docs/collection-agents/docker/install/#step-2-create-collector-configuration)

- Replace `<run_command>` with the command to run your application
- `<service_name>` is name of your service


**Step 2.** Run your Docker container

Run your docker container to start exporting.

```bash
docker build -t <image-name> . && docker run -d -p <host-port>:<container-port> <image-name>
```

- Replace `<image-name>`, `<host-port>`, and `<container-port>` with values for your application.

- `-d` runs the container in detached mode

- `-p` maps a host port to a container port


**Step 3.** You can validate if your application is sending traces to SigNoz cloud by following the instructions [here](#validating-instrumentation-by-checking-for-traces).

In case you encounter an issue where all applications do not get listed in the services section then please refer to the [troubleshooting section](#troubleshooting-your-signoz-installation).

</TabItem>

</Tabs>

</TabItem>
Expand Down
Loading