-
-
Notifications
You must be signed in to change notification settings - Fork 4
Autoinstall Profiler #222
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
base: main
Are you sure you want to change the base?
Autoinstall Profiler #222
Changes from all commits
cc3948a
04b26ee
3172dfc
41221cf
90cf614
59add6f
be846af
d15cf76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| import static io.sentry.autoinstall.jdbc.JdbcInstallStrategy.SENTRY_JDBC_ID; | ||
| import static io.sentry.autoinstall.log4j2.Log4j2InstallStrategy.SENTRY_LOG4J2_ID; | ||
| import static io.sentry.autoinstall.logback.LogbackInstallStrategy.SENTRY_LOGBACK_ID; | ||
| import static io.sentry.autoinstall.profiler.ProfilerInstallStrategy.SENTRY_ASYNC_PROFILER_ID; | ||
| import static io.sentry.autoinstall.quartz.QuartzInstallStrategy.SENTRY_QUARTZ_ID; | ||
| import static io.sentry.autoinstall.spring.Spring5InstallStrategy.SENTRY_SPRING_5_ID; | ||
| import static io.sentry.autoinstall.spring.Spring6InstallStrategy.SENTRY_SPRING_6_ID; | ||
|
|
@@ -22,6 +23,7 @@ | |
| import io.sentry.autoinstall.jdbc.JdbcInstallStrategy; | ||
| import io.sentry.autoinstall.log4j2.Log4j2InstallStrategy; | ||
| import io.sentry.autoinstall.logback.LogbackInstallStrategy; | ||
| import io.sentry.autoinstall.profiler.ProfilerInstallStrategy; | ||
| import io.sentry.autoinstall.quartz.QuartzInstallStrategy; | ||
| import io.sentry.autoinstall.spring.*; | ||
| import io.sentry.config.ConfigParser; | ||
|
|
@@ -64,7 +66,8 @@ public class SentryInstallerLifecycleParticipant extends AbstractMavenLifecycleP | |
| GraphqlInstallStrategy.class, | ||
| Graphql22InstallStrategy.class, | ||
| JdbcInstallStrategy.class, | ||
| QuartzInstallStrategy.class) | ||
| QuartzInstallStrategy.class, | ||
| ProfilerInstallStrategy.class) | ||
| .collect(Collectors.toList()); | ||
|
|
||
| @Inject @NotNull ArtifactResolver resolver; | ||
|
|
@@ -125,6 +128,7 @@ public void afterProjectsRead(final @NotNull MavenSession session) | |
| autoInstallState.setInstallGraphql(shouldInstallGraphQL(resolvedArtifacts)); | ||
| autoInstallState.setInstallJdbc(!isModuleAvailable(resolvedArtifacts, SENTRY_JDBC_ID)); | ||
| autoInstallState.setInstallQuartz(!isModuleAvailable(resolvedArtifacts, SENTRY_QUARTZ_ID)); | ||
| autoInstallState.setInstallProfiler(shouldInstallProfiler(resolvedArtifacts, pluginConfig)); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Profiler skip message logged for every build by defaultMedium Severity Since Additional Locations (1)Reviewed by Cursor Bugbot for commit d15cf76. Configure here. |
||
|
|
||
| for (final @NotNull Class<? extends AbstractIntegrationInstaller> installerClass : | ||
| installers) { | ||
|
|
@@ -160,6 +164,12 @@ private boolean shouldInstallGraphQL(final @NotNull List<Artifact> resolvedArtif | |
| || isModuleAvailable(resolvedArtifacts, SENTRY_GRAPHQL_22_ID)); | ||
| } | ||
|
|
||
| private boolean shouldInstallProfiler( | ||
| final @NotNull List<Artifact> resolvedArtifacts, final @NotNull PluginConfig pluginConfig) { | ||
| return pluginConfig.isInstallProfiler() | ||
| && !(isModuleAvailable(resolvedArtifacts, SENTRY_ASYNC_PROFILER_ID)); | ||
| } | ||
|
|
||
| public static boolean isModuleAvailable( | ||
| final @NotNull List<Artifact> resolvedArtifacts, final @NotNull String artifactId) { | ||
| return resolvedArtifacts.stream() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| package io.sentry.autoinstall.profiler; | ||
|
|
||
| import io.sentry.autoinstall.AbstractIntegrationInstaller; | ||
| import io.sentry.autoinstall.AutoInstallState; | ||
| import io.sentry.semver.Version; | ||
| import java.util.List; | ||
| import org.eclipse.aether.artifact.Artifact; | ||
| import org.eclipse.aether.artifact.DefaultArtifact; | ||
| import org.jetbrains.annotations.NotNull; | ||
| import org.jetbrains.annotations.Nullable; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| public class ProfilerInstallStrategy extends AbstractIntegrationInstaller { | ||
| public static final @NotNull String SENTRY_ASYNC_PROFILER_ID = "sentry-async-profiler"; | ||
|
|
||
| public ProfilerInstallStrategy() { | ||
| this(LoggerFactory.getLogger(ProfilerInstallStrategy.class)); | ||
| } | ||
|
|
||
| public ProfilerInstallStrategy(final @NotNull Logger logger) { | ||
| super(logger); | ||
| } | ||
|
|
||
| @Override | ||
| protected @Nullable Artifact findThirdPartyDependency( | ||
| final @NotNull List<Artifact> resolvedArtifacts) { | ||
| // Return a dummy artifact as there are no third-party dependencies required | ||
| return new DefaultArtifact("dummy:dummy:1.0.0"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks fine as a workaround for now. We should consider a cleaner implementation if there's more of these in the future. |
||
| } | ||
|
|
||
| @Override | ||
| protected boolean shouldInstallModule(final @NotNull AutoInstallState autoInstallState) { | ||
| return autoInstallState.isInstallProfiler(); | ||
| } | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| @Override | ||
| protected @NotNull String skippedInstallMessage( | ||
| final @NotNull List<Artifact> resolvedArtifacts, | ||
| final @NotNull AutoInstallState autoInstallState) { | ||
| return sentryModuleId() | ||
| + " won't be installed because it was already installed directly or its auto-installation has been disabled"; | ||
| } | ||
|
|
||
| @Override | ||
| protected @NotNull Version minSupportedSentryVersion() { | ||
| return Version.create(8, 23, 0); | ||
| } | ||
|
|
||
| @Override | ||
| protected @NotNull String sentryModuleId() { | ||
| return SENTRY_ASYNC_PROFILER_ID; | ||
| } | ||
| } | ||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should mention the name of the option to enable it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated changelog