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

.Net: Create a classifiable Kernel Function logger #6011

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

feiyun0112
Copy link
Contributor

fix #5989

@feiyun0112 feiyun0112 requested a review from a team as a code owner April 26, 2024 04:18
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code kernel.core labels Apr 26, 2024
@@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 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?
  2. 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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 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.

@markwallace-microsoft markwallace-microsoft self-assigned this May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kernel.core .NET Issue or Pull requests regarding .NET code
Projects
Status: Community PRs
Development

Successfully merging this pull request may close these issues.

.Net: Create a classifiable Kernel Function logger.
5 participants