generateDatadogAttributes function

Map<String, Object?> generateDatadogAttributes(
  1. TracingContext? context,
  2. double samplingRate
)

Implementation

Map<String, Object?> generateDatadogAttributes(
    TracingContext? context, double samplingRate) {
  var attributes = <String, Object?>{};

  if (context != null) {
    attributes[DatadogRumPlatformAttributeKey.rulePsr] = samplingRate / 100.0;
    if (context.sampled) {
      attributes[DatadogRumPlatformAttributeKey.traceID] =
          context.traceId.asString(TraceIdRepresentation.decimal);
      attributes[DatadogRumPlatformAttributeKey.spanID] =
          context.spanId.asString(TraceIdRepresentation.decimal);
    }
  }

  return attributes;
}