Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Adding OTEL_EXPORTER_OTLP_ENDPOINT #189

Merged
merged 19 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/webservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ COPY turbo.json turbo.json
RUN pnpm add -g turbo

COPY package.json package.json
COPY .npmrc .npmrc
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsbroks this is the fix.

COPY pnpm-*.yaml .

COPY tooling/tailwind/package.json ./tooling/tailwind/package.json
Expand Down Expand Up @@ -59,6 +60,7 @@ EXPOSE 3000
ENV PORT=3000
ENV AUTH_TRUST_HOST=true
ENV NODE_ENV=production
ENV NODE_PATH=/app/apps/webservice/node_modules
zacharyblasczyk marked this conversation as resolved.
Show resolved Hide resolved
zacharyblasczyk marked this conversation as resolved.
Show resolved Hide resolved
ENV HOSTNAME=0.0.0.0

CMD ["node", "apps/webservice/server.js"]
12 changes: 1 addition & 11 deletions apps/webservice/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,7 @@ const config = {

experimental: {
instrumentationHook: true,
optimizePackageImports: ["bullmq", "googleapis"],
/** @see https://github.com/open-telemetry/opentelemetry-js/issues/4297 */
serverComponentsExternalPackages: [
"@opentelemetry/sdk-node",
"@opentelemetry/auto-instrumentations-node",
"@appsignal/opentelemetry-instrumentation-bullmq",
"@opentelemetry/exporter-trace-otlp-http",
"@opentelemetry/resources",
"@opentelemetry/sdk-node",
"@opentelemetry/semantic-conventions",
],
optimizePackageImports: ["googleapis"],
},

async rewrites() {
Expand Down
7 changes: 3 additions & 4 deletions apps/webservice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"openapi": "ts-node tooling/openapi/merge.ts"
},
"dependencies": {
"@appsignal/opentelemetry-instrumentation-bullmq": "^0.7.1",
"@ctrlplane/api": "workspace:*",
"@ctrlplane/auth": "workspace:*",
"@ctrlplane/db": "workspace:*",
Expand All @@ -33,9 +32,9 @@
"@octokit/rest": "catalog:",
"@octokit/webhooks": "^13.3.0",
"@octokit/webhooks-types": "^7.5.1",
"@opentelemetry/auto-instrumentations-node": "^0.50.0",
"@opentelemetry/exporter-trace-otlp-http": "^0.53.0",
"@opentelemetry/sdk-node": "^0.53.0",
"@opentelemetry/auto-instrumentations-node": "^0.52.1",
"@opentelemetry/exporter-trace-otlp-http": "^0.54.2",
"@opentelemetry/sdk-node": "^0.54.2",
"@t3-oss/env-nextjs": "catalog:",
"@tabler/icons-react": "^3.17.0",
"@tailwindcss/typography": "^0.5.13",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import { BatchLogRecordProcessor } from "@opentelemetry/sdk-logs";
import { NodeSDK } from "@opentelemetry/sdk-node";
import {
AlwaysOnSampler,
BatchSpanProcessor,
SimpleSpanProcessor,
} from "@opentelemetry/sdk-trace-base";
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";

const sdk = new NodeSDK({
resource: new Resource({
[ATTR_SERVICE_NAME]: "ctrlplane/webservice",
}),
spanProcessors: [new BatchSpanProcessor(new OTLPTraceExporter())],
spanProcessors: [new SimpleSpanProcessor(new OTLPTraceExporter())],
logRecordProcessors: [new BatchLogRecordProcessor(new OTLPLogExporter())],
instrumentations: [
getNodeAutoInstrumentations({
Expand Down Expand Up @@ -44,15 +44,11 @@ const sdk = new NodeSDK({
}),
],
sampler: new AlwaysOnSampler(),
// sampler:
// env.NODE_ENV === "development"
// ? new AlwaysOnSampler()
// : new TraceIdRatioBasedSampler(env.OTEL_SAMPLER_RATIO),
});

try {
sdk.start();
console.log("Tracing initialized");
console.log("Tracing initialized test");
} catch (error) {
console.error("Error initializing tracing", error);
}
2 changes: 1 addition & 1 deletion apps/webservice/src/instrumentation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export async function register() {
// eslint-disable-next-line no-restricted-properties
if (process.env.NEXT_RUNTIME === "nodejs")
await import("./instrumentation.node");
await import("./instrumentation-node");
}
13 changes: 13 additions & 0 deletions docker-compose.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ services:
volumes:
- redisinsight-data:/data

# otel-collector:
# image: otel/opentelemetry-collector-contrib:latest
# container_name: ctrlplane-otel-collector
# command: ["--config=/etc/otel-collector-config.yaml"]
# volumes:
# - ./otel-collector-config.yaml:/etc/otel-collector-config.yaml
# ports:
# - "4317:4317" # OTLP gRPC
# - "4318:4318" # OTLP HTTP
# - "8125:8125" # StatsD
# - "8888:8888" # Telemetry
# - "9109:9109" # Prometheus endpoint

volumes:
db-data:
redis-data:
Expand Down
57 changes: 42 additions & 15 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "3.8"
version: "3.9"

services:
postgres:
Expand Down Expand Up @@ -26,52 +26,79 @@ services:

migrations:
platform: linux/amd64
image: ctrlplane/migrations:c656deb
image: ctrlplane/migrations:75685e0
container_name: ctrlplane-migrations
restart: "no"
environment:
DATABASE_URL: postgres://ctrlplane:ctrlplane@postgres:5432/ctrlplane
POSTGRES_URL: "postgres://ctrlplane:ctrlplane@postgres:5432/ctrlplane"
depends_on:
- postgres

webservice:
platform: linux/amd64
image: ctrlplane/webservice:c656deb
# platform: linux/amd64
# image: ctrlplane/webservice:75685e0
build:
context: .
dockerfile: ./apps/webservice/Dockerfile
Comment on lines +40 to +42
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just docker-compose build if you wanna test locally.


container_name: ctrlplane-webservice
environment:
BASE_URL: "http://127.0.0.1" # <set your instance url>
AUTH_SECRET: "<auth-secret>"
# AUTH_OIDC_ISSUER: "<oidc-issuer>"
# AUTH_OIDC_CLIENT_ID: "<oidc-client-id>"
# AUTH_OIDC_CLIENT_SECRET: "<oidc-client-secret>"
AUTH_SECRET: ${AUTH_SECRET}
# AUTH_OIDC_ISSUER: ${AUTH_OIDC_ISSUER}
# AUTH_OIDC_CLIENT_ID: ${AUTH_OIDC_CLIENT_ID}
# AUTH_OIDC_CLIENT_SECRET: ${AUTH_OIDC_CLIENT_SECRET}

AUTH_GOOGLE_CLIENT_ID: 27586067691-1us5sc17f0pq0vs4c0ml1eaqphmf9sl9.apps.googleusercontent.com
AUTH_GOOGLE_CLIENT_SECRET: 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
zacharyblasczyk marked this conversation as resolved.
Show resolved Hide resolved

NEXTAUTH_URL: ${BASE_URL}
DATABASE_URL: postgres://ctrlplane:ctrlplane@postgres:5432/ctrlplane
OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector:4318"
REDIS_URL: redis://redis:6379
POSTGRES_URL: postgresql://ctrlplane:ctrlplane@postgres:5432/ctrlplane
VARIABLES_AES_256_KEY: d2506d733ee210078461c08ee8e1605be75ed73b0941d4b513ab7b159c6fbcd9
zacharyblasczyk marked this conversation as resolved.
Show resolved Hide resolved
depends_on:
- postgres
- migrations
ports:
- "8080:8080"
- "3000:3000"

jobs:
platform: linux/amd64
image: ctrlplane/jobs:c656deb
image: ctrlplane/jobs:75685e0
container_name: ctrlplane-jobs
environment:
POSTGRES_URL: postgres://ctrlplane:ctrlplane@postgres:5432/ctrlplane
POSTGRES_URL: "postgres://ctrlplane:ctrlplane@postgres:5432/ctrlplane"
REDIS_URL: "redis://redis:6379"
VARIABLES_AES_256_KEY: d2506d733ee210078461c08ee8e1605be75ed73b0941d4b513ab7b159c6fbcd9
depends_on:
- postgres

event-worker:
platform: linux/amd64
image: ctrlplane/event-worker:c656deb
image: ctrlplane/event-worker:75685e0
container_name: ctrlplane-event-worker
environment:
POSTGRES_URL: postgres://ctrlplane:ctrlplane@postgres:5432/ctrlplane
POSTGRES_URL: "postgres://ctrlplane:ctrlplane@postgres:5432/ctrlplane"
REDIS_URL: "redis://redis:6379"
VARIABLES_AES_256_KEY: d2506d733ee210078461c08ee8e1605be75ed73b0941d4b513ab7b159c6fbcd9
depends_on:
- postgres
- redis

otel-collector:
image: otel/opentelemetry-collector-contrib:latest
container_name: ctrlplane-otel-collector
command: ["--config=/etc/otel-collector-config.yaml"]
volumes:
- ./otel-collector-config.yaml:/etc/otel-collector-config.yaml
ports:
- "4317:4317" # OTLP gRPC
- "4318:4318" # OTLP HTTP
- "8125:8125" # StatsD
- "8888:8888" # Telemetry
- "9109:9109" # Prometheus endpoint

zacharyblasczyk marked this conversation as resolved.
Show resolved Hide resolved
volumes:
postgres_data:
redis_data:
Loading