Skip to content

feat: Auto-enabling integrations behind feature flag #625

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 15 commits into from
Feb 25, 2020

Conversation

untitaker
Copy link
Member

The idea is that you can write init(_experiments={"auto_enabling_integrations": True}) to get maximal instrumentation.

Unsolved questions:

  • How to opt out of integrations?

@rhcarvalho
Copy link
Contributor

👀

to get maximal instrumentation.

@untitaker does that mean the integrations that it enables may change over time?

How to opt out of integrations?

Good question. What's the motivation for this new option? The PR description gave the what, we're missing the why.

@untitaker
Copy link
Member Author

@rhcarvalho This was asked for in the context of APM where people would have to enable a lot of small integrations to get a meaningful span tree. Generally it's nice if people have to think about as little as possible (so, not about which integrations are necessary) when enabling the SDK.

The semver compatibility is another thing. Yes, you could upgrade to a new version of the SDK and just get more integrations enabled automatically. Similar effects were already observable to some degree as we added more features to integrations that the user already explicitly enabled (breadcrumbs for django sql queries for example). I think we will just avoid this problem and make sure that new integrations or changes to existing ones don't break fundamental things like grouping, ever (like we already do)

Copy link
Contributor

@rhcarvalho rhcarvalho left a comment

Choose a reason for hiding this comment

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

A couple of questions and suggestions.

Got me thinking if Integration subclasses would know about their default "enabled" state maybe we could write less code.

@@ -106,6 +106,9 @@ def _init_impl(self):
self.integrations = setup_integrations(
self.options["integrations"],
with_defaults=self.options["default_integrations"],
with_auto_enabling_integrations=self.options["_experiments"].get(
Copy link
Contributor

Choose a reason for hiding this comment

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

How is "_experiments" meant to be used? I see we use it for "max_spans" and "record_sql_params" already.
Do experimental options eventually migrate out of the "_experiments" namespace?

For maintenance's sake, could we document it?

Copy link
Member Author

Choose a reason for hiding this comment

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

I added in-code documentation in consts.py but believe adding "real" documentation may give the impression anything in there is stable (despite any disclaimers).

For example we removed Relay from the main docs as it was alpha, even though each page of its documentation had a red "alpha" banner on top.

@@ -37,6 +38,31 @@ def error_processor(event, exc_info):
assert event["exception"]["values"][0]["value"] == "aha! whatever"


def test_auto_enabling_integrations_does_not_break(sentry_init, caplog):
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the intention of this test? "Does not break" is too open ended.

Seems like it checks that none of the integrations in the list get enabled.

Copy link
Member Author

Choose a reason for hiding this comment

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

That they don't get enabled, but by break I rather meant that the DidNotEnable and ImportErrors are caught down properly. I'll rename

Comment on lines 47 to 56
"sentry_sdk.integrations.django.DjangoIntegration",
"sentry_sdk.integrations.flask.FlaskIntegration",
"sentry_sdk.integrations.bottle.BottleIntegration",
"sentry_sdk.integrations.falcon.FalconIntegration",
"sentry_sdk.integrations.sanic.SanicIntegration",
"sentry_sdk.integrations.celery.CeleryIntegration",
"sentry_sdk.integrations.rq.RqIntegration",
"sentry_sdk.integrations.aiohttp.AioHttpIntegration",
"sentry_sdk.integrations.tornado.TornadoIntegration",
"sentry_sdk.integrations.sqlalchemy.SqlalchemyIntegration",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: extract this sequence such that the tests stay in sync with the implementation.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah this makes sense

@rhcarvalho
Copy link
Contributor

  • How to opt out of integrations?

How to opt-out of a default integration today, say we don't want sentry_sdk.integrations.argv.ArgvIntegration?

@untitaker
Copy link
Member Author

@rhcarvalho we don't have a solution for that either. We tell you to disable default_integrations and enumerate all integrations explicitly

@rhcarvalho
Copy link
Contributor

We tell you to disable default_integrations and enumerate all integrations explicitly

Fair enough.


I wonder what would it look like if we simply "promoted" those now "auto-enabling" integrations to be default integrations. Meaning there would be only one concept: either an integration is part of the default set or not.

Default integrations are enabled on a best-effort basis, such that integrations for modules you don't use would just not be enabled (e.g. the Flask integration, though being default on, would not be enabled in a typical Django project).

To disable any integration, only a single answer: enumerate them explicitly, overriding the default set.

But maybe the auto-enabling integrations have some other characteristic I didn't account for?

@untitaker
Copy link
Member Author

I wonder what would it look like if we simply "promoted" those now "auto-enabling" integrations to be default integrations.

This is the goal, and if it weren't for auto-integration being behind a feature flag it would already work

@rhcarvalho
Copy link
Contributor

@untitaker my bad, I overlooked that in the sanic integration there was already a VERSION variable before, and the rename broke it... https://github.com/getsentry/sentry-python/pull/625/files#diff-9118f4d8201c6ac1bb83687985d21737R61

https://travis-ci.com/getsentry/sentry-python/jobs/288969634

@untitaker untitaker requested a review from mitsuhiko February 23, 2020 16:51
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.

3 participants