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

add support for different label value types #12

Merged
merged 3 commits into from
Oct 10, 2023
Merged

Conversation

wazazaby
Copy link
Owner

@wazazaby wazazaby commented Oct 10, 2023

With this PR, we can set a bool, float or int as a label value using the corresponding builder methods.

It either uses strconv.Append... functions or append under the hood to be as fast as possible and to make fewer allocations possible.

Running benchmarks gives a solid 1 alloc/op for each test case :)

Example usage

var builder vimebu.Builder
builder.Metric("your_metric_name")
builder.Label("host", 1.2.3.4) // String.
builder.LabelBool("with_retry", true) // Boolean.
builder.LabelInt("val", 1234) // Int.
builder.LabelFloat("p", 123.456) // Float.
_ = builder.String() // your_metric_name{host="1.2.3.4",with_retry="true",val="1234",p="123.456"}

@wazazaby wazazaby added the enhancement New feature or request label Oct 10, 2023
@wazazaby wazazaby self-assigned this Oct 10, 2023
@wazazaby wazazaby changed the title Feature/label type add support for different label value types Oct 10, 2023
@wazazaby wazazaby marked this pull request as ready for review October 10, 2023 14:32
@wazazaby wazazaby merged commit 2a287bd into master Oct 10, 2023
@wazazaby wazazaby deleted the feature/label-type branch October 10, 2023 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant