before method
Before flag evaluation
Implementation
@override
Future<void> before(HookContext context) async {
_startTime = DateTime.now();
// Start span with OTel naming convention
final attributes = <String, Object?>{
'feature_flag.key': context.flagKey,
'feature_flag.provider_name': 'IntelliToggle',
};
// Extract targetingKey from evaluation context map (required by OTel)
if (context.evaluationContext != null) {
final evalContext = context.evaluationContext;
// Check for targetingKey in the map
if (evalContext is Map<String, dynamic> &&
evalContext.containsKey('targetingKey')) {
attributes['feature_flag.context.targetingKey'] =
evalContext['targetingKey'];
}
}
_span = Telemetry.startSpan('feature_flag', attributes: attributes);
// Increment total evaluation counter
Telemetry.metrics.increment('feature_flag.evaluation_count');
}