Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit a7ebb74

Browse files
authored
Loosen ikey validation to follow GUID (#986)
1 parent 82379aa commit a7ebb74

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

contrib/opencensus-ext-azure/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
([#949](https://github.com/census-instrumentation/opencensus-python/pull/949))
1515
- Disable heartbeat metrics in exporters
1616
([#984](https://github.com/census-instrumentation/opencensus-python/pull/984))
17+
- Loosen instrumentation key validation to GUID
18+
([#984](https://github.com/census-instrumentation/opencensus-python/pull/984))
1719

1820
## 1.0.4
1921
Released 2020-06-29

contrib/opencensus-ext-azure/opencensus/ext/azure/common/transport.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ def _transmit(self, envelopes):
7676
except Exception:
7777
pass
7878
if response.status_code == 200:
79-
logger.info('Transmission succeeded: %s.', text)
8079
return 0
8180
if response.status_code == 206: # Partial Content
8281
if data:

contrib/opencensus-ext-azure/opencensus/ext/azure/common/utils.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,9 @@ def timestamp_to_iso_str(timestamp):
5858
return to_iso_str(datetime.datetime.utcfromtimestamp(timestamp))
5959

6060

61-
# Validate UUID format
62-
# Specs taken from https://tools.ietf.org/html/rfc4122
61+
# Validate GUID format
6362
uuid_regex_pattern = re.compile('^[0-9a-f]{8}-'
64-
'[0-9a-f]{4}-'
65-
'[1-5][0-9a-f]{3}-'
66-
'[89ab][0-9a-f]{3}-'
63+
'([0-9a-f]{4}-){3}'
6764
'[0-9a-f]{12}$')
6865

6966

contrib/opencensus-ext-azure/tests/test_azure_utils.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,14 @@ def test_invalid_key_section5_hex(self):
121121
self.assertRaises(ValueError,
122122
lambda: utils.validate_instrumentation_key(key))
123123

124-
def test_invalid_key_version(self):
125-
key = '1234abcd-5678-6efa-8abc-1234567890ab'
126-
self.assertRaises(ValueError,
127-
lambda: utils.validate_instrumentation_key(key))
124+
def test_valid_key_section2_hex(self):
125+
key = '1234abcd-567a-4efa-8abc-1234567890ab'
126+
self.assertIsNone(utils.validate_instrumentation_key(key))
128127

129-
def test_invalid_key_variant(self):
130-
key = '1234abcd-5678-4efa-2abc-1234567890ab'
131-
self.assertRaises(ValueError,
132-
lambda: utils.validate_instrumentation_key(key))
128+
def test_valid_key_section3_hex(self):
129+
key = '1234abcd-5678-befa-8abc-1234567890ab'
130+
self.assertIsNone(utils.validate_instrumentation_key(key))
131+
132+
def test_valid_key_section4_hex(self):
133+
key = '1234abcd-5678-4efa-cabc-1234567890ab'
134+
self.assertIsNone(utils.validate_instrumentation_key(key))

0 commit comments

Comments
 (0)