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;
try {
result = InvocationUtils.invokeQuietly(statement, method, args);
} finally {
String sql = (String) args[0];
profiler.addContext("sql", SqlLogFormatter.reformatSql(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 DetectPluginChange method start.
@Override
public void start() {
Preconditions.checkState(changesDetected == null, "Can only call #start() once");
Profiler profiler = Profiler.create(LOG).startInfo("Detect plugin changes");
changesDetected = anyChange();
if (changesDetected) {
LOG.debug("Plugin changes detected");
} else {
LOG.info("No plugin change detected");
}
profiler.stopDebug();
}
use of org.sonar.api.utils.log.Profiler in project sonarqube by SonarSource.
the class GeneratePluginIndex method start.
@Override
public void start() {
Profiler profiler = Profiler.create(LOG).startInfo("Generate scanner plugin index");
writeIndex(serverFs.getPluginIndex());
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(true)) {
save(session, metrics);
sanitizeQualityGates(session);
session.commit();
}
profiler.stopDebug();
}
use of org.sonar.api.utils.log.Profiler in project sonarqube by SonarSource.
the class RegisterRules method mergeParams.
private void mergeParams(RegisterRulesContext context, RulesDefinition.Rule ruleDef, RuleDefinitionDto rule, DbSession session) {
List<RuleParamDto> paramDtos = context.getRuleParametersFor(rule.getUuid());
Map<String, RuleParamDto> existingParamsByName = new HashMap<>();
Profiler profiler = Profiler.create(Loggers.get(getClass()));
for (RuleParamDto paramDto : paramDtos) {
RulesDefinition.Param paramDef = ruleDef.param(paramDto.getName());
if (paramDef == null) {
profiler.start();
dbClient.activeRuleDao().deleteParamsByRuleParam(session, paramDto);
profiler.stopDebug(format("Propagate deleted param with name %s to active rules of rule %s", paramDto.getName(), rule.getKey()));
dbClient.ruleDao().deleteRuleParam(session, paramDto.getUuid());
} else {
if (mergeParam(paramDto, paramDef)) {
dbClient.ruleDao().updateRuleParam(session, rule, paramDto);
}
existingParamsByName.put(paramDto.getName(), paramDto);
}
}
// Create newly parameters
for (RulesDefinition.Param param : ruleDef.params()) {
RuleParamDto paramDto = existingParamsByName.get(param.key());
if (paramDto != null) {
continue;
}
paramDto = RuleParamDto.createFor(rule).setName(param.key()).setDescription(param.description()).setDefaultValue(param.defaultValue()).setType(param.type().toString());
dbClient.ruleDao().insertRuleParam(session, rule, paramDto);
if (StringUtils.isEmpty(param.defaultValue())) {
continue;
}
// Propagate the default value to existing active rule parameters
profiler.start();
for (ActiveRuleDto activeRule : dbClient.activeRuleDao().selectByRuleUuid(session, rule.getUuid())) {
ActiveRuleParamDto activeParam = ActiveRuleParamDto.createFor(paramDto).setValue(param.defaultValue());
dbClient.activeRuleDao().insertParam(session, activeRule, activeParam);
}
profiler.stopDebug(format("Propagate new param with name %s to active rules of rule %s", paramDto.getName(), rule.getKey()));
}
}
Aggregations