Skip to content

Commit

Permalink
Merge branch 'master' into hermes_console_vue
Browse files Browse the repository at this point in the history
  • Loading branch information
szczygiel-m authored Oct 26, 2023
2 parents 880ea3c + 97a54ab commit ba2e4b4
Show file tree
Hide file tree
Showing 20 changed files with 181 additions and 41 deletions.
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ allprojects {
wiremock : '3.0.1',
spock : '2.4-M1-groovy-4.0',
groovy : '4.0.12',
alpn_api : '1.1.2.v20150522',
avro : '1.9.1',
json2avro : '0.2.14',
okhttp : '3.9.1',
Expand Down
15 changes: 6 additions & 9 deletions hermes-client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ plugins {
}

dependencies {
api group: 'io.dropwizard.metrics', name: 'metrics-core', version: versions.dropwizard_metrics
api group: 'io.micrometer', name: 'micrometer-core', version: versions.micrometer_metrics
api group: 'org.glassfish.jersey.core', name: 'jersey-client', version: versions.jersey
compileOnly group: 'io.dropwizard.metrics', name: 'metrics-core', version: versions.dropwizard_metrics
compileOnly group: 'io.micrometer', name: 'micrometer-core', version: versions.micrometer_metrics
compileOnly group: 'org.glassfish.jersey.core', name: 'jersey-client', version: versions.jersey
compileOnly group: 'org.glassfish.jersey.inject', name: 'jersey-hk2', version: versions.jersey
api group: 'org.springframework', name: 'spring-web', version: versions.spring_web
api group: 'org.springframework', name: 'spring-webflux', version: versions.spring_web

api group: 'com.squareup.okhttp3', name: 'okhttp', version: versions.okhttp
compileOnly group: 'org.eclipse.jetty.alpn', name: 'alpn-api', version: versions.alpn_api
compileOnly group: 'org.springframework', name: 'spring-web', version: versions.spring_web
compileOnly group: 'org.springframework', name: 'spring-webflux', version: versions.spring_web
compileOnly group: 'com.squareup.okhttp3', name: 'okhttp', version: versions.okhttp

implementation group: 'net.jodah', name: 'failsafe', version: versions.failsafe
api group: 'io.projectreactor', name: 'reactor-core', version: '3.4.25'
Expand All @@ -29,7 +27,6 @@ dependencies {
testImplementation group: 'org.springframework', name: 'spring-web', version: versions.spring_web
testImplementation group: 'org.springframework', name: 'spring-webflux', version: versions.spring_web
testImplementation group: 'com.squareup.okhttp3', name: 'okhttp', version: versions.okhttp
testImplementation group: 'org.eclipse.jetty.alpn', name: 'alpn-api', version: versions.alpn_api
testImplementation group: 'io.projectreactor.netty', name: 'reactor-netty', version: '1.0.25'
testImplementation group: 'io.projectreactor', name: 'reactor-test', version: '3.4.25'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package pl.allegro.tech.hermes.common.di.factories;

import io.micrometer.core.instrument.Meter;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.binder.jvm.JvmGcMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics;
import io.micrometer.core.instrument.config.MeterFilter;
import io.micrometer.core.instrument.distribution.DistributionStatisticConfig;
import io.micrometer.prometheus.PrometheusConfig;
Expand Down Expand Up @@ -31,6 +35,7 @@ public PrometheusMeterRegistry provide() {
if (parameters.zookeeperReporterEnabled()) {
registerZookeeperReporter(meterRegistry);
}
registerJvmMetrics(meterRegistry);
return meterRegistry;
}

Expand All @@ -55,4 +60,10 @@ private void registerZookeeperReporter(PrometheusMeterRegistry meterRegistry) {
new ZookeeperCounterReporter(meterRegistry, counterStorage, prefix)
.start(parameters.zookeeperReportPeriod().toSeconds(), TimeUnit.SECONDS);
}

private void registerJvmMetrics(MeterRegistry meterRegistry) {
new JvmMemoryMetrics().bindTo(meterRegistry);
new JvmGcMetrics().bindTo(meterRegistry);
new JvmThreadMetrics().bindTo(meterRegistry);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package pl.allegro.tech.hermes.common.metric.executor;

import com.google.common.util.concurrent.ThreadFactoryBuilder;
import pl.allegro.tech.hermes.common.metric.HermesMetrics;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ScheduledExecutorService;
Expand All @@ -14,8 +11,6 @@
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import static java.util.concurrent.Executors.newScheduledThreadPool;

public class InstrumentedExecutorServiceFactory {

private final ThreadPoolMetrics threadPoolMetrics;
Expand Down
5 changes: 4 additions & 1 deletion hermes-console/static/js/console/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ home.controller('HomeController', ['$scope', 'DASHBOARD_CONFIG', function($scope

$scope.statsDashboard = config.metrics;
$scope.docs = config.docs;

$scope.costs = {
detailsUrl: window.config.costs.globalDetailsUrl,
enabled: window.config.costs.enabled
};
}]);
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,26 @@ var subscriptions = angular.module('hermes.subscription', [

subscriptions.controller('SubscriptionController', ['SubscriptionRepository', 'SubscriptionHealth', 'SubscriptionMetrics',
'TopicRepository', 'TopicMetrics', '$scope', '$location', '$stateParams', '$uibModal', '$q', 'ConfirmationModal',
'toaster', 'PasswordService', 'MessagePreviewModal', 'FiltersDebuggerModalFactory', 'SUBSCRIPTION_CONFIG',
'toaster', 'PasswordService', 'MessagePreviewModal', 'FiltersDebuggerModalFactory', 'SUBSCRIPTION_CONFIG', '$sce',
function (subscriptionRepository, subscriptionHealth, subscriptionMetrics, topicRepository, topicMetrics,
$scope, $location, $stateParams, $modal, $q, confirmationModal, toaster, passwordService,
messagePreviewModal, filtersDebuggerModal, config) {
messagePreviewModal, filtersDebuggerModal, config, $sce) {
var groupName = $scope.groupName = $stateParams.groupName;
var topicName = $scope.topicName = $stateParams.topicName;
var subscriptionName = $scope.subscriptionName = $stateParams.subscriptionName;
$scope.config = config;
$scope.costs = {
enabled: window.config.costs.enabled,
iframeUrl: $sce.trustAsResourceUrl(resolveCostsUrl(window.config.costs.subscriptionIframeUrl)),
detailsUrl: resolveCostsUrl(window.config.costs.subscriptionDetailsUrl)
};

function resolveCostsUrl(template) {
if (template) {
return template.replace('{{topic_name}}', topicName).replace('{{subscription_name}}', subscriptionName);
}
return template;
}

function getUndelivered() {
subscriptionRepository.undelivered(topicName, subscriptionName).$promise
Expand Down Expand Up @@ -276,8 +288,8 @@ subscriptions.controller('SubscriptionController', ['SubscriptionRepository', 'S
});
};
$scope.skipMessages = function (){
tommorowDate = new Date()
tommorowDate.setDate(tommorowDate.getDate() + 1)
tommorowDate = new Date();
tommorowDate.setDate(tommorowDate.getDate() + 1);

confirmationModal.open({
action: 'Skip messages',
Expand All @@ -299,7 +311,7 @@ subscriptions.controller('SubscriptionController', ['SubscriptionRepository', 'S
});
});

}
};
$scope.debugFilters = function () {
filtersDebuggerModal.open(topicName, $scope.subscription.filters, $scope.topicContentType)
.then(function (result) {
Expand All @@ -311,6 +323,9 @@ subscriptions.controller('SubscriptionController', ['SubscriptionRepository', 'S

$scope.trackingModeName = {"trackingOff": "No tracking", "discardedOnly": "Track message discarding only", "trackingAll": "Track everything"};

$scope.goToCostDetails = function () {
window.open($scope.costs.detailsUrl, '_blank');
};
}]);

subscriptions.controller('SubscriptionEditController', ['SubscriptionRepository', '$scope', '$uibModalInstance', 'subscription',
Expand Down
16 changes: 16 additions & 0 deletions hermes-console/static/js/console/topic/TopicController.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ topics.controller('TopicController', ['TOPIC_CONFIG', 'TopicRepository', 'TopicM
$scope.showHeadersFilter = subscriptionConfig.showHeadersFilter;
$scope.offlineRetransmissionEnabled = topicConfig.offlineRetransmissionEnabled;
$scope.iframeSource = "";
$scope.costs = {
enabled: window.config.costs.enabled,
iframeUrl: $sce.trustAsResourceUrl(resolveCostsUrl(window.config.costs.topicIframeUrl)),
detailsUrl: resolveCostsUrl(window.config.costs.topicDetailsUrl)
};

function resolveCostsUrl(template) {
if (template) {
return template.replace('{{topic_name}}', topicName);
}
return template;
}

topicRepository.get(topicName).then(function(topicWithSchema) {
$scope.topic = topicWithSchema;
Expand Down Expand Up @@ -288,6 +300,10 @@ topics.controller('TopicController', ['TOPIC_CONFIG', 'TopicRepository', 'TopicM
}
});
};

$scope.goToCostDetails = function () {
window.open($scope.costs.detailsUrl, '_blank');
};
}]);

topics.controller('TopicEditController', ['TOPIC_CONFIG', 'TopicRepository', '$scope', '$uibModalInstance', 'PasswordService',
Expand Down
7 changes: 6 additions & 1 deletion hermes-console/static/partials/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@
</div>

<div class="row" style="margin-bottom: 2em;">
<div class="col-md-6 col-md-offset-3">
<div class="col-md-{{costs.enabled ? 3 : 6}} col-md-offset-3">
<a class="btn btn-main btn-block" ng-href="#/groups">
<i class="fa fa-cogs"></i> Console
</a>
</div>
<div class="col-md-3" ng-if="costs.enabled">
<a class="btn btn-main btn-block" ng-href="{{costs.detailsUrl}}" target="_blank">
<i class="fa fa-money"></i> Costs
</a>
</div>
</div>

<div class="row" style="margin-bottom: 2em;">
Expand Down
13 changes: 13 additions & 0 deletions hermes-console/static/partials/subscription.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,19 @@ <h3 class="panel-title">Service response metrics</h3>
<p><strong><a ng-href="{{metricsUrls.networkErrors}}">Other network errors</a></strong></p>
</div>
</div>

<div class="panel panel-info" ng-if="costs.enabled">
<div class="panel-heading">
<div class="pull-right">
<button class="btn btn-primary btn-xs" ng-click="goToCostDetails()">Go to details</button>
</div>
<h3 class="panel-title">Costs</h3>
</div>
<div class="panel-body">
<iframe height="100%" width="100%" style="border: none;" ng-src="{{costs.iframeUrl}}"></iframe>
</div>
</div>

<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Manage subscription messages</h3>
Expand Down
11 changes: 11 additions & 0 deletions hermes-console/static/partials/topic.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ <h3 class="panel-title">Metrics</h3>
<p><strong><a ng-href="{{metricsUrls.messageSize}}">Message size</a></strong></p>
</div>
</div>
<div ng-if="costs.enabled" class="panel panel-info">
<div class="panel-heading">
<div class="pull-right">
<button class="btn btn-primary btn-xs" ng-click="goToCostDetails()">Go to details</button>
</div>
<h3 class="panel-title">Costs</h3>
</div>
<div class="panel-body">
<iframe height="100%" width="100%" style="border: none;" ng-src="{{costs.iframeUrl}}"></iframe>
</div>
</div>
</div>
<div class="col-md-6">
<div class="panel panel-default">
Expand Down
4 changes: 0 additions & 4 deletions hermes-frontend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ dependencies {
implementation group: 'commons-io', name: 'commons-io', version: '2.4'
implementation group: 'net.jodah', name: 'failsafe', version: versions.failsafe

compileOnly group: 'org.eclipse.jetty.alpn', name: 'alpn-api', version: versions.alpn_api

testImplementation group: 'org.eclipse.jetty.alpn', name: 'alpn-api', version: versions.alpn_api

testImplementation group: 'org.spockframework', name: 'spock-core', version: versions.spock
testImplementation group: 'org.apache.groovy', name: 'groovy-json', version: versions.groovy

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public GraphiteClient graphiteClient(@Qualifier("monitoringRestTemplate") RestTe
public VictoriaMetricsMetricsProvider prometheusMetricsProvider(PrometheusClient prometheusClient,
PrometheusMonitoringClientProperties properties) {
return new VictoriaMetricsMetricsProvider(prometheusClient,
properties.getConsumersMetricsPrefix(), properties.getFrontendMetricsPrefix());
properties.getConsumersMetricsPrefix(), properties.getFrontendMetricsPrefix(),
properties.getAdditionalFilters());
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public class PrometheusMonitoringClientProperties extends ExternalMonitoringClientProperties {
private String consumersMetricsPrefix = "hermes_consumers";
private String frontendMetricsPrefix = "hermes_frontend";
private String additionalFilters = "";

public String getConsumersMetricsPrefix() {
return consumersMetricsPrefix;
Expand All @@ -19,4 +20,12 @@ public String getFrontendMetricsPrefix() {
public void setFrontendMetricsPrefix(String frontendMetricsPrefix) {
this.frontendMetricsPrefix = frontendMetricsPrefix;
}

public String getAdditionalFilters() {
return additionalFilters;
}

public void setAdditionalFilters(String additionalFilters) {
this.additionalFilters = additionalFilters;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class ConsoleProperties {
private SubscriptionView subscription = new SubscriptionView();
private ConsistencyView consistency = new ConsistencyView();
private GroupView group = new GroupView();
private Costs costs = new Costs();

public Dashboard getDashboard() {
return dashboard;
Expand Down Expand Up @@ -82,6 +83,14 @@ public void setGroup(GroupView group) {
this.group = group;
}

public Costs getCosts() {
return costs;
}

public void setCosts(Costs costs) {
this.costs = costs;
}

public static final class Console {
private String title = "hermes console";
private String contactLink = "";
Expand Down Expand Up @@ -822,4 +831,61 @@ public void setMaxGroupBatchSize(int maxGroupBatchSize) {
this.maxGroupBatchSize = maxGroupBatchSize;
}
}

public static final class Costs {
private boolean enabled = false;
private String globalDetailsUrl = "";
private String topicIframeUrl = "";
private String topicDetailsUrl = "";
private String subscriptionIframeUrl = "";
private String subscriptionDetailsUrl = "";

public boolean isEnabled() {
return enabled;
}

public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

public String getTopicIframeUrl() {
return topicIframeUrl;
}

public void setTopicIframeUrl(String topicIframeUrl) {
this.topicIframeUrl = topicIframeUrl;
}

public String getGlobalDetailsUrl() {
return globalDetailsUrl;
}

public void setGlobalDetailsUrl(String globalDetailsUrl) {
this.globalDetailsUrl = globalDetailsUrl;
}

public String getTopicDetailsUrl() {
return topicDetailsUrl;
}

public void setTopicDetailsUrl(String topicDetailsUrl) {
this.topicDetailsUrl = topicDetailsUrl;
}

public String getSubscriptionIframeUrl() {
return subscriptionIframeUrl;
}

public void setSubscriptionIframeUrl(String subscriptionIframeUrl) {
this.subscriptionIframeUrl = subscriptionIframeUrl;
}

public String getSubscriptionDetailsUrl() {
return subscriptionDetailsUrl;
}

public void setSubscriptionDetailsUrl(String subscriptionDetailsUrl) {
this.subscriptionDetailsUrl = subscriptionDetailsUrl;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ public List<Subscription> getAllSubscriptions() {
.map(Topic::getName)
.map(this::listSubscriptions)
.flatMap(List::stream)
.map(Subscription::anonymize)
.collect(toList());
}

Expand Down
Loading

0 comments on commit ba2e4b4

Please sign in to comment.