(t testing.TB, vec *MetricVec, typ dto.MetricType, ctsPerLabelValue map[string]time.Time)
| 355 | } |
| 356 | |
| 357 | func expectCTsForMetricVecValues(t testing.TB, vec *MetricVec, typ dto.MetricType, ctsPerLabelValue map[string]time.Time) { |
| 358 | t.Helper() |
| 359 | |
| 360 | for val, ct := range ctsPerLabelValue { |
| 361 | var metric dto.Metric |
| 362 | m, err := vec.GetMetricWithLabelValues(val) |
| 363 | if err != nil { |
| 364 | t.Fatal(err) |
| 365 | } |
| 366 | |
| 367 | if err := m.Write(&metric); err != nil { |
| 368 | t.Fatal(err) |
| 369 | } |
| 370 | |
| 371 | var gotTs time.Time |
| 372 | switch typ { |
| 373 | case dto.MetricType_COUNTER: |
| 374 | gotTs = metric.Counter.CreatedTimestamp.AsTime() |
| 375 | case dto.MetricType_HISTOGRAM: |
| 376 | gotTs = metric.Histogram.CreatedTimestamp.AsTime() |
| 377 | case dto.MetricType_SUMMARY: |
| 378 | gotTs = metric.Summary.CreatedTimestamp.AsTime() |
| 379 | default: |
| 380 | t.Fatalf("unknown metric type %v", typ) |
| 381 | } |
| 382 | |
| 383 | if !gotTs.Equal(ct) { |
| 384 | t.Errorf("expected created timestamp for %s with label value %q: %s, got %s", typ, val, ct, gotTs) |
| 385 | } |
| 386 | } |
| 387 | } |
no test coverage detected