Search in sources :

Example 11 with Profiler

use of org.sonar.api.utils.log.Profiler in project sonarqube by SonarSource.

the class ProfilingStatementHandler method invoke.

@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    if (method.getName().startsWith("execute")) {
        Profiler profiler = Profiler.create(ProfiledDataSource.SQL_LOGGER).start();
        Object result = null;
        try {
            result = InvocationUtils.invokeQuietly(statement, method, args);
        } finally {
            String sql = (String) args[0];
            profiler.addContext("sql", SqlLogFormatter.formatSql(sql));
            profiler.stopTrace("");
        }
        return result;
    } else {
        return InvocationUtils.invokeQuietly(statement, method, args);
    }
}
Also used : Profiler(org.sonar.api.utils.log.Profiler)

Example 12 with Profiler

use of org.sonar.api.utils.log.Profiler in project sonarqube by SonarSource.

the class ProfilingPreparedStatementHandler method invoke.

@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    if (method.getName().startsWith("execute")) {
        Profiler profiler = Profiler.create(ProfiledDataSource.SQL_LOGGER).start();
        Object result = null;
        try {
            result = InvocationUtils.invokeQuietly(statement, method, args);
        } finally {
            profiler.addContext("sql", SqlLogFormatter.formatSql(sql));
            if (sqlParams.length > 0) {
                profiler.addContext("params", SqlLogFormatter.formatParams(sqlParams));
            }
            profiler.stopTrace("");
        }
        return result;
    } else if (method.getName().startsWith("set") && args.length > 1) {
        sqlParams[(int) args[0] - 1] = args[1];
        return InvocationUtils.invokeQuietly(statement, method, args);
    } else {
        return InvocationUtils.invokeQuietly(statement, method, args);
    }
}
Also used : Profiler(org.sonar.api.utils.log.Profiler)

Example 13 with Profiler

use of org.sonar.api.utils.log.Profiler in project sonarqube by SonarSource.

the class IndexerStartupTask method indexEmptyTypes.

private void indexEmptyTypes(StartupIndexer indexer) {
    Set<IndexType> uninizializedTypes = getUninitializedTypes(indexer);
    if (!uninizializedTypes.isEmpty()) {
        Profiler profiler = Profiler.create(LOG);
        profiler.startInfo(getLogMessage(uninizializedTypes, "..."));
        indexer.indexOnStartup(uninizializedTypes);
        uninizializedTypes.forEach(this::setInitialized);
        profiler.stopInfo(getLogMessage(uninizializedTypes, "done"));
    }
}
Also used : Profiler(org.sonar.api.utils.log.Profiler)

Example 14 with Profiler

use of org.sonar.api.utils.log.Profiler in project sonarqube by SonarSource.

the class RegisterPermissionTemplates method start.

public void start() {
    Profiler profiler = Profiler.create(Loggers.get(getClass())).startInfo("Register permission templates");
    try (DbSession dbSession = dbClient.openSession(false)) {
        String defaultOrganizationUuid = defaultOrganizationProvider.get().getUuid();
        Optional<DefaultTemplates> defaultTemplates = dbClient.organizationDao().getDefaultTemplates(dbSession, defaultOrganizationUuid);
        if (!defaultTemplates.isPresent()) {
            PermissionTemplateDto defaultTemplate = getOrInsertDefaultTemplate(dbSession, defaultOrganizationUuid);
            dbClient.organizationDao().setDefaultTemplates(dbSession, defaultOrganizationUuid, new DefaultTemplates().setProjectUuid(defaultTemplate.getUuid()));
            dbSession.commit();
        }
    }
    profiler.stopDebug();
}
Also used : DbSession(org.sonar.db.DbSession) PermissionTemplateDto(org.sonar.db.permission.template.PermissionTemplateDto) Profiler(org.sonar.api.utils.log.Profiler) DefaultTemplates(org.sonar.db.organization.DefaultTemplates)

Example 15 with Profiler

use of org.sonar.api.utils.log.Profiler in project sonarqube by SonarSource.

the class RegisterMetrics method register.

void register(Iterable<Metric> metrics) {
    Profiler profiler = Profiler.create(LOG).startInfo("Register metrics");
    try (DbSession session = dbClient.openSession(false)) {
        save(session, metrics);
        sanitizeQualityGates(session);
        session.commit();
    }
    profiler.stopDebug();
}
Also used : DbSession(org.sonar.db.DbSession) Profiler(org.sonar.api.utils.log.Profiler)

Aggregations

Profiler (org.sonar.api.utils.log.Profiler)24 DbSession (org.sonar.db.DbSession)4 IOException (java.io.IOException)3 GetRequest (org.sonarqube.ws.client.GetRequest)3 Reader (java.io.Reader)2 HashMap (java.util.HashMap)2 PrivilegedPluginBridge (org.sonar.plugin.PrivilegedPluginBridge)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 File (java.io.File)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 OptInCaching (org.picocontainer.behaviors.OptInCaching)1 ReflectionLifecycleStrategy (org.picocontainer.lifecycle.ReflectionLifecycleStrategy)1 NullComponentMonitor (org.picocontainer.monitors.NullComponentMonitor)1 Initializer (org.sonar.api.batch.Initializer)1 ProjectBuilder (org.sonar.api.batch.bootstrap.ProjectBuilder)1 ProjectDefinition (org.sonar.api.batch.bootstrap.ProjectDefinition)1 ProjectReactor (org.sonar.api.batch.bootstrap.ProjectReactor)1 ProjectBuilderContext (org.sonar.api.batch.bootstrap.internal.ProjectBuilderContext)1