@@ -261,6 +261,14 @@ func TestEscapeName(t *testing.T) {
261261 expectedUnescapedDots : "mysystem.prod.west.cpu.load" ,
262262 expectedValue : "U__mysystem_2e_prod_2e_west_2e_cpu_2e_load" ,
263263 },
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+ },
264272 {
265273 name : "name with dots and colon" ,
266274 input : "http.status:sum" ,
@@ -269,16 +277,32 @@ func TestEscapeName(t *testing.T) {
269277 expectedUnescapedDots : "http.status:sum" ,
270278 expectedValue : "U__http_2e_status:sum" ,
271279 },
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+ },
272288 {
273289 name : "name with unicode characters > 0x100" ,
274290 input : "花火" ,
275291 expectedUnderscores : "__" ,
276- expectedDots : "__ " ,
292+ expectedDots : "____ " ,
277293 // Dots-replacement does not know the difference between two replaced
278294 // characters and a single underscore.
279- expectedUnescapedDots : "_ " ,
295+ expectedUnescapedDots : "__ " ,
280296 expectedValue : "U___82b1__706b_" ,
281297 },
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+ },
282306 }
283307
284308 for _ , scenario := range scenarios {
@@ -564,7 +588,7 @@ func TestEscapeMetricFamily(t *testing.T) {
564588 },
565589 },
566590 expected : & dto.MetricFamily {
567- Name : proto .String ("unicode_dot_and_dot_dots_dot___ " ),
591+ Name : proto .String ("unicode_dot_and_dot_dots_dot_____ " ),
568592 Help : proto .String ("some help text" ),
569593 Type : dto .MetricType_GAUGE .Enum (),
570594 Metric : []* dto.Metric {
@@ -575,7 +599,7 @@ func TestEscapeMetricFamily(t *testing.T) {
575599 Label : []* dto.LabelPair {
576600 {
577601 Name : proto .String ("__name__" ),
578- Value : proto .String ("unicode_dot_and_dot_dots_dot___ " ),
602+ Value : proto .String ("unicode_dot_and_dot_dots_dot_____ " ),
579603 },
580604 {
581605 Name : proto .String ("some_label" ),
0 commit comments