1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2026-06-03 18:35:08 +02:00

Increase instrument name maximum length from 63 to 255 characters (#4434)

This commit is contained in:
Tyler Yahn
2023-08-11 00:49:47 -07:00
committed by GitHub
parent a9552aaffa
commit e9014a287c
3 changed files with 11 additions and 5 deletions
+3 -3
View File
@@ -28,7 +28,7 @@ import (
var (
// ErrInstrumentName indicates the created instrument has an invalid name.
// Valid names must consist of 63 or fewer characters including alphanumeric, _, ., -, and start with a letter.
// Valid names must consist of 255 or fewer characters including alphanumeric, _, ., -, and start with a letter.
ErrInstrumentName = errors.New("invalid instrument name")
)
@@ -252,8 +252,8 @@ func validateInstrumentName(name string) error {
if len(name) == 0 {
return fmt.Errorf("%w: %s: is empty", ErrInstrumentName, name)
}
if len(name) > 63 {
return fmt.Errorf("%w: %s: longer than 63 characters", ErrInstrumentName, name)
if len(name) > 255 {
return fmt.Errorf("%w: %s: longer than 255 characters", ErrInstrumentName, name)
}
if !isAlpha([]rune(name)[0]) {
return fmt.Errorf("%w: %s: must start with a letter", ErrInstrumentName, name)
+7 -2
View File
@@ -743,6 +743,11 @@ func TestMeterCreatesInstrumentsValidations(t *testing.T) {
}
func TestValidateInstrumentName(t *testing.T) {
const longName = "longNameOver255characters" +
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
testCases := []struct {
name string
@@ -776,8 +781,8 @@ func TestValidateInstrumentName(t *testing.T) {
wantErr: fmt.Errorf("%w: name!: must only contain [A-Za-z0-9_.-]", ErrInstrumentName),
},
{
name: "someverylongnamewhichisover63charactersbutallofwhichmatchtheregexp",
wantErr: fmt.Errorf("%w: someverylongnamewhichisover63charactersbutallofwhichmatchtheregexp: longer than 63 characters", ErrInstrumentName),
name: longName,
wantErr: fmt.Errorf("%w: %s: longer than 255 characters", ErrInstrumentName, longName),
},
}