fix(metrics): use client-side filtering for --filter flag, add --tag-filter#54
Merged
Merged
Conversation
…filter The --filter flag was incorrectly using the API's tag_filter parameter, which filters by Datadog tags (env:prod), not metric names. This caused all metric name filters to return empty results. Changes: - Add matchMetricName() helper supporting wildcards (* and ?) - Apply client-side filtering on metric names when --filter is used - Add --tag-filter flag to expose actual tag filtering functionality - Update documentation to clarify filter vs tag-filter usage - Add comprehensive tests for wildcard pattern matching The fix allows users to filter metrics by name patterns (system.*, *.cpu.*, *request*) while maintaining backward compatibility. Users can now use --tag-filter for tag-based filtering if needed. Fixes #53 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
📊 Test Coverage ReportThreshold: 80% ✅ Coverage by Package📈 Coverage Status: ✅ PASSED - Coverage meets minimum threshold Updated for commit 392f1c3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #53 -
pup metrics list --filternow correctly filters metrics by name patterns instead of returning empty results.The
--filterflag was incorrectly using the Datadog API'stag_filterparameter, which filters by Datadog tags (likeenv:prod), not metric names. This caused all metric name filters to return empty results.Changes
matchMetricName()helper (cmd/metrics.go:637) - Implements wildcard pattern matching supporting*(match any characters) and?(match single character)--filteris used--tag-filterflag (cmd/metrics.go:484) - Exposes actual tag filtering functionality for users who want to filter by Datadog tags--filter(name patterns) and--tag-filter(Datadog tags)Testing
Unit tests:
Manual testing with real API:
Test coverage:
Examples
Breaking Changes
None. The
--filterflag behavior is fixed to match its documentation. Since it was broken (always returned empty), no existing workflows should break.Related Issues
Closes #53
🤖 Generated with Claude Code