github.com/grafana/pyroscope@v1.18.0/pkg/segmentwriter/client/distributor/distribution_key.go (about) 1 package distributor 2 3 import ( 4 "github.com/cespare/xxhash/v2" 5 6 typesv1 "github.com/grafana/pyroscope/api/gen/proto/go/types/v1" 7 phlaremodel "github.com/grafana/pyroscope/pkg/model" 8 "github.com/grafana/pyroscope/pkg/segmentwriter/client/distributor/placement" 9 ) 10 11 // NewTenantServiceDatasetKey builds a distribution key, where the dataset 12 // is the service name, and the fingerprint is the hash of the labels. 13 // The resulting key references the tenant and dataset strings. 14 func NewTenantServiceDatasetKey(tenant string, labels ...*typesv1.LabelPair) placement.Key { 15 dataset := phlaremodel.Labels(labels).Get(phlaremodel.LabelNameServiceName) 16 return placement.Key{ 17 TenantID: tenant, 18 DatasetName: dataset, 19 20 Tenant: xxhash.Sum64String(tenant), 21 Dataset: xxhash.Sum64String(dataset), 22 Fingerprint: phlaremodel.Labels(labels).Hash(), 23 } 24 }