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

Store clean metric name separately #691

Open
npazosmendez opened this issue Sep 12, 2022 · 0 comments
Open

Store clean metric name separately #691

npazosmendez opened this issue Sep 12, 2022 · 0 comments

Comments

@npazosmendez
Copy link
Collaborator

This idea came out of the following discussion: #686 (comment)

The problem

Some functions need the name of the metric clean from function names (usually to split it into nodes). For example:

metricTags := arg.Tags
nodes := strings.Split(metricTags["name"], ".")

The problem is that the "name" is not always clean from functions. For example: https://github.com/graphite-project/graphite-web/blob/ed08fa4e2f6526ae11e55f88f70d0b6d36e4052f/webapp/graphite/render/functions.py#L243-L249 . In that case, strings.Split("sumSeries(foo.bar)", ".") returns "sumSeries(foo", "bar)", which is not the wanted nodes.

The first (currently implemented) solution for this is to call ExtractNameTag when the clean metric name is needed: https://github.com/grafana/carbonapi/blob/7b2a1ee8bfcba3bb1aba9619dc2f39d3cf9622c0/expr/helper/helper.go#L95-L96 (at time of writing, this is close to being merged here). But we want to avoid calling this function because:

  • It can affect performance and it's avoidable
  • The function is complex and error-prone, especially when all symbols are supported in metric names

The solution

The proposed solution is to have a separate private field in the MetricData struct to store the metric name clean from function names, so it's taken from there whenever it is needed.

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