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 DSPy (#509)

Patcher9bf71996d09e
diff --git a/.github/workflows/vale-validator.yml b/.github/workflows/vale-validator.yml
index 5161aa64..8646f87d 100644
--- a/.github/workflows/vale-validator.yml
+++ b/.github/workflows/vale-validator.yml
@@ -1,4 +1,4 @@
-name: reviewdog
+name: Vale Validator
on:
pull_request:
permissions:
diff --git a/docs/images/docs-dspy-banner.gif b/docs/images/docs-dspy-banner.gif
new file mode 100644
index 00000000..4d525a57
Binary files /dev/null and b/docs/images/docs-dspy-banner.gif differ
diff --git a/docs/latest/integrations/crewai.mdx b/docs/latest/integrations/crewai.mdx
index 980676d7..6501795c 100644
--- a/docs/latest/integrations/crewai.mdx
+++ b/docs/latest/integrations/crewai.mdx
@@ -7,7 +7,7 @@ sidebarTitle: 'CrewAI'
<img src="/images/docs-crewai-banner.gif" />
</Frame>
-OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor LLM applications built using Haystack. This includes tracking performance and operation stats.
+OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor AI Agents built using CrewAI. 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.
diff --git a/docs/latest/integrations/dspy.mdx b/docs/latest/integrations/dspy.mdx
new file mode 100644
index 00000000..bc9dba84
--- /dev/null
+++ b/docs/latest/integrations/dspy.mdx
@@ -0,0 +1,75 @@
+---
+title: 'Monitor DSPy using OpenTelemetry'
+sidebarTitle: 'DSPy'
+---
+
+<Frame>
+ <img src="/images/docs-dspy-banner.gif" />
+</Frame>
+
+OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor AI applications built using DSPy. 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 8bf6b0c8..ef361dbc 100644
--- a/docs/latest/integrations/introduction.mdx
+++ b/docs/latest/integrations/introduction.mdx
@@ -543,6 +543,18 @@ Start integrating and monitoring your applications with OpenLIT effortlessly. Ch
}
>
</Card>
+ <Card
+ title="CrewAI"
+ href="/latest/integrations/crewai"
+ iconType="duotone"
+ icon={
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 480 480">
+ <path d="M0 0 C0 0.66 0 1.32 0 2 C0.59530518 2.114646 1.19061035 2.22929199 1.80395508 2.34741211 C5.41745308 3.42121757 7.92082804 6.10133181 10.6875 8.5625 C11.61199951 9.37243408 11.61199951 9.37243408 12.55517578 10.19873047 C13.79408156 11.28564311 15.03045095 12.37545423 16.26416016 13.46826172 C17.80375153 14.8268266 19.35972378 16.1667777 20.91796875 17.50390625 C21.72878906 18.20386719 22.53960937 18.90382812 23.375 19.625 C24.43847656 20.54152344 24.43847656 20.54152344 25.5234375 21.4765625 C27 23 27 23 27 25 C27.66 25 28.32 25 29 25 C51.14784149 48.7266082 60.15767166 76.02286571 59.14794922 108.03759766 C58.43392079 122.33466189 54.67505428 135.54901965 50 149 C49.55817207 150.30584699 49.11674168 151.61182857 48.67578125 152.91796875 C46.42706687 159.42292484 43.90061106 165.68672899 40.91796875 171.890625 C39.86698782 173.92223453 39.86698782 173.92223453 40 176 C40.96679688 176.15855469 41.93359375 176.31710938 42.9296875 176.48046875 C57.89687839 179.09225802 70.93771718 185.16176601 80 198 C92.12243583 215.9229562 94.12688849 240.39783923 90.74609375 261.2421875 C88.03744265 274.88471296 83.71763921 286.83152944 77 299 C76.61465088 299.71824951 76.22930176 300.43649902 75.83227539 301.17651367 C72.99444104 306.40941961 69.88442682 311.33605681 66.4375 316.1875 C65.92590332 316.91146973 65.41430664 317.63543945 64.88720703 318.38134766 C60.39535279 324.63927686 55.50303836 330.47943263 50.3984375 336.2421875 C47.94354618 338.94659536 47.94354618 338.94659536 46 342 C45.34 342 44.68 342 44 342 C43.75507813 342.57105469 43.51015625 343.14210938 43.2578125 343.73046875 C39.22636498 351.00460232 31.28609429 356.66674527 25 362 C24.41863281 362.50917969 23.83726562 363.01835937 23.23828125 363.54296875 C19.23897059 367 19.23897059 367 17 367 C17 367.66 17 368.32 17 369 C15.64575195 370.20166016 15.64575195 370.20166016 13.73828125 371.5390625 C12.68761475 372.280354 12.68761475 372.280354 11.61572266 373.03662109 C10.85565918 373.56078613 10.0955957 374.08495117 9.3125 374.625 C8.5395459 375.16334473 7.7665918 375.70168945 6.97021484 376.25634766 C-48.18941549 414.37719893 -115.02623708 434.65626241 -182 423 C-201.21934969 419.22351264 -219.47414821 412.60576769 -236 402 C-236.78375 401.50886719 -237.5675 401.01773437 -238.375 400.51171875 C-273.69459747 377.76246413 -296.37566879 342.92622436 -305.36572266 302.24511719 C-317.69554878 239.16272733 -299.44411241 174.32663078 -267 120 C-266.20212371 118.5241736 -265.40959071 117.04543208 -264.625 115.5625 C-254.88107482 98.03673697 -243.03549908 81.19432154 -229.7734375 66.17578125 C-227.38315718 63.46835705 -225.15429687 60.66454498 -222.9375 57.8125 C-218.33715241 52.13474759 -213.21085075 46.99235665 -208.0625 41.8125 C-207.20841553 40.94923096 -206.35433105 40.08596191 -205.47436523 39.1965332 C-204.66942627 38.39562256 -203.8644873 37.59471191 -203.03515625 36.76953125 C-202.3069165 36.04354736 -201.57867676 35.31756348 -200.82836914 34.56958008 C-199 33 -199 33 -197 33 C-197 32.34 -197 31.68 -197 31 C-195.49576101 29.60126876 -193.91734851 28.28204731 -192.3125 27 C-191.31605469 26.20207031 -190.31960937 25.40414062 -189.29296875 24.58203125 C-184.87348531 21.10320362 -180.41696227 17.67313706 -175.9453125 14.26171875 C-174.1215078 12.8612109 -172.31936003 11.43135031 -170.5546875 9.95703125 C-167.53408805 7.6430858 -164.32245616 5.83091649 -161 4 C-159.69302607 3.2478015 -158.38707097 2.49383056 -157.08203125 1.73828125 C-107.65240613 -26.50721882 -48.68782437 -36.43631301 0 0 Z " fill="#471A18" transform="translate(337,29)"/>
+ <path d="M0 0 C0.721875 0.53109375 1.44375 1.0621875 2.1875 1.609375 C19.24357464 14.51987594 36.30198529 31.29541865 41 53 C42.52534709 73.86258815 38.88679649 91.3205145 31.01708984 110.50976562 C29.98034388 113.04812589 28.98076317 115.5994332 27.98046875 118.15234375 C26.27139554 122.42606965 24.35139538 126.53230269 22.25 130.625 C21.91000977 131.29740723 21.57001953 131.96981445 21.21972656 132.66259766 C19.79200851 135.48591339 18.3545929 138.30425544 16.91796875 141.12304688 C12.92415127 148.9727136 9.10518559 156.74803043 6 165 C5.0085224 167.58705222 4.00856322 170.16967028 3 172.75 C2.76265137 173.37656494 2.52530273 174.00312988 2.28076172 174.64868164 C-0.36139195 181.40135107 -3.3754848 186.6877424 -10 190 C-21.81932831 191.37892164 -30.77356081 185.80531685 -40 179 C-41.00740234 178.27296875 -41.00740234 178.27296875 -42.03515625 177.53125 C-51.6418685 170.00343903 -59.74845378 157.26742087 -61.71484375 145.14453125 C-62.9242655 131.80775715 -62.34138592 119.76693691 -58 107 C-57.52034721 105.50275981 -57.04120713 104.00535531 -56.5625 102.5078125 C-50.94003364 85.3759905 -43.60294234 68.79131808 -35.31665039 52.7890625 C-32.79765676 47.45307451 -31.43942421 42.94210337 -32 37 C-32.98048938 34.93597315 -32.98048938 34.93597315 -35 34 C-40.32156806 33.40871466 -43.13235539 34.88374351 -47.5625 37.75 C-48.65691406 38.44609375 -49.75132812 39.1421875 -50.87890625 39.859375 C-58.743425 45.25331276 -64.78650662 51.82144039 -71.01171875 58.98828125 C-71.99591797 59.98408203 -71.99591797 59.98408203 -73 61 C-73.66 61 -74.32 61 -75 61 C-75.25007812 61.57234375 -75.50015625 62.1446875 -75.7578125 62.734375 C-77.17579905 65.32063978 -78.83810894 67.11611413 -80.875 69.25 C-87.13613114 76.08397941 -92.54006944 83.52136296 -98 91 C-98.45584473 91.61987793 -98.91168945 92.23975586 -99.38134766 92.87841797 C-104.91075518 100.40778063 -110.06485802 108.06439996 -114.8515625 116.09472656 C-116.15119525 118.25083497 -117.48118702 120.38675136 -118.8125 122.5234375 C-125.6609158 133.60130234 -131.56383607 144.88719026 -136.95849609 156.73779297 C-137.84500909 158.66335074 -138.77187598 160.57024655 -139.70703125 162.47265625 C-142.90106516 169.00399208 -145.40708841 175.68947464 -147.75 182.5625 C-148.19122192 183.83867187 -148.19122192 183.83867187 -148.64135742 185.140625 C-152.37391307 196.43449742 -153.33087246 207.46928586 -153.26074219 219.2902832 C-153.25003031 221.43144142 -153.26069704 223.5717578 -153.2734375 225.71289062 C-153.29173635 243.130391 -151.18212626 258.71230407 -139 272 C-122.99420501 284.37485076 -103.03302724 281.48077443 -84.20898438 279.26025391 C-82.41692616 279.04912061 -80.62277185 278.85583203 -78.828125 278.66796875 C-33.59577577 272.7197841 6.33698333 242.64429973 33.90625 207.84375 C36.05858494 204.92042942 38.06279143 201.9268796 40.06738281 198.90161133 C49.52358888 184.69957586 49.52358888 184.69957586 58.625 181.875 C63.01796601 182.03770244 64.72484977 183.08875535 68 186 C73.01359074 192.805333 74.37000514 199.89608067 74.3125 208.1875 C74.30686035 209.03610596 74.3012207 209.88471191 74.29541016 210.7590332 C74.16954421 217.27602277 73.27239189 222.86882944 71 229 C70.58621094 230.24136719 70.17242187 231.48273438 69.74609375 232.76171875 C66.60122729 241.94922937 62.52924094 249.966759 57 258 C56.33355469 258.97195313 55.66710937 259.94390625 54.98046875 260.9453125 C48.72866128 269.64448802 41.42483281 277.3044349 34 285 C32.75669922 286.30517578 32.75669922 286.30517578 31.48828125 287.63671875 C26.03491675 293.24673285 20.1357022 298.15559169 14 303 C13.05898438 303.76957031 12.11796875 304.53914063 11.1484375 305.33203125 C-16.53843332 327.47437367 -48.66263437 341.15680711 -83 349 C-84.19471924 349.27336182 -84.19471924 349.27336182 -85.41357422 349.55224609 C-97.17516016 352.09481307 -108.95623795 352.27903628 -120.9375 352.3125 C-122.05989075 352.31814972 -122.05989075 352.31814972 -123.20495605 352.32391357 C-132.66160522 352.34805225 -141.67519733 351.74793029 -151 350 C-152.25554687 349.78859375 -153.51109375 349.5771875 -154.8046875 349.359375 C-181.68657771 344.02403801 -206.34900888 328.62818955 -223 307 C-223.6084375 306.23042969 -224.216875 305.46085937 -224.84375 304.66796875 C-236.23255854 289.47426281 -244.03171238 268.83932433 -246 250 C-246.16435547 248.49759766 -246.16435547 248.49759766 -246.33203125 246.96484375 C-246.6586023 243.31160225 -246.85779771 239.66399578 -247 236 C-247.03399902 235.19723633 -247.06799805 234.39447266 -247.10302734 233.56738281 C-248.17571588 204.32709133 -242.64525344 174.85015965 -230.87597656 148.015625 C-229.83700741 145.6249535 -228.83677483 143.21937899 -227.8359375 140.8125 C-223.98585976 131.6069227 -220.05486937 122.61920034 -215 114 C-214.03050857 112.27446484 -213.06102802 110.54892356 -212.09179688 108.82324219 C-208.27962393 102.07056013 -204.2121575 95.50969796 -200 89 C-199.4121875 88.0615625 -198.824375 87.123125 -198.21875 86.15625 C-194.71251919 80.55858326 -191.06696322 75.20213756 -187 70 C-185.79537109 68.44152344 -185.79537109 68.44152344 -184.56640625 66.8515625 C-179.78861592 60.69561324 -174.92649197 54.61129171 -169.9375 48.625 C-169.47255127 48.05950439 -169.00760254 47.49400879 -168.52856445 46.91137695 C-167.39740956 45.56832759 -166.20391653 44.27823236 -165 43 C-164.34 43 -163.68 43 -163 43 C-162.62875 42.071875 -162.62875 42.071875 -162.25 41.125 C-160.76259631 38.59641373 -159.56321991 38.28160996 -157 37 C-156.71511719 36.401875 -156.43023437 35.80375 -156.13671875 35.1875 C-149.24983248 21.93438553 -128.54505975 10.54905096 -116 3 C-115.43458496 2.65485352 -114.86916992 2.30970703 -114.28662109 1.95410156 C-77.44586536 -20.42137882 -36.22485271 -26.88563287 0 0 Z " fill="#FDFDFD" transform="translate(315,63)"/>
+ </svg>
+ }
+ >
+ </Card>
<Card
title="LlamaIndex"
href="/latest/integrations/llama-index"
@@ -554,6 +566,17 @@ Start integrating and monitoring your applications with OpenLIT effortlessly. Ch
}
>
</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"
@@ -766,18 +789,6 @@ Start integrating and monitoring your applications with OpenLIT effortlessly. Ch
}
>
</Card>
- <Card
- title="CrewAI"
- href="/latest/integrations/crewai"
- iconType="duotone"
- icon={
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 480 480">
- <path d="M0 0 C0 0.66 0 1.32 0 2 C0.59530518 2.114646 1.19061035 2.22929199 1.80395508 2.34741211 C5.41745308 3.42121757 7.92082804 6.10133181 10.6875 8.5625 C11.61199951 9.37243408 11.61199951 9.37243408 12.55517578 10.19873047 C13.79408156 11.28564311 15.03045095 12.37545423 16.26416016 13.46826172 C17.80375153 14.8268266 19.35972378 16.1667777 20.91796875 17.50390625 C21.72878906 18.20386719 22.53960937 18.90382812 23.375 19.625 C24.43847656 20.54152344 24.43847656 20.54152344 25.5234375 21.4765625 C27 23 27 23 27 25 C27.66 25 28.32 25 29 25 C51.14784149 48.7266082 60.15767166 76.02286571 59.14794922 108.03759766 C58.43392079 122.33466189 54.67505428 135.54901965 50 149 C49.55817207 150.30584699 49.11674168 151.61182857 48.67578125 152.91796875 C46.42706687 159.42292484 43.90061106 165.68672899 40.91796875 171.890625 C39.86698782 173.92223453 39.86698782 173.92223453 40 176 C40.96679688 176.15855469 41.93359375 176.31710938 42.9296875 176.48046875 C57.89687839 179.09225802 70.93771718 185.16176601 80 198 C92.12243583 215.9229562 94.12688849 240.39783923 90.74609375 261.2421875 C88.03744265 274.88471296 83.71763921 286.83152944 77 299 C76.61465088 299.71824951 76.22930176 300.43649902 75.83227539 301.17651367 C72.99444104 306.40941961 69.88442682 311.33605681 66.4375 316.1875 C65.92590332 316.91146973 65.41430664 317.63543945 64.88720703 318.38134766 C60.39535279 324.63927686 55.50303836 330.47943263 50.3984375 336.2421875 C47.94354618 338.94659536 47.94354618 338.94659536 46 342 C45.34 342 44.68 342 44 342 C43.75507813 342.57105469 43.51015625 343.14210938 43.2578125 343.73046875 C39.22636498 351.00460232 31.28609429 356.66674527 25 362 C24.41863281 362.50917969 23.83726562 363.01835937 23.23828125 363.54296875 C19.23897059 367 19.23897059 367 17 367 C17 367.66 17 368.32 17 369 C15.64575195 370.20166016 15.64575195 370.20166016 13.73828125 371.5390625 C12.68761475 372.280354 12.68761475 372.280354 11.61572266 373.03662109 C10.85565918 373.56078613 10.0955957 374.08495117 9.3125 374.625 C8.5395459 375.16334473 7.7665918 375.70168945 6.97021484 376.25634766 C-48.18941549 414.37719893 -115.02623708 434.65626241 -182 423 C-201.21934969 419.22351264 -219.47414821 412.60576769 -236 402 C-236.78375 401.50886719 -237.5675 401.01773437 -238.375 400.51171875 C-273.69459747 377.76246413 -296.37566879 342.92622436 -305.36572266 302.24511719 C-317.69554878 239.16272733 -299.44411241 174.32663078 -267 120 C-266.20212371 118.5241736 -265.40959071 117.04543208 -264.625 115.5625 C-254.88107482 98.03673697 -243.03549908 81.19432154 -229.7734375 66.17578125 C-227.38315718 63.46835705 -225.15429687 60.66454498 -222.9375 57.8125 C-218.33715241 52.13474759 -213.21085075 46.99235665 -208.0625 41.8125 C-207.20841553 40.94923096 -206.35433105 40.08596191 -205.47436523 39.1965332 C-204.66942627 38.39562256 -203.8644873 37.59471191 -203.03515625 36.76953125 C-202.3069165 36.04354736 -201.57867676 35.31756348 -200.82836914 34.56958008 C-199 33 -199 33 -197 33 C-197 32.34 -197 31.68 -197 31 C-195.49576101 29.60126876 -193.91734851 28.28204731 -192.3125 27 C-191.31605469 26.20207031 -190.31960937 25.40414062 -189.29296875 24.58203125 C-184.87348531 21.10320362 -180.41696227 17.67313706 -175.9453125 14.26171875 C-174.1215078 12.8612109 -172.31936003 11.43135031 -170.5546875 9.95703125 C-167.53408805 7.6430858 -164.32245616 5.83091649 -161 4 C-159.69302607 3.2478015 -158.38707097 2.49383056 -157.08203125 1.73828125 C-107.65240613 -26.50721882 -48.68782437 -36.43631301 0 0 Z " fill="#471A18" transform="translate(337,29)"/>
- <path d="M0 0 C0.721875 0.53109375 1.44375 1.0621875 2.1875 1.609375 C19.24357464 14.51987594 36.30198529 31.29541865 41 53 C42.52534709 73.86258815 38.88679649 91.3205145 31.01708984 110.50976562 C29.98034388 113.04812589 28.98076317 115.5994332 27.98046875 118.15234375 C26.27139554 122.42606965 24.35139538 126.53230269 22.25 130.625 C21.91000977 131.29740723 21.57001953 131.96981445 21.21972656 132.66259766 C19.79200851 135.48591339 18.3545929 138.30425544 16.91796875 141.12304688 C12.92415127 148.9727136 9.10518559 156.74803043 6 165 C5.0085224 167.58705222 4.00856322 170.16967028 3 172.75 C2.76265137 173.37656494 2.52530273 174.00312988 2.28076172 174.64868164 C-0.36139195 181.40135107 -3.3754848 186.6877424 -10 190 C-21.81932831 191.37892164 -30.77356081 185.80531685 -40 179 C-41.00740234 178.27296875 -41.00740234 178.27296875 -42.03515625 177.53125 C-51.6418685 170.00343903 -59.74845378 157.26742087 -61.71484375 145.14453125 C-62.9242655 131.80775715 -62.34138592 119.76693691 -58 107 C-57.52034721 105.50275981 -57.04120713 104.00535531 -56.5625 102.5078125 C-50.94003364 85.3759905 -43.60294234 68.79131808 -35.31665039 52.7890625 C-32.79765676 47.45307451 -31.43942421 42.94210337 -32 37 C-32.98048938 34.93597315 -32.98048938 34.93597315 -35 34 C-40.32156806 33.40871466 -43.13235539 34.88374351 -47.5625 37.75 C-48.65691406 38.44609375 -49.75132812 39.1421875 -50.87890625 39.859375 C-58.743425 45.25331276 -64.78650662 51.82144039 -71.01171875 58.98828125 C-71.99591797 59.98408203 -71.99591797 59.98408203 -73 61 C-73.66 61 -74.32 61 -75 61 C-75.25007812 61.57234375 -75.50015625 62.1446875 -75.7578125 62.734375 C-77.17579905 65.32063978 -78.83810894 67.11611413 -80.875 69.25 C-87.13613114 76.08397941 -92.54006944 83.52136296 -98 91 C-98.45584473 91.61987793 -98.91168945 92.23975586 -99.38134766 92.87841797 C-104.91075518 100.40778063 -110.06485802 108.06439996 -114.8515625 116.09472656 C-116.15119525 118.25083497 -117.48118702 120.38675136 -118.8125 122.5234375 C-125.6609158 133.60130234 -131.56383607 144.88719026 -136.95849609 156.73779297 C-137.84500909 158.66335074 -138.77187598 160.57024655 -139.70703125 162.47265625 C-142.90106516 169.00399208 -145.40708841 175.68947464 -147.75 182.5625 C-148.19122192 183.83867187 -148.19122192 183.83867187 -148.64135742 185.140625 C-152.37391307 196.43449742 -153.33087246 207.46928586 -153.26074219 219.2902832 C-153.25003031 221.43144142 -153.26069704 223.5717578 -153.2734375 225.71289062 C-153.29173635 243.130391 -151.18212626 258.71230407 -139 272 C-122.99420501 284.37485076 -103.03302724 281.48077443 -84.20898438 279.26025391 C-82.41692616 279.04912061 -80.62277185 278.85583203 -78.828125 278.66796875 C-33.59577577 272.7197841 6.33698333 242.64429973 33.90625 207.84375 C36.05858494 204.92042942 38.06279143 201.9268796 40.06738281 198.90161133 C49.52358888 184.69957586 49.52358888 184.69957586 58.625 181.875 C63.01796601 182.03770244 64.72484977 183.08875535 68 186 C73.01359074 192.805333 74.37000514 199.89608067 74.3125 208.1875 C74.30686035 209.03610596 74.3012207 209.88471191 74.29541016 210.7590332 C74.16954421 217.27602277 73.27239189 222.86882944 71 229 C70.58621094 230.24136719 70.17242187 231.48273438 69.74609375 232.76171875 C66.60122729 241.94922937 62.52924094 249.966759 57 258 C56.33355469 258.97195313 55.66710937 259.94390625 54.98046875 260.9453125 C48.72866128 269.64448802 41.42483281 277.3044349 34 285 C32.75669922 286.30517578 32.75669922 286.30517578 31.48828125 287.63671875 C26.03491675 293.24673285 20.1357022 298.15559169 14 303 C13.05898438 303.76957031 12.11796875 304.53914063 11.1484375 305.33203125 C-16.53843332 327.47437367 -48.66263437 341.15680711 -83 349 C-84.19471924 349.27336182 -84.19471924 349.27336182 -85.41357422 349.55224609 C-97.17516016 352.09481307 -108.95623795 352.27903628 -120.9375 352.3125 C-122.05989075 352.31814972 -122.05989075 352.31814972 -123.20495605 352.32391357 C-132.66160522 352.34805225 -141.67519733 351.74793029 -151 350 C-152.25554687 349.78859375 -153.51109375 349.5771875 -154.8046875 349.359375 C-181.68657771 344.02403801 -206.34900888 328.62818955 -223 307 C-223.6084375 306.23042969 -224.216875 305.46085937 -224.84375 304.66796875 C-236.23255854 289.47426281 -244.03171238 268.83932433 -246 250 C-246.16435547 248.49759766 -246.16435547 248.49759766 -246.33203125 246.96484375 C-246.6586023 243.31160225 -246.85779771 239.66399578 -247 236 C-247.03399902 235.19723633 -247.06799805 234.39447266 -247.10302734 233.56738281 C-248.17571588 204.32709133 -242.64525344 174.85015965 -230.87597656 148.015625 C-229.83700741 145.6249535 -228.83677483 143.21937899 -227.8359375 140.8125 C-223.98585976 131.6069227 -220.05486937 122.61920034 -215 114 C-214.03050857 112.27446484 -213.06102802 110.54892356 -212.09179688 108.82324219 C-208.27962393 102.07056013 -204.2121575 95.50969796 -200 89 C-199.4121875 88.0615625 -198.824375 87.123125 -198.21875 86.15625 C-194.71251919 80.55858326 -191.06696322 75.20213756 -187 70 C-185.79537109 68.44152344 -185.79537109 68.44152344 -184.56640625 66.8515625 C-179.78861592 60.69561324 -174.92649197 54.61129171 -169.9375 48.625 C-169.47255127 48.05950439 -169.00760254 47.49400879 -168.52856445 46.91137695 C-167.39740956 45.56832759 -166.20391653 44.27823236 -165 43 C-164.34 43 -163.68 43 -163 43 C-162.62875 42.071875 -162.62875 42.071875 -162.25 41.125 C-160.76259631 38.59641373 -159.56321991 38.28160996 -157 37 C-156.71511719 36.401875 -156.43023437 35.80375 -156.13671875 35.1875 C-149.24983248 21.93438553 -128.54505975 10.54905096 -116 3 C-115.43458496 2.65485352 -114.86916992 2.30970703 -114.28662109 1.95410156 C-77.44586536 -20.42137882 -36.22485271 -26.88563287 0 0 Z " fill="#FDFDFD" transform="translate(315,63)"/>
- </svg>
- }
- >
- </Card>
</CardGroup>
### GPUs
@@ -834,6 +845,8 @@ Start integrating and monitoring your applications with OpenLIT effortlessly. Ch
| LiteLLM | Framework | ✔️ | ❌ |
| LlamaIndex | Framework | ✔️ | ❌ |
| Haystack | Framework | ✔️ | ❌ |
+| CrewAI | Framework | ✔️ | ❌ |
+| DSPy | Framework | ✔️ | ❌ |
| EmbedChain | Framework | ✔️ | ❌ |
| NVIDIA GPUs | GPU | ✔️ | ❌ |
| AMD GPUs | GPU | ✔️ | ❌ |
diff --git a/docs/mint.json b/docs/mint.json
index 8340933f..4ac0edad 100644
--- a/docs/mint.json
+++ b/docs/mint.json
@@ -120,7 +120,9 @@
"pages": [
"latest/integrations/langchain",
"latest/integrations/litellm",
+ "latest/integrations/crewai",
"latest/integrations/llama-index",
+ "latest/integrations/dspy",
"latest/integrations/haystack",
"latest/integrations/embedchain",
"latest/integrations/guardrails"
diff --git a/sdk/python/README.md b/sdk/python/README.md
index 7b1ec0a8..bd25df1d 100644
--- a/sdk/python/README.md
+++ b/sdk/python/README.md
@@ -41,7 +41,7 @@ This project proudly follows and maintains the [Semantic Conventions](https://gi
| [✅ 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) | |
+| [✅ 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) | | | |
| [✅ HuggingFace Transformers](https://docs.openlit.io/latest/integrations/huggingface) | | | |
| [✅ Amazon Bedrock](https://docs.openlit.io/latest/integrations/bedrock) | | | |
@@ -53,6 +53,7 @@ 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)
diff --git a/sdk/python/pyproject.toml b/sdk/python/pyproject.toml
index 5da5a844..f1a001b6 100644
--- a/sdk/python/pyproject.toml
+++ b/sdk/python/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "openlit"
-version = "1.30.2"
+version = "1.30.3"
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/instrumentation/litellm/__init__.py b/sdk/python/src/openlit/instrumentation/litellm/__init__.py
index e3278a66..5f3d9eda 100644
--- a/sdk/python/src/openlit/instrumentation/litellm/__init__.py
+++ b/sdk/python/src/openlit/instrumentation/litellm/__init__.py
@@ -7,10 +7,10 @@ from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
from wrapt import wrap_function_wrapper
from openlit.instrumentation.litellm.litellm import (
- completion
+ completion, embedding
)
from openlit.instrumentation.litellm.async_litellm import (
- acompletion
+ acompletion, aembedding
)
_instruments = ("litellm >= 1.52.6",)
@@ -48,6 +48,20 @@ class LiteLLMInstrumentor(BaseInstrumentor):
tracer, pricing_info, trace_content, metrics, disable_metrics),
)
+ wrap_function_wrapper(
+ "litellm",
+ "embedding",
+ embedding("litellm.embedding", version, environment, application_name,
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
+ )
+
+ wrap_function_wrapper(
+ "litellm",
+ "aembedding",
+ aembedding("litellm.embedding", version, environment, application_name,
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
+ )
+
def _uninstrument(self, **kwargs):
# Proper uninstrumentation logic to revert patched methods
diff --git a/sdk/python/src/openlit/instrumentation/litellm/async_litellm.py b/sdk/python/src/openlit/instrumentation/litellm/async_litellm.py
index 03db7a0f..57a978cc 100644
--- a/sdk/python/src/openlit/instrumentation/litellm/async_litellm.py
+++ b/sdk/python/src/openlit/instrumentation/litellm/async_litellm.py
@@ -8,6 +8,7 @@ from opentelemetry.trace import SpanKind, Status, StatusCode
from opentelemetry.sdk.resources import TELEMETRY_SDK_NAME
from openlit.__helpers import (
get_chat_model_cost,
+ get_embed_model_cost,
openai_tokens,
handle_exception,
response_as_dict,
@@ -404,3 +405,117 @@ def acompletion(gen_ai_endpoint, version, environment, application_name,
return response
return wrapper
+
+def aembedding(gen_ai_endpoint, version, environment, application_name,
+ tracer, pricing_info, trace_content, metrics, disable_metrics):
+ """
+ Generates a telemetry wrapper for embeddings to collect metrics.
+
+ Args:
+ gen_ai_endpoint: Endpoint identifier for logging and tracing.
+ version: Version of the monitoring package.
+ environment: Deployment environment (e.g., production, staging).
+ application_name: Name of the application using the OpenAI API.
+ tracer: OpenTelemetry tracer for creating spans.
+ pricing_info: Information used for calculating the cost of OpenAI usage.
+ trace_content: Flag indicating whether to trace the actual content.
+
+ Returns:
+ A function that wraps the embeddings method to add telemetry.
+ """
+
+ async def wrapper(wrapped, instance, args, kwargs):
+ """
+ Wraps the 'embeddings' API call to add telemetry.
+
+ This collects metrics such as execution time, cost, and token usage, and handles errors
+ gracefully, adding details to the trace for observability.
+
+ Args:
+ wrapped: The original 'embeddings' method to be wrapped.
+ instance: The instance of the class where the original method is defined.
+ args: Positional arguments for the 'embeddings' method.
+ kwargs: Keyword arguments for the 'embeddings' method.
+
+ Returns:
+ The response from the original 'embeddings' method.
+ """
+
+ with tracer.start_as_current_span(gen_ai_endpoint, kind= SpanKind.CLIENT) as span:
+ response = await wrapped(*args, **kwargs)
+ response_dict = response_as_dict(response)
+ try:
+ # Calculate cost of the operation
+ cost = get_embed_model_cost(kwargs.get("model", "text-embedding-ada-002"),
+ pricing_info, response_dict.get('usage').get('prompt_tokens'))
+
+ # Set Span attributes
+ span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
+ span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
+ SemanticConvetion.GEN_AI_SYSTEM_OPENAI)
+ span.set_attribute(SemanticConvetion.GEN_AI_TYPE,
+ SemanticConvetion.GEN_AI_TYPE_EMBEDDING)
+ span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ gen_ai_endpoint)
+ span.set_attribute(SemanticConvetion.GEN_AI_ENVIRONMENT,
+ environment)
+ span.set_attribute(SemanticConvetion.GEN_AI_APPLICATION_NAME,
+ application_name)
+ span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ kwargs.get("model", "text-embedding-ada-002"))
+ span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_EMBEDDING_FORMAT,
+ kwargs.get("encoding_format", "float"))
+ # span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_EMBEDDING_DIMENSION,
+ # kwargs.get("dimensions", "null"))
+ span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ kwargs.get("user", ""))
+ span.set_attribute(SemanticConvetion.GEN_AI_USAGE_PROMPT_TOKENS,
+ response_dict.get('usage').get('prompt_tokens'))
+ span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ response_dict.get('usage').get('total_tokens'))
+ span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ cost)
+ if trace_content:
+ span.add_event(
+ name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ attributes={
+ SemanticConvetion.GEN_AI_CONTENT_PROMPT: kwargs.get("input", ""),
+ },
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ if disable_metrics is False:
+ attributes = {
+ TELEMETRY_SDK_NAME:
+ "openlit",
+ SemanticConvetion.GEN_AI_APPLICATION_NAME:
+ application_name,
+ SemanticConvetion.GEN_AI_SYSTEM:
+ SemanticConvetion.GEN_AI_SYSTEM_OPENAI,
+ SemanticConvetion.GEN_AI_ENVIRONMENT:
+ environment,
+ SemanticConvetion.GEN_AI_TYPE:
+ SemanticConvetion.GEN_AI_TYPE_EMBEDDING,
+ SemanticConvetion.GEN_AI_REQUEST_MODEL:
+ kwargs.get("model", "text-embedding-ada-002")
+ }
+
+ metrics["genai_requests"].add(1, attributes)
+ metrics["genai_total_tokens"].add(
+ response_dict.get('usage').get('total_tokens'), attributes)
+ metrics["genai_prompt_tokens"].add(
+ response_dict.get('usage').get('prompt_tokens'), attributes)
+ metrics["genai_cost"].record(cost, attributes)
+
+ # 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/instrumentation/litellm/litellm.py b/sdk/python/src/openlit/instrumentation/litellm/litellm.py
index e13b50e4..af038a83 100644
--- a/sdk/python/src/openlit/instrumentation/litellm/litellm.py
+++ b/sdk/python/src/openlit/instrumentation/litellm/litellm.py
@@ -8,6 +8,7 @@ from opentelemetry.trace import SpanKind, Status, StatusCode
from opentelemetry.sdk.resources import TELEMETRY_SDK_NAME
from openlit.__helpers import (
get_chat_model_cost,
+ get_embed_model_cost,
openai_tokens,
handle_exception,
response_as_dict,
@@ -404,3 +405,117 @@ def completion(gen_ai_endpoint, version, environment, application_name,
return response
return wrapper
+
+def embedding(gen_ai_endpoint, version, environment, application_name,
+ tracer, pricing_info, trace_content, metrics, disable_metrics):
+ """
+ Generates a telemetry wrapper for embeddings to collect metrics.
+
+ Args:
+ gen_ai_endpoint: Endpoint identifier for logging and tracing.
+ version: Version of the monitoring package.
+ environment: Deployment environment (e.g., production, staging).
+ application_name: Name of the application using the OpenAI API.
+ tracer: OpenTelemetry tracer for creating spans.
+ pricing_info: Information used for calculating the cost of OpenAI usage.
+ trace_content: Flag indicating whether to trace the actual content.
+
+ Returns:
+ A function that wraps the embeddings method to add telemetry.
+ """
+
+ def wrapper(wrapped, instance, args, kwargs):
+ """
+ Wraps the 'embeddings' API call to add telemetry.
+
+ This collects metrics such as execution time, cost, and token usage, and handles errors
+ gracefully, adding details to the trace for observability.
+
+ Args:
+ wrapped: The original 'embeddings' method to be wrapped.
+ instance: The instance of the class where the original method is defined.
+ args: Positional arguments for the 'embeddings' method.
+ kwargs: Keyword arguments for the 'embeddings' method.
+
+ Returns:
+ The response from the original 'embeddings' method.
+ """
+
+ with tracer.start_as_current_span(gen_ai_endpoint, kind= SpanKind.CLIENT) as span:
+ response = wrapped(*args, **kwargs)
+ response_dict = response_as_dict(response)
+ try:
+ # Calculate cost of the operation
+ cost = get_embed_model_cost(kwargs.get("model", "text-embedding-ada-002"),
+ pricing_info, response_dict.get('usage').get('prompt_tokens'))
+
+ # Set Span attributes
+ span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
+ span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
+ SemanticConvetion.GEN_AI_SYSTEM_OPENAI)
+ span.set_attribute(SemanticConvetion.GEN_AI_TYPE,
+ SemanticConvetion.GEN_AI_TYPE_EMBEDDING)
+ span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ gen_ai_endpoint)
+ span.set_attribute(SemanticConvetion.GEN_AI_ENVIRONMENT,
+ environment)
+ span.set_attribute(SemanticConvetion.GEN_AI_APPLICATION_NAME,
+ application_name)
+ span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ kwargs.get("model", "text-embedding-ada-002"))
+ span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_EMBEDDING_FORMAT,
+ kwargs.get("encoding_format", "float"))
+ # span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_EMBEDDING_DIMENSION,
+ # kwargs.get("dimensions", "null"))
+ span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ kwargs.get("user", ""))
+ span.set_attribute(SemanticConvetion.GEN_AI_USAGE_PROMPT_TOKENS,
+ response_dict.get('usage').get('prompt_tokens'))
+ span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ response_dict.get('usage').get('total_tokens'))
+ span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ cost)
+ if trace_content:
+ span.add_event(
+ name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ attributes={
+ SemanticConvetion.GEN_AI_CONTENT_PROMPT: kwargs.get("input", ""),
+ },
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ if disable_metrics is False:
+ attributes = {
+ TELEMETRY_SDK_NAME:
+ "openlit",
+ SemanticConvetion.GEN_AI_APPLICATION_NAME:
+ application_name,
+ SemanticConvetion.GEN_AI_SYSTEM:
+ SemanticConvetion.GEN_AI_SYSTEM_OPENAI,
+ SemanticConvetion.GEN_AI_ENVIRONMENT:
+ environment,
+ SemanticConvetion.GEN_AI_TYPE:
+ SemanticConvetion.GEN_AI_TYPE_EMBEDDING,
+ SemanticConvetion.GEN_AI_REQUEST_MODEL:
+ kwargs.get("model", "text-embedding-ada-002")
+ }
+
+ metrics["genai_requests"].add(1, attributes)
+ metrics["genai_total_tokens"].add(
+ response_dict.get('usage').get('total_tokens'), attributes)
+ metrics["genai_prompt_tokens"].add(
+ response_dict.get('usage').get('prompt_tokens'), attributes)
+ metrics["genai_cost"].record(cost, attributes)
+
+ # 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/instrumentation/openai/async_openai.py b/sdk/python/src/openlit/instrumentation/openai/async_openai.py
index dc1e536f..168cc529 100644
--- a/sdk/python/src/openlit/instrumentation/openai/async_openai.py
+++ b/sdk/python/src/openlit/instrumentation/openai/async_openai.py
@@ -446,11 +446,11 @@ def async_embedding(gen_ai_endpoint, version, environment, application_name,
with tracer.start_as_current_span(gen_ai_endpoint, kind= SpanKind.CLIENT) as span:
response = await wrapped(*args, **kwargs)
-
+ response_dict = response_as_dict(response)
try:
# Calculate cost of the operation
cost = get_embed_model_cost(kwargs.get("model", "text-embedding-ada-002"),
- pricing_info, response.usage.prompt_tokens)
+ pricing_info, response_dict.get('usage').get('prompt_tokens'))
# Set Span attributes
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
@@ -473,9 +473,9 @@ def async_embedding(gen_ai_endpoint, version, environment, application_name,
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
kwargs.get("user", ""))
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_PROMPT_TOKENS,
- response.usage.prompt_tokens)
+ response_dict.get('usage').get('prompt_tokens'))
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
- response.usage.total_tokens)
+ response_dict.get('usage').get('total_tokens'))
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
cost)
if trace_content:
@@ -505,8 +505,10 @@ def async_embedding(gen_ai_endpoint, version, environment, application_name,
}
metrics["genai_requests"].add(1, attributes)
- metrics["genai_total_tokens"].add(response.usage.total_tokens, attributes)
- metrics["genai_prompt_tokens"].add(response.usage.prompt_tokens, attributes)
+ metrics["genai_total_tokens"].add(
+ response_dict.get('usage').get('total_tokens'), attributes)
+ metrics["genai_prompt_tokens"].add(
+ response_dict.get('usage').get('prompt_tokens'), attributes)
metrics["genai_cost"].record(cost, attributes)
# Return original response
diff --git a/sdk/python/src/openlit/instrumentation/openai/openai.py b/sdk/python/src/openlit/instrumentation/openai/openai.py
index 4f874b2b..ec1ee010 100644
--- a/sdk/python/src/openlit/instrumentation/openai/openai.py
+++ b/sdk/python/src/openlit/instrumentation/openai/openai.py
@@ -446,11 +446,11 @@ def embedding(gen_ai_endpoint, version, environment, application_name,
with tracer.start_as_current_span(gen_ai_endpoint, kind= SpanKind.CLIENT) as span:
response = wrapped(*args, **kwargs)
-
+ response_dict = response_as_dict(response)
try:
# Calculate cost of the operation
cost = get_embed_model_cost(kwargs.get("model", "text-embedding-ada-002"),
- pricing_info, response.usage.prompt_tokens)
+ pricing_info, response_dict.get('usage').get('prompt_tokens'))
# Set Span attributes
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
@@ -473,9 +473,9 @@ def embedding(gen_ai_endpoint, version, environment, application_name,
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
kwargs.get("user", ""))
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_PROMPT_TOKENS,
- response.usage.prompt_tokens)
+ response_dict.get('usage').get('prompt_tokens'))
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
- response.usage.total_tokens)
+ response_dict.get('usage').get('total_tokens'))
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
cost)
if trace_content:
@@ -505,8 +505,10 @@ def embedding(gen_ai_endpoint, version, environment, application_name,
}
metrics["genai_requests"].add(1, attributes)
- metrics["genai_total_tokens"].add(response.usage.total_tokens, attributes)
- metrics["genai_prompt_tokens"].add(response.usage.prompt_tokens, attributes)
+ metrics["genai_total_tokens"].add(
+ response_dict.get('usage').get('total_tokens'), attributes)
+ metrics["genai_prompt_tokens"].add(
+ response_dict.get('usage').get('prompt_tokens'), attributes)
metrics["genai_cost"].record(cost, attributes)
# Return original response