Skip to content

Sending data to a self-hosted custom collector #16

@GiamBoscaro

Description

@GiamBoscaro

When I try to start my node application, I get this error as soon as the instrumentation.js file is preloaded.
I am using Node 16 inside Docker container (node:16-slim official image).

ReferenceError: crypto is not defined
    at V (/usr/src/app/node_modules/logfire/dist/index.cjs:1:2221)
    at m.generateTraceId (/usr/src/app/node_modules/logfire/dist/index.cjs:1:2139)
    at Tracer.startSpan (/usr/src/app/node_modules/@opentelemetry/sdk-trace-base/build/src/Tracer.js:71:41)
    at ProxyTracer.startSpan (/usr/src/app/node_modules/@opentelemetry/api/build/src/trace/ProxyTracer.js:32:34)
    at w (/usr/src/app/node_modules/@pydantic/logfire-api/dist/index.cjs:1:6201)
    at Module.ue [as reportError] (/usr/src/app/node_modules/@pydantic/logfire-api/dist/index.cjs:1:6916)
    at process.<anonymous> (/usr/src/app/node_modules/logfire/dist/index.cjs:1:3715)
    at process.emit (node:events:513:28)
    at process._fatalException (node:internal/process/execution:146:13)
// instrumentation.js
const logfire = require('logfire');
const os = require('os');
const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http');
const { ExpressInstrumentation } = require('@opentelemetry/instrumentation-express');
const config = require('./config');
const { version } = require('./package.json');

logfire.configure({
  serviceName: os.hostname(),
  sendToLogfire: false,
  serviceVersion: version,
  environment: config.NODE_ENV,
  nodeAutoInstrumentations: {
    '@opentelemetry/instrumentation-express': ExpressInstrumentation,
    '@opentelemetry/instrumentation-http': HttpInstrumentation,
  },
  advanced: {
    baseUrl: config.TRACING_BASE_URL,
  },
});

I am connecting to a local instance of Alloy, and then I see the Traces in grafana. Everything is working normally in the Python logfire SDK, but getting these errors in the Javascript SDK

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions