activeagents-telemetry 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: 1c2085ce9e986ab9f20cd5b8b6faf925301ec001c3f2c1c2b83192a5dcdde2f3
4
- data.tar.gz: a62a35e305d0aa40b045759aef40ba1875ee44c87fa5a8c567e26b9ecda32ad5
3
+ metadata.gz: fe9ec7ae7a6a457e50b5da5ec21640978ce363718236c64b3eb0b1a16fe1b7f7
4
+ data.tar.gz: f225f754c6365b3bc7b75d683e9f8684954e68d2b8b69e010c51b2b7f04485bc
5
5
  SHA512:
6
- metadata.gz: e5c6fdd40bd2528aa6c8deea2cbe5aaf506a05020b2a298f00f264178ef86821af63b36a6f6b7bb3bd03c3b23b35d15dce5ed1b24a5a3cfca0a30e336582167a
7
- data.tar.gz: 93342e15bc143cd5298b39a6944ea95dea84a0cb50f19c359605b5c5f777f91b780e75f02638f074f632fdf473aaf3a8f9cdc05df0af8331324d538a7b3ced4a
6
+ metadata.gz: d7e70e2daef1faa3527d61fcd303f6783cbac2ce32da62c5cf053fc215dc5e602a166b6b9791bee256f041a04474557e75719563f1a3e077b8218650a3296704
7
+ data.tar.gz: a0b55b62db84a92e41cff0ad30edc2b420fff2a947d10665f9acaf8938bb469068cc797940e89a7d3ed53a5a0ec25efc95a738b4b1c395b6b1ecb56a083dec81
data/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.0] - 2026-09-12
4
+
5
+ ### Added
6
+
7
+ - `RubyLLM.with_agent` takes `attributes:`, `on_trace:` and `synchronous:`.
8
+ `attributes` are merged onto the root span of every trace recorded in the
9
+ block, with the `agent.*` identity keys taking precedence, so an evaluation
10
+ can stamp its run and result identifiers on the traces it causes. `on_trace`
11
+ receives each trace the reporter accepted for delivery, so the caller can
12
+ keep the `trace_id` of that delivery attempt; a trace dropped by
13
+ `sample_rate` or a disabled configuration is never announced. Acceptance is
14
+ not ingestion: a delivery that fails afterwards is logged by the reporter,
15
+ not surfaced to the callback. `synchronous: true` delivers in
16
+ the calling thread for that scope only, through the same sampling and
17
+ configuration checks as ordinary delivery; the shared asynchronous
18
+ configuration is untouched, and a delivery failure follows the reporter's
19
+ existing logging policy rather than raising. A turn keeps the scope it
20
+ started under, so a turn left open by a pending tool call and closed later
21
+ by `flush!` still reports with that scope's agent, attributes and callback,
22
+ and a turn that started outside any scope never adopts a later one.
23
+ Nested scopes restore the previous context, including when the block
24
+ raises. A callback that raises is logged by exception class and the trace
25
+ is still delivered. (#5)
26
+ - `Reporter#report` takes `sync: true` to deliver in the calling thread for
27
+ that call only, keeping the enabled, configured and sampling checks that
28
+ `report_now` skips, and returns whether the traces were accepted.
29
+ `BatchingReporter#report` delivers that call's traces in the calling
30
+ thread when asked the same, leaving its buffer on its own schedule. The
31
+ RubyLLM adapter now requires core `~> 0.3` for it.
32
+
33
+ ### Fixed
34
+
35
+ - `Configuration::LOCAL_ENDPOINT_PATH`, the class docs and the README's
36
+ self-hosting example pointed at `/active_agent/api/traces`, a path no
37
+ current dashboard mount serves. The actionagent engine ingests at
38
+ `<mount>/api/traces` and is mounted at `/activeagents` by default, so the
39
+ constant and the docs now say `/activeagents/api/traces` and note that a
40
+ custom mount changes the prefix. (#3)
41
+
3
42
  ## [0.2.0] - 2026-08-14
4
43
 
5
44
  ### Added
@@ -18,8 +57,6 @@
18
57
  the application sends the model, so enabling this is a data-handling
19
58
  decision — the truncation is a cap on trace size, not a redaction boundary.
20
59
 
21
- ## [Unreleased]
22
-
23
60
  ## [0.1.0] - 2026-08-10
24
61
 
25
62
  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.0"
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.0
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-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  The wire format, configuration, and delivery layer behind ActiveAgents