Skip to content

Commit a02f57d

Browse files
fix(ai): use PostHog AI OTLP endpoint /i/v0/ai/otel
Aligns with the endpoint used by the OTel examples in PR #482. Generated-By: PostHog Code Task-Id: 1ba1f07a-1453-4162-90a8-665958c5fe46
1 parent f8790c0 commit a02f57d

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

posthog/ai/otel/exporter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(
5050
self._host = host.rstrip("/")
5151

5252
self._exporter = OTLPSpanExporter(
53-
endpoint=f"{self._host}/v1/traces",
53+
endpoint=f"{self._host}/i/v0/ai/otel",
5454
headers={"Authorization": f"Bearer {self._api_key}"},
5555
)
5656

posthog/ai/otel/processor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def __init__(
4949
self._host = host.rstrip("/")
5050

5151
exporter = OTLPSpanExporter(
52-
endpoint=f"{self._host}/v1/traces",
52+
endpoint=f"{self._host}/i/v0/ai/otel",
5353
headers={"Authorization": f"Bearer {self._api_key}"},
5454
)
5555
self._processor = BatchSpanProcessor(exporter)

posthog/test/ai/otel/test_exporter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ class TestPostHogTraceExporter(unittest.TestCase):
1818
def test_configures_exporter_with_correct_endpoint(self, mock_otlp_cls):
1919
PostHogTraceExporter(api_key="phc_test123")
2020
mock_otlp_cls.assert_called_once_with(
21-
endpoint="https://us.i.posthog.com/v1/traces",
21+
endpoint="https://us.i.posthog.com/i/v0/ai/otel",
2222
headers={"Authorization": "Bearer phc_test123"},
2323
)
2424

2525
@patch("posthog.ai.otel.exporter.OTLPSpanExporter")
2626
def test_configures_custom_host(self, mock_otlp_cls):
2727
PostHogTraceExporter(api_key="phc_test", host="https://eu.i.posthog.com")
2828
mock_otlp_cls.assert_called_once_with(
29-
endpoint="https://eu.i.posthog.com/v1/traces",
29+
endpoint="https://eu.i.posthog.com/i/v0/ai/otel",
3030
headers={"Authorization": "Bearer phc_test"},
3131
)
3232

posthog/test/ai/otel/test_processor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_configures_exporter_with_correct_endpoint(
1919
):
2020
PostHogSpanProcessor(api_key="phc_test123")
2121
mock_otlp_cls.assert_called_once_with(
22-
endpoint="https://us.i.posthog.com/v1/traces",
22+
endpoint="https://us.i.posthog.com/i/v0/ai/otel",
2323
headers={"Authorization": "Bearer phc_test123"},
2424
)
2525
mock_batch_cls.assert_called_once_with(mock_otlp_cls.return_value)
@@ -29,7 +29,7 @@ def test_configures_exporter_with_correct_endpoint(
2929
def test_configures_custom_host(self, mock_batch_cls, mock_otlp_cls):
3030
PostHogSpanProcessor(api_key="phc_test", host="https://eu.i.posthog.com")
3131
mock_otlp_cls.assert_called_once_with(
32-
endpoint="https://eu.i.posthog.com/v1/traces",
32+
endpoint="https://eu.i.posthog.com/i/v0/ai/otel",
3333
headers={"Authorization": "Bearer phc_test"},
3434
)
3535

@@ -38,7 +38,7 @@ def test_configures_custom_host(self, mock_batch_cls, mock_otlp_cls):
3838
def test_strips_trailing_slash_from_host(self, mock_batch_cls, mock_otlp_cls):
3939
PostHogSpanProcessor(api_key="phc_test", host="https://us.i.posthog.com/")
4040
mock_otlp_cls.assert_called_once_with(
41-
endpoint="https://us.i.posthog.com/v1/traces",
41+
endpoint="https://us.i.posthog.com/i/v0/ai/otel",
4242
headers={"Authorization": "Bearer phc_test"},
4343
)
4444

0 commit comments

Comments
 (0)