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);
}
}
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);
}
}
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"));
}
}
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();
}
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();
}
Aggregations