Create usage tracker

6.19.x
Max Shaposhnik 2016-07-19 15:55:15 +03:00 committed by Sergii Kabashniuk
parent a0cef67fd4
commit 0caa49f393
4 changed files with 91 additions and 0 deletions

View File

@ -0,0 +1,44 @@
/*******************************************************************************
* Copyright (c) 2012-2016 Codenvy, S.A.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Codenvy, S.A. - initial API and implementation
*******************************************************************************/
package org.eclipse.che.wsagent.server;
import org.eclipse.che.commons.schedule.ScheduleRate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Singleton;
import javax.net.ssl.HttpsURLConnection;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.concurrent.TimeUnit;
@Singleton
public class WsAgentAnalyticsAddresser {
private static final Logger LOG = LoggerFactory.getLogger(WsAgentAnalyticsAddresser.class);
@ScheduleRate(period = 1, unit = TimeUnit.HOURS)
void send() {
HttpURLConnection connection = null;
try {
final URL url = new URL("https://install.codenvycorp.com/che/telemetry/workspace");
connection = (HttpsURLConnection)url.openConnection();
connection.getResponseCode();
} catch (IOException e) {
LOG.error("Failed to send agent analytics", e);
} finally {
if (connection != null) {
connection.disconnect();
}
}
}
}

View File

@ -66,6 +66,7 @@ public class WsAgentModule extends AbstractModule {
install(new ProjectApiModule());
install(new org.eclipse.che.swagger.deploy.DocsModule());
install(new org.eclipse.che.api.debugger.server.DebuggerModule());
install(new org.eclipse.che.commons.schedule.executor.ScheduleModule());
bind(GitUserResolver.class).to(LocalGitUserResolver.class);
bind(GitConnectionFactory.class).to(JGitConnectionFactory.class);
@ -80,6 +81,7 @@ public class WsAgentModule extends AbstractModule {
bind(String.class).annotatedWith(Names.named("event.bus.url")).toProvider(EventBusURLProvider.class);
bind(ApiEndpointAccessibilityChecker.class);
bind(WsAgentAnalyticsAddresser.class);
bind(String.class).annotatedWith(Names.named("wsagent.endpoint"))
.toProvider(WsAgentURLProvider.class);

View File

@ -0,0 +1,44 @@
/*******************************************************************************
* Copyright (c) 2012-2016 Codenvy, S.A.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Codenvy, S.A. - initial API and implementation
*******************************************************************************/
package org.eclipse.che.api.deploy;
import org.eclipse.che.commons.schedule.ScheduleRate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Singleton;
import javax.net.ssl.HttpsURLConnection;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.concurrent.TimeUnit;
@Singleton
public class WsMasterAnalyticsAddresser {
private static final Logger LOG = LoggerFactory.getLogger(WsMasterAnalyticsAddresser.class);
@ScheduleRate(period = 1, unit = TimeUnit.HOURS)
void send() {
HttpURLConnection connection = null;
try {
final URL url = new URL("https://install.codenvycorp.com/che/telemetry/master");
connection = (HttpsURLConnection)url.openConnection();
connection.getResponseCode();
} catch (IOException e) {
LOG.error("Failed to send master analytics", e);
} finally {
if (connection != null) {
connection.disconnect();
}
}
}
}

View File

@ -83,6 +83,7 @@ public class WsMasterModule extends AbstractModule {
.to(org.eclipse.che.api.machine.server.wsagent.WsAgentLauncherImpl.class);
bind(org.eclipse.che.api.machine.server.terminal.MachineTerminalLauncher.class);
bind(org.eclipse.che.api.deploy.WsMasterAnalyticsAddresser.class);
Multibinder<org.eclipse.che.api.machine.server.spi.InstanceProvider> machineImageProviderMultibinder =
Multibinder.newSetBinder(binder(), org.eclipse.che.api.machine.server.spi.InstanceProvider.class);