dspy 0.24.1 → 0.24.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0946116ac08ee09e62d204db418f2d45f62eb4d4b1eff8306de1780a8cdfba8f'
4
- data.tar.gz: a294c49d86d084940738ebb39da6c7d3b8fef15064ff2c2cb15c07a90acdec8f
3
+ metadata.gz: a4383ac0dbb6237559bb521cf0d1355f9333f6495895742f6b2c4360d7c68392
4
+ data.tar.gz: 914f295500dd86cf4d2fe611450ddf3f8f6a01b1c7834cb5b8a9057d7449c8b4
5
5
  SHA512:
6
- metadata.gz: 91141a65593592604c301f3c51f48fac2c29b654c871c3155a055202d25efdcf7511ff4fda0372021f686b864f1e078e89fed27d245300f20966de62e3e295c5
7
- data.tar.gz: e4885370fde056ff4dda5464901f0f3e460bbf0cf2985e079088adf67d091718fe72e8ee0efc34999b021bb3e238649a782f12c3fec1162a8b6b13576bd25dc0
6
+ metadata.gz: 3d48a54390b11eee3a38d15770abda175cd7545aa30b24d48123e2ab6657e7f3212bbc4aa3bddab5a6ec700d3137b1e7bbd8b7f4d5e78313f7d3d90b574b47a3
7
+ data.tar.gz: 6189b3137e9fe1a36e6bedfc45a1a9ba10308089d497885edbfd8a20ba7879824c4e103b96eaa1efaca93e8e6c90aa4154f99ba8aa278528045d96aec7ff2024
@@ -87,7 +87,7 @@ module DSPy
87
87
  def forward_untyped(**input_values)
88
88
  # Wrap in chain-specific span tracking (overrides parent's span attributes)
89
89
  DSPy::Context.with_span(
90
- operation: "ChainOfThought.forward",
90
+ operation: "#{self.class.name}.forward",
91
91
  'langfuse.observation.type' => 'chain',
92
92
  'langfuse.observation.input' => input_values.to_json,
93
93
  'dspy.module' => 'ChainOfThought',
data/lib/dspy/context.rb CHANGED
@@ -43,12 +43,25 @@ module DSPy
43
43
  span_attributes['langfuse.trace.name'] = operation
44
44
  end
45
45
 
46
+ # Record start time for explicit duration tracking
47
+ otel_start_time = Time.now
48
+
46
49
  DSPy::Observability.tracer.in_span(
47
50
  operation,
48
51
  attributes: span_attributes,
49
52
  kind: :internal
50
53
  ) do |span|
51
- yield(span)
54
+ result = yield(span)
55
+
56
+ # Add explicit timing information to help Langfuse
57
+ if span
58
+ duration_ms = ((Time.now - otel_start_time) * 1000).round(3)
59
+ span.set_attribute('duration.ms', duration_ms)
60
+ span.set_attribute('langfuse.observation.startTime', otel_start_time.iso8601(3))
61
+ span.set_attribute('langfuse.observation.endTime', Time.now.iso8601(3))
62
+ end
63
+
64
+ result
52
65
  end
53
66
  else
54
67
  yield(nil)
@@ -103,6 +103,15 @@ module DSPy
103
103
  DSPy.log('observability.span_finish_error', error: e.message)
104
104
  end
105
105
 
106
+ def flush!
107
+ return unless enabled?
108
+
109
+ # Force flush any pending spans
110
+ OpenTelemetry.tracer_provider.force_flush
111
+ rescue StandardError => e
112
+ DSPy.log('observability.flush_error', error: e.message)
113
+ end
114
+
106
115
  def reset!
107
116
  @enabled = false
108
117
  @tracer = nil
data/lib/dspy/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DSPy
4
- VERSION = "0.24.1"
4
+ VERSION = "0.24.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dspy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.1
4
+ version: 0.24.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vicente Reig Rincón de Arellano