1
0
mirror of synced 2024-12-11 06:26:03 +01:00

Add service name for tracing

This commit is contained in:
Luna 2022-11-19 17:39:35 +00:00
parent 04dea9021d
commit 49f14889b8
3 changed files with 9 additions and 1 deletions

View File

@ -24,6 +24,7 @@
"@opentelemetry/auto-instrumentations-node": "^0.35.0", "@opentelemetry/auto-instrumentations-node": "^0.35.0",
"@opentelemetry/exporter-trace-otlp-grpc": "^0.34.0", "@opentelemetry/exporter-trace-otlp-grpc": "^0.34.0",
"@opentelemetry/sdk-node": "^0.34.0", "@opentelemetry/sdk-node": "^0.34.0",
"@opentelemetry/semantic-conventions": "^1.8.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",

View File

@ -4,6 +4,8 @@ import * as opentelemetry from '@opentelemetry/sdk-node';
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node'; import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
import { diag, DiagConsoleLogger, DiagLogLevel } from '@opentelemetry/api'; import { diag, DiagConsoleLogger, DiagLogLevel } from '@opentelemetry/api';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc'; import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc';
import { Resource } from '@opentelemetry/resources';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import process from 'process'; import process from 'process';
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO); diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO);
@ -13,6 +15,11 @@ const sdk = new opentelemetry.NodeSDK({
url: process.env.OPENTELEMETRY_OTLP_URI, url: process.env.OPENTELEMETRY_OTLP_URI,
headers: {} headers: {}
}), }),
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: 'bayshore',
[SemanticResourceAttributes.DEPLOYMENT_ENVIRONMENT]:
process.env.NODE_ENV !== undefined ? process.env.NODE_ENV : 'development',
}),
instrumentations: [getNodeAutoInstrumentations()] instrumentations: [getNodeAutoInstrumentations()]
}); });

View File

@ -686,7 +686,7 @@
"@opentelemetry/sdk-trace-base" "1.8.0" "@opentelemetry/sdk-trace-base" "1.8.0"
semver "^7.3.5" semver "^7.3.5"
"@opentelemetry/semantic-conventions@1.8.0", "@opentelemetry/semantic-conventions@^1.0.0": "@opentelemetry/semantic-conventions@1.8.0", "@opentelemetry/semantic-conventions@^1.0.0", "@opentelemetry/semantic-conventions@^1.8.0":
version "1.8.0" version "1.8.0"
resolved "https://registry.yarnpkg.com/@opentelemetry/semantic-conventions/-/semantic-conventions-1.8.0.tgz#fe2aa90e6df050a11cd57f5c0f47b0641fd2cad3" resolved "https://registry.yarnpkg.com/@opentelemetry/semantic-conventions/-/semantic-conventions-1.8.0.tgz#fe2aa90e6df050a11cd57f5c0f47b0641fd2cad3"
integrity sha512-TYh1MRcm4JnvpqtqOwT9WYaBYY4KERHdToxs/suDTLviGRsQkIjS5yYROTYTSJQUnYLOn/TuOh5GoMwfLSU+Ew== integrity sha512-TYh1MRcm4JnvpqtqOwT9WYaBYY4KERHdToxs/suDTLviGRsQkIjS5yYROTYTSJQUnYLOn/TuOh5GoMwfLSU+Ew==