mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
* added spanfilter to filter out spans * return the error if the filters are not correctly formatted * add filters to the userconfigurable overrides * add core logic for drop items cache * wired up everything * some tweaks * refactor * fmt and manifest * tighten names * rename metric * drop already buffered counterparts when a span is filter out * add a new test and documentation * Update docs/sources/tempo/operations/manage-advanced-systems/user-configurable-overrides.md Co-authored-by: Suraj Nath <[email protected]> * Update docs/sources/tempo/configuration/_index.md Co-authored-by: Suraj Nath <[email protected]> * Update docs/sources/tempo/configuration/_index.md Co-authored-by: Suraj Nath <[email protected]> * bail early when the span kind is not client or server * Update docs/sources/tempo/operations/manage-advanced-systems/user-configurable-overrides.md Co-authored-by: Suraj Nath <[email protected]> --------- Co-authored-by: Suraj Nath <[email protected]>
81 lines
3.0 KiB
Go
81 lines
3.0 KiB
Go
package servicegraphs
|
|
|
|
import (
|
|
"flag"
|
|
"time"
|
|
|
|
"github.com/grafana/tempo/modules/generator/registry"
|
|
filterconfig "github.com/grafana/tempo/pkg/spanfilter/config"
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
semconv "go.opentelemetry.io/otel/semconv/v1.25.0"
|
|
semconvnew "go.opentelemetry.io/otel/semconv/v1.34.0"
|
|
)
|
|
|
|
type Config struct {
|
|
// Wait is the value to wait for an edge to be completed
|
|
Wait time.Duration `yaml:"wait"`
|
|
// MaxItems is the amount of edges that will be stored in the storeMap
|
|
MaxItems int `yaml:"max_items"`
|
|
|
|
// Workers is the amount of workers that will be used to process the edges
|
|
Workers int `yaml:"workers"`
|
|
|
|
// Buckets for latency histogram in seconds.
|
|
HistogramBuckets []float64 `yaml:"histogram_buckets"`
|
|
|
|
// The histogram mode to select.
|
|
HistogramOverride registry.HistogramMode `yaml:"-"`
|
|
|
|
// Additional dimensions (labels) to be added to the metric along with the default ones.
|
|
// If client and server spans have the same attribute and EnableClientServerPrefix is not enabled,
|
|
// behaviour is undetermined (either value could get used)
|
|
Dimensions []string `yaml:"dimensions"`
|
|
|
|
// If enabled, additional dimensions (labels) will be prefixed with either
|
|
// "client_" or "server_" depending on the span kind. Up to two labels will be added
|
|
// per dimension.
|
|
EnableClientServerPrefix bool `yaml:"enable_client_server_prefix"`
|
|
|
|
// If enabled another histogram will be produced for interactions over messaging systems middlewares
|
|
EnableMessagingSystemLatencyHistogram bool `yaml:"enable_messaging_system_latency_histogram"`
|
|
|
|
// PeerAttributes are attributes that will be used to create a peer edge
|
|
// Attributes are searched in the order they are provided
|
|
PeerAttributes []string `yaml:"peer_attributes"`
|
|
|
|
// If enabled attribute value will be used for metric calculation
|
|
SpanMultiplierKey string `yaml:"span_multiplier_key"`
|
|
|
|
// EnableVirtualNodeLabel enables additional labels for uninstrumented services
|
|
EnableVirtualNodeLabel bool `yaml:"enable_virtual_node_label"`
|
|
|
|
// DatabaseNameAttributes the list of attribute names used to identify the database name from span attributes.
|
|
DatabaseNameAttributes []string `yaml:"database_name_attributes"`
|
|
|
|
// FilterPolicies is a list of policies that will be applied to spans for inclusion or exclusion.
|
|
FilterPolicies []filterconfig.FilterPolicy `yaml:"filter_policies"`
|
|
}
|
|
|
|
func (cfg *Config) RegisterFlagsAndApplyDefaults(string, *flag.FlagSet) {
|
|
cfg.Wait = 10 * time.Second
|
|
cfg.MaxItems = 10_000
|
|
cfg.Workers = 10
|
|
// TODO: Revisit this default value.
|
|
cfg.HistogramBuckets = prometheus.ExponentialBuckets(0.1, 2, 8)
|
|
cfg.HistogramOverride = registry.HistogramModeClassic
|
|
|
|
peerAttr := make([]string, 0, len(defaultPeerAttributes))
|
|
for _, attr := range defaultPeerAttributes {
|
|
peerAttr = append(peerAttr, string(attr))
|
|
}
|
|
cfg.PeerAttributes = peerAttr
|
|
|
|
cfg.EnableMessagingSystemLatencyHistogram = false
|
|
|
|
cfg.DatabaseNameAttributes = []string{
|
|
string(semconvnew.DBNamespaceKey),
|
|
string(semconv.DBNameKey),
|
|
string(semconv.DBSystemKey),
|
|
}
|
|
}
|