Skip to content

Commit

Permalink
Create usage tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
mshaposhnik authored and Sergii Kabashniuk committed Jul 19, 2016
1 parent a0cef67 commit 0caa49f
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ protected void configure() {
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);
Expand All @@ -80,6 +81,7 @@ protected void configure() {

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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ protected void configure() {
.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);
Expand Down

0 comments on commit 0caa49f

Please sign in to comment.