Skip to content

feat(telemetry): send box telemetry to Langfuse, LangSmith and CloudWatch - #314

Merged
leo237 merged 4 commits into
strands-agents:mainfrom
SaiAbhishek98:feature/third-party-telemetry-export
Nov 17, 2026
Merged

leo237 merged 4 commits into
strands-agents:mainfrom
SaiAbhishek98:feature/third-party-telemetry-export

Conversation

@SaiAbhishek98

@SaiAbhishek98 SaiAbhishek98 commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Description

Box sends telemetry to a file, or to an OTLP endpoint that takes one bearer secret. It cannot send to CloudWatch Logs or X-Ray, because they need SigV4. It cannot send correctly to Langfuse or LangSmith, because each one needs its own path, headers and credential placement.

This PR adds two things:

  1. Direct OTLP export, with one vault for each target. The exporter posts each batch directly to the destination. The vault of the target attaches the credential as a header, as HTTP Basic auth, or as a SigV4 signature for logs or xray. A target can name the payloads that it accepts (accepts), and fixed headers (headers).
  2. Vendor kinds in box.toml. kind can be langfuse, langsmith, cloudwatch_logs or cloudwatch_traces. The operator writes only the destination or the region, the project or the log group and stream, and secret.ref. Box expands each kind into the otlp target that it stands for, and stores that target.

A telemetry secret.ref can name env://, secret://, aws:// or credsd://. It refuses file:// and op://.

The design is in team/designs/0004-third-party-telemetry.md.

[telemetry.langfuse]
kind = "langfuse"
destination = "https://us.cloud.langfuse.com"
secret.ref = "env://LANGFUSE_AUTH"

[telemetry.cloudwatch_logs]
kind = "cloudwatch_logs"
region = "us-west-2"
log_group = "my-group"
log_stream = "my-stream"
secret.ref = "aws://my-profile"

Decisions that the diff does not show

  • Telemetry does not go through the egress gateway, and policy makes no decision for each send. Telemetry is an action of Box, not of the agent. If each send went through the gateway, a default-deny policy would drop the record of the refusals of the box. The relayed spans of the agent also go out this way. This is to ensure agent gets no control of telemetry in case of over permissive permissions.
  • Each target has its own vault, apart from the vault of the egress gateway. Thus no request of the agent can get a telemetry key.
  • A vendor kind refuses each field that it sets itself: headers, accepts, secret.header, secret.prefix and secret.placement. It also names each field that it needs and does not have.
  • A telemetry secret.ref refuses file:// and op://. The workload can swap a file that it can reach, and op runs from the PATH of the trusted process.
  • Box checks each telemetry aws:// and credsd:// credential before the workload starts. A signed credential resolves on each request, so without the check a profile that cannot sign would fail every batch after the workload starts. Each aws:// target signs one request that Box does not send, and the credsd:// environments join the existing credsd preflight.
  • A record that uses the new settings stores record version 36 (TELEMETRY_EXPORT_RECORD_VERSION). An earlier build refuses that record, instead of sending without the vendor's headers. A target that uses only the settings on main keeps version 21, so an earlier build still resumes it.
  • A failed send is reported in two ways. From fix(telemetry): report lost records once on stderr when the run drains #439 on main, the drain reports the count of lost records one time on stderr. With STRANDS_BOX_TELEMETRY_DEBUG set, Box also prints each failed send with its full cause. the_debug_variable_prints_a_failed_export_and_its_cause checks both.
  • A failure report never quotes a credential. With STRANDS_BOX_TELEMETRY_DEBUG set, Box quotes the start of the answer of a refusing endpoint. Before it does, it replaces each credential that it attached with [REDACTED]: each value, each token of it, and for HTTP Basic the decoded pair and each half. Thus an endpoint that echoes a refused key does not put the key on stderr.
  • The vault signs the URL that the client sends. reqwest removes a default port and changes the host to lowercase. The vault thus signs the URL after url parses it, and a destination such as https://logs.us-west-2.amazonaws.com:443 gets a signature for the Host that it sends.
  • One deadline covers the credential lookup and the send. The lookup runs on a thread that the runtime does not own, so a slow credsd lookup cannot hold the runtime open at shutdown.
  • An IPv6 destination can carry a credential. DestinationPattern::ipv6 binds the address and port. The egress destinations vocabulary does not change.

