opentelemetry-instrumentation-ruby_llm 0.7.0 → 0.7.1

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: 41a9d9a93e7b336c7256c49918b535ee43de7fdb4f5ecdea78b03e31fad68749
4
- data.tar.gz: 02bca3602ca2715d2c5fa4351a9dde621edf8886a521b2ffef9c94a0ce64ee50
3
+ metadata.gz: c4a1a4d73f6af67b0e80799f194cc9e1b7d6fc8b5eee1960522e132d26037e7f
4
+ data.tar.gz: 056d2ce28ebf67ad85cd957f43706cbdf7fa786b48cd927aa58c131d1d325f58
5
5
  SHA512:
6
- metadata.gz: 881eec27d1ff083de355052b9bfdce866118c6a3000ec480a4e23cd7aeaf9ce33060b32c48d8f040b3cd26d071e2fa66a774c8097d053ad9616eabdc5a0f79e3
7
- data.tar.gz: a582e32144ba0cb3781b3f5a3e1d3aa42e5109abdf0b1fd8044cba527465ad12f4ba783c4c9c305fd226bcfb848cda09214d9db96088fda5f6da83178bfd4fe4
6
+ metadata.gz: ec92f5658bd541102d670e07287c2cd4a5e311edb48ea97fd8c7a237e5efc27cc8192e03ec65a5f2d535bc029268a5d71ef0fac2129845601d46c53664aad06a
7
+ data.tar.gz: 24f8ea7a11d56d929fd68fc6d54948eb7275944972a89192d5355af2f77628e0462ecc19521748cea4070fc1b7224c46dd8d5f1897c99016640f3b9c0669ea41
@@ -72,9 +72,9 @@ module OpenTelemetry
72
72
  end
73
73
  end
74
74
 
75
- @otel_attributes&.each { |key, value| span.set_attribute(key, value.respond_to?(:call) ? value.call : value) }
76
-
77
75
  result
76
+ ensure
77
+ @otel_attributes&.each { |key, value| span.set_attribute(key, value.respond_to?(:call) ? value.call : value) }
78
78
  end
79
79
  end
80
80
 
@@ -3,7 +3,7 @@
3
3
  module OpenTelemetry
4
4
  module Instrumentation
5
5
  module RubyLLM
6
- VERSION = "0.7.0"
6
+ VERSION = "0.7.1"
7
7
  end
8
8
  end
9
9
  end
@@ -406,6 +406,27 @@ class InstrumentationTest < Minitest::Test
406
406
  assert_equal "fixed", span.attributes["custom.static"]
407
407
  end
408
408
 
409
+ def test_with_otel_attributes_applied_on_api_failure
410
+ stub_request(:post, "https://api.openai.com/v1/chat/completions")
411
+ .to_return(status: 500, body: "Internal Server Error")
412
+
413
+ chat = RubyLLM.chat(model: "gpt-4o-mini")
414
+ chat.with_otel_attributes(
415
+ "langfuse.trace.name" => "My Agent",
416
+ "custom.last_role" => -> { chat.messages.last&.role.to_s }
417
+ )
418
+
419
+ assert_raises do
420
+ chat.ask("Hi")
421
+ end
422
+
423
+ span = EXPORTER.finished_spans.last
424
+ assert_equal "chat gpt-4o-mini", span.name
425
+ assert_equal OpenTelemetry::Trace::Status::ERROR, span.status.code
426
+ assert_equal "My Agent", span.attributes["langfuse.trace.name"]
427
+ assert_equal "user", span.attributes["custom.last_role"]
428
+ end
429
+
409
430
  def test_works_without_otel_attributes
410
431
  stub_chat_completion(chat_completion_body(content: "Hello!"))
411
432
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentelemetry-instrumentation-ruby_llm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clarissa Borges
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
98
  requirements: []
99
- rubygems_version: 3.7.1
99
+ rubygems_version: 4.0.6
100
100
  specification_version: 4
101
101
  summary: OpenTelemetry instrumentation for RubyLLM
102
102
  test_files: []