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
7
7
8
8
## [ Unreleased] ( https://github.com/open-telemetry/opentelemetry-python/compare/v1.12.0rc1-0.31b0...HEAD )
9
9
10
+ - Fix instrument name and unit regexes
11
+ ([ #2796 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/2796 ) )
10
12
- 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 ) )
12
14
- Add min/max fields to Histogram
13
15
([ #2759 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/2759 ) )
14
16
- ` opentelemetry-exporter-otlp-proto-http ` Add support for OTLP/HTTP log exporter
Original file line number Diff line number Diff line change 18
18
from abc import ABC , abstractmethod
19
19
from dataclasses import dataclass
20
20
from logging import getLogger
21
- from re import ASCII
22
21
from re import compile as re_compile
23
22
from typing import (
24
23
Callable ,
39
38
40
39
_logger = getLogger (__name__ )
41
40
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}" )
44
43
45
44
46
45
@dataclass (frozen = True )
Original file line number Diff line number Diff line change @@ -571,6 +571,7 @@ def test_name_regex(self):
571
571
self .assertTrue (instrument ._check_name_and_unit ("a." , "unit" )[0 ])
572
572
self .assertTrue (instrument ._check_name_and_unit ("a-" , "unit" )[0 ])
573
573
self .assertTrue (instrument ._check_name_and_unit ("a_" , "unit" )[0 ])
574
+
574
575
self .assertFalse (instrument ._check_name_and_unit ("a" * 64 , "unit" )[0 ])
575
576
self .assertFalse (instrument ._check_name_and_unit ("Ñ" , "unit" )[0 ])
576
577
self .assertFalse (instrument ._check_name_and_unit ("_a" , "unit" )[0 ])
@@ -582,5 +583,7 @@ def test_unit_regex(self):
582
583
instrument = ChildInstrument ("name" )
583
584
584
585
self .assertTrue (instrument ._check_name_and_unit ("name" , "a" * 63 )[1 ])
586
+ self .assertTrue (instrument ._check_name_and_unit ("name" , "{a}" )[1 ])
587
+
585
588
self .assertFalse (instrument ._check_name_and_unit ("name" , "a" * 64 )[1 ])
586
589
self .assertFalse (instrument ._check_name_and_unit ("name" , "Ñ" )[1 ])
You can’t perform that action at this time.
0 commit comments