Fix backend
Build & Push Docker Images / test-backend (push) Successful in 33s
Build & Push Docker Images / test-frontend (push) Successful in 29s
Build & Push Docker Images / deploy (push) Successful in 8s
Build & Push Docker Images / build-backend (push) Successful in 2m9s
Build & Push Docker Images / build-frontend (push) Successful in 56s
Build & Push Docker Images / test-backend (push) Successful in 33s
Build & Push Docker Images / test-frontend (push) Successful in 29s
Build & Push Docker Images / deploy (push) Successful in 8s
Build & Push Docker Images / build-backend (push) Successful in 2m9s
Build & Push Docker Images / build-frontend (push) Successful in 56s
This commit is contained in:
+15
-4
@@ -11,18 +11,25 @@
|
||||
import { NodeSDK } from '@opentelemetry/sdk-node';
|
||||
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
|
||||
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc';
|
||||
import { resourceFromAttributes } from '@opentelemetry/resources';
|
||||
import * as resources from '@opentelemetry/resources';
|
||||
import { ATTR_SERVICE_NAME, ATTR_SERVICE_NAMESPACE } from '@opentelemetry/semantic-conventions';
|
||||
import { PinoInstrumentation } from '@opentelemetry/instrumentation-pino';
|
||||
|
||||
const serviceName = process.env.OTEL_SERVICE_NAME || 'farmafinder-backend';
|
||||
const otlpEndpoint = process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4317';
|
||||
|
||||
const sdk = new NodeSDK({
|
||||
resource: resourceFromAttributes({
|
||||
const resource = typeof resources.resourceFromAttributes === 'function'
|
||||
? resources.resourceFromAttributes({
|
||||
[ATTR_SERVICE_NAME]: serviceName,
|
||||
[ATTR_SERVICE_NAMESPACE]: 'farmafinder',
|
||||
}),
|
||||
})
|
||||
: new resources.Resource({
|
||||
[ATTR_SERVICE_NAME]: serviceName,
|
||||
[ATTR_SERVICE_NAMESPACE]: 'farmafinder',
|
||||
});
|
||||
|
||||
const sdk = new NodeSDK({
|
||||
resource,
|
||||
traceExporter: new OTLPTraceExporter({ url: otlpEndpoint }),
|
||||
instrumentations: [
|
||||
getNodeAutoInstrumentations({
|
||||
@@ -34,11 +41,15 @@ const sdk = new NodeSDK({
|
||||
],
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV !== 'test') {
|
||||
sdk.start();
|
||||
}
|
||||
|
||||
const shutdown = async () => {
|
||||
try {
|
||||
if (process.env.NODE_ENV !== 'test') {
|
||||
await sdk.shutdown();
|
||||
}
|
||||
} catch (err) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('OpenTelemetry shutdown failed', err);
|
||||
|
||||
Reference in New Issue
Block a user