Interface changes

These change frozen surfaces:

  • box.toml telemetry keys: accepts, headers, log_group, log_stream, project, region, secret.placement and secret.prefix.
  • box.toml telemetry kinds: langfuse, langsmith, cloudwatch_logs and cloudwatch_traces.
  • A telemetry secret.ref accepts aws:// and credsd://, beside env:// and secret://.
  • Record version 36, for a record that uses the new telemetry settings.
  • A run stops before its workload starts when a telemetry aws:// profile cannot sign or a credsd:// environment fails.
  • The environment variable STRANDS_BOX_TELEMETRY_DEBUG, which prints the full cause of a failed export.
  • Crate API additions in internal crates (publish = false): telemetry::Payload, Target::accepting, Target::with_header, Target::with_vault, TelemetryConfig::reporting_failures and credentials::DestinationPattern::ipv6.

Verified outside CI

During local testing from Mac, the box sent 8 records to each of CloudWatch Logs, X-Ray, Langfuse and LangSmith. The vendor keys came from env://, and an AWS profile signed the CloudWatch requests. No export failed.

Deferred

  • This branch is not compiled locally for Linux. It adds no cfg-gated code. Before the rebase onto 8c56aa8, the CI unit tests passed on ubuntu-24.04-arm and macos-latest. The CI Gate fails on a draft by design, because the containment suite does not run on a draft.
  • Section 7 of the design doc lists the open questions for reviewers.

Related Issues

None.

Type of Change

New feature

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce new warnings.

  • I ran the relevant suites (just check, or cargo test --workspace --all-features)
  • If I touched Rust, I ran cargo fmt --all and cargo clippy --workspace --all-targets --all-features -- -D warnings

Results on this branch, which is based on main at 8c56aa8:

  • cargo test -p strands-box-telemetry --all-features --lib: 107 passed.
  • cargo test -p strands-box --all-features --lib -- record::config run::: 987 passed, 1 ignored.
  • cargo build --workspace --all-features --locked --tests has no errors.

Results on an earlier base, main at 70eb3af:

  • cargo test --workspace --all-features --no-fail-fast: 5240 passed, 2 failed, 19 ignored. Both failures are timing checks that ran while a second build used the same Mac, and neither is in code that this PR changes. Each one passed 3 of 3 runs alone:
    • a_stuck_request_does_not_block_a_healthy_one (crates/box/tests/box_programs.rs).
    • e2b_a_non_yielding_request_does_not_delay_a_concurrent_one (crates/box/tests/box_cardinality.rs).
  • cargo test -p strands-box --test box_telemetry: 32 passed, 1 ignored.
  • The containment suite test-integ/run.sh on macOS: GREEN. 141 cases: 129 pass, 0 fail, 12 skip (Linux only).
  • cargo fmt --all --check: passes.
  • cargo clippy --workspace --all-targets --all-features reports 17 warnings, all in crates/shell. This PR does not change crates/shell.
  • feature-critic ran on this change. Its first verdict was rework. The second commit fixes each finding, and the confirmation pass gave ship.
  • New tests:
    • Vendor kinds: a_vendor_kind_expands_to_its_otlp_target, a_vendor_kind_refuses_what_it_sets_or_lacks, and through the binary, a_langfuse_kind_sends_spans_where_langfuse_takes_them.
    • Credentials: a_cloudwatch_logs_target_is_signed_for_logs, an_xray_target_is_signed_for_xray, the_vault_attaches_basic_auth, the_vault_attaches_an_api_key_header, a_file_or_op_secret_is_refused, an_ipv6_pattern_matches_its_address_and_port and the_vault_attaches_a_credential_on_an_ipv6_address.
    • Startup check: a_telemetry_profile_that_cannot_sign_stops_the_run, a_telemetry_credsd_environment_without_a_daemon_stops_the_run, the_credsd_environments_are_the_distinct_signing_ones and the_aws_preflight_reads_a_schemeless_destination_as_the_exporter_dials_it.
    • Record version: a_vendor_telemetry_target_stores_a_version_no_earlier_build_reads, a_bearer_telemetry_target_keeps_the_ordinary_version and an_earlier_record_with_a_secret_alias_still_parses.
    • Export: a_traces_only_target_is_sent_no_other_payload, a_transport_failure_names_its_cause and, through the binary, the_debug_variable_prints_a_failed_export_and_its_cause.
    • Review fixes: a_failure_report_redacts_an_echoed_credential, a_signature_covers_the_url_the_client_sends and a_slow_credential_lookup_is_bounded_and_does_not_hold_shutdown. Each one fails when its fix is removed.

Checklist

  • I have read the CONTRIBUTING document
  • I have reviewed and understand every line of code in this PR, including any generated by AI tools, and I can explain why it works
  • My change is focused and reasonably small; I have split unrelated work into separate PRs
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • My changes generate no new warnings

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@github-actions github-actions Bot added Area - Telemetry The telemetry collector, receiver, and record targets Area - Egress/Creds enhancement New feature or request labels Nov 4, 2026
@SaiAbhishek98
SaiAbhishek98 force-pushed the feature/third-party-telemetry-export branch 3 times, most recently from 049e6e4 to 34f8626 Compare November 9, 2026 21:08
@SaiAbhishek98
SaiAbhishek98 marked this pull request as ready for review November 9, 2026 21:43
@SaiAbhishek98
SaiAbhishek98 force-pushed the feature/third-party-telemetry-export branch from 34f8626 to e997e5a Compare November 13, 2026 18:31
Comment thread crates/telemetry/src/export.rs Resolved
Comment thread crates/telemetry/src/export.rs Resolved
Comment thread crates/telemetry/src/export.rs Resolved
@SaiAbhishek98
SaiAbhishek98 force-pushed the feature/third-party-telemetry-export branch from e924135 to 46a389b Compare November 14, 2026 00:04
…atch

Box sends telemetry to a file, or to an OTLP endpoint that takes one bearer secret. It cannot
send to CloudWatch Logs or X-Ray, because they need SigV4. It cannot send correctly to Langfuse or
LangSmith, because each one needs its own path, headers and credential placement.

- The telemetry crate exports OTLP directly to each target. Each target has its own credentials
  vault. The vault attaches the credential as a header, as HTTP Basic auth, or as a SigV4
  signature for `logs` or `xray`. A target can name the payloads that it accepts (`accepts`) and
  fixed headers (`headers`). With `STRANDS_BOX_TELEMETRY_DEBUG` set, a failed export prints its
  full cause.
- `box.toml` takes four vendor kinds: `langfuse`, `langsmith`, `cloudwatch_logs` and
  `cloudwatch_traces`. Box expands each kind into the `otlp` target that it stands for, and stores
  that target. The operator writes only the destination or the region, the project or the log
  group and stream, and `secret.ref`. A vendor kind refuses each field that it sets itself.
- A telemetry `secret.ref` can name `env://`, `file://`, `op://`, `aws://` or `credsd://`.
- `team/designs/0004-third-party-telemetry.md` describes the design.
- Interface changes, approved for this work: the telemetry keys `accepts`, `headers`, `log_group`,
  `log_stream`, `project`, `region`, `secret.placement` and `secret.prefix`; the four vendor
  kinds; the `STRANDS_BOX_TELEMETRY_DEBUG` variable.

- `cargo test --all-features`: strands-box-telemetry 92, strands-box telemetry config 18,
  strands-box `box_telemetry` 27, strands-box-credentials 234. All pass. New tests:
  `a_vendor_kind_expands_to_its_otlp_target`, `a_vendor_kind_refuses_what_it_sets_or_lacks`,
  `a_file_or_op_secret_is_accepted_with_a_placement`, `a_cloudwatch_logs_target_is_signed_for_logs`,
  `an_xray_target_is_signed_for_xray`, `the_vault_attaches_basic_auth`,
  `the_vault_attaches_an_api_key_header`, `a_traces_only_target_is_sent_no_other_payload` and
  `a_transport_failure_names_its_cause`.
