Skip to content
Merged
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
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ COPY --from=0 /home/node/package-lock.json ./package-lock.json
COPY --from=0 /home/node/supergraph.yaml ./supergraph.yaml
COPY --from=0 /home/node/supergraph.graphql ./supergraph.graphql
COPY --from=0 /home/node/envelopPlugins.ts ./envelopPlugins.ts
COPY --from=0 /home/node/otlp.js ./otlp.js
CMD ["npm", "start"]
6 changes: 6 additions & 0 deletions docker-compose-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ services:
start_period: 3s
environment:
- FORK=8
- OTEL_TRACES_EXPORTER=none
- OTEL_EXPORTER_OTLP_ENDPOINT="http://otel-collector:4318"
- OTEL_NODE_RESOURCE_DETECTORS=env,host,os
- OTEL_SERVICE_NAME=gateway
- OTEL_SEMCONV_STABILITY_OPT_IN=http
- NODE_OPTIONS= --require @opentelemetry/auto-instrumentations-node/register
gateway-dapr:
image: "daprio/daprd:edge"
command: [
Expand Down
24 changes: 24 additions & 0 deletions otlp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const { NodeSDK } = require('@opentelemetry/sdk-node');
const { OTLPMetricExporter } = require('@opentelemetry/exporter-metrics-otlp-http');
const { PeriodicExportingMetricReader } = require('@opentelemetry/sdk-metrics');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');

// TODO this does not expose http_server_request metrics, only http_client_request
const sdk = new NodeSDK({
metricReader: new PeriodicExportingMetricReader({
exporter: new OTLPMetricExporter({ url: 'http://otel-collector:4318/v1/metrics' }),
exportIntervalMillis: 5000,
}),
instrumentations: [
getNodeAutoInstrumentations({
'@opentelemetry/instrumentation-http': {
'enabled': true,
'enhancedMetrics': true,
'tracing': false
},
}),
],
});

sdk.start();
console.log('OpenTelemetry initialized ✅');
Loading