Skip to content

chore(deps): bump langfuse from 3.14.5 to 4.0.4#3129

Merged
snopoke merged 4 commits into
mainfrom
dependabot/uv/langfuse-4.0.4
Apr 28, 2026
Merged

chore(deps): bump langfuse from 3.14.5 to 4.0.4#3129
snopoke merged 4 commits into
mainfrom
dependabot/uv/langfuse-4.0.4

Conversation

@dependabot

@dependabot dependabot Bot commented on behalf of github Apr 1, 2026

Copy link
Copy Markdown
Contributor

Bumps langfuse from 3.14.5 to 4.0.4.

Release notes

Sourced from langfuse's releases.

v3.163.0

What's Changed

Features

Fixes

Chores

... (truncated)

Commits

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

@dependabot dependabot Bot added dependencies Pull requests that update a dependency file python:uv Pull requests that update python:uv code labels Apr 1, 2026
@claude

claude Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

🔍 Dependency Analysis Summary

Package Old Version New Version Type
langfuse 3.14.5 4.0.4 Python (uv)

Overall Risk Assessment: 🔴 HIGH — This is a major version bump with multiple breaking API changes that directly affect OCS's tracing integration.


📋 Detailed Changelog Review

Package: langfuse (3.14.5 → 4.0.4)

Key Changes:

  • Dropped openai and requests as runtime dependencies (now uses httpx exclusively)
  • Pydantic v1 support dropped (requires Pydantic v2+)
  • Complete rework of the tracing/span API
  • Internal client class renamed
  • DatasetItemClient.run() removed
  • LangChain CallbackHandler: update_trace parameter removed

Breaking Changes:

  1. start_as_current_span()start_as_current_observation() — method renamed
  2. start_span() / start_generation()start_observation(as_type=...) — unified API
  3. span.update_trace() removed — replaced by propagate_attributes() context manager
  4. FernLangfuse (API client class) renamed to LangfuseAPI
  5. AsyncFernLangfuse renamed to AsyncLangfuseAPI
  6. API namespace restructured: langfuse.api.observations_v_2langfuse.api.observations, etc.
  7. release/environment attributes removed from trace — must use LANGFUSE_RELEASE / LANGFUSE_TRACING_ENVIRONMENT env vars

Migration Guide: langfuse/langfuse-python#1486


⚠️ Impact Assessment

Breaking Changes Found: YES — Multiple breaking changes directly hit OCS code.

Affected Files:

apps/service_providers/tracing/langfuse.py — 🔴 CRITICAL

  • Line 12: from langfuse._client.get_client import _create_client_from_instance — private API, likely moved/removed
  • Line 13: from langfuse._client.resource_manager import LangfuseResourceManager — private API, likely moved/removed
  • Line 23: from langfuse.api.client import FernLangfuse — class renamed to LangfuseAPI
  • Line 33-34: from langfuse.api.client import FernLangfuse (runtime import) — same rename issue
  • Line 82: self.client.start_as_current_span(...) — method renamed to start_as_current_observation()
  • Line 88-91: self.trace_record.update_trace(session_id=..., user_id=...)update_trace() removed; use propagate_attributes() instead
  • Line 120: self.client.start_as_current_span(...) — same rename as line 82

apps/service_providers/tests/test_langfuse_client_manager.py — 🔴 CRITICAL

  • Line 7: from langfuse._client.resource_manager import LangfuseResourceManager — private API import; if this moved, tests will break

apps/service_providers/management/commands/migrate_langfuse_data.py — 🟡 MEDIUM

  • Line 19-30: Imports from langfuse.api.resources.ingestion.types and langfuse.api.resources.commons.types — these namespaces may have been reorganized; needs verification

apps/trace/views.py — 🟡 MEDIUM

  • Line 101: Uses get_langfuse_api_client() which returns the renamed FernLangfuseLangfuseAPI; the api_client.trace.get() call pattern should still work if the rename is handled

Test Impact:

  • apps/service_providers/tests/test_langfuse_client_manager.py — relies on private LangfuseResourceManager internals
  • apps/service_providers/tests/test_ocs_tracer.py — likely mocks start_as_current_span which is renamed
  • apps/trace/tests/test_langfuse_spans_view.py — may be affected by FernLangfuse rename

