I working on Azure Function App and would like to adding custom messages/traces which can aid in debugging and improving performance. THis is my code I am using:
var telemetry = new Microsoft.ApplicationInsights.TelemetryClient();
telemetry.TrackTrace("Alert Button Pressed by Device ->"+CloudObject.A, SeverityLevel.Warning,new Dictionary<string, string> { { "IoT Object", IOTMESSAGE } });
But when I go to Application Insight and Query traces(All) I do not see trace message I am setting.
Am I doing something wrong?
3
Answers
It still not working. I am getting this warning, could this be an issue?
I have set a sampling and data ap on application insight, I am hoping custom trace messages ignore those set limits
I have reproduced with the same code and got the expected results as below:
Application Insights:
Query Traces:
You shoud not instantiate
TelemetryClient
using the parameterless constructor. Use dependency injection instead.When 1 and 2 are done you could also use the
ILogger
interface to create traces telemetry in application insights. You can inject a logger like this:Please read this section in the docs carefully.