Skip to content

Add explicit signal disable controls#48

Merged
dialupdisaster merged 3 commits into
DEVtheOPS:mainfrom
DanMaly:signal-controls
May 19, 2026
Merged

Add explicit signal disable controls#48
dialupdisaster merged 3 commits into
DEVtheOPS:mainfrom
DanMaly:signal-controls

Conversation

@DanMaly
Copy link
Copy Markdown
Contributor

@DanMaly DanMaly commented May 8, 2026

Add explicit controls for suppressing OTLP log and trace export.

  • add OPENCODE_DISABLE_LOGS to suppress every OTLP log event while leaving metrics and traces untouched
  • make OPENCODE_DISABLE_TRACES support explicit global values such as all, *, true, and 1
  • update docs and add focused tests covering the new signal disable behaviour

Summary by CodeRabbit

  • New Features

    • New env var OPENCODE_DISABLE_LOGS to suppress OTLP log export while leaving metrics/traces intact.
    • New env var OPENCODE_DISABLE_TRACES to selectively disable trace types (supports all, *, true, 1).
  • Behavior Changes

    • Log emission is now gated by the new logs-enabled setting; relevant events are routed through the gated emitter.
    • Config handling now normalizes/expands disabled trace values and exposes trace-type listing and logs-enabled state.
  • Tests

    • Added tests for log/tracing suppression and expanded disable-values.
  • Documentation

    • README updated with new sections, examples, and TOC entries for disabling logs and traces.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 69d28a8e-69f2-436c-b285-d18485207bdd

📥 Commits

Reviewing files that changed from the base of the PR and between dfeba19 and c8fc0e4.

📒 Files selected for processing (6)
  • README.md
  • src/handlers/activity.ts
  • src/handlers/session.ts
  • src/index.ts
  • src/types.ts
  • tests/helpers.ts
✅ Files skipped from review due to trivial changes (2)
  • README.md
  • src/handlers/activity.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/types.ts
  • tests/helpers.ts
  • src/index.ts
  • src/handlers/session.ts

📝 Walkthrough

Walkthrough

This PR adds OPENCODE_DISABLE_LOGS and OPENCODE_DISABLE_TRACES, computes logsEnabled and normalized disabledTraces at startup, provides a gated emitLog callback in OtelPlugin, updates handlers to call emitLog, and adds tests and README docs covering the new flags.

Changes

Log and Trace Disablement Feature

Layer / File(s) Summary
Type Contracts
src/types.ts
HandlerContext replaces logger: OtelLogger with emitLog: (record: LogRecord) => void and imports LogRecord.
Configuration & Constants
src/config.ts
Adds TRACE_TYPES, extends PluginConfig with logsEnabled, and adds parsing helpers (parseDisabledTraces()) to normalize/expand OPENCODE_DISABLE_TRACES (supports all, *, true, 1).
Plugin Core Implementation
src/index.ts
Introduces an emitLog() helper that forwards records to OpenTelemetry only when config.logsEnabled is true; wires emitLog into HandlerContext and logs startup note when logs are disabled.
Handler Log Emission
src/handlers/activity.ts, src/handlers/message.ts, src/handlers/permission.ts, src/handlers/session.ts
Handlers switch from ctx.logger.emit() to ctx.emitLog() for structured OTLP log events while preserving existing payloads and metric/span behavior.
Test Infrastructure & Coverage
tests/helpers.ts, tests/config.test.ts, tests/handlers/disabled-signals.test.ts
makeCtx gains logsEnabled param; config tests validate logsEnabled default and OPENCODE_DISABLE_LOGS behavior; new tests verify log suppression and disabled-trace behavior.
Documentation
README.md
Documents OPENCODE_DISABLE_LOGS and OPENCODE_DISABLE_TRACES with examples and accepted wildcard/disable-all values.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • dialupdisaster
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 53.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add explicit signal disable controls' accurately reflects the main changes, which introduce new configuration options (OPENCODE_DISABLE_LOGS and OPENCODE_DISABLE_TRACES) for suppressing OTLP signals throughout the codebase.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@README.md`:
- Around line 179-205: Add entries for the new "Disabling OTLP logs" and
"Disabling traces" sections to the top-level configuration TOC in README.md so
they are discoverable; update the TOC to include links that match the headings
(e.g., Disabling OTLP logs -> `#disabling-otlp-logs` and Disabling traces ->
`#disabling-traces`), place them near other configuration/env-var items, and
ensure the entries mention the related env vars OPENCODE_DISABLE_LOGS and
OPENCODE_DISABLE_TRACES for clarity.

In `@tests/config.test.ts`:
- Around line 270-283: Add a test asserting that OPENCODE_DISABLE_TRACES="1" is
treated as a global-disable alias: set
process.env["OPENCODE_DISABLE_TRACES"]="1" and expect
loadConfig().disabledTraces to equal new Set(TRACE_TYPES). This mirrors the
existing tests for "all", "*", and "true" and ensures parseDisabledTraces /
loadConfig handle the "1" alias as disabling every trace type.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0ba279a7-a881-4ffa-baee-1f7b476923c5

📥 Commits

Reviewing files that changed from the base of the PR and between a123a37 and 707a546.

📒 Files selected for processing (11)
  • README.md
  • src/config.ts
  • src/handlers/activity.ts
  • src/handlers/message.ts
  • src/handlers/permission.ts
  • src/handlers/session.ts
  • src/index.ts
  • src/types.ts
  • tests/config.test.ts
  • tests/handlers/disabled-signals.test.ts
  • tests/helpers.ts

Comment thread README.md
Comment thread tests/config.test.ts
@dialupdisaster
Copy link
Copy Markdown
Contributor

Can you resolve the conflicts on this?

It looks good, I will merge as soon as you fix those. Thanks!

@DanMaly
Copy link
Copy Markdown
Contributor Author

DanMaly commented May 19, 2026

Fixed, thank you for reviewing.

@dialupdisaster dialupdisaster merged commit 21549bd into DEVtheOPS:main May 19, 2026
2 checks passed
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.

2 participants