Configuration Changes:

  • If release or environment were passed to Langfuse(...) in config, those kwargs are now removed; must use env vars LANGFUSE_RELEASE / LANGFUSE_TRACING_ENVIRONMENT

🛠️ Recommendations

Action Required: This PR requires code changes before merging. The core tracing integration (langfuse.py) will be broken at runtime.

Required fixes in apps/service_providers/tracing/langfuse.py:

  1. Replace start_as_current_span(...)start_as_current_observation(...) (lines 82, 120)
  2. Replace self.trace_record.update_trace(session_id=..., user_id=...) with the v4 propagate_attributes() pattern
  3. Update FernLangfuseLangfuseAPI import/type annotation
  4. Audit the _client.get_client._create_client_from_instance and LangfuseResourceManager private API usage — these may have changed paths or been removed entirely; the ClientManager class may need a different implementation approach

Testing Focus:

  • Run uv run pytest apps/service_providers/tests/test_langfuse_client_manager.py -v to confirm whether private API imports still resolve
  • Run uv run pytest apps/service_providers/tests/test_ocs_tracer.py -v to check span creation
  • Run uv run pytest apps/trace/tests/test_langfuse_spans_view.py -v

Follow-up Tasks:

  • Review migrate_langfuse_data.py ingestion type imports against v4 namespace structure
  • Check if any Langfuse(release=..., environment=...) kwargs are being passed via config dict (would silently fail or raise)

Merge Recommendation: 🔴 HOLD — Do not merge without updating apps/service_providers/tracing/langfuse.py and related tests. The tracing integration will fail at runtime for all Langfuse trace providers.


📚 Useful Links

