Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.
TypeScript agent-harnessagent-harness-engineeringai-engineeringai-observabilityamd-gpuclaude-codeclickhousecodexcoding-agentcoding-agentscursorgenaigpu-monitoringllm-observabilityllmopsnvidia-smiobservabilityopen-sourceopenaiopentelemetry
[Feat]: Add OpenTelemetry Monitoring Instrumentation for browser-use (#847)
Patcher84a933d88289
diff --git a/docs/images/docs-browser-use-banner.gif b/docs/images/docs-browser-use-banner.gifnew file mode 100644index 00000000..dfcbfc48Binary files /dev/null and b/docs/images/docs-browser-use-banner.gif differdiff --git a/docs/latest/integrations/browser-use.mdx b/docs/latest/integrations/browser-use.mdxnew file mode 100644index 00000000..a4015ed7--- /dev/null+++ b/docs/latest/integrations/browser-use.mdx@@ -0,0 +1,78 @@+---+title: 'Monitor Browser Use using OpenTelemetry'+sidebarTitle: 'Browser Use'+---++<Frame>+ <img src="/images/docs-browser-use-banner.gif" />+</Frame>++OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor browser agents built using Browser Use. 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.++The integration is compatible with+- Browser Use Python SDK client `>= 0.5.7`++## 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 filediff --git a/docs/latest/integrations/introduction.mdx b/docs/latest/integrations/introduction.mdxindex 83d44e32..963b5ff5 100644--- a/docs/latest/integrations/introduction.mdx+++ b/docs/latest/integrations/introduction.mdx@@ -2240,6 +2240,20 @@ Start integrating and monitoring your applications with OpenLIT in just one line}></Card>+ <Card+ title="Browser Use"+ href="/latest/integrations/browser-use"+ iconType="duotone"+ icon={+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 420 420">+ <path d="M0 0 C1.12921875 -0.01224609 2.2584375 -0.02449219 3.421875 -0.03710938 C20.34465245 -0.06615304 36.53800272 3.41471569 51.625 11.1875 C52.43195313 11.59355469 53.23890625 11.99960937 54.0703125 12.41796875 C63.90462405 17.80944823 72.89336139 26.22857246 79.625 35.1875 C79.625 36.1775 79.625 37.1675 79.625 38.1875 C80.285 38.1875 80.945 38.1875 81.625 38.1875 C90.42583164 55.03659811 90.42583164 55.03659811 92.625 64.1875 C92.88925781 65.15171875 93.15351563 66.1159375 93.42578125 67.109375 C98.17403242 84.84218032 97.44820526 103.17616516 94.625 121.1875 C94.43967752 122.5207741 94.2547866 123.85410825 94.0703125 125.1875 C92.23957156 137.53507564 89.22954173 150.97841654 83.625 162.1875 C81.796875 161.9609375 81.796875 161.9609375 79.625 161.1875 C78.140625 159.2265625 78.140625 159.2265625 76.875 156.8125 C76.44703125 156.02101562 76.0190625 155.22953125 75.578125 154.4140625 C74.625 152.1875 74.625 152.1875 74.625 149.1875 C73.965 149.1875 73.305 149.1875 72.625 149.1875 C72.22667969 148.43984375 71.82835937 147.6921875 71.41796875 146.921875 C70.88816406 145.93703125 70.35835938 144.9521875 69.8125 143.9375 C69.29042969 142.96296875 68.76835937 141.9884375 68.23046875 140.984375 C66.71744481 138.20957169 66.71744481 138.20957169 64.92578125 135.953125 C63.625 134.1875 63.625 134.1875 63.625 132.1875 C62.965 132.1875 62.305 132.1875 61.625 132.1875 C60.60932193 130.53034104 59.61494188 128.86016041 58.625 127.1875 C58.02429688 126.62546875 57.42359375 126.0634375 56.8046875 125.484375 C53.98768254 122.67841711 51.75006274 120.27954951 51.50292969 116.14550781 C51.69997216 112.24339324 52.28337453 108.43721677 52.94140625 104.58984375 C54.13726738 97.53580613 53.65426928 90.8839769 52.375 83.875 C52.1725769 82.76523804 52.1725769 82.76523804 51.96606445 81.63305664 C50.08087321 71.82258548 47.2432924 63.80306934 40.625 56.1875 C40.026875 55.465625 39.42875 54.74375 38.8125 54 C28.17005785 45.1819765 14.51795592 42.98545356 1.0625 43 C-0.11723389 43.0012085 -0.11723389 43.0012085 -1.32080078 43.00244141 C-8.45940326 43.0762142 -15.34665838 43.95258531 -22.375 45.1875 C-23.25679932 45.31302246 -24.13859863 45.43854492 -25.04711914 45.56787109 C-32.38819814 46.65936188 -39.09438499 48.53462011 -46.0625 51.0625 C-47.02994141 51.40152344 -47.99738281 51.74054688 -48.99414062 52.08984375 C-71.94171857 60.24003011 -93.10144912 72.73350244 -112.95703125 86.69921875 C-113.54830811 87.11389404 -114.13958496 87.52856934 -114.7487793 87.95581055 C-116.42178528 89.13248909 -118.08992385 90.31607904 -119.7578125 91.5 C-122.375 93.1875 -122.375 93.1875 -124.375 93.1875 C-124.705 94.1775 -125.035 95.1675 -125.375 96.1875 C-126.96875 97.50390625 -126.96875 97.50390625 -128.875 98.75 C-131.63036594 100.50369395 -131.63036594 100.50369395 -133.375 103.1875 C-134.365 103.1875 -135.355 103.1875 -136.375 103.1875 C-136.375 103.8475 -136.375 104.5075 -136.375 105.1875 C-137.035 105.1875 -137.695 105.1875 -138.375 105.1875 C-138.705 106.1775 -139.035 107.1675 -139.375 108.1875 C-141.15234375 110.01171875 -141.15234375 110.01171875 -143.3125 111.875 C-144.37791016 112.80892578 -144.37791016 112.80892578 -145.46484375 113.76171875 C-147.375 115.1875 -147.375 115.1875 -149.375 115.1875 C-149.601875 115.765 -149.82875 116.3425 -150.0625 116.9375 C-151.70988275 119.76158471 -153.80954838 121.1851963 -156.375 123.1875 C-157.2103125 124.30125 -157.2103125 124.30125 -158.0625 125.4375 C-158.495625 126.015 -158.92875 126.5925 -159.375 127.1875 C-160.035 127.1875 -160.695 127.1875 -161.375 127.1875 C-161.643125 127.77015625 -161.91125 128.3528125 -162.1875 128.953125 C-163.38980991 131.21536601 -164.71325913 132.99326318 -166.375 134.9375 C-166.890625 135.55109375 -167.40625 136.1646875 -167.9375 136.796875 C-169.375 138.1875 -169.375 138.1875 -171.375 138.1875 C-171.375 138.8475 -171.375 139.5075 -171.375 140.1875 C-172.035 140.1875 -172.695 140.1875 -173.375 140.1875 C-173.375 141.1775 -173.375 142.1675 -173.375 143.1875 C-174.9972454 144.89743434 -176.66913425 146.56097684 -178.375 148.1875 C-178.931875 148.950625 -179.48875 149.71375 -180.0625 150.5 C-180.495625 151.056875 -180.92875 151.61375 -181.375 152.1875 C-182.035 152.1875 -182.695 152.1875 -183.375 152.1875 C-183.61476563 152.88617188 -183.85453125 153.58484375 -184.1015625 154.3046875 C-185.5810061 157.65385736 -187.5703647 160.40122402 -189.75 163.3125 C-199.19037751 176.25650473 -207.53245217 189.70054326 -214.375 204.1875 C-215.00863965 205.41821339 -215.64278957 206.64866414 -216.27734375 207.87890625 C-222.42027548 220.13117783 -227.85386639 233.69943517 -230.375 247.1875 C-230.63796875 248.47269531 -230.9009375 249.75789062 -231.171875 251.08203125 C-235.08048294 270.86707587 -237.02845729 293.45396463 -225.9609375 311.4921875 C-223.19536577 315.36398792 -220.29456951 318.44380134 -216.375 321.1875 C-215.55 321.8475 -214.725 322.5075 -213.875 323.1875 C-204.46279652 329.35663855 -192.21900377 330.3805109 -181.25 330.3125 C-180.52006836 330.3127417 -179.79013672 330.3129834 -179.03808594 330.31323242 C-173.08293853 330.2802632 -167.24498977 329.80732107 -161.328125 329.11328125 C-157.81836946 329.20148939 -156.12309171 330.04500628 -153.375 332.1875 C-153.375 332.8475 -153.375 333.5075 -153.375 334.1875 C-152.83875 334.435 -152.3025 334.6825 -151.75 334.9375 C-149.46051778 336.14249064 -147.36622043 337.5150396 -145.234375 338.9765625 C-142.02616346 341.06594397 -138.67801807 342.92648971 -135.3515625 344.8203125 C-134.69929687 345.27148438 -134.04703125 345.72265625 -133.375 346.1875 C-133.375 346.8475 -133.375 347.5075 -133.375 348.1875 C-132.199375 348.496875 -132.199375 348.496875 -131 348.8125 C-124.27236134 351.36436294 -118.31441164 354.92941664 -113.375 360.1875 C-124.44719215 364.18963612 -135.4605295 367.66904087 -147 370.0625 C-147.969375 370.26512451 -148.93875 370.46774902 -149.9375 370.67651367 C-167.70240322 374.20059593 -187.63626118 375.20338524 -205.375 371.1875 C-206.54675781 370.93097656 -207.71851563 370.67445313 -208.92578125 370.41015625 C-222.37149684 367.15693534 -234.88727442 362.39845899 -245.375 353.1875 C-246.11234375 352.66671875 -246.8496875 352.1459375 -247.609375 351.609375 C-248.19203125 351.14015625 -248.7746875 350.6709375 -249.375 350.1875 C-249.375 349.5275 -249.375 348.8675 -249.375 348.1875 C-250.24125 347.8471875 -250.24125 347.8471875 -251.125 347.5 C-253.97239809 345.83901778 -255.49567193 343.87225439 -257.375 341.1875 C-257.375 340.5275 -257.375 339.8675 -257.375 339.1875 C-258.365 338.8575 -259.355 338.5275 -260.375 338.1875 C-260.705 336.5375 -261.035 334.8875 -261.375 333.1875 C-262.035 333.1875 -262.695 333.1875 -263.375 333.1875 C-281.42894971 297.38634244 -280.30657214 259.8466876 -268.41308594 222.13769531 C-263.73747599 208.0060899 -258.15615982 194.43272551 -251.375 181.1875 C-250.98779785 180.42937012 -250.6005957 179.67124023 -250.20166016 178.89013672 C-239.97705204 158.99417272 -239.97705204 158.99417272 -236.375 154.1875 C-235.715 154.1875 -235.055 154.1875 -234.375 154.1875 C-234.1275 153.506875 -233.88 152.82625 -233.625 152.125 C-232.13302092 148.61884917 -230.30664489 145.47129632 -228.375 142.1875 C-227.715 142.1875 -227.055 142.1875 -226.375 142.1875 C-226.14554688 141.4965625 -225.91609375 140.805625 -225.6796875 140.09375 C-224.09092864 136.5547183 -221.89815694 133.70092753 -219.5 130.6875 C-219.06558594 130.13191406 -218.63117188 129.57632813 -218.18359375 129.00390625 C-217.32784888 127.91173937 -216.46760611 126.82307929 -215.60253906 125.73828125 C-214.43991216 124.26950517 -213.30876422 122.77597079 -212.1796875 121.28125 C-211.58414063 120.5903125 -210.98859375 119.899375 -210.375 119.1875 C-209.715 119.1875 -209.055 119.1875 -208.375 119.1875 C-208.271875 118.548125 -208.16875 117.90875 -208.0625 117.25 C-207.835625 116.569375 -207.60875 115.88875 -207.375 115.1875 C-206.385 114.8575 -205.395 114.5275 -204.375 114.1875 C-204.045 113.3625 -203.715 112.5375 -203.375 111.6875 C-203.045 110.8625 -202.715 110.0375 -202.375 109.1875 C-201.385 108.8575 -200.395 108.5275 -199.375 108.1875 C-198.65960355 106.87966586 -197.99845927 105.54157561 -197.375 104.1875 C-196.41619966 102.90562563 -195.41506043 101.6543707 -194.375 100.4375 C-193.859375 99.82390625 -193.34375 99.2103125 -192.8125 98.578125 C-191.375 97.1875 -191.375 97.1875 -189.375 97.1875 C-189.375 96.5275 -189.375 95.8675 -189.375 95.1875 C-188.715 95.1875 -188.055 95.1875 -187.375 95.1875 C-187.375 94.5275 -187.375 93.8675 -187.375 93.1875 C-186.715 93.1875 -186.055 93.1875 -185.375 93.1875 C-185.375 92.5275 -185.375 91.8675 -185.375 91.1875 C-184.715 91.1875 -184.055 91.1875 -183.375 91.1875 C-183.375 90.5275 -183.375 89.8675 -183.375 89.1875 C-182.715 89.1875 -182.055 89.1875 -181.375 89.1875 C-181.375 88.5275 -181.375 87.8675 -181.375 87.1875 C-180.715 87.1875 -180.055 87.1875 -179.375 87.1875 C-179.375 86.5275 -179.375 85.8675 -179.375 85.1875 C-177.73046875 83.49609375 -177.73046875 83.49609375 -175.5625 81.625 C-174.85480469 81.00496094 -174.14710938 80.38492188 -173.41796875 79.74609375 C-171.375 78.1875 -171.375 78.1875 -168.375 77.1875 C-167.88 75.7025 -167.88 75.7025 -167.375 74.1875 C-166.570625 73.878125 -165.76625 73.56875 -164.9375 73.25 C-162.25866446 72.47055221 -162.25866446 72.47055221 -161.46484375 70.32421875 C-160.15035298 67.74706301 -158.70189507 66.63134273 -156.375 64.9375 C-155.323125 64.15632813 -155.323125 64.15632813 -154.25 63.359375 C-152.375 62.1875 -152.375 62.1875 -150.375 62.1875 C-150.375 61.5275 -150.375 60.8675 -150.375 60.1875 C-148.725 59.5275 -147.075 58.8675 -145.375 58.1875 C-145.375 57.5275 -145.375 56.8675 -145.375 56.1875 C-144.385 56.1875 -143.395 56.1875 -142.375 56.1875 C-142.375 55.5275 -142.375 54.8675 -142.375 54.1875 C-140.75439453 52.85888672 -140.75439453 52.85888672 -138.5078125 51.3671875 C-137.70472656 50.83222656 -136.90164062 50.29726562 -136.07421875 49.74609375 C-134.79998047 48.91271484 -134.79998047 48.91271484 -133.5 48.0625 C-132.65824219 47.49917969 -131.81648437 46.93585938 -130.94921875 46.35546875 C-124.64175999 42.1875 -124.64175999 42.1875 -122.375 42.1875 C-122.375 41.5275 -122.375 40.8675 -122.375 40.1875 C-120.10854942 38.84619239 -117.83739903 37.51433766 -115.5625 36.1875 C-114.91990234 35.8059375 -114.27730469 35.424375 -113.61523438 35.03125 C-108.71484375 32.1875 -108.71484375 32.1875 -105.375 32.1875 C-105.375 31.5275 -105.375 30.8675 -105.375 30.1875 C-104.59020264 29.81782104 -104.59020264 29.81782104 -103.78955078 29.44067383 C-101.35913299 28.29498184 -98.92952053 27.14759343 -96.5 26 C-95.624646 25.5872583 -94.74929199 25.1745166 -93.84741211 24.74926758 C-89.50366552 22.69476554 -85.19451264 20.60519773 -80.9375 18.375 C-76.57987687 16.16196626 -72.08854783 14.63800112 -67.4296875 13.1796875 C-65.09591854 12.42166024 -62.8336038 11.60793521 -60.546875 10.7265625 C-56.34256874 9.13388643 -52.08476033 7.87250829 -47.75 6.6875 C-46.57812134 6.36604004 -46.57812134 6.36604004 -45.38256836 6.03808594 C-30.19153159 1.93013962 -15.75221391 0.00892983 0 0 Z " transform="translate(320.375,43.8125)"/>+ <path d="M0 0 C2.44234509 1.44076936 3.9839103 2.93473738 6 5 C6 5.66 6 6.32 6 7 C7.2065625 7.4021875 7.2065625 7.4021875 8.4375 7.8125 C9.283125 8.204375 10.12875 8.59625 11 9 C11.33 9.99 11.66 10.98 12 12 C13.31161414 12.70844235 14.64938718 13.3690743 16 14 C17.43090825 15.10171971 18.82668139 16.25029427 20.1875 17.4375 C20.88230469 18.03433594 21.57710937 18.63117188 22.29296875 19.24609375 C24 21 24 21 25 24 C27.00016466 25.20882096 27.00016466 25.20882096 29 26 C29 26.66 29 27.32 29 28 C29.66 28 30.32 28 31 28 C31 28.66 31 29.32 31 30 C31.66 30 32.32 30 33 30 C33 30.66 33 31.32 33 32 C33.66 32 34.32 32 35 32 C36.37073786 33.63604196 37.70055256 35.30678061 39 37 C39.99460928 38.00536181 40.99496231 39.00506319 42 40 C43.62142425 41.79305133 45.20225901 43.61812034 46.78515625 45.4453125 C48.45020416 47.36584395 50.12555344 49.27506098 51.80859375 51.1796875 C70 71.90997494 70 71.90997494 70 77 C70.66 77 71.32 77 72 77 C73.41015625 78.87890625 73.41015625 78.87890625 75.0625 81.5625 C75.68382812 82.56796875 76.30515625 83.5734375 76.9453125 84.609375 C77.62335938 85.72828125 78.30140625 86.8471875 79 88 C79.53318848 88.87495117 79.53318848 88.87495117 80.07714844 89.76757812 C82.37082518 93.53416509 84.63630291 97.31653916 86.88134766 101.11230469 C87.60672939 102.33636657 88.33537684 103.55850135 89.06787109 104.77832031 C94.19513327 113.32456154 98.4062106 121.9799681 102.23144531 131.16601562 C102.91621998 132.80007766 103.62448001 134.42425265 104.3359375 136.046875 C107.87364725 144.20388728 110.6400062 152.59596705 113.36108398 161.05249023 C113.89152842 162.66936271 114.46394746 164.27239322 115.046875 165.87109375 C116.42959663 170.41027419 117.22921154 175.02045094 118.0625 179.6875 C118.23587891 180.61755859 118.40925781 181.54761719 118.58789062 182.50585938 C124.36448639 214.44313022 120.49706405 244.75060271 104 273 C103.34 273 102.68 273 102 273 C101.6596875 273.8353125 101.6596875 273.8353125 101.3125 274.6875 C99.62622733 277.65855185 97.469646 279.64522125 95 282 C93.7315625 283.3303125 93.7315625 283.3303125 92.4375 284.6875 C90.30387276 286.71171046 88.69176935 287.90335323 86 289 C86 289.66 86 290.32 86 291 C83.90625 292.40234375 83.90625 292.40234375 81 294 C79.43765625 294.86818359 79.43765625 294.86818359 77.84375 295.75390625 C76.7403125 296.35074219 75.636875 296.94757813 74.5 297.5625 C72.84484375 298.46162109 72.84484375 298.46162109 71.15625 299.37890625 C65.8477999 302.1053998 60.61165149 303.7043728 54.8125 305.0625 C54.10802734 305.23587891 53.40355469 305.40925781 52.67773438 305.58789062 C35.10117729 309.7394575 15.68010294 309.1912219 -2 306 C-2.72123047 305.88172852 -3.44246094 305.76345703 -4.18554688 305.64160156 C-23.91503806 302.39194103 -43.11258486 296.22837273 -60.8828125 287.02734375 C-62.56812982 286.20956062 -64.29274452 285.47289385 -66.02734375 284.765625 C-71.35998624 282.50223663 -76.37217631 279.61045694 -81.4375 276.8125 C-82.45521484 276.25369141 -83.47292969 275.69488281 -84.52148438 275.11914062 C-87.01591765 273.74895897 -89.50868824 272.3758466 -92 271 C-92 270.34 -92 269.68 -92 269 C-92.83789062 268.76796875 -93.67578125 268.5359375 -94.5390625 268.296875 C-98.60299731 266.77404615 -101.81963902 264.70021255 -105.375 262.25 C-106.37333862 261.57239624 -106.37333862 261.57239624 -107.3918457 260.88110352 C-111.3142913 258.20389398 -115.19262311 255.4812074 -118.94921875 252.57421875 C-120.66172254 251.25966822 -122.4001709 249.97900582 -124.14453125 248.70703125 C-124.97464722 248.09903687 -124.97464722 248.09903687 -125.8215332 247.47875977 C-127.43092692 246.30056652 -129.04351905 245.12674604 -130.65625 243.953125 C-131.4296875 243.30859375 -132.203125 242.6640625 -133 242 C-133 241.34 -133 240.68 -133 240 C-133.721875 239.773125 -134.44375 239.54625 -135.1875 239.3125 C-138.57700303 237.73073192 -140.42464097 235.7009863 -143 233 C-144.09443009 232.09229732 -145.19864732 231.19626105 -146.3125 230.3125 C-147.199375 229.549375 -148.08625 228.78625 -149 228 C-149 227.34 -149 226.68 -149 226 C-149.66 226 -150.32 226 -151 226 C-151 225.34 -151 224.68 -151 224 C-151.66 224 -152.32 224 -153 224 C-153 223.34 -153 222.68 -153 222 C-153.57878906 221.74863281 -154.15757812 221.49726563 -154.75390625 221.23828125 C-157.28283677 219.84407086 -158.9343046 218.26209642 -160.9375 216.1875 C-161.63101563 215.4759375 -162.32453125 214.764375 -163.0390625 214.03125 C-163.68617188 213.3609375 -164.33328125 212.690625 -165 212 C-165.928125 211.071875 -166.85625 210.14375 -167.8125 209.1875 C-168.534375 208.465625 -169.25625 207.74375 -170 207 C-170.598125 206.443125 -171.19625 205.88625 -171.8125 205.3125 C-173 204 -173 204 -173 202 C-173.66 202 -174.32 202 -175 202 C-176.40234375 200.35546875 -176.40234375 200.35546875 -177.9375 198.1875 C-180.4584532 194.6478496 -183.11875241 191.80979509 -186.3125 188.875 C-188.16136067 185.72508923 -188.20178626 185.31217652 -187.5 181.9375 C-187.03143268 180.2824435 -186.52829496 178.63697031 -186 177 C-185.57267578 175.60007812 -185.57267578 175.60007812 -185.13671875 174.171875 C-181.46218488 162.61901953 -176.5522149 151.76099382 -171 141 C-168 141 -168 141 -166.60888672 142.38598633 C-166.13725098 143.02818115 -165.66561523 143.67037598 -165.1796875 144.33203125 C-164.64915771 145.04262695 -164.11862793 145.75322266 -163.57202148 146.48535156 C-163.01200439 147.25331055 -162.4519873 148.02126953 -161.875 148.8125 C-160.69786632 150.38765496 -159.5194797 151.96187437 -158.33984375 153.53515625 C-157.7660498 154.3048877 -157.19225586 155.07461914 -156.60107422 155.86767578 C-149.23310865 165.68039479 -141.08189996 175.30655869 -132.1484375 183.75 C-131 185 -131 185 -131 187 C-130.195625 187.3403125 -130.195625 187.3403125 -129.375 187.6875 C-124.16951726 190.56421415 -120.16897477 194.83102523 -116 199 C-113.87193426 200.83371646 -111.73192438 202.650466 -109.57421875 204.44921875 C-109.05472656 204.96097656 -108.53523438 205.47273437 -108 206 C-108 206.66 -108 207.32 -108 208 C-106.35 208.66 -104.7 209.32 -103 210 C-103 210.66 -103 211.32 -103 212 C-102.26523438 212.2578125 -101.53046875 212.515625 -100.7734375 212.78125 C-97.89212983 214.0474021 -96.00799982 215.4598177 -93.625 217.5 C-89.32055978 221.03532853 -84.87937842 224.22548887 -80.25 227.3125 C-79.31148193 227.94285156 -79.31148193 227.94285156 -78.35400391 228.5859375 C-74.68396848 231.01118269 -70.98422576 233.11177031 -67 235 C-67 235.66 -67 236.32 -67 237 C-65.54787109 237.34804688 -65.54787109 237.34804688 -64.06640625 237.703125 C-59.33572451 239.05712379 -55.23002472 241.38830544 -50.9375 243.75 C-23.06091852 258.65502381 12.12676839 270.94317128 44 263 C44.83789062 262.81695312 45.67578125 262.63390625 46.5390625 262.4453125 C56.68044029 259.90211869 64.87064868 253.79544902 70.30078125 244.859375 C82.56320654 222.43252049 78.00988392 195.92934054 71.38671875 172.54296875 C69.30698807 165.54453358 66.71984122 158.77051385 64 152 C63.60039062 150.95457031 63.20078125 149.90914062 62.7890625 148.83203125 C60.09666721 141.99262443 56.69289223 135.69754096 52.97265625 129.37890625 C51.23941868 126.41009338 49.60489125 123.41423547 48 120.375 C45.19038721 115.15160384 41.9199499 110.30232486 38.5390625 105.43359375 C37 103 37 103 37 101 C36.34 101 35.68 101 35 101 C34.34 99.02 33.68 97.04 33 95 C32.34 95 31.68 95 31 95 C29.50047084 93.15283932 28.07478913 91.24537846 26.6875 89.3125 C24.33190003 86.03705625 22.10763438 83.10432256 19.20703125 80.29296875 C17 78 17 78 17 75 C16.34 75 15.68 75 15 75 C15 74.34 15 73.68 15 73 C14.01 72.67 13.02 72.34 12 72 C10.47988374 70.30339084 9.02984854 68.54321964 7.625 66.75 C2.88474613 60.72287309 -2.42411873 55.53819694 -8.0625 50.375 C-8.57876953 49.89804688 -9.09503906 49.42109375 -9.62695312 48.9296875 C-11.80789588 46.92933236 -13.96953866 45.02198034 -16.37109375 43.2890625 C-16.90863281 42.86367187 -17.44617188 42.43828125 -18 42 C-18 41.34 -18 40.68 -18 40 C-18.66 40 -19.32 40 -20 40 C-20 39.34 -20 38.68 -20 38 C-20.53367187 37.76667969 -21.06734375 37.53335938 -21.6171875 37.29296875 C-24.7080033 35.61582116 -27.37600809 33.48593312 -30.125 31.3125 C-35.62434216 27.01777565 -41.23311307 22.93137664 -47 19 C-46 16 -46 16 -42.78125 14.16796875 C-41.3603081 13.49469523 -39.93267353 12.83543492 -38.5 12.1875 C-37.7462207 11.83929199 -36.99244141 11.49108398 -36.21582031 11.13232422 C-29.48512301 8.08775062 -22.6077482 5.57773759 -15.609375 3.2265625 C-13.46241887 2.49696918 -11.32819021 1.72426425 -9.23046875 0.86328125 C-5.93094469 -0.41376747 -3.50651266 -0.43062436 0 0 Z " transform="translate(296,109)"/>+ <path d="M0 0 C-13.16446195 8.64818668 -13.16446195 8.64818668 -19.875 12.1875 C-24.6385276 14.72202999 -28.76501897 17.67644346 -33 21 C-34.88690143 22.44920435 -36.78322552 23.88620095 -38.6875 25.3125 C-39.57824219 25.98925781 -40.46898437 26.66601562 -41.38671875 27.36328125 C-46.2651024 30.41865158 -50.10719935 29.97946277 -55.60009766 29.27539062 C-71.42983151 27.45891659 -85.94884315 30.11010803 -101 35 C-101 35.66 -101 36.32 -101 37 C-102.66666667 38 -104.33333333 39 -106 40 C-109.8359041 43.44444695 -109.8359041 43.44444695 -112 48 C-112.66 48 -113.32 48 -114 48 C-114.29003906 48.97839844 -114.29003906 48.97839844 -114.5859375 49.9765625 C-114.84632812 50.85054688 -115.10671875 51.72453125 -115.375 52.625 C-115.63023438 53.48351562 -115.88546875 54.34203125 -116.1484375 55.2265625 C-116.73060821 57.12262307 -117.36077503 59.00443048 -118.03125 60.87109375 C-119.12203179 64.394143 -119.65340843 67.78079397 -120.125 71.4375 C-120.29257813 72.69433594 -120.46015625 73.95117188 -120.6328125 75.24609375 C-121.3810117 82.89523666 -120.59645982 89.9700597 -119.359375 97.50390625 C-118.57465342 103.32065498 -118.57465342 103.32065498 -120.6484375 106.6328125 C-121.81246094 107.80457031 -121.81246094 107.80457031 -123 109 C-123.80811037 110.06392235 -124.59622678 111.14323215 -125.3671875 112.234375 C-125.77525635 112.80438232 -126.1833252 113.37438965 -126.60375977 113.96166992 C-127.02326904 114.55181885 -127.44277832 115.14196777 -127.875 115.75 C-128.31191162 116.36399658 -128.74882324 116.97799316 -129.19897461 117.6105957 C-135.47744379 125.83820717 -135.47744379 125.83820717 -140 135 C-140.66 135 -141.32 135 -142 135 C-142.226875 135.825 -142.45375 136.65 -142.6875 137.5 C-144.27426232 141.73136618 -146.50748237 145.25171013 -149 149 C-151.34032619 146.8965867 -152.50259837 145.24317372 -153.46484375 142.25390625 C-153.70557617 141.50931152 -153.94630859 140.7647168 -154.19433594 139.99755859 C-154.43958008 139.19398926 -154.68482422 138.39041992 -154.9375 137.5625 C-155.32663574 136.30300537 -155.32663574 136.30300537 -155.72363281 135.01806641 C-163.47240562 109.14561495 -166.47794103 82.69825424 -161.39697266 56.08447266 C-161.05790558 54.30405769 -160.75029366 52.51770064 -160.44921875 50.73046875 C-156.69840052 32.07844067 -143.01437667 13.18718262 -128 2 C-125.0625 1.125 -125.0625 1.125 -123 1 C-123 0.34 -123 -0.32 -123 -1 C-114.88122545 -5.38852678 -106.90015903 -8.57587774 -98 -11 C-97.2471875 -11.21527344 -96.494375 -11.43054687 -95.71875 -11.65234375 C-71.26582676 -18.29926931 -20.88489154 -17.185004 0 0 Z " transform="translate(207,58)"/>+ <path d="M0 0 C8.35771629 7.22147088 12.07396272 21.78499511 15.35986328 32.01953125 C15.95302845 33.85467841 16.58243251 35.67800492 17.21484375 37.5 C19.47237291 44.75310574 19.47237291 44.75310574 18.1328125 48.2890625 C16.8125 50.25 16.8125 50.25 14 53 C13.34 53 12.68 53 12 53 C12 53.66 12 54.32 12 55 C11.34 55 10.68 55 10 55 C9.63841797 55.83724609 9.63841797 55.83724609 9.26953125 56.69140625 C7.73113421 59.48892209 5.84438036 61.58486915 3.6875 63.9375 C2.47513672 65.26201172 2.47513672 65.26201172 1.23828125 66.61328125 C-1.12239939 69.13051662 -3.55995284 71.55995284 -6 74 C-7.04330333 75.2486343 -8.08478191 76.49879428 -9.125 77.75 C-12.83711825 82.0590007 -17.09179634 85.5040013 -21.546875 89.01953125 C-23.95253958 90.87874936 -23.95253958 90.87874936 -25.703125 92.76171875 C-27 94 -27 94 -29 94 C-29 94.66 -29 95.32 -29 96 C-29.66 96 -30.32 96 -31 96 C-31 96.66 -31 97.32 -31 98 C-34.22965359 101.47187761 -35.63898885 102.95050869 -40.4375 103.125 C-55.66471357 100.0387961 -70.30684837 93.06508355 -84 86 C-82.48022743 81.7446368 -79.7273812 80.34948673 -76 78 C-74.86965719 77.15455106 -73.74996846 76.29469563 -72.640625 75.421875 C-72.08246094 74.98359375 -71.52429688 74.5453125 -70.94921875 74.09375 C-69.79918916 73.18430131 -68.65079527 72.27278102 -67.50390625 71.359375 C-63.21470424 68 -63.21470424 68 -61 68 C-61 67.34 -61 66.68 -61 66 C-60.34 66 -59.68 66 -59 66 C-59 65.34 -59 64.68 -59 64 C-57.34516392 62.50122497 -55.62409488 61.07511527 -53.875 59.6875 C-52.36292969 58.47320312 -52.36292969 58.47320312 -50.8203125 57.234375 C-49.27671844 56.01147222 -47.73165115 54.79038845 -46.1796875 53.578125 C-42.49918775 50.64177001 -39.58082755 47.30115002 -36.61328125 43.671875 C-35 42 -35 42 -32 41 C-31.30678233 39.68027598 -30.64484701 38.34402179 -30 37 C-28.68737754 35.44316871 -27.32754675 33.92561001 -25.9375 32.4375 C-18.69308608 24.51972709 -12.0479867 16.24979264 -5.82421875 7.5078125 C-3.95664347 4.94039637 -2.00077295 2.46452827 0 0 Z " transform="translate(333,249)"/>+ </svg>+ }+ >+ </Card><Cardtitle="Pydantic AI"href="/latest/integrations/pydantic"diff --git a/docs/mint.json b/docs/mint.jsonindex 32559657..914ee7fb 100644--- a/docs/mint.json+++ b/docs/mint.json@@ -162,6 +162,7 @@"latest/integrations/litellm","latest/integrations/crewai","latest/integrations/llama-index",+ "latest/integrations/browser-use","latest/integrations/pydantic","latest/integrations/dspy","latest/integrations/ag2",diff --git a/sdk/python/.pylintrc b/sdk/python/.pylintrcindex 5c19961e..b4acdb09 100644--- a/sdk/python/.pylintrc+++ b/sdk/python/.pylintrc@@ -34,5 +34,6 @@ disable=no-else-return,import-outside-toplevel,too-many-return-statements,- too-many-function-args+ too-many-function-args,+ unnecessary-pass\ No newline at end of filediff --git a/sdk/python/pyproject.toml b/sdk/python/pyproject.tomlindex 208d1d6e..72485f03 100644--- a/sdk/python/pyproject.toml+++ b/sdk/python/pyproject.toml@@ -1,6 +1,6 @@[tool.poetry]name = "openlit"-version = "1.34.41"+version = "1.34.42"description = "OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications and GPUs, facilitating the integration of observability into your GenAI-driven projects"authors = ["OpenLIT"]license = "Apache-2.0"diff --git a/sdk/python/src/openlit/_instrumentors.py b/sdk/python/src/openlit/_instrumentors.pyindex 5c6b9f61..5913d762 100644--- a/sdk/python/src/openlit/_instrumentors.py+++ b/sdk/python/src/openlit/_instrumentors.py@@ -51,6 +51,7 @@ MODULE_NAME_MAP = {"openai-agents": "agents","pydantic_ai": "pydantic_ai","sarvam": "sarvamai",+ "browser-use": "browser_use",}# Dictionary mapping instrumentor names to their full module paths@@ -100,6 +101,7 @@ INSTRUMENTOR_MAP = {"openai-agents": "openlit.instrumentation.openai_agents.OpenAIAgentsInstrumentor","pydantic_ai": "openlit.instrumentation.pydantic_ai.PydanticAIInstrumentor","sarvam": "openlit.instrumentation.sarvam.SarvamInstrumentor",+ "browser-use": "openlit.instrumentation.browser_use.BrowserUseInstrumentor",}diff --git a/sdk/python/src/openlit/instrumentation/browser_use/__init__.py b/sdk/python/src/openlit/instrumentation/browser_use/__init__.pynew file mode 100644index 00000000..ff082b8e--- /dev/null+++ b/sdk/python/src/openlit/instrumentation/browser_use/__init__.py@@ -0,0 +1,168 @@+"""+Module for monitoring Browser-Use browser automation framework.+Supports comprehensive instrumentation of agent operations, browser actions, and task management.+"""++import logging+import importlib.metadata+from typing import Collection+from wrapt import wrap_function_wrapper++from opentelemetry.instrumentation.instrumentor import BaseInstrumentor++from openlit.semcov import SemanticConvention++logger = logging.getLogger(__name__)++_instruments = ("browser-use >= 0.1.0",)+++class BrowserUseInstrumentor(BaseInstrumentor):+ """+ Instrumentor for Browser-Use browser automation framework+ """++ def instrumentation_dependencies(self) -> Collection[str]:+ return _instruments++ def _instrument(self, **kwargs):+ """Instrument Browser-Use operations"""++ # Get configuration+ tracer = kwargs.get("tracer")+ application_name = kwargs.get("application_name", "default_application")+ environment = kwargs.get("environment", "default_environment")+ pricing_info = kwargs.get("pricing_info", {})+ capture_message_content = kwargs.get("capture_message_content", True)+ metrics = kwargs.get("metrics", {})+ disable_metrics = kwargs.get("disable_metrics", False)++ try:+ version = importlib.metadata.version("browser-use")+ except Exception:+ version = "1.0.0"++ # Import the wrapper functions+ from openlit.instrumentation.browser_use.browser_use import general_wrap+ from openlit.instrumentation.browser_use.async_browser_use import (+ async_general_wrap,+ )++ # Instrument Agent async operations+ wrap_function_wrapper(+ "browser_use.agent.service",+ "Agent.run",+ async_general_wrap(+ "agent.run",+ version,+ environment,+ application_name,+ tracer,+ pricing_info,+ capture_message_content,+ metrics,+ disable_metrics,+ ),+ )++ wrap_function_wrapper(+ "browser_use.agent.service",+ "Agent.step",+ async_general_wrap(+ "agent.step",+ version,+ environment,+ application_name,+ tracer,+ pricing_info,+ capture_message_content,+ metrics,+ disable_metrics,+ ),+ )++ # Instrument task management operations+ wrap_function_wrapper(+ "browser_use.agent.service",+ "Agent.pause",+ general_wrap(+ "agent.pause",+ version,+ environment,+ application_name,+ tracer,+ pricing_info,+ capture_message_content,+ metrics,+ disable_metrics,+ ),+ )++ wrap_function_wrapper(+ "browser_use.agent.service",+ "Agent.resume",+ general_wrap(+ "agent.resume",+ version,+ environment,+ application_name,+ tracer,+ pricing_info,+ capture_message_content,+ metrics,+ disable_metrics,+ ),+ )++ wrap_function_wrapper(+ "browser_use.agent.service",+ "Agent.stop",+ general_wrap(+ "agent.stop",+ version,+ environment,+ application_name,+ tracer,+ pricing_info,+ capture_message_content,+ metrics,+ disable_metrics,+ ),+ )++ # Instrument history operations (async methods)+ wrap_function_wrapper(+ "browser_use.agent.service",+ "Agent.rerun_history",+ async_general_wrap(+ "agent.rerun_history",+ version,+ environment,+ application_name,+ tracer,+ pricing_info,+ capture_message_content,+ metrics,+ disable_metrics,+ ),+ )++ wrap_function_wrapper(+ "browser_use.agent.service",+ "Agent.load_and_rerun",+ async_general_wrap(+ "agent.load_and_rerun",+ version,+ environment,+ application_name,+ tracer,+ pricing_info,+ capture_message_content,+ metrics,+ disable_metrics,+ ),+ )++ def _uninstrument(self, **kwargs):+ """Uninstrument Browser-Use operations"""+ passdiff --git a/sdk/python/src/openlit/instrumentation/browser_use/async_browser_use.py b/sdk/python/src/openlit/instrumentation/browser_use/async_browser_use.pynew file mode 100644index 00000000..fa174534--- /dev/null+++ b/sdk/python/src/openlit/instrumentation/browser_use/async_browser_use.py@@ -0,0 +1,880 @@+"""+Module for monitoring Browser-Use asynchronous operations.+Creates detailed spans with agent settings, step-by-step execution, and individual actions.+"""++import asyncio+import json+import logging+import time+from typing import Any, List+from opentelemetry.trace import SpanKind+from opentelemetry import context as context_api++from openlit.__helpers import handle_exception, common_framework_span_attributes+from openlit.instrumentation.browser_use.utils import (+ BrowserUseInstrumentationContext,+ get_operation_name,+ capture_token_and_cost_metrics,+)+from openlit.semcov import SemanticConvention++logger = logging.getLogger(__name__)+++def async_general_wrap(+ gen_ai_endpoint,+ version,+ environment,+ application_name,+ tracer,+ pricing_info,+ capture_message_content,+ metrics,+ disable_metrics,+):+ """+ Enhanced telemetry wrapper for Browser-Use async operations with detailed spans.+ Creates agent settings spans, step-by-step execution tracking, and individual action spans.+ """++ def wrapper(wrapped, instance, args, kwargs):+ """Enhanced wrapper with detailed span creation and step hooks."""++ async def _async_wrapper():+ # Check if instrumentation is suppressed+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):+ return await wrapped(*args, **kwargs)++ operation_name = get_operation_name(gen_ai_endpoint)+ ctx = BrowserUseInstrumentationContext(+ instance, args, kwargs, version, environment, application_name+ )++ # Create enhanced span name+ span_name = _create_enhanced_span_name(operation_name, ctx)++ with tracer.start_as_current_span(+ span_name, kind=SpanKind.CLIENT+ ) as main_span:+ start_time = time.time()++ try:+ # Set enhanced span attributes (before execution, so end_time not available yet)+ _set_enhanced_span_attributes(+ main_span, operation_name, ctx, start_time, start_time+ )++ # For agent.run(), add configuration to main span and install hooks+ if operation_name == "run":+ _add_agent_configuration_attributes(main_span, instance, ctx)+ _install_step_hooks(+ tracer,+ main_span,+ instance,+ ctx,+ capture_message_content,+ kwargs,+ )++ # Execute the original async function+ logger.debug(+ "Executing enhanced Browser-Use async operation: %s",+ operation_name,+ )+ response = await wrapped(*args, **kwargs)++ # Calculate duration+ end_time = time.time()+ duration_ms = (end_time - start_time) * 1000+ main_span.set_attribute(+ SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, duration_ms+ )++ # Process response with enhanced details+ _process_enhanced_response(+ main_span, response, ctx, capture_message_content+ )++ # Capture token usage and cost metrics+ model_name = ctx.model_name+ if model_name != "unknown" and pricing_info:+ capture_token_and_cost_metrics(+ main_span, response, model_name, pricing_info+ )++ # Record metrics if enabled+ if not disable_metrics and metrics:+ _record_operation_metrics(+ metrics, operation_name, duration_ms, True+ )++ return response++ except Exception as e:+ # Calculate duration even for errors+ end_time = time.time()+ duration_ms = (end_time - start_time) * 1000+ main_span.set_attribute(+ SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, duration_ms+ )++ # Handle and log the exception+ handle_exception(main_span, e)+ logger.error(+ "Error in enhanced Browser-Use async operation %s: %s",+ operation_name,+ e,+ )++ # Record error metrics if enabled+ if not disable_metrics and metrics:+ _record_operation_metrics(+ metrics, operation_name, duration_ms, False+ )++ # Re-raise the exception to maintain original behavior+ raise++ return _async_wrapper()++ return wrapper+++def _create_enhanced_span_name(+ operation_name: str, ctx: BrowserUseInstrumentationContext+) -> str:+ """Create enhanced span names with more context."""++ if operation_name == "run":+ return f"invoke_agent {ctx.agent_name}"+ if operation_name == "step":+ step_count = ctx.step_count+ if step_count is not None:+ return f"execute_task step {step_count}"+ model_name = ctx.model_name if ctx.model_name != "unknown" else "llm"+ return f"{SemanticConvention.GEN_AI_SPAN_INVOKE_MODEL} {model_name}"+ return f"browser {operation_name}"+++class SpanScope:+ """Simple scope wrapper for common_framework_span_attributes."""++ def __init__(self, span, start_time, end_time):+ self._span = span+ self._start_time = start_time+ self._end_time = end_time++ @property+ def span(self):+ """Get the span."""+ return self._span++ @property+ def start_time(self):+ """Get the start time."""+ return self._start_time+++def _set_enhanced_span_attributes(+ span: Any,+ operation_name: str,+ ctx: BrowserUseInstrumentationContext,+ start_time: float,+ end_time: float,+) -> None:+ """Set enhanced span attributes with detailed information using common framework helpers."""++ # Create scope for common_framework_span_attributes+ scope = SpanScope(span, start_time, end_time)++ # Use common framework span attributes like crewai does+ common_framework_span_attributes(+ scope,+ SemanticConvention.GEN_AI_SYSTEM_BROWSER_USE,+ "browser-use.com", # server_address+ 443, # server_port+ ctx.environment,+ ctx.application_name,+ ctx.version,+ operation_name,+ ctx, # instance for model extraction+ )++ # Add browser-use specific attributes+ _add_browser_use_attributes(span, operation_name, ctx)+++def _add_browser_use_attributes(+ span: Any, operation_name: str, ctx: BrowserUseInstrumentationContext+) -> None:+ """Add browser-use specific attributes based on SDK research."""++ # Enhanced agent attributes+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_NAME, ctx.agent_name)+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_TYPE,+ SemanticConvention.GEN_AI_AGENT_TYPE_BROWSER,+ )++ # Task description (agent description)+ agent_desc = ctx.agent_description+ if agent_desc != "browser_automation_task":+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_DESCRIPTION, agent_desc)++ # Current URL if available+ current_url = ctx.current_url+ if current_url:+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_BROWSE_URL, current_url)++ # Step information+ step_count = ctx.step_count+ if step_count is not None:+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_STEP_COUNT, step_count)++ max_steps = ctx.max_steps+ if max_steps is not None:+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_MAX_STEPS, max_steps)++ # Browser-use specific agent information+ try:+ instance = ctx.instance+ if hasattr(instance, "id"):+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_ID, str(instance.id))+ if hasattr(instance, "task_id"):+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_TASK_ID, str(instance.task_id)+ )+ if hasattr(instance, "session_id"):+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_SESSION_ID, str(instance.session_id)+ )++ # Agent settings information+ if hasattr(instance, "settings"):+ settings = instance.settings+ if hasattr(settings, "use_vision"):+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_USE_VISION, settings.use_vision+ )+ if hasattr(settings, "max_failures"):+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_MAX_FAILURES, settings.max_failures+ )+ if hasattr(settings, "max_actions_per_step"):+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_MAX_ACTIONS_PER_STEP,+ settings.max_actions_per_step,+ )++ # Browser profile information+ if hasattr(instance, "browser_profile"):+ profile = instance.browser_profile+ if hasattr(profile, "headless"):+ headless_value = profile.headless+ if headless_value is not None:+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_HEADLESS, bool(headless_value)+ )+ if hasattr(profile, "allowed_domains") and profile.allowed_domains:+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_ALLOWED_DOMAINS,+ json.dumps(profile.allowed_domains),+ )++ except Exception as e:+ logger.debug("Error capturing browser-use specific attributes: %s", e)++ # Operation type mapping+ operation_type_map = {+ "run": SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT,+ "step": SemanticConvention.GEN_AI_OPERATION_TYPE_EXECUTE_AGENT_TASK,+ "pause": SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,+ "resume": SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,+ "stop": SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,+ }++ if operation_name in operation_type_map:+ span.set_attribute(+ SemanticConvention.GEN_AI_OPERATION_TYPE, operation_type_map[operation_name]+ )+++def _add_agent_configuration_attributes(+ span: Any, agent_instance: Any, _ctx: BrowserUseInstrumentationContext+) -> None:+ """Add agent configuration attributes to the main execution span."""++ try:+ # Agent settings from the instance+ if hasattr(agent_instance, "settings"):+ settings = agent_instance.settings++ # Vision settings+ if hasattr(settings, "use_vision"):+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_USE_VISION, settings.use_vision+ )+ if hasattr(settings, "vision_detail_level"):+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_VISION_DETAIL_LEVEL,+ settings.vision_detail_level,+ )++ # Execution settings+ if hasattr(settings, "max_failures"):+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_MAX_FAILURES, settings.max_failures+ )+ if hasattr(settings, "retry_delay"):+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_RETRY_DELAY, settings.retry_delay+ )+ if hasattr(settings, "validate_output"):+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_VALIDATE_OUTPUT,+ settings.validate_output,+ )+ if hasattr(settings, "max_actions_per_step"):+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_MAX_ACTIONS_PER_STEP,+ settings.max_actions_per_step,+ )++ # LLM settings+ if hasattr(settings, "llm_timeout"):+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_LLM_TIMEOUT, settings.llm_timeout+ )++ # Browser profile information+ if hasattr(agent_instance, "browser_profile"):+ profile = agent_instance.browser_profile+ if hasattr(profile, "allowed_domains") and profile.allowed_domains:+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_ALLOWED_DOMAINS,+ json.dumps(profile.allowed_domains),+ )+ if hasattr(profile, "headless"):+ headless_value = profile.headless+ if headless_value is not None:+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_HEADLESS, bool(headless_value)+ )++ # Task ID and session information+ if hasattr(agent_instance, "task_id"):+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_TASK_ID, str(agent_instance.task_id)+ )+ if hasattr(agent_instance, "session_id"):+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_SESSION_ID,+ str(agent_instance.session_id),+ )++ except Exception as e:+ logger.debug("Error capturing agent configuration: %s", e)+++def _install_step_hooks(+ tracer: Any,+ _parent_span: Any,+ _agent_instance: Any,+ ctx: BrowserUseInstrumentationContext,+ capture_message_content: bool,+ run_kwargs: dict,+) -> None:+ """Install step hooks to create detailed spans for each agent step."""++ # Get original hooks from run() kwargs+ original_on_step_start = run_kwargs.get("on_step_start", None)+ original_on_step_end = run_kwargs.get("on_step_end", None)++ async def enhanced_step_start_hook(agent):+ """Enhanced step start hook."""+ try:+ # Call original hook if it exists+ if original_on_step_start:+ if asyncio.iscoroutinefunction(original_on_step_start):+ await original_on_step_start(agent)+ else:+ original_on_step_start(agent)+ except Exception as e:+ logger.debug("Error in original step start hook: %s", e)++ async def enhanced_step_end_hook(agent):+ """Enhanced step end hook that creates detailed step spans."""+ try:+ # Create detailed step span with all the information we can extract+ await _create_detailed_step_span(+ tracer, agent, ctx, capture_message_content+ )++ # Call original hook if it exists+ if original_on_step_end:+ if asyncio.iscoroutinefunction(original_on_step_end):+ await original_on_step_end(agent)+ else:+ original_on_step_end(agent)+ except Exception as e:+ logger.debug("Error in enhanced step end hook: %s", e)++ # Replace the hooks in run_kwargs so they get used+ run_kwargs["on_step_start"] = enhanced_step_start_hook+ run_kwargs["on_step_end"] = enhanced_step_end_hook+++async def _create_detailed_step_span(+ tracer: Any,+ agent_instance: Any,+ ctx: BrowserUseInstrumentationContext,+ capture_message_content: bool,+) -> None:+ """Create a detailed span for a completed agent step."""++ try:+ # Get the latest step information+ if (+ not hasattr(agent_instance, "state")+ or not agent_instance.state.history.history+ ):+ return++ latest_step = agent_instance.state.history.history[-1]+ step_number = len(agent_instance.state.history.history)++ span_name = f"execute_task step {step_number}"++ with tracer.start_as_current_span(+ span_name, kind=SpanKind.INTERNAL+ ) as step_span:+ # Basic step information+ step_span.set_attribute(+ SemanticConvention.GEN_AI_SYSTEM,+ SemanticConvention.GEN_AI_SYSTEM_BROWSER_USE,+ )+ step_span.set_attribute(SemanticConvention.GEN_AI_OPERATION, "step")+ step_span.set_attribute(+ SemanticConvention.GEN_AI_OPERATION_TYPE,+ SemanticConvention.GEN_AI_OPERATION_TYPE_EXECUTE_AGENT_TASK,+ )+ step_span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_NAME, ctx.agent_name+ )+ step_span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_STEP_COUNT, step_number+ )++ # Extract agent thoughts and decision-making+ if latest_step.model_output:+ model_output = latest_step.model_output++ # Agent thoughts and reasoning+ if hasattr(model_output, "thinking") and model_output.thinking:+ step_span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_THINKING,+ str(model_output.thinking)[:500],+ )++ if hasattr(model_output, "memory") and model_output.memory:+ step_span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_MEMORY,+ str(model_output.memory)[:500],+ )++ if hasattr(model_output, "next_goal") and model_output.next_goal:+ step_span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_NEXT_GOAL,+ str(model_output.next_goal)[:200],+ )++ if (+ hasattr(model_output, "evaluation_previous_goal")+ and model_output.evaluation_previous_goal+ ):+ step_span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_EVALUATION,+ str(model_output.evaluation_previous_goal)[:200],+ )++ # Actions taken in this step+ if hasattr(model_output, "action") and model_output.action:+ await _create_individual_action_spans(+ tracer,+ step_span,+ model_output.action,+ latest_step,+ ctx,+ capture_message_content,+ )++ # Summary of actions+ actions_summary = []+ for action in model_output.action:+ if hasattr(action, "model_dump"):+ action_dict = action.model_dump()+ # Get the action type (first key that's not empty)+ action_type = next(+ (k for k, v in action_dict.items() if v), "unknown"+ )+ actions_summary.append(f"{action_type}")++ step_span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_ACTIONS,+ json.dumps(actions_summary),+ )+ step_span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_ACTIONS_COUNT,+ len(model_output.action),+ )++ # Browser state information+ if latest_step.state:+ state = latest_step.state++ # Current URL and page title+ if hasattr(state, "url") and state.url:+ step_span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_BROWSE_URL, state.url+ )++ if hasattr(state, "title") and state.title:+ step_span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_PAGE_TITLE, state.title[:100]+ )++ # Tab information+ if hasattr(state, "tabs") and state.tabs:+ step_span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_TABS_COUNT, len(state.tabs)+ )++ # Elements interacted with+ if hasattr(state, "interacted_element") and state.interacted_element:+ interacted_count = sum(+ 1 for el in state.interacted_element if el is not None+ )+ step_span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_INTERACTED_ELEMENTS_COUNT,+ interacted_count,+ )++ # Action results summary+ if latest_step.result:+ success_count = 0+ error_count = 0+ error_messages = []++ for result in latest_step.result:+ if hasattr(result, "is_success"):+ if result.is_success:+ success_count += 1+ else:+ error_count += 1++ if hasattr(result, "error") and result.error:+ error_messages.append(str(result.error)[:100])++ step_span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_ACTIONS_SUCCESS_COUNT, success_count+ )+ step_span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_ACTIONS_ERROR_COUNT, error_count+ )++ if error_messages and capture_message_content:+ step_span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_ACTION_ERRORS,+ json.dumps(error_messages),+ )++ # Step metadata (timing, etc.)+ if latest_step.metadata:+ metadata = latest_step.metadata+ if hasattr(metadata, "duration_seconds"):+ step_span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_STEP_DURATION,+ metadata.duration_seconds,+ )++ except Exception as e:+ logger.debug("Error creating detailed step span: %s", e)+++async def _create_individual_action_spans(+ tracer: Any,+ _parent_span: Any,+ actions: List[Any],+ step: Any,+ ctx: BrowserUseInstrumentationContext,+ capture_message_content: bool,+) -> None:+ """Create individual spans for each action in a step."""++ try:+ for i, action in enumerate(actions):+ if hasattr(action, "model_dump"):+ action_dict = action.model_dump()+ # Get the action type (first key that's not empty)+ action_type = next((k for k, v in action_dict.items() if v), "unknown")+ action_data = action_dict.get(action_type, {})++ span_name = f"invoke_agent {action_type}"++ with tracer.start_as_current_span(+ span_name, kind=SpanKind.INTERNAL+ ) as action_span:+ # Basic action information+ action_span.set_attribute(+ SemanticConvention.GEN_AI_SYSTEM,+ SemanticConvention.GEN_AI_SYSTEM_BROWSER_USE,+ )+ action_span.set_attribute(+ SemanticConvention.GEN_AI_OPERATION, "invoke_agent"+ )+ action_span.set_attribute(+ SemanticConvention.GEN_AI_OPERATION_TYPE,+ SemanticConvention.GEN_AI_OPERATION_TYPE_EXECUTE_AGENT_TASK,+ )+ action_span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_NAME, ctx.agent_name+ )+ action_span.set_attribute(+ SemanticConvention.GEN_AI_ACTION_TYPE, action_type+ )+ action_span.set_attribute(+ SemanticConvention.GEN_AI_ACTION_INDEX, i + 1+ )++ # Enhanced action-specific parameters+ if isinstance(action_data, dict):+ # Core action parameters+ for key, value in action_data.items():+ if key in [+ "index",+ "text",+ "url",+ "query",+ "selector",+ "new_tab",+ "down",+ "num_pages",+ ]:+ action_span.set_attribute(+ f"gen_ai.action.{key}", str(value)[:200]+ )++ # Special handling for sensitive data+ if action_type == "input_text" and action_data.get(+ "has_sensitive_data"+ ):+ action_span.set_attribute(+ SemanticConvention.GEN_AI_ACTION_HAS_SENSITIVE_DATA,+ True,+ )++ # File operations+ if action_type in ["upload_file", "write_file", "read_file"]:+ if "path" in action_data or "file_name" in action_data:+ file_path = action_data.get(+ "path", action_data.get("file_name", "")+ )+ action_span.set_attribute(+ SemanticConvention.GEN_AI_ACTION_FILE_PATH,+ str(file_path)[:100],+ )++ # Enhanced action result tracking+ if step.result and i < len(step.result):+ result = step.result[i]+ if hasattr(result, "is_success"):+ action_span.set_attribute(+ SemanticConvention.GEN_AI_ACTION_SUCCESS,+ result.is_success,+ )+ if (+ hasattr(result, "error")+ and result.error+ and capture_message_content+ ):+ action_span.set_attribute(+ SemanticConvention.GEN_AI_ACTION_ERROR,+ str(result.error)[:200],+ )+ if (+ hasattr(result, "extracted_content")+ and result.extracted_content+ and capture_message_content+ ):+ action_span.set_attribute(+ SemanticConvention.GEN_AI_ACTION_EXTRACTED_CONTENT_LENGTH,+ len(str(result.extracted_content)),+ )++ # Enhanced browser state context+ if step.state:+ if hasattr(step.state, "url") and step.state.url:+ action_span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_BROWSE_URL,+ step.state.url,+ )+ if hasattr(step.state, "title") and step.state.title:+ action_span.set_attribute(+ SemanticConvention.GEN_AI_BROWSER_PAGE_TITLE,+ step.state.title[:100],+ )+ if hasattr(step.state, "tabs") and step.state.tabs:+ action_span.set_attribute(+ SemanticConvention.GEN_AI_BROWSER_TABS_COUNT,+ len(step.state.tabs),+ )++ except Exception as e:+ logger.debug("Error creating individual action spans: %s", e)+++def _calculate_step_stats(history):+ """Calculate success/failure statistics for steps."""+ successful_steps = 0+ failed_steps = 0+ total_actions = 0++ for step in history:+ if step.result:+ step_success = True+ for result in step.result:+ total_actions += 1+ if hasattr(result, "is_success") and not result.is_success:+ step_success = False+ elif hasattr(result, "error") and result.error:+ step_success = False++ if step_success:+ successful_steps += 1+ else:+ failed_steps += 1++ return {+ "successful_steps": successful_steps,+ "failed_steps": failed_steps,+ "total_actions": total_actions,+ }+++def _process_enhanced_response(+ span: Any,+ response: Any,+ _ctx: BrowserUseInstrumentationContext,+ capture_message_content: bool,+) -> None:+ """Process response with enhanced details and summary information."""++ try:+ # Handle AgentHistoryList (from agent.run())+ if hasattr(response, "history") and hasattr(response, "usage"):+ history_list = response++ # Overall execution summary+ total_steps = len(history_list.history)+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_STEP_COUNT, total_steps)++ # Calculate success/failure stats+ stats = _calculate_step_stats(history_list.history)+ successful_steps = stats["successful_steps"]+ failed_steps = stats["failed_steps"]+ total_actions = stats["total_actions"]++ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_TOTAL_ACTIONS, total_actions+ )+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_SUCCESSFUL_STEPS, successful_steps+ )+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_FAILED_STEPS, failed_steps+ )++ if total_steps > 0:+ success_rate = (successful_steps / total_steps) * 100+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_SUCCESS_RATE, success_rate+ )++ # Final result+ final_result = history_list.final_result()+ if final_result and capture_message_content:+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_FINAL_RESULT,+ str(final_result)[:1000],+ )++ # Usage summary if available+ if history_list.usage:+ usage = history_list.usage+ if hasattr(usage, "total_input_tokens") and usage.total_input_tokens:+ span.set_attribute(+ SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,+ usage.total_input_tokens,+ )+ if hasattr(usage, "total_output_tokens") and usage.total_output_tokens:+ span.set_attribute(+ SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,+ usage.total_output_tokens,+ )+ if hasattr(usage, "total_cost") and usage.total_cost:+ span.set_attribute(+ SemanticConvention.GEN_AI_USAGE_COST, usage.total_cost+ )++ # Total duration+ if hasattr(history_list, "total_duration_seconds"):+ duration = history_list.total_duration_seconds()+ if duration:+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_EXECUTION_TIME, duration+ )++ # Handle single action results+ elif hasattr(response, "is_success") or hasattr(response, "error"):+ if hasattr(response, "is_success"):+ span.set_attribute(+ SemanticConvention.GEN_AI_ACTION_SUCCESS, response.is_success+ )++ if hasattr(response, "error") and response.error:+ span.set_attribute(SemanticConvention.ERROR_TYPE, "action_failed")+ if capture_message_content:+ span.set_attribute(+ SemanticConvention.GEN_AI_ACTION_ERROR,+ str(response.error)[:200],+ )++ except Exception as e:+ logger.debug("Error processing enhanced response: %s", e)+++def _record_operation_metrics(metrics, operation_name, duration_ms, is_success):+ """Record operation metrics for performance tracking."""++ try:+ # Record duration metrics+ duration_key = f"browser_use.{operation_name}.duration"+ if duration_key not in metrics:+ metrics[duration_key] = []+ metrics[duration_key].append(duration_ms)++ # Record success/error metrics+ if is_success:+ success_key = f"browser_use.{operation_name}.success"+ if success_key not in metrics:+ metrics[success_key] = 0+ metrics[success_key] += 1+ else:+ error_key = f"browser_use.{operation_name}.error"+ if error_key not in metrics:+ metrics[error_key] = 0+ metrics[error_key] += 1++ except Exception as e:+ logger.debug("Error recording operation metrics: %s", e)diff --git a/sdk/python/src/openlit/instrumentation/browser_use/browser_use.py b/sdk/python/src/openlit/instrumentation/browser_use/browser_use.pynew file mode 100644index 00000000..eb4d0fad--- /dev/null+++ b/sdk/python/src/openlit/instrumentation/browser_use/browser_use.py@@ -0,0 +1,427 @@+"""+Module for monitoring Browser-Use synchronous operations.+Handles the few sync methods in browser-use (pause, resume, stop).+"""++import json+import logging+import time+from typing import Any+from opentelemetry.trace import SpanKind+from opentelemetry import context as context_api++from openlit.__helpers import handle_exception, common_framework_span_attributes+from openlit.instrumentation.browser_use.utils import (+ BrowserUseInstrumentationContext,+ get_operation_name,+ capture_token_and_cost_metrics,+)+from openlit.semcov import SemanticConvention++logger = logging.getLogger(__name__)+++def general_wrap(+ gen_ai_endpoint,+ version,+ environment,+ application_name,+ tracer,+ pricing_info,+ capture_message_content,+ metrics,+ disable_metrics,+):+ """+ Enhanced telemetry wrapper for Browser-Use sync operations with detailed spans.+ Handles sync methods like pause, resume, stop.+ """++ def wrapper(wrapped, instance, args, kwargs):+ """Enhanced wrapper with detailed span creation."""++ # Check if instrumentation is suppressed+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):+ return wrapped(*args, **kwargs)++ operation_name = get_operation_name(gen_ai_endpoint)+ ctx = BrowserUseInstrumentationContext(+ instance, args, kwargs, version, environment, application_name+ )++ # Create enhanced span name+ span_name = _create_enhanced_span_name(operation_name, ctx)++ with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as main_span:+ start_time = time.time()++ try:+ # Set enhanced span attributes+ _set_enhanced_span_attributes(+ main_span, operation_name, ctx, start_time, start_time+ )++ # Execute the original sync function+ logger.debug(+ "Executing enhanced Browser-Use sync operation: %s", operation_name+ )+ response = wrapped(*args, **kwargs)++ # Calculate duration+ end_time = time.time()+ duration_ms = (end_time - start_time) * 1000+ main_span.set_attribute(+ SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, duration_ms+ )++ # Process response with enhanced details+ _process_enhanced_response(+ main_span, response, ctx, capture_message_content+ )++ # Capture token usage and cost metrics+ model_name = ctx.model_name+ if model_name != "unknown" and pricing_info:+ capture_token_and_cost_metrics(+ main_span, response, model_name, pricing_info+ )++ # Record metrics if enabled+ if not disable_metrics and metrics:+ _record_operation_metrics(+ metrics, operation_name, duration_ms, True+ )++ return response++ except Exception as e:+ # Calculate duration even for errors+ end_time = time.time()+ duration_ms = (end_time - start_time) * 1000+ main_span.set_attribute(+ SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, duration_ms+ )++ # Handle and log the exception+ handle_exception(main_span, e)+ logger.error(+ "Error in enhanced Browser-Use sync operation %s: %s",+ operation_name,+ e,+ )++ # Record error metrics if enabled+ if not disable_metrics and metrics:+ _record_operation_metrics(+ metrics, operation_name, duration_ms, False+ )++ # Re-raise the exception to maintain original behavior+ raise++ return wrapper+++def _create_enhanced_span_name(+ operation_name: str, ctx: BrowserUseInstrumentationContext+) -> str:+ """Create enhanced span names with more context."""++ if operation_name == "run":+ return f"invoke_agent {ctx.agent_name}"+ if operation_name == "step":+ step_count = ctx.step_count+ if step_count is not None:+ return f"execute_task step {step_count}"+ model_name = ctx.model_name if ctx.model_name != "unknown" else "llm"+ return f"{SemanticConvention.GEN_AI_SPAN_INVOKE_MODEL} {model_name}"+ return f"browser {operation_name}"+++class SpanScope:+ """Simple scope wrapper for common_framework_span_attributes."""++ def __init__(self, span, start_time, end_time):+ self._span = span+ self._start_time = start_time+ self._end_time = end_time++ @property+ def span(self):+ """Get the span."""+ return self._span++ @property+ def start_time(self):+ """Get the start time."""+ return self._start_time+++def _set_enhanced_span_attributes(+ span: Any,+ operation_name: str,+ ctx: BrowserUseInstrumentationContext,+ start_time: float,+ end_time: float,+) -> None:+ """Set enhanced span attributes with detailed information using common framework helpers."""++ # Create scope for common_framework_span_attributes+ scope = SpanScope(span, start_time, end_time)++ # Use common framework span attributes like crewai does+ common_framework_span_attributes(+ scope,+ SemanticConvention.GEN_AI_SYSTEM_BROWSER_USE,+ "browser-use.com", # server_address+ 443, # server_port+ ctx.environment,+ ctx.application_name,+ ctx.version,+ operation_name,+ ctx, # instance for model extraction+ )++ # Add browser-use specific attributes+ _add_browser_use_attributes(span, operation_name, ctx)+++def _add_browser_use_attributes(+ span: Any, operation_name: str, ctx: BrowserUseInstrumentationContext+) -> None:+ """Add browser-use specific attributes based on SDK research."""++ # Enhanced agent attributes+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_NAME, ctx.agent_name)+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_TYPE,+ SemanticConvention.GEN_AI_AGENT_TYPE_BROWSER,+ )++ # Task description (agent description)+ agent_desc = ctx.agent_description+ if agent_desc != "browser_automation_task":+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_DESCRIPTION, agent_desc)++ # Current URL if available+ current_url = ctx.current_url+ if current_url:+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_BROWSE_URL, current_url)++ # Step information+ step_count = ctx.step_count+ if step_count is not None:+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_STEP_COUNT, step_count)++ max_steps = ctx.max_steps+ if max_steps is not None:+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_MAX_STEPS, max_steps)++ # Browser-use specific agent information+ try:+ instance = ctx.instance+ if hasattr(instance, "id"):+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_ID, str(instance.id))+ if hasattr(instance, "task_id"):+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_TASK_ID, str(instance.task_id)+ )+ if hasattr(instance, "session_id"):+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_SESSION_ID, str(instance.session_id)+ )++ # Agent settings information+ if hasattr(instance, "settings"):+ settings = instance.settings+ if hasattr(settings, "use_vision"):+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_USE_VISION, settings.use_vision+ )+ if hasattr(settings, "max_failures"):+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_MAX_FAILURES, settings.max_failures+ )+ if hasattr(settings, "max_actions_per_step"):+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_MAX_ACTIONS_PER_STEP,+ settings.max_actions_per_step,+ )++ # Browser profile information+ if hasattr(instance, "browser_profile"):+ profile = instance.browser_profile+ if hasattr(profile, "headless"):+ headless_value = profile.headless+ if headless_value is not None:+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_HEADLESS, bool(headless_value)+ )+ if hasattr(profile, "allowed_domains") and profile.allowed_domains:+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_ALLOWED_DOMAINS,+ json.dumps(profile.allowed_domains),+ )++ except Exception as e:+ logger.debug("Error capturing browser-use specific attributes: %s", e)++ # Operation type mapping+ operation_type_map = {+ "run": SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT,+ "step": SemanticConvention.GEN_AI_OPERATION_TYPE_EXECUTE_AGENT_TASK,+ "pause": SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,+ "resume": SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,+ "stop": SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,+ }++ if operation_name in operation_type_map:+ span.set_attribute(+ SemanticConvention.GEN_AI_OPERATION_TYPE, operation_type_map[operation_name]+ )+++def _calculate_step_stats(history):+ """Calculate success/failure statistics for steps."""+ successful_steps = 0+ failed_steps = 0+ total_actions = 0++ for step in history:+ if step.result:+ step_success = True+ for result in step.result:+ total_actions += 1+ if hasattr(result, "is_success") and not result.is_success:+ step_success = False+ elif hasattr(result, "error") and result.error:+ step_success = False++ if step_success:+ successful_steps += 1+ else:+ failed_steps += 1++ return {+ "successful_steps": successful_steps,+ "failed_steps": failed_steps,+ "total_actions": total_actions,+ }+++def _process_enhanced_response(+ span: Any,+ response: Any,+ _ctx: BrowserUseInstrumentationContext,+ capture_message_content: bool,+) -> None:+ """Process response with enhanced details and summary information."""++ try:+ # Handle AgentHistoryList (from agent.run())+ if hasattr(response, "history") and hasattr(response, "usage"):+ history_list = response++ # Overall execution summary+ total_steps = len(history_list.history)+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_STEP_COUNT, total_steps)++ # Calculate success/failure stats+ stats = _calculate_step_stats(history_list.history)+ successful_steps = stats["successful_steps"]+ failed_steps = stats["failed_steps"]+ total_actions = stats["total_actions"]++ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_TOTAL_ACTIONS, total_actions+ )+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_SUCCESSFUL_STEPS, successful_steps+ )+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_FAILED_STEPS, failed_steps+ )++ if total_steps > 0:+ success_rate = (successful_steps / total_steps) * 100+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_SUCCESS_RATE, success_rate+ )++ # Final result+ final_result = history_list.final_result()+ if final_result and capture_message_content:+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_FINAL_RESULT,+ str(final_result)[:1000],+ )++ # Usage summary if available+ if history_list.usage:+ usage = history_list.usage+ if hasattr(usage, "total_input_tokens") and usage.total_input_tokens:+ span.set_attribute(+ SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,+ usage.total_input_tokens,+ )+ if hasattr(usage, "total_output_tokens") and usage.total_output_tokens:+ span.set_attribute(+ SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,+ usage.total_output_tokens,+ )+ if hasattr(usage, "total_cost") and usage.total_cost:+ span.set_attribute(+ SemanticConvention.GEN_AI_USAGE_COST, usage.total_cost+ )++ # Total duration+ if hasattr(history_list, "total_duration_seconds"):+ duration = history_list.total_duration_seconds()+ if duration:+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_EXECUTION_TIME, duration+ )++ # Handle single action results+ elif hasattr(response, "is_success") or hasattr(response, "error"):+ if hasattr(response, "is_success"):+ span.set_attribute(+ SemanticConvention.GEN_AI_ACTION_SUCCESS, response.is_success+ )++ if hasattr(response, "error") and response.error:+ span.set_attribute(SemanticConvention.ERROR_TYPE, "action_failed")+ if capture_message_content:+ span.set_attribute(+ SemanticConvention.GEN_AI_ACTION_ERROR,+ str(response.error)[:200],+ )++ except Exception as e:+ logger.debug("Error processing enhanced response: %s", e)+++def _record_operation_metrics(metrics, operation_name, duration_ms, is_success):+ """Record operation metrics for performance tracking."""++ try:+ # Record duration metrics+ duration_key = f"browser_use.{operation_name}.duration"+ if duration_key not in metrics:+ metrics[duration_key] = []+ metrics[duration_key].append(duration_ms)++ # Record success/error metrics+ if is_success:+ success_key = f"browser_use.{operation_name}.success"+ if success_key not in metrics:+ metrics[success_key] = 0+ metrics[success_key] += 1+ else:+ error_key = f"browser_use.{operation_name}.error"+ if error_key not in metrics:+ metrics[error_key] = 0+ metrics[error_key] += 1++ except Exception as e:+ logger.debug("Error recording operation metrics: %s", e)diff --git a/sdk/python/src/openlit/instrumentation/browser_use/utils.py b/sdk/python/src/openlit/instrumentation/browser_use/utils.pynew file mode 100644index 00000000..80fa55c5--- /dev/null+++ b/sdk/python/src/openlit/instrumentation/browser_use/utils.py@@ -0,0 +1,463 @@+"""+Utilities for Browser-Use instrumentation with proper OpenLIT semantic conventions.+"""++import json+import logging+from typing import Any, Dict, Optional+from openlit.__helpers import get_chat_model_cost+from openlit.semcov import SemanticConvention++logger = logging.getLogger(__name__)+++class BrowserUseInstrumentationContext:+ """+ Context object to cache agent information and provide optimized attribute access.+ Uses __slots__ for memory efficiency.+ """++ __slots__ = (+ "instance",+ "args",+ "kwargs",+ "version",+ "environment",+ "application_name",+ "_cache",+ )++ def __init__(+ self,+ instance: Any,+ args: tuple,+ kwargs: dict,+ version: str,+ environment: str,+ application_name: str,+ ):+ self.instance = instance+ self.args = args+ self.kwargs = kwargs+ self.version = version+ self.environment = environment+ self.application_name = application_name++ # Cache for expensive operations with lazy loading+ self._cache = {}++ @property+ def agent_name(self) -> str:+ """Get agent name with caching."""+ if "agent_name" not in self._cache:+ self._cache["agent_name"] = self._extract_agent_name()+ return self._cache["agent_name"]++ def _extract_agent_name(self) -> str:+ """Extract agent name from instance."""+ try:+ # Check for agent name attribute+ if hasattr(self.instance, "name"):+ return str(self.instance.name)+ if hasattr(self.instance, "agent_name"):+ return str(self.instance.agent_name)+ return "browser_use"+ except (AttributeError, ValueError, TypeError):+ return "browser_use"++ @property+ def agent_description(self) -> str:+ """Get agent task description with caching."""+ if "agent_description" not in self._cache:+ self._cache["agent_description"] = self._extract_agent_description()+ return self._cache["agent_description"]++ def _extract_agent_description(self) -> str:+ """Extract agent task description from arguments or instance."""+ try:+ # Check args for task description (usually first argument in Agent constructor)+ if self.args and len(self.args) > 0:+ first_arg = self.args[0]+ if isinstance(first_arg, str):+ return first_arg[:200] # Limit length++ # Check kwargs for task-related parameters+ for key in ["task", "instruction", "description"]:+ if key in self.kwargs:+ value = self.kwargs[key]+ if isinstance(value, str):+ return value[:200]++ # Check instance attributes+ if hasattr(self.instance, "task"):+ return str(self.instance.task)[:200]++ return "browser_automation_task"+ except (AttributeError, ValueError, TypeError):+ return "browser_automation_task"++ @property+ def model_name(self) -> str:+ """Get model name with caching."""+ if "model_name" not in self._cache:+ self._cache["model_name"] = self._extract_model_name()+ return self._cache["model_name"]++ def _extract_model_name(self) -> str:+ """Extract model name from instance."""+ try:+ # Check instance for llm attribute (Agent uses llm)+ if hasattr(self.instance, "llm"):+ llm = self.instance.llm+ if hasattr(llm, "model_name"):+ return str(llm.model_name)+ if hasattr(llm, "model"):+ return str(llm.model)+ if hasattr(llm, "name"):+ return str(llm.name)++ # Check for model attribute directly+ if hasattr(self.instance, "model"):+ model = self.instance.model+ if isinstance(model, str):+ return model+ if hasattr(model, "model_name"):+ return str(model.model_name)++ return "unknown"+ except (AttributeError, ValueError, TypeError):+ return "unknown"++ @property+ def current_url(self) -> Optional[str]:+ """Get current browser URL."""+ if "current_url" not in self._cache:+ self._cache["current_url"] = self._extract_current_url()+ return self._cache["current_url"]++ def _extract_current_url(self) -> Optional[str]:+ """Extract current URL from browser session."""+ try:+ # Check for browser session+ if hasattr(self.instance, "browser_session"):+ browser_session = self.instance.browser_session+ if browser_session and hasattr(browser_session, "current_page"):+ page = browser_session.current_page+ if page and hasattr(page, "url"):+ return str(page.url)++ # Check controller for page info+ if hasattr(self.instance, "page"):+ page = self.instance.page+ if hasattr(page, "url"):+ return str(page.url)++ return None+ except (AttributeError, ValueError, TypeError):+ return None++ @property+ def step_count(self) -> Optional[int]:+ """Get current step count."""+ if "step_count" not in self._cache:+ self._cache["step_count"] = self._extract_step_count()+ return self._cache["step_count"]++ def _extract_step_count(self) -> Optional[int]:+ """Extract step count from instance."""+ try:+ if hasattr(self.instance, "step_count"):+ return self.instance.step_count+ if hasattr(self.instance, "current_step"):+ return self.instance.current_step+ return None+ except (AttributeError, ValueError, TypeError):+ return None++ @property+ def max_steps(self) -> Optional[int]:+ """Get max steps with caching."""+ if "max_steps" not in self._cache:+ self._cache["max_steps"] = self._extract_max_steps()+ return self._cache["max_steps"]++ def _extract_max_steps(self) -> Optional[int]:+ """Extract max steps from kwargs or instance."""+ try:+ # Check kwargs first (from run() method)+ if "max_steps" in self.kwargs:+ return int(self.kwargs["max_steps"])++ # Check instance attributes+ if hasattr(self.instance, "max_steps"):+ return self.instance.max_steps++ return None+ except (AttributeError, ValueError, TypeError):+ return None+++def get_operation_name(gen_ai_endpoint: str) -> str:+ """Extract operation name from endpoint."""+ if "." in gen_ai_endpoint:+ return gen_ai_endpoint.split(".")[-1]+ return gen_ai_endpoint.replace("_", " ")+++def create_span_name(operation_name: str, ctx: BrowserUseInstrumentationContext) -> str:+ """Create span name following OpenLIT pattern."""++ # Map operation types to span name patterns+ operation_patterns = {+ "run": f"agent {ctx.agent_name}",+ "multi_act": "agent multi_act",+ "act": "browser act",+ }++ if operation_name in operation_patterns:+ return operation_patterns[operation_name]++ if operation_name in ["step"]:+ # Individual step execution+ step_num = ctx.step_count+ return (+ f"agent step_{step_num}"+ if step_num is not None+ else f"agent {ctx.agent_name}_step"+ )++ if operation_name in ["pause", "resume", "stop"]:+ # Task management+ return f"agent {operation_name}"++ # Generic operations+ return f"agent {operation_name}"+++def set_span_attributes(+ span: Any,+ operation_name: str,+ ctx: BrowserUseInstrumentationContext,+ additional_attrs: Optional[Dict[str, Any]] = None,+) -> None:+ """Set comprehensive span attributes using proper OpenLIT semantic conventions."""++ # Core framework attributes+ span.set_attribute(+ SemanticConvention.GEN_AI_SYSTEM, SemanticConvention.GEN_AI_SYSTEM_BROWSER_USE+ )+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION, operation_name)++ # Environment and application attributes+ span.set_attribute(SemanticConvention.GEN_AI_ENVIRONMENT, ctx.environment)+ span.set_attribute(SemanticConvention.GEN_AI_APPLICATION_NAME, ctx.application_name)+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION, ctx.version)++ # Agent attributes using proper semcov+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_NAME, ctx.agent_name)+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_TYPE,+ SemanticConvention.GEN_AI_AGENT_TYPE_BROWSER,+ )++ # Agent description (task)+ agent_desc = ctx.agent_description+ if agent_desc != "browser_automation_task":+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_DESCRIPTION, agent_desc)++ # Model information if available+ model_name = ctx.model_name+ if model_name != "unknown":+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL, model_name)++ # Step information+ step_count = ctx.step_count+ if step_count is not None:+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_STEP_COUNT, step_count)++ max_steps = ctx.max_steps+ if max_steps is not None:+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_MAX_STEPS, max_steps)++ # Current URL if available+ current_url = ctx.current_url+ if current_url:+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_BROWSE_URL, current_url)++ # Operation type mapping+ operation_type_map = {+ "run": SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT,+ "step": SemanticConvention.GEN_AI_OPERATION_TYPE_EXECUTE_AGENT_TASK,+ "multi_act": SemanticConvention.GEN_AI_OPERATION_TYPE_TOOL_COORDINATION,+ "act": SemanticConvention.GEN_AI_OPERATION_TYPE_EXECUTE_AGENT_TASK,+ "pause": SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,+ "resume": SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,+ "stop": SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,+ }++ if operation_name in operation_type_map:+ span.set_attribute(+ SemanticConvention.GEN_AI_OPERATION_TYPE, operation_type_map[operation_name]+ )++ # Set additional attributes if provided+ if additional_attrs:+ for key, value in additional_attrs.items():+ if value is not None:+ span.set_attribute(key, value)+++def process_response(+ span: Any,+ response: Any,+ _ctx: BrowserUseInstrumentationContext,+ capture_message_content: bool = True,+) -> None:+ """Process and capture response data with proper semantic conventions."""++ try:+ # Handle AgentHistoryList (from agent.run())+ if hasattr(response, "history") and hasattr(response, "usage"):+ history_list = response++ # Capture usage summary if available+ if history_list.usage:+ usage = history_list.usage+ if hasattr(usage, "total_input_tokens") and usage.total_input_tokens:+ span.set_attribute(+ SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,+ usage.total_input_tokens,+ )+ if hasattr(usage, "total_output_tokens") and usage.total_output_tokens:+ span.set_attribute(+ SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,+ usage.total_output_tokens,+ )+ if hasattr(usage, "total_cost") and usage.total_cost:+ span.set_attribute(+ SemanticConvention.GEN_AI_USAGE_COST, usage.total_cost+ )++ # Capture total duration+ if hasattr(history_list, "total_duration_seconds"):+ duration = history_list.total_duration_seconds()+ if duration:+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_EXECUTION_TIME, duration+ )++ # Capture step count+ step_count = len(history_list.history)+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_STEP_COUNT, step_count)++ # Handle ActionResult (from controller.act())+ elif hasattr(response, "is_success") or hasattr(response, "error"):+ action_result = response++ # Capture success/failure+ if hasattr(action_result, "is_success"):+ span.set_attribute(+ SemanticConvention.GEN_AI_ACTION_SUCCESS, action_result.is_success+ )++ # Capture error information+ if hasattr(action_result, "error") and action_result.error:+ span.set_attribute(SemanticConvention.ERROR_TYPE, "action_failed")++ # Generic response capture+ if capture_message_content:+ if isinstance(response, str):+ span.set_attribute(+ SemanticConvention.GEN_AI_CONTENT_COMPLETION, response[:1000]+ )+ elif hasattr(response, "__dict__"):+ try:+ content = json.dumps(response.__dict__, default=str)[:1000]+ span.set_attribute(+ SemanticConvention.GEN_AI_CONTENT_COMPLETION, content+ )+ except (TypeError, ValueError):+ pass++ except (AttributeError, ValueError, TypeError, KeyError) as e:+ logger.debug("Error processing response: %s", e)+++def capture_agent_thoughts_and_state(span: Any, agent_output: Any) -> None:+ """Capture agent thoughts and state information."""++ try:+ if hasattr(agent_output, "thinking") and agent_output.thinking:+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_THINKING,+ str(agent_output.thinking)[:500],+ )++ if hasattr(agent_output, "memory") and agent_output.memory:+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_MEMORY, str(agent_output.memory)[:500]+ )++ if hasattr(agent_output, "next_goal") and agent_output.next_goal:+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_NEXT_GOAL,+ str(agent_output.next_goal)[:200],+ )++ if (+ hasattr(agent_output, "evaluation_previous_goal")+ and agent_output.evaluation_previous_goal+ ):+ span.set_attribute(+ SemanticConvention.GEN_AI_AGENT_EVALUATION,+ str(agent_output.evaluation_previous_goal)[:200],+ )++ except (AttributeError, ValueError, TypeError) as e:+ logger.debug("Error capturing agent thoughts: %s", e)+++def capture_token_and_cost_metrics(+ span: Any, response: Any, model_name: str, pricing_info: Dict[str, Any]+) -> None:+ """Capture token usage and cost metrics for business intelligence."""++ try:+ # Extract token usage if available+ input_tokens = 0+ output_tokens = 0++ if hasattr(response, "usage"):+ usage = response.usage+ if hasattr(usage, "input_tokens"):+ input_tokens = usage.input_tokens+ if hasattr(usage, "output_tokens"):+ output_tokens = usage.output_tokens+ elif isinstance(response, dict) and "usage" in response:+ usage = response["usage"]+ input_tokens = usage.get("input_tokens", 0)+ output_tokens = usage.get("output_tokens", 0)++ if input_tokens > 0:+ span.set_attribute(+ SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, input_tokens+ )++ if output_tokens > 0:+ span.set_attribute(+ SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, output_tokens+ )++ # Calculate cost if pricing info is available+ if pricing_info and model_name != "unknown":+ try:+ cost = get_chat_model_cost(+ model_name, pricing_info, input_tokens, output_tokens+ )+ if cost > 0:+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST, cost)+ except (ValueError, TypeError, KeyError) as cost_error:+ logger.debug("Error calculating cost: %s", cost_error)++ except (AttributeError, ValueError, TypeError, KeyError) as e:+ logger.debug("Error capturing token and cost metrics: %s", e)diff --git a/sdk/python/src/openlit/semcov/__init__.py b/sdk/python/src/openlit/semcov/__init__.pyindex 800905ee..5cecfef4 100644--- a/sdk/python/src/openlit/semcov/__init__.py+++ b/sdk/python/src/openlit/semcov/__init__.py@@ -163,6 +163,7 @@ class SemanticConvention:GEN_AI_SYSTEM_OPENAI_AGENTS = "openai_agents"GEN_AI_SYSTEM_PYDANTIC_AI = "pydantic_ai"GEN_AI_SYSTEM_SARVAM = "sarvam"+ GEN_AI_SYSTEM_BROWSER_USE = "browser_use"# GenAI Framework Component Attributes (Standard)GEN_AI_FRAMEWORK_COMPONENT_NAME = "gen_ai.framework.component.name"@@ -547,6 +548,106 @@ class SemanticConvention:GPU_POWER_DRAW = "gpu.power.draw"GPU_POWER_LIMIT = "gpu.power.limit"+ # Browser-Use Specific Attributes+ GEN_AI_BROWSER_ACTION_TYPE = "gen_ai.browser.action.type"+ GEN_AI_BROWSER_ACTION_TARGET = "gen_ai.browser.action.target"+ GEN_AI_BROWSER_ACTION_VALUE = "gen_ai.browser.action.value"+ GEN_AI_BROWSER_ACTION_SELECTOR = "gen_ai.browser.action.selector"+ GEN_AI_BROWSER_PAGE_URL = "gen_ai.browser.page.url"+ GEN_AI_BROWSER_PAGE_TITLE = "gen_ai.browser.page.title"+ GEN_AI_BROWSER_VIEWPORT_WIDTH = "gen_ai.browser.viewport.width"+ GEN_AI_BROWSER_VIEWPORT_HEIGHT = "gen_ai.browser.viewport.height"+ GEN_AI_BROWSER_USER_AGENT = "gen_ai.browser.user_agent"+ GEN_AI_BROWSER_TASK_DESCRIPTION = "gen_ai.browser.task.description"+ GEN_AI_BROWSER_STEP_NUMBER = "gen_ai.browser.step.number"+ GEN_AI_BROWSER_MAX_STEPS = "gen_ai.browser.max_steps"+ GEN_AI_BROWSER_DOM_ELEMENTS_COUNT = "gen_ai.browser.dom.elements_count"+ GEN_AI_BROWSER_SCREENSHOT_TAKEN = "gen_ai.browser.screenshot.taken"+ GEN_AI_BROWSER_SESSION_ID = "gen_ai.browser.session.id"+ GEN_AI_BROWSER_CONTROLLER_TYPE = "gen_ai.browser.controller.type"++ # Browser-Use Operation Types+ GEN_AI_OPERATION_TYPE_BROWSER_RUN = "browser_run"+ GEN_AI_OPERATION_TYPE_BROWSER_STEP = "browser_step"+ GEN_AI_OPERATION_TYPE_BROWSER_ACTION = "browser_action"+ GEN_AI_OPERATION_TYPE_BROWSER_PAUSE = "browser_pause"+ GEN_AI_OPERATION_TYPE_BROWSER_RESUME = "browser_resume"+ GEN_AI_OPERATION_TYPE_BROWSER_STOP = "browser_stop"++ # Browser-Use Agent Specific Attributes+ GEN_AI_AGENT_MAX_STEPS = "gen_ai.agent.max_steps"+ GEN_AI_AGENT_ID = "gen_ai.agent.id"+ GEN_AI_AGENT_TASK_ID = "gen_ai.agent.task_id"+ GEN_AI_AGENT_SESSION_ID = "gen_ai.agent.session_id"+ GEN_AI_AGENT_USE_VISION = "gen_ai.agent.use_vision"+ GEN_AI_AGENT_MAX_FAILURES = "gen_ai.agent.max_failures"+ GEN_AI_AGENT_MAX_ACTIONS_PER_STEP = "gen_ai.agent.max_actions_per_step"+ GEN_AI_AGENT_HEADLESS = "gen_ai.agent.headless"+ GEN_AI_AGENT_ALLOWED_DOMAINS = "gen_ai.agent.allowed_domains"+ GEN_AI_AGENT_VISION_DETAIL_LEVEL = "gen_ai.agent.vision_detail_level"+ GEN_AI_AGENT_RETRY_DELAY = "gen_ai.agent.retry_delay"+ GEN_AI_AGENT_VALIDATE_OUTPUT = "gen_ai.agent.validate_output"+ GEN_AI_AGENT_LLM_TIMEOUT = "gen_ai.agent.llm_timeout"++ # Browser-Use Action Specific Attributes+ GEN_AI_ACTION_SUCCESS = "gen_ai.action.success"+ GEN_AI_ACTION_ERROR = "gen_ai.action.error"+ GEN_AI_ACTION_TYPE = "gen_ai.action.type"+ GEN_AI_ACTION_INDEX = "gen_ai.action.index"+ GEN_AI_ACTION_HAS_SENSITIVE_DATA = "gen_ai.action.has_sensitive_data"+ GEN_AI_ACTION_FILE_PATH = "gen_ai.action.file_path"+ GEN_AI_ACTION_EXTRACTED_CONTENT_LENGTH = "gen_ai.action.extracted_content_length"++ # Browser-Use Browser Specific Attributes+ GEN_AI_BROWSER_PAGE_TITLE = "gen_ai.browser.page_title"+ GEN_AI_BROWSER_TABS_COUNT = "gen_ai.browser.tabs_count"++ # Browser-Use Agent Execution Attributes+ GEN_AI_AGENT_THINKING = "gen_ai.agent.thinking"+ GEN_AI_AGENT_MEMORY = "gen_ai.agent.memory"+ GEN_AI_AGENT_NEXT_GOAL = "gen_ai.agent.next_goal"+ GEN_AI_AGENT_EVALUATION = "gen_ai.agent.evaluation"+ GEN_AI_AGENT_ACTIONS = "gen_ai.agent.actions"+ GEN_AI_AGENT_ACTIONS_COUNT = "gen_ai.agent.actions_count"+ GEN_AI_AGENT_PAGE_TITLE = "gen_ai.agent.page_title"+ GEN_AI_AGENT_TABS_COUNT = "gen_ai.agent.tabs_count"+ GEN_AI_AGENT_INTERACTED_ELEMENTS_COUNT = "gen_ai.agent.interacted_elements_count"+ GEN_AI_AGENT_ACTIONS_SUCCESS_COUNT = "gen_ai.agent.actions_success_count"+ GEN_AI_AGENT_ACTIONS_ERROR_COUNT = "gen_ai.agent.actions_error_count"+ GEN_AI_AGENT_ACTION_ERRORS = "gen_ai.agent.action_errors"+ GEN_AI_AGENT_STEP_DURATION = "gen_ai.agent.step_duration"+ GEN_AI_AGENT_TOTAL_ACTIONS = "gen_ai.agent.total_actions"+ GEN_AI_AGENT_SUCCESSFUL_STEPS = "gen_ai.agent.successful_steps"+ GEN_AI_AGENT_FAILED_STEPS = "gen_ai.agent.failed_steps"+ GEN_AI_AGENT_SUCCESS_RATE = "gen_ai.agent.success_rate"+ GEN_AI_AGENT_FINAL_RESULT = "gen_ai.agent.final_result"++ # Browser-Use Operation Attributes+ GEN_AI_OPERATION_TYPE = "gen_ai.operation.type"+ GEN_AI_CLIENT_OPERATION_DURATION = "gen_ai.client.operation.duration"++ # Browser-Use Span Name Components+ GEN_AI_SPAN_INVOKE_MODEL = "invoke_model"++ GEN_AI_BROWSER_SESSION_DURATION = "gen_ai.browser.session.duration"+ GEN_AI_BROWSER_SESSION_ACTIONS_COUNT = "gen_ai.browser.session.actions_count"+ GEN_AI_BROWSER_SESSION_SUCCESS_RATE = "gen_ai.browser.session.success_rate"+ GEN_AI_BROWSER_PAGE_LOAD_TIME = "gen_ai.browser.page.load_time"+ GEN_AI_BROWSER_ACTION_SUCCESS = "gen_ai.browser.action.success"+ GEN_AI_BROWSER_ACTION_RETRY_COUNT = "gen_ai.browser.action.retry_count"+ GEN_AI_BROWSER_ERROR_TYPE = "gen_ai.browser.error.type"+ GEN_AI_BROWSER_ERROR_MESSAGE = "gen_ai.browser.error.message"+ GEN_AI_BROWSER_NETWORK_REQUESTS_COUNT = "gen_ai.browser.network.requests_count"+ GEN_AI_BROWSER_NETWORK_FAILED_REQUESTS = "gen_ai.browser.network.failed_requests"+ GEN_AI_BROWSER_MEMORY_USAGE = "gen_ai.browser.memory.usage"+ GEN_AI_BROWSER_CPU_USAGE = "gen_ai.browser.cpu.usage"+ GEN_AI_BROWSER_SCREENSHOT_CAPTURED = "gen_ai.browser.screenshot.captured"+ GEN_AI_BROWSER_VIDEO_RECORDING = "gen_ai.browser.video.recording"+ GEN_AI_BROWSER_DOM_CHANGES_COUNT = "gen_ai.browser.dom.changes_count"+ GEN_AI_BROWSER_JAVASCRIPT_ERRORS = "gen_ai.browser.javascript.errors"+ GEN_AI_BROWSER_CONSOLE_LOGS = "gen_ai.browser.console.logs"+ GEN_AI_BROWSER_NETWORK_TIMING = "gen_ai.browser.network.timing"+# GuardGUARD_REQUESTS = "guard.requests"GUARD_VERDICT = "guard.verdict"