Skip to content

Commit

Permalink
chore: update doc and naming
Browse files Browse the repository at this point in the history
  • Loading branch information
kyungeunni committed Apr 30, 2024
1 parent 0153994 commit ee43158
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions docappendertest/docappendertest.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ func DecodeBulkRequest(r *http.Request) ([][]byte, esutil.BulkIndexerResponse) {
return indexed, result
}

// DecodeBulkRequest decodes a /_bulk request's body, returning the decoded documents and a response body.
// DecodeBulkRequestWithStats decodes a /_bulk request's body, returning the decoded documents
// and a response body and stats about request.
func DecodeBulkRequestWithStats(r *http.Request) (
docs [][]byte,
res esutil.BulkIndexerResponse,
Expand Down Expand Up @@ -132,7 +133,7 @@ func DecodeBulkRequestWithStats(r *http.Request) (
item := esutil.BulkIndexerResponseItem{Status: http.StatusCreated, Index: action[actionType].Index}
result.Items = append(result.Items, map[string]esutil.BulkIndexerResponseItem{actionType: item})
}
return indexed, result, RequestStats{int64(cr.count)}
return indexed, result, RequestStats{int64(cr.bytesRead)}
}

// NewMockElasticsearchClient returns an elasticsearch.Client which sends /_bulk requests to bulkHandler.
Expand Down Expand Up @@ -193,14 +194,14 @@ func AssertOTelMetrics(t testing.TB, ms []metricdata.Metrics, assert func(m metr

// helper reader to keep track of the bytes read by ReadCloser
type countReader struct {
count int
bytesRead int
io.ReadCloser
}

// Read implements the [io.Reader] interface.
func (c *countReader) Read(p []byte) (int, error) {
n, err := c.ReadCloser.Read(p)
c.count += n
c.bytesRead += n
return n, err
}

Expand Down

0 comments on commit ee43158

Please sign in to comment.