[RW] Use remoteapi.Write function to sendSamplesWithBackoff#17373
[RW] Use remoteapi.Write function to sendSamplesWithBackoff#17373pipiland2612 wants to merge 11 commits intoprometheus:mainfrom
Conversation
Signed-off-by: pipiland2612 <[email protected]>
Signed-off-by: pipiland2612 <[email protected]>
Signed-off-by: pipiland2612 <[email protected]>
Signed-off-by: pipiland2612 <[email protected]>
Signed-off-by: pipiland2612 <[email protected]>
Signed-off-by: pipiland2612 <[email protected]>
Signed-off-by: pipiland2612 <[email protected]>
Signed-off-by: pipiland2612 <[email protected]>
Signed-off-by: pipiland2612 <[email protected]>
|
This is just an overall idea of what would look liek if we want to use Write function for sendsSampleWithBackOff. The test I will fix later if the overall method is good. |
Signed-off-by: pipiland2612 <[email protected]>
Signed-off-by: pipiland2612 <[email protected]>
| @@ -459,37 +489,42 @@ func TestSampleDeliveryOrder(t *testing.T) { | |||
|
|
|||
| func TestShutdown(t *testing.T) { | |||
There was a problem hiding this comment.
This changed version of the test is flaky
| externalLabels: extLabelsSlice, | ||
| relabelConfigs: relabelConfigs, | ||
| storeClient: client, | ||
| remoteAPI: nil, // Will be set below after QueueManager is created |
There was a problem hiding this comment.
| remoteAPI: nil, // Will be set below after QueueManager is created |
| backoffCfg := remoteapi.BackoffConfig{ | ||
| Min: time.Duration(t.cfg.MinBackoff), | ||
| Max: time.Duration(t.cfg.MaxBackoff), | ||
| MaxRetries: 0, |
There was a problem hiding this comment.
this is noop
| MaxRetries: 0, |
| var err error | ||
| t.remoteAPI, err = remoteapi.NewAPI(client.Endpoint(), apiOpts...) | ||
| if err != nil { | ||
| logger.Error("Failed to create remote API client", "endpoint", client.Endpoint(), "err", err) |
| logger.Error("Failed to create remote API client", "endpoint", client.Endpoint(), "err", err) | ||
| } | ||
|
|
||
| return t |
There was a problem hiding this comment.
| return t | |
| return t, err |
|
|
||
| // Initialize remoteAPI now that QueueManager is fully created | ||
| // Configure backoff to match queue manager config | ||
| backoffCfg := remoteapi.BackoffConfig{ |
There was a problem hiding this comment.
Why not just do t.SetClient(....)
| @@ -1048,8 +1073,29 @@ func (t *QueueManager) SeriesReset(index int) { | |||
| // fields are updated to avoid restarting the queue. | |||
| func (t *QueueManager) SetClient(c WriteClient) { | |||
There was a problem hiding this comment.
| func (t *QueueManager) SetClient(c WriteClient) { | |
| func (t *QueueManager) SetClient(c WriteClient) error { |
| if isSampleOld(currentTime, time.Duration(s.qm.cfg.SampleAgeLimit), lowest) { | ||
| // Data became stale - cancel the Write to stop retrying stale data. | ||
| s.qm.logger.Debug("data became stale during Write retries, canceling", | ||
| "refresh_attempt", refreshAttempt, |
There was a problem hiding this comment.
Let's ensure we have a test for refreshed retries.
| return accumulatedStats, err | ||
| s.qm.metrics.sentBatchDuration.Observe(time.Since(begin).Seconds()) | ||
|
|
||
| // Convert client_golang stats to Prometheus stats. |
There was a problem hiding this comment.
Do we need to convert things? I wonder why we still need to use private field here. Is this enough to convince us to make this field public or are we missing helper function?
Which issue(s) does the PR fix:
Does this PR introduce a user-facing change?