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

Is it possible to override the normalizePath from the config? #15

Closed
ayashjorden opened this issue Jul 22, 2018 · 2 comments
Closed

Is it possible to override the normalizePath from the config? #15

ayashjorden opened this issue Jul 22, 2018 · 2 comments

Comments

@ayashjorden
Copy link

Hello,
In the documentation it says that one needs to override the original normalizePath function to add custom logic.

Is it possible to do so also by specifying a normalizePath key in the config passed to the promBundle function call?
for example: (my config, in the code i call promBundle(config.get("prometheus")))

    prometheus:
        includeMethod: true
        includePath: true
        promClient:
            collectDefaultMetrics:
                timeout: 1000
         normalizePath:
             '\/auth\/token\/.*$': '/auth/token/*' => this will get magically parsed and added to the paths-to-normalize

Thank you,
Yarden

@disjunction
Copy link
Collaborator

this sounds like a good idea. I'll see if i have time to code that. I would change the format though to:

...
normalizePath:
  - ^\/auth\/token\/(.*)$
  - ^\/people\/(.*)\/account\/(.*)$

each bracket would be converted to #val

@disjunction
Copy link
Collaborator

... on the second thought your suggestion is more flexible. I've implemented in v 4.1.0 (just published on npm). It's different from your suggestion in terms how the regexps are defined: it's all based on arrays instead of object with regex as a key.

See commit 5e0cd75

Example:

app.use(promBundle({
  normalizePath: [
     ['^/customer/.*', '/customer/#name'],
     ['^.*/order-list', '/#name/order-list']
  ]
}));

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

No branches or pull requests

2 participants