MCPcopy Create free account
hub / github.com/prometheus/common / TestDottedEncode

Function TestDottedEncode

expfmt/encode_test.go:574–662  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

572}
573
574func TestDottedEncode(t *testing.T) {
575 //nolint:staticcheck
576 model.NameValidationScheme = model.UTF8Validation
577 metric := &dto.MetricFamily{
578 Name: proto.String("foo.metric"),
579 Type: dto.MetricType_COUNTER.Enum(),
580 Metric: []*dto.Metric{
581 {
582 Counter: &dto.Counter{
583 Value: proto.Float64(1.234),
584 },
585 },
586 {
587 Label: []*dto.LabelPair{
588 {
589 Name: proto.String("dotted.label.name"),
590 Value: proto.String("my.label.value"),
591 },
592 },
593 Counter: &dto.Counter{
594 Value: proto.Float64(8),
595 },
596 },
597 },
598 }
599
600 scenarios := []struct {
601 format Format
602 expectMetricName string
603 expectLabelName string
604 }{
605 {
606 format: FmtProtoDelim,
607 expectMetricName: "foo_metric",
608 expectLabelName: "dotted_label_name",
609 },
610 {
611 format: FmtProtoDelim.WithEscapingScheme(model.NoEscaping),
612 expectMetricName: "foo.metric",
613 expectLabelName: "dotted.label.name",
614 },
615 {
616 format: FmtProtoDelim.WithEscapingScheme(model.DotsEscaping),
617 expectMetricName: "foo_dot_metric",
618 expectLabelName: "dotted_dot_label_dot_name",
619 },
620 {
621 format: FmtText,
622 expectMetricName: "foo_metric",
623 expectLabelName: "dotted_label_name",
624 },
625 {
626 format: FmtText.WithEscapingScheme(model.NoEscaping),
627 expectMetricName: "foo.metric",
628 expectLabelName: "dotted.label.name",
629 },
630 {
631 format: FmtText.WithEscapingScheme(model.DotsEscaping),

Callers

nothing calls this directly

Calls 7

EncodeMethod · 0.95
DecodeMethod · 0.95
NewEncoderFunction · 0.85
NewDecoderFunction · 0.85
WithEscapingSchemeMethod · 0.80
ErrorMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected