Cleanup modified & misisng files
Run Tests on Branches / Backend Tests (push) Successful in 3m31s
Run Tests on Branches / Frontend Tests (push) Successful in 3m26s

This commit is contained in:
Antoni Nuñez Romeu
2026-07-02 20:37:29 +02:00
parent 0ebd2dc35c
commit 3f5f88bbf5
16 changed files with 3732 additions and 379 deletions
+46
View File
@@ -0,0 +1,46 @@
// OpenTelemetry Node SDK bootstrap for the FarmaClic scraper.
// Started as a side-effect require from index.js (CommonJS).
//
// Env vars:
// OTEL_SERVICE_NAME — default: farmaclic-scraper
// OTEL_EXPORTER_OTLP_ENDPOINT — OTLP gRPC endpoint (e.g. http://alloy:4317)
const { NodeSDK } = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-grpc');
const { resourceFromAttributes } = require('@opentelemetry/resources');
const {
ATTR_SERVICE_NAME,
ATTR_SERVICE_NAMESPACE,
} = require('@opentelemetry/semantic-conventions');
const serviceName = process.env.OTEL_SERVICE_NAME || 'farmaclic-scraper';
const otlpEndpoint = process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4317';
const sdk = new NodeSDK({
resource: resourceFromAttributes({
[ATTR_SERVICE_NAME]: serviceName,
[ATTR_SERVICE_NAMESPACE]: 'farmaclic',
}),
traceExporter: new OTLPTraceExporter({ url: otlpEndpoint }),
instrumentations: [
getNodeAutoInstrumentations({
'@opentelemetry/instrumentation-fs': { enabled: false },
'@opentelemetry/instrumentation-dns': { enabled: false },
}),
],
});
sdk.start();
const shutdown = async () => {
try {
await sdk.shutdown();
} catch (err) {
// eslint-disable-next-line no-console
console.error('OpenTelemetry shutdown failed', err);
}
};
process.on('SIGTERM', shutdown);
process.on('SIGINT', shutdown);