Skip to content

[chore] Create service/internal/obsconsumer package #12817

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

Merged
merged 4 commits into from
Apr 15, 2025

Conversation

djaglowski
Copy link
Member

Subset of #12812

This internal package defines wrappers around consumers. These are useful for instrumenting the component graph, so that we can generate telemetry describing data as it is passed in between components.

Currently, this supports only a single counter metric, but in the near future it can be enhanced to automatically capture multiple metrics (e.g. item count & size), and potentially spans and/or logs as well.

Copy link

codecov bot commented Apr 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.46%. Comparing base (cf18559) to head (37f5e4f).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12817      +/-   ##
==========================================
+ Coverage   91.43%   91.46%   +0.03%     
==========================================
  Files         488      493       +5     
  Lines       26879    26984     +105     
==========================================
+ Hits        24577    24682     +105     
  Misses       1818     1818              
  Partials      484      484              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@djaglowski djaglowski force-pushed the obsconsumer branch 2 times, most recently from 94b6fcb to 9d93162 Compare April 9, 2025 18:38
@djaglowski djaglowski marked this pull request as ready for review April 9, 2025 19:06
@djaglowski djaglowski requested a review from a team as a code owner April 9, 2025 19:06
@djaglowski djaglowski requested a review from bogdandrutu April 9, 2025 19:06
@djaglowski djaglowski force-pushed the obsconsumer branch 2 times, most recently from 3a2603b to 712a269 Compare April 9, 2025 20:20
// Measure before calling ConsumeLogs because the data may be mutated downstream
itemCount := ld.LogRecordCount()

err := c.consumer.ConsumeLogs(ctx, ld)
Copy link
Contributor

Choose a reason for hiding this comment

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

would we also want to record a metric for after the consume for the amount produced?

Copy link
Member Author

Choose a reason for hiding this comment

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

The way this is intended to be used is that there will be two instances of the wrapper, one measuring consumed and the other measuring produced. Measuring both in one instance would effectively mean that we need to enhance the model for edges so that each edge is aware of the attributes of the producing and consuming components. I think it ends up being a lot simpler this way.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we document how this is intended to be used then? Or write a parent component that does the wrapping automatically? i.e. something that creates both instances wrapping the actual component Consume call?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's an internal package so I'm not too worried about documentation. #12812 uses it as I've described. The reason I've split it into a separate PR is to make it easier to test and review. I'm not sure further abstractions are helpful.

Copy link

@dehaansa dehaansa left a comment

Choose a reason for hiding this comment

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

👍 Structure looks good. As this will affect performance, we should ensure we optimize what we can (pre-allocated slices)

Copy link
Member

@MikeGoldsmith MikeGoldsmith left a comment

Choose a reason for hiding this comment

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

I think this looks really good 👍🏻

I would also like to see bytes being recorded, but understand that's not part of this PR and would need to involve some serialisation like the ProtoMarshaler which has additional cost.

Copy link
Member

@mx-psi mx-psi left a comment

Choose a reason for hiding this comment

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

Just one small comment

@mx-psi mx-psi requested a review from jade-guiton-dd April 14, 2025 09:57
Copy link
Contributor

@jade-guiton-dd jade-guiton-dd left a comment

Choose a reason for hiding this comment

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

Looks pretty good to me, just one question

@mx-psi mx-psi requested a review from jade-guiton-dd April 15, 2025 08:07
Copy link
Contributor

@jade-guiton-dd jade-guiton-dd left a comment

Choose a reason for hiding this comment

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

LGTM, with two notes for posterity:

  • As already mentioned in a comment thread, we'll need to implement a "downstream" error marker and the "rejected" outcome eventually
  • I don't think I implemented component attribute injection for profiles, so there is probably additional work to be done on that front as well

@mx-psi mx-psi added this pull request to the merge queue Apr 15, 2025
Merged via the queue into open-telemetry:main with commit 55f569d Apr 15, 2025
56 checks passed
@djaglowski djaglowski deleted the obsconsumer branch April 15, 2025 12:31
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.

6 participants