@@ -261,6 +261,14 @@ func TestEscapeName(t *testing.T) {
261
261
expectedUnescapedDots : "mysystem.prod.west.cpu.load" ,
262
262
expectedValue : "U__mysystem_2e_prod_2e_west_2e_cpu_2e_load" ,
263
263
},
264
+ {
265
+ name : "name with dots and underscore" ,
266
+ input : "mysystem.prod.west.cpu.load_total" ,
267
+ expectedUnderscores : "mysystem_prod_west_cpu_load_total" ,
268
+ expectedDots : "mysystem_dot_prod_dot_west_dot_cpu_dot_load__total" ,
269
+ expectedUnescapedDots : "mysystem.prod.west.cpu.load_total" ,
270
+ expectedValue : "U__mysystem_2e_prod_2e_west_2e_cpu_2e_load__total" ,
271
+ },
264
272
{
265
273
name : "name with dots and colon" ,
266
274
input : "http.status:sum" ,
@@ -269,16 +277,32 @@ func TestEscapeName(t *testing.T) {
269
277
expectedUnescapedDots : "http.status:sum" ,
270
278
expectedValue : "U__http_2e_status:sum" ,
271
279
},
280
+ {
281
+ name : "name with spaces and emoji" ,
282
+ input : "label with 😱" ,
283
+ expectedUnderscores : "label_with__" ,
284
+ expectedDots : "label__with____" ,
285
+ expectedUnescapedDots : "label_with__" ,
286
+ expectedValue : "U__label_20_with_20__1f631_" ,
287
+ },
272
288
{
273
289
name : "name with unicode characters > 0x100" ,
274
290
input : "花火" ,
275
291
expectedUnderscores : "__" ,
276
- expectedDots : "__ " ,
292
+ expectedDots : "____ " ,
277
293
// Dots-replacement does not know the difference between two replaced
278
294
// characters and a single underscore.
279
- expectedUnescapedDots : "_ " ,
295
+ expectedUnescapedDots : "__ " ,
280
296
expectedValue : "U___82b1__706b_" ,
281
297
},
298
+ {
299
+ name : "name with spaces and edge-case value" ,
300
+ input : "label with \u0100 " ,
301
+ expectedUnderscores : "label_with__" ,
302
+ expectedDots : "label__with____" ,
303
+ expectedUnescapedDots : "label_with__" ,
304
+ expectedValue : "U__label_20_with_20__100_" ,
305
+ },
282
306
}
283
307
284
308
for _ , scenario := range scenarios {
@@ -564,7 +588,7 @@ func TestEscapeMetricFamily(t *testing.T) {
564
588
},
565
589
},
566
590
expected : & dto.MetricFamily {
567
- Name : proto .String ("unicode_dot_and_dot_dots_dot___ " ),
591
+ Name : proto .String ("unicode_dot_and_dot_dots_dot_____ " ),
568
592
Help : proto .String ("some help text" ),
569
593
Type : dto .MetricType_GAUGE .Enum (),
570
594
Metric : []* dto.Metric {
@@ -575,7 +599,7 @@ func TestEscapeMetricFamily(t *testing.T) {
575
599
Label : []* dto.LabelPair {
576
600
{
577
601
Name : proto .String ("__name__" ),
578
- Value : proto .String ("unicode_dot_and_dot_dots_dot___ " ),
602
+ Value : proto .String ("unicode_dot_and_dot_dots_dot_____ " ),
579
603
},
580
604
{
581
605
Name : proto .String ("some_label" ),
0 commit comments