-
Notifications
You must be signed in to change notification settings - Fork 806
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: SungJin1212 <[email protected]>
- Loading branch information
1 parent
2b5ac96
commit e739b3d
Showing
29 changed files
with
3,014 additions
and
5,702 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package cortexpb | ||
|
||
import ( | ||
"github.com/prometheus/prometheus/model/labels" | ||
) | ||
|
||
// ToLabels return model labels.Labels from timeseries' remote labels. | ||
func (t TimeSeriesV2) ToLabels(b *labels.ScratchBuilder, symbols []string) labels.Labels { | ||
return desymbolizeLabels(b, t.GetLabelsRefs(), symbols) | ||
} | ||
|
||
// ToLabels return model labels.Labels from exemplar remote labels. | ||
func (e ExemplarV2) ToLabels(b *labels.ScratchBuilder, symbols []string) labels.Labels { | ||
return desymbolizeLabels(b, e.GetLabelsRefs(), symbols) | ||
} | ||
|
||
func (m MetadataV2) ToV1Metadata(name string, symbols []string) *MetricMetadata { | ||
return &MetricMetadata{ | ||
Type: m.Type, | ||
MetricFamilyName: name, | ||
Unit: symbols[m.UnitRef], | ||
Help: symbols[m.HelpRef], | ||
} | ||
} | ||
|
||
// desymbolizeLabels decodes label references, with given symbols to labels. | ||
func desymbolizeLabels(b *labels.ScratchBuilder, labelRefs []uint32, symbols []string) labels.Labels { | ||
b.Reset() | ||
for i := 0; i < len(labelRefs); i += 2 { | ||
b.Add(symbols[labelRefs[i]], symbols[labelRefs[i+1]]) | ||
} | ||
b.Sort() | ||
return b.Labels() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 5 additions & 7 deletions
12
pkg/cortexpbv2/compatv2_test.go → pkg/cortexpb/compatv2_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.