Skip to content

Commit 36d9269

Browse files
authored
feat: all python dockerized (#1889)
* feat: inbuilt otel-collector * feat: restruct * feat: django instructions * feat: all python complete
1 parent cd355fb commit 36d9269

File tree

5 files changed

+557
-74
lines changed

5 files changed

+557
-74
lines changed

data/docs/instrumentation/opentelemetry-django.mdx

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,134 @@ In case you encounter an issue where all applications do not get listed in the s
445445

446446
</TabItem>
447447
</Tabs>
448+
</TabItem>
449+
<TabItem value="Docker" label="Docker">
450+
451+
There are two ways to send data to SigNoz Cloud. You can containerize the images in both the cases.
452+
453+
- [Send traces directly to SigNoz Cloud](#send-traces-directly-to-signoz-cloud)
454+
- [Send traces via OTel Collector binary](#send-traces-via-otel-collector-binary) (recommended)
455+
456+
#### Send traces directly to SigNoz Cloud
457+
458+
**Step 1.** Configure OpenTelemetry to run in Docker Container
459+
460+
Add the following in your Dockerfile.
461+
462+
```bash
463+
...
464+
465+
# install dependencies
466+
RUN pip install opentelemetry-distro==0.43b0 opentelemetry-exporter-otlp==1.22.0
467+
468+
...
469+
470+
# NOTE: ADD THIS AFTER pip install requirements.txt
471+
RUN opentelemetry-bootstrap --action=install
472+
473+
...
474+
475+
# Set environment variables for OpenTelemetry
476+
ENV OTEL_RESOURCE_ATTRIBUTES=service.name=<service-name>
477+
ENV OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.<region>.signoz.cloud:443
478+
ENV OTEL_EXPORTER_OTLP_HEADERS=signoz-ingestion-key=<your-ingestion-key>
479+
ENV OTEL_EXPORTER_OTLP_PROTOCOL=grpc
480+
481+
# Replace with your run command
482+
CMD ["opentelemetry-instrument", <run_command>]
483+
```
484+
485+
- Replace `<run_command>` with the command to run your application
486+
- Set the `<region>` to match your SigNoz Cloud [region](https://signoz.io/docs/ingestion/signoz-cloud/overview/#endpoint)
487+
- Replace `<your-ingestion-key>` with your SigNoz [ingestion key](https://signoz.io/docs/ingestion/signoz-cloud/keys/)
488+
- `<service_name>` is name of your service
489+
490+
The above steps install OpenTelemetry dependencies directly inside the Docker container without altering `requirements.txt` file of project & sets environment variables to export the traces.
491+
492+
**Step 2.** Run your Docker container
493+
494+
Here's how you can run your docker container:
495+
496+
```bash
497+
docker build -t <image-name> . && docker run -d -p <host-port>:<container-port> <image-name>
498+
```
499+
500+
- Replace `<image-name>`, `<host-port>`, and `<container-port>` with values for your application.
501+
502+
- `-d` runs the container in detached mode
503+
- `-p` maps a host port to a container port
504+
505+
506+
**Step 3.** Validate if your application is sending traces to SigNoz cloud by following the instructions [here](#validating-instrumentation-by-checking-for-traces).
507+
508+
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).
509+
510+
---
511+
512+
#### Send traces via OTel Collector binary
513+
514+
**Step 1.** Configure OpenTelemetry to run in Docker Container
515+
516+
Add the following in your Dockerfile.
517+
518+
```bash
519+
# install OpenTelemetry Collector in Docker container
520+
FROM otel/opentelemetry-collector-contrib:0.131.0 AS otel
521+
522+
COPY --from=otel /otelcol-contrib /otelcol-contrib
523+
COPY --from=otel /etc/otelcol-contrib /etc/otelcol-contrib
524+
525+
COPY config.yaml /etc/otelcol-contrib/config.yaml
526+
527+
...
528+
529+
# And install OpenTelemetry packages
530+
RUN pip install --upgrade pip && \
531+
pip install opentelemetry-distro==0.43b0 opentelemetry-exporter-otlp==1.22.0
532+
533+
...
534+
535+
# add this right after installing your dependencies
536+
RUN opentelemetry-bootstrap --action=install
537+
538+
# Replace APP_PORT with the port of your application
539+
EXPOSE 4317 4318 <APP_PORT>
540+
541+
# Set environment variables for OpenTelemetry
542+
ENV OTEL_RESOURCE_ATTRIBUTES=service.name=<service-name>
543+
ENV OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
544+
ENV OTEL_EXPORTER_OTLP_PROTOCOL=grpc
545+
546+
# Run app.py with OpenTelemetry instrumentation when the container launches
547+
CMD sh -c "/otelcol-contrib --config=/etc/otelcol-contrib/config.yaml & opentelemetry-instrument <run_command>
548+
...
549+
```
550+
551+
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)
552+
553+
- Replace `<run_command>` with the command to run your application
554+
- `<service_name>` is name of your service
555+
556+
557+
**Step 2.** Run your Docker container
558+
559+
Run your docker container to start exporting.
560+
561+
```bash
562+
docker build -t <image-name> . && docker run -d -p <host-port>:<container-port> <image-name>
563+
```
564+
565+
- Replace `<image-name>`, `<host-port>`, and `<container-port>` with values for your application.
566+
567+
- `-d` runs the container in detached mode
568+
569+
- `-p` maps a host port to a container port
570+
571+
572+
**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).
573+
574+
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).
575+
448576
</TabItem>
449577
</Tabs>
450578
</TabItem>

data/docs/instrumentation/opentelemetry-falcon.mdx

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,134 @@ In case you encounter an issue where all applications do not get listed in the s
470470

471471
</TabItem>
472472
</Tabs>
473+
</TabItem>
474+
<TabItem value="Docker" label="Docker">
475+
476+
There are two ways to send data to SigNoz Cloud. You can containerize the images in both the cases.
477+
478+
- [Send traces directly to SigNoz Cloud](#send-traces-directly-to-signoz-cloud-1)
479+
- [Send traces via OTel Collector binary](#send-traces-via-otel-collector-binary-1) (recommended)
480+
481+
#### Send traces directly to SigNoz Cloud
482+
483+
**Step 1.** Configure OpenTelemetry to run in Docker Container
484+
485+
Add the following in your Dockerfile.
486+
487+
```bash
488+
...
489+
490+
# install dependencies
491+
RUN pip install opentelemetry-distro==0.43b0 opentelemetry-exporter-otlp==1.22.0
492+
493+
...
494+
495+
# NOTE: ADD THIS AFTER pip install requirements.txt
496+
RUN opentelemetry-bootstrap --action=install
497+
498+
...
499+
500+
# Set environment variables for OpenTelemetry
501+
ENV OTEL_RESOURCE_ATTRIBUTES=service.name=<service-name>
502+
ENV OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.<region>.signoz.cloud:443
503+
ENV OTEL_EXPORTER_OTLP_HEADERS=signoz-ingestion-key=<your-ingestion-key>
504+
ENV OTEL_EXPORTER_OTLP_PROTOCOL=grpc
505+
506+
# Replace with your run command
507+
CMD ["opentelemetry-instrument", <run_command>]
508+
```
509+
510+
- Replace `<run_command>` with the command to run your application
511+
- Set the `<region>` to match your SigNoz Cloud [region](https://signoz.io/docs/ingestion/signoz-cloud/overview/#endpoint)
512+
- Replace `<your-ingestion-key>` with your SigNoz [ingestion key](https://signoz.io/docs/ingestion/signoz-cloud/keys/)
513+
- `<service_name>` is name of your service
514+
515+
The above steps install OpenTelemetry dependencies directly inside the Docker container without altering `requirements.txt` file of project & sets environment variables to export the traces.
516+
517+
**Step 2.** Run your Docker container
518+
519+
Here's how you can run your docker container:
520+
521+
```bash
522+
docker build -t <image-name> . && docker run -d -p <host-port>:<container-port> <image-name>
523+
```
524+
525+
- Replace `<image-name>`, `<host-port>`, and `<container-port>` with values for your application.
526+
527+
- `-d` runs the container in detached mode
528+
- `-p` maps a host port to a container port
529+
530+
531+
**Step 3.** Validate if your application is sending traces to SigNoz cloud by following the instructions [here](#validating-instrumentation-by-checking-for-traces).
532+
533+
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).
534+
535+
---
536+
537+
#### Send traces via OTel Collector binary
538+
539+
**Step 1.** Configure OpenTelemetry to run in Docker Container
540+
541+
Add the following in your Dockerfile.
542+
543+
```bash
544+
# install OpenTelemetry Collector in Docker container
545+
FROM otel/opentelemetry-collector-contrib:0.131.0 AS otel
546+
547+
COPY --from=otel /otelcol-contrib /otelcol-contrib
548+
COPY --from=otel /etc/otelcol-contrib /etc/otelcol-contrib
549+
550+
COPY config.yaml /etc/otelcol-contrib/config.yaml
551+
552+
...
553+
554+
# And install OpenTelemetry packages
555+
RUN pip install --upgrade pip && \
556+
pip install opentelemetry-distro==0.43b0 opentelemetry-exporter-otlp==1.22.0
557+
558+
...
559+
560+
# add this right after installing your dependencies
561+
RUN opentelemetry-bootstrap --action=install
562+
563+
# Replace APP_PORT with the port of your application
564+
EXPOSE 4317 4318 <APP_PORT>
565+
566+
# Set environment variables for OpenTelemetry
567+
ENV OTEL_RESOURCE_ATTRIBUTES=service.name=<service-name>
568+
ENV OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
569+
ENV OTEL_EXPORTER_OTLP_PROTOCOL=grpc
570+
571+
# Run app.py with OpenTelemetry instrumentation when the container launches
572+
CMD sh -c "/otelcol-contrib --config=/etc/otelcol-contrib/config.yaml & opentelemetry-instrument <run_command>
573+
...
574+
```
575+
576+
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)
577+
578+
- Replace `<run_command>` with the command to run your application
579+
- `<service_name>` is name of your service
580+
581+
582+
**Step 2.** Run your Docker container
583+
584+
Run your docker container to start exporting.
585+
586+
```bash
587+
docker build -t <image-name> . && docker run -d -p <host-port>:<container-port> <image-name>
588+
```
589+
590+
- Replace `<image-name>`, `<host-port>`, and `<container-port>` with values for your application.
591+
592+
- `-d` runs the container in detached mode
593+
594+
- `-p` maps a host port to a container port
595+
596+
597+
**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).
598+
599+
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).
600+
473601
</TabItem>
474602
</Tabs>
475603
</TabItem>

0 commit comments

Comments
 (0)