-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
send batches concurrently in each flush and compress payload #720
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package data | ||
|
||
import ( | ||
"bytes" | ||
"compress/gzip" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this will be fine for now, but we will need to look at adopting lz4 compression to help improve performance. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. idk if there's choice for now as the OTLP doc is quite confusing, specification here says it only need to support |
||
"context" | ||
"net/http" | ||
|
||
|
@@ -13,7 +15,7 @@ type metricsRequest struct { | |
raw *v1export.ExportMetricsServiceRequest | ||
} | ||
|
||
func NewMetricsRequest(ctx context.Context, endpoint string, metrics []ResourceMetrics) (*http.Request, error) { | ||
func NewMetricsRequest(ctx context.Context, endpoint string, metrics []ResourceMetrics, compressPayload bool) (*http.Request, error) { | ||
mr := metricsRequest{ | ||
raw: &v1export.ExportMetricsServiceRequest{ | ||
ResourceMetrics: make([]*v1metrics.ResourceMetrics, 0, len(metrics)), | ||
|
@@ -29,5 +31,19 @@ func NewMetricsRequest(ctx context.Context, endpoint string, metrics []ResourceM | |
return nil, err | ||
} | ||
|
||
if compressPayload { | ||
var b bytes.Buffer | ||
w := gzip.NewWriter(&b) | ||
if _, err = w.Write(buf); err != nil { | ||
return nil, err | ||
} | ||
|
||
if err = w.Close(); err != nil { | ||
return nil, err | ||
} | ||
|
||
return createProtobufRequest(ctx, endpoint, b.Bytes(), withHeader("Content-Encoding", "gzip")) | ||
} | ||
|
||
return createProtobufRequest(ctx, endpoint, buf) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool this means async sends? Do we have any retries in the otlp backend?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah retry is in the
postMetrics