Bumps [langfuse](https://github.com/langfuse/langfuse) from 3.14.5 to 4.0.4.
- [Release notes](https://github.com/langfuse/langfuse/releases)
- [Commits](https://github.com/langfuse/langfuse/commits)

---
updated-dependencies:
- dependency-name: langfuse
  dependency-version: 4.0.4
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
@dependabot dependabot Bot force-pushed the dependabot/uv/langfuse-4.0.4 branch from 46557d0 to a58b4bb Compare April 23, 2026 12:14
@claude

claude Bot commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

🔍 Dependency Analysis Summary

Package Old Version New Version Risk
langfuse 3.14.5 4.5.0 🔴 HIGH

⚠️ Version discrepancy: The PR title says "bump to 4.0.4" but the uv.lock resolves to 4.5.0 (the latest stable at the time). The pyproject.toml minimum changed from >=2.59.7 to >=4.5.0.

Overall Risk: 🔴 HIGH — Multiple breaking changes require code updates before merging.


📋 Detailed Changelog Review

Package: langfuse (3.14.5 → 4.5.0)

Architectural Shift: v4 is a ground-up rewrite built on OpenTelemetry (OTel). The SDK now depends on opentelemetry-api, opentelemetry-exporter-otlp-proto-http, and opentelemetry-sdk instead of the former openai and requests dependencies.

Key Changes:

  • All tracing methods are now OTel-based spans under the hood
  • start_as_current_span() renamed to start_as_current_observation()
  • update_trace() on span objects has been removed — session/user attributes now use langfuse.propagate_attributes() context manager
  • FernLangfuse API client class renamed to LangfuseAPI
  • Module structure restructured: langfuse.api.resources.*langfuse.api.*

Security Fixes: None noted in this release series.

Migration guide: https://langfuse.com/docs/observability/sdk/upgrade-path/python-v3-to-v4


⚠️ Impact Assessment

Breaking Changes Found: YES — 5 breaking issues confirmed by importing against the installed v4.5.0.

Affected Files

apps/service_providers/tracing/langfuse.py — 3 breaks

  1. ImportError on startup (line 23):

    # BROKEN:
    from langfuse.api.client import FernLangfuse
    # FIX:
    from langfuse.api.client import LangfuseAPI

    Also update the type annotation on get_langfuse_api_client() return type and FernLangfuse usage in the TYPE_CHECKING block.

  2. AttributeError at trace start (line ~77):

    # BROKEN — method no longer exists:
    with self.client.start_as_current_span(name=..., input=..., metadata=...) as trace:
    # FIX:
    with self.client.start_as_current_observation(name=..., input=..., metadata=...) as trace:

    Same fix applies to the inner span context manager in LangFuseTracer.span().

  3. AttributeError when setting trace session/user (line ~84):

    # BROKEN — update_trace() removed from span objects:
    self.trace_record.update_trace(session_id=str(session.external_id), user_id=session.participant.identifier)
    # FIX — use propagate_attributes() wrapping the entire trace() context:
    with self.client.propagate_attributes(
        session_id=str(session.external_id),
        user_id=session.participant.identifier,
    ):
        with self.client.start_as_current_observation(...) as trace:
            ...

    Note: trace_record.trace_id and span.update() / span.create_event() still work in v4. ✅

apps/service_providers/management/commands/migrate_langfuse_data.py — 2 breaks

  1. ModuleNotFoundError (line 18):

    # BROKEN — langfuse.api.resources.* path removed:
    from langfuse.api.resources.commons.types import Usage
    # FIX:
    from langfuse.api.commons.types import Usage
  2. ModuleNotFoundError (lines 19-29):

    # BROKEN:
    from langfuse.api.resources.ingestion.types import (CreateEventBody, ...)
    # FIX:
    from langfuse.api.ingestion.types import (CreateEventBody, ...)

Test Impact

  • apps/service_providers/tests/test_langfuse_client_manager.py — tests use LangfuseResourceManager (private API) which still exists in v4 ✅
  • apps/service_providers/tests/test_ocs_tracer.py — likely mocks start_as_current_span; will need updating
  • All tests exercising LangFuseTracer.trace() or LangFuseTracer.span() will fail

Configuration Changes

None required — environment variables and credentials format unchanged.


🛠️ Recommendations

Action Required: Do NOT merge — 5 confirmed runtime/import errors will break Langfuse tracing in production.

Required fixes before merge:

  1. apps/service_providers/tracing/langfuse.py:
    • Replace FernLangfuse import/annotation → LangfuseAPI
    • Replace start_as_current_span(...)start_as_current_observation(...) (2 call sites: trace() and span())
    • Replace trace_record.update_trace(session_id=..., user_id=...) → wrap with client.propagate_attributes(session_id=..., user_id=...)
  2. apps/service_providers/management/commands/migrate_langfuse_data.py:
    • Update langfuse.api.resources.commons.typeslangfuse.api.commons.types
    • Update langfuse.api.resources.ingestion.typeslangfuse.api.ingestion.types

Testing Focus:

  • Run apps/service_providers/tests/test_ocs_tracer.py and test_langfuse_client_manager.py after fixes
  • Manual test of a trace session end-to-end with a real Langfuse project to verify session_id/user_id propagation still works correctly

Follow-up Tasks:

  • Check if LangfuseCallbackHandler.on_custom_event still works — the parent _get_parent_observation method exists but on_custom_event is not defined in v4's CallbackHandler; the OCS subclass overrides it which should be fine.
  • Consider pinning langfuse>=4.5.0,<5 to prevent future major-version surprises.

Merge Recommendation: 🔴 HOLD — Requires companion PR fixing the 5 breaking API usages listed above.


📚 Useful Links

Breaking changes in langfuse 3→4:
- FernLangfuse renamed to LangfuseAPI
- start_as_current_span() → start_as_current_observation()
- update_trace() removed; use propagate_attributes() context manager instead
  (must wrap the outer observation to set session_id/user_id on root span)
- span.update(tags=...) no longer supported; use
  _create_trace_tags_via_ingestion() for trace-level tags
- langfuse.api.resources.{commons,ingestion}.types namespace dropped;
  now langfuse.api.{commons,ingestion}.types

Closes #3129
snopoke and others added 2 commits April 23, 2026 17:43
In v4, client.get_trace_url() makes a blocking HTTP call to fetch the
project_id. If that raises, TracingService's broad except used to drop the
entire langfuse entry from trace_info, so ChatMessage.metadata ended up
with no langfuse trace data. Isolate the URL fetch so trace_id still lands
in metadata regardless.

Capture the langfuse trace id via client.get_current_trace_id() on context
entry and reuse it for get_trace_metadata() and add_trace_tags().

Add regression tests that exercise the TracingService -> LangFuseTracer
path with a realistic mock client, including the URL-fetch failure case.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
fix: update OCS langfuse integration for v4 SDK
@snopoke snopoke merged commit 556be55 into main Apr 28, 2026
13 checks passed
@snopoke snopoke deleted the dependabot/uv/langfuse-4.0.4 branch April 28, 2026 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file python:uv Pull requests that update python:uv code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant