From 4b2c51923061aae05d056c7836da8107c36e86be Mon Sep 17 00:00:00 2001 From: Aaron Abbott Date: Tue, 12 Sep 2023 15:50:45 +0000 Subject: [PATCH 1/3] Allow '/' character in instrument names --- sdk/metric/meter.go | 6 +++--- sdk/metric/meter_test.go | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/sdk/metric/meter.go b/sdk/metric/meter.go index 9d2de67c594..e5ec1ad4675 100644 --- a/sdk/metric/meter.go +++ b/sdk/metric/meter.go @@ -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") ) @@ -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 diff --git a/sdk/metric/meter_test.go b/sdk/metric/meter_test.go index 7c1d21f96cd..34a95ab7026 100644 --- a/sdk/metric/meter_test.go +++ b/sdk/metric/meter_test.go @@ -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, From 52f3e188cb452b31802ca3a2f957f53a8c184556 Mon Sep 17 00:00:00 2001 From: Aaron Abbott Date: Tue, 12 Sep 2023 15:56:44 +0000 Subject: [PATCH 2/3] Add changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5734521026..b3d0f56c606 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [Unreleased] +- Allow '/' characters in metric instrument names. (#4501) + ## [1.18.0/0.41.0/0.0.6] 2023-09-12 This release drops the compatibility guarantee of [Go 1.19]. From 936a8c4239457db9671eae23a07303d81be27962 Mon Sep 17 00:00:00 2001 From: Aaron Abbott Date: Tue, 12 Sep 2023 12:50:04 -0400 Subject: [PATCH 3/3] Update CHANGELOG.md Co-authored-by: Tyler Yahn --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3d0f56c606..7e264600fd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [Unreleased] +### Changed + - Allow '/' characters in metric instrument names. (#4501) ## [1.18.0/0.41.0/0.0.6] 2023-09-12