Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

241
Vistas
How to manually extract context or span from incoming http request in NodeJS?

I trying to migrate my Node.js application from jaeger-client to @opentelemetry/* packages

In my Node.js application i have a simple http server and i want to create span on each response.

With jaeger-client i did it in the following way:

import { FORMAT_HTTP_HEADERS } from 'opentracing';
import { initTracerFromEnv } from 'jaeger-client';

const tracer = initTracerFromEnv(/* some options here */);

// app is expressjs app
app.get('/home', req => {
  const rootSpan = tracer.startSpan('response', {
    childOf: tracer.extract(FORMAT_HTTP_HEADERS, req.headers),
  });

  // ...make child spans of rootSpan
});

I want to connect my root span of response with spans from other application, that performs request to my Node.js application server. About the same as I would do it with jaeger-client.

How can i make it with OpenTelemetry instead of jeager-client and opentracing? Is it possible to create child spans manually, without auto instrumentations?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can do the Context Propagation by extracting the parent context from the request headers and creating the child span with it, as follows:

const opentelemetry = require('@opentelemetry/api');
const {SpanKind, ROOT_CONTEXT} = require("@opentelemetry/api");


app.get('/home', req => {
  // Get incoming context from headers
  const remoteCtx = opentelemetry.propagation.extract(ROOT_CONTEXT, req.headers);

  // ...make child spans of remoteSpan

  // Create child span passing parent context 
  const childSpan = tracer.startSpan(
    'childSpan',
    remoteCtx
  );

  // ... Do important stuff

  
  // End the span
  childSpan.end();
});

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda