Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

andborja
Copy link

@andborja andborja commented Jun 17, 2025

Description

Add duration metric to processors.

Testing

Unit tests added.

Documentation

Implements issue Processor duration metric #13231.

Basic documentation generated by mdatagen.

@andborja andborja requested a review from a team as a code owner June 17, 2025 17:19
@andborja andborja requested a review from mx-psi June 17, 2025 17:19
Copy link

linux-foundation-easycla bot commented Jun 17, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@andborja andborja marked this pull request as draft June 17, 2025 17:19
@andborja andborja force-pushed the andborja/procDuration branch 2 times, most recently from 7f57384 to 2ab1342 Compare June 17, 2025 22:31
@andborja andborja marked this pull request as ready for review June 18, 2025 16:40
@atoulme
Copy link
Contributor

atoulme commented Jun 18, 2025

@andborja please make sure you review and sign the CLA.

@andborja
Copy link
Author

@andborja please make sure you review and sign the CLA.

Thanks @atoulme. I just created a ticket for it.

@andborja andborja force-pushed the andborja/procDuration branch from 077c9b3 to d25590d Compare June 18, 2025 21:48
Copy link
Contributor

@axw axw left a 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!

Comment on lines +187 to +207
// 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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants