feat: add filtering options to list-sources#18
Merged
Conversation
Add --collector, --name, --category, and --limit flags to list-sources. When --collector is specified, the collector list is filtered by name before fetching sources, avoiding unnecessary API calls to collectors that don't match. Source-level filters (--name, --category) are applied as post-filters, and --limit caps total sources across all collectors. Closes #12.
b7939e6 to
ee3ecde
Compare
3 tasks
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
--collectorflag to filter by collector name before fetching sources (avoids unnecessary API calls)-n/--nameflag to filter sources by name--categoryflag to filter sources by category-l/--limitflag to cap total sources returnedDetails
The key optimization is pre-filtering collectors by name before the parallel source fetch. In environments with 200+ collectors, specifying
--collector "my-service"might narrow down to 3-5 collectors, eliminating ~98% of API calls and avoiding rate-limit errors.Source-level filters (
--name,--category) are applied as post-filters after fetching. Collectors with no matching sources after filtering are excluded from output.--limitis applied last, capping total sources across all collectors.Files changed:
lib/sumologic/cli.rb— Thor option declarations and updated help textlib/sumologic/cli/commands/list_sources_command.rb— Pass filter options to clientlib/sumologic/metadata/source.rb— Collector pre-filter, source post-filter, limit logiclib/sumologic/client.rb— Updatedlist_all_sourcesfacade signaturespec/sumologic/metadata/source_spec.rb— New: 11 tests for filtering/limitingspec/sumologic/cli/commands/commands_spec.rb— Updated command testsTest plan
Closes #12