Skip to content

Commit d96f897

Browse files
mrm9084avaniguptaazure-sdk
authored
Merge App Config Provider Beta to Main (#38579)
* Revert "Remove Telemetry from main (#37783)" (#37812) This reverts commit a65dfb2. * Allocation Id (#37840) * Adding Telemetry * Telemetry Support * fixing formatting * Update _azureappconfigurationprovider.py * Update _azureappconfigurationproviderasync.py * formatting * changing doc style due to pylint-next * fixing kwargs docs * Formatting * Review comments * Changed label checking. * black format changes * pylint * Update sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationprovider.py Co-authored-by: Avani Gupta <[email protected]> * added space checks * Update conftest.py * moved telemetry to client wrapper * fixing format * updating after merge * fixing black issue * removing unused imports * AllocationId * Update CODEOWNERS * Update CODEOWNERS * fixing issues * Update _client_manager_base.py * Fixing configuration value empty in calc * fixing pylint * Update _constants.py * review comments * fixing allocation check * format fix --------- Co-authored-by: Avani Gupta <[email protected]> * Python Provider 2.0.0b2 Changelog update (#37860) * Update CHANGELOG.md * Update CHANGELOG.md * Increment package version after release of azure-appconfiguration-provider (#37877) * Update _client_manager_base.py (#38019) * App Config Allocation Id Update (#38065) * updated calc to sort keys * Update CHANGELOG.md * Allocation id update (#38242) * updated calc to sort keys * Update CHANGELOG.md * Update _client_manager_base.py * Update CHANGELOG.md (#38521) * Increment package version after release of azure-appconfiguration-provider (#38553) * Removing Allocation ID (#38555) * Removing Allocation ID * Remove constants * Update _client_manager_base.py --------- Co-authored-by: Avani Gupta <[email protected]> Co-authored-by: Azure SDK Bot <[email protected]>
1 parent 89a86d7 commit d96f897

File tree

7 files changed

+61
-8
lines changed

7 files changed

+61
-8
lines changed

.github/CODEOWNERS

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
# ServiceLabel: %App Configuration Provider
8888

8989
# PRLabel: %App Configuration Provider
90-
/sdk/appconfiguration/azure-appconfiguration-provider/ @mametcal @albertofori @avanigupta @mrm9084
90+
/sdk/appconfiguration/azure-appconfiguration-provider/ @albertofori @avanigupta @mrm9084 @rossgrambo
9191

9292
# ServiceLabel: %Attestation
9393
# PRLabel: %Attestation

sdk/appconfiguration/azure-appconfiguration-provider/CHANGELOG.md

+25-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,33 @@
11
# Release History
22

3-
## 2.0.0b2 (2024-09-12)
3+
## 2.0.0b4 (Unreleased)
4+
5+
### Features Added
6+
7+
### Breaking Changes
8+
9+
### Bugs Fixed
10+
11+
### Other Changes
12+
13+
## 2.0.0b3 (2024-11-13)
14+
15+
### Breaking Changes
16+
17+
* Allocation Id value changed so other providers can match the value.
18+
19+
## 2.0.0b2 (2024-10-11)
20+
21+
### Feature Added
22+
23+
* Added AllocationId to the feature flag telemetry metadata when the feature flag has telemetry enabled.
424

525
### Bugs Fixed
626

7-
* Fixing ETag to be "ETag" instead of "etag" in feature flag telemetry.
27+
* Fixed a number of cases where snake case was used instead of pascal case for feature flag telemetry.
28+
* etag -> ETag
29+
* feature_flag_reference -> FeatureFlagReference
30+
* feature_flag_id -> FeatureFlagId
831

932
## 2.0.0b1 (2024-09-11)
1033

sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_client_manager.py

+2
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ def load_feature_flags(
163163
loaded_feature_flags = []
164164
# Needs to be removed unknown keyword argument for list_configuration_settings
165165
kwargs.pop("sentinel_keys", None)
166+
endpoint = self._client._impl._config.endpoint # pylint: disable=protected-access
166167
filters_used: Dict[str, bool] = {}
167168
for select in feature_flag_selectors:
168169
feature_flags = self._client.list_configuration_settings(
@@ -176,6 +177,7 @@ def load_feature_flags(
176177

177178
feature_flag_value = json.loads(feature_flag.value)
178179

180+
self._feature_flag_telemetry(endpoint, feature_flag, feature_flag_value)
179181
self._feature_flag_appconfig_telemetry(feature_flag, filters_used)
180182

181183
loaded_feature_flags.append(feature_flag_value)

sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_client_manager_base.py

+28-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import hashlib
99
import base64
1010
from dataclasses import dataclass
11-
from typing import Dict, List
11+
from typing import Dict, List, Mapping, Any
1212
from azure.appconfiguration import ( # type:ignore # pylint:disable=no-name-in-module
1313
FeatureFlagConfigurationSetting,
1414
)
@@ -20,11 +20,18 @@
2020
PERCENTAGE_FILTER_KEY,
2121
TIME_WINDOW_FILTER_KEY,
2222
TARGETING_FILTER_KEY,
23+
TELEMETRY_KEY,
24+
METADATA_KEY,
25+
ETAG_KEY,
26+
FEATURE_FLAG_REFERENCE_KEY,
27+
FEATURE_FLAG_ID_KEY,
2328
)
2429

2530
FALLBACK_CLIENT_REFRESH_EXPIRED_INTERVAL = 3600 # 1 hour in seconds
2631
MINIMAL_CLIENT_REFRESH_INTERVAL = 30 # 30 seconds
2732

33+
JSON = Mapping[str, Any]
34+
2835

2936
@dataclass
3037
class _ConfigurationClientWrapperBase:
@@ -36,10 +43,28 @@ def _calculate_feature_id(key, label):
3643
if label and not label.isspace():
3744
basic_value += f"{label}"
3845
feature_flag_id_hash_bytes = hashlib.sha256(basic_value.encode()).digest()
39-
encoded_flag = base64.b64encode(feature_flag_id_hash_bytes)
40-
encoded_flag = encoded_flag.replace(b"+", b"-").replace(b"/", b"_")
46+
encoded_flag = base64.urlsafe_b64encode(feature_flag_id_hash_bytes)
4147
return encoded_flag[: encoded_flag.find(b"=")]
4248

49+
def _feature_flag_telemetry(
50+
self, endpoint: str, feature_flag: FeatureFlagConfigurationSetting, feature_flag_value: Dict
51+
):
52+
if TELEMETRY_KEY in feature_flag_value:
53+
if METADATA_KEY not in feature_flag_value[TELEMETRY_KEY]:
54+
feature_flag_value[TELEMETRY_KEY][METADATA_KEY] = {}
55+
feature_flag_value[TELEMETRY_KEY][METADATA_KEY][ETAG_KEY] = feature_flag.etag
56+
57+
if not endpoint.endswith("/"):
58+
endpoint += "/"
59+
feature_flag_reference = f"{endpoint}kv/{feature_flag.key}"
60+
if feature_flag.label and not feature_flag.label.isspace():
61+
feature_flag_reference += f"?label={feature_flag.label}"
62+
if feature_flag_value[TELEMETRY_KEY].get("enabled"):
63+
feature_flag_value[TELEMETRY_KEY][METADATA_KEY][FEATURE_FLAG_REFERENCE_KEY] = feature_flag_reference
64+
feature_flag_value[TELEMETRY_KEY][METADATA_KEY][FEATURE_FLAG_ID_KEY] = self._calculate_feature_id(
65+
feature_flag.key, feature_flag.label
66+
)
67+
4368
def _feature_flag_appconfig_telemetry(
4469
self, feature_flag: FeatureFlagConfigurationSetting, filters_used: Dict[str, bool]
4570
):

sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_constants.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919

2020
TELEMETRY_KEY = "telemetry"
2121
METADATA_KEY = "metadata"
22-
ETAG_KEY = "ETag"
2322

23+
ETAG_KEY = "ETag"
2424
FEATURE_FLAG_REFERENCE_KEY = "FeatureFlagReference"
2525
FEATURE_FLAG_ID_KEY = "FeatureFlagId"
26+
2627
PERCENTAGE_FILTER_NAMES = ["Percentage", "PercentageFilter", "Microsoft.Percentage", "Microsoft.PercentageFilter"]
2728
TIME_WINDOW_FILTER_NAMES = ["TimeWindow", "TimeWindowFilter", "Microsoft.TimeWindow", "Microsoft.TimeWindowFilter"]
2829
TARGETING_FILTER_NAMES = ["Targeting", "TargetingFilter", "Microsoft.Targeting", "Microsoft.TargetingFilter"]

sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# license information.
55
# -------------------------------------------------------------------------
66

7-
VERSION = "2.0.0b2"
7+
VERSION = "2.0.0b4"

sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/aio/_async_client_manager.py

+2
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ async def load_feature_flags(
165165
loaded_feature_flags = []
166166
# Needs to be removed unknown keyword argument for list_configuration_settings
167167
kwargs.pop("sentinel_keys", None)
168+
endpoint = self._client._impl._config.endpoint # pylint: disable=protected-access
168169
filters_used: Dict[str, bool] = {}
169170
for select in feature_flag_selectors:
170171
feature_flags = self._client.list_configuration_settings(
@@ -178,6 +179,7 @@ async def load_feature_flags(
178179

179180
feature_flag_value = json.loads(feature_flag.value)
180181

182+
self._feature_flag_telemetry(endpoint, feature_flag, feature_flag_value)
181183
self._feature_flag_appconfig_telemetry(feature_flag, filters_used)
182184

183185
loaded_feature_flags.append(feature_flag_value)

0 commit comments

Comments
 (0)