File tree Expand file tree Collapse file tree 3 files changed +8
-4
lines changed
src/opentelemetry/metrics/_internal Expand file tree Collapse file tree 3 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -7,8 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
88## [ Unreleased] ( https://github.com/open-telemetry/opentelemetry-python/compare/v1.12.0rc1-0.31b0...HEAD )
99
10+ - Fix instrument name and unit regexes
11+ ([ #2796 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/2796 ) )
1012- Add optional sessions parameter to all Exporters leveraging requests.Session
11- ([ #2783 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/2783 ) )
13+ ([ #2783 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/2783 ) )
1214- Add min/max fields to Histogram
1315 ([ #2759 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/2759 ) )
1416- ` opentelemetry-exporter-otlp-proto-http ` Add support for OTLP/HTTP log exporter
Original file line number Diff line number Diff line change 1818from abc import ABC , abstractmethod
1919from dataclasses import dataclass
2020from logging import getLogger
21- from re import ASCII
2221from re import compile as re_compile
2322from typing import (
2423 Callable ,
3938
4039_logger = getLogger (__name__ )
4140
42- _name_regex = re_compile (r"[a-zA-Z][-.\w ]{0,62}" , ASCII )
43- _unit_regex = re_compile (r"\w {0,63}" , ASCII )
41+ _name_regex = re_compile (r"[a-zA-Z][-_.a-zA-Z0-9 ]{0,62}" )
42+ _unit_regex = re_compile (r"[\x00-\x7F] {0,63}" )
4443
4544
4645@dataclass (frozen = True )
Original file line number Diff line number Diff line change @@ -571,6 +571,7 @@ def test_name_regex(self):
571571 self .assertTrue (instrument ._check_name_and_unit ("a." , "unit" )[0 ])
572572 self .assertTrue (instrument ._check_name_and_unit ("a-" , "unit" )[0 ])
573573 self .assertTrue (instrument ._check_name_and_unit ("a_" , "unit" )[0 ])
574+
574575 self .assertFalse (instrument ._check_name_and_unit ("a" * 64 , "unit" )[0 ])
575576 self .assertFalse (instrument ._check_name_and_unit ("Ñ" , "unit" )[0 ])
576577 self .assertFalse (instrument ._check_name_and_unit ("_a" , "unit" )[0 ])
@@ -582,5 +583,7 @@ def test_unit_regex(self):
582583 instrument = ChildInstrument ("name" )
583584
584585 self .assertTrue (instrument ._check_name_and_unit ("name" , "a" * 63 )[1 ])
586+ self .assertTrue (instrument ._check_name_and_unit ("name" , "{a}" )[1 ])
587+
585588 self .assertFalse (instrument ._check_name_and_unit ("name" , "a" * 64 )[1 ])
586589 self .assertFalse (instrument ._check_name_and_unit ("name" , "Ñ" )[1 ])
You can’t perform that action at this time.
0 commit comments