@@ -23,8 +23,6 @@ import (
23
23
"strings"
24
24
"time"
25
25
26
- //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
27
- "github.com/golang/protobuf/proto"
28
26
dto "github.com/prometheus/client_model/go"
29
27
"github.com/prometheus/common/expfmt"
30
28
@@ -321,25 +319,10 @@ func ExampleSummary() {
321
319
// internally).
322
320
metric := & dto.Metric {}
323
321
temps .Write (metric )
324
- fmt .Println (proto . MarshalTextString ( metric ))
322
+ fmt .Println (metric . String ( ))
325
323
326
324
// Output:
327
- // summary: <
328
- // sample_count: 1000
329
- // sample_sum: 29969.50000000001
330
- // quantile: <
331
- // quantile: 0.5
332
- // value: 31.1
333
- // >
334
- // quantile: <
335
- // quantile: 0.9
336
- // value: 41.3
337
- // >
338
- // quantile: <
339
- // quantile: 0.99
340
- // value: 41.9
341
- // >
342
- // >
325
+ // summary:<sample_count:1000 sample_sum:29969.50000000001 quantile:<quantile:0.5 value:31.1 > quantile:<quantile:0.9 value:41.3 > quantile:<quantile:0.99 value:41.9 > >
343
326
}
344
327
345
328
func ExampleSummaryVec () {
@@ -371,78 +354,10 @@ func ExampleSummaryVec() {
371
354
if err != nil || len (metricFamilies ) != 1 {
372
355
panic ("unexpected behavior of custom test registry" )
373
356
}
374
- fmt .Println (proto . MarshalTextString ( metricFamilies [0 ]))
357
+ fmt .Println (metricFamilies [0 ]. String ( ))
375
358
376
359
// Output:
377
- // name: "pond_temperature_celsius"
378
- // help: "The temperature of the frog pond."
379
- // type: SUMMARY
380
- // metric: <
381
- // label: <
382
- // name: "species"
383
- // value: "leiopelma-hochstetteri"
384
- // >
385
- // summary: <
386
- // sample_count: 0
387
- // sample_sum: 0
388
- // quantile: <
389
- // quantile: 0.5
390
- // value: nan
391
- // >
392
- // quantile: <
393
- // quantile: 0.9
394
- // value: nan
395
- // >
396
- // quantile: <
397
- // quantile: 0.99
398
- // value: nan
399
- // >
400
- // >
401
- // >
402
- // metric: <
403
- // label: <
404
- // name: "species"
405
- // value: "lithobates-catesbeianus"
406
- // >
407
- // summary: <
408
- // sample_count: 1000
409
- // sample_sum: 31956.100000000017
410
- // quantile: <
411
- // quantile: 0.5
412
- // value: 32.4
413
- // >
414
- // quantile: <
415
- // quantile: 0.9
416
- // value: 41.4
417
- // >
418
- // quantile: <
419
- // quantile: 0.99
420
- // value: 41.9
421
- // >
422
- // >
423
- // >
424
- // metric: <
425
- // label: <
426
- // name: "species"
427
- // value: "litoria-caerulea"
428
- // >
429
- // summary: <
430
- // sample_count: 1000
431
- // sample_sum: 29969.50000000001
432
- // quantile: <
433
- // quantile: 0.5
434
- // value: 31.1
435
- // >
436
- // quantile: <
437
- // quantile: 0.9
438
- // value: 41.3
439
- // >
440
- // quantile: <
441
- // quantile: 0.99
442
- // value: 41.9
443
- // >
444
- // >
445
- // >
360
+ // name:"pond_temperature_celsius" help:"The temperature of the frog pond." type:SUMMARY metric:<label:<name:"species" value:"leiopelma-hochstetteri" > summary:<sample_count:0 sample_sum:0 quantile:<quantile:0.5 value:nan > quantile:<quantile:0.9 value:nan > quantile:<quantile:0.99 value:nan > > > metric:<label:<name:"species" value:"lithobates-catesbeianus" > summary:<sample_count:1000 sample_sum:31956.100000000017 quantile:<quantile:0.5 value:32.4 > quantile:<quantile:0.9 value:41.4 > quantile:<quantile:0.99 value:41.9 > > > metric:<label:<name:"species" value:"litoria-caerulea" > summary:<sample_count:1000 sample_sum:29969.50000000001 quantile:<quantile:0.5 value:31.1 > quantile:<quantile:0.9 value:41.3 > quantile:<quantile:0.99 value:41.9 > > >
446
361
}
447
362
448
363
func ExampleNewConstSummary () {
@@ -466,33 +381,10 @@ func ExampleNewConstSummary() {
466
381
// internally).
467
382
metric := & dto.Metric {}
468
383
s .Write (metric )
469
- fmt .Println (proto . MarshalTextString ( metric ))
384
+ fmt .Println (metric . String ( ))
470
385
471
386
// Output:
472
- // label: <
473
- // name: "code"
474
- // value: "200"
475
- // >
476
- // label: <
477
- // name: "method"
478
- // value: "get"
479
- // >
480
- // label: <
481
- // name: "owner"
482
- // value: "example"
483
- // >
484
- // summary: <
485
- // sample_count: 4711
486
- // sample_sum: 403.34
487
- // quantile: <
488
- // quantile: 0.5
489
- // value: 42.3
490
- // >
491
- // quantile: <
492
- // quantile: 0.9
493
- // value: 323.3
494
- // >
495
- // >
387
+ // label:<name:"code" value:"200" > label:<name:"method" value:"get" > label:<name:"owner" value:"example" > summary:<sample_count:4711 sample_sum:403.34 quantile:<quantile:0.5 value:42.3 > quantile:<quantile:0.9 value:323.3 > >
496
388
}
497
389
498
390
func ExampleHistogram () {
@@ -512,33 +404,10 @@ func ExampleHistogram() {
512
404
// internally).
513
405
metric := & dto.Metric {}
514
406
temps .Write (metric )
515
- fmt .Println (proto . MarshalTextString ( metric ))
407
+ fmt .Println (metric . String ( ))
516
408
517
409
// Output:
518
- // histogram: <
519
- // sample_count: 1000
520
- // sample_sum: 29969.50000000001
521
- // bucket: <
522
- // cumulative_count: 192
523
- // upper_bound: 20
524
- // >
525
- // bucket: <
526
- // cumulative_count: 366
527
- // upper_bound: 25
528
- // >
529
- // bucket: <
530
- // cumulative_count: 501
531
- // upper_bound: 30
532
- // >
533
- // bucket: <
534
- // cumulative_count: 638
535
- // upper_bound: 35
536
- // >
537
- // bucket: <
538
- // cumulative_count: 816
539
- // upper_bound: 40
540
- // >
541
- // >
410
+ // histogram:<sample_count:1000 sample_sum:29969.50000000001 bucket:<cumulative_count:192 upper_bound:20 > bucket:<cumulative_count:366 upper_bound:25 > bucket:<cumulative_count:501 upper_bound:30 > bucket:<cumulative_count:638 upper_bound:35 > bucket:<cumulative_count:816 upper_bound:40 > >
542
411
}
543
412
544
413
func ExampleNewConstHistogram () {
@@ -562,41 +431,10 @@ func ExampleNewConstHistogram() {
562
431
// internally).
563
432
metric := & dto.Metric {}
564
433
h .Write (metric )
565
- fmt .Println (proto . MarshalTextString ( metric ))
434
+ fmt .Println (metric . String ( ))
566
435
567
436
// Output:
568
- // label: <
569
- // name: "code"
570
- // value: "200"
571
- // >
572
- // label: <
573
- // name: "method"
574
- // value: "get"
575
- // >
576
- // label: <
577
- // name: "owner"
578
- // value: "example"
579
- // >
580
- // histogram: <
581
- // sample_count: 4711
582
- // sample_sum: 403.34
583
- // bucket: <
584
- // cumulative_count: 121
585
- // upper_bound: 25
586
- // >
587
- // bucket: <
588
- // cumulative_count: 2403
589
- // upper_bound: 50
590
- // >
591
- // bucket: <
592
- // cumulative_count: 3221
593
- // upper_bound: 100
594
- // >
595
- // bucket: <
596
- // cumulative_count: 4233
597
- // upper_bound: 200
598
- // >
599
- // >
437
+ // label:<name:"code" value:"200" > label:<name:"method" value:"get" > label:<name:"owner" value:"example" > histogram:<sample_count:4711 sample_sum:403.34 bucket:<cumulative_count:121 upper_bound:25 > bucket:<cumulative_count:2403 upper_bound:50 > bucket:<cumulative_count:3221 upper_bound:100 > bucket:<cumulative_count:4233 upper_bound:200 > >
600
438
}
601
439
602
440
func ExampleNewConstHistogram_WithExemplar () {
@@ -631,81 +469,10 @@ func ExampleNewConstHistogram_WithExemplar() {
631
469
// internally).
632
470
metric := & dto.Metric {}
633
471
h .Write (metric )
634
- fmt .Println (proto . MarshalTextString ( metric ))
472
+ fmt .Println (metric . String ( ))
635
473
636
474
// Output:
637
- // label: <
638
- // name: "code"
639
- // value: "200"
640
- // >
641
- // label: <
642
- // name: "method"
643
- // value: "get"
644
- // >
645
- // label: <
646
- // name: "owner"
647
- // value: "example"
648
- // >
649
- // histogram: <
650
- // sample_count: 4711
651
- // sample_sum: 403.34
652
- // bucket: <
653
- // cumulative_count: 121
654
- // upper_bound: 25
655
- // exemplar: <
656
- // label: <
657
- // name: "testName"
658
- // value: "testVal"
659
- // >
660
- // value: 24
661
- // timestamp: <
662
- // seconds: 1136214245
663
- // >
664
- // >
665
- // >
666
- // bucket: <
667
- // cumulative_count: 2403
668
- // upper_bound: 50
669
- // exemplar: <
670
- // label: <
671
- // name: "testName"
672
- // value: "testVal"
673
- // >
674
- // value: 42
675
- // timestamp: <
676
- // seconds: 1136214245
677
- // >
678
- // >
679
- // >
680
- // bucket: <
681
- // cumulative_count: 3221
682
- // upper_bound: 100
683
- // exemplar: <
684
- // label: <
685
- // name: "testName"
686
- // value: "testVal"
687
- // >
688
- // value: 89
689
- // timestamp: <
690
- // seconds: 1136214245
691
- // >
692
- // >
693
- // >
694
- // bucket: <
695
- // cumulative_count: 4233
696
- // upper_bound: 200
697
- // exemplar: <
698
- // label: <
699
- // name: "testName"
700
- // value: "testVal"
701
- // >
702
- // value: 157
703
- // timestamp: <
704
- // seconds: 1136214245
705
- // >
706
- // >
707
- // >
708
- // >
475
+ // label:<name:"code" value:"200" > label:<name:"method" value:"get" > label:<name:"owner" value:"example" > histogram:<sample_count:4711 sample_sum:403.34 bucket:<cumulative_count:121 upper_bound:25 exemplar:<label:<name:"testName" value:"testVal" > value:24 timestamp:<seconds:1136214245 > > > bucket:<cumulative_count:2403 upper_bound:50 exemplar:<label:<name:"testName" value:"testVal" > value:42 timestamp:<seconds:1136214245 > > > bucket:<cumulative_count:3221 upper_bound:100 exemplar:<label:<name:"testName" value:"testVal" > value:89 timestamp:<seconds:1136214245 > > > bucket:<cumulative_count:4233 upper_bound:200 exemplar:<label:<name:"testName" value:"testVal" > value:157 timestamp:<seconds:1136214245 > > > >
709
476
}
710
477
711
478
func ExampleAlreadyRegisteredError () {
@@ -858,11 +625,8 @@ func ExampleNewMetricWithTimestamp() {
858
625
// internally).
859
626
metric := & dto.Metric {}
860
627
s .Write (metric )
861
- fmt .Println (proto . MarshalTextString ( metric ))
628
+ fmt .Println (metric . String ( ))
862
629
863
630
// Output:
864
- // gauge: <
865
- // value: 298.15
866
- // >
867
- // timestamp_ms: 1257894000012
631
+ // gauge:<value:298.15 > timestamp_ms:1257894000012
868
632
}
0 commit comments