- End to end on macOS: a box sent 8 records to each of CloudWatch Logs, X-Ray, Langfuse and
  LangSmith, with the vendor keys in `env://` and an AWS profile for SigV4. No export failed.
- `cargo clippy` adds no warnings outside `crates/shell`, and `cargo fmt --check` passes.
- Not run: `feature-critic`. `RECORD_VERSION` is not changed, because the record gains only
  optional fields.
The review of the telemetry export found these gaps:

- The stored record gained new telemetry fields, but its version did not change. An earlier build
  could resume the box and send without the vendor's headers.
- A telemetry credential could not be bound to an IPv6 destination, which `main` accepted.
- A telemetry `aws://` or `credsd://` credential was not checked at startup. A profile that cannot
  sign failed every batch after the workload started.
- The telemetry crate read `STRANDS_BOX_TELEMETRY_DEBUG` itself, against its own README.
- A telemetry `secret.ref` could name `file://` or `op://`. The workload can swap a file that it
  can reach, and `op` runs from the trusted process's `PATH`.
- Telemetry kept its own copy of the egress placement vocabulary.
- The user docs, the crate README and two `decisions.md` entries still described two kinds and
  unconditional logs and metrics.

- A record whose telemetry target uses `accepts`, `headers`, `secret.prefix`, `secret.placement`,
  or a secret that is not `env://` or `secret://` stores `TELEMETRY_EXPORT_RECORD_VERSION` (36).
  Other records keep their version, so an earlier build still resumes them, and this build still
  reads a record that an earlier build wrote.
- `DestinationPattern::ipv6` binds one IPv6 address and port. Telemetry uses it for an IPv6
  destination. The egress `destinations` vocabulary does not change.
- At startup, the credsd preflight also reads the telemetry `credsd://` environments. Each
  telemetry `aws://` target signs one request that is not sent, for the URL that the exporter
  dials. A failure stops the run before the workload starts.
- `strands-box run` reads `STRANDS_BOX_TELEMETRY_DEBUG` and passes it in with
  `TelemetryConfig::reporting_failures`.
- A telemetry `secret.ref` takes only `env://`, `secret://`, `aws://` and `credsd://`.
- Telemetry uses the egress `Placement` and the shared placement constants.
- `docs/user/config.md` and `docs/user/telemetry.md` describe the vendor kinds, the new keys, the
  refusals, the startup check and the debug variable. `docs/user/native-filesystem-policy.md`
  names record version 25 and its rollback step. The crate README, the crate AGENTS.md and
  `docs/design/telemetry.md` are updated.
  `decisions.md#a-target-is-a-file-or-an-otlp-endpoint` and
  `decisions.md#a-target-names-a-set-of-signals` now state the vendor kinds and `accepts`, and
  `decisions.md#delivery-is-best-effort` states when a lost record is printed.

- `cargo test --workspace --all-features`: 4607 passed, 0 failed, 16 ignored.
- New tests: `a_vendor_telemetry_target_stores_a_version_no_earlier_build_reads`,
  `a_bearer_telemetry_target_keeps_the_ordinary_version`,
  `an_earlier_record_with_a_secret_alias_still_parses`,
  `the_aws_preflight_reads_a_schemeless_destination_as_the_exporter_dials_it`,
  `an_ipv6_pattern_matches_its_address_and_port`,
  `the_vault_attaches_a_credential_on_an_ipv6_address`, `a_file_or_op_secret_is_refused`,
  `the_credsd_environments_are_the_distinct_signing_ones`, and in `box_telemetry`:
  `a_langfuse_kind_sends_spans_where_langfuse_takes_them`,
  `the_debug_variable_prints_a_failed_export_and_its_cause`,
  `a_telemetry_profile_that_cannot_sign_stops_the_run` and
  `a_telemetry_credsd_environment_without_a_daemon_stops_the_run`.
