# Exporters and OTLP: getting spans to Jaeger or Langfuse

> The OpenTelemetry OTLP exporter in a TypeScript Node.js example: send agent spans to Jaeger or Langfuse, and why spans vanish without shutdown.

Source: https://hashspan.dev/learn/otel-exporters-otlp

By Selim Aytaç, maintainer · Published Oct 1, 2026 · Updated Oct 18, 2026

## Short answer

An exporter sends finished spans from the SDK to a backend. OTLP is OpenTelemetry's own protocol, over HTTP or gRPC, and Jaeger, Langfuse and most tracing backends accept it. You pick the destination with OTEL_EXPORTER_OTLP_ENDPOINT. Because exporters send in batches, a short-lived process has to shut the SDK down, or its last spans never leave.

In the demo trace, the slowest span is the reverted `confirm`: 264.9 ms, against 11.8 ms for the successful one. It also fetches the revert reason. In a short script, it's the span most likely to miss the backend.

Figure: The Node.js OTLP export path from span.end() through a BatchSpanProcessor and an OTLP exporter to Jaeger or Langfuse, and why a short script must flush and shut down before it exits.

## What does an exporter do?

It takes finished [spans](https://hashspan.dev/learn/otel-traces-and-spans) from a span processor and sends them somewhere. The usual pair in Node.js:

| Piece | Job |
|---|---|
| `BatchSpanProcessor` | Collects finished spans, exports them in batches on a timer |
| `OTLPTraceExporter` | Encodes them as OTLP and sends them over HTTP or gRPC |
| `OTEL_EXPORTER_OTLP_ENDPOINT` | Where they go |
| `OTEL_EXPORTER_OTLP_HEADERS` | Auth, if the backend needs it |

Node.js has three OTLP trace exporter packages: `exporter-trace-otlp-proto` (HTTP with protobuf), `-http` (HTTP with JSON) and `-grpc`. The hashspan demo uses `-proto` with a batch processor, and switches to the console exporter when `OTEL_TRACES_EXPORTER=console` is set.

## Jaeger or Langfuse?

Both speak OTLP over HTTP, so only the variables change:

```sh
# Jaeger, local
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318

# Langfuse Cloud (EU)
OTEL_EXPORTER_OTLP_ENDPOINT=https://cloud.langfuse.com/api/public/otel
OTEL_EXPORTER_OTLP_HEADERS="Authorization=Basic <base64 of public-key:secret-key>"
```

The Langfuse values are from its [OpenTelemetry docs](https://langfuse.com/docs/opentelemetry/get-started). Langfuse doesn't take gRPC yet, so use the `-proto` or `-http` exporter. In both cases the exporter adds `/v1/traces` to the base URL.

## Why do spans vanish at exit?

The batch processor waits before it exports, and a script can end before it does. Here it is, run twice against a local Jaeger (`@opentelemetry/sdk-trace-node@2.11.0`, `exporter-trace-otlp-proto@0.222.0`), once without `SHUTDOWN` and once with it:

```ts
import { trace } from '@opentelemetry/api';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';
import { resourceFromAttributes } from '@opentelemetry/resources';
import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';

const provider = new NodeTracerProvider({
  resource: resourceFromAttributes({ 'service.name': process.env.SVC ?? 'learn-otlp' }),
  spanProcessors: [new BatchSpanProcessor(new OTLPTraceExporter())], // reads OTEL_EXPORTER_OTLP_ENDPOINT
});
provider.register();

trace.getTracer('learn-demo').startSpan('send 8453').end();

if (process.env.SHUTDOWN) await provider.shutdown(); // exports what the batch still holds
```

| Run | Jaeger |
|---|---|
| No shutdown | "No traces found" |
| `await provider.shutdown()` | The span is there |

No error either way. The span just isn't there.

**In a hashspan trace:**
`provider.shutdown()` exports ended spans. Some hashspan spans haven't ended yet at that point: a background confirmation, a reverted `confirm` still replaying the [revert reason](https://hashspan.dev/learn/tx-lifecycle), or an x402 `payment` still waiting for its settlement. So in scripts, CLI agents and serverless functions, flush hashspan first:

  ```ts
  await hashspan.flush(); // at most 10 s by default
  await provider.shutdown();
  ```

Every adapter (viem, CDP, x402 and MPP) has `flush()`. On timeout it ends the spans it was still waiting on, so they're exported too, and the viem one resolves `false`. A span whose outcome is still unknown then gets `error.type` `timeout`. Long-running services don't need it. Details are in the [viem docs](https://hashspan.dev/docs/adapters/viem).

## FAQ

### How do I configure the OTLP exporter in Node.js?

Create an OTLPTraceExporter from @opentelemetry/exporter-trace-otlp-proto or -http, put it in a BatchSpanProcessor, and set OTEL_EXPORTER_OTLP_ENDPOINT. For HTTP, the exporter appends /v1/traces to that base URL.

### Why are my spans missing when my Node.js script exits?

The BatchSpanProcessor holds spans and exports them on a timer. If the process exits first, they're lost. Await provider.shutdown() before exiting, which exports what's left.

### Does Langfuse accept OTLP?

Yes, over HTTP with JSON or protobuf, at /api/public/otel with Basic auth from your public and secret key. gRPC isn't supported.
