Search in sources :

Example 31 with Profiler

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

the class ScannerPluginInstaller method loadPluginIndex.

private String loadPluginIndex() {
    Profiler profiler = Profiler.create(LOG).startInfo("Load plugins index");
    GetRequest getRequest = new GetRequest(PLUGINS_INDEX_URL);
    String str;
    try (Reader reader = wsClient.call(getRequest).contentReader()) {
        str = IOUtils.toString(reader);
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
    profiler.stopInfo();
    return str;
}
Also used : Profiler(org.sonar.api.utils.log.Profiler) GetRequest(org.sonarqube.ws.client.GetRequest) Reader(java.io.Reader) IOException(java.io.IOException)

Example 32 with Profiler

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

the class InitializersExecutor method execute.

public void execute() {
    Collection<Initializer> initializers = selector.select(Initializer.class, module, true, null);
    eventBus.fireEvent(new InitializersPhaseEvent(Lists.newArrayList(initializers), true));
    if (LOG.isDebugEnabled()) {
        LOG.debug("Initializers : {}", StringUtils.join(initializers, " -> "));
    }
    Project project = new Project(module.definition());
    for (Initializer initializer : initializers) {
        eventBus.fireEvent(new InitializerExecutionEvent(initializer, true));
        Profiler profiler = Profiler.create(LOG).startInfo("Initializer " + initializer);
        initializer.execute(project);
        profiler.stopInfo();
        eventBus.fireEvent(new InitializerExecutionEvent(initializer, false));
    }
    eventBus.fireEvent(new InitializersPhaseEvent(Lists.newArrayList(initializers), false));
}
Also used : Project(org.sonar.api.resources.Project) Profiler(org.sonar.api.utils.log.Profiler) Initializer(org.sonar.api.batch.Initializer)

Example 33 with Profiler

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

the class ProjectRepositoriesProvider method provide.

public ProjectRepositories provide(ProjectRepositoriesLoader loader, ProjectKey projectKey, DefaultAnalysisMode mode) {
    if (project == null) {
        Profiler profiler = Profiler.create(LOG).startInfo(LOG_MSG);
        project = loader.load(projectKey.get(), mode.isIssues());
        checkProject(mode);
        profiler.stopInfo();
    }
    return project;
}
Also used : Profiler(org.sonar.api.utils.log.Profiler)

Example 34 with Profiler

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

the class QualityProfileProvider method provide.

public ModuleQProfiles provide(ProjectKey projectKey, QualityProfileLoader loader, ProjectRepositories projectRepositories, AnalysisProperties props) {
    if (this.profiles == null) {
        List<QualityProfile> profileList;
        Profiler profiler = Profiler.create(LOG).startInfo(LOG_MSG);
        if (!projectRepositories.exists()) {
            profileList = loader.loadDefault(getSonarProfile(props));
        } else {
            profileList = loader.load(projectKey.get(), getSonarProfile(props));
        }
        profiler.stopInfo();
        profiles = new ModuleQProfiles(profileList);
    }
    return profiles;
}
Also used : Profiler(org.sonar.api.utils.log.Profiler) QualityProfile(org.sonarqube.ws.QualityProfiles.SearchWsResponse.QualityProfile) ModuleQProfiles(org.sonar.scanner.rule.ModuleQProfiles)

Example 35 with Profiler

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

the class DefaultSettingsLoader method load.

@Override
public Map<String, String> load(@Nullable String componentKey) {
    String url = "api/settings/values.protobuf";
    Profiler profiler = Profiler.create(LOG);
    if (componentKey != null) {
        url += "?component=" + ScannerUtils.encodeForUrl(componentKey);
        profiler.startInfo("Load settings for component '" + componentKey + "'");
    } else {
        profiler.startInfo("Load global settings");
    }
    try (InputStream is = wsClient.call(new GetRequest(url)).contentStream()) {
        ValuesWsResponse values = ValuesWsResponse.parseFrom(is);
        profiler.stopInfo();
        return toMap(values.getSettingsList());
    } catch (IOException e) {
        throw new IllegalStateException("Failed to load server settings", e);
    }
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) Profiler(org.sonar.api.utils.log.Profiler) InputStream(java.io.InputStream) GetRequest(org.sonarqube.ws.client.GetRequest) IOException(java.io.IOException)

Aggregations

Profiler (org.sonar.api.utils.log.Profiler)56 Bean (org.springframework.context.annotation.Bean)7 HashMap (java.util.HashMap)6 IOException (java.io.IOException)5 DbSession (org.sonar.db.DbSession)5 GetRequest (org.sonarqube.ws.client.GetRequest)5 File (java.io.File)3 Reader (java.io.Reader)3 RulesDefinition (org.sonar.api.server.rule.RulesDefinition)3 InputStream (java.io.InputStream)2 Path (java.nio.file.Path)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 CheckForNull (javax.annotation.CheckForNull)2 OptInCaching (org.picocontainer.behaviors.OptInCaching)2 ReflectionLifecycleStrategy (org.picocontainer.lifecycle.ReflectionLifecycleStrategy)2 NullComponentMonitor (org.picocontainer.monitors.NullComponentMonitor)2 InputFile (org.sonar.api.batch.fs.InputFile)2 NewRule (org.sonar.api.batch.rule.internal.NewRule)2 RulesBuilder (org.sonar.api.batch.rule.internal.RulesBuilder)2