Hello Everyone, My name is kavish, Working as DevO...
# support
p
Hello Everyone, My name is kavish, Working as DevOps Engineer. Currently i am trying to setup an tracing for an node.js application, i have first tried to use signoz cloud for instrumenting my application, and i am able to connect my application to signoz, but when i used an selfhosted signoz i cannot able to connect my application to signoz, Here is my tracing.js file // tracing.js 'use strict' const process = require('process'); const opentelemetry = require('@opentelemetry/sdk-node'); const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node'); const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http'); const { Resource } = require('@opentelemetry/resources'); // do not set headers in exporterOptions, the OTel spec recommends setting headers through ENV variables // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#specifying-headers-via-environment-variables const exporterOptions = { // url: 'https://ingest.in.signoz.cloud:443/v1/traces' url: 'http://localhost:3301/v1/traces' } const traceExporter = new OTLPTraceExporter(exporterOptions); const sdk = new opentelemetry.NodeSDK({ traceExporter, instrumentations: [getNodeAutoInstrumentations()], resource: new Resource({ 'service.name': 'kavish-app' // Directly specify the attribute key as a string }) }); // 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)); }); //sample-app const express = require("express"); const cors = require('cors') const PORT = process.env.PORT || "5555"; const app = express(); const { trace, SpanStatusCode } = require("@opentelemetry/api"); app.use(cors()); app.use(express.json()) app.all("/", (req, res) => { // Get the current span from the tracer const span = trace.getActiveSpan(); err = new _Error_("This is a test error"); // recordException converts the error into a span event. span.recordException(err); span.setAttribute('attribute1', 'value1'); // Update the span status to failed. span.setStatus({ code: SpanStatusCode.ERROR, message: _String_(err) }); res.json({ method: req.method, message: "Hello World", ...req.body }); }); app.get('/404', (req, res) => { res.sendStatus(404); }) app.listen(parseInt(PORT, 10), () => { console.log(
Listening for requests on <http://localhost>:${PORT}
); }); My signoz is running on "http://localhost:3301/" And i am running my application with this command "node -r ./tracing.js app.js" Can anyone tell me that what i am doing wrong?, what change do i need to do, or any insight ?
p
In this url update port to 4317(gRPC)/4318(http) this might fix your problem.
url: '<http://localhost:4318/v1/traces>'
🙌 1
This address in for signoz otel collector. while 3301 is for the UI
p
This works, thanks @Pradyuman
Hello @Pradyuman,Can we send Jaeger-collector trace which it collect to an signoz-otel-collector?
p
Since Jaeger importer is present in signoz collector is signoz collector you can send it. Someone from signoz team would be able to help you in exact implementation. https://github.com/SigNoz/signoz-otel-collector/blob/275a1e6873f7e1e06145c16014b35694e75c8fd1/components/components.go#L175