Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(data-warehouse): add 3 missing tables to the Langfuse source (#118299)

Tom Owers5978748fa88c
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
index 514119c20037..39f1e10aa933 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
@@ -7065,9 +7065,9 @@ Diffed against: <https://cloud.langfuse.com/generated/api/openapi.yml>
- [ ] `GET /api/public/dataset-run-items` — join table linking dataset items to the trace/observation produced in each eval run - without it synced dataset_items and traces cannot be joined (high) — skipped: deprecated, removed from Langfuse Cloud on 2026-11-16; superseded by `GET /api/public/experiment-items`
- [ ] `GET /api/public/datasets/{datasetName}/runs` — the eval run records that dataset-run-items and scores hang off; the unit of 'how did this prompt version do' (high) — skipped: deprecated, removed from Langfuse Cloud on 2026-11-16; superseded by `GET /api/public/experiments`
- [x] `GET /api/public/score-configs` — lookup that resolves the config, data type and categorical values behind the score rows already synced (high)
-- [ ] `GET /api/public/experiments and GET /api/public/experiment-items` — experiment runs and their per-item results, the headline eval surface (medium)
+- [x] `GET /api/public/experiments and GET /api/public/experiment-items` — experiment runs and their per-item results, the headline eval surface (medium)
- [x] `GET /api/public/annotation-queues, /{queueId}/items` — human annotation queue state and per-item status for review throughput analysis (medium)
-- [ ] `GET /api/public/comments` — human comments attached to traces/observations/sessions, useful for qualitative review joins (low)
+- [x] `GET /api/public/comments` — human comments attached to traces/observations/sessions, useful for qualitative review joins (low)
- [ ] `GET /api/public/organizations/memberships and /projects/{projectId}/memberships` — org/project membership lookup resolving user ids seen on traces and annotations (org-scoped key required) (low)
Note: Endpoint map in products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/settings.py is fully static - no dynamic table discovery. Some newer resources (dashboards, evaluators, evaluation-rules) sit under /api/public/unstable/ and are config-shaped, so excluded.
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/canonical_descriptions.py
index 8200717e26ec..aa8235fb55fa 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/canonical_descriptions.py
@@ -204,4 +204,56 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"updatedAt": "The timestamp when the item was last updated.",
},
},
+ "experiments": {
+ "description": "Experiment runs: one row per experiment, with its dataset and the time range and item count of its runs.",
+ "docs_url": "https://api.reference.langfuse.com/#tag/experiments/get/api/public/experiments",
+ "columns": {
+ "id": "The unique identifier of the experiment.",
+ "name": "The name of the experiment.",
+ "description": "A description of the experiment.",
+ "startTime": "The time of the earliest event of the experiment.",
+ "endTime": "The time of the latest event end of the experiment.",
+ "itemCount": "The number of experiment items in the experiment.",
+ "datasetId": "The dataset the experiment ran against. Null when the experiment has no dataset.",
+ "metadata": "The metadata of the experiment. Can be any JSON.",
+ },
+ },
+ "experiment_items": {
+ "description": "Per-item results of experiment runs: the input, output, and expected output of each item, and the trace it produced.",
+ "docs_url": "https://api.reference.langfuse.com/#tag/experiments/get/api/public/experiment-items",
+ "columns": {
+ "id": "The unique identifier of the experiment item run.",
+ "traceId": "The trace produced by this experiment item run.",
+ "startTime": "The time the experiment item run started.",
+ "endTime": "The time the experiment item run ended.",
+ "level": "The level of the experiment item run (DEBUG, DEFAULT, WARNING, or ERROR).",
+ "environment": "The environment the experiment item ran in.",
+ "experimentId": "The experiment this item run belongs to.",
+ "experimentName": "The name of the experiment this item run belongs to.",
+ "experimentItemId": "The identifier of the experiment item.",
+ "experimentDatasetId": "The dataset of the experiment.",
+ "experimentItemVersion": "The version of the dataset item used for this run.",
+ "input": "The input of the experiment item. Can be any JSON.",
+ "output": "The output the run produced. Can be any JSON.",
+ "expectedOutput": "The expected output of the experiment item. Can be any JSON.",
+ "metadata": "The metadata of the experiment item run. Can be any JSON.",
+ "experimentItemMetadata": "The metadata of the experiment item. Can be any JSON.",
+ "experimentMetadata": "The metadata of the experiment. Can be any JSON.",
+ "experimentDescription": "A description of the experiment.",
+ },
+ },
+ "comments": {
+ "description": "Comments that users add to traces, observations, sessions, and prompts.",
+ "docs_url": "https://api.reference.langfuse.com/#tag/comments/get/api/public/comments",
+ "columns": {
+ "id": "The unique identifier of the comment.",
+ "projectId": "The Langfuse project the comment belongs to.",
+ "createdAt": "The timestamp when the comment was created.",
+ "updatedAt": "The timestamp when the comment was last updated.",
+ "objectType": "The type of the object the comment is attached to (TRACE, OBSERVATION, SESSION, or PROMPT).",
+ "objectId": "The ID of the object the comment is attached to.",
+ "content": "The text of the comment.",
+ "authorUserId": "The user ID of the comment author.",
+ },
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/langfuse.py b/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/langfuse.py
index bc2fe9942d54..6a169535e90c 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/langfuse.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/langfuse.py
@@ -186,9 +186,12 @@ def _from_filter_value(
db_incremental_field_last_value: Any,
incremental_field: str | None,
) -> str | None:
- """The formatted lower-bound filter value for this run, or None for a full / first sync."""
+ """The formatted lower-bound filter value for this run.
+
+ A full or first sync gets the endpoint's required bound, which is None for most endpoints.
+ """
if not (should_use_incremental_field and db_incremental_field_last_value and config.incremental_filter_param):
- return None
+ return config.required_from_value
field = incremental_field or config.default_incremental_field
if field != config.default_incremental_field:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/settings.py
index cb699d01ce65..ef10fdff3f97 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/settings.py
@@ -65,6 +65,9 @@ class LangfuseEndpointConfig:
# Fan-out child: `path` holds a `{parent_id}` placeholder, filled with the `id` of every row of
# this parent endpoint.
parent: Optional[str] = None
+ # From-filter value sent when no incremental watermark applies, for endpoints that reject a
+ # request without a lower bound (experiments).
+ required_from_value: Optional[str] = None
_DEFAULT_LOOKBACK = timedelta(hours=1)
@@ -76,9 +79,16 @@ _OBSERVATION_FIELDS = "core,basic,time,io,metadata,model,usage,prompt,metrics,tr
# Score field groups added on top of the always-returned core fields.
_SCORE_FIELDS = "details,subject,annotation"
+# Experiment field groups. `scores` is left out: those rows are already synced by the scores table.
+_EXPERIMENT_FIELDS = "core,metadata"
+_EXPERIMENT_ITEM_FIELDS = "core,dataset,io,metadata,itemMetadata,experimentMetadata"
+
+# The experiments endpoints require fromStartTime, so a full sync sends a bound before any data.
+_EARLIEST_START_TIME = "1970-01-01T00:00:00Z"
+
# Endpoints cover the resources a user most commonly wants to analyze from an LLM observability
# platform: traces, observations, scores, sessions, prompts, datasets, model pricing, score
-# configs, and annotation queues.
+# configs, annotation queues, experiments, and comments.
# Incremental support is only declared where the API documents a server-side timestamp filter.
LANGFUSE_ENDPOINTS: dict[str, LangfuseEndpointConfig] = {
"traces": LangfuseEndpointConfig(
@@ -200,6 +210,41 @@ LANGFUSE_ENDPOINTS: dict[str, LangfuseEndpointConfig] = {
primary_keys=["queueId", "id"],
partition_key="createdAt",
),
+ "experiments": LangfuseEndpointConfig(
+ name="experiments",
+ path="/api/public/experiments",
+ pagination="cursor",
+ page_size=100, # documented maximum
+ # Full refresh only: startTime and itemCount are computed over the requested window, so a
+ # windowed incremental sync would overwrite each row with partial totals.
+ incremental_filter_param="fromStartTime",
+ required_from_value=_EARLIEST_START_TIME,
+ extra_params={"fields": _EXPERIMENT_FIELDS},
+ ),
+ "experiment_items": LangfuseEndpointConfig(
+ name="experiment_items",
+ path="/api/public/experiment-items",
+ pagination="cursor",
+ page_size=100, # documented maximum
+ incremental_fields=[_datetime_incremental_field("startTime")],
+ default_incremental_field="startTime",
+ incremental_filter_param="fromStartTime",
+ required_from_value=_EARLIEST_START_TIME,
+ extra_params={"fields": _EXPERIMENT_ITEM_FIELDS},
+ primary_keys=["experimentId", "id"],
+ partition_key="startTime",
+ # Documented as ordered by time descending.
+ sort_mode="desc",
+ incremental_lookback=_DEFAULT_LOOKBACK,
+ ),
+ "comments": LangfuseEndpointConfig(
+ name="comments",
+ path="/api/public/comments",
+ pagination="page",
+ page_size=50,
+ # Only filterable by object and author, not by time -> full refresh only.
+ partition_key="createdAt",
+ ),
}
ENDPOINTS = tuple(LANGFUSE_ENDPOINTS.keys())
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/tests/test_langfuse.py b/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/tests/test_langfuse.py
index aaddd9c25085..2099b7eb4743 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/tests/test_langfuse.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/tests/test_langfuse.py
@@ -243,6 +243,37 @@ class TestGetRows:
assert [r["id"] for r in result.rows] == ["o9"]
assert result.raised is None
+ @pytest.mark.parametrize(
+ "endpoint, last_value, incremental_field, expected_from",
+ [
+ ("experiments", None, None, "1970-01-01T00:00:00Z"),
+ ("experiment_items", None, None, "1970-01-01T00:00:00Z"),
+ (
+ "experiment_items",
+ datetime(2026, 3, 4, 10, 0, 0, tzinfo=UTC),
+ "startTime",
+ "2026-03-04T09:00:00Z",
+ ),
+ ],
+ )
+ def test_experiment_endpoints_send_a_lower_bound_on_every_page(
+ self, endpoint, last_value, incremental_field, expected_from
+ ):
+ # Both endpoints reject a request without fromStartTime, so a full sync must send one too.
+ result = _driver().run(
+ endpoint,
+ [
+ _cursor_page([{"id": "e1", "experimentId": "x1"}], cursor="next"),
+ _cursor_page([{"id": "e2", "experimentId": "x1"}], cursor=None),
+ ],
+ db_incremental_field_last_value=last_value,
+ incremental_field=incremental_field,
+ )
+ assert result.raised is None
+ assert [r["id"] for r in result.rows] == ["e1", "e2"]
+ assert result.params("fromStartTime") == [expected_from, expected_from]
+ assert result.params("cursor") == [None, "next"]
+
def test_rejects_plaintext_http_before_request(self):
result = _driver("http://langfuse.example.com").run("traces", [], api_version="v1")
assert isinstance(result.raised, langfuse_module.LangfuseHostNotAllowedError)