simforge 0.5.0 → 0.5.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: 662f1ce8942083e856907a38568a40b252c4d6360f043fc25da58900a46e36e7
4
- data.tar.gz: 9d74cf518171472d22b49c6b8fb3544e258607e5284acebe0f6b46e71213e0cd
3
+ metadata.gz: 712b471d28942f55c0ac0a78d05507f1060396de60c584173d3824f1e8c6d9b7
4
+ data.tar.gz: efa9dfc4e4173382d853327ee4edeafa54114482e04d97c86a3933465ee24285
5
5
  SHA512:
6
- metadata.gz: 556e17aa0f010ecb394f7a5937c3c02a43ef0d76bffe00082899074a19f26c555bec5c4d47dfe1afa98c34f7093beae5dd4b4a4d2d9d00a68d0155aadd979aea
7
- data.tar.gz: 14cd3fbc8c4ea4096036ce312e6eac67ab7b57a634c10faba0962fa3dd10368928ebc3c25c1236b5ff6019a8db36094b0a4e4a8eeb737da2c76fc42e5525cd62
6
+ metadata.gz: 1ca7cb706679154120fc89cac714b7d2eaa45017389f33f726afee7a77a0a0d1203dd7e14da32c8aa042d828381654bb87fe42fcb75c276edf61c52a27ba83e8
7
+ data.tar.gz: b9d9f5e70bf640447f046f9e272054c5f27f2aba849f42df20c6424c7a11c923c3403f89b23d0eb6b9eb50d53c39d0292b99213a5c4e2b745c7580948613a7d9
@@ -26,6 +26,39 @@ module Simforge
26
26
  base.extend(ClassMethods)
27
27
  end
28
28
 
29
+ # Wrap an existing method on an external class with span tracing.
30
+ # Use this to trace third-party library calls without modifying their source.
31
+ #
32
+ # @example
33
+ # Simforge::Traceable.wrap(OpenAI::Client, :chat,
34
+ # trace_function_key: "openai", name: "Chat", type: "llm")
35
+ #
36
+ # @param klass [Class, Module] the class to wrap
37
+ # @param method_name [Symbol] the method to wrap
38
+ # @param trace_function_key [String] the trace function key
39
+ # @param name [String, nil] explicit span name (defaults to method name)
40
+ # @param type [String] span type: llm, agent, function, guardrail, handoff, custom
41
+ def self.wrap(klass, method_name, trace_function_key:, name: nil, type: "custom")
42
+ span_name = name || method_name.to_s
43
+ method_name_str = method_name.to_s
44
+
45
+ wrapper = Module.new do
46
+ define_method(method_name) do |*args, **kwargs, &block|
47
+ Simforge.client.send(:execute_span,
48
+ trace_function_key:,
49
+ span_name:,
50
+ span_type: type,
51
+ function_name: method_name_str,
52
+ args:,
53
+ kwargs:) do
54
+ super(*args, **kwargs, &block)
55
+ end
56
+ end
57
+ end
58
+
59
+ klass.prepend(wrapper)
60
+ end
61
+
29
62
  module ClassMethods
30
63
  # Set the trace function key for this class.
31
64
  # All spans declared in this class will be grouped under this key.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Simforge
4
- VERSION = "0.5.0"
4
+ VERSION = "0.5.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simforge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harvest Team