Skip to content

Make a BatchProcessor class which both BatchSpanRecordProcessor and BatchLogRecordProcessor can use #4562

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 29 commits into
base: main
Choose a base branch
from

Conversation

DylanRussell
Copy link
Contributor

@DylanRussell DylanRussell commented Apr 25, 2025

Description

Make a BatchProcessor class which both BatchSpanRecordProcessor and BatchLogRecordProcessor can use.

Move BatchProcessor into a new _shared_internal folder in the SDK, so both processors can make use of it.

In a follow up PR, I will update BatchSpanRecordProcessor to use this new class.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Added unit tests

Does This PR Require a Contrib Repo Change?

  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@DylanRussell DylanRussell requested a review from a team as a code owner April 25, 2025 17:54
@DylanRussell
Copy link
Contributor Author

DylanRussell commented Apr 30, 2025

Nevermind.. was able to get the test working

Copy link
Member

@aabmass aabmass left a comment

Choose a reason for hiding this comment

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

Nice, just a few comments on design and typing

token = attach(set_value(_SUPPRESS_INSTRUMENTATION_KEY, True))
try:
self._exporter.export(
[ # pyright: ignore [reportArgumentType]
Copy link
Member

Choose a reason for hiding this comment

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

see comment about generics

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack switched to generics.. I still get a pyright issue thrown here, because now it can't figure out that the generic _exporter has an export method.. But I think it's cleaner then before anyway



class BatchLogRecordProcessor(LogRecordProcessor):
class BatchLogRecordProcessor(BatchProcessor, LogRecordProcessor):
Copy link
Member

Choose a reason for hiding this comment

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

I'm not a huge fan of multiple inheritance. Wdyt of using composition instead of inheritance here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried doing that, but then the emit and shutdown methods need to be accessed like batch_record_processor._batch_processor.emit() which breaks stuff, also the linter complains about the BatchLogRecordProcessor being initialized directly because it inherits from an abstract class (LogRecordProcessor) and doesn't implement those methods.

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.

4 participants