logEvent method
Log an event (synchronous).
If no sink is attached, events are queued and drained when the sink attaches.
Implementation
void logEvent(String eventName, LogEventMetadata metadata) {
// Check sampling.
final sampleResult = shouldSampleEvent(eventName, _samplingConfig);
if (sampleResult != null && sampleResult == 0) return;
final metadataWithRate = sampleResult != null && sampleResult > 0
? {...metadata, 'sample_rate': sampleResult}
: metadata;
if (_sink == null) {
_eventQueue.add(
_QueuedEvent(
eventName: eventName,
metadata: metadataWithRate,
isAsync: false,
),
);
return;
}
// Strip _PROTO_* before Datadog (general-access).
_sink!.logEvent(eventName, metadataWithRate);
}