Skip to content

Commit 77857fe

Browse files
committed
updated comments and made parameters Optional
1 parent f283f82 commit 77857fe

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

azure/durable_functions/models/DurableOrchestrationClient.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ async def start_new(self,
4848
orchestration_function_name: str,
4949
instance_id: Optional[str] = None,
5050
client_input: Optional[Any] = None,
51-
trace_parent: str = None,
52-
trace_state: str = None) -> str:
51+
trace_parent: Optional[str] = None,
52+
trace_state: Optional[str] = None) -> str:
5353
"""Start a new instance of the specified orchestrator function.
5454
5555
If an orchestration instance with the specified ID already exists, the
@@ -64,6 +64,10 @@ async def start_new(self,
6464
the Durable Functions extension will generate a random GUID (recommended).
6565
client_input : Optional[Any]
6666
JSON-serializable input value for the orchestrator function.
67+
trace_parent : str
68+
The traceparent header to send with the request.
69+
trace_state : str
70+
The tracestate header to send with the request.
6771
6872
Returns
6973
-------

azure/durable_functions/models/utils/http_utils.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,23 @@ async def post_async_request(url: str, data: Any = None, trace_parent: str = Non
1212
url to make the post to
1313
data: Any
1414
object to post
15+
trace_parent: str
16+
traceparent header to send with the request
17+
trace_state: str
18+
tracestate header to send with the request
1519
1620
Returns
1721
-------
1822
[int, Any]
1923
Tuple with the Response status code and the data returned from the request
2024
"""
2125
async with aiohttp.ClientSession() as session:
22-
async with session.post(url,
23-
json=data,
24-
headers={
25-
"traceparent": trace_parent,
26-
"tracestate": trace_state
27-
}) as response:
26+
headers = {}
27+
if trace_parent:
28+
headers["traceparent"] = trace_parent
29+
if trace_state:
30+
headers["tracestate"] = trace_state
31+
async with session.post(url, json=data, headers=headers) as response:
2832
# We disable aiohttp's input type validation
2933
# as the server may respond with alternative
3034
# data encodings. This is potentially unsafe.

0 commit comments

Comments
 (0)