Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

Commit d1368da

Browse files
committed
remove tilde from name values when indexing tags
1 parent 4fb720e commit d1368da

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

idx/memory/memory.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ func (m *UnpartitionedMemoryIdx) indexTags(def *schema.MetricDefinition) {
543543
tagValue := tagSplits[1]
544544
tags.addTagId(tagName, tagValue, def.Id)
545545
}
546-
tags.addTagId("name", def.Name, def.Id)
546+
tags.addTagId("name", def.NameSanitizedAsTagValue(), def.Id)
547547

548548
m.defByTagSet.add(def)
549549
}
@@ -569,7 +569,7 @@ func (m *UnpartitionedMemoryIdx) deindexTags(tags TagIndex, def *schema.MetricDe
569569
tags.delTagId(tagName, tagValue, def.Id)
570570
}
571571

572-
tags.delTagId("name", def.Name, def.Id)
572+
tags.delTagId("name", def.NameSanitizedAsTagValue(), def.Id)
573573

574574
m.defByTagSet.del(def)
575575

@@ -968,7 +968,7 @@ func (m *UnpartitionedMemoryIdx) FindTagValuesWithQuery(orgId uint32, tag, prefi
968968

969969
// special case if the tag to complete values for is "name"
970970
if tag == "name" {
971-
valueMap[def.Name] = struct{}{}
971+
valueMap[def.NameSanitizedAsTagValue()] = struct{}{}
972972
} else {
973973
for _, tag := range def.Tags {
974974
if !strings.HasPrefix(tag, tagPrefix) {

idx/memory/tag_query.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ func (q *TagQueryContext) testByMatch(def *idx.Archive, exprs []kvRe, not bool)
326326
EXPRS:
327327
for _, e := range exprs {
328328
if e.Key == "name" {
329-
if e.Regex == nil || e.Regex.MatchString(def.Name) {
329+
if e.Regex == nil || e.Regex.MatchString(def.NameSanitizedAsTagValue()) {
330330
if not {
331331
return false
332332
}
@@ -447,7 +447,7 @@ func (q *TagQueryContext) testByFrom(def *idx.Archive) bool {
447447
func (q *TagQueryContext) testByPrefix(def *idx.Archive, exprs []kv) bool {
448448
EXPRS:
449449
for _, e := range exprs {
450-
if e.Key == "name" && strings.HasPrefix(def.Name, e.Value) {
450+
if e.Key == "name" && strings.HasPrefix(def.NameSanitizedAsTagValue(), e.Value) {
451451
continue EXPRS
452452
}
453453

0 commit comments

Comments
 (0)