-
Notifications
You must be signed in to change notification settings - Fork 786
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
LogLevel configuration (appSettings.json) for OpenTelemetry provider not working on Functions app using HostBuilder without defaults #5702
Comments
Log filtering is completely part of If you share a minimal repro app, we can help see if there is anything wrong with the setup. |
Thanks @cijothomas I just invited to a repo, Please simply replace the ApplicationInsights configuration with a proper one. |
@Arash-Sabet Please take a look at https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/docs/logs/getting-started-aspnetcore and make incrementation changes to it till it reproduces the issue you are facing, and share that. Please use ConsoleExporter only to verify if logs are filtered or not. This will be easy for us to investigate and not I won't have the bandwidth to investigate any custom projects that requires ApplicationInsights or anything not shipped from this repo. |
@cijothomas Putting the Application Insights thing aside, the console does not produce logs consistent with the configuration in the appsettings.json config file. |
Yes I understand that, but i need to get a minimal repro to investigate.! Also, repeating my original comment below - most likely its an ILogger configuration issue, nothing specific to OTel. Happy to help, if you show a minimal repro app. Log filtering is completely part of ILogger infra, nothing to do with OpenTelemetry itself, as long as you got the alias "OpenTelemetry" correctly (which you have already using correctly!) |
@cijothomas Thanks, I just minimized the repo and committed the code. I got rid of all application insights stuff. Please note that this is a dotnet-isolated function app with one Web API exposed to simply call it to view the output to the console. |
@cijothomas just wondering, did you have a chance to run the minimal project I shared with you? |
Not yet. I also suggest to share the repro right here for anyone looking at this to see, as opposed to just me having access! (I don't have much experience with Functions specifics, so I won't be of much use, unless you modify the repro to be extremely minimal) |
@cijothomas I made the repository public and everybody must have access to it now. It's found here: https://github.com/Arash-Sabet/FunctionAppOpenTelemetryPOC
I cannot reduce the number of files in the function app as the project is already at its very minimum number of required files to run successfully. If I eliminate even one file, the function won't run. Simply open the solution file in VS 2022 and hit F5 to debug or Ctrl+F5 to run the application. |
Did you nest your "OpenTelemetry" section under "Logging"? Here is an example: Something like this should work automatically if you are using a host: {
"Logging": {
"LogLevel": {
"Default": "Warning"
},
"OpenTelemetry": {
"LogLevel": {
"Default": "Information"
},
"IncludeFormattedMessage": true,
"IncludeScopes": true,
"ParseStateValues": true
}
}
} |
@CodeBlanch Thanks for the reply. I used the json payload you shared in the appsettings.json as is and it dot work. To be more specific,, changing |
So the issue is you are NOT really using a host. You are building a host manually. Seems like a quirk of functions bootstrap. Here is where configuration is bound in a Here is the generic host equivalent: https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.Extensions.Hosting/src/HostingHostBuilderExtensions.cs#L294 You have a couple options... Bind configuration manually- .ConfigureServices(services =>
+ .ConfigureServices((context, services) =>
{
+ services.AddLogging(logging => logging.AddConfiguration(context.Configuration.GetSection("Logging")));
services
.AddOpenTelemetry()
.ConfigureResource(r => r.AddService("POC.Func.App"))
.WithLogging(logging => logging.AddConsoleExporter());
}) Enable host defaultsvar host = new HostBuilder()
+ .ConfigureDefaults(args) // Calls into the code linked above to set up defaults including configuration binding
.ConfigureFunctionsWebApplication() Don't ask me what other side effects that will have 😄 |
Thanks @CodeBlanch I will keep you posted as soon as I try your recent approach. |
@CodeBlanch @cijothomas The solution worked. Thanks for your support. |
What is the question?
One would normally follow the following pattern to set the log level in their application:
Apparently
OpenTelemetryLoggerProvider
hasOpenTelemetry
alias and hence we must be able to configure it like the following entry but it's not working:Are we missing anything in the configuration?
Additional context
No response
The text was updated successfully, but these errors were encountered: