JavaScript Instrumentation in Containers
JavaScript Applications in Containers with the otel-agent-nodejs-v2 Agent
Agent Installation in the Container
# Using Yarn
RUN yarn add otel-agent-nodejs-v2
# Or using NPM
RUN npm install otel-agent-nodejs-v2 --save --ignore-scriptsExample Dockerfile:
FROM node:20-alpine as build
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
COPY . .
# Intall OpenTelemetry
RUN yarn add otel-agent-nodejs-v2
RUN yarn build
RUN yarn prisma generate
FROM node:20-alpine
WORKDIR /app
COPY --from=build /app/dist ./dist
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/package.json ./
COPY --from=build /app/prisma ./prisma
RUN apk add --no-cache openssl
CMD ["node", "dist/index.js"]Environment Variable Configuration
Explanation of main variables:
Examples by Environment
Docker Compose
Kubernetes
ECS (Fargate ou EC2)
Execução Local
Collector (Collector Endpoint)
Validation
Troubleshooting
Best Practices
Ready .env example
Last updated
Was this helpful?

