feat(observability): add LangSmith as alternative tracing backend - #23
Merged
Conversation
@observable dispatches to langsmith.traceable when LANGSMITH_TRACING=true or DANA_LANGSMITH_ENABLED truthy; exclusive with Langfuse (LangSmith wins). No call-site changes — all 30+ @observable sites traced automatically. - observable.py: LANGSMITH>LANGFUSE>noop dispatch, _langsmith_kwargs adapter (as_type->run_type, session_id/user_id folded into metadata), bare-form normalization to avoid double-call, factored _langfuse_wrap preserves byte-equivalent flush behavior on the langfuse path - init_environment.py: _install_langsmith_shim mirrors the langfuse shim so the module imports cleanly without the extra installed - pyproject.toml: langsmith>=0.8,<0.9 added to [observability] extra - tests: 11 cases incl. SC7 langfuse flush regression (sync/bare/async) and async exclusivity - docs: tracing-backends section + silent no-op caveat + changelog entry Enable: pip install dana[observability]; LANGSMITH_TRACING=true LANGSMITH_API_KEY=...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds LangSmith as an alternative tracing backend for
@observable, mirroring the existing Langfuse integration. ONE backend active per process; selection at decoration time: LangSmith > Langfuse > no-op. No call-site changes — all 30+@observablesites (agents, workflows, LLM calls, codecs) traced automatically.Why
Operators want LangSmith as an option alongside Langfuse. Both are OTLP-capable, but a parallel backend behind the existing decorator is lower-risk than an OTLP pivot and matches the established
LANGFUSE_ENABLEDtoggle pattern.How to enable
Toggle back to Langfuse by unsetting
LANGSMITH_TRACINGand settingLANGFUSE_ENABLED=true.Changes
dana/common/observable.py— dispatch (LANGSMITH>LANGFUSE>noop),_langsmith_kwargsadapter (as_type→run_type,session_id/user_id→metadata), bare-form normalization (avoids double-call), factored_langfuse_wrappreserving byte-equivalent flush behavior on the langfuse path.dana/__init__/init_environment.py—_install_langsmith_shimmirrors the langfuse shim (clean import without the extra).pyproject.toml—langsmith>=0.8,<0.9in[observability]extra (langfuse pins untouched).tests/unit/test_observable_langsmith_dispatch.py— 11 mocked cases incl. SC7 langfuse flush regression (sync/bare/async) and async exclusivity.docs/codebase-summary.md— tracing-backends section + silent no-op caveat.docs/project-changelog.md— Added + Changed entries.Verification
langsmith==0.8.5.Scope / Out of scope
LangSmithPromptRepository(prompt management) — separate PR. LangSmith native versioning will also let us drop thedana_versionsconfig-stashing hack currently inLangfusePromptRepository.run_type="llm"forllm_caller.pyspans;process_inputsscrubbing forself(parity with langfuse).Breaking changes
None. Default behavior (no env set) is unchanged except
@observablenow returns the decorated function unchanged (identity) on the no-op path instead of a passthrough wrapper — improvesinspect.signature(), no introspection-sensitive call sites affected.