v0.0.24 includes the MetadataSampler, which allows you to easily decide whether or not to log a trace based on metadata fields.
How it works
At configuration time, you can pass asampler parameter to the configure function. The MetadataSampler accepts any function that maps metadata Optional[dict[str, str]] to a boolean.
Basic Usage
Complete Example
Check out our full example on GitHub that demonstrates metadata-based sampling in action.Use Cases
Metadata sampling is particularly useful for:- Environment-based filtering: Different sampling rates for dev/staging/prod
- Feature flagging: Only trace when specific features are enabled
- User-based sampling: Focus on specific user segments or cohorts
- Compliance: Exclude traces containing sensitive user data based on metadata flags