- `cargo fmt --all --check` passes. `cargo clippy` adds no warnings outside `crates/shell`.
- `feature-critic` ran on this change. Its first verdict was rework, for a `secret://` record that
  this change stamped with version 25. The fix is above. Its confirmation pass gave ship. It found
  the crate API additions `Payload`, `Target::accepting`, `Target::with_header`,
  `Target::with_vault`, `TelemetryConfig::reporting_failures` and `DestinationPattern::ipv6`, and
  they wait for the owner's review.
- The containment suite `test-integ/run.sh` on macOS: GREEN, 140 cases, 128 pass, 0 fail, 12 skip
  (Linux only).
- Not compiled for Linux. The change adds no `cfg`-gated code.
## Problem

Section 4 of `team/designs/0004-third-party-telemetry.md` says that a telemetry key can come from
`file://` and `op://`. A telemetry target now refuses both, and Box checks each `aws://` and
`credsd://` credential at startup. The section does not say either.

## Solution

Section 4 names the three sources a telemetry target reads, says why it refuses `file://` and
`op://`, and says that Box checks a signing credential before the workload starts.

## Tests

None. The change is to a design document only.
…lookup

## Problem

An inspection of the export path found three faults:

- With `STRANDS_BOX_TELEMETRY_DEBUG` set, the error report quotes the answer of the endpoint. An
  endpoint that echoes a refused API key in its answer thus put the key on stderr.
- The vault signed the URL as the operator wrote it, but `reqwest` removes a default port and
  changes the host to lowercase before it sends the request. A destination such as
  `https://logs.us-west-2.amazonaws.com:443` or one with an uppercase host thus got a signature
  for a different `Host`, and the endpoint refused it.
- The four-second deadline started after the credential lookup. A slow `credsd` lookup was thus
  not bounded. The lookup also ran in the blocking pool of the runtime, so runtime shutdown waited
  for a lookup that the export had stopped.

## Solution

- The error report replaces each credential that Box attached in the answer of the endpoint with
  `[REDACTED]`: each value, each token of it, and for HTTP Basic the decoded pair and each half.
- The vault signs the URL after `url` parses it, which is the URL that `reqwest` sends.
- One deadline covers the credential lookup and the send. The lookup runs on a thread that the
  runtime does not own, so the runtime does not wait for it at shutdown.
- `docs/user/telemetry.md` and `docs/user/config.md` say that the deadline covers the lookup, and
  that the error report redacts each credential that Box attached.
- The telemetry crate declares the tokio `time` feature and `base64` as dependencies. These add no
  package to `Cargo.lock`.

## Tests

- New tests: `a_failure_report_redacts_an_echoed_credential`,
  `a_signature_covers_the_url_the_client_sends` and
  `a_slow_credential_lookup_is_bounded_and_does_not_hold_shutdown`. Each one fails when its fix is
  removed.
- `cargo test -p strands-box-telemetry --all-features --lib`: 107 passed, 0 failed.
- `cargo test -p strands-box --all-features --test box_telemetry`: 32 passed, 0 failed.
- `cargo fmt --all --check` and `cargo build --workspace --all-features --locked` have no errors.
  `cargo clippy` adds no warnings in crates other than `crates/shell`.
@SaiAbhishek98
SaiAbhishek98 force-pushed the feature/third-party-telemetry-export branch from 46a389b to 3c22ea7 Compare November 16, 2026 19:47

@SaiAbhishek98 SaiAbhishek98 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved.

@leo237
leo237 merged commit 1c48cd6 into strands-agents:main Nov 17, 2026
16 of 17 checks passed
hanaduy added a commit that referenced this pull request Nov 17, 2026
One conflict, in crates/box/src/record/config/mod.rs: main's telemetry export (#314) took record
version 36, which this branch used for monty = false. Telemetry export keeps 36; monty = false
moves to 37 and stays the first check in record_version(), since it is now the highest. The
monty test's too-old version, decisions.md and config.md now say 37.
@SaiAbhishek98
SaiAbhishek98 deleted the feature/third-party-telemetry-export branch November 24, 2026 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area - Egress/Creds Area - Telemetry The telemetry collector, receiver, and record targets enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants