-
Notifications
You must be signed in to change notification settings - Fork 15
Remove Stats datastructure in favour of OTel #249
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
base: main
Are you sure you want to change the base?
Conversation
525b8b3
to
1141f1c
Compare
1141f1c
to
c6f2f06
Compare
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.
Overall the changes looks good, thank you!
Albeit OTel metrics assertions are quite verbose and repetitive, it would be nice to sugar it up a bit to reduce the tests code. I would recommend to look into expanding docappendertest.AssertOTelMetrics
helper to accept a metrics assertion map.
docappendertest.AssertOTelMetricsWithMap(t, rm.ScopeMetrics[0].Metrics, map[string]int64{
"elasticsearch.bulk_requests.count": 1,
"elasticsearch.indexer.created": 2,
"elasticsearch.indexer.destroyed": 3,
})
With such helper most if not all of the tests could be simmered down a bit.
b450780
to
89c79b2
Compare
89c79b2
to
e650c89
Compare
e2de81c
to
f48cdad
Compare
f48cdad
to
bd8e118
Compare
const N = 10 | ||
for i := 0; i < N; i++ { | ||
addMinimalDoc(t, indexer, "logs-foo-testing") | ||
} | ||
<-time.After(1 * time.Second) |
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.
For Reviewers: I have created this ticket to improve this wait using a channel: #253
} | ||
if status != "" { | ||
a.addCount(int64(n), legacy, a.metrics.docsIndexed, | ||
metric.WithAttributes(attribute.String("status", status), semconv.HTTPResponseStatusCode(errFailed.statusCode)), | ||
a.tooManyRequests.Add(legacy) |
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.
issue: I think this is updating the wrong metric. It should only update toomanyrequests in the switch case for tooMany
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.
Left a bunch of smaller questions in the first review.
@@ -274,7 +268,7 @@ func TestAppenderRetry(t *testing.T) { | |||
|
|||
indexer, err := docappender.New(client, docappender.Config{ | |||
FlushInterval: time.Minute, | |||
FlushBytes: 750, // this is enough to flush after 9 documents | |||
FlushBytes: 800, // this is enough to flush after 9 documents |
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.
Why does this value change?
@@ -288,79 +282,74 @@ func TestAppenderRetry(t *testing.T) { | |||
for i := 0; i < N; i++ { | |||
addMinimalDoc(t, indexer, "logs-foo-testing") | |||
} | |||
<-time.After(1 * time.Second) |
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.
Is 1 second enough? it used to be 2 seconds..
} | ||
if status != "" { | ||
a.addCount(int64(n), legacy, a.metrics.docsIndexed, | ||
metric.WithAttributes(attribute.String("status", status), semconv.HTTPResponseStatusCode(errFailed.statusCode)), | ||
a.tooManyRequests.Add(legacy) |
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.
Would it make sense to add this in the errFailed.tooMany
case?
|
||
// Collect metrics before flushing. | ||
var rm metricdata.ResourceMetrics | ||
assert.NoError(t, rdr.Collect(context.Background(), &rm)) |
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.
assert.NoError(t, rdr.Collect(context.Background(), &rm)) | |
require.NoError(t, rdr.Collect(context.Background(), &rm)) |
case "elasticsearch.events.count": | ||
assertCounter(m, N, indexerAttrs) | ||
case "elasticsearch.events.queued": | ||
assertCounter(m, N, indexerAttrs) |
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.
So far this test tested for docs.active
- why is this not necessary anymore?
assert.True(t, exist) | ||
switch status.AsString() { | ||
case "Success": | ||
assert.Equal(t, int64(8), dp.Value) |
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.
Where is this number from?
BulkRequests: 2, | ||
Failed: failed, | ||
FailedClient: 1, | ||
FailedServer: 1, |
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.
Where are these checked now?
@@ -92,7 +92,7 @@ func TestAppender(t *testing.T) { | |||
|
|||
rdr := sdkmetric.NewManualReader(sdkmetric.WithTemporalitySelector( | |||
func(ik sdkmetric.InstrumentKind) metricdata.Temporality { | |||
return metricdata.DeltaTemporality | |||
return metricdata.CumulativeTemporality |
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.
Why does this change to Cumulative?
BulkRequests: 1, | ||
Failed: failed, | ||
FailedClient: 1, | ||
FailedServer: 1, |
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.
Where are the failed events checked now? Haven't seen them below
Closes #246
Remove the
Stats
datastructure and leverage the current OTel implementation.Updated Unit Tests