File tree Expand file tree Collapse file tree 3 files changed +75
-0
lines changed Expand file tree Collapse file tree 3 files changed +75
-0
lines changed Original file line number Diff line number Diff line change 1+ FROM python:3.13-slim
2+
3+ WORKDIR /app
4+
5+ COPY . /app
6+
7+ RUN pip install aiohttp elastic-opentelemetry
8+
9+ # Install all the instrumentations available for the installed packages
10+ RUN edot-bootstrap -a install
11+
12+ EXPOSE 8080
13+
14+ # Set some resource attributes to make our service recognizable
15+ ENV OTEL_RESOURCE_ATTRIBUTES="service.name=AioHttpService,service.version=0.0.1,deployment.environment=development"
16+
17+ CMD ["opentelemetry-instrument" , "python" , "app.py" ]
Original file line number Diff line number Diff line change 1+ # Aiohttp autoinstrumented application
2+
3+ This is a barebone aiohttp 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-aiohttp:latest .
9+ ```
10+
11+ You can run the application with:
12+
13+ ``` sh
14+ export OTEL_METRICS_EXPORTER=otlp
15+ export OTEL_LOGS_EXPORTER=otlp
16+ export OTEL_EXPORTER_OTLP_ENDPOINT=https://my-deployment.apm.us-west1.gcp.cloud.es.io
17+ export OTEL_EXPORTER_OTLP_HEADERS=" Authorization=Bearer P....l"
18+ docker run -e OTEL_EXPORTER_OTLP_ENDPOINT=" $OTEL_EXPORTER_OTLP_ENDPOINT " \
19+ -e OTEL_EXPORTER_OTLP_HEADERS=" $OTEL_EXPORTER_OTLP_HEADERS " \
20+ -p 8080:8080 -it --rm edot-aiohttp:latest
21+ ```
22+
23+ You can access the application from [ http://127.0.0.1:8080 ] ( http://127.0.0.1:8080 ) .
Original file line number Diff line number Diff line change 1+ # Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
2+ # or more contributor license agreements. See the NOTICE file distributed with
3+ # this work for additional information regarding copyright
4+ # ownership. Elasticsearch B.V. licenses this file to you under
5+ # the Apache License, Version 2.0 (the "License"); you may
6+ # not use this file except in compliance with the License.
7+ # You may obtain a copy of the License at
8+ #
9+ # http://www.apache.org/licenses/LICENSE-2.0
10+ #
11+ # Unless required by applicable law or agreed to in writing, software
12+ # distributed under the License is distributed on an "AS IS" BASIS,
13+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ # See the License for the specific language governing permissions and
15+ # limitations under the License.
16+
17+ import logging
18+ from aiohttp import web
19+
20+
21+ logging .basicConfig (level = logging .INFO , format = "%(asctime)s - %(levelname)s - %(message)s" )
22+ logger = logging .getLogger (__name__ )
23+
24+ routes = web .RouteTableDef ()
25+
26+
27+ @routes .get ("/" )
28+ async def hello (request ):
29+ logger .info ("Hello, world" )
30+ return web .Response (text = "Hello, world" )
31+
32+
33+ app = web .Application ()
34+ app .add_routes (routes )
35+ web .run_app (app )
You can’t perform that action at this time.
0 commit comments