I'm using Azure function and WebJob in .Net and sending logs into ApplicationInsights using TelemetryClient.
I have almost same logging code for WebJob and Azure function.
For azure function, I can see my data in Requests, Traces and customMetrics but for WebJob no data is available in customMetrics only available in Traces and Requests.
My EventHub WebJob logging Code
public Task ProcessEventsAsync(PartitionContext context, IEnumerable<EventData> messages)
{
foreach (var eventData in messages)
{
Log log = LogManager.GetLogger();
RequestTelemetry requestTelemetry = new RequestTelemetry { Name = "EventhubWebJob" };
requestTelemetry.Properties.Add("MessageId", Guid.NewGuid().ToString());
IOperationHolder<RequestTelemetry> operation = log.TelemetryClient.StartOperation(requestTelemetry);
operation.Telemetry.Success = true;
log.Trace($"Message processing start...");
try
{
log.Trace("Message received.");
Console.WriteLine($"Message received.");
}
catch (Exception ex)
{
operation.Telemetry.Success = false;
log.Trace(ex.Message);
throw;
}
finally
{
log.Trace($"Message processing completed.");
log.TelemetryClient.StopOperation(operation);
}
}
return context.CheckpointAsync();
}
I can see below data for Function same I need for WebJob.