Skip to content

Commit

Permalink
feat: identificaiton headers
Browse files Browse the repository at this point in the history
  • Loading branch information
Tymek committed Jan 27, 2025
1 parent 9847b43 commit 63ae07e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions UnleashClient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
METRIC_LAST_SENT_TIME,
REQUEST_RETRIES,
REQUEST_TIMEOUT,
SDK_NAME,
SDK_VERSION,
)
from UnleashClient.events import UnleashEvent, UnleashEventType
from UnleashClient.loader import load_features
Expand Down Expand Up @@ -108,6 +110,7 @@ def __init__(
self.unleash_app_name = app_name
self.unleash_environment = environment
self.unleash_instance_id = instance_id
self.unleash_connection_id = str(uuid.uuid4())
self.unleash_refresh_interval = refresh_interval
self.unleash_request_timeout = request_timeout
self.unleash_request_retries = request_retries
Expand Down Expand Up @@ -211,12 +214,19 @@ def initialize_client(self, fetch_toggles: bool = True) -> None:
if not self.is_initialized:
# pylint: disable=no-else-raise
try:
headers = { # SDK identification headers
**self.unleash_custom_headers,
"x-unleash-connection-id": self.unleash_connection_id,
"x-unleash-appname": self.unleash_app_name,
"x-unleash-sdk": f"{SDK_NAME}:{SDK_VERSION}",
}

# Setup
metrics_args = {
"url": self.unleash_url,
"app_name": self.unleash_app_name,
"instance_id": self.unleash_instance_id,
"custom_headers": self.unleash_custom_headers,
"custom_headers": headers,
"custom_options": self.unleash_custom_options,
"request_timeout": self.unleash_request_timeout,
"engine": self.engine,
Expand All @@ -229,7 +239,7 @@ def initialize_client(self, fetch_toggles: bool = True) -> None:
self.unleash_app_name,
self.unleash_instance_id,
self.unleash_metrics_interval,
self.unleash_custom_headers,
headers,
self.unleash_custom_options,
self.strategy_mapping,
self.unleash_request_timeout,
Expand All @@ -240,7 +250,7 @@ def initialize_client(self, fetch_toggles: bool = True) -> None:
"url": self.unleash_url,
"app_name": self.unleash_app_name,
"instance_id": self.unleash_instance_id,
"custom_headers": self.unleash_custom_headers,
"custom_headers": headers,
"custom_options": self.unleash_custom_options,
"cache": self.cache,
"engine": self.engine,
Expand Down

0 comments on commit 63ae07e

Please sign in to comment.