fromHookContext static method

OTelAttributes fromHookContext(
  1. HookContext context, {
  2. String? providerName,
  3. String? reason,
})

Creates OpenTelemetry-compatible attributes from HookContext

This is a convenience method for use in hooks when EvaluationDetails is not available.

Implementation

static OTelAttributes fromHookContext(
  HookContext context, {
  String? providerName,
  String? reason,
}) {
  return createOTelAttributes(
    flagKey: context.flagKey,
    value: context.result,
    providerName: providerName,
    reason:
        reason ??
        (context.error != null
            ? OTelFeatureFlagConstants.REASON_ERROR
            : OTelFeatureFlagConstants.REASON_DEFAULT),
    evaluationContext: context.evaluationContext,
  );
}