@@ -216,6 +216,50 @@ def test_get_base_url():
216216 assert exporter .base_url == "https://custom-trace.example.com/prefix"
217217
218218
219+ def test_internal_headers_set_when_trace_base_url_present ():
220+ """Test that internal tenant/account headers are set when UIPATH_TRACE_BASE_URL is configured."""
221+ with patch .dict (
222+ os .environ ,
223+ {
224+ "UIPATH_TRACE_BASE_URL" : "http://localhost:8888/llmops_" ,
225+ "UIPATH_ACCESS_TOKEN" : "test-token" ,
226+ "UIPATH_TENANT_ID" : "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" ,
227+ "UIPATH_ORGANIZATION_ID" : "11111111-2222-3333-4444-555555555555" ,
228+ },
229+ clear = True ,
230+ ):
231+ with patch ("uipath.tracing._otel_exporters.httpx.Client" ):
232+ exporter = LlmOpsHttpExporter ()
233+
234+ assert (
235+ exporter .headers ["X-UiPath-Internal-TenantId" ]
236+ == "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
237+ )
238+ assert (
239+ exporter .headers ["X-UiPath-Internal-AccountId" ]
240+ == "11111111-2222-3333-4444-555555555555"
241+ )
242+
243+
244+ def test_internal_headers_not_set_without_trace_base_url ():
245+ """Test that internal headers are NOT set when UIPATH_TRACE_BASE_URL is absent (cloud mode)."""
246+ with patch .dict (
247+ os .environ ,
248+ {
249+ "UIPATH_URL" : "https://cloud.uipath.com/org/tenant" ,
250+ "UIPATH_ACCESS_TOKEN" : "test-token" ,
251+ "UIPATH_TENANT_ID" : "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" ,
252+ "UIPATH_ORGANIZATION_ID" : "11111111-2222-3333-4444-555555555555" ,
253+ },
254+ clear = True ,
255+ ):
256+ with patch ("uipath.tracing._otel_exporters.httpx.Client" ):
257+ exporter = LlmOpsHttpExporter ()
258+
259+ assert "X-UiPath-Internal-TenantId" not in exporter .headers
260+ assert "X-UiPath-Internal-AccountId" not in exporter .headers
261+
262+
219263def test_send_with_retries_success ():
220264 """Test _send_with_retries method with successful response."""
221265 with patch ("uipath.tracing._otel_exporters.httpx.Client" ):
0 commit comments