Skip to content

ref: Integration options now live on the client#101

Merged
untitaker merged 20 commits into
masterfrom
ref/per-client-integration-options
Oct 9, 2018
Merged

ref: Integration options now live on the client#101
untitaker merged 20 commits into
masterfrom
ref/per-client-integration-options

Conversation

@untitaker

Copy link
Copy Markdown
Member

fix #100

@codecov-io

codecov-io commented Oct 2, 2018

Copy link
Copy Markdown

Codecov Report

Merging #101 into master will decrease coverage by 1.85%.
The diff coverage is 77.08%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #101      +/-   ##
==========================================
- Coverage   68.76%   66.91%   -1.86%     
==========================================
  Files          25       25              
  Lines        2347     2457     +110     
  Branches      319      352      +33     
==========================================
+ Hits         1614     1644      +30     
- Misses        620      680      +60     
- Partials      113      133      +20
Impacted Files Coverage Δ
sentry_sdk/consts.py 50% <ø> (+3.84%) ⬆️
sentry_sdk/scope.py 66.94% <100%> (+0.56%) ⬆️
sentry_sdk/api.py 58.9% <100%> (-2.8%) ⬇️
sentry_sdk/_compat.py 80.76% <100%> (+0.76%) ⬆️
sentry_sdk/client.py 57.5% <100%> (-3.19%) ⬇️
sentry_sdk/integrations/dedupe.py 100% <100%> (ø) ⬆️
sentry_sdk/integrations/modules.py 87.5% <100%> (+0.54%) ⬆️
sentry_sdk/integrations/excepthook.py 78.26% <100%> (+2.07%) ⬆️
sentry_sdk/integrations/sanic.py 75.86% <68.18%> (-4.33%) ⬇️
sentry_sdk/integrations/flask.py 70.64% <68.88%> (-5.12%) ⬇️
... and 23 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5805bff...b3c323e. Read the comment docs.

@untitaker untitaker requested a review from mitsuhiko October 2, 2018 16:40
Comment thread sentry_sdk/integrations/excepthook.py Outdated
hub = Hub.current
event, hint = event_from_exception(
(exctype, value, traceback),
with_locals=hub.client.options["with_locals"],

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.

I don't quite like this entire pattern of accessing Integration.current + Hub.current + assuming that Hub.current.client then is not none. What if we have a method that returns (integration, hub) or (None, None) if the integration is not configured or hub is none or client is none?

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.

Are you concerned about performance or the potential race condition? I would claim that the race condition is practically irrelevant.

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.

I'm mostly concerned because the thing is nullable and every time I read such code I'm not sure if the programmer validated that it's not none here. Rust broke me to look at nullables in a different way now :) Performance i'm not that much concerned.

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.

Ok, I know what you mean but this instance of nullability in particular should be caught by tests. I don't think adding another layer of indirection is really going to help.

Comment thread sentry_sdk/scope.py Outdated
event = new_event

for processor in self._event_processors:
for processor in chain(self._event_processors, global_event_processors):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't it be chain(global_event_processors, self._event_processors)?

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.

I imagine that every event processor looks like this:

if "key" not in event:
    event["key"] = "bar"

and not like this:

event["key"] = "bar"

In the first example, the first event processor sets "key" and every other event processor skips their logic. So the first processor wins.

In the second example the last processor wins, as its the only one whose value does not get overridden.

The reason is that scopes are applied to the event before event processors are, and data set on the scope should win over data set by integrations.

I wonder if we should apply event processors to the event before we apply scope data.

Comment thread sentry_sdk/integrations/atexit.py Outdated

def install(self):
@staticmethod
def install():

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.

@mitsuhiko why is this a staticmethod?

@untitaker untitaker force-pushed the ref/per-client-integration-options branch from 70647c2 to ee207e2 Compare October 3, 2018 15:56
@untitaker untitaker force-pushed the ref/per-client-integration-options branch from b4daed0 to 250fdd8 Compare October 3, 2018 17:32
@untitaker untitaker dismissed mitsuhiko’s stale review October 3, 2018 18:05

armin fixed his own comment

@mitsuhiko mitsuhiko left a comment

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.

I think this is good now.

@untitaker untitaker force-pushed the ref/per-client-integration-options branch from 39c6563 to 8604b28 Compare October 5, 2018 13:48
@untitaker untitaker force-pushed the ref/per-client-integration-options branch from 44b133a to 8a5aaff Compare October 5, 2018 14:40
@untitaker untitaker merged commit 68b8533 into master Oct 9, 2018
@untitaker untitaker deleted the ref/per-client-integration-options branch October 9, 2018 11:19
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.

Possible double reporting in 0.3.7

4 participants