tempo/pkg/spanfilter/spanfilter.go

78 lines
1.7 KiB
Go
Raw Permalink Normal View History

[metrics-generator] filter out spans based on policy (#2274) * First pass at span filtering Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Validate the spanmetrics filteirng config on startup Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Give some hope that we return a true match Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Drop unused argument service name and rely on attributes Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Handling a few intrinsics Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include documentation for spanmetrics filtering policies Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Adjust filter policy to split policies during New() Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update test for intrinsic Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include benchmark and supporting span generator Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include metric for counting spans that have been filtered out Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include config warning when unsupported intrinic is used Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Relocate spanmetrics.FilterPolicy to sharedconfig package and implement overrides Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include sharedconfig pacakge Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update modules/generator/processor/spanmetrics/spanmetrics.go Co-authored-by: Joe Elliott <joe.elliott@grafana.com> * Refactor spanfilter into its own package Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include tests for spanfilter.New() Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update spanmetrics processor to return an error for spanfilter error Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Relocate config validation to spanfilter during New Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update tests for spanmetrics error return Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Drop unused Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update docs to include nesting of filtering config Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Exit early when attributes are unmatched Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Exit early when intrinsics are not matched Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Preallocate a couple variables Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Add note about use of RandomBatcher Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update changelog * Drop TODO comment Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Add back the lost metric during rebase Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Fix policy override configuration Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include generator config test Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Migrate the metric and expand reasons Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update tests for discardCounter Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include doc about which kinds are available for filtering Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Spellcheck * Perform number matching for kind and status Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Rename discardCounter to filteredSpansCounter Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Improve error quality Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update error message in test Signed-off-by: Zach Leslie <zach.leslie@grafana.com> --------- Signed-off-by: Zach Leslie <zach.leslie@grafana.com> Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> Co-authored-by: Joe Elliott <joe.elliott@grafana.com>
2023-05-02 20:36:49 +00:00
package spanfilter
import (
"github.com/grafana/tempo/pkg/spanfilter/config"
v1 "github.com/grafana/tempo/pkg/tempopb/resource/v1"
tracev1 "github.com/grafana/tempo/pkg/tempopb/trace/v1"
[metrics-generator] filter out spans based on policy (#2274) * First pass at span filtering Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Validate the spanmetrics filteirng config on startup Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Give some hope that we return a true match Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Drop unused argument service name and rely on attributes Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Handling a few intrinsics Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include documentation for spanmetrics filtering policies Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Adjust filter policy to split policies during New() Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update test for intrinsic Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include benchmark and supporting span generator Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include metric for counting spans that have been filtered out Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include config warning when unsupported intrinic is used Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Relocate spanmetrics.FilterPolicy to sharedconfig package and implement overrides Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include sharedconfig pacakge Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update modules/generator/processor/spanmetrics/spanmetrics.go Co-authored-by: Joe Elliott <joe.elliott@grafana.com> * Refactor spanfilter into its own package Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include tests for spanfilter.New() Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update spanmetrics processor to return an error for spanfilter error Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Relocate config validation to spanfilter during New Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update tests for spanmetrics error return Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Drop unused Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update docs to include nesting of filtering config Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Exit early when attributes are unmatched Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Exit early when intrinsics are not matched Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Preallocate a couple variables Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Add note about use of RandomBatcher Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update changelog * Drop TODO comment Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Add back the lost metric during rebase Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Fix policy override configuration Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include generator config test Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Migrate the metric and expand reasons Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update tests for discardCounter Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include doc about which kinds are available for filtering Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Spellcheck * Perform number matching for kind and status Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Rename discardCounter to filteredSpansCounter Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Improve error quality Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update error message in test Signed-off-by: Zach Leslie <zach.leslie@grafana.com> --------- Signed-off-by: Zach Leslie <zach.leslie@grafana.com> Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> Co-authored-by: Joe Elliott <joe.elliott@grafana.com>
2023-05-02 20:36:49 +00:00
)
type SpanFilter struct {
filterPolicies []*filterPolicy
}
type filterPolicy struct {
Include *splitPolicy
Exclude *splitPolicy
}
// NewSpanFilter returns a SpanFilter that will filter spans based on the given filter policies.
[metrics-generator] filter out spans based on policy (#2274) * First pass at span filtering Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Validate the spanmetrics filteirng config on startup Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Give some hope that we return a true match Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Drop unused argument service name and rely on attributes Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Handling a few intrinsics Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include documentation for spanmetrics filtering policies Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Adjust filter policy to split policies during New() Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update test for intrinsic Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include benchmark and supporting span generator Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include metric for counting spans that have been filtered out Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include config warning when unsupported intrinic is used Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Relocate spanmetrics.FilterPolicy to sharedconfig package and implement overrides Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include sharedconfig pacakge Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update modules/generator/processor/spanmetrics/spanmetrics.go Co-authored-by: Joe Elliott <joe.elliott@grafana.com> * Refactor spanfilter into its own package Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include tests for spanfilter.New() Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update spanmetrics processor to return an error for spanfilter error Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Relocate config validation to spanfilter during New Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update tests for spanmetrics error return Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Drop unused Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update docs to include nesting of filtering config Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Exit early when attributes are unmatched Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Exit early when intrinsics are not matched Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Preallocate a couple variables Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Add note about use of RandomBatcher Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update changelog * Drop TODO comment Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Add back the lost metric during rebase Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Fix policy override configuration Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include generator config test Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Migrate the metric and expand reasons Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update tests for discardCounter Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include doc about which kinds are available for filtering Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Spellcheck * Perform number matching for kind and status Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Rename discardCounter to filteredSpansCounter Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Improve error quality Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update error message in test Signed-off-by: Zach Leslie <zach.leslie@grafana.com> --------- Signed-off-by: Zach Leslie <zach.leslie@grafana.com> Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> Co-authored-by: Joe Elliott <joe.elliott@grafana.com>
2023-05-02 20:36:49 +00:00
func NewSpanFilter(filterPolicies []config.FilterPolicy) (*SpanFilter, error) {
var policies []*filterPolicy
for _, policy := range filterPolicies {
err := config.ValidateFilterPolicy(policy)
[metrics-generator] filter out spans based on policy (#2274) * First pass at span filtering Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Validate the spanmetrics filteirng config on startup Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Give some hope that we return a true match Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Drop unused argument service name and rely on attributes Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Handling a few intrinsics Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include documentation for spanmetrics filtering policies Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Adjust filter policy to split policies during New() Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update test for intrinsic Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include benchmark and supporting span generator Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include metric for counting spans that have been filtered out Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include config warning when unsupported intrinic is used Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Relocate spanmetrics.FilterPolicy to sharedconfig package and implement overrides Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include sharedconfig pacakge Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update modules/generator/processor/spanmetrics/spanmetrics.go Co-authored-by: Joe Elliott <joe.elliott@grafana.com> * Refactor spanfilter into its own package Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include tests for spanfilter.New() Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update spanmetrics processor to return an error for spanfilter error Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Relocate config validation to spanfilter during New Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update tests for spanmetrics error return Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Drop unused Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update docs to include nesting of filtering config Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Exit early when attributes are unmatched Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Exit early when intrinsics are not matched Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Preallocate a couple variables Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Add note about use of RandomBatcher Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update changelog * Drop TODO comment Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Add back the lost metric during rebase Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Fix policy override configuration Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include generator config test Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Migrate the metric and expand reasons Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update tests for discardCounter Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include doc about which kinds are available for filtering Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Spellcheck * Perform number matching for kind and status Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Rename discardCounter to filteredSpansCounter Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Improve error quality Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update error message in test Signed-off-by: Zach Leslie <zach.leslie@grafana.com> --------- Signed-off-by: Zach Leslie <zach.leslie@grafana.com> Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> Co-authored-by: Joe Elliott <joe.elliott@grafana.com>
2023-05-02 20:36:49 +00:00
if err != nil {
return nil, err
}
include, err := getSplitPolicy(policy.Include)
if err != nil {
return nil, err
}
exclude, err := getSplitPolicy(policy.Exclude)
if err != nil {
return nil, err
}
p := filterPolicy{
Include: include,
Exclude: exclude,
[metrics-generator] filter out spans based on policy (#2274) * First pass at span filtering Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Validate the spanmetrics filteirng config on startup Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Give some hope that we return a true match Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Drop unused argument service name and rely on attributes Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Handling a few intrinsics Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include documentation for spanmetrics filtering policies Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Adjust filter policy to split policies during New() Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update test for intrinsic Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include benchmark and supporting span generator Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include metric for counting spans that have been filtered out Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include config warning when unsupported intrinic is used Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Relocate spanmetrics.FilterPolicy to sharedconfig package and implement overrides Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include sharedconfig pacakge Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update modules/generator/processor/spanmetrics/spanmetrics.go Co-authored-by: Joe Elliott <joe.elliott@grafana.com> * Refactor spanfilter into its own package Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include tests for spanfilter.New() Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update spanmetrics processor to return an error for spanfilter error Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Relocate config validation to spanfilter during New Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update tests for spanmetrics error return Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Drop unused Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update docs to include nesting of filtering config Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Exit early when attributes are unmatched Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Exit early when intrinsics are not matched Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Preallocate a couple variables Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Add note about use of RandomBatcher Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update changelog * Drop TODO comment Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Add back the lost metric during rebase Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Fix policy override configuration Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include generator config test Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Migrate the metric and expand reasons Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update tests for discardCounter Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include doc about which kinds are available for filtering Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Spellcheck * Perform number matching for kind and status Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Rename discardCounter to filteredSpansCounter Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Improve error quality Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update error message in test Signed-off-by: Zach Leslie <zach.leslie@grafana.com> --------- Signed-off-by: Zach Leslie <zach.leslie@grafana.com> Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> Co-authored-by: Joe Elliott <joe.elliott@grafana.com>
2023-05-02 20:36:49 +00:00
}
if p.Include != nil || p.Exclude != nil {
policies = append(policies, &p)
[metrics-generator] filter out spans based on policy (#2274) * First pass at span filtering Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Validate the spanmetrics filteirng config on startup Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Give some hope that we return a true match Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Drop unused argument service name and rely on attributes Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Handling a few intrinsics Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include documentation for spanmetrics filtering policies Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Adjust filter policy to split policies during New() Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update test for intrinsic Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include benchmark and supporting span generator Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include metric for counting spans that have been filtered out Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include config warning when unsupported intrinic is used Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Relocate spanmetrics.FilterPolicy to sharedconfig package and implement overrides Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include sharedconfig pacakge Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update modules/generator/processor/spanmetrics/spanmetrics.go Co-authored-by: Joe Elliott <joe.elliott@grafana.com> * Refactor spanfilter into its own package Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include tests for spanfilter.New() Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update spanmetrics processor to return an error for spanfilter error Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Relocate config validation to spanfilter during New Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update tests for spanmetrics error return Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Drop unused Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update docs to include nesting of filtering config Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Exit early when attributes are unmatched Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Exit early when intrinsics are not matched Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Preallocate a couple variables Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Add note about use of RandomBatcher Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update changelog * Drop TODO comment Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Add back the lost metric during rebase Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Fix policy override configuration Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include generator config test Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Migrate the metric and expand reasons Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update tests for discardCounter Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include doc about which kinds are available for filtering Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Spellcheck * Perform number matching for kind and status Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Rename discardCounter to filteredSpansCounter Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Improve error quality Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update error message in test Signed-off-by: Zach Leslie <zach.leslie@grafana.com> --------- Signed-off-by: Zach Leslie <zach.leslie@grafana.com> Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> Co-authored-by: Joe Elliott <joe.elliott@grafana.com>
2023-05-02 20:36:49 +00:00
}
}
return &SpanFilter{
filterPolicies: policies,
}, nil
}
// ApplyFilterPolicy returns true if the span should be included in the metrics.
func (f *SpanFilter) ApplyFilterPolicy(rs *v1.Resource, span *tracev1.Span) bool {
[metrics-generator] filter out spans based on policy (#2274) * First pass at span filtering Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Validate the spanmetrics filteirng config on startup Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Give some hope that we return a true match Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Drop unused argument service name and rely on attributes Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Handling a few intrinsics Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include documentation for spanmetrics filtering policies Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Adjust filter policy to split policies during New() Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update test for intrinsic Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include benchmark and supporting span generator Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include metric for counting spans that have been filtered out Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include config warning when unsupported intrinic is used Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Relocate spanmetrics.FilterPolicy to sharedconfig package and implement overrides Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include sharedconfig pacakge Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update modules/generator/processor/spanmetrics/spanmetrics.go Co-authored-by: Joe Elliott <joe.elliott@grafana.com> * Refactor spanfilter into its own package Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include tests for spanfilter.New() Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update spanmetrics processor to return an error for spanfilter error Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Relocate config validation to spanfilter during New Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update tests for spanmetrics error return Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Drop unused Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update docs to include nesting of filtering config Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Exit early when attributes are unmatched Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Exit early when intrinsics are not matched Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Preallocate a couple variables Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Add note about use of RandomBatcher Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update changelog * Drop TODO comment Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Add back the lost metric during rebase Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Fix policy override configuration Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include generator config test Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Migrate the metric and expand reasons Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update tests for discardCounter Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include doc about which kinds are available for filtering Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Spellcheck * Perform number matching for kind and status Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Rename discardCounter to filteredSpansCounter Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Improve error quality Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update error message in test Signed-off-by: Zach Leslie <zach.leslie@grafana.com> --------- Signed-off-by: Zach Leslie <zach.leslie@grafana.com> Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> Co-authored-by: Joe Elliott <joe.elliott@grafana.com>
2023-05-02 20:36:49 +00:00
// With no filter policies specified, all spans are included.
if len(f.filterPolicies) == 0 {
return true
}
for _, policy := range f.filterPolicies {
if policy.Include != nil && !policy.Include.Match(rs, span) {
return false
[metrics-generator] filter out spans based on policy (#2274) * First pass at span filtering Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Validate the spanmetrics filteirng config on startup Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Give some hope that we return a true match Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Drop unused argument service name and rely on attributes Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Handling a few intrinsics Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include documentation for spanmetrics filtering policies Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Adjust filter policy to split policies during New() Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update test for intrinsic Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include benchmark and supporting span generator Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include metric for counting spans that have been filtered out Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include config warning when unsupported intrinic is used Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Relocate spanmetrics.FilterPolicy to sharedconfig package and implement overrides Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include sharedconfig pacakge Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update modules/generator/processor/spanmetrics/spanmetrics.go Co-authored-by: Joe Elliott <joe.elliott@grafana.com> * Refactor spanfilter into its own package Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include tests for spanfilter.New() Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update spanmetrics processor to return an error for spanfilter error Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Relocate config validation to spanfilter during New Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update tests for spanmetrics error return Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Drop unused Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update docs to include nesting of filtering config Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Exit early when attributes are unmatched Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Exit early when intrinsics are not matched Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Preallocate a couple variables Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Add note about use of RandomBatcher Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update changelog * Drop TODO comment Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Add back the lost metric during rebase Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Fix policy override configuration Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include generator config test Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Migrate the metric and expand reasons Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update tests for discardCounter Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include doc about which kinds are available for filtering Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Spellcheck * Perform number matching for kind and status Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Rename discardCounter to filteredSpansCounter Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Improve error quality Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update error message in test Signed-off-by: Zach Leslie <zach.leslie@grafana.com> --------- Signed-off-by: Zach Leslie <zach.leslie@grafana.com> Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> Co-authored-by: Joe Elliott <joe.elliott@grafana.com>
2023-05-02 20:36:49 +00:00
}
if policy.Exclude != nil && policy.Exclude.Match(rs, span) {
return false
[metrics-generator] filter out spans based on policy (#2274) * First pass at span filtering Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Validate the spanmetrics filteirng config on startup Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Give some hope that we return a true match Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Drop unused argument service name and rely on attributes Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Handling a few intrinsics Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include documentation for spanmetrics filtering policies Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Adjust filter policy to split policies during New() Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update test for intrinsic Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include benchmark and supporting span generator Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include metric for counting spans that have been filtered out Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include config warning when unsupported intrinic is used Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Relocate spanmetrics.FilterPolicy to sharedconfig package and implement overrides Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include sharedconfig pacakge Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update modules/generator/processor/spanmetrics/spanmetrics.go Co-authored-by: Joe Elliott <joe.elliott@grafana.com> * Refactor spanfilter into its own package Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include tests for spanfilter.New() Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update spanmetrics processor to return an error for spanfilter error Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Relocate config validation to spanfilter during New Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update tests for spanmetrics error return Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Drop unused Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update docs to include nesting of filtering config Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Exit early when attributes are unmatched Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Exit early when intrinsics are not matched Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Preallocate a couple variables Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Add note about use of RandomBatcher Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update changelog * Drop TODO comment Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Add back the lost metric during rebase Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Fix policy override configuration Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include generator config test Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Migrate the metric and expand reasons Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update tests for discardCounter Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include doc about which kinds are available for filtering Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Spellcheck * Perform number matching for kind and status Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Rename discardCounter to filteredSpansCounter Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Improve error quality Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update error message in test Signed-off-by: Zach Leslie <zach.leslie@grafana.com> --------- Signed-off-by: Zach Leslie <zach.leslie@grafana.com> Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> Co-authored-by: Joe Elliott <joe.elliott@grafana.com>
2023-05-02 20:36:49 +00:00
}
}
return true
[metrics-generator] filter out spans based on policy (#2274) * First pass at span filtering Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Validate the spanmetrics filteirng config on startup Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Give some hope that we return a true match Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Drop unused argument service name and rely on attributes Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Handling a few intrinsics Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include documentation for spanmetrics filtering policies Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Adjust filter policy to split policies during New() Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update test for intrinsic Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include benchmark and supporting span generator Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include metric for counting spans that have been filtered out Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include config warning when unsupported intrinic is used Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Relocate spanmetrics.FilterPolicy to sharedconfig package and implement overrides Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include sharedconfig pacakge Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update modules/generator/processor/spanmetrics/spanmetrics.go Co-authored-by: Joe Elliott <joe.elliott@grafana.com> * Refactor spanfilter into its own package Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include tests for spanfilter.New() Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update spanmetrics processor to return an error for spanfilter error Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Relocate config validation to spanfilter during New Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update tests for spanmetrics error return Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Drop unused Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update docs to include nesting of filtering config Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Exit early when attributes are unmatched Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Exit early when intrinsics are not matched Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Preallocate a couple variables Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Add note about use of RandomBatcher Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update changelog * Drop TODO comment Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Add back the lost metric during rebase Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Fix policy override configuration Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include generator config test Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Migrate the metric and expand reasons Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update tests for discardCounter Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include doc about which kinds are available for filtering Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Spellcheck * Perform number matching for kind and status Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Rename discardCounter to filteredSpansCounter Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Improve error quality Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update error message in test Signed-off-by: Zach Leslie <zach.leslie@grafana.com> --------- Signed-off-by: Zach Leslie <zach.leslie@grafana.com> Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> Co-authored-by: Joe Elliott <joe.elliott@grafana.com>
2023-05-02 20:36:49 +00:00
}
func getSplitPolicy(policy *config.PolicyMatch) (*splitPolicy, error) {
[metrics-generator] filter out spans based on policy (#2274) * First pass at span filtering Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Validate the spanmetrics filteirng config on startup Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Give some hope that we return a true match Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Drop unused argument service name and rely on attributes Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Handling a few intrinsics Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include documentation for spanmetrics filtering policies Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Adjust filter policy to split policies during New() Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update test for intrinsic Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include benchmark and supporting span generator Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include metric for counting spans that have been filtered out Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include config warning when unsupported intrinic is used Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Relocate spanmetrics.FilterPolicy to sharedconfig package and implement overrides Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include sharedconfig pacakge Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update modules/generator/processor/spanmetrics/spanmetrics.go Co-authored-by: Joe Elliott <joe.elliott@grafana.com> * Refactor spanfilter into its own package Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include tests for spanfilter.New() Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update spanmetrics processor to return an error for spanfilter error Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Relocate config validation to spanfilter during New Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update tests for spanmetrics error return Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Drop unused Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update docs to include nesting of filtering config Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Exit early when attributes are unmatched Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Exit early when intrinsics are not matched Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Preallocate a couple variables Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Add note about use of RandomBatcher Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update changelog * Drop TODO comment Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Add back the lost metric during rebase Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Fix policy override configuration Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include generator config test Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Migrate the metric and expand reasons Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update tests for discardCounter Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include doc about which kinds are available for filtering Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Spellcheck * Perform number matching for kind and status Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Rename discardCounter to filteredSpansCounter Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Improve error quality Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update error message in test Signed-off-by: Zach Leslie <zach.leslie@grafana.com> --------- Signed-off-by: Zach Leslie <zach.leslie@grafana.com> Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> Co-authored-by: Joe Elliott <joe.elliott@grafana.com>
2023-05-02 20:36:49 +00:00
if policy == nil {
return nil, nil
[metrics-generator] filter out spans based on policy (#2274) * First pass at span filtering Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Validate the spanmetrics filteirng config on startup Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Give some hope that we return a true match Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Drop unused argument service name and rely on attributes Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Handling a few intrinsics Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include documentation for spanmetrics filtering policies Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Adjust filter policy to split policies during New() Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update test for intrinsic Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include benchmark and supporting span generator Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include metric for counting spans that have been filtered out Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include config warning when unsupported intrinic is used Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Relocate spanmetrics.FilterPolicy to sharedconfig package and implement overrides Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include sharedconfig pacakge Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update modules/generator/processor/spanmetrics/spanmetrics.go Co-authored-by: Joe Elliott <joe.elliott@grafana.com> * Refactor spanfilter into its own package Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include tests for spanfilter.New() Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update spanmetrics processor to return an error for spanfilter error Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Relocate config validation to spanfilter during New Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update tests for spanmetrics error return Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Drop unused Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update docs to include nesting of filtering config Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Exit early when attributes are unmatched Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Exit early when intrinsics are not matched Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Preallocate a couple variables Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Add note about use of RandomBatcher Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update changelog * Drop TODO comment Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Add back the lost metric during rebase Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Fix policy override configuration Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include generator config test Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Migrate the metric and expand reasons Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update tests for discardCounter Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include doc about which kinds are available for filtering Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Spellcheck * Perform number matching for kind and status Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Rename discardCounter to filteredSpansCounter Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Improve error quality Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update error message in test Signed-off-by: Zach Leslie <zach.leslie@grafana.com> --------- Signed-off-by: Zach Leslie <zach.leslie@grafana.com> Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> Co-authored-by: Joe Elliott <joe.elliott@grafana.com>
2023-05-02 20:36:49 +00:00
}
return newSplitPolicy(policy)
[metrics-generator] filter out spans based on policy (#2274) * First pass at span filtering Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Validate the spanmetrics filteirng config on startup Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Give some hope that we return a true match Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Drop unused argument service name and rely on attributes Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Handling a few intrinsics Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include documentation for spanmetrics filtering policies Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/tempo/metrics-generator/span_metrics.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Adjust filter policy to split policies during New() Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update test for intrinsic Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include benchmark and supporting span generator Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include metric for counting spans that have been filtered out Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include config warning when unsupported intrinic is used Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Relocate spanmetrics.FilterPolicy to sharedconfig package and implement overrides Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include sharedconfig pacakge Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update modules/generator/processor/spanmetrics/spanmetrics.go Co-authored-by: Joe Elliott <joe.elliott@grafana.com> * Refactor spanfilter into its own package Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include tests for spanfilter.New() Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update spanmetrics processor to return an error for spanfilter error Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Relocate config validation to spanfilter during New Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update tests for spanmetrics error return Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Drop unused Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update docs to include nesting of filtering config Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Exit early when attributes are unmatched Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Exit early when intrinsics are not matched Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Preallocate a couple variables Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Add note about use of RandomBatcher Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update changelog * Drop TODO comment Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Add back the lost metric during rebase Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Fix policy override configuration Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include generator config test Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Migrate the metric and expand reasons Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update tests for discardCounter Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Include doc about which kinds are available for filtering Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Spellcheck * Perform number matching for kind and status Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Rename discardCounter to filteredSpansCounter Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Improve error quality Signed-off-by: Zach Leslie <zach.leslie@grafana.com> * Update error message in test Signed-off-by: Zach Leslie <zach.leslie@grafana.com> --------- Signed-off-by: Zach Leslie <zach.leslie@grafana.com> Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> Co-authored-by: Joe Elliott <joe.elliott@grafana.com>
2023-05-02 20:36:49 +00:00
}