feat(instrumentation): allow disabling instrumentation for specific variants - #1409
feat(instrumentation): allow disabling instrumentation for specific variants#1409ansman wants to merge 2 commits into
Conversation
0xadam-brown
left a comment
There was a problem hiding this comment.
Backward compatible + a sane extension of our current API + worth exposing ASM off-switches. Lgtm – and thanks 💯
|
...removed my approval as it looks like folks are discussing the precise API internally atm. We'll get back with you shortly... |
|
hey @ansman thanks a bunch for your contribution -- we've discussed this internally and have come up with an inverse approach where you'd specify the variant name as the sub-DSL of sentry {
variants {
create("fullDebug") {
tracingInstrumentation { enabled = false }
runtimeOptimizations { enabled = false }
}
create("qaDebug") {
tracingInstrumentation { enabled = false }
runtimeOptimizations { enabled = false }
}
}
}
// or if you want a bit of sugar on top to disable it for all `debug` variants
androidComponents.beforeVariants(selector().withBuildType("debug")) { vb ->
sentry.variants.maybeCreate(vb.name).with {
tracingInstrumentation { enabled = false }
runtimeOptimizations { enabled = false }
}
}let us know if it's not gonna work for your case, we can revisit it later! For now I'm gonna supersede it |
|
oh and btw, it only exposes bytecode stuff now ( |
|
@romtsn That works fine too, though I'm not exactly sure what the sentry variants would be used for. I think doing something like this would feel more natural to me: androidComponents.onVariants(selector().withBuildType("debug")) { variant ->
variant.sentry {
tracingInstrumentation { enabled = false }
runtimeOptimizations { enabled = false }
}
}Personally I just wanted to disable the bytecode transforms because they prohibit incremental compilation. |
📜 Description
Add
ignoredVariants,ignoredBuildTypes, andignoredFlavorsto bothtracingInstrumentationandruntimeOptimizations.sentry { tracingInstrumentation { ignoredBuildTypes.add("debug") } runtimeOptimizations { ignoredBuildTypes.add("debug") } }All exclusions default to empty, preserving existing behavior. Other plugin features, including mapping uploads, remain enabled for excluded variants.
💡 Motivation and Context
Bytecode instrumentation disables incremental compilation, increasing build times during development. Existing variant exclusions disable the entire Sentry plugin, including unrelated functionality such as mapping uploads. This change allows instrumentation and runtime optimizations to be disabled independently for selected variants while preserving other plugin features and release behavior.
Fixes #1407.
💚 How did you test it?
All 429 unit tests and 13 variant integration tests pass. Integration coverage includes exclusions by variant, build type, and flavor; preserved mapping uploads; unaffected variants; and disabling both instrumentation visitors together.
I also tested it in our project and confirmed that the bytecode transforms did not run for disabled variants.
📝 Checklist
🔮 Next steps
Decide if debug builds should be excluded by default.