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

Bump future metric name length to 128 #3335

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/tests/cmd_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1575,7 +1575,7 @@ func TestMetricNameWarning(t *testing.T) {
t.Log(stdout)

logEntries := ts.LoggerHook.Drain()
expectedMsg := `Metric name should only include ASCII letters, numbers and underscores. This name will stop working in `
expectedMsg := `Metric name should only include up to 128 ASCII letters, numbers and/or underscores.`
filteredEntries := testutils.FilterEntries(logEntries, logrus.WarnLevel, expectedMsg)
require.Len(t, filteredEntries, 2)
// we do it this way as ordering is not guaranteed
Expand Down
6 changes: 4 additions & 2 deletions js/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ type Bundle struct {
// https://github.com/grafana/k6/issues/3065
func (b *Bundle) checkMetricNamesForPrometheusCompatibility() {
const (
nameRegexString = "^[a-zA-Z_][a-zA-Z0-9_]{1,63}$"
badNameWarning = "Metric name should only include ASCII letters, numbers and underscores. " +
// The name restrictions are the union of Otel and Prometheus naming restrictions, with the length restrictions of 128
// coming from old k6 restrictions where character set was way bigger though.
nameRegexString = "^[a-zA-Z_][a-zA-Z0-9_]{1,128}$"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
nameRegexString = "^[a-zA-Z_][a-zA-Z0-9_]{1,128}$"
nameRegexString = "^[a-zA-Z_][a-zA-Z0-9_]{1,255}$"

Is there a specific reason behind it? If not then I would prefer if we could keep it aligned with OTel.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that is the current limit in the registry. The place where this limit will go after this becomes an error instead of a warning.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My suggestion was about the size limit s/128/255/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is hte current limit - 128

const nameRegexString = "^[\\p{L}\\p{N}\\._ !\\?/&#\\(\\)<>%-]{1,128}$"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but I'm not still getting why we are not just bumping everything to 255. What is the reason to keep as 128? If there is one technical then I would like us adding a comment on the registry's regex explaining it. Prometheus doesn't have any limit and the OpenTelemetry limit is set to 255 so it sounds to me we should just match the OTel limit.

badNameWarning = "Metric name should only include up to 128 ASCII letters, numbers and/or underscores. " +
"This name will stop working in k6 v0.48.0 (around December 2023)."
)

Expand Down