Skip to content

feat(telemetry): support AGENTCORE_TELEMETRY_DISABLED env var - #12

Closed
Hweinstock wants to merge 7 commits into
refactorfrom
feat/telemetry-disabled-env
Closed

feat(telemetry): support AGENTCORE_TELEMETRY_DISABLED env var#12
Hweinstock wants to merge 7 commits into
refactorfrom
feat/telemetry-disabled-env

Conversation

@Hweinstock

Copy link
Copy Markdown
Owner

Spec

Problem: CI runs emit telemetry, adding noise on the refactor branch.

Definition of Done:

  • Support the mainline env var AGENTCORE_TELEMETRY_DISABLED; when set to "true" or "1", telemetry is not emitted. Precedence: env var >> config >> default.
  • Audit must still work.
  • Inject the env var into each CI workflow that executes tests or CLI code.

Changes

  • src/globalConfig/config.tsx: applyOverrides now gives AGENTCORE_TELEMETRY_DISABLED top precedence over config/default for telemetry.enabled. Name matches mainline. telemetry.audit is untouched, so audit still works. Disable-only semantics (matches mainline).
  • .github/workflows/build.yml, unit-test.yml: set env: AGENTCORE_TELEMETRY_DISABLED: "1" at the reusable-workflow level. These are the only workflows that execute the CLI (agentcore --help smoke test) or tests (bun test). Set inside the reusable workflows because a caller's env: does not propagate into reusable workflows.
  • src/globalConfig/config.test.tsx: table-driven unit tests for the precedence and audit behavior.

Verification

Unit / static checks

bun test src/globalConfig/   # 10 pass, 0 fail
bun run lint:check           # OK
bun run format:check         # OK
bun run typecheck            # OK

End-to-end (local OTLP collector + isolated HOME)

Minimal collector logs each /v1/metrics export to a file; the CLI points at it via config telemetry.endpoint=http://localhost:4318, with enabled and audit both true.

Scenario 1 — no env var (baseline):

$ agentcore config telemetry.enabled
true
# collector.log:
2026-09-01T00:28:54Z received /v1/metrics export (1251 bytes)
# audit file written:
~/.agentcore/telemetry/5724d7b5-...jsonl   (cli.command_run entry)

Scenario 2 — AGENTCORE_TELEMETRY_DISABLED=1:

$ AGENTCORE_TELEMETRY_DISABLED=1 agentcore config telemetry.enabled
false                        # env override forces resolved enabled=false (over config's true)
# collector.log: unchanged — NO new export received
# audit file STILL written:
~/.agentcore/telemetry/0a29f880-...jsonl   (audit still works)

Result: env var suppresses network telemetry with top precedence over config; audit is unaffected.

Reproduce

bun install
bun run compile:linux-x64
# terminal A: tiny OTLP collector on :4318 logging POSTs to /v1/metrics
# terminal B, isolated HOME with config { telemetry: { enabled:true, audit:true, endpoint:"http://localhost:4318" } }:
./dist/bin/agentcore-linux-x64 config telemetry.enabled                       # -> collector gets export + audit file
AGENTCORE_TELEMETRY_DISABLED=1 ./dist/bin/agentcore-linux-x64 config telemetry.enabled  # -> no export; audit file still written

Comment thread src/globalConfig/config.test.tsx Outdated
@@ -0,0 +1,41 @@
import { test, describe, afterEach, expect } from "bun:test";

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

remove these tests and replace them with some on the e2e config handler.

Comment thread src/handlers/config/config.test.tsx Outdated
const readOutput = await run(["telemetry.enabled"]);
expect(JSON.parse(readOutput)).toBe(false);
});

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

use a test.each and fix the failing tests

@Hweinstock Hweinstock closed this Sep 1, 2026
@Hweinstock
Hweinstock deleted the feat/telemetry-disabled-env branch September 1, 2026 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant