Skip to content

feat(celery): Queues module producer implementation#3079

Merged
szokeasaurusrex merged 2 commits intomasterfrom
szokeasaurusrex/celery-producer
May 17, 2024
Merged

feat(celery): Queues module producer implementation#3079
szokeasaurusrex merged 2 commits intomasterfrom
szokeasaurusrex/celery-producer

Conversation

@szokeasaurusrex
Copy link
Copy Markdown
Member

@szokeasaurusrex szokeasaurusrex commented May 16, 2024

Depends on #3082

Fixes #3078

@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/celery-producer branch from 0a72ae0 to dd9cd92 Compare May 16, 2024 16:30
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/celery-producer branch from dd9cd92 to 3d6154d Compare May 16, 2024 17:13
Copy link
Copy Markdown

@edwardgou-sentry edwardgou-sentry left a comment

Choose a reason for hiding this comment

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

tested locally, from a product perspective I think this looks good. Thanks!

Copy link
Copy Markdown
Contributor

@antonpirker antonpirker 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 question, but otherwise looks very good!

def sentry_publish(self, *args, **kwargs):
# type: (Producer, *Any, **Any) -> Any
kwargs_headers = kwargs.get("headers", {})
if not isinstance(kwargs_headers, Mapping):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If kwargs_headers is a list [("key", "value"), ("k", "v")] then it would be reset to an empty dict?

I am not sure if this list of tuples could happen, but I do not understand this if.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Basically, what I am trying to do here is to make sure that the get operations (line 453 to 455) are successful.

Mapping (full name collections.abc.Mapping) is the abstract base class that all mapping types in Python inherit from. dict inherits from Mapping, so this isinstance is true for any dictionary, but it would also be possible to create a custom Mapping type, which provides similar functionality to a dict, but which does not inherit from dict. This isinstance also evaluates to True for any of these dict-like data structures.

Regarding your example, isinstance([("key", "value"), ("k", "v")], Mapping) would evaluate to False since list does not inherit from Mapping (it does not have a get method, which all Mapping types have). So, we would replace it with an empty dictionary to ensure that the get calls don't raise an exception.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

now I get it!

@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/celery-producer branch from 3d6154d to de047fe Compare May 17, 2024 08:56
def sentry_publish(self, *args, **kwargs):
# type: (Producer, *Any, **Any) -> Any
kwargs_headers = kwargs.get("headers", {})
if not isinstance(kwargs_headers, Mapping):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

now I get it!

@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/celery-producer branch from de047fe to 4402cf4 Compare May 17, 2024 10:07
szokeasaurusrex added a commit that referenced this pull request May 17, 2024
Recently `flake8` started to fail with `N803` errors in some places where it had previously passed. This PR adds `# noqa` comments to suppress these errors.

Unblocks #3079
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/celery-producer branch from 4402cf4 to 3283960 Compare May 17, 2024 10:34
@szokeasaurusrex szokeasaurusrex changed the base branch from master to szokeasaurusrex/fix-linter-failures May 17, 2024 10:35
Base automatically changed from szokeasaurusrex/fix-linter-failures to master May 17, 2024 11:05
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/celery-producer branch from 3283960 to 22df82d Compare May 17, 2024 11:10
@szokeasaurusrex szokeasaurusrex merged commit 22df82d into master May 17, 2024
@szokeasaurusrex szokeasaurusrex deleted the szokeasaurusrex/celery-producer branch May 17, 2024 11:24
arjennienhuis pushed a commit to arjennienhuis/sentry-python that referenced this pull request Sep 30, 2024
Recently `flake8` started to fail with `N803` errors in some places where it had previously passed. This PR adds `# noqa` comments to suppress these errors.

Unblocks getsentry#3079
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.

Queues module: Celery producer instrumentation

3 participants