diff --git a/litellm/integrations/opentelemetry.py b/litellm/integrations/opentelemetry.py index 7aea333ee9..997dd044a6 100644 --- a/litellm/integrations/opentelemetry.py +++ b/litellm/integrations/opentelemetry.py @@ -144,6 +144,7 @@ class OpenTelemetry(CustomLogger): self.OTEL_EXPORTER = self.config.exporter self.OTEL_ENDPOINT = self.config.endpoint self.OTEL_HEADERS = self.config.headers + self._tracer_provider_cache: Dict[str, Any] = {} self._init_tracing(tracer_provider) _debug_otel = str(os.getenv("DEBUG_OTEL", "False")).lower() @@ -615,12 +616,20 @@ class OpenTelemetry(CustomLogger): """Create a temporary tracer with dynamic headers for this request only.""" from opentelemetry.sdk.trace import TracerProvider + # Prevents thread exhaustion by reusing providers for the same credential sets (e.g. per-team keys) + cache_key = str(sorted(dynamic_headers.items())) + if cache_key in self._tracer_provider_cache: + return self._tracer_provider_cache[cache_key].get_tracer(LITELLM_TRACER_NAME) + # Create a temporary tracer provider with dynamic headers temp_provider = TracerProvider(resource=self._get_litellm_resource(self.config)) temp_provider.add_span_processor( self._get_span_processor(dynamic_headers=dynamic_headers) ) + # Store in cache for reuse + self._tracer_provider_cache[cache_key] = temp_provider + return temp_provider.get_tracer(LITELLM_TRACER_NAME) def construct_dynamic_otel_headers( diff --git a/litellm/llms/vertex_ai/common_utils.py b/litellm/llms/vertex_ai/common_utils.py index 152b99ca4d..a0e2ddf5e9 100644 --- a/litellm/llms/vertex_ai/common_utils.py +++ b/litellm/llms/vertex_ai/common_utils.py @@ -849,7 +849,7 @@ def get_vertex_model_id_from_url(url: str) -> Optional[str]: `https://${LOCATION}-aiplatform.googleapis.com/v1/projects/${PROJECT_ID}/locations/${LOCATION}/publishers/google/models/${MODEL_ID}:streamGenerateContent` """ - match = re.search(r"/models/([^/:]+)", url) + match = re.search(r"/models/([^:]+)", url) return match.group(1) if match else None diff --git a/litellm/proxy/_experimental/out/404.html b/litellm/proxy/_experimental/out/404.html index de67ea1428..4044871809 100644 --- a/litellm/proxy/_experimental/out/404.html +++ b/litellm/proxy/_experimental/out/404.html @@ -1 +1 @@ -
=1e7/2&&++S;do f=0,(u=e(T,v,P,m))<0?(b=v[0],P!=m&&(b=1e7*b+(v[1]||0)),(f=b/S|0)>1?(f>=1e7&&(f=1e7-1),h=(p=t(T,f)).length,m=v.length,1==(u=e(p,v,h,m))&&(f--,r(p,P 0?i=i.charAt(0)+"."+i.slice(1)+j(n):a>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(o<0?"e":"e+")+o):o<0?(i="0."+j(-o-1)+i,r&&(n=r-a)>0&&(i+=j(n))):o>=a?(i+=j(o+1-a),r&&(n=r-o-1)>0&&(i=i+"."+j(n))):((n=o+1)0&&(o+1===a&&(i+="."),i+=j(n))),t.s<0?"-"+i:i}function M(t,e){if(t.length>e)return t.length=e,!0}function _(t){if(!t||"object"!=typeof t)throw Error(c+"Object expected");var e,r,n,o=["precision",1,1e9,"rounding",0,8,"toExpNeg",-1/0,0,"toExpPos",0,1/0];for(e=0;e-1&&t%1==0&&t0&&360>Math.abs(g-x)?d({cx:a,cy:c,innerRadius:s,outerRadius:p,cornerRadius:Math.min(S,j/2),forceCornerRadius:m,cornerIsExternal:b,startAngle:g,endAngle:x}):h({cx:a,cy:c,innerRadius:s,outerRadius:p,startAngle:g,endAngle:x}),n.createElement("path",l({},(0,i.L6)(r,!0),{className:O,d:e,role:"img"}))}},14870:function(t,e,r){"use strict";r.d(e,{v:function(){return N}});var n=r(2265),o=r(75551),i=r.n(o);let a=Math.cos,u=Math.sin,c=Math.sqrt,l=Math.PI,s=2*l;var f={draw(t,e){let r=c(e/l);t.moveTo(r,0),t.arc(0,0,r,0,s)}};let p=c(1/3),h=2*p,d=u(l/10)/u(7*l/10),y=u(s/10)*d,v=-a(s/10)*d,m=c(3),b=c(3)/2,g=1/c(12),x=(g/2+1)*3;var w=r(76115),O=r(67790);c(3),c(3);var j=r(87602),S=r(82944);function P(t){return(P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var E=["type","size","sizeType"];function k(){return(k=Object.assign?Object.assign.bind():function(t){for(var e=1;e=s&&f<=l}return r?p(p({},e),{},{radius:o,angle:f+360*Math.min(Math.floor(e.startAngle/360),Math.floor(e.endAngle/360))}):null},j=function(t){return(0,i.isValidElement)(t)||u()(t)||"boolean"==typeof t?"":t.className}},82944:function(t,e,r){"use strict";r.d(e,{$R:function(){return R},Bh:function(){return B},Gf:function(){return j},L6:function(){return N},NN:function(){return k},TT:function(){return M},eu:function(){return L},jf:function(){return T},rL:function(){return D},sP:function(){return A}});var n=r(13735),o=r.n(n),i=r(77571),a=r.n(i),u=r(42715),c=r.n(u),l=r(86757),s=r.n(l),f=r(28302),p=r.n(f),h=r(2265),d=r(14326),y=r(16630),v=r(46485),m=r(41637),b=["children"],g=["children"];function x(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(e.indexOf(n)>=0)continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n-1===e.slice(1,-1).indexOf(":")?void 0:(()=>{let r=e.slice(1,-1),o=r.indexOf(":"),t=r.slice(0,o);return t?"arbitrary.."+t:void 0})(),c=e=>{let{theme:r,classGroups:o}=e;return m(o,r)},m=(e,r)=>{let o=n();for(let t in e)p(e[t],o,t,r);return o},p=(e,r,o,t)=>{let l=e.length;for(let n=0;n{let{componentCls:e,antCls:n}=t;return{[e]:{display:"inline-flex","&-rtl":{direction:"rtl"},"&-vertical":{flexDirection:"column"},"&-align":{flexDirection:"column","&-center":{alignItems:"center"},"&-start":{alignItems:"flex-start"},"&-end":{alignItems:"flex-end"},"&-baseline":{alignItems:"baseline"}},["".concat(e,"-item:empty")]:{display:"none"},["".concat(e,"-item > ").concat(n,"-badge-not-a-wrapper:only-child")]:{display:"block"}}}},E=t=>{let{componentCls:e}=t;return{[e]:{"&-gap-row-small":{rowGap:t.spaceGapSmallSize},"&-gap-row-middle":{rowGap:t.spaceGapMiddleSize},"&-gap-row-large":{rowGap:t.spaceGapLargeSize},"&-gap-col-small":{columnGap:t.spaceGapSmallSize},"&-gap-col-middle":{columnGap:t.spaceGapMiddleSize},"&-gap-col-large":{columnGap:t.spaceGapLargeSize}}}};var w=(0,p.I$)("Space",t=>{let e=(0,O.IX)(t,{spaceGapSmallSize:t.paddingXS,spaceGapMiddleSize:t.padding,spaceGapLargeSize:t.paddingLG});return[S(e),E(e)]},()=>({}),{resetStyle:!1}),x=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&0>e.indexOf(o)&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,o=Object.getOwnPropertySymbols(t);a=0&&ex.current.focus(e)}e9(null)},[e8]);var e7=r.useMemo(function(){return(!ej||null!==eT)&&ej},[ej,eT]),te=(0,d.Z)(function(e,t){e3(e,t),null==K||K(eX(eV))}),tt=-1!==eQ;r.useEffect(function(){if(!tt){var e=eV.lastIndexOf(e0);ex.current.focus(e)}},[tt]);var tn=r.useMemo(function(){return(0,l.Z)(e2).sort(function(e,t){return e-t})},[e2]),tr=r.useMemo(function(){return eP?[tn[0],tn[tn.length-1]]:[eL,tn[0]]},[tn,eP,eL]),ta=(0,u.Z)(tr,2),ts=ta[0],ti=ta[1];r.useImperativeHandle(t,function(){return{focus:function(){ex.current.focus(0)},blur:function(){var e,t=document.activeElement;null!==(e=eM.current)&&void 0!==e&&e.contains(t)&&(null==t||t.blur())}}}),r.useEffect(function(){N&&ex.current.focus(0)},[]);var to=r.useMemo(function(){return{min:eL,max:eZ,direction:eE,disabled:A,keyboard:T,step:eT,included:ei,includedStart:ts,includedEnd:ti,range:eP,tabIndex:ey,ariaLabelForHandle:ew,ariaLabelledByForHandle:e_,ariaRequired:ek,ariaValueTextFormatterForHandle:eS,styles:C||{},classNames:M||{}}},[eL,eZ,eE,A,T,eT,ei,ts,ti,eP,ey,ew,e_,ek,eS,C,M]);return r.createElement(_.Provider,{value:to},r.createElement("div",{ref:eM,className:s()(k,S,(0,o.Z)((0,o.Z)((0,o.Z)((0,o.Z)({},"".concat(k,"-disabled"),A),"".concat(k,"-vertical"),ea),"".concat(k,"-horizontal"),!ea),"".concat(k,"-with-marks"),ez.length)),style:x,onMouseDown:function(e){e.preventDefault();var t,n=eM.current.getBoundingClientRect(),r=n.width,a=n.height,s=n.left,i=n.top,o=n.bottom,l=n.right,c=e.clientX,u=e.clientY;switch(eE){case"btt":t=(o-u)/a;break;case"ttb":t=(u-i)/a;break;case"rtl":t=(l-c)/r;break;default:t=(c-s)/r}e6(eD(eL+t*(eZ-eL)),e)},id:P},r.createElement("div",{className:s()("".concat(k,"-rail"),null==M?void 0:M.rail),style:(0,i.Z)((0,i.Z)({},eu),null==C?void 0:C.rail)}),!1!==eb&&r.createElement(I,{prefixCls:k,style:el,values:eV,startPoint:eo,onStartMove:e7?te:void 0}),r.createElement(O,{prefixCls:k,marks:ez,dots:ep,style:ed,activeStyle:eh}),r.createElement(E,{ref:ex,prefixCls:k,style:ec,values:e2,draggingIndex:eQ,draggingDelete:e1,onStartMove:te,onOffsetChange:function(e,t){if(!A){var n=eB(eV,e,t);null==K||K(eX(eV)),eJ(n.values),e9(n.value)}},onFocus:z,onBlur:$,handleRender:eg,activeHandleRender:em,onChangeComplete:eG,onDelete:eO?function(e){if(!A&&eO&&!(eV.length<=eI)){var t=(0,l.Z)(eV);t.splice(e,1),null==K||K(eX(t)),eJ(t),ex.current.hideHelp(),ex.current.focus(Math.max(0,e-1))}}:void 0}),r.createElement(R,{prefixCls:k,marks:ez,onClick:e6})))}),N=n(53346),z=n(86586);let $=(0,r.createContext)({});var q=n(28791),D=n(99981);let B=r.forwardRef((e,t)=>{let{open:n,draggingDelete:a,value:s}=e,i=(0,r.useRef)(null),o=n&&!a,l=(0,r.useRef)(null);function c(){N.Z.cancel(l.current),l.current=null}return r.useEffect(()=>(o?l.current=(0,N.Z)(()=>{var e;null===(e=i.current)||void 0===e||e.forceAlign(),l.current=null}):c(),c),[o,e.title,s]),r.createElement(D.Z,Object.assign({ref:(0,q.sQ)(i,t)},e,{open:o}))});var H=n(93463),U=n(54558),W=n(12918),F=n(99320),V=n(71140);let X=e=>{let{componentCls:t,antCls:n,controlSize:r,dotSize:a,marginFull:s,marginPart:i,colorFillContentHover:o,handleColorDisabled:l,calc:c,handleSize:u,handleSizeHover:d,handleActiveColor:h,handleActiveOutlineColor:f,handleLineWidth:p,handleLineWidthHover:g,motionDurationMid:m}=e;return{[t]:Object.assign(Object.assign({},(0,W.Wf)(e)),{position:"relative",height:r,margin:"".concat((0,H.bf)(i)," ").concat((0,H.bf)(s)),padding:0,cursor:"pointer",touchAction:"none","&-vertical":{margin:"".concat((0,H.bf)(s)," ").concat((0,H.bf)(i))},["".concat(t,"-rail")]:{position:"absolute",backgroundColor:e.railBg,borderRadius:e.borderRadiusXS,transition:"background-color ".concat(m)},["".concat(t,"-track,").concat(t,"-tracks")]:{position:"absolute",transition:"background-color ".concat(m)},["".concat(t,"-track")]:{backgroundColor:e.trackBg,borderRadius:e.borderRadiusXS},["".concat(t,"-track-draggable")]:{boxSizing:"content-box",backgroundClip:"content-box",border:"solid rgba(0,0,0,0)"},"&:hover":{["".concat(t,"-rail")]:{backgroundColor:e.railHoverBg},["".concat(t,"-track")]:{backgroundColor:e.trackHoverBg},["".concat(t,"-dot")]:{borderColor:o},["".concat(t,"-handle::after")]:{boxShadow:"0 0 0 ".concat((0,H.bf)(p)," ").concat(e.colorPrimaryBorderHover)},["".concat(t,"-dot-active")]:{borderColor:e.dotActiveBorderColor}},["".concat(t,"-handle")]:{position:"absolute",width:u,height:u,outline:"none",userSelect:"none","&-dragging-delete":{opacity:0},"&::before":{content:'""',position:"absolute",insetInlineStart:c(p).mul(-1).equal(),insetBlockStart:c(p).mul(-1).equal(),width:c(u).add(c(p).mul(2)).equal(),height:c(u).add(c(p).mul(2)).equal(),backgroundColor:"transparent"},"&::after":{content:'""',position:"absolute",insetBlockStart:0,insetInlineStart:0,width:u,height:u,backgroundColor:e.colorBgElevated,boxShadow:"0 0 0 ".concat((0,H.bf)(p)," ").concat(e.handleColor),outline:"0px solid transparent",borderRadius:"50%",cursor:"pointer",transition:"\n inset-inline-start ".concat(m,",\n inset-block-start ").concat(m,",\n width ").concat(m,",\n height ").concat(m,",\n box-shadow ").concat(m,",\n outline ").concat(m,"\n ")},"&:hover, &:active, &:focus":{"&::before":{insetInlineStart:c(d).sub(u).div(2).add(g).mul(-1).equal(),insetBlockStart:c(d).sub(u).div(2).add(g).mul(-1).equal(),width:c(d).add(c(g).mul(2)).equal(),height:c(d).add(c(g).mul(2)).equal()},"&::after":{boxShadow:"0 0 0 ".concat((0,H.bf)(g)," ").concat(h),outline:"6px solid ".concat(f),width:d,height:d,insetInlineStart:e.calc(u).sub(d).div(2).equal(),insetBlockStart:e.calc(u).sub(d).div(2).equal()}}},["&-lock ".concat(t,"-handle")]:{"&::before, &::after":{transition:"none"}},["".concat(t,"-mark")]:{position:"absolute",fontSize:e.fontSize},["".concat(t,"-mark-text")]:{position:"absolute",display:"inline-block",color:e.colorTextDescription,textAlign:"center",wordBreak:"keep-all",cursor:"pointer",userSelect:"none","&-active":{color:e.colorText}},["".concat(t,"-step")]:{position:"absolute",background:"transparent",pointerEvents:"none"},["".concat(t,"-dot")]:{position:"absolute",width:a,height:a,backgroundColor:e.colorBgElevated,border:"".concat((0,H.bf)(p)," solid ").concat(e.dotBorderColor),borderRadius:"50%",cursor:"pointer",transition:"border-color ".concat(e.motionDurationSlow),pointerEvents:"auto","&-active":{borderColor:e.dotActiveBorderColor}},["&".concat(t,"-disabled")]:{cursor:"not-allowed",["".concat(t,"-rail")]:{backgroundColor:"".concat(e.railBg," !important")},["".concat(t,"-track")]:{backgroundColor:"".concat(e.trackBgDisabled," !important")},["\n ".concat(t,"-dot\n ")]:{backgroundColor:e.colorBgElevated,borderColor:e.trackBgDisabled,boxShadow:"none",cursor:"not-allowed"},["".concat(t,"-handle::after")]:{backgroundColor:e.colorBgElevated,cursor:"not-allowed",width:u,height:u,boxShadow:"0 0 0 ".concat((0,H.bf)(p)," ").concat(l),insetInlineStart:0,insetBlockStart:0},["\n ".concat(t,"-mark-text,\n ").concat(t,"-dot\n ")]:{cursor:"not-allowed !important"}},["&-tooltip ".concat(n,"-tooltip-inner")]:{minWidth:"unset"}})}},J=(e,t)=>{let{componentCls:n,railSize:r,handleSize:a,dotSize:s,marginFull:i,calc:o}=e,l=t?"width":"height",c=t?"height":"width",u=t?"insetBlockStart":"insetInlineStart",d=t?"top":"insetInlineStart",h=o(r).mul(3).sub(a).div(2).equal(),f=o(a).sub(r).div(2).equal(),p=t?{borderWidth:"".concat((0,H.bf)(f)," 0"),transform:"translateY(".concat((0,H.bf)(o(f).mul(-1).equal()),")")}:{borderWidth:"0 ".concat((0,H.bf)(f)),transform:"translateX(".concat((0,H.bf)(e.calc(f).mul(-1).equal()),")")};return{[t?"paddingBlock":"paddingInline"]:r,[c]:o(r).mul(3).equal(),["".concat(n,"-rail")]:{[l]:"100%",[c]:r},["".concat(n,"-track,").concat(n,"-tracks")]:{[c]:r},["".concat(n,"-track-draggable")]:Object.assign({},p),["".concat(n,"-handle")]:{[u]:h},["".concat(n,"-mark")]:{insetInlineStart:0,top:0,[d]:o(r).mul(3).add(t?0:i).equal(),[l]:"100%"},["".concat(n,"-step")]:{insetInlineStart:0,top:0,[d]:r,[l]:"100%",[c]:r},["".concat(n,"-dot")]:{position:"absolute",[u]:o(r).sub(s).div(2).equal()}}},G=e=>{let{componentCls:t,marginPartWithMark:n}=e;return{["".concat(t,"-horizontal")]:Object.assign(Object.assign({},J(e,!0)),{["&".concat(t,"-with-marks")]:{marginBottom:n}})}},K=e=>{let{componentCls:t}=e;return{["".concat(t,"-vertical")]:Object.assign(Object.assign({},J(e,!1)),{height:"100%"})}};var Y=(0,F.I$)("Slider",e=>{let t=(0,V.IX)(e,{marginPart:e.calc(e.controlHeight).sub(e.controlSize).div(2).equal(),marginFull:e.calc(e.controlSize).div(2).equal(),marginPartWithMark:e.calc(e.controlHeightLG).sub(e.controlSize).equal()});return[X(t),G(t),K(t)]},e=>{let t=e.controlHeightLG/4,n=e.controlHeightSM/2,r=e.lineWidth+1,a=e.lineWidth+1.5,s=e.colorPrimary,i=new U.t(s).setA(.2).toRgbString();return{controlSize:t,railSize:4,handleSize:t,handleSizeHover:n,dotSize:8,handleLineWidth:r,handleLineWidthHover:a,railBg:e.colorFillTertiary,railHoverBg:e.colorFillSecondary,trackBg:e.colorPrimaryBorder,trackHoverBg:e.colorPrimaryBorderHover,handleColor:e.colorPrimaryBorder,handleActiveColor:s,handleActiveOutlineColor:i,handleColorDisabled:new U.t(e.colorTextDisabled).onBackground(e.colorBgContainer).toHexString(),dotBorderColor:e.colorBorderSecondary,dotActiveBorderColor:e.colorPrimaryBorder,trackBgDisabled:e.colorBgContainerDisabled}});function Q(){let[e,t]=r.useState(!1),n=r.useRef(null),a=()=>{N.Z.cancel(n.current)};return r.useEffect(()=>a,[]),[e,e=>{a(),e?t(e):n.current=(0,N.Z)(()=>{t(e)})}]}var ee=n(71744),et=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&0>t.indexOf(r)&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,r=Object.getOwnPropertySymbols(e);a