1
0
mirror of synced 2024-12-02 18:27:19 +01:00

Initialise instrumentation

This commit is contained in:
Luna 2022-11-19 16:36:08 +00:00
parent d247dcf8af
commit 05b23d4d17
5 changed files with 1264 additions and 9 deletions

View File

@ -2,4 +2,6 @@ POSTGRES_URL=postgresql://user:password@your-host:5432/database
ALLNET_PORT=20080
MUCHA_PORT=10082
SERVICE_PORT=9002
API_PORT=9003
API_PORT=9003
OPENTELEMETRY_ENABLED=false
OPENTELEMETRY_OTLP_URI=disregard-this

View File

@ -20,6 +20,10 @@
"typescript": "^4.7.4"
},
"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",
"@sentry/node": "^7.7.0",
"@sentry/tracing": "^7.7.0",

View File

@ -1,6 +1,14 @@
// Bayshore - a Wangan Midnight Maximum Tune 6 private server.
// 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 {PrismaClient} from '@prisma/client';
import https, {globalAgent} from 'https';
@ -10,14 +18,10 @@ import bodyParser from 'body-parser';
import AllnetModule from './allnet';
import MuchaModule from './mucha';
import { Config } from './config';
import process from 'process';
import * as Sentry from '@sentry/node';
import * as Tracing from '@sentry/tracing';
import * as common from './util/common';
import * as dotenv from "dotenv";
dotenv.config({path: __dirname + '/.env'});
globalAgent.options.keepAlive = true;
// @ts-ignore

19
src/tracing.ts Normal file
View 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();

1234
yarn.lock

File diff suppressed because it is too large Load Diff