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

Normalizing URL path: Replace #val with custom values/attributes #96

Open
girish7999 opened this issue Oct 4, 2021 · 1 comment
Open

Comments

@girish7999
Copy link

Current values using the 'express-prom-bundle' module:

attribute: path
Value:
"/api/v1/engagements/#val/features"
"/api/v1/engagements/#val"
"/api/v1/engagements/#val/data/workspace/assets/#val/unzip"

But we are expecting the metrics report to come up with the below values:

attribute: path
Value:
"/api/v1/engagements/{engagementId}/features"
"/api/v1/engagements/{engagementId"
"/api/v1/engagements/{engagementId}/data/workspace/assets/{assetId}/unzip"

I already tried the below normalizePath expressions:

normalizePath: [
['^/api/v1/engagements/./features', '/api/v1/engagements/{engagementId}/features'],
['^/api/v1/engagements/.
', '/api/v1/engagements/{engagementId}'],
]

@disjunction
Copy link
Collaborator

Formally right solution: normalizePath also takes the function and let's you do any custom replacement you like.

It will not work with the array of regex, because those replacements are matched against individual chunks. In your example if the path is: /api/v1/engagements/345472387234/features, then the path is split into chunks and then analyzsed?

  • api looks like an id? No
  • v1 looks like an id? No
  • engagements looks like an id? No
  • 345472387234 looks like an id? Yes! Replace it with regex. At this point you don't know what the preceding parts were

Actually right solution: don't customize anything. You're missing the point of this library. It's meant to work with an unknown paths and provide good results. So that when you add a new API tomorrow /api/v2/raccons/{racoonId}/furr-color it would still replace racoon IDs with #val without you need to touch anything. Look at your API. After /engagements there can be nothing else than engementId so replacing with {engementId}, #val or foobar will work just the same - provide one path for all possible ids.

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