Skip to content

Commit

Permalink
Allow '/' character in instrument names
Browse files Browse the repository at this point in the history
  • Loading branch information
aabmass committed Sep 12, 2023
1 parent 69611bd commit b1e6bbf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions sdk/metric/meter.go
Expand Up @@ -28,7 +28,7 @@ import (

var (
// ErrInstrumentName indicates the created instrument has an invalid name.
// Valid names must consist of 255 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")
)

Expand Down Expand Up @@ -262,8 +262,8 @@ func validateInstrumentName(name string) error {
return nil
}
for _, c := range name[1:] {
if !isAlphanumeric(c) && c != '_' && c != '.' && c != '-' {
return fmt.Errorf("%w: %s: must only contain [A-Za-z0-9_.-]", ErrInstrumentName, name)
if !isAlphanumeric(c) && c != '_' && c != '.' && c != '-' && c != '/' {
return fmt.Errorf("%w: %s: must only contain [A-Za-z0-9_.-/]", ErrInstrumentName, name)
}
}
return nil
Expand Down
5 changes: 4 additions & 1 deletion sdk/metric/meter_test.go
Expand Up @@ -775,9 +775,12 @@ func TestValidateInstrumentName(t *testing.T) {
{
name: "nam.",
},
{
name: "nam/e",
},
{
name: "name!",
wantErr: fmt.Errorf("%w: name!: must only contain [A-Za-z0-9_.-]", ErrInstrumentName),
wantErr: fmt.Errorf("%w: name!: must only contain [A-Za-z0-9_.-/]", ErrInstrumentName),
},
{
name: longName,
Expand Down

0 comments on commit b1e6bbf

Please sign in to comment.