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

Python: Add OpenTelemetry to Python SK #6914

Merged
merged 41 commits into from
Jul 25, 2024
Merged

Conversation

glahaye
Copy link
Contributor

@glahaye glahaye commented Jun 23, 2024

Motivation and Context

We want observability into usage of SK

Description

Add OpenTelemetry to Python SK

Contribution Checklist

@glahaye glahaye requested a review from a team as a code owner June 23, 2024 23:12
@markwallace-microsoft markwallace-microsoft added the python Pull requests for the Python Semantic Kernel label Jun 23, 2024
@github-actions github-actions bot changed the title Add OpenTelemetry to Python SK Python: Add OpenTelemetry to Python SK Jun 23, 2024
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Jun 23, 2024

Py3.10 Test Coverage

Python 3.10 Test Coverage Report
FileStmtsMissCoverMissing
semantic_kernel
   kernel.py157994%145, 156, 160, 200–201, 310–313, 422
semantic_kernel/connectors/ai/azure_ai_inference/services
   azure_ai_inference_chat_completion.py149497%169, 312, 416, 430
semantic_kernel/connectors/ai/embeddings
   embedding_generator_base.py8188%50
semantic_kernel/connectors/ai/hugging_face/services
   hf_text_completion.py54394%95, 103, 134
   hf_text_embedding.py32584%77–81
semantic_kernel/connectors/openapi_plugin
   openapi_manager.py58297%110–111
   openapi_parser.py88199%127
   openapi_runner.py105298%181–182
semantic_kernel/connectors/openapi_plugin/models
   rest_api_operation.py129199%240
semantic_kernel/functions
   kernel_function_decorator.py98199%102
   kernel_function_from_method.py96199%153
   kernel_function_from_prompt.py154795%165–166, 180, 201, 219, 239, 322
   kernel_plugin.py187299%472, 475
semantic_kernel/planners
   plan.py2344581%52, 161–163, 195, 212–225, 262, 267, 275–276, 286–289, 306, 311, 327, 330–335, 353, 358, 361, 363, 370, 384–386, 391–395
semantic_kernel/planners/function_calling_stepwise_planner
   function_calling_stepwise_planner.py116497%143, 187–188, 196
semantic_kernel/planners/sequential_planner
   sequential_planner.py64691%69, 73, 107, 123, 132–133
   sequential_planner_extensions.py50982%29–30, 52, 106–120
   sequential_planner_parser.py771284%64–72, 91, 115–118
semantic_kernel/schema
   kernel_json_schema_builder.py119596%48, 82, 204, 208–209
semantic_kernel/template_engine/blocks
   code_block.py77199%119
   named_arg_block.py43198%98
semantic_kernel/utils/telemetry
   decorators.py113496%232, 240, 243, 252
   user_agent.py16288%18–19
TOTAL747112898% 

Python 3.10 Unit Test Overview

Tests Skipped Failures Errors Time
1940 1 💤 0 ❌ 0 🔥 33.706s ⏱️

python/poetry.lock Outdated Show resolved Hide resolved
Copy link
Member

@eavanvalkenburg eavanvalkenburg left a comment

Choose a reason for hiding this comment

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

Some work to do, the basics are there, but most important is to refactor this into a decorator that we can use with all completion services and functions!

Copy link
Member

@eavanvalkenburg eavanvalkenburg left a comment

Choose a reason for hiding this comment

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

I see both naming with diagnostics (env setting and model_diagnostics.py file) and tracing, let's make that more consistent! And we really need to create a decorator out of the code inside openai_chat_completion_base!

Copy link
Member

@eavanvalkenburg eavanvalkenburg left a comment

Choose a reason for hiding this comment

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

couple of small notes, but most importantly I don't see any tests for the actual span stuff...

python/semantic_kernel/utils/tracing/decorators.py Outdated Show resolved Hide resolved
python/semantic_kernel/utils/tracing/decorators.py Outdated Show resolved Hide resolved
python/semantic_kernel/utils/tracing/decorators.py Outdated Show resolved Hide resolved
@moonbox3
Copy link
Contributor

Related to #5891

Copy link
Member

@eavanvalkenburg eavanvalkenburg left a comment

Choose a reason for hiding this comment

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

couple of small notes, starting to look good!

python/semantic_kernel/utils/tracing/__init__.py Outdated Show resolved Hide resolved
python/semantic_kernel/utils/tracing/const.py Outdated Show resolved Hide resolved
python/semantic_kernel/utils/tracing/const.py Outdated Show resolved Hide resolved
python/semantic_kernel/utils/tracing/const.py Outdated Show resolved Hide resolved
@eavanvalkenburg
Copy link
Member

Also just noticed that there are a bunch of lines in decorators.py not covered by tests, have a look at those please, @glahaye

@glahaye
Copy link
Contributor Author

glahaye commented Jul 24, 2024

Also just noticed that there are a bunch of lines in decorators.py not covered by tests, have a look at those please, @glahaye

Oh, yes, I didn't know I needed "@pytest.mark.asyncio" for async tests.

Fixed.

@glahaye glahaye enabled auto-merge July 25, 2024 20:18
@glahaye glahaye added this pull request to the merge queue Jul 25, 2024
Merged via the queue into microsoft:main with commit ca78ff7 Jul 25, 2024
24 checks passed
@glahaye glahaye deleted the python_telemetry branch July 25, 2024 20:40
LudoCorporateShark pushed a commit to LudoCorporateShark/semantic-kernel that referenced this pull request Aug 25, 2024
### Motivation and Context
We want observability into usage of SK

### Description
Add OpenTelemetry to Python SK

### Contribution Checklist
- [ ] 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

---------

Co-authored-by: Tao Chen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
memory python Pull requests for the Python Semantic Kernel
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants