-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add processor duration metric #13227
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
7f57384
to
2ab1342
Compare
@andborja please make sure you review and sign the CLA. |
077c9b3
to
d25590d
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.
LGTM, would like to see the test simplified though. Thanks for adding this!
// Regardless of how many logs are ingested, emit just one | ||
mockAggregate := func(_ context.Context, _ plog.Logs) (plog.Logs, error) { | ||
ld := plog.NewLogs() | ||
ld.ResourceLogs().AppendEmpty().ScopeLogs().AppendEmpty().LogRecords().AppendEmpty() | ||
return ld, nil | ||
} | ||
|
||
incomingLogs := plog.NewLogs() | ||
incomingLogRecords := incomingLogs.ResourceLogs().AppendEmpty().ScopeLogs().AppendEmpty().LogRecords() | ||
|
||
// Add 3 records to the incoming | ||
incomingLogRecords.AppendEmpty() | ||
incomingLogRecords.AppendEmpty() | ||
incomingLogRecords.AppendEmpty() | ||
|
||
tel := componenttest.NewTelemetry() | ||
lp, err := NewLogs(context.Background(), newSettings(tel), &testLogsCfg, consumertest.NewNop(), mockAggregate) | ||
require.NoError(t, err) | ||
|
||
assert.NoError(t, lp.Start(context.Background(), componenttest.NewNopHost())) | ||
assert.NoError(t, lp.ConsumeLogs(context.Background(), incomingLogs)) |
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.
// Regardless of how many logs are ingested, emit just one | |
mockAggregate := func(_ context.Context, _ plog.Logs) (plog.Logs, error) { | |
ld := plog.NewLogs() | |
ld.ResourceLogs().AppendEmpty().ScopeLogs().AppendEmpty().LogRecords().AppendEmpty() | |
return ld, nil | |
} | |
incomingLogs := plog.NewLogs() | |
incomingLogRecords := incomingLogs.ResourceLogs().AppendEmpty().ScopeLogs().AppendEmpty().LogRecords() | |
// Add 3 records to the incoming | |
incomingLogRecords.AppendEmpty() | |
incomingLogRecords.AppendEmpty() | |
incomingLogRecords.AppendEmpty() | |
tel := componenttest.NewTelemetry() | |
lp, err := NewLogs(context.Background(), newSettings(tel), &testLogsCfg, consumertest.NewNop(), mockAggregate) | |
require.NoError(t, err) | |
assert.NoError(t, lp.Start(context.Background(), componenttest.NewNopHost())) | |
assert.NoError(t, lp.ConsumeLogs(context.Background(), incomingLogs)) | |
nop := func(_ context.Context, ld plog.Logs) (plog.Logs, error) { | |
return ld, nil | |
} | |
tel := componenttest.NewTelemetry() | |
lp, err := NewLogs(context.Background(), newSettings(tel), &testLogsCfg, consumertest.NewNop(), nop) | |
require.NoError(t, err) | |
assert.NoError(t, lp.Start(context.Background(), componenttest.NewNopHost())) | |
assert.NoError(t, lp.ConsumeLogs(context.Background(), plog.NewLogs())) |
Much of that setup is irrelevant to the test, and is distracting from what's really being tested. Same goes for metrics & traces.
Description
Add duration metric to processors.
Testing
Unit tests added.
Documentation
Implements issue Processor duration metric #13231.
Basic documentation generated by mdatagen.