Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply minor polish to BuildAnalyticsProvider #42066

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;

import javax.inject.Inject;
Expand All @@ -25,9 +26,9 @@
@Named
public class BuildAnalyticsProvider {

private RuntimeInformation runtimeInformation;
private final RuntimeInformation runtimeInformation;

private AnalyticsService analyticsService;
private final AnalyticsService analyticsService;

private Log log;

Expand All @@ -41,18 +42,21 @@ public void sendAnalytics(TrackEventType trackEventType,
ApplicationModel applicationModel,
Map<String, String> graalVMInfo,
File localBuildDir) {
final long start = System.currentTimeMillis();
final long start = System.nanoTime();

final Map<String, Object> buildInfo = new HashMap<>();
buildInfo.putAll(graalVMInfo);
final Map<String, Object> buildInfo = new HashMap<>(graalVMInfo);
buildInfo.put(MAVEN_VERSION, runtimeInformation.getMavenVersion());
analyticsService.sendAnalytics(trackEventType, applicationModel, buildInfo, localBuildDir);

if (getLog().isDebugEnabled()) {
getLog().debug("Analytics took " + (System.currentTimeMillis() - start) + "ms");
getLog().debug("Analytics took " + (duration(System.nanoTime(), start)) + "ms");
}
}

private long duration(long end, long start) {
return TimeUnit.MILLISECONDS.convert(end - start, TimeUnit.NANOSECONDS);
}

public void buildAnalyticsUserInput(Function<String, String> analyticsEnabledSupplier) {
analyticsService.buildAnalyticsUserInput(analyticsEnabledSupplier);
}
Expand Down
Loading