Skip to content

prometheus #11

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
32 changes: 30 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,37 @@ services:
ports:
- '6379:6379'

otel-collector:
image: otel/opentelemetry-collector-contrib:latest
command:
- "--config=/etc/otel-collector.yaml"
volumes:
- ./otel-collector.yaml:/etc/otel-collector.yaml
ports:
- "9464:9464"
- "4318:4318"
- "4317:4317"

jaeger:
image: jaegertracing/all-in-one:latest
container_name: opentelemetry_jaeger_redis
ports:
- '16686:16686'
- '4318:4318'
- "16686:16686"

prometheus:
image: prom/prometheus:latest
volumes:
- ./prometheus.yaml:/etc/prometheus/prometheus.yaml
command: ["--config.file=/etc/prometheus/prometheus.yaml"]
ports:
- "9090:9090"

grafana:
image: grafana/grafana-enterprise
container_name: grafana
restart: unless-stopped
ports:
- '3001:3000'
environment:
GF_SECURITY_ADMIN_USER: "${GRAFANA_USER}"
GF_SECURITY_ADMIN_PASSWORD: "${GRAFANA_PASSWORD}"
28 changes: 28 additions & 0 deletions otel-collector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
receivers:
otlp:
protocols:
http:
endpoint: 0.0.0.0:4318

processors:
batch:

exporters:
otlp:
endpoint: jaeger:4317
tls:
insecure: true

prometheus:
endpoint: 0.0.0.0:9464

service:
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [otlp]
metrics:
receivers: [otlp]
processors: [batch]
exporters: [prometheus]
74 changes: 74 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
},
"dependencies": {
"@opentelemetry/exporter-metrics-otlp-proto": "^0.54.0",
"@opentelemetry/exporter-prometheus": "^0.56.0",
"@opentelemetry/exporter-trace-otlp-proto": "^0.54.0",
"@opentelemetry/instrumentation-express": "^0.44.0",
"@opentelemetry/instrumentation-http": "^0.54.0",
Expand Down
7 changes: 7 additions & 0 deletions prometheus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
global:
scrape_interval: 15s

scrape_configs:
- job_name: 'otel-collector'
static_configs:
- targets: ['otel-collector:9464']
4 changes: 2 additions & 2 deletions src/instrumentation/instrumentation.consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { PgInstrumentation } from '@opentelemetry/instrumentation-pg';
import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express';
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
import { IORedisInstrumentation } from '@opentelemetry/instrumentation-ioredis';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-proto';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http';

const sdk = new NodeSDK({
serviceName: 'consumer',
Expand Down
4 changes: 2 additions & 2 deletions src/instrumentation/instrumentation.producer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { PgInstrumentation } from '@opentelemetry/instrumentation-pg';
import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express';
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
import { IORedisInstrumentation } from '@opentelemetry/instrumentation-ioredis';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-proto';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http';

const sdk = new NodeSDK({
serviceName: 'producer',
Expand Down
9 changes: 8 additions & 1 deletion src/nodemailer/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ export function initWorker() {
const worker = new Worker(bullmqConfig.queueName, processor, {
connection: bullmqConfig.connection,
concurrency: bullmqConfig.concurrency,
telemetry: new BullMQOtel('example-tracer')
telemetry: new BullMQOtel({
traces: {
name: 'example-tracer',
},
metrics: {
name: 'example-metrics',
},
}),
});

worker.on('completed', (job) =>
Expand Down
9 changes: 8 additions & 1 deletion src/services/newsletter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ class NewsletterService {
constructor() {
this.queue = new Queue<NodemailerInterface>(bullmqConfig.queueName, {
connection: bullmqConfig.connection,
telemetry: new BullMQOtel('example-tracer'),
telemetry: new BullMQOtel({
traces: {
name: 'example-tracer',
},
metrics: {
name: 'example-metrics',
},
}),
});

this.subscribedUserCRUD = SubscribedUserCrud;
Expand Down