opentelemetry-instrumentation-ruby_llm 0.2.0 → 0.3.0
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dfb17d4d74d31d2a53792683e0d5d070cd25e9160ee3c5018c0a1dbfb5bbeb4b
|
|
4
|
+
data.tar.gz: 91c3b7ac277d43ddf80a6fc49e2228d8005bf40f9321cd10cd5ac2539c96dfc7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: df479838c253aa695c1b36b393b4f7eac31dd041a581df3d04d9f9e9ca1253d026b8582b32d2cdf398e812d53459ef0c012406654342d37a9ae45c45dc68c5e7
|
|
7
|
+
data.tar.gz: 9c18a05253193ce23af8bc0f342cd726778c6daccff7d1010602a63b36f20d07eb13852ea6f01d6e40bf2439236fbf4b495e32e144e701d521aaeec18972f6a4
|
|
@@ -67,7 +67,7 @@ class InstrumentationTest < Minitest::Test
|
|
|
67
67
|
assert_equal OpenTelemetry::Trace::Status::ERROR, span.status.code
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
-
def
|
|
70
|
+
def test_complete_still_works_when_instrumentation_fails
|
|
71
71
|
stub_request(:post, "https://api.openai.com/v1/chat/completions")
|
|
72
72
|
.to_return(
|
|
73
73
|
status: 200,
|
|
@@ -92,6 +92,39 @@ class InstrumentationTest < Minitest::Test
|
|
|
92
92
|
assert_equal "Hello!", response.content
|
|
93
93
|
end
|
|
94
94
|
|
|
95
|
+
def test_instruments_complete_called_directly
|
|
96
|
+
stub_request(:post, "https://api.openai.com/v1/chat/completions")
|
|
97
|
+
.to_return(
|
|
98
|
+
status: 200,
|
|
99
|
+
headers: { "Content-Type" => "application/json" },
|
|
100
|
+
body: {
|
|
101
|
+
id: "chatcmpl-123",
|
|
102
|
+
object: "chat.completion",
|
|
103
|
+
model: "gpt-4o-mini",
|
|
104
|
+
choices: [{
|
|
105
|
+
index: 0,
|
|
106
|
+
message: { role: "assistant", content: "Hello, world!" },
|
|
107
|
+
finish_reason: "stop"
|
|
108
|
+
}],
|
|
109
|
+
usage: { prompt_tokens: 10, completion_tokens: 5, total_tokens: 15 }
|
|
110
|
+
}.to_json
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
chat = RubyLLM.chat(model: "gpt-4o-mini")
|
|
114
|
+
chat.add_message(role: :user, content: "Hi")
|
|
115
|
+
chat.complete
|
|
116
|
+
|
|
117
|
+
spans = EXPORTER.finished_spans
|
|
118
|
+
assert_equal 1, spans.length
|
|
119
|
+
|
|
120
|
+
span = spans.first
|
|
121
|
+
assert_equal "chat gpt-4o-mini", span.name
|
|
122
|
+
assert_equal "chat", span.attributes["gen_ai.operation.name"]
|
|
123
|
+
assert_equal "openai", span.attributes["gen_ai.provider.name"]
|
|
124
|
+
assert_equal 10, span.attributes["gen_ai.usage.input_tokens"]
|
|
125
|
+
assert_equal 5, span.attributes["gen_ai.usage.output_tokens"]
|
|
126
|
+
end
|
|
127
|
+
|
|
95
128
|
def test_creates_span_for_tool_call
|
|
96
129
|
calculator = Class.new(RubyLLM::Tool) do
|
|
97
130
|
def self.name = "calculator"
|
|
@@ -155,7 +188,7 @@ class InstrumentationTest < Minitest::Test
|
|
|
155
188
|
chat_spans = spans.select { |s| s.name.include?("chat ") }
|
|
156
189
|
|
|
157
190
|
assert_equal 1, tool_spans.length
|
|
158
|
-
assert_equal
|
|
191
|
+
assert_equal 2, chat_spans.length
|
|
159
192
|
|
|
160
193
|
tool_span = tool_spans.first
|
|
161
194
|
assert_equal OpenTelemetry::Trace::SpanKind::INTERNAL, tool_span.kind
|