Module: Langchain::Datadog::Tracing
- Included in:
- Assistant, LLM, Vectorsearch
- Defined in:
- lib/langchain/datadog/tracing.rb
Overview
Implements the Datadog LLM Observability API tracing.
Class Method Summary collapse
-
.active_parent_id ⇒ Object
Returns the active parent span ID.
-
.active_span_id ⇒ Object
Returns the active span ID.
-
.active_trace_id ⇒ Object
Returns the active trace ID.
-
.agent(input = nil, name: nil, &block) ⇒ Object
Starts a new agent span.
-
.end_span(parent_id: nil) ⇒ Object
Ends the active span, setting the parent ID to the given value.
-
.start_span(parent_id: active_span_id) ⇒ Object
Starts a new span, setting the parent ID to the active span ID.
-
.workflow(input = nil, name: nil, &block) ⇒ Object
Starts a new workflow span.
Class Method Details
.active_parent_id ⇒ Object
Returns the active parent span ID.
20 21 22 |
# File 'lib/langchain/datadog/tracing.rb', line 20 def self.active_parent_id @active_parent_id end |
.active_span_id ⇒ Object
Returns the active span ID.
15 16 17 |
# File 'lib/langchain/datadog/tracing.rb', line 15 def self.active_span_id @active_span_id end |
.active_trace_id ⇒ Object
Returns the active trace ID.
8 9 10 11 12 |
# File 'lib/langchain/datadog/tracing.rb', line 8 def self.active_trace_id @active_trace_id ||= (::Datadog::Tracing.active_trace&.id if defined? ::Datadog) || next_id end |
.agent(input = nil, name: nil, &block) ⇒ Object
Starts a new agent span.
44 45 46 47 48 |
# File 'lib/langchain/datadog/tracing.rb', line 44 def self.agent(input = nil, name: nil, &block) return yield unless Datadog.enabled? span(input, name:, kind: 'agent', &block) end |
.end_span(parent_id: nil) ⇒ Object
Ends the active span, setting the parent ID to the given value.
31 32 33 34 |
# File 'lib/langchain/datadog/tracing.rb', line 31 def self.end_span(parent_id: nil) @active_span_id = active_parent_id @active_parent_id = parent_id end |
.start_span(parent_id: active_span_id) ⇒ Object
Starts a new span, setting the parent ID to the active span ID.
25 26 27 28 |
# File 'lib/langchain/datadog/tracing.rb', line 25 def self.start_span(parent_id: active_span_id) @active_parent_id = parent_id @active_span_id = next_id end |