parse static method

LogDropTraceContext? parse(
  1. String? value
)

Implementation

static LogDropTraceContext? parse(String? value) {
  if (value == null) return null;
  final match = _pattern.firstMatch(value);
  if (match == null) return null;
  final version = match.group(1)!;
  final traceId = match.group(2)!;
  final spanId = match.group(3)!;
  final flags = match.group(4)!;
  final suffix = match.group(5) ?? '';
  if (version == 'ff' ||
      (version == '00' && suffix.isNotEmpty) ||
      _isZero(traceId) ||
      _isZero(spanId)) {
    return null;
  }
  return LogDropTraceContext(
    traceId: traceId,
    clientSpanId: spanId,
    traceFlags: flags,
    traceparent: value,
    source: 'caller',
    version: version,
    suffix: suffix,
  );
}