feat: Add Openlayer Integration#10699
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThis PR introduces OpenLayer integration to LangFlow's tracing system. Changes include a new OpenlayerTracer class handling trace creation and hierarchy construction, integration into the tracing service, dependency addition, documentation, and test updates. Changes
Sequence Diagram(s)sequenceDiagram
participant Flow as LangFlow Flow
participant Svc as Tracing Service
participant OT as OpenlayerTracer
participant SDK as OpenLayer SDK
Flow->>Svc: start_tracers(trace_context)
Svc->>OT: __init__(trace_name, trace_id, ...)
OT->>OT: _get_config() resolves api_key & pipeline_id
Note over OT: Configuration resolved,<br/>SDK setup deferred
Flow->>OT: add_trace(trace_id, inputs, vertex, ...)
OT->>OT: Convert LangFlow types to OpenLayer StepTypes
OT->>OT: Build step hierarchy from vertex
OT->>OT: Store in _openlayer_steps & traces
Flow->>OT: end_trace(trace_id, outputs, error, ...)
OT->>OT: Finalize step (timing, outputs, errors, logs)
OT->>OT: Clear context
Flow->>OT: end(inputs, outputs, error, ...)
OT->>OT: setup_openlayer() initializes SDK
OT->>OT: Build final trace hierarchy
OT->>SDK: Stream trace to inference pipeline
Note over SDK: Async processing
OT->>OT: Cleanup on success/error
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touchesImportant Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 3 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (4)
src/backend/tests/unit/services/tracing/test_tracing_service.py (1)
121-123: Test coverage for Openlayer tracer registration is adequatePatching
_get_openlayer_tracerto returnMockTracerand asserting"openlayer"intrace_context.tracerskeeps the tests aligned with the new tracer without requiring the actual Openlayer SDK at test time. The fixture structure and the new assertion are consistent with the existing tracers; no issues from a correctness standpoint. If you ever want stricter coverage, you could also assert the presence of"opik"here for symmetry with the service initialization, but that’s optional.Also applies to: 148-151, 177-184
src/backend/base/langflow/services/tracing/openlayer.py (3)
64-101: Consider surfacing minimal diagnostics when Openlayer setup fails
setup_openlayerdefensively returnsFalseon any missing config,ImportError, or genericException, which is good for not breaking LangFlow when Openlayer is misconfigured. However, this makes it hard to understand why the tracer isn’t ready (no API key vs. bad JSON vs. import failure).A lightweight improvement would be to log at debug level before returning
Falsefor each failure path (missing required keys, import error, generic exception), so users can quickly see whyOpenlayerTracer.readyisFalsewithout impacting production behavior.This is optional, but would make diagnosing integration issues much easier.
285-385: Clean up unused hierarchy helpers or hook them into the step treeWithin the hierarchy utilities:
self.component_parent_idspopulated inadd_trace(Lines 166–170) is never read._is_tool_provider(Lines 327–331) is defined but never used.If you don’t plan to use these in a follow‑up to build a deeper component‑level tree (e.g., nesting steps based on
component_parent_idsor special‑casing tool providers), consider removing them to keep the tracer lean and easier to maintain. If you do plan to use them, adding a short comment about their intended purpose would help future readers understand why they’re there.
391-443: Data conversion logic is robust but can be made cheaper and slightly clearerThe recursive
_convert_to_openlayer_typecovers most of the important LangFlow/LangChain types (Message, Data, BaseMessage, Document, Pydantic models, tools, generators) and will generally produce sensible strings or primitives for Openlayer. A couple of optional refinements:
- Imports of
Document,BaseMessage,Data, andMessagehappen on every call. If performance becomes a concern on large traces, you could hoist these imports to module level or cache them in a small helper to avoid repeated import overhead.- The
types.GeneratorType | types.NoneTypeisinstancecheck works, but the special‑case is not strictly needed since both are handled by the string fallback. You can simplify by letting them fall through to the finalstr(value)case (or explicitly check only forGeneratorTypeif you want to avoid accidentally stringifying other “tool‑like” objects).These are micro‑optimizations / clarity tweaks; correctness looks fine as is.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock
📒 Files selected for processing (5)
docs/docs/Develop/integrations-openlayer.mdx(1 hunks)pyproject.toml(1 hunks)src/backend/base/langflow/services/tracing/openlayer.py(1 hunks)src/backend/base/langflow/services/tracing/service.py(3 hunks)src/backend/tests/unit/services/tracing/test_tracing_service.py(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/backend/base/langflow/services/tracing/openlayer.py (4)
src/lfx/src/lfx/schema/message.py (1)
Message(34-299)src/backend/base/langflow/services/tracing/base.py (1)
BaseTracer(16-71)src/lfx/src/lfx/field_typing/constants.py (1)
Document(43-44)src/lfx/src/lfx/schema/data.py (1)
Data(26-288)
🔇 Additional comments (3)
pyproject.toml (1)
140-140: Openlayer dependency wiring looks consistent with the new tracerAdding
openlayeras a core dependency matches the newOpenlayerTracerintegration and avoids runtimeImportError. Please just double‑check this version range against what you validated in your environment (API surface, performance, and security advisories), since my view of upstream releases may lag yours.docs/docs/Develop/integrations-openlayer.mdx (1)
1-139: Docs nicely mirror the implemented configuration behaviorThe integration guide clearly matches the code: env var names, flow‑specific
OPENLAYER_PIPELINE_<FLOW_NAME>handling, JSON mapping viaOPENLAYER_LANGFLOW_MAPPING, and the priority order all line up with_get_config. Disable behavior via removingOPENLAYER_API_KEYis also consistent with the tracer’s readiness checks. Looks good.src/backend/base/langflow/services/tracing/service.py (1)
62-66: Openlayer tracer wiring into the tracing lifecycle looks correct
_get_openlayer_tracerand_initialize_openlayer_tracermirror the existing tracer helpers, are gated byself.deactivated, and registration under"openlayer"integrates cleanly with the existingtracersdict,readychecks, and LangChain callback aggregation. The addition tostart_tracersis in the right place and won’t interfere with existing tracers.Also applies to: 229-240, 269-269
|
Hi @edwinjosechittilappilly, @ogabrielluiz and @Yukiyukiyeah. CodeRabbit suggested you as reviewers on this PR. Could any of you help us here? Pls let me know if there's anything needed to improve this PR. I've already addressed CodeRabbit comments. |
054b523 to
05e2f21
Compare
5d1d02c to
1d0480d
Compare
Add Openlayer as a tracing provider for Langflow, enabling users to monitor and evaluate their LLM pipelines through the Openlayer platform. - Implement OpenlayerTracer following the BaseTracer interface - Support both Chat flows and Agent-only flows - Add integration documentation - Register openlayer as an optional dependency Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1d0480d to
35de3b4
Compare
|
@ogabrielluiz, can you merge this one? |
Pull Request
Summary
Adds Openlayer tracing integration to LangFlow via
OpenlayerTracerservice. Enables comprehensive observability for LangFlow flows with automatic component tracking, LangChain callback integration, and hierarchical trace organization.Changes
OpenlayerTracerclass implementingBaseTracerinterfaceContext
Provides LangFlow users with production-grade observability through Openlayer's tracing platform. Key capabilities:
OPENLAYER_API_KEYis setConfiguration priority:
OPENLAYER_PIPELINE_<FLOW_NAME>(flow-specific)OPENLAYER_LANGFLOW_MAPPING(JSON mapping)OPENLAYER_INFERENCE_PIPELINE_ID(default)Example
The following Flow
Resulted on the following trace on the platform
Testing
Summary by CodeRabbit
New Features
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.