File tree Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Original file line number Diff line number Diff line change 1+ FROM python:3.12-slim
2+
3+ WORKDIR /app
4+
5+ COPY . /app
6+
7+ RUN pip install flask elastic-opentelemetry
8+
9+ # Install all the available instrumentations
10+ RUN opentelemetry-bootstrap -a install
11+
12+ # default flask run port
13+ EXPOSE 5000
14+
15+ # Set some resource attributes to make our service recognizable
16+ ENV OTEL_RESOURCE_ATTRIBUTES="service.name=FlaskService,service.version=0.0.1,deployment.environment=development"
17+
18+ CMD ["opentelemetry-instrument" , "flask" , "run" ]
Original file line number Diff line number Diff line change 1+ # Flask autoinstrumented application
2+
3+ This is a barebone Flask app used for demonstrating autoinstrumentation with EDOT.
4+
5+ You can build the application image it with:
6+
7+ ```
8+ docker build --load -t edot-flask:latest .
9+ ```
10+
11+ You can run the application with:
12+
13+ ```
14+ export OTEL_EXPORTER_OTLP_ENDPOINT=https://my-deployment.apm.us-west1.gcp.cloud.es.io
15+ export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer P....l"
16+ docker run -e OTEL_EXPORTER_OTLP_ENDPOINT="$OTEL_EXPORTER_OTLP_ENDPOINT" \
17+ -e OTEL_EXPORTER_OTLP_HEADERS="$OTEL_EXPORTER_OTLP_HEADERS" \
18+ -p 5000:5000 -it --rm edot-flask:latest
19+ ```
20+
21+ You can access the application from [ http://127.0.0.1:5000 ] ( http://127.0.0.1:5000 ) .
Original file line number Diff line number Diff line change 1+ from flask import Flask , jsonify
2+
3+ app = Flask (__name__ )
4+
5+
6+ @app .route ("/" , methods = ["GET" ])
7+ def home ():
8+ return jsonify (message = "Hello, world!" )
You can’t perform that action at this time.
0 commit comments