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

WIP: prometheus client integration #283

Closed
wants to merge 1 commit into from
Closed

WIP: prometheus client integration #283

wants to merge 1 commit into from

Conversation

helio-frota
Copy link
Member

@helio-frota helio-frota commented Mar 13, 2019

This is not working for now.
An weird behavior needs to be investigated when calling require('prom-client').
I'm going to push the changes on this PR to share what is happening.

Error here

Connects to: #247

@helio-frota helio-frota requested a review from lance March 13, 2019 19:20
@helio-frota
Copy link
Member Author

After comment the require('prom-client') the error is gone but of course the build is broken since we don't have the client. here

Now I'm using ES6 class approach and not able to run npm link to move forward.

I deleted my previous approach using functions but was totally wrong anyway.

For example if we create a file foo.js with the content:

const client = require('prom-client');
console.log(client);

The build passes

@helio-frota
Copy link
Member Author

Probably need to add/update webpack configuration since the error is common related.

Copy link
Member

@lance lance left a comment

Choose a reason for hiding this comment

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

Good start. I've suggested a couple of metrics that we want to track, but you should look at the metrics collected in Status and in the long run, hystrixFormatter.

@helio-frota
Copy link
Member Author

@lance Thanks for the suggestions and review. 👍

@helio-frota
Copy link
Member Author

Now able to run the build locally, let's see what happen on CI.
After struggling for a good time trying to create a solution with multiple targets I decided to try it using two separated webpack configuration files.

@helio-frota
Copy link
Member Author

Build failed with tests but at least a progress.

@helio-frota
Copy link
Member Author

Using the webpack.DefinePlugin + ignoring the file prometheus-metrics.js we are able to add checks on the code to avoid the usage

new webpack.DefinePlugin({
  WEB: JSON.stringify(true)
})
if (!WEB) {
  const PrometheusMetrics = require('./prometheus-metrics');
}
const Semaphore = require('./semaphore');

And to add that checks on every part of the project that uses prometheus-metrics file. Using this we are able to run the browser tests but besides the ugly checks on the code we get with error on the node test:

showing the browser test finished and starting the node test with failures:

# CircuitBreaker semaphore rate limiting
ok 209 Semaphore rejection status incremented
ok 210 Semaphore was locked
# CircuitBreaker default capacity
ok 211 should be equal

1..211
# tests 211
# pass  211

# ok

✔ ~/Desktop/opossum [prometheus-client L|✚ 2] 
17:23 $ npm run test

> opossum@1.11.0 pretest /home/hf/Desktop/opossum
> npm run lint && npm run build:browser


> opossum@1.11.0 lint /home/hf/Desktop/opossum
> semistandard examples/*/*.js test/*.js index.js lib/*.js

semistandard: Semicolons For All! (https://github.com/Flet/semistandard)
  /home/hf/Desktop/opossum/lib/circuit.js:6:6: 'WEB' is not defined.
  /home/hf/Desktop/opossum/lib/circuit.js:7:9: 'PrometheusMetrics' is assigned a value but never used.
  /home/hf/Desktop/opossum/lib/circuit.js:164:10: 'WEB' is not defined.
  /home/hf/Desktop/opossum/lib/circuit.js:165:38: 'PrometheusMetrics' is not defined.
  /home/hf/Desktop/opossum/lib/circuit.js:213:10: 'WEB' is not defined.
  /home/hf/Desktop/opossum/lib/circuit.js:285:10: 'WEB' is not defined.

@helio-frota
Copy link
Member Author

While this is not an elegant solution IMO. It was able to run both browser and node tests locally. Let's see what happen on CI.

@helio-frota helio-frota requested a review from lance March 19, 2019 18:59
@helio-frota
Copy link
Member Author

Things I think need to be revisited/review/agreed/improved:

  • Webpack configuration approach on build:node and build:browser
  • Probably to install opossum via github instead to release canary version for every change
  • To use (a fork) the example to verify the results
  • Currently we can see the metrics circuit_open and circuit_fired inside prometheus running on minishift but for some reason they are not increasing (on the graph) the values after run the bench test.

2019-04-03_11-38

The current dev workflow for this:

  1. make changes on opossum
  2. release canary version
  3. deploy example app
  4. run the bench
  5. verify the results on prometheus web interface running on minishift (setup/config based on the example app)

@helio-frota
Copy link
Member Author

                      === npm audit security report ===                        
                                                                                
┌──────────────────────────────────────────────────────────────────────────────┐
│                                Manual Review                                 │
│            Some vulnerabilities require your attention to resolve            │
│                                                                              │
│         Visit https://go.npm.me/audit-guide for additional guidance          │
└──────────────────────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Moderate      │ Regular Expression Denial of Service                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ marked                                                       │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ >=0.6.2                                                      │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ jsdoc [dev]                                                  │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ jsdoc > marked                                               │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://npmjs.com/advisories/812                             │
└───────────────┴──────────────────────────────────────────────────────────────┘

@lance can we remove jsdoc? One of the deps has vulnerability.

@lance
Copy link
Member

lance commented Apr 24, 2019

@helio-frota we already have an issue for this #289

Adds Prometheus metrics to the circuit. As a result,
of limitiations with names in Prometheus, this also
normalizes all circuit event names to camelCase.
@lance
Copy link
Member

lance commented Apr 30, 2019

Closing this. Duplicated in #313

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