zking2000 / NotePad

1 stars 0 forks source link

otelcol #72

Closed zking2000 closed 1 month ago

zking2000 commented 2 months ago
# 使用官方的 Python 镜像作为基础镜像
FROM python:3.9-slim

# 设置工作目录
WORKDIR /app

# 复制 requirements.txt 并安装 Python 依赖
COPY requirements.txt requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

RUN opentelemetry-bootstrap -a install

# 复制应用程序代码
COPY . .

# 暴露应用程序运行的端口
EXPOSE 5002

# 设置环境变量
ENV FLASK_APP=app.py
ENV FLASK_RUN_HOST=0.0.0.0
ENV OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true

# 运行 Flask 应用
CMD ["opentelemetry-instrument", "--traces_exporter", "otlp", "--metrics_exporter", "otlp", "--logs_exporter", "otlp", "--service_name", "inventory", "flask", "run", "-p", "8080"]
zking2000 commented 2 months ago
OTEL_SERVICE_NAME=your-service-name \
OTEL_TRACES_EXPORTER=console,otlp \
OTEL_METRICS_EXPORTER=console \
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=0.0.0.0:4317
opentelemetry-instrument \
    python myapp.py
zking2000 commented 2 months ago
OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true
zking2000 commented 2 months ago
OTEL_EXPORTER_OTLP_TRACES_INSECURE OTEL_EXPORTER_OTLP_METRICS_INSECURE OTEL_EXPORTER_OTLP_LOGS_INSECURE