(ctx context.Context, metadata []prompb.MetricMetadata, pBuf *proto.Buffer)
| 589 | } |
| 590 | |
| 591 | func (t *QueueManager) sendMetadataWithBackoff(ctx context.Context, metadata []prompb.MetricMetadata, pBuf *proto.Buffer) error { |
| 592 | // Build the WriteRequest with no samples (v1 flow). |
| 593 | req, _, _, err := buildWriteRequest(t.logger, nil, metadata, pBuf, nil, nil, t.compr) |
| 594 | if err != nil { |
| 595 | return err |
| 596 | } |
| 597 | |
| 598 | metadataCount := len(metadata) |
| 599 | |
| 600 | attemptStore := func(try int) error { |
| 601 | ctx, span := otel.Tracer("").Start(ctx, "Remote Metadata Send Batch") |
| 602 | defer span.End() |
| 603 | |
| 604 | span.SetAttributes( |
| 605 | attribute.Int("metadata", metadataCount), |
| 606 | attribute.Int("try", try), |
| 607 | attribute.String("remote_name", t.storeClient.Name()), |
| 608 | attribute.String("remote_url", t.storeClient.Endpoint()), |
| 609 | ) |
| 610 | // Attributes defined by OpenTelemetry semantic conventions. |
| 611 | if try > 0 { |
| 612 | span.SetAttributes(semconv.HTTPResendCount(try)) |
| 613 | } |
| 614 | |
| 615 | begin := time.Now() |
| 616 | // Ignoring WriteResponseStats, because there is nothing for metadata, since it's |
| 617 | // embedded in v2 calls now, and we do v1 here. |
| 618 | _, err := t.storeClient.Store(ctx, req, try) |
| 619 | t.metrics.sentBatchDuration.Observe(time.Since(begin).Seconds()) |
| 620 | |
| 621 | if err != nil { |
| 622 | span.RecordError(err) |
| 623 | return err |
| 624 | } |
| 625 | return nil |
| 626 | } |
| 627 | |
| 628 | retry := func() { |
| 629 | t.metrics.retriedMetadataTotal.Add(float64(len(metadata))) |
| 630 | } |
| 631 | err = t.sendWriteRequestWithBackoff(ctx, attemptStore, retry) |
| 632 | if err != nil { |
| 633 | return err |
| 634 | } |
| 635 | t.metrics.metadataTotal.Add(float64(len(metadata))) |
| 636 | t.metrics.metadataBytesTotal.Add(float64(len(req))) |
| 637 | return nil |
| 638 | } |
| 639 | |
| 640 | func isSampleOld(baseTime time.Time, sampleAgeLimit time.Duration, ts int64) bool { |
| 641 | if sampleAgeLimit == 0 { |
no test coverage detected