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

Function TestDottedEncode

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

Source from the content-addressed store, hash-verified

370}
371
372func TestDottedEncode(t *testing.T) {
373 //nolint:staticcheck
374 model.NameValidationScheme = model.UTF8Validation
375 metric := &dto.MetricFamily{
376 Name: proto.String("foo.metric"),
377 Type: dto.MetricType_COUNTER.Enum(),
378 Metric: []*dto.Metric{
379 {
380 Counter: &dto.Counter{
381 Value: proto.Float64(1.234),
382 },
383 },
384 {
385 Label: []*dto.LabelPair{
386 {
387 Name: proto.String("dotted.label.name"),
388 Value: proto.String("my.label.value"),
389 },
390 },
391 Counter: &dto.Counter{
392 Value: proto.Float64(8),
393 },
394 },
395 },
396 }
397
398 scenarios := []struct {
399 format Format
400 expectMetricName string
401 expectLabelName string
402 }{
403 {
404 format: FmtProtoDelim,
405 expectMetricName: "foo_metric",
406 expectLabelName: "dotted_label_name",
407 },
408 {
409 format: FmtProtoDelim.WithEscapingScheme(model.NoEscaping),
410 expectMetricName: "foo.metric",
411 expectLabelName: "dotted.label.name",
412 },
413 {
414 format: FmtProtoDelim.WithEscapingScheme(model.DotsEscaping),
415 expectMetricName: "foo_dot_metric",
416 expectLabelName: "dotted_dot_label_dot_name",
417 },
418 {
419 format: FmtText,
420 expectMetricName: "foo_metric",
421 expectLabelName: "dotted_label_name",
422 },
423 {
424 format: FmtText.WithEscapingScheme(model.NoEscaping),
425 expectMetricName: "foo.metric",
426 expectLabelName: "dotted.label.name",
427 },
428 {
429 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…