-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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: SK Telemetry improvements #1905
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
github-actions
bot
added
docs and tests
Improvements or additions to documentation
.NET
Issue or Pull requests regarding .NET code
kernel
Issues or pull requests impacting the core kernel
samples
memory connector
labels
Jul 8, 2023
dotnet/src/Extensions/Planning.SequentialPlanner/SequentialPlannerExtensions.cs
Show resolved
Hide resolved
dotnet/src/Connectors/Connectors.AI.OpenAI/AzureSdk/OpenAIClientBase.cs
Outdated
Show resolved
Hide resolved
SergeyMenshykh
previously approved these changes
Jul 18, 2023
stephentoub
reviewed
Jul 18, 2023
shawncal
approved these changes
Jul 18, 2023
piotrek-appstream
pushed a commit
to Appstream-Studio/semantic-kernel
that referenced
this pull request
Jul 19, 2023
### 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. --> This PR contains changes to improve observability for Semantic Kernel users, including: - Logging: using already existing `ILogger` interface with some improvements described below. - Metering: implemented using `Meter` and `MeterListener` classes from `System.Diagnostics.Metrics` namespace. - Tracing: implemented using `Activity`, `ActivitySource` and `ActivityListener` classes from `System.Diagnostics` namespace. Added telemetry uses native .NET methods, which means that it's not dependent on specific telemetry tool. Current PR contains console application using Application Insights as example to show telemetry capabilities in Kernel. Changes include instrumentation for `SequentialPlanner` as a starting point and later there will be new PRs for other types of planners and more improvements for kernel telemetry. Also, there are updates for `LogLevel` handling across codebase to align with described log level purpose: https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.loglevel?view=dotnet-plat-ext-7.0 Particularly, there are changes for `LogLevel.Trace` to be used for sensitive data and most detailed messages, which should not be enabled in prodution environments. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Changes: - Marked `.WithLogger` method in KernelBuilder as obsolete and added new method `.WithLogging`. - Added new methods `.WithMetering` and `.WithTracing` in KernelBuilder. - Improved `LogLevel` handling across codebase to cover cases of logging sensitive data. - Implemented `InstrumentedSequentialPlanner` for instrumentation using decorator pattern. - Extended `InvokeAsync` method in `Plan` for instrumentation. ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows SK Contribution Guidelines (https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) - [x] The code follows the .NET coding conventions (https://learn.microsoft.com/dotnet/csharp/fundamentals/coding-style/coding-conventions) verified with `dotnet format` - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 --------- Co-authored-by: Shawn Callegari <36091529+shawncal@users.noreply.github.com>
4 tasks
github-merge-queue bot
pushed a commit
that referenced
this pull request
Jul 24, 2023
) ### 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. --> This is follow-up PR to the previous one regarding telemetry: #1905 ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> 1. Added small improvements in instrumentation for `SequentialPlanner`. 2. Added instrumentation for `ActionPlanner`. 3. Added instrumentation for `StepwisePlanner`. 4. Updated log levels in `StepwisePlanner` to disable sensitive data by default. ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] 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 - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 --------- Co-authored-by: Shawn Callegari <36091529+shawncal@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
kernel
Issues or pull requests impacting the core kernel
memory connector
.NET
Issue or Pull requests regarding .NET code
PR: ready for review
All feedback addressed, ready for reviews
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
This PR contains changes to improve observability for Semantic Kernel users, including:
ILogger
interface with some improvements described below.Meter
andMeterListener
classes fromSystem.Diagnostics.Metrics
namespace.Activity
,ActivitySource
andActivityListener
classes fromSystem.Diagnostics
namespace.Added telemetry uses native .NET methods, which means that it's not dependent on specific telemetry tool.
Current PR contains console application using Application Insights as example to show telemetry capabilities in Kernel.
Changes include instrumentation for
SequentialPlanner
as a starting point and later there will be new PRs for other types of planners and more improvements for kernel telemetry.Also, there are updates for
LogLevel
handling across codebase to align with described log level purpose:https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.loglevel?view=dotnet-plat-ext-7.0
Particularly, there are changes for
LogLevel.Trace
to be used for sensitive data and most detailed messages, which should not be enabled in prodution environments.Description
Changes:
.WithLogger
method in KernelBuilder as obsolete and added new method.WithLogging
..WithMetering
and.WithTracing
in KernelBuilder.LogLevel
handling across codebase to cover cases of logging sensitive data.InstrumentedSequentialPlanner
for instrumentation using decorator pattern.InvokeAsync
method inPlan
for instrumentation.Contribution Checklist
dotnet format