Search in sources :

Example 16 with Profiler

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

the class ComponentContainer method createPicoContainer.

public static MutablePicoContainer createPicoContainer() {
    ReflectionLifecycleStrategy lifecycleStrategy = new ReflectionLifecycleStrategy(new NullComponentMonitor(), "start", "stop", "close") {

        @Override
        public void start(Object component) {
            Profiler profiler = Profiler.createIfTrace(Loggers.get(ComponentContainer.class));
            profiler.start();
            super.start(component);
            profiler.stopTrace(component.getClass().getCanonicalName() + " started");
        }
    };
    return new ExtendedDefaultPicoContainer(new OptInCaching(), lifecycleStrategy, null);
}
Also used : OptInCaching(org.picocontainer.behaviors.OptInCaching) Profiler(org.sonar.api.utils.log.Profiler) NullComponentMonitor(org.picocontainer.monitors.NullComponentMonitor) ReflectionLifecycleStrategy(org.picocontainer.lifecycle.ReflectionLifecycleStrategy)

Example 17 with Profiler

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

the class ScannerWsClient method call.

/**
   * If an exception is not thrown, the response needs to be closed by either calling close() directly, or closing the 
   * body content's stream/reader.
   * @throws IllegalStateException if the request could not be executed due to
   *     a connectivity problem or timeout. Because networks can
   *     fail during an exchange, it is possible that the remote server
   *     accepted the request before the failure
   * @throws HttpException if the response code is not in range [200..300)
   */
public WsResponse call(WsRequest request) {
    Preconditions.checkState(!globalMode.isMediumTest(), "No WS call should be made in medium test mode");
    Profiler profiler = Profiler.createIfDebug(LOG).start();
    WsResponse response = target.wsConnector().call(request);
    profiler.stopDebug(format("%s %d %s", request.getMethod(), response.code(), response.requestUrl()));
    failIfUnauthorized(response);
    return response;
}
Also used : Profiler(org.sonar.api.utils.log.Profiler) WsResponse(org.sonarqube.ws.client.WsResponse)

Example 18 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 19 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 20 with Profiler

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

the class MetricsRepositoryProvider method provide.

public MetricsRepository provide(MetricsRepositoryLoader loader) {
    if (metricsRepository == null) {
        Profiler profiler = Profiler.create(LOG).startInfo(LOG_MSG);
        metricsRepository = loader.load();
        profiler.stopInfo();
    }
    return metricsRepository;
}
Also used : 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