Marc Trepanier
04/17/2024, 11:03 AM{
"stack": "Error: connect ECONNREFUSED 127.0.0.1:4318\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16)\n at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17)",
"message": "connect ECONNREFUSED 127.0.0.1:4318",
"errno": "-61",
"code": "ECONNREFUSED",
"syscall": "connect",
"address": "127.0.0.1",
"port": "4318",
"name": "Error"
}
My instrumentation file: (Note access token has been redacted)
"use strict";
import { NodeSDK } from "@opentelemetry/sdk-node";
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
import { Resource } from "@opentelemetry/resources";
import { SEMRESATTRS_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
import { SimpleSpanProcessor } from "@opentelemetry/sdk-trace-node";
import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";
import { diag, DiagConsoleLogger, DiagLogLevel } from "@opentelemetry/api";
diag.setLogger(new DiagConsoleLogger(), <http://DiagLogLevel.INFO|DiagLogLevel.INFO>);
// configure the SDK to export telemetry data to the console
// enable all auto-instrumentations from the meta package
const exporterOptions = {
url: "<https://ingest.eu.signoz.cloud:443/v1/traces>", // use your own data region or use localhost:8080 for self-hosted
headers: { "signoz-access-token": "your-access-token" }, // Use if you are using SigNoz Cloud
};
const traceExporter = new OTLPTraceExporter(exporterOptions);
const sdk = new NodeSDK({
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: `LEO-${process.env.APP_ENV}`,
}),
serviceName: `LEO-${process.env.APP_ENV}`,
traceExporter,
instrumentations: [getNodeAutoInstrumentations()],
spanProcessors: [new SimpleSpanProcessor(new OTLPTraceExporter())],
});
// initialize the SDK and register with the OpenTelemetry API
// this enables the API to record telemetry
sdk.start();
// gracefully shut down the SDK on process exit
process.on("SIGTERM", () => {
sdk
.shutdown()
.then(() => console.log("Tracing terminated"))
.catch((error) => console.log("Error terminating tracing", error))
.finally(() => process.exit(0));
});
Srikanth Chekuri
04/18/2024, 2:59 AMtraceExporter
instead of creating a new one in spanProcessors: [new SimpleSpanProcessor(new OTLPTraceExporter())]
. As you can see from the error logs, it is trying to send data to 127.0.0.1:4318
. This happens because the URL is not provided in ``new OTLPTraceExporter())`` so it uses the localhost.Srikanth Chekuri
04/18/2024, 3:00 AMMarc Trepanier
04/18/2024, 7:58 AMMarc Trepanier
04/18/2024, 7:58 AMSigNoz is an open-source APM. It helps developers monitor their applications & troubleshoot problems, an open-source alternative to DataDog, NewRelic, etc.
Powered by