mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-01-30 04:40:41 +02:00
Increase instrument name maximum length from 63 to 255 characters (#4434)
This commit is contained in:
parent
a9552aaffa
commit
e9014a287c
@ -44,6 +44,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||
- Restrict `Meter`s in `go.opentelemetry.io/otel/sdk/metric` to only register and collect instruments it created. (#4333)
|
||||
- `PeriodicReader.Shutdown` and `PeriodicReader.ForceFlush` in `go.opentelemetry.io/otel/sdk/metric` now apply the periodic reader's timeout to the operation if the user provided context does not contain a deadline. (#4356, #4377)
|
||||
- Upgrade all use of `go.opentelemetry.io/otel/semconv` to use `v1.21.0`. (#4408)
|
||||
- Increase instrument name maximum length from 63 to 255 characters. (#4434)
|
||||
|
||||
### Removed
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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),
|
||||
},
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user