Example #1
0
        public void Sink(ITrackingEvent trackingEvent)
        {
            if (trackingEvent is null)
            {
                throw new ArgumentNullException(nameof(trackingEvent));
            }

            switch (trackingEvent)
            {
            case IScopeCreatedEvent e:
                _logScopeCreated(_logger, e.ScopeId, e.Timestamp, null);
                break;

            case ITrackerCreatedEvent e:
                _logTrackerCreated(_logger, e.ScopeId, e.TrackerId, e.Timestamp, null);
                break;

            case ITrackerStartedEvent e:
                _logTrackerStarted(_logger, e.ScopeId, e.TrackerId, e.Timestamp, e.Elapsed, null);
                break;

            case ITrackerStoppedEvent e:
                _logTrackerStopped(_logger, e.ScopeId, e.TrackerId, e.Timestamp, e.Elapsed, null);
                break;

            case ITrackerCompletedEvent e:
                _logTrackerCompleted(_logger, e.ScopeId, e.TrackerId, e.Timestamp, e.Elapsed, null);
                break;

            case ITrackerFaultedEvent e:
                _logTrackerFaulted(_logger, e.ScopeId, e.TrackerId, e.Timestamp, e.Elapsed, e.Exception);
                break;

            case ITrackerCancelledEvent e:
                _logTrackerCancelled(_logger, e.ScopeId, e.TrackerId, e.Timestamp, e.Elapsed, e.Exception);
                break;

            default:
                throw new InvalidOperationException($"TrackingEvent of type '{trackingEvent.GetType().Name}' is not supported by this sink");
            }
        }