// Send working set of device memory over telemetry. private async Task SendDeviceMemoryAsync(CancellationToken cancellationToken) { string telemetryName = "workingSet"; long workingSet = Process.GetCurrentProcess().PrivateMemorySize64 / 1024; using Message msg = PnpHelper.CreateIothubMessageUtf8(telemetryName, JsonConvert.SerializeObject(workingSet)); await _deviceClient.SendEventAsync(msg, cancellationToken); _logger.LogDebug($"Telemetry: Sent - {{ \"{telemetryName}\": {workingSet}KiB }}."); }
// Send working set of device memory over telemetry. private static async Task SendDeviceMemoryAsync() { string telemetryName = "workingSet"; long workingSet = Environment.WorkingSet / 1024; Message msg = PnpHelper.CreateIothubMessageUtf8(telemetryName, JsonConvert.SerializeObject(workingSet)); await s_deviceClient.SendEventAsync(msg); s_logger.LogDebug($"Telemetry: Sent - {{ \"{telemetryName}\": {workingSet}KiB }}."); }
private static async Task SendTemperatureTelemetryAsync(string componentName) { string telemetryName = "temperature"; double currentTemperature = s_temperature[componentName]; Message msg = PnpHelper.CreateIothubMessageUtf8(telemetryName, JsonConvert.SerializeObject(currentTemperature), componentName); await s_deviceClient.SendEventAsync(msg); s_logger.LogDebug($"Telemetry: Sent - component=\"{componentName}\", {{ \"{telemetryName}\": {currentTemperature}°C }}."); if (s_temperatureReadings.ContainsKey(componentName)) { s_temperatureReadings[componentName].TryAdd(DateTimeOffset.Now, currentTemperature); } else { s_temperatureReadings.TryAdd(componentName, new Dictionary <DateTimeOffset, double>() { { DateTimeOffset.Now, currentTemperature } }); } }