Skip to content

Commit

Permalink
Merge branch 'rjawesome-otel' into otel
Browse files Browse the repository at this point in the history
  • Loading branch information
tokebe committed Dec 14, 2023
2 parents b3bb8bd + ceed55d commit 9502f59
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@
"@biothings-explorer/utils": "workspace:../utils",
"@bull-board/api": "^5.9.1",
"@bull-board/express": "^5.9.1",
"@opentelemetry/api": "^1.7.0",
"@opentelemetry/auto-instrumentations-node": "^0.40.2",
"@opentelemetry/exporter-metrics-otlp-proto": "^0.45.1",
"@opentelemetry/exporter-trace-otlp-proto": "^0.45.1",
"@opentelemetry/resources": "^1.18.1",
"@opentelemetry/sdk-metrics": "^1.18.1",
"@opentelemetry/sdk-node": "^0.45.1",
"@opentelemetry/sdk-trace-node": "^1.18.1",
"@sentry/node": "^7.74.1",
"@sentry/profiling-node": "^1.2.1",
"axios": "^0.27.2",
Expand Down
4 changes: 4 additions & 0 deletions src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,8 @@ module.exports = class Config {
debug(error);
}
}

setOpenTel() {

}
};
34 changes: 34 additions & 0 deletions src/controllers/opentelemetry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*instrumentation.js*/
const opentelemetry = require('@opentelemetry/sdk-node');
const {
getNodeAutoInstrumentations,
} = require('@opentelemetry/auto-instrumentations-node');
const {
OTLPTraceExporter,
} = require('@opentelemetry/exporter-trace-otlp-proto');
const {
OTLPMetricExporter,
} = require('@opentelemetry/exporter-metrics-otlp-proto');
const { PeriodicExportingMetricReader, ConsoleMetricExporter } = require('@opentelemetry/sdk-metrics');
const { Resource } = require('@opentelemetry/resources')
const { ConsoleSpanExporter } = require('@opentelemetry/sdk-trace-node');

const sdk = new opentelemetry.NodeSDK({
traceExporter: new OTLPTraceExporter({
url: process.env.JAEGER_URL ?? 'http://localhost:4318/v1/traces',
// optional - collection of custom headers to be sent with each request, empty by default
headers: {},
}),
metricReader: new PeriodicExportingMetricReader({
exporter: new OTLPMetricExporter({
url: process.env.JAEGER_URL ?? 'http://localhost:4318/v1/traces',
headers: {}, // an optional object containing custom headers to be sent with each request
concurrencyLimit: 1, // an optional limit on pending requests
}),
}),
instrumentations: [getNodeAutoInstrumentations()],
resource: new Resource({
"service.name": "biothings-explorer"
})
});
sdk.start();

0 comments on commit 9502f59

Please sign in to comment.