Open ijagberg opened 5 years ago
cc: @brettsam
This is a bug. We currently only apply the metrics if it comes from our logger that we pass in. We check the category/event pair. When you inject a logger, that category isn't what we expect.
One workaround -- you could request a TelemetryClient
in your class constructor (DI will inject it) and log your metrics directly via that.
Thanks for the update. Looking forward to the fix but trying the workaround meanwhile.
This is a bug. We currently only apply the metrics if it comes from our logger that we pass in. We check the category/event pair. When you inject a logger, that category isn't what we expect.
One workaround -- you could request a
TelemetryClient
in your class constructor (DI will inject it) and log your metrics directly via that.
Hi Bett,
I am trying to use the DI injected TelemetryClient from within my function and when I track an event I am not seeing it in AI anywhere. I have my local settings using the correct key (verified my ILogger is sending telemetry). When I inspect the TelemetryClient instance that gets injected the instrumentation key is empty. Any ideas?
More info (that helped me) about how to use DI for TelemetryClient https://docs.microsoft.com/en-us/azure/azure-monitor/app/asp-net-core
Hey guys, Whats the progress on this? This seems to be a small problem that could have been fixed by now, no? @brettsam
@brettsam is this on a roadmap?
Looking for this too.
Any update on this.
@brettsam - Any updates on this issue? Its been 3+ years 🤷
Hello from 2022 ? any luck, having same problem....
This is almost five years old - still no progress on fixing this?
@mpaul31 Not sure if you're still facing the same issue.
I recently came across this thread and I have a webjob using the .Net Core webjobs SDK and using the package Microsoft.Azure.WebJobs.Logging.ApplicationInsights
I also faced a similar issue where the TelemetryClient was injected but somehow nothing seemed to show up in app insights.
I found the steps in this article helped me get around it even though the article was written for a slightly different context. https://learn.microsoft.com/en-us/azure/azure-monitor/app/ilogger?tabs=dotnet6#im-using-the-standalone-package-microsoftextensionsloggingapplicationinsights-and-i-want-to-log-more-custom-telemetry-manually-how-should-i-do-that
Function App v2.0
I am using Dependency Injection via FunctionsStartup, and my services request an
ILogger<T>
, which seems to be working for trace-logging, but not for metrics.I have tried a few different variations of my host.json file to see if it is a problem with my logging filters, but nothing so far has worked. Even when I set the default filter to "Debug", no custom metrics show up in Application Insights.
I am logging metrics using the instead of the ILogger supplied in the Run() method.
LogMetric
extension method on ILogger from the Microsoft.Extensions.Logging NuGet package. This all worked fine before switching over to using an injected ILoggerInterestingly enough, I can see some trace-logs in Application Insights that seem to correspond with my custom metric logs. There are empty messages in the log analytics that have LogLevel Information and customDimensions "propName" and "propValue" that are the same as my metrics. So it seems like the actual messages are coming through the filters but are not being correctly identified as being metrics.