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

Update push gateway #966

Merged
merged 1 commit into from
Aug 28, 2020

Conversation

nklincoln
Copy link
Contributor

@nklincoln nklincoln commented Aug 27, 2020

Contributes to #637

Modifies the prometheus-push-tx-observer to use prom-client and push the same metrics as available if using scrape mechanism:

  • caliper_tx_submitted (counter)
  • caliper_tx_finished (counter)
  • caliper_tx_e2e_latency (histogram)

User may provide options for:

  • pushInterval
  • pushUrl
  • processMetricCollectInterval option
  • additional labels (applied to all metrics)
  • histogramBuckets override (explicit/linear/exponential)

Additionally, should a user provide runtime settings for basic auth, these may be used, with the following flags:

  • --caliper-auth-prometheuspush-username=bob
  • --caliper-auth-prometheuspush-password=secrets

It may be of interest to add the basic auth capability to the prometheus monitor

@nklincoln nklincoln force-pushed the update-push-gateway branch from c8bc86b to 1317b4d Compare August 27, 2020 11:21
const Constants = require('../../common/utils/constants');

const prometheus = require('prom-client');
const promGcStats = require('prometheus-gc-stats');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expand prom to prometheus

previouslySubmittedTotal: 0
};
const url = CaliperUtils.augmentUrlWithBasicAuth(options.pushUrl, Constants.AuthComponents.PushGateway);
this.prometheusClient = new prometheus.Pushgateway(url, null, this.registry);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a prometheus push gateway client ? might be worth naming the variable explicitly to say that


const express = require('express');
const appServer = express();
const promClient = require('prom-client');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would recommend expanding prom to prometheus

"fs-extra": "8.1.0",
"js-yaml": "^3.13.1",
"mustache": "^2.3.0",
"mqtt": "3.0.0",
"nconf": "^0.10.0",
"nconf-yaml": "^1.0.2",
"pidusage": "^1.1.6",
"prom-client": "^11.5.3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should these have the ^

describe('caliper utilities', () => {


describe('#augmentUrlWithBasicAuth', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would suggest providing a description rather than the name of the function

constructor(options, messenger, workerIndex) {
super(messenger, workerIndex);
this.metricPath = options.metricPath || '/metrics';
this.port = Number(options.port) || ConfigUtil.get(ConfigUtil.keys.Monitor.PrometheusScrapePort);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an inbound port or outbound port ? would be good if the variable was a bit more descriptive

this.defaultLabels.roundLabel = this.roundLabel;
this.registry.setDefaultLabels(this.defaultLabels);

const self = this;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is self necessary ? I thought javascript correctly handled it when using arrow functions

*/
txFinished(results) {
if (Array.isArray(results)) {
for (let result of results) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let -> const

describe('caliper utilities', () => {


describe('Using the static method "augmentUrlWithBasicAuth" to augment base URLs with basic auth', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would suggest either removing this describe altogether or changing it to
when augmenting the urls
We want to avoid putting implementation details into descriptions if possible and just describe the expected behaviour

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do, slowly adjusting to behavioural descriptions 😂

@nklincoln nklincoln force-pushed the update-push-gateway branch from c834e00 to 425899e Compare August 28, 2020 08:15
Copy link
Contributor

@davidkel davidkel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nklincoln nklincoln merged commit d9f2cc8 into hyperledger-caliper:master Aug 28, 2020
@nklincoln nklincoln deleted the update-push-gateway branch August 28, 2020 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants