shouldAddTraceParent static method

bool shouldAddTraceParent(
  1. String? requestURLString,
  2. CXExporterOptions options
)

Implementation

static bool shouldAddTraceParent(String? requestURLString, CXExporterOptions options) {
  if (requestURLString == null) {
    return false;
  }

  final traceParentDict = options.traceParentInHeader;
  if (traceParentDict == null) {
    return false;
  }

  final traceParent = TraceParentInHeader.params(traceParentDict);

  if (!traceParent.enable) {
    return false;
  }

  final allowedUrls = traceParent.allowedTracingUrls;

  if (allowedUrls != null && allowedUrls.isNotEmpty) {
    if (allowedUrls.contains(requestURLString)) {
      return true;
    }

    return Global.isHostMatchesRegexPattern(requestURLString, allowedUrls);
  }

  return true;
}