cocomon

Exporters

Choose between console, in-memory, and OTLP exporters and understand the main transport tradeoffs.

Exporters

The SDK supports several exporter families.

Preset choices through Otel.init()

ExporterUse it for
OtelExporter.consoleLocal development and quick inspection
OtelExporter.otlpHttpOTLP over HTTP protobuf
OtelExporter.otlpHttpJsonOTLP over HTTP JSON
OtelExporter.otlpGrpcOTLP over gRPC

Console exporter

await Otel.init(
  serviceName: 'my-app',
  exporter: OtelExporter.console,
);

Best for local development. Not a production delivery path.

OTLP over HTTP or gRPC

await Otel.init(
  serviceName: 'my-app',
  exporter: OtelExporter.otlpHttp,
  endpoint: 'http://localhost:4318',
);

Use per-signal endpoints, headers, timeouts, and compression overrides when your collector topology needs them.

In-memory exporters for tests

final helper = await OtelTestHelper.setup();

await Otel.instance.tracer.traceAsync('test-operation', fn: () async {});
await Otel.forceFlush();

expect(helper.spanExporter.lastSpanNamed('test-operation'), isNotNull);

That is the fastest path for verifying instrumentation behavior without a running collector.

Practical rule

  • local development: console
  • tests: in-memory
  • real delivery: OTLP HTTP or gRPC

On this page