activeagents-telemetry 0.2.0 → 0.3.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: 1c2085ce9e986ab9f20cd5b8b6faf925301ec001c3f2c1c2b83192a5dcdde2f3
4
- data.tar.gz: a62a35e305d0aa40b045759aef40ba1875ee44c87fa5a8c567e26b9ecda32ad5
3
+ metadata.gz: abbd653e7fdf9bb8656ce12e2324c61ac2fe32c76ecfa1c0bc4465a14d15d4eb
4
+ data.tar.gz: 2de365d2249eb439cd598fdd508aa10d5b3b90421f580a45c3d77b04c547deba
5
5
  SHA512:
6
- metadata.gz: e5c6fdd40bd2528aa6c8deea2cbe5aaf506a05020b2a298f00f264178ef86821af63b36a6f6b7bb3bd03c3b23b35d15dce5ed1b24a5a3cfca0a30e336582167a
7
- data.tar.gz: 93342e15bc143cd5298b39a6944ea95dea84a0cb50f19c359605b5c5f777f91b780e75f02638f074f632fdf473aaf3a8f9cdc05df0af8331324d538a7b3ced4a
6
+ metadata.gz: 87f70bf678ea9c3e7777be4837c5752d86ddc7e7ed42683a5c5d435367c687a822faf1e038ef9c6e2ca1483ac02457cb2c6a1259748a97fd33c724d2211f22b6
7
+ data.tar.gz: 1781ca860649b2e45b51e381a1f59ec2c3689415c3daba07ca5a86fcfff798412e3780531b199d79d75d1fe411b6a3f3cb1e700776d092c4ccb4b4b5ff08803d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,60 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.1] - 2026-09-20
4
+
5
+ ### Fixed
6
+
7
+ - The RubyLLM adapter reads token counts from a RubyLLM 2.x turn. 2.0 moved
8
+ the per-message readers (`input_tokens`, `output_tokens`, `thinking_tokens`)
9
+ to `message.tokens` and puts the round's `Tokens` on the `chat.ruby_llm`
10
+ payload; the adapter only knew the 1.x readers, so every 2.x trace reported
11
+ 0 tokens while its spans, timings and errors were correct. The payload's
12
+ `tokens` is read first, then the round's messages with either generation's
13
+ readers, so 1.x traces are unchanged.
14
+
15
+ The core gem is republished at 0.3.1 with no changes, so the two gems stay on
16
+ one version.
17
+
18
+
19
+ ## [0.3.0] - 2026-09-12
20
+
21
+ ### Added
22
+
23
+ - `RubyLLM.with_agent` takes `attributes:`, `on_trace:` and `synchronous:`.
24
+ `attributes` are merged onto the root span of every trace recorded in the
25
+ block, with the `agent.*` identity keys taking precedence, so an evaluation
26
+ can stamp its run and result identifiers on the traces it causes. `on_trace`
27
+ receives each trace the reporter accepted for delivery, so the caller can
28
+ keep the `trace_id` of that delivery attempt; a trace dropped by
29
+ `sample_rate` or a disabled configuration is never announced. Acceptance is
30
+ not ingestion: a delivery that fails afterwards is logged by the reporter,
31
+ not surfaced to the callback. `synchronous: true` delivers in
32
+ the calling thread for that scope only, through the same sampling and
33
+ configuration checks as ordinary delivery; the shared asynchronous
34
+ configuration is untouched, and a delivery failure follows the reporter's
35
+ existing logging policy rather than raising. A turn keeps the scope it
36
+ started under, so a turn left open by a pending tool call and closed later
37
+ by `flush!` still reports with that scope's agent, attributes and callback,
38
+ and a turn that started outside any scope never adopts a later one.
39
+ Nested scopes restore the previous context, including when the block
40
+ raises. A callback that raises is logged by exception class and the trace
41
+ is still delivered. (#5)
42
+ - `Reporter#report` takes `sync: true` to deliver in the calling thread for
43
+ that call only, keeping the enabled, configured and sampling checks that
44
+ `report_now` skips, and returns whether the traces were accepted.
45
+ `BatchingReporter#report` delivers that call's traces in the calling
46
+ thread when asked the same, leaving its buffer on its own schedule. The
47
+ RubyLLM adapter now requires core `~> 0.3` for it.
48
+
49
+ ### Fixed
50
+
51
+ - `Configuration::LOCAL_ENDPOINT_PATH`, the class docs and the README's
52
+ self-hosting example pointed at `/active_agent/api/traces`, a path no
53
+ current dashboard mount serves. The actionagent engine ingests at
54
+ `<mount>/api/traces` and is mounted at `/activeagents` by default, so the
55
+ constant and the docs now say `/activeagents/api/traces` and note that a
56
+ custom mount changes the prefix. (#3)
57
+
3
58
  ## [0.2.0] - 2026-08-14
4
59
 
5
60
  ### Added
@@ -18,8 +73,6 @@
18
73
  the application sends the model, so enabling this is a data-handling
19
74
  decision — the truncation is a cap on trace size, not a redaction boundary.
20
75
 
21
- ## [Unreleased]
22
-
23
76
  ## [0.1.0] - 2026-08-10
24
77
 
25
78
  First public release of both gems: `activeagents-telemetry` (the shared
data/README.md CHANGED
@@ -56,12 +56,16 @@ backtraces are never transmitted.
56
56
 
57
57
  ## Self-hosting
58
58
 
59
- Point the endpoint at your mounted dashboard — same gems, same wire format:
59
+ Point the endpoint at your mounted dashboard — same gems, same wire format.
60
+ The dashboard engine ingests at `<mount>/api/traces`; its install generator
61
+ mounts it at `/activeagents`, so on a default install that is:
60
62
 
61
63
  ```ruby
62
- config.endpoint = "https://your-app.example.com/active_agent/api/traces"
64
+ config.endpoint = "https://your-app.example.com/activeagents/api/traces"
63
65
  ```
64
66
 
67
+ If you mounted `ActionAgent::Engine` somewhere else, use that prefix instead.
68
+
65
69
  ## Development
66
70
 
67
71
  ```bash
@@ -24,13 +24,28 @@ module ActiveAgents
24
24
  @shutdown = false
25
25
  end
26
26
 
27
- # Enqueues a trace, flushing if the batch is full.
28
- def report(traces)
29
- return if @shutdown
27
+ # Enqueues a trace, flushing if the batch is full. `sync: true` skips the
28
+ # buffer: that call's traces are delivered in the calling thread before
29
+ # it returns, so a short-lived process can hand a trace over before it
30
+ # exits, and whatever the buffer already holds stays on its own schedule.
31
+ # @return [Boolean] whether any of the traces were accepted
32
+ def report(traces, sync: false)
33
+ return false if @shutdown
30
34
 
31
35
  accepted = normalize(traces).select { sample_trace? }
32
- return if accepted.empty?
33
- return unless configuration.enabled? && configuration.configured?
36
+ return false if accepted.empty?
37
+ return false unless configuration.enabled? && configuration.configured?
38
+
39
+ if sync
40
+ body = begin
41
+ payload_for(accepted)
42
+ rescue StandardError => e
43
+ log("failed to build trace payload: #{e.class}: #{e.message}")
44
+ return false
45
+ end
46
+ deliver(body)
47
+ return true
48
+ end
34
49
 
35
50
  batch = nil
36
51
  @mutex.synchronize do
@@ -39,7 +54,7 @@ module ActiveAgents
39
54
  start_flusher
40
55
  end
41
56
  deliver_batch(batch) if batch
42
- nil
57
+ true
43
58
  end
44
59
 
45
60
  # Delivers everything buffered, blocking until done.
@@ -14,13 +14,17 @@ module ActiveAgents
14
14
  # end
15
15
  #
16
16
  # A self-hosted ActiveAgent dashboard is the same thing with a different
17
- # endpoint — point it at "https://your-app.example.com/active_agent/api/traces".
17
+ # endpoint — point it at "https://your-app.example.com/activeagents/api/traces"
18
+ # (the actionagent engine's default mount; adjust the prefix to wherever
19
+ # the host app actually mounted ActionAgent::Engine).
18
20
  class Configuration
19
21
  # The hosted platform. Self-hosters override `endpoint`.
20
22
  DEFAULT_ENDPOINT = "https://api.activeagents.ai/v1/traces"
21
23
 
22
- # Path a mounted ActiveAgent::Dashboard::Engine serves traces on.
23
- LOCAL_ENDPOINT_PATH = "/active_agent/api/traces"
24
+ # The ingest path of the dashboard engine (ActionAgent::Engine) at its
25
+ # default mount. The engine ingests at "<mount>/api/traces", so a host
26
+ # that mounted it elsewhere uses that prefix instead.
27
+ LOCAL_ENDPOINT_PATH = "/activeagents/api/traces"
24
28
 
25
29
  # Attribute keys scrubbed from spans before delivery. Name-based — a
26
30
  # secret inside free text is not caught; see the wiki's privacy page.
@@ -35,19 +35,29 @@ module ActiveAgents
35
35
 
36
36
  # @param traces [Trace, Hash, Array<Trace, Hash>] traces to deliver —
37
37
  # Trace objects or already-serialized trace hashes
38
- # @return [void]
39
- def report(traces)
38
+ # @param sync [Boolean] deliver in the calling thread for this call
39
+ # only; every other call keeps the configured async behaviour. The
40
+ # enabled, configured and sampling checks still apply, unlike
41
+ # #report_now.
42
+ # @return [Boolean] whether the traces were accepted for delivery. A
43
+ # delivery failure is logged rather than surfaced here, so true means
44
+ # the traces passed the enabled, configured and sampling checks.
45
+ def report(traces, sync: false)
40
46
  traces = normalize(traces)
41
- return if traces.empty?
42
- return unless configuration.enabled? && configuration.configured?
43
- return unless sample_trace?
47
+ return false if traces.empty?
48
+ return false unless configuration.enabled? && configuration.configured?
49
+ return false unless sample_trace?
44
50
 
45
51
  body = payload_for(traces)
46
- configuration.async? ? Thread.new { deliver(body) } : deliver(body)
47
- nil
52
+ if sync || !configuration.async?
53
+ deliver(body)
54
+ else
55
+ Thread.new { deliver(body) }
56
+ end
57
+ true
48
58
  rescue StandardError => e
49
59
  log("failed to build trace payload: #{e.class}: #{e.message}")
50
- nil
60
+ false
51
61
  end
52
62
 
53
63
  # Blocking delivery, for tests and for at-exit flushes.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveAgents
4
4
  module Telemetry
5
- VERSION = "0.2.0"
5
+ VERSION = "0.3.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeagents-telemetry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ActiveAgents
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-08-14 00:00:00.000000000 Z
11
+ date: 2026-09-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  The wire format, configuration, and delivery layer behind ActiveAgents