Initialise instrumentation
This commit is contained in:
parent
d247dcf8af
commit
05b23d4d17
@ -2,4 +2,6 @@ POSTGRES_URL=postgresql://user:password@your-host:5432/database
|
|||||||
ALLNET_PORT=20080
|
ALLNET_PORT=20080
|
||||||
MUCHA_PORT=10082
|
MUCHA_PORT=10082
|
||||||
SERVICE_PORT=9002
|
SERVICE_PORT=9002
|
||||||
API_PORT=9003
|
API_PORT=9003
|
||||||
|
OPENTELEMETRY_ENABLED=false
|
||||||
|
OPENTELEMETRY_OTLP_URI=disregard-this
|
@ -20,6 +20,10 @@
|
|||||||
"typescript": "^4.7.4"
|
"typescript": "^4.7.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@opentelemetry/api": "^1.3.0",
|
||||||
|
"@opentelemetry/auto-instrumentations-node": "^0.35.0",
|
||||||
|
"@opentelemetry/exporter-trace-otlp-http": "^0.34.0",
|
||||||
|
"@opentelemetry/sdk-node": "^0.34.0",
|
||||||
"@prisma/client": "^4.0.0",
|
"@prisma/client": "^4.0.0",
|
||||||
"@sentry/node": "^7.7.0",
|
"@sentry/node": "^7.7.0",
|
||||||
"@sentry/tracing": "^7.7.0",
|
"@sentry/tracing": "^7.7.0",
|
||||||
|
12
src/index.ts
12
src/index.ts
@ -1,6 +1,14 @@
|
|||||||
// Bayshore - a Wangan Midnight Maximum Tune 6 private server.
|
// Bayshore - a Wangan Midnight Maximum Tune 6 private server.
|
||||||
// Made with love by Luna, and part of Project Asakura.
|
// Made with love by Luna, and part of Project Asakura.
|
||||||
|
|
||||||
|
import process from 'process';
|
||||||
|
import * as dotenv from "dotenv";
|
||||||
|
dotenv.config({path: __dirname + '/.env'});
|
||||||
|
|
||||||
|
if (process.env.OPENTELEMETRY_ENABLED === "true") {
|
||||||
|
require('./tracing');
|
||||||
|
}
|
||||||
|
|
||||||
import express, { Router } from 'express';
|
import express, { Router } from 'express';
|
||||||
import {PrismaClient} from '@prisma/client';
|
import {PrismaClient} from '@prisma/client';
|
||||||
import https, {globalAgent} from 'https';
|
import https, {globalAgent} from 'https';
|
||||||
@ -10,14 +18,10 @@ import bodyParser from 'body-parser';
|
|||||||
import AllnetModule from './allnet';
|
import AllnetModule from './allnet';
|
||||||
import MuchaModule from './mucha';
|
import MuchaModule from './mucha';
|
||||||
import { Config } from './config';
|
import { Config } from './config';
|
||||||
import process from 'process';
|
|
||||||
import * as Sentry from '@sentry/node';
|
import * as Sentry from '@sentry/node';
|
||||||
import * as Tracing from '@sentry/tracing';
|
import * as Tracing from '@sentry/tracing';
|
||||||
import * as common from './util/common';
|
import * as common from './util/common';
|
||||||
|
|
||||||
import * as dotenv from "dotenv";
|
|
||||||
dotenv.config({path: __dirname + '/.env'});
|
|
||||||
|
|
||||||
globalAgent.options.keepAlive = true;
|
globalAgent.options.keepAlive = true;
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
19
src/tracing.ts
Normal file
19
src/tracing.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// OpenTelemetry tracing module
|
||||||
|
|
||||||
|
import * as opentelemetry from '@opentelemetry/sdk-node';
|
||||||
|
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
|
||||||
|
import { diag, DiagConsoleLogger, DiagLogLevel } from '@opentelemetry/api';
|
||||||
|
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
||||||
|
import process from 'process';
|
||||||
|
|
||||||
|
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO);
|
||||||
|
|
||||||
|
const sdk = new opentelemetry.NodeSDK({
|
||||||
|
traceExporter: new OTLPTraceExporter({
|
||||||
|
url: process.env.OPENTELEMETRY_OTLP_URI,
|
||||||
|
headers: {}
|
||||||
|
}),
|
||||||
|
instrumentations: [getNodeAutoInstrumentations()]
|
||||||
|
});
|
||||||
|
|
||||||
|
sdk.start();
|
Loading…
Reference in New Issue
Block a user