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); }
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); }
private void SetBlockId(IVsTelemetryEvent telemetryEvent, FunctionId functionId, int blockId) { var blockIdName = functionId.GetPropertyName(BlockId); telemetryEvent.SetIntProperty(blockIdName, blockId); }
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; }
private void SetBlockId(TelemetryEvent telemetryEvent, FunctionId functionId, int blockId) { var blockIdName = functionId.GetPropertyName(BlockId); telemetryEvent.Properties.Add(blockIdName, blockId); }