Skip to content

Add with_tracing_filter for custom/reloadable tracing filters#122

Closed
cetra3 wants to merge 1 commit intomainfrom
add-custom-tracing-filter
Closed

Add with_tracing_filter for custom/reloadable tracing filters#122
cetra3 wants to merge 1 commit intomainfrom
add-custom-tracing-filter

Conversation

@cetra3
Copy link
Contributor

@cetra3 cetra3 commented Mar 12, 2026

Summary

  • Adds LogfireConfigBuilder::with_tracing_filter() method that accepts any F: Filter<Registry>, allowing consumers to replace the default EnvFilter with a custom filter (e.g. reload::Layer<EnvFilter> for dynamic reloading)
  • Changes LogfireTracingLayer::new to accept Arc<dyn Filter<S>> instead of Arc<EnvFilter> (internal API only)
  • No local() mode required — the custom filter integrates into the normal finish() flow, so the global subscriber, log bridge, console output, and meter provider all work as before

Test plan

  • test_with_tracing_filter_custom_filter — verifies a static LevelFilter::WARN replaces the default, filtering out lower-level events
  • test_with_tracing_filter_reload — verifies a reload::Layer<EnvFilter> can dynamically switch INFO→DEBUG→INFO, with events correctly filtered at each phase
  • All existing tests pass

🤖 Generated with Claude Code

Allow consumers to provide their own tracing filter (e.g. a
`reload::Layer<EnvFilter>`) instead of the default `EnvFilter` that
Logfire constructs. This enables dynamic filter reloading at runtime
without requiring `local()` mode or manual subscriber composition.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 91.85185% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/bridges/tracing.rs 90.35% 11 Missing ⚠️

📢 Thoughts on this report? Let us know!

@cetra3
Copy link
Contributor Author

cetra3 commented Mar 12, 2026

Closing this one off for now, it looks like this probably won't work for tracing & needs a bit of a refactor

@cetra3 cetra3 closed this Mar 12, 2026
@cetra3 cetra3 deleted the add-custom-tracing-filter branch March 12, 2026 23:19
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