Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Application Insights metrics sent with same log category as automatic function traces #3024

Open
ben-hamida opened this issue Sep 28, 2023 · 0 comments

Comments

@ben-hamida
Copy link

The automatic trace logging generated during function execution shares the same log category as custom metrics sent in functions. This makes it impossible to filter out one while retaining the other in the 'logging' section of the host.json configuration.

The built-in trace logging that we want to filter out are the ones that say 'Executing function....' at the start of function execution and 'Executed function...' at the end. The reason is that we have event-hub-triggered functions that are executed very frequently, sometimes hundreds of times per second, resulting in excessive costs associated with the trace logs generated.

If a function is called 'MetricSender', the category that both the traces and the metrics get is 'Function.MetricSender'.

Repro steps

  1. Create a function that uses ITelemetryClient to send metrics

  2. Add the following in host.json:

"logging": {
  "logLevel": {
    "Function": "Warning",
  }
}
  1. Run the app

Expected behavior

Custom metrics should not be filtered out. There should be a mechanism in host.json that allows us to filter out built-in function execution traces while preserving custom metrics generated by functions.

Actual behavior

Currently, custom metrics are inadvertently filtered out along with function execution traces. There is no direct way to filter out function traces without affecting custom metrics in host.json

Known workarounds

We can work around the issue by implementing a custom ITelemetryProcessor that filters out the undesired traces instead of filtering them out in host.json. Alternatively, we could have the processor change the category for metrics.

Related information

We are using the following packages:

  • Microsoft.Azure.WebJobs.Logging.ApplicationInsights 3.0.35
  • Microsoft.NET.Sdk.Functions 4.2.0
  • Microsoft.Extensions.Logging 6.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant