Skip to content

Add String() method to telemetry Config to redact OTLP credentials - #3782

Merged
ChrisJBurns merged 1 commit into
mainfrom
otel/redact-config-headers
Feb 11, 2026
Merged

ChrisJBurns merged 1 commit into
mainfrom
otel/redact-config-headers

Conversation

@ChrisJBurns

@ChrisJBurns ChrisJBurns commented Feb 11, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Adds fmt.Stringer implementation to telemetry.Config that redacts Headers values with [REDACTED] while preserving keys
  • Adds fmt.GoStringer implementation (GoString()) to prevent credential leakage via %#v format verb
  • Prevents accidental credential leakage (API keys, bearer tokens) if the config struct is logged or printed in error paths
  • Includes compile-time interface assertions for both fmt.Stringer and fmt.GoStringer

Parent issue: #3399

Test plan

  • TestConfigString_HeaderRedaction — table-driven test covering:
    • Single header redaction (keys visible, values replaced with [REDACTED])
    • Multiple headers redaction
    • Empty headers (no [REDACTED] in output)
    • Nil headers (no panic, no [REDACTED])
    • GoString() delegates to String() in all cases
    • %#v format verb uses GoString() in all cases
  • go vet ./pkg/telemetry/... passes
  • task lint-fix — 0 issues

🤖 Generated with Claude Code

@github-actions github-actions Bot added the size/S Small PR: 100-299 lines changed label Feb 11, 2026
jerm-dro
jerm-dro previously approved these changes Feb 11, 2026
JAORMX
JAORMX previously approved these changes Feb 11, 2026
@codecov

codecov Bot commented Feb 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.51%. Comparing base (15eaa3c) to head (e645130).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3782      +/-   ##
==========================================
- Coverage   66.56%   66.51%   -0.05%     
==========================================
  Files         434      434              
  Lines       42309    42321      +12     
==========================================
- Hits        28161    28150      -11     
- Misses      11998    12019      +21     
- Partials     2150     2152       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ChrisJBurns
ChrisJBurns dismissed stale reviews from JAORMX and jerm-dro via 1199bd0 February 11, 2026 17:08
@ChrisJBurns
ChrisJBurns force-pushed the otel/redact-config-headers branch from c21de48 to 1199bd0 Compare February 11, 2026 17:08
@github-actions github-actions Bot added size/S Small PR: 100-299 lines changed and removed size/S Small PR: 100-299 lines changed labels Feb 11, 2026
The Config struct's Headers field stores authentication credentials
(API keys, bearer tokens) for OTLP endpoints. Without a String()
method, these values could be exposed if the struct is logged or
printed in error paths.

Add a fmt.Stringer implementation that redacts header values with
[REDACTED] while preserving keys for debuggability.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ChrisJBurns
ChrisJBurns force-pushed the otel/redact-config-headers branch from 1199bd0 to e645130 Compare February 11, 2026 17:16
@github-actions github-actions Bot added size/XS Extra small PR: < 100 lines changed and removed size/S Small PR: 100-299 lines changed labels Feb 11, 2026
@ChrisJBurns
ChrisJBurns merged commit 3420ec5 into main Feb 11, 2026
36 checks passed
@ChrisJBurns
ChrisJBurns deleted the otel/redact-config-headers branch February 11, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Extra small PR: < 100 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants