public void ProcessQueueMessage([QueueTrigger("demoqueue")] ValueMessage message, ILogger log) { // Set operation id correlation CorrelationManager.SetOperationId(message.OperationId); TelemetryClient.TrackEvent(GlobalMetricNames.QueueMessageReceived, new Dictionary <string, string> { [nameof(message)] = JsonConvert.SerializeObject(message) }); var stopWatch = Stopwatch.StartNew(); // Process queue message var i = 0; const int max = 5; while (i++ < max) { log.LogTrace($"Tracing a test message... ({i}/{max})"); Thread.Sleep(2500); } stopWatch.Stop(); TelemetryClient.TrackEvent(nameof(ProcessQueueMessage), metrics: new Dictionary <string, double> { [GlobalMetricNames.Elapsed] = stopWatch.ElapsedMilliseconds }); }
public void Initialize(ITelemetry telemetry) { telemetry.Context.Operation.Id = CorrelationManager.GetOperationId(); }