File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,28 @@ func ExampleNewCounterVecT_promauto_global_migrated() {
118
118
// Output:
119
119
}
120
120
121
+ func ExampleNewCounterVecT_pointer_to_labels_promauto () {
122
+ // It's possible to use pointer to labels struct
123
+ myReg := prometheus .NewRegistry ()
124
+
125
+ counterOpts := prometheus.CounterOpts {
126
+ Name : "items_counted_detailed_ptr" ,
127
+ }
128
+
129
+ type MyLabels struct {
130
+ promsafe.StructLabelProvider
131
+ EventType string
132
+ Source string
133
+ }
134
+ c := promsafe.WithAuto [* MyLabels ](myReg ).NewCounterVecT (counterOpts )
135
+
136
+ c .With (& MyLabels {
137
+ EventType : "reservation" , Source : "source1" ,
138
+ }).Inc ()
139
+
140
+ // Output:
141
+ }
142
+
121
143
func ExampleNewCounterVecT_single_label_manual () {
122
144
// Manually registering with a single label
123
145
// Example of usage of shorthand: no structs no generics, but one string only
You can’t perform that action at this time.
0 commit comments