Skip to content

Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.

[Feat]: Add OpenTelemetry Instrumentation for monitorng Autogen / AG2 applications (#516)

Patchera2b9530b6629
diff --git a/docs/images/docs-ag2-banner.gif b/docs/images/docs-ag2-banner.gif
new file mode 100644
index 00000000..a7d37c31
Binary files /dev/null and b/docs/images/docs-ag2-banner.gif differ
diff --git a/docs/latest/integrations/ag2.mdx b/docs/latest/integrations/ag2.mdx
new file mode 100644
index 00000000..1b2e8d94
--- /dev/null
+++ b/docs/latest/integrations/ag2.mdx
@@ -0,0 +1,75 @@
+---
+title: 'Monitor AutoGen using OpenTelemetry'
+sidebarTitle: 'AutoGen / AG2'
+---
+
+<Frame>
+ <img src="/images/docs-ag2-banner.gif" />
+</Frame>
+
+OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor AI Agents built using AutoGen. This includes tracking performance and operation stats.
+
+Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.
+
+## Get Started
+
+<Steps>
+ <Step title="Install OpenLIT">
+ Open your command line or terminal and run:
+ ```shell
+ pip install openlit
+ ```
+ </Step>
+ <Step title="Initialize OpenLIT in your Application">
+ You can set up OpenLIT in your application using either function arguments directly in your code or by using environment variables.
+ <Tabs>
+ <Tab title="Setup using function arguments">
+
+ Add the following two lines to your application code:
+
+ ```python
+ import openlit
+
+ openlit.init(
+ otlp_endpoint="YOUR_OTEL_ENDPOINT",
+ )
+ ```
+
+ Replace:
+ 1. `YOUR_OTEL_ENDPOINT` with the URL of your OpenTelemetry backend, such as `http://127.0.0.1:4318` if you are using OpenLIT and a local OTel Collector.
+ </Tab>
+ <Tab title="Setup using Environment Variables">
+
+ Add the following two lines to your application code:
+
+ ```python
+ import openlit
+
+ openlit.init()
+ ```
+
+ Then, configure the your OTLP endpoint using environment variable:
+ ```shell
+ export OTEL_EXPORTER_OTLP_ENDPOINT = "YOUR_OTEL_ENDPOINT"
+ ```
+
+ Replace:
+ 1. `YOUR_OTEL_ENDPOINT` with the URL of your OpenTelemetry backend, such as `http://127.0.0.1:4318` if you are using OpenLIT and a local OTel Collector.
+ </Tab>
+ </Tabs>
+ To send metrics and traces to other Observability tools, refer to the [Connections Guide](/latest/connections/intro).
+
+ For more advanced configurations and application use cases, visit the [OpenLIT Python repository](https://github.com/openlit/openlit/tree/main/sdk/python).
+ </Step>
+</Steps>
+
+---
+
+<CardGroup cols={2}>
+<Card title="Connections" href="/latest/connections/intro" icon='link'>
+Connect to your existing Observablity Stack
+</Card>
+<Card title="SDK configuration" href="/latest/sdk-configuration" icon='file-code'>
+Documentation of the configuration options for the OpenLIT SDK.
+</Card>
+</CardGroup>
\ No newline at end of file
diff --git a/docs/latest/integrations/introduction.mdx b/docs/latest/integrations/introduction.mdx
index ef361dbc..d8aa72c7 100644
--- a/docs/latest/integrations/introduction.mdx
+++ b/docs/latest/integrations/introduction.mdx
@@ -556,35 +556,15 @@ Start integrating and monitoring your applications with OpenLIT effortlessly. Ch
>
</Card>
<Card
- title="LlamaIndex"
- href="/latest/integrations/llama-index"
+ title="AutoGen / AG2"
+ href="/latest/integrations/ag2"
iconType="duotone"
icon={
- <svg id="LlamaIndexSquare" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1620 1620">
- <path d="M1227.57,1375.94c-3.92-4.37-7.85-8.74-11.77-13.1-27.64-30.21-41.35-65.1-30.46-111.35-104.67,33.94-205.19,41.62-308.99,17.88-2.72,31.05-3.81,59.43-8.02,87.34-5.15,34.16-13.02,67.9-19.47,101.86-2.25,11.83-4.72,23.74-5.46,35.71-2.2,35.64-1.41,71.63-6.21,106.88-2.47,18.13-14.33,34.99-21.3,50.93h-77.71l.42-.97c4.15-11.29,8.29-22.58,12.44-33.87,0,0-.21.27-.21.27,4.2-4.21,8.39-8.43,12.59-12.64l-.27.27c2.12-2.13,4.24-4.25,6.36-6.38l11.44-1.32c1.11-18.89.94-11.95,1.11-18.89.83-33.72.34-67.53-1.47-101.21-.67-12.36-6.26-24.46-9.6-36.68-2.32.06-4.64.12-6.96.18-12.39,44.7-24.78,89.41-37.17,134.11,0,0,.55-.24.55-.24-8.87,16.08-21.35,47.27-30.22,63.35-11.03,1-42.13-.92-67.88-.77,2.1-21.24,9.98-32.37,23.37-44.39,28.79-25.84,36.54-63.75,36.43-100.05-.15-50.7-6.92-101.37-10.86-152.06,5.59-10.19,8.83-23.19,17.14-30.11,56.24-46.85,102.12-102.83,144.95-161.48,41.46-56.78,83.19-113.45,122.26-171.88,43.03-64.36,87.61-128.6,97.48-208.71,72.88,7.68,142.46,25.43,207.78,60.42,19.96,10.69,45.01,11.89,67.72,17.44,8.42,6.5,20.9,11.26,24.57,19.8,18.5,43.03,36.6,86.42,51.23,130.87,17.99,54.67,22.8,110.74,13.5,168.57-11.14,69.24-41.63,128.83-80.9,185.36-6.53,9.41-8.65,21.88-12.81,32.94,0,0,.15-.18.15-.18-6.82,4.82-14.03,9.18-20.38,14.54-17.18,14.49-21.33,42.61-48.67,46.55-.37-1.49-.55-2.99-.52-4.53-1.44-2.72-2.87-5.43-4.31-8.15-9.96-18.77-19.93-37.53-29.89-56.3ZM517.28,570.6c-10.46-.44-21.29,7.69-31.95,11.86,0,0-9.76,80.82-9.76,121.49s13.91,75.15,16.27,113.41c1.68,27.25,3.01,56.38,13.57,80.73,12.68,29.21,18.19,57.44,16.61,88.5-4.38,86.3,40.37,144.69,108.96,189.16,30.85-33.52,64.34-65,91.99-100.98,55.34-72.02,102.6-149.18,128.62-237.37,5.42-18.37,8.99-37.27,14.28-59.58,2.88-2.94,8.79-8.99,14.7-15.04l-141.94-.4c-2.09-1.89-3.55-3.22-5.64-5.11l-17.96-175.16c-65.91-4.05-131.8-8.74-197.77-11.52ZM665.84,361.83c-23.76-47.96-58.65-85.02-111.51-106.14-.84,14.47-1.52,26.06-2.26,38.88-17.66-12.73-33.28-23.98-53.45-38.52,2.58,25.98,5.08,44.11,6.04,62.33,1.89,36.02-13.58,54.11-49.86,59.15-7.07.98-14.41,0-21.52.83-21.28,2.46-32.65,14.43-35.51,35.63-3.74,27.68,10.41,45.81,33.06,56.83,23.57,11.47,48.7,19.75,77.45,31.13-4.21,14.19-8.49,28.22-12.51,42.32-3.62,12.69-6.95,25.46-10.41,38.2,10.66-4.17,21.48-12.3,31.95-11.86,65.97,2.78,131.86,7.46,197.77,11.52-3.72-76.27-14.91-151.03-49.22-220.28ZM1363.96,1424.58c1.96,2.05,3.91,4.09,5.87,6.14,2.05,2.06,4.1,4.12,6.15,6.17,2.04,1.96,4.07,3.92,6.11,5.88,7.5,4.99,15,9.99,22.49,14.98,3.64-19.55,25.85-47.67,44.43-61.31,7.67-5.63,11.05-16.91,16.99-25.18,3.32-4.62,7.89-8.34,11.9-12.46-1.62-13.04-4.17-26.03-4.67-39.11-1.43-37.53.92-74.57-10.84-112.04-14.13-45-8.64-92.52-6.02-140.17,43.12-8.67,61.47-36.79,63.89-74.64,2.92-45.72-5.65-89.82-34.29-127.23-20.53-26.81-48.34-41.86-82.84-36.43-22.85,3.59-45.04,11.37-67.53,17.28,8.42,6.5,20.9,11.26,24.57,19.8,18.5,43.03,36.6,86.42,51.23,130.87,17.99,54.67,22.8,110.74,13.5,168.57-11.14,69.24-41.63,128.83-80.9,185.36-6.53,9.41-8.65,21.88-12.81,32.94,10.93,13.53,21.85,27.05,32.78,40.58ZM985.74,765.38c-6.29,81.15-44.94,149.41-87.84,215.37-37.77,58.07-75.75,116.3-118.15,170.97-30.45,39.26-68.33,72.77-102.9,108.84.47,26.74.94,53.49,1.41,80.23,5.59-10.19,8.83-23.19,17.14-30.11,56.24-46.85,102.12-102.83,144.95-161.48,41.46-56.78,83.19-113.45,122.26-171.88,43.03-64.36,87.61-128.6,97.48-208.71-24.78-1.08-49.56-2.15-74.34-3.23ZM664.54,1198.77c31.99-35.25,67.97-67.72,95.05-106.41,41.85-59.77,79.26-122.86,115.33-186.36,20.46-36.01,35.34-75.24,37.26-118.13.34-7.72,8.23-15.09,12.63-22.63-3.62.1-7.23.2-10.85.3-4.64-.95-9.28-1.91-13.91-2.86-6.49.04-12.97.07-19.46.11-5.91,6.05-11.83,12.1-14.7,15.04-5.29,22.3-8.87,41.21-14.28,59.58-26.02,88.19-73.28,165.35-128.62,237.37-27.65,35.98-61.14,67.46-91.99,100.98,11.18,7.67,22.36,15.34,33.54,23.02ZM942.72,765.23c2.4,67.42-27.68,124.69-59.91,180.03-31.13,53.43-66.12,104.74-101.63,155.44-20.89,29.83-45.84,56.84-69.42,84.74-11.1,13.13-23.27,25.36-34.96,37.99.02,12.38.03,24.75.05,37.13,34.57-36.07,72.45-69.58,102.9-108.84,42.4-54.66,80.39-112.89,118.15-170.97,42.9-65.96,81.55-134.22,87.84-215.37-14.34-.05-28.68-.1-43.03-.15ZM1405.73,1462.64c5.46,11.19,15.47,22.34,15.54,33.56.25,39.8-2.64,79.65-5.17,119.42-.22,3.52-6.45,6.66-9.89,9.98-2.3,1.72-4.61,3.44-6.91,5.16-1.99,2.12-3.98,4.24-5.97,6.35-2.17,1.91-4.35,3.81-6.52,5.72,3.41,3.84,6.65,10.81,10.25,11,20.21,1.08,40.5.52,61.67.52,17.8-43.47,23.9-85.93,17.32-130.35-1.3-8.8-3.75-19.81.05-26.59,25.92-46.24,19.03-92.21,1.8-138.62-4.01,4.12-8.58,7.84-11.9,12.46-5.94,8.27-9.32,19.55-16.99,25.18-18.58,13.64-40.79,41.76-44.43,61.31.29,1.65.67,3.28,1.15,4.89ZM924.82,765.23c-4.4,7.53-12.29,14.91-12.63,22.63-1.92,42.89-16.8,82.12-37.26,118.13-36.08,63.51-73.48,126.6-115.33,186.36-27.09,38.69-63.06,71.15-95.05,106.41,4.09,8.22,8.17,16.44,12.26,24.66,11.69-12.64,23.86-24.86,34.96-37.99,23.58-27.89,48.53-54.91,69.42-84.74,35.5-50.7,70.5-102.01,101.63-155.44,32.23-55.34,62.31-112.61,59.91-180.03-5.97,0-11.93,0-17.9,0ZM900.05,762.67c4.64.95,9.28,1.91,13.91,2.86-4.64-.95-9.28-1.91-13.91-2.86ZM733.27,759.83c1.79.85,3.59,1.7,5.38,2.55-1.6-1.25-3.4-2.1-5.38-2.55ZM479.39,702.93c1.24,2.91-1.24,5.83,0,8.74-1.24-2.91,1.24-5.83,0-8.74ZM1215.35,1588.66c-8.44,5.86-16.88,11.72-25.32,17.58-1.64,9.45-3.28,18.9-5,28.8h72.24c0-14.59-.97-27.72.34-40.61.87-8.56,2.71-18.87,8.08-24.82,47.78-52.98,66.64-115.78,65.65-185.78-6.82,4.82-14.03,9.18-20.38,14.54-17.18,14.49-21.33,42.61-48.67,46.55.78,53.28-15.32,101.04-46.93,143.74ZM1257.46,1432.24c1.44,2.72,2.87,5.43,4.31,8.15-1.44-2.72-2.87-5.43-4.31-8.15Z"/>
- </svg>
- }
- >
- </Card>
- <Card
- title="DSPy"
- href="/latest/integrations/dspy"
- iconType="duotone"
- icon={
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 162 162">
- <path d="M0 0 C1.02060516 -0.00426498 2.04121033 -0.00852997 3.09274292 -0.01292419 C4.2169162 -0.01247101 5.34108948 -0.01201782 6.49932861 -0.0115509 C8.27021347 -0.01658882 8.27021347 -0.01658882 10.07687378 -0.02172852 C13.32086638 -0.02961703 16.56482062 -0.03290711 19.80882168 -0.0335443 C22.5173671 -0.03449325 25.22590637 -0.0381716 27.93444943 -0.0417164 C34.32749826 -0.04986562 40.720533 -0.05230031 47.11358643 -0.05158997 C53.703911 -0.05098987 60.29415353 -0.06152687 66.88445735 -0.07733363 C72.54399651 -0.09042329 78.20350892 -0.09577322 83.8630631 -0.09513456 C87.2424452 -0.09487987 90.62175451 -0.09771426 94.00112152 -0.10831261 C97.77403063 -0.11810231 101.54672865 -0.11523805 105.31964111 -0.10920715 C106.99375565 -0.11763641 106.99375565 -0.11763641 108.70169067 -0.12623596 C118.52353902 -0.08631131 118.52353902 -0.08631131 123.16827393 2.13371277 C124.32498934 4.44714359 124.29399338 5.76118266 124.29525757 8.3354187 C124.29807739 9.21680511 124.30089722 10.09819153 124.30380249 11.00628662 C124.30076614 12.46094582 124.30076614 12.46094582 124.29766846 13.94499207 C124.30029694 15.47473663 124.30029694 15.47473663 124.30297852 17.03538513 C124.30739886 20.42625098 124.30445557 23.81706508 124.30108643 27.20793152 C124.30176009 29.56810516 124.30273064 31.92827874 124.3039856 34.28845215 C124.30546336 39.25095781 124.30330798 44.21344552 124.29864502 49.1759491 C124.29298812 55.50136871 124.29620037 61.82674551 124.30221748 68.15216351 C124.30585568 73.03643101 124.30466894 77.92068861 124.30208969 82.80495644 C124.30142729 85.13428058 124.30222456 87.46360564 124.30456924 89.7929287 C124.32751431 119.03486684 124.32751431 119.03486684 123.16827393 126.13371277 C120.01624093 127.70972927 116.61017622 127.52216201 113.14093018 127.68840027 C112.27210709 127.73044586 111.403284 127.77249146 110.50813293 127.81581116 C97.71041823 128.35946011 84.89663464 128.28374907 72.08990479 128.26408386 C68.37488034 128.25842364 64.65992814 128.26175453 60.94490623 128.2675209 C-2.39713386 128.35100888 -2.39713386 128.35100888 -8.83172607 125.13371277 C-11.05033445 112.80538804 -9.90036592 99.44051981 -9.78094482 86.97355652 C-9.76167757 84.65141978 -9.74262299 82.32928126 -9.72377014 80.00714111 C-9.68302508 75.16850939 -9.63782802 70.32994327 -9.58978271 65.49137878 C-9.52884776 59.29094065 -9.48209035 53.09048342 -9.43895245 46.88989925 C-9.40363211 42.10721864 -9.35939817 37.32465123 -9.31260109 32.54207039 C-9.2915737 30.25474742 -9.27366606 27.96739355 -9.25894737 25.68002129 C-9.23739799 22.49245926 -9.20349466 19.30525798 -9.16644287 16.11784363 C-9.16271164 15.17598709 -9.15898041 14.23413055 -9.15513611 13.26373291 C-9.03543154 5.00287464 -9.03543154 5.00287464 -6.83172607 1.13371277 C-4.36883671 -0.09773192 -2.75485479 0.00518712 0 0 Z M-1.83172607 7.13371277 C-1.83172607 23.96371277 -1.83172607 40.79371277 -1.83172607 58.13371277 C4.43827393 58.79371277 10.70827393 59.45371277 17.16827393 60.13371277 C17.82827393 60.46371277 18.48827393 60.79371277 19.16827393 61.13371277 C19.08448486 61.90457214 19.0006958 62.67543152 18.91436768 63.46965027 C18.81253174 64.47254089 18.7106958 65.47543152 18.60577393 66.50871277 C18.50135986 67.50644714 18.3969458 68.50418152 18.28936768 69.53215027 C17.95682685 72.11774977 17.95682685 72.11774977 19.16827393 74.13371277 C25.42065705 75.40577891 25.42065705 75.40577891 31.16827393 73.13371277 C31.15667236 72.27906433 31.1450708 71.42441589 31.13311768 70.54386902 C31.12409424 69.43914246 31.1150708 68.33441589 31.10577393 67.19621277 C31.09417236 66.09406433 31.0825708 64.99191589 31.07061768 63.85636902 C31.16827393 61.13371277 31.16827393 61.13371277 32.16827393 60.13371277 C39.19784569 59.69994609 46.19258755 60.28634089 53.16827393 61.13371277 C53.67094187 59.00934229 54.17033003 56.88419551 54.66827393 54.75871277 C54.94671143 53.57535339 55.22514893 52.39199402 55.51202393 51.17277527 C56.23863168 48.32607435 56.23863168 48.32607435 56.16827393 46.13371277 C55.55339111 46.02414246 54.9385083 45.91457214 54.30499268 45.80168152 C53.09262939 45.56384949 53.09262939 45.56384949 51.85577393 45.32121277 C51.05526611 45.17039246 50.2547583 45.01957214 49.42999268 44.86418152 C46.87788119 44.03992444 45.81510605 43.22645636 44.16827393 41.13371277 C42.34066637 35.6508901 42.41720753 29.58719633 44.10577393 24.07121277 C47.29045294 21.0795446 51.79949282 20.13371277 56.16827393 20.13371277 C56.16827393 15.84371277 56.16827393 11.55371277 56.16827393 7.13371277 C37.02827393 7.13371277 17.88827393 7.13371277 -1.83172607 7.13371277 Z M64.16827393 7.13371277 C64.03550049 8.33769714 63.90272705 9.54168152 63.76593018 10.78215027 C63.58774373 12.35769362 63.40934743 13.93321324 63.23077393 15.50871277 C63.10025635 16.69980652 63.10025635 16.69980652 62.96710205 17.91496277 C62.28155518 23.90715027 62.28155518 23.90715027 61.16827393 26.13371277 C58.6141618 26.44903525 56.08744565 26.51324978 53.51593018 26.59465027 C51.03381017 26.89272203 51.03381017 26.89272203 49.84014893 28.97746277 C48.89321267 32.0164675 49.31054386 34.09866792 50.16827393 37.13371277 C53.27193121 39.20281762 53.81632797 39.3565885 57.29327393 39.19621277 C58.57202393 39.17558777 59.85077393 39.15496277 61.16827393 39.13371277 C62.16827393 40.13371277 62.16827393 40.13371277 62.35577393 43.88371277 C62.30594871 50.05207476 61.218013 56.06959508 60.16827393 62.13371277 C63.8426579 62.81001243 67.30747862 63.25281573 71.04327393 63.19621277 C71.8244458 63.18718933 72.60561768 63.17816589 73.41046143 63.16886902 C73.99053955 63.15726746 74.57061768 63.14566589 75.16827393 63.13371277 C75.18954346 62.12050964 75.18954346 62.12050964 75.21124268 61.08683777 C75.60298975 53.76010875 75.60298975 53.76010875 78.48077393 50.57121277 C84.04828289 47.59324286 89.88056737 47.25699102 95.98077393 48.88371277 C98.64784577 50.40775382 99.73009463 51.40117212 101.16827393 54.13371277 C101.69706233 56.81359184 101.94064684 59.40218779 102.16827393 62.13371277 C103.73067425 62.16101685 105.29321663 62.18024503 106.85577393 62.19621277 C107.72589111 62.20781433 108.5960083 62.21941589 109.49249268 62.23136902 C112.15946811 62.13403415 114.56299048 61.68530758 117.16827393 61.13371277 C117.1935404 53.60401625 117.21110534 46.07433057 117.22320557 38.54460144 C117.22824763 35.9807952 117.23508107 33.41699185 117.24371338 30.85319519 C117.25578457 27.17716256 117.26150335 23.50116779 117.26593018 19.82511902 C117.27109146 18.67097 117.27625275 17.51682098 117.28157043 16.32769775 C117.28168373 14.73616127 117.28168373 14.73616127 117.28179932 13.11247253 C117.28401993 12.17315384 117.28624054 11.23383514 117.28852844 10.26605225 C117.40670037 8.15008236 117.40670037 8.15008236 116.16827393 7.13371277 C114.54152615 7.04030843 112.91073341 7.01626106 111.28131104 7.02018738 C109.71980568 7.02030067 109.71980568 7.02030067 108.12675476 7.02041626 C106.4283419 7.02815819 106.4283419 7.02815819 104.69561768 7.03605652 C103.54283829 7.03747147 102.3900589 7.03888641 101.2023468 7.04034424 C97.50346329 7.04596272 93.80463929 7.05851835 90.10577393 7.07121277 C87.60512376 7.07622539 85.10447264 7.08078871 82.6038208 7.08488464 C76.45861804 7.09593815 70.31345023 7.11269425 64.16827393 7.13371277 Z M82.16827393 56.13371277 C82.16827393 60.42371277 82.16827393 64.71371277 82.16827393 69.13371277 C74.57827393 69.13371277 66.98827393 69.13371277 59.16827393 69.13371277 C59.16827393 73.42371277 59.16827393 77.71371277 59.16827393 82.13371277 C60.52952393 82.07183777 61.89077393 82.00996277 63.29327393 81.94621277 C67.62165256 81.93938567 70.47733767 82.73460421 74.16827393 85.13371277 C75.66182122 88.12080736 75.47458621 91.17105757 75.54327393 94.44621277 C75.5922583 95.76234558 75.64124268 97.07847839 75.69171143 98.43449402 C75.16827393 102.13371277 75.16827393 102.13371277 73.00811768 105.09465027 C69.74818465 107.43534496 68.30423231 107.68407171 64.35577393 107.44621277 C63.37995361 107.40109558 62.4041333 107.35597839 61.39874268 107.30949402 C60.29466064 107.2224823 60.29466064 107.2224823 59.16827393 107.13371277 C59.14131027 108.92529766 59.12189476 110.7169975 59.10577393 112.50871277 C59.09417236 113.50644714 59.0825708 114.50418152 59.07061768 115.53215027 C58.98820791 118.1180373 58.98820791 118.1180373 60.16827393 120.13371277 C78.3240336 122.86351493 97.93783624 121.63504293 116.16827393 120.13371277 C116.96211078 113.38618388 117.30635479 106.76090695 117.26593018 99.96965027 C117.26380775 98.59252365 117.26380775 98.59252365 117.26164246 97.18757629 C117.25610612 94.29458669 117.24356612 91.40167844 117.23077393 88.50871277 C117.22575068 86.53084931 117.22118923 84.55298463 117.21710205 82.57511902 C117.20701434 77.76126142 117.18742723 72.94757668 117.16827393 68.13371277 C109.57827393 68.46371277 101.98827393 68.79371277 94.16827393 69.13371277 C94.46124268 66.07381694 94.75421143 63.0139211 95.04718018 59.95402527 C95.39466797 57.18219254 95.39466797 57.18219254 94.16827393 55.13371277 C92.54336439 55.10673088 90.91832759 55.0873252 89.29327393 55.07121277 C88.38835205 55.05961121 87.48343018 55.04800964 86.55108643 55.03605652 C84.15141543 54.97122019 84.15141543 54.97122019 82.16827393 56.13371277 Z M-1.83172607 66.13371277 C-1.83172607 83.62371277 -1.83172607 101.11371277 -1.83172607 119.13371277 C4.21026503 119.80504511 10.06327657 120.32783286 16.11358643 120.48527527 C16.92769989 120.50842804 17.74181335 120.53158081 18.58059692 120.55543518 C20.28636514 120.60266932 21.99218859 120.64794665 23.69805908 120.69132996 C26.29385206 120.75872778 28.88919981 120.83653466 31.48468018 120.91496277 C33.15263205 120.95986508 34.82060049 121.00415684 36.48858643 121.04777527 C37.25542755 121.07167328 38.02226868 121.09557129 38.81234741 121.12019348 C39.54355804 121.13706207 40.27476868 121.15393066 41.02813721 121.17131042 C41.660513 121.18827972 42.29288879 121.20524902 42.94442749 121.22273254 C46.03792065 121.09890112 49.10341937 120.57154913 52.16827393 120.13371277 C52.49827393 113.53371277 52.82827393 106.93371277 53.16827393 100.13371277 C56.74900309 100.4592336 60.32973226 100.78475444 63.91046143 101.11027527 C64.98553955 101.11800964 66.06061768 101.12574402 67.16827393 101.13371277 C69.33339716 99.37896215 69.33339716 99.37896215 69.39874268 97.25871277 C69.38456299 96.55746277 69.3703833 95.85621277 69.35577393 95.13371277 C69.34932861 94.43246277 69.3428833 93.73121277 69.33624268 93.00871277 C69.27533525 91.04314904 69.27533525 91.04314904 68.16827393 89.13371277 C63.38348571 89.03606403 58.89141706 89.36258736 54.16827393 90.13371277 C52.99357948 87.78432388 52.96792504 86.18298072 52.85186768 83.56340027 C52.80997314 82.66750183 52.76807861 81.77160339 52.72491455 80.84855652 C52.68559814 79.91140808 52.64628174 78.97425964 52.60577393 78.00871277 C52.56259033 77.06382996 52.51940674 76.11894714 52.47491455 75.14543152 C52.36868453 72.80837104 52.26796121 70.47106146 52.16827393 68.13371277 C47.54827393 67.47371277 42.92827393 66.81371277 38.16827393 66.13371277 C38.08577393 67.70121277 38.00327393 69.26871277 37.91827393 70.88371277 C37.57340203 74.36691891 37.39580017 75.82276024 35.29327393 78.69621277 C30.39709927 82.00833092 24.86231643 81.60891105 19.16827393 81.13371277 C15.42797208 79.53072626 14.43668927 78.53633579 12.16827393 75.13371277 C11.90719512 72.11042021 12.08012211 69.17495035 12.16827393 66.13371277 C7.54827393 66.13371277 2.92827393 66.13371277 -1.83172607 66.13371277 Z " fill="#EF4036" transform="translate(9.83172607421875,0.8662872314453125)"/>
- </svg>
- }
- >
- </Card>
- <Card
- title="Haystack"
- href="/latest/integrations/haystack"
- iconType="duotone"
- icon={
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 172 172">
- <path d="M0 0 C0.85369675 -0.0071553 1.70739349 -0.01431061 2.58695984 -0.02168274 C3.52052307 -0.02437164 4.4540863 -0.02706055 5.41593933 -0.02983093 C6.40160385 -0.03640213 7.38726837 -0.04297333 8.40280151 -0.04974365 C11.66914443 -0.0694768 14.93544139 -0.08113868 18.201828 -0.09111023 C19.87444985 -0.09722352 19.87444985 -0.09722352 21.58086205 -0.10346031 C27.48161509 -0.12432006 33.38234488 -0.13862281 39.28312683 -0.147995 C45.37974874 -0.15906554 51.47600627 -0.1934735 57.57249928 -0.23316669 C62.25910118 -0.25930038 66.94561579 -0.26768391 71.63228416 -0.27127647 C73.87975719 -0.27614998 76.12722613 -0.2877856 78.37462807 -0.30631447 C81.52020363 -0.33063851 84.66482993 -0.32975302 87.81047058 -0.32279968 C88.73796112 -0.33560974 89.66545166 -0.3484198 90.62104797 -0.36161804 C96.15238475 -0.31706859 99.50125664 0.3226312 103.80729675 4.14717102 C105.8682373 7.38111996 106.06190316 9.96075955 106.07472229 13.75762939 C106.08325226 14.9002272 106.09178223 16.04282501 106.10057068 17.220047 C106.09966431 18.46951111 106.09875793 19.71897522 106.0978241 21.00630188 C106.10454132 22.32534012 106.11125854 23.64437836 106.11817932 25.00338745 C106.13583849 28.61909204 106.14053461 32.23470196 106.14181089 35.85044551 C106.14323291 38.10988712 106.14750343 40.36930468 106.15280533 42.62874031 C106.17130416 50.51242221 106.17947598 58.3960365 106.17790222 66.27973938 C106.17670032 73.62683952 106.19781239 80.97364613 106.22938955 88.32067198 C106.25554299 94.63077136 106.26626994 100.94077481 106.2649914 107.25092798 C106.26448156 111.01876908 106.27017689 114.7863492 106.2913475 118.55413628 C106.31071492 122.09765824 106.3108652 125.64066983 106.29631424 129.18420982 C106.29322708 131.10242051 106.30991246 133.02063116 106.32719421 134.93876648 C106.31880524 136.08418411 106.31041626 137.22960175 106.30177307 138.409729 C106.30286261 139.40283553 106.30395214 140.39594206 106.30507469 141.41914272 C105.65918611 144.95887838 104.30608279 146.59510689 101.80729675 149.14717102 C98.98311617 150.99563202 96.80820199 151.40140558 93.46310425 151.42805481 C92.60106384 151.4394751 91.73902344 151.45089539 90.8508606 151.46266174 C89.44423912 151.46601532 89.44423912 151.46601532 88.00920105 151.46943665 C86.51826431 151.48433136 86.51826431 151.48433136 84.99720764 151.49952698 C81.70861543 151.52873962 78.42021615 151.54236865 75.1315155 151.55342102 C72.84471634 151.56492625 70.55791723 151.57644169 68.27111816 151.58796692 C63.47530723 151.60897802 58.67956326 151.62066921 53.88371277 151.62763977 C47.74327507 151.63860919 41.60372439 151.68666604 35.46356487 151.74358368 C30.73916043 151.780861 26.01496916 151.79124887 21.29043007 151.79431152 C19.02701275 151.80035996 16.76359898 151.81640177 14.50032616 151.84268188 C11.33072605 151.8768594 8.16328652 151.87303197 4.99357605 151.86006165 C4.06190109 151.87849121 3.13022614 151.89692078 2.1703186 151.91590881 C-3.61072638 151.84193862 -6.69669801 150.71658166 -10.92190838 146.72757721 C-13.41823999 143.62304946 -13.32147233 140.58321397 -13.33314514 136.77085876 C-13.33885529 135.65487808 -13.34456543 134.5388974 -13.35044861 133.38909912 C-13.35156647 132.16409195 -13.35268433 130.93908478 -13.35383606 129.67695618 C-13.35880096 128.38732468 -13.36376587 127.09769318 -13.36888123 125.76898193 C-13.38199725 122.22968105 -13.38844851 118.69039913 -13.39289188 115.15107775 C-13.39582362 112.93972424 -13.3999286 110.7283759 -13.40439606 108.51702499 C-13.41806828 101.59774888 -13.42773654 94.67848461 -13.43159795 87.75919592 C-13.43607956 79.77256996 -13.45363329 71.78611506 -13.48259854 63.79954112 C-13.5042134 57.62535235 -13.5143021 51.45121173 -13.51563907 45.27698553 C-13.51668715 41.5896512 -13.52259561 37.90247774 -13.54045868 34.21518326 C-13.5599973 30.1020748 -13.55565121 25.98932463 -13.54914856 21.87617493 C-13.55836334 20.65521622 -13.56757812 19.43425751 -13.57707214 18.17630005 C-13.57150299 17.05467972 -13.56593384 15.93305939 -13.56019592 14.77745056 C-13.56166248 13.80516825 -13.56312904 12.83288593 -13.56464005 11.83114052 C-12.95267206 7.41505849 -10.59231074 3.98017726 -7.19270325 1.14717102 C-4.45214497 0.23365159 -2.82279632 0.01626586 0 0 Z " fill="#04AF9D" transform="translate(49.19270324707031,25.852828979492188)"/>
- <path d="M0 0 C8.56257142 6.21206161 15.13410994 13.32451308 17 24 C17.27297659 28.82135157 17.23319759 33.63785146 17.1953125 38.46484375 C17.19157708 39.8673126 17.18873261 41.26978407 17.18673706 42.67225647 C17.17914221 46.34326527 17.15952998 50.01411295 17.1373291 53.68505859 C17.11678072 57.43910544 17.10771621 61.19317861 17.09765625 64.94726562 C17.07627965 72.29825011 17.04219457 79.64910238 17 87 C10.40625 87.265625 10.40625 87.265625 6.75 84.875 C0.66509373 78.51350708 0.58023841 72.90171474 0.62890625 64.50390625 C0.61152626 62.23111827 0.59394185 59.95833184 0.57617188 57.68554688 C0.56609811 54.1196813 0.5625041 50.55391633 0.56420898 46.98803711 C0.56063335 43.53469117 0.53327222 40.08211489 0.50390625 36.62890625 C0.51208878 35.56829483 0.5202713 34.50768341 0.52870178 33.41493225 C0.46495418 27.05536485 -0.1974533 23.16470457 -4 18 C-9.6759731 13.43454338 -15.44960295 11.44621744 -22.69140625 11.6171875 C-28.0049639 12.49828505 -31.80318766 15.70870248 -35.375 19.5625 C-38.1056093 23.65841395 -39.24839494 26.45184831 -39.4140625 31.421875 C-39.45273438 32.44667969 -39.49140625 33.47148438 -39.53125 34.52734375 C-39.57765625 36.12255859 -39.57765625 36.12255859 -39.625 37.75 C-39.66367188 38.82894531 -39.70234375 39.90789062 -39.7421875 41.01953125 C-39.83634248 43.67940932 -39.9192555 46.33968106 -40 49 C-35.71 49 -31.42 49 -27 49 C-27.04640625 47.74703125 -27.0928125 46.4940625 -27.140625 45.203125 C-27.17814813 43.55210719 -27.21454771 41.90106358 -27.25 40.25 C-27.28351563 39.425 -27.31703125 38.6 -27.3515625 37.75 C-27.45017991 31.63572044 -27.45017991 31.63572044 -25.19921875 28.45703125 C-21.9286803 26.29022691 -19.83483007 26.39450051 -16 27 C-12.7596102 29.5528916 -11.18636005 31.03812658 -10.39199829 35.13812256 C-10.40008514 36.3142511 -10.408172 37.49037964 -10.41650391 38.70214844 C-10.41416748 39.35476151 -10.41183105 40.00737457 -10.40942383 40.67976379 C-10.40781664 42.82379799 -10.44174967 44.96564853 -10.4765625 47.109375 C-10.48335483 48.60198185 -10.48807528 50.09459945 -10.49081421 51.58721924 C-10.50147242 54.70771633 -10.52812352 57.82749335 -10.56787109 60.94775391 C-10.6189141 64.95514049 -10.64391245 68.96211483 -10.65880775 72.96978378 C-10.67356324 76.78720505 -10.69880067 80.60452873 -10.7265625 84.421875 C-10.73392866 85.51933674 -10.73392866 85.51933674 -10.74144363 86.63896942 C-10.75765164 88.69789902 -10.78105095 90.75660427 -10.80712891 92.81542969 C-10.81998932 93.98837585 -10.83284973 95.16132202 -10.84609985 96.36981201 C-11 99 -11 99 -12 100 C-15.11063879 100.5184398 -17.17900563 100.5229155 -19.8828125 98.80078125 C-23.90413728 95.46089435 -26.67345258 92.72139517 -27.31884766 87.34277344 C-27.365979 85.86599121 -27.365979 85.86599121 -27.4140625 84.359375 C-27.45273438 83.28945312 -27.49140625 82.21953125 -27.53125 81.1171875 C-27.5621875 80.00601563 -27.593125 78.89484375 -27.625 77.75 C-27.66367188 76.62335938 -27.70234375 75.49671875 -27.7421875 74.3359375 C-27.83636983 71.55755891 -27.91927028 68.77880201 -28 66 C-31.63 66 -35.26 66 -39 66 C-39.02578125 66.79664062 -39.0515625 67.59328125 -39.078125 68.4140625 C-39.6679908 79.43382814 -39.6679908 79.43382814 -44 84 C-48.20403055 86.74175905 -51.06972187 87.12360029 -56 87 C-56.0931181 78.95858673 -56.16397484 70.91740273 -56.20724869 62.87558174 C-56.22802924 59.1404921 -56.25616923 55.4057742 -56.30175781 51.67089844 C-56.34556031 48.05930865 -56.36920859 44.448074 -56.37950897 40.83623886 C-56.38683928 39.46565036 -56.40115198 38.09507894 -56.42292023 36.72464371 C-56.607692 24.59815217 -54.42933664 15.03009114 -46 6 C-32.53468903 -6.63826692 -16.50134604 -8.5562535 0 0 Z " fill="#F8FCFC" transform="translate(115,54)"/>
+ <svg viewBox="0 0 1024 1024" fill="none" xmlns="http://www.w3.org/2000/svg">
+ <path d="M44.522 44.5217H489.739V489.739H44.522V44.5217Z" fill="#F35325"/>
+ <path d="M534.261 44.5217H979.478V489.739H534.261V44.5217Z" fill="#81BC06"/>
+ <path d="M44.522 534.261H489.739V979.478H44.522V534.261Z" fill="#05A6F0"/>
+ <path d="M534.261 534.261H979.478V979.478H534.261V534.261Z" fill="#FFBA08"/>
</svg>
}
>
diff --git a/docs/mint.json b/docs/mint.json
index 4ac0edad..c993da9e 100644
--- a/docs/mint.json
+++ b/docs/mint.json
@@ -123,6 +123,7 @@
"latest/integrations/crewai",
"latest/integrations/llama-index",
"latest/integrations/dspy",
+ "latest/integrations/ag2",
"latest/integrations/haystack",
"latest/integrations/embedchain",
"latest/integrations/guardrails"
diff --git a/sdk/python/README.md b/sdk/python/README.md
index bd25df1d..f4e850be 100644
--- a/sdk/python/README.md
+++ b/sdk/python/README.md
@@ -35,14 +35,14 @@ This project proudly follows and maintains the [Semantic Conventions](https://gi
| LLMs | Vector DBs | Frameworks | GPUs |
|--------------------------------------------------------------------------|----------------------------------------------|-------------------------------------------------|---------------|
| [✅ OpenAI](https://docs.openlit.io/latest/integrations/openai) | [✅ ChromaDB](https://docs.openlit.io/latest/integrations/chromadb) | [✅ Langchain](https://docs.openlit.io/latest/integrations/langchain) | [✅ NVIDIA](https://docs.openlit.io/latest/integrations/nvidia-gpu) |
-| [✅ Ollama](https://docs.openlit.io/latest/integrations/ollama) | [✅ Pinecone](https://docs.openlit.io/latest/integrations/pinecone) | [✅ LiteLLM](https://docs.openlit.io/latest/integrations/litellm) | [✅ AMD](#) |
+| [✅ Ollama](https://docs.openlit.io/latest/integrations/ollama) | [✅ Pinecone](https://docs.openlit.io/latest/integrations/pinecone) | [✅ LiteLLM](https://docs.openlit.io/latest/integrations/litellm) | [✅ AMD](https://docs.openlit.io/latest/integrations/amd-gpu) |
| [✅ Anthropic](https://docs.openlit.io/latest/integrations/anthropic) | [✅ Qdrant](https://docs.openlit.io/latest/integrations/qdrant) | [✅ LlamaIndex](https://docs.openlit.io/latest/integrations/llama-index) | |
| [✅ GPT4All](https://docs.openlit.io/latest/integrations/gpt4all) | [✅ Milvus](https://docs.openlit.io/latest/integrations/milvus) | [✅ Haystack](https://docs.openlit.io/latest/integrations/haystack) | |
| [✅ Cohere](https://docs.openlit.io/latest/integrations/cohere) | | [✅ EmbedChain](https://docs.openlit.io/latest/integrations/embedchain) | |
| [✅ Mistral](https://docs.openlit.io/latest/integrations/mistral) | | [✅ Guardrails](https://docs.openlit.io/latest/integrations/guardrails) | |
| [✅ Azure OpenAI](https://docs.openlit.io/latest/integrations/azure-openai) | | [✅ CrewAI](https://docs.openlit.io/latest/integrations/crewai) | |
-| [✅ Azure AI Inference](https://docs.openlit.io/latest/integrations/azure-ai-inference) | | [✅ DSPy](https://docs.openlit.io/latest/integrations/dspy) | |
-| [✅ GitHub AI Models](https://docs.openlit.io/latest/integrations/github-models) | | | |
+| [✅ Azure AI Inference](https://docs.openlit.io/latest/integrations/azure-ai-inference) | | [✅ DSPy](https://docs.openlit.io/latest/integrations/dspy) | |
+| [✅ GitHub AI Models](https://docs.openlit.io/latest/integrations/github-models) | | [✅ AG2](https://docs.openlit.io/latest/integrations/ag2) | |
| [✅ HuggingFace Transformers](https://docs.openlit.io/latest/integrations/huggingface) | | | |
| [✅ Amazon Bedrock](https://docs.openlit.io/latest/integrations/bedrock) | | | |
| [✅ Vertex AI](https://docs.openlit.io/latest/integrations/vertexai) | | | |
@@ -53,7 +53,6 @@ This project proudly follows and maintains the [Semantic Conventions](https://gi
| [✅ Google AI Studio](https://docs.openlit.io/latest/integrations/google-ai-studio) | | | |
| [✅ NVIDIA NIM](https://docs.openlit.io/latest/integrations/nvidia-nim) | | | |
-
## Supported Destinations
- [✅ OpenTelemetry Collector](https://docs.openlit.io/latest/connections/otelcol)
- [✅ Prometheus + Tempo](https://docs.openlit.io/latest/connections/prometheus-tempo)
@@ -61,6 +60,7 @@ This project proudly follows and maintains the [Semantic Conventions](https://gi
- [✅ Grafana Cloud](https://docs.openlit.io/latest/connections/grafanacloud)
- [✅ New Relic](https://docs.openlit.io/latest/connections/new-relic)
- [✅ Elastic](https://docs.openlit.io/latest/connections/elastic)
+- [✅ Middleware.io](https://docs.openlit.io/latest/connections/middleware)
- [✅ HyperDX](https://docs.openlit.io/latest/connections/hyperdx)
- [✅ DataDog](https://docs.openlit.io/latest/connections/datadog)
- [✅ SigNoz](https://docs.openlit.io/latest/connections/signoz)
diff --git a/sdk/python/pyproject.toml b/sdk/python/pyproject.toml
index 0aea613e..8d74db8f 100644
--- a/sdk/python/pyproject.toml
+++ b/sdk/python/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "openlit"
-version = "1.30.5"
+version = "1.31.0"
description = "OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications and GPUs, facilitating the integration of observability into your GenAI-driven projects"
authors = ["OpenLIT"]
repository = "https://github.com/openlit/openlit/tree/main/openlit/python"
diff --git a/sdk/python/src/openlit/__init__.py b/sdk/python/src/openlit/__init__.py
index 427984cb..0f9c67f3 100644
--- a/sdk/python/src/openlit/__init__.py
+++ b/sdk/python/src/openlit/__init__.py
@@ -48,6 +48,7 @@ from openlit.instrumentation.milvus import MilvusInstrumentor
from openlit.instrumentation.transformers import TransformersInstrumentor
from openlit.instrumentation.litellm import LiteLLMInstrumentor
from openlit.instrumentation.crewai import CrewAIInstrumentor
+from openlit.instrumentation.ag2 import AG2Instrumentor
from openlit.instrumentation.gpu import GPUInstrumentor
import openlit.guard
import openlit.evals
@@ -232,6 +233,9 @@ def init(environment="default", application_name="default", tracer=None, otlp_en
"transformers": "transformers",
"litellm": "litellm",
"crewai": "crewai",
+ "ag2": "ag2",
+ "autogen": "autogen",
+ "pyautogen": "pyautogen",
}
invalid_instrumentors = [
@@ -311,6 +315,9 @@ def init(environment="default", application_name="default", tracer=None, otlp_en
"transformers": TransformersInstrumentor(),
"litellm": LiteLLMInstrumentor(),
"crewai": CrewAIInstrumentor(),
+ "ag2": AG2Instrumentor(),
+ "autogen": AG2Instrumentor(),
+ "pyautogen": AG2Instrumentor(),
}
# Initialize and instrument only the enabled instrumentors
diff --git a/sdk/python/src/openlit/instrumentation/ag2/__init__.py b/sdk/python/src/openlit/instrumentation/ag2/__init__.py
new file mode 100644
index 00000000..b952f804
--- /dev/null
+++ b/sdk/python/src/openlit/instrumentation/ag2/__init__.py
@@ -0,0 +1,50 @@
+# pylint: disable=useless-return, bad-staticmethod-argument, disable=duplicate-code
+"""Initializer of Auto Instrumentation of AG2 Functions"""
+
+from typing import Collection
+import importlib.metadata
+from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
+from wrapt import wrap_function_wrapper
+
+from openlit.instrumentation.ag2.ag2 import (
+ wrap_ag2
+)
+
+_instruments = ("ag2 >= 0.3.2",)
+
+class AG2Instrumentor(BaseInstrumentor):
+ """
+ An instrumentor for AG2's client library.
+ """
+
+ def instrumentation_dependencies(self) -> Collection[str]:
+ return _instruments
+
+ def _instrument(self, **kwargs):
+ application_name = kwargs.get("application_name", "default_application")
+ environment = kwargs.get("environment", "default_environment")
+ tracer = kwargs.get("tracer")
+ metrics = kwargs.get("metrics_dict")
+ pricing_info = kwargs.get("pricing_info", {})
+ trace_content = kwargs.get("trace_content", False)
+ disable_metrics = kwargs.get("disable_metrics")
+ version = importlib.metadata.version("ag2")
+
+ wrap_function_wrapper(
+ "autogen.agentchat.conversable_agent",
+ "ConversableAgent.initiate_chat",
+ wrap_ag2("ag2.initiate_chat", version, environment, application_name,
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
+ )
+
+ wrap_function_wrapper(
+ "autogen.agentchat.conversable_agent",
+ "ConversableAgent.generate_reply",
+ wrap_ag2("ag2.generate_reply", version, environment, application_name,
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
+ )
+
+
+ def _uninstrument(self, **kwargs):
+ # Proper uninstrumentation logic to revert patched methods
+ pass
diff --git a/sdk/python/src/openlit/instrumentation/ag2/ag2.py b/sdk/python/src/openlit/instrumentation/ag2/ag2.py
new file mode 100644
index 00000000..28d638c2
--- /dev/null
+++ b/sdk/python/src/openlit/instrumentation/ag2/ag2.py
@@ -0,0 +1,98 @@
+# pylint: disable=duplicate-code, broad-exception-caught, too-many-statements, unused-argument
+"""
+Module for monitoring AG2.
+"""
+
+import logging
+from opentelemetry.trace import SpanKind, Status, StatusCode
+from opentelemetry.sdk.resources import TELEMETRY_SDK_NAME
+from openlit.__helpers import handle_exception
+from openlit.semcov import SemanticConvetion
+
+# Initialize logger for logging potential issues and operations
+logger = logging.getLogger(__name__)
+
+def wrap_ag2(gen_ai_endpoint, version, environment, application_name,
+ tracer, pricing_info, trace_content, metrics, disable_metrics):
+ """
+ Creates a wrapper around a function call to trace and log its execution metrics.
+
+ This function wraps any given function to measure its execution time,
+ log its operation, and trace its execution using OpenTelemetry.
+
+ Parameters:
+ - gen_ai_endpoint (str): A descriptor or name for the endpoint being traced.
+ - version (str): The version of the Langchain application.
+ - environment (str): The deployment environment (e.g., 'production', 'development').
+ - application_name (str): Name of the Langchain application.
+ - tracer (opentelemetry.trace.Tracer): The tracer object used for OpenTelemetry tracing.
+ - pricing_info (dict): Information about the pricing for internal metrics (currently not used).
+ - trace_content (bool): Flag indicating whether to trace the content of the response.
+
+ Returns:
+ - function: A higher-order function that takes a function 'wrapped' and returns
+ a new function that wraps 'wrapped' with additional tracing and logging.
+ """
+
+ def wrapper(wrapped, instance, args, kwargs):
+ """
+ An inner wrapper function that executes the wrapped function, measures execution
+ time, and records trace data using OpenTelemetry.
+
+ Parameters:
+ - wrapped (Callable): The original function that this wrapper will execute.
+ - instance (object): The instance to which the wrapped function belongs. This
+ is used for instance methods. For static and classmethods,
+ this may be None.
+ - args (tuple): Positional arguments passed to the wrapped function.
+ - kwargs (dict): Keyword arguments passed to the wrapped function.
+
+ Returns:
+ - The result of the wrapped function call.
+
+ The wrapper initiates a span with the provided tracer, sets various attributes
+ on the span based on the function's execution and response, and ensures
+ errors are handled and logged appropriately.
+ """
+
+ with tracer.start_as_current_span(gen_ai_endpoint, kind= SpanKind.CLIENT) as span:
+ response = wrapped(*args, **kwargs)
+
+ if isinstance(instance.__dict__.get('llm_config'), dict):
+ llm_model = instance.__dict__['llm_config'].get('model', 'gpt-4')
+ else:
+ # Fallback to default if 'llm_config' is not a dictionary
+ llm_model = None
+
+ try:
+ span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
+ span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ gen_ai_endpoint)
+ span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
+ SemanticConvetion.GEN_AI_SYSTEM_AG2)
+ span.set_attribute(SemanticConvetion.GEN_AI_ENVIRONMENT,
+ environment)
+ span.set_attribute(SemanticConvetion.GEN_AI_APPLICATION_NAME,
+ application_name)
+ span.set_attribute(SemanticConvetion.GEN_AI_TYPE,
+ SemanticConvetion.GEN_AI_TYPE_AGENT)
+ span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ROLE,
+ instance.name)
+ if llm_model:
+ span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ llm_model)
+
+
+ span.set_status(Status(StatusCode.OK))
+
+ # Return original response
+ return response
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in trace creation: %s", e)
+
+ # Return original response
+ return response
+
+ return wrapper
diff --git a/sdk/python/src/openlit/semcov/__init__.py b/sdk/python/src/openlit/semcov/__init__.py
index b56659da..442495dd 100644
--- a/sdk/python/src/openlit/semcov/__init__.py
+++ b/sdk/python/src/openlit/semcov/__init__.py
@@ -111,6 +111,7 @@ class SemanticConvetion:
GEN_AI_SYSTEM_EMBEDCHAIN = "embedchain"
GEN_AI_SYSTEM_LITELLM = "litellm"
GEN_AI_SYSTEM_CREWAI = "crewai"
+ GEN_AI_SYSTEM_AG2 = "ag2"
# Vector DB
DB_REQUESTS = "db.total.requests"