addSpanExporter method

void addSpanExporter({
  1. required String endpoint,
  2. List<Map<String, String>>? headers,
  3. int? timeoutSeconds,
})

Adds an OTLP HTTP span exporter.

Must be called before start so the exporter is registered before the native SDK initializes. endpoint must be the full OTLP/HTTP URL for traces (e.g. https://otlp.example.com/v1/traces). headers is an optional list of single-entry maps, one per header, e.g. [{'x-api-key': 'token'}] — this mirrors the format expected by the platform method channel. timeoutSeconds defaults to the platform SDK's default timeout when omitted.

Implementation

void addSpanExporter({
  required String endpoint,
  List<Map<String, String>>? headers,
  int? timeoutSeconds,
}) {
  _ensureOTelInitialized();
  _runCatching(
    'addSpanExporter',
    () => tracerProvider.addSpanExporter(
      endpoint: endpoint,
      headers: headers,
      timeoutSeconds: timeoutSeconds,
    ),
  );
}