Skip to content

Commit

Permalink
Update logic for checking graph urls
Browse files Browse the repository at this point in the history
  • Loading branch information
samwelkanda committed Jun 17, 2021
1 parent 22622bf commit 8b86e24
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions msgraph/core/middleware/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
from .._enums import NationalClouds
from .middleware import BaseMiddleware

ENDPOINTS = {
NationalClouds.China, NationalClouds.Germany, NationalClouds.Global, NationalClouds.US_DoD,
NationalClouds.US_GOV
}


class TelemetryHandler(BaseMiddleware):
"""Middleware component that attaches metadata to a Graph request in order to help
Expand All @@ -30,12 +25,14 @@ def send(self, request, **kwargs):
def is_graph_url(self, url):
"""Check if the request is made to a graph endpoint. We do not add telemetry headers to
non-graph endpoints"""
endpoints = set(item.value for item in NationalClouds)

base_url = parse_url(url)
endpoint = "{}://{}".format(
base_url.scheme,
base_url.netloc,
)
return endpoint in ENDPOINTS
return endpoint in endpoints

def _add_client_request_id_header(self, request) -> None:
"""Add a client-request-id header with GUID value to request"""
Expand Down

0 comments on commit 8b86e24

Please sign in to comment.