@@ -909,6 +909,12 @@ func (d *Distributor) ForReplicationSet(ctx context.Context, replicationSet ring
909
909
}
910
910
911
911
func (d * Distributor ) LabelValuesForLabelNameCommon (ctx context.Context , from , to model.Time , labelName model.LabelName , f func (ctx context.Context , rs ring.ReplicationSet , req * ingester_client.LabelValuesRequest ) ([]interface {}, error ), matchers ... * labels.Matcher ) ([]string , error ) {
912
+ span , ctx := opentracing .StartSpanFromContext (ctx , "Distributor.LabelValues" , opentracing.Tags {
913
+ "name" : labelName ,
914
+ "start" : from .Unix (),
915
+ "end" : to .Unix (),
916
+ })
917
+ defer span .Finish ()
912
918
replicationSet , err := d .GetIngestersForMetadata (ctx )
913
919
if err != nil {
914
920
return nil , err
@@ -924,6 +930,8 @@ func (d *Distributor) LabelValuesForLabelNameCommon(ctx context.Context, from, t
924
930
return nil , err
925
931
}
926
932
933
+ span , _ = opentracing .StartSpanFromContext (ctx , "response_merge" )
934
+ defer span .Finish ()
927
935
valueSet := map [string ]struct {}{}
928
936
for _ , resp := range resps {
929
937
for _ , v := range resp .([]string ) {
@@ -938,11 +946,12 @@ func (d *Distributor) LabelValuesForLabelNameCommon(ctx context.Context, from, t
938
946
939
947
// We need the values returned to be sorted.
940
948
sort .Strings (values )
949
+ span .SetTag ("result_length" , len (values ))
941
950
942
951
return values , nil
943
952
}
944
953
945
- // LabelValuesForLabelName returns all of the label values that are associated with a given label name.
954
+ // LabelValuesForLabelName returns all the label values that are associated with a given label name.
946
955
func (d * Distributor ) LabelValuesForLabelName (ctx context.Context , from , to model.Time , labelName model.LabelName , matchers ... * labels.Matcher ) ([]string , error ) {
947
956
return d .LabelValuesForLabelNameCommon (ctx , from , to , labelName , func (ctx context.Context , rs ring.ReplicationSet , req * ingester_client.LabelValuesRequest ) ([]interface {}, error ) {
948
957
return d .ForReplicationSet (ctx , rs , func (ctx context.Context , client ingester_client.IngesterClient ) (interface {}, error ) {
@@ -955,7 +964,7 @@ func (d *Distributor) LabelValuesForLabelName(ctx context.Context, from, to mode
955
964
}, matchers ... )
956
965
}
957
966
958
- // LabelValuesForLabelName returns all of the label values that are associated with a given label name.
967
+ // LabelValuesForLabelNameStream returns all the label values that are associated with a given label name.
959
968
func (d * Distributor ) LabelValuesForLabelNameStream (ctx context.Context , from , to model.Time , labelName model.LabelName , matchers ... * labels.Matcher ) ([]string , error ) {
960
969
return d .LabelValuesForLabelNameCommon (ctx , from , to , labelName , func (ctx context.Context , rs ring.ReplicationSet , req * ingester_client.LabelValuesRequest ) ([]interface {}, error ) {
961
970
return d .ForReplicationSet (ctx , rs , func (ctx context.Context , client ingester_client.IngesterClient ) (interface {}, error ) {
@@ -982,6 +991,11 @@ func (d *Distributor) LabelValuesForLabelNameStream(ctx context.Context, from, t
982
991
}
983
992
984
993
func (d * Distributor ) LabelNamesCommon (ctx context.Context , from , to model.Time , f func (ctx context.Context , rs ring.ReplicationSet , req * ingester_client.LabelNamesRequest ) ([]interface {}, error )) ([]string , error ) {
994
+ span , ctx := opentracing .StartSpanFromContext (ctx , "Distributor.LabelNames" , opentracing.Tags {
995
+ "start" : from .Unix (),
996
+ "end" : to .Unix (),
997
+ })
998
+ defer span .Finish ()
985
999
replicationSet , err := d .GetIngestersForMetadata (ctx )
986
1000
if err != nil {
987
1001
return nil , err
@@ -996,6 +1010,8 @@ func (d *Distributor) LabelNamesCommon(ctx context.Context, from, to model.Time,
996
1010
return nil , err
997
1011
}
998
1012
1013
+ span , _ = opentracing .StartSpanFromContext (ctx , "response_merge" )
1014
+ defer span .Finish ()
999
1015
valueSet := map [string ]struct {}{}
1000
1016
for _ , resp := range resps {
1001
1017
for _ , v := range resp .([]string ) {
@@ -1009,6 +1025,7 @@ func (d *Distributor) LabelNamesCommon(ctx context.Context, from, to model.Time,
1009
1025
}
1010
1026
1011
1027
sort .Strings (values )
1028
+ span .SetTag ("result_length" , len (values ))
1012
1029
1013
1030
return values , nil
1014
1031
}
@@ -1038,7 +1055,7 @@ func (d *Distributor) LabelNamesStream(ctx context.Context, from, to model.Time)
1038
1055
})
1039
1056
}
1040
1057
1041
- // LabelNames returns all of the label names.
1058
+ // LabelNames returns all the label names.
1042
1059
func (d * Distributor ) LabelNames (ctx context.Context , from , to model.Time ) ([]string , error ) {
1043
1060
return d .LabelNamesCommon (ctx , from , to , func (ctx context.Context , rs ring.ReplicationSet , req * ingester_client.LabelNamesRequest ) ([]interface {}, error ) {
1044
1061
return d .ForReplicationSet (ctx , rs , func (ctx context.Context , client ingester_client.IngesterClient ) (interface {}, error ) {
0 commit comments