You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
.Net: Establish pattern to use LoggerMessage attribute in KernelFunction and Instrumented Planner (microsoft#3859)
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here.
-->
It has been recommended by folks from the OpenTelemetry team to use the
`LoggerMessage` attribute to produce more optimized code. As we are
improving observability for the kernel, it's also important that we
achieve better observability with optimized performance.
For more information, please refer to this link:
https://learn.microsoft.com/en-us/dotnet/core/extensions/logger-message-generator
### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
1. Create a new extension for `KernelFunction` named
`KernelFunctionLogExtensions` that contains methods to perform optimized
logging.
2. Turn logging calls in `PlannerInstrumentation` to calls to
source-generated logging code.
Other parts of the kernel will also adopt `LoggerMessage` in the future.
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [ ] The code builds clean without any errors or warnings
- [ ] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [ ] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄
@@ -182,11 +177,7 @@ public async Task<FunctionResult> InvokeAsync(
182
177
thrownewOperationCanceledException($"A {nameof(Kernel)}.{nameof(Kernel.FunctionInvoked)} event handler requested cancellation after function invocation.");
0 commit comments