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(TracingIdRepresentation.hex32Chars);
      attributes[DatadogRumPlatformAttributeKey.spanID] =
          context.spanId.asString(TracingIdRepresentation.decimal);
    }
  }

  return attributes;
}