Skip to content

Commit

Permalink
[chore] [exporter/prometheusremotewrite] Do not repeat marshal proto …
Browse files Browse the repository at this point in the history
…on retry (open-telemetry#29584)

**Description:** <Describe what has changed.>
Do not repeat marshal proto on retry.

**Link to tracking Issue:** <Issue number if applicable>
n/a
**Testing:** <Describe what testing was performed and which tests were
added.>
n/a
**Documentation:** <Describe the documentation added.>
n/a
  • Loading branch information
philchia committed Dec 1, 2023
1 parent 9db03ec commit 4756047
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions exporter/prometheusremotewriteexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,16 +226,16 @@ func (prwe *prwExporter) export(ctx context.Context, requests []*prompb.WriteReq
}

func (prwe *prwExporter) execute(ctx context.Context, writeReq *prompb.WriteRequest) error {
// Uses proto.Marshal to convert the WriteRequest into bytes array
data, errMarshal := proto.Marshal(writeReq)
if errMarshal != nil {
return consumererror.NewPermanent(errMarshal)
}
buf := make([]byte, len(data), cap(data))
compressedData := snappy.Encode(buf, data)

// executeFunc can be used for backoff and non backoff scenarios.
executeFunc := func() error {
// Uses proto.Marshal to convert the WriteRequest into bytes array
data, err := proto.Marshal(writeReq)
if err != nil {
return backoff.Permanent(consumererror.NewPermanent(err))
}
buf := make([]byte, len(data), cap(data))
compressedData := snappy.Encode(buf, data)

// Create the HTTP POST request to send to the endpoint
req, err := http.NewRequestWithContext(ctx, "POST", prwe.endpointURL.String(), bytes.NewReader(compressedData))
if err != nil {
Expand Down

0 comments on commit 4756047

Please sign in to comment.