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

Allow for scoping of auto marking #25

Open
domtronn opened this issue Jul 8, 2019 · 0 comments
Open

Allow for scoping of auto marking #25

domtronn opened this issue Jul 8, 2019 · 0 comments

Comments

@domtronn
Copy link
Contributor

domtronn commented Jul 8, 2019

The automark functionality should be allowed to take a scope to be used in different areas of the application, rather than just once on access.

e.g.

[
  {
    "name": "total_upstream_requests",
    "help": "A count of the upstream calls with cache hits",
    "type": "Gauge",
    "mark": {
      "id":"cache",
      "method":"set",
      "path":["cache", "size"]
     }
  },
  {
    "name": "http_request_duration_hist_seconds",
    "help": "The response time of requests",
    "type": "Histogram",
    "labelNames": [
      { "key": "method", "path": [ "req", "method" ] },
      { "key": "code", "path": [ "res", "status" ] },
      { "key": "path", "path": [ "_matchedRoute" ] }
    ],
    "mark": {
      "id": "access",
      "method": "observe",
      "path": [ "res", "responseTime" ]
    },
    "buckets": {
      "type": "linear",
      "start": 40,
      "buckets": 15,
      "factor": 40
    }
  }
]

This declare to metrics that will be marked given different contexts, one on access and one when interacting with the cache, you could call them with

meters.automark('cache', cache)
meters.automark('access', ctx)

One of the main concerns would be how to make this backwards compatible for when no id / namespace is defined.

domtronn added a commit that referenced this issue Jul 10, 2019
Now you will have `ctx.state.meters.automark[scope](ctx)` for you to
declare multiple scopes using the `id` of the `mark` block.

This will retain the API for meters that don't have a scope id by
keeping the `ctx.state.meters.automark` as a function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant