-
Notifications
You must be signed in to change notification settings - Fork 4k
.Net: Create a classifiable Kernel Function logger #6011
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
Conversation
dotnet/src/SemanticKernel.Abstractions/Functions/KernelFunction.cs
Outdated
Show resolved
Hide resolved
…n.cs Co-authored-by: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
@@ -156,7 +156,7 @@ internal KernelFunction(string name, string? pluginName, string description, IRe | |||
Verify.NotNull(kernel); | |||
|
|||
using var activity = s_activitySource.StartActivity(this.Name); | |||
ILogger logger = kernel.LoggerFactory.CreateLogger(this.Name) ?? NullLogger.Instance; | |||
ILogger logger = kernel.LoggerFactory.CreateLogger($"{this.GetType()}.{this.Name}") ?? NullLogger.Instance; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- This means that the implementation detail of the internal derived type's name will end up showing up in logging. That name could easily change. Is this desirable?
- We don't need to allocate a new string on each invocation. It can be cached once and then used on each access. That also avoids the duplication between InvokeAsync and InvokeStreamingAsync.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- This means that the implementation detail of the internal derived type's name will end up showing up in logging. That name could easily change. Is this desirable?
I think we want to avoid creating logger with name based on function name, because in this case the number of different loggers created will be equal to number of different functions users execute.
Having Microsoft.SemanticKernel.KernelFunction
logger name and specific logs like this._logger.LogInformation("Start function execution: {PluginName}-{FunctionName}", this.PluginName, this.Name");
should be enough, and it will be possible to filter logs by FunctionName
property in monitoring tool.
Replacing with #8107 |
fix #5989