(t *testing.T)
| 370 | } |
| 371 | |
| 372 | func 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), |
nothing calls this directly
no test coverage detected
searching dependent graphs…