-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update cookbooks * Fix * Fix * Add * Update indexg * resolve comments * casing --------- Co-authored-by: Jack Gerrits <jack@jackgerrits.com> Co-authored-by: Jack Gerrits <jackgerrits@users.noreply.github.com>
- Loading branch information
1 parent
a72ebae
commit 0172c71
Showing
4 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
python/packages/autogen-core/docs/src/core-user-guide/cookbook/instrumenting.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Instrumentating your code locally | ||
|
||
AutoGen supports instrumenting your code using [OpenTelemetry](https://opentelemetry.io). This allows you to collect traces and logs from your code and send them to a backend of your choice. | ||
|
||
While debugging, you can use a local backend such as [Aspire](https://aspiredashboard.com/) or [Jaeger](https://www.jaegertracing.io/). In this guide we will use Aspire as an example. | ||
|
||
## Setting up Aspire | ||
|
||
Follow the instructions [here](https://learn.microsoft.com/en-us/dotnet/aspire/fundamentals/dashboard/overview?tabs=bash#standalone-mode) to set up Aspire in standalone mode. This will require Docker to be installed on your machine. | ||
|
||
## Instrumenting your code | ||
|
||
Once you have a dashboard set up, now it's a matter of sending traces and logs to it. You can follow the steps in the [Telemetry Guide](../guides/telemetry.md) to set up the opentelemetry sdk and exporter. | ||
|
||
After instrumenting your code with the Aspire Dashboard running, you should see traces and logs appear in the dashboard as your code runs. | ||
|
||
## Observing LLM calls using Open AI | ||
|
||
If you are using the Open AI package, you can observe the LLM calls by setting up the opentelemetry for that library. We use [opentelemetry-instrumentation-openai](https://pypi.org/project/opentelemetry-instrumentation-openai/) in this example. | ||
|
||
Install the package: | ||
```bash | ||
pip install opentelemetry-instrumentation-openai | ||
``` | ||
|
||
Enable the instrumentation: | ||
```python | ||
from opentelemetry.instrumentation.openai import OpenAIInstrumentor | ||
|
||
OpenAIInstrumentor().instrument() | ||
``` | ||
|
||
Now running your code will send traces including the LLM calls to your telemetry backend (Aspire in our case). | ||
|
||
![Open AI Telemetry logs](../../images/open-ai-telemetry-example.png) |
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
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
Binary file added
BIN
+516 KB
python/packages/autogen-core/docs/src/images/open-ai-telemetry-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.