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

Function BenchmarkCreateBuildInfo

expfmt/text_create_test.go:690–724  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

688}
689
690func BenchmarkCreateBuildInfo(b *testing.B) {
691 mf := &dto.MetricFamily{
692 Name: proto.String("benchmark_build_info"),
693 Help: proto.String("Test the creation of constant 1-value build_info metric."),
694 Type: dto.MetricType_GAUGE.Enum(),
695 Metric: []*dto.Metric{
696 {
697 Label: []*dto.LabelPair{
698 {
699 Name: proto.String("version"),
700 Value: proto.String("1.2.3"),
701 },
702 {
703 Name: proto.String("revision"),
704 Value: proto.String("2e84f5e4eacdffb574035810305191ff390360fe"),
705 },
706 {
707 Name: proto.String("go_version"),
708 Value: proto.String("1.11.1"),
709 },
710 },
711 Gauge: &dto.Gauge{
712 Value: proto.Float64(1),
713 },
714 },
715 },
716 }
717 out := bytes.NewBuffer(make([]byte, 0, 1024))
718
719 for i := 0; i < b.N; i++ {
720 _, err := MetricFamilyToText(out, mf)
721 require.NoError(b, err)
722 out.Reset()
723 }
724}
725
726func TestCreateError(t *testing.T) {
727 scenarios := []struct {

Callers

nothing calls this directly

Calls 2

MetricFamilyToTextFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…