Ejemplo n.º 1
0
        public void LogBlockEnd(FunctionId functionId, LogMessage logMessage, int blockId, int delta, CancellationToken cancellationToken)
        {
            var kvLogMessage = logMessage as KeyValueLogMessage;

            if (kvLogMessage == null)
            {
                return;
            }

            try
            {
                // guard us from exception thrown by telemetry
                var telemetryEvent = CreateTelemetryEvent(functionId, End);
                SetBlockId(telemetryEvent, functionId, blockId);

                var durationName = functionId.GetPropertyName(Duration);
                telemetryEvent.SetIntProperty(durationName, delta);

                var cancellationName = functionId.GetPropertyName(CancellationRequested);
                telemetryEvent.SetBoolProperty(cancellationName, cancellationToken.IsCancellationRequested);

                _session.PostEvent(telemetryEvent);
            }
            catch
            {
            }
        }
        private static T AppendProperties <T>(T @event, FunctionId functionId, KeyValueLogMessage logMessage)
            where T : TelemetryEvent
        {
            if (!logMessage.ContainsProperty)
            {
                return(@event);
            }

            foreach (var kv in logMessage.Properties)
            {
                var propertyName = functionId.GetPropertyName(kv.Key);

                // call SetProperty. VS telemetry will take care of finding correct
                // API based on given object type for us.
                //
                // numeric data will show up in ES with measurement prefix.
                @event.Properties.Add(propertyName, kv.Value);
            }

            return(@event);
        }
Ejemplo n.º 3
0
        private IVsTelemetryEvent CreateTelemetryEvent(FunctionId functionId, string eventKey = null, KeyValueLogMessage logMessage = null)
        {
            var eventName      = functionId.GetEventName(eventKey);
            var telemetryEvent = _service.CreateEvent(eventName);

            if (logMessage == null || !logMessage.ContainsProperty)
            {
                return(telemetryEvent);
            }

            foreach (var kv in logMessage.Properties)
            {
                var propertyName = functionId.GetPropertyName(kv.Key);

                // call SetProperty. VS telemetry will take care of finding correct
                // API based on given object type for us.
                //
                // numeric data will show up in ES with measurement prefix.
                telemetryEvent.SetProperty(propertyName, kv.Value);
            }

            return(telemetryEvent);
        }
Ejemplo n.º 4
0
        private void SetBlockId(IVsTelemetryEvent telemetryEvent, FunctionId functionId, int blockId)
        {
            var blockIdName = functionId.GetPropertyName(BlockId);

            telemetryEvent.SetIntProperty(blockIdName, blockId);
        }
Ejemplo n.º 5
0
        public void LogBlockEnd(FunctionId functionId, LogMessage logMessage, int blockId, int delta, CancellationToken cancellationToken)
        {
            var kvLogMessage = logMessage as KeyValueLogMessage;
            if (kvLogMessage == null)
            {
                return;
            }

            try
            {
                // guard us from exception thrown by telemetry
                var telemetryEvent = CreateTelemetryEvent(functionId, End);
                SetBlockId(telemetryEvent, functionId, blockId);

                var durationName = functionId.GetPropertyName(Duration);
                telemetryEvent.SetIntProperty(durationName, delta);

                var cancellationName = functionId.GetPropertyName(CancellationRequested);
                telemetryEvent.SetBoolProperty(cancellationName, cancellationToken.IsCancellationRequested);

                _session.PostEvent(telemetryEvent);
            }
            catch
            {
            }
        }
Ejemplo n.º 6
0
 private void SetBlockId(IVsTelemetryEvent telemetryEvent, FunctionId functionId, int blockId)
 {
     var blockIdName = functionId.GetPropertyName(BlockId);
     telemetryEvent.SetIntProperty(blockIdName, blockId);
 }
Ejemplo n.º 7
0
        private IVsTelemetryEvent CreateTelemetryEvent(FunctionId functionId, string eventKey = null, KeyValueLogMessage logMessage = null)
        {
            var eventName = functionId.GetEventName(eventKey);
            var telemetryEvent = _service.CreateEvent(eventName);

            if (logMessage == null || !logMessage.ContainsProperty)
            {
                return telemetryEvent;
            }

            foreach (var kv in logMessage.Properties)
            {
                var propertyName = functionId.GetPropertyName(kv.Key);

                // call SetProperty. VS telemetry will take care of finding correct
                // API based on given object type for us.
                // 
                // numeric data will show up in ES with measurement prefix.
                telemetryEvent.SetProperty(propertyName, kv.Value);
            }

            return telemetryEvent;
        }
Ejemplo n.º 8
0
        private void SetBlockId(TelemetryEvent telemetryEvent, FunctionId functionId, int blockId)
        {
            var blockIdName = functionId.GetPropertyName(BlockId);

            telemetryEvent.Properties.Add(blockIdName, blockId);
        }