SentryTraceHeader.fromTraceHeader constructor

SentryTraceHeader.fromTraceHeader(
  1. String header
)

Implementation

factory SentryTraceHeader.fromTraceHeader(String header) {
  final parts = header.split('-');
  bool? sampled;

  if (parts.length < 2) {
    throw InvalidSentryTraceHeaderException('Header: $header is invalid.');
  } else if (parts.length == 3) {
    sampled = '1' == parts[2];
  }

  final traceId = SentryId.fromId(parts[0]);
  final spanId = SpanId.fromId(parts[1]);

  return SentryTraceHeader(
    traceId,
    spanId,
    sampled: sampled,
  );
}