Skip to content

Commit a2ca265

Browse files
authored
Merge branch 'dev' into andystaples/add-unit-testing-change
2 parents 55886db + 7d1a993 commit a2ca265

File tree

6 files changed

+56
-14
lines changed

6 files changed

+56
-14
lines changed

CODEOWNERS

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,4 @@
99
# For all file changes, github would automatically include the following people in the PRs.
1010
#
1111

12-
* @nytian
13-
* @bachuv
14-
* @andystaples
15-
* @cgillum
12+
* @nytian @cgillum @bachuv @andystaples

CONTRIBUTING.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,30 @@ pip install -e $REPOSITORY_ROOT/
123123
```
124124
where REPOSITORY_ROOT is the root folder of the azure-functions-durable-python repository
125125

126-
7. Set breakpoints and click Run -> Start Debugging in VS Code. This should internally start the Azure Function using `func host start` command.
126+
7. Set breakpoints and click Run -> Start Debugging in VS Code. This should internally start the Azure Function using `func host start` command. If the breakpoints are not getting hit, check to make sure that you have set `justMyCode: false` in the function app's .vscode/launch.json.
127+
128+
```
129+
{
130+
"version": "0.2.0",
131+
"configurations": [
132+
{
133+
...
134+
"justMyCode": false
135+
...
136+
}
137+
]
138+
}
139+
```
127140

128141
### Debugging end-to-end
129142

130143
If you want to debug into the Durable Task or any of the .NET bits, follow instructions below:
131144

132-
1. Open the Azure Storage Explorer and connect to the local storage emulator or the storage account you are using.
133-
2. Make sure the Durable Python debugging is setup already and the debugger has started the `func` process.
134-
3. In the VSCode editor for DurableTask, click Debug -> .NET Core Attach Process and search for `func host start` process and attach to it.
135-
4. Add a breakpoint in both editors and continue debugging.
145+
1. If you would like to debug a custom local WebJobs extension package then create the custom package, place it in a local directory, and then run `func extensions install --package Microsoft.Azure.WebJobs.Extensions.DurableTask --version <VERSION>`. If you update the version while debugging and the new version doesn't get picked up, then try running `func extensions install` to get the new changes.
146+
2. Open the Azure Storage Explorer and connect to the local storage emulator or the storage account you are using.
147+
3. Make sure the Durable Python debugging is setup already and the debugger has started the `func` process.
148+
4. In the VSCode editor for DurableTask, click Debug -> .NET Core Attach Process, search for `func host start` process and attach to it. If you are using Visual Studio, click Debug -> Attach to Process, search for the `func` process and attach to it.
149+
5. Add a breakpoint in both editors and continue debugging.
136150

137151
## Testing changes locally (Windows)
138152

azure/durable_functions/models/DurableOrchestrationClient.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from time import time
55
from asyncio import sleep
66
from urllib.parse import urlparse, quote
7+
from opentelemetry import trace
78

89
import azure.functions as func
910

@@ -71,8 +72,25 @@ async def start_new(self,
7172
request_url = self._get_start_new_url(
7273
instance_id=instance_id, orchestration_function_name=orchestration_function_name)
7374

75+
# Get the current span
76+
current_span = trace.get_current_span()
77+
span_context = current_span.get_span_context()
78+
79+
# Get the traceparent and tracestate from the span context
80+
# Follows the W3C Trace Context specification for traceparent
81+
# https://www.w3.org/TR/trace-context/#traceparent-header
82+
trace_id = format(span_context.trace_id, '032x')
83+
span_id = format(span_context.span_id, '016x')
84+
trace_flags = format(span_context.trace_flags, '02x')
85+
trace_parent = f"00-{trace_id}-{span_id}-{trace_flags}"
86+
87+
trace_state = span_context.trace_state
88+
7489
response: List[Any] = await self._post_async_request(
75-
request_url, self._get_json_input(client_input))
90+
request_url,
91+
self._get_json_input(client_input),
92+
trace_parent,
93+
trace_state)
7694

7795
status_code: int = response[0]
7896
if status_code <= 202 and response[1]:

azure/durable_functions/models/utils/http_utils.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
import aiohttp
44

55

6-
async def post_async_request(url: str, data: Any = None) -> List[Union[int, Any]]:
6+
async def post_async_request(url: str,
7+
data: Any = None,
8+
trace_parent: str = None,
9+
trace_state: str = None) -> List[Union[int, Any]]:
710
"""Post request with the data provided to the url provided.
811
912
Parameters
@@ -12,15 +15,23 @@ async def post_async_request(url: str, data: Any = None) -> List[Union[int, Any]
1215
url to make the post to
1316
data: Any
1417
object to post
18+
trace_parent: str
19+
traceparent header to send with the request
20+
trace_state: str
21+
tracestate header to send with the request
1522
1623
Returns
1724
-------
1825
[int, Any]
1926
Tuple with the Response status code and the data returned from the request
2027
"""
2128
async with aiohttp.ClientSession() as session:
22-
async with session.post(url,
23-
json=data) as response:
29+
headers = {}
30+
if trace_parent:
31+
headers["traceparent"] = trace_parent
32+
if trace_state:
33+
headers["tracestate"] = trace_state
34+
async with session.post(url, json=data, headers=headers) as response:
2435
# We disable aiohttp's input type validation
2536
# as the server may respond with alternative
2637
# data encodings. This is potentially unsafe.

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ furl==2.1.0
1111
pytest-asyncio==0.20.2
1212
autopep8
1313
types-python-dateutil
14+
opentelemetry-api==1.32.1
15+
opentelemetry-sdk==1.32.1

tests/models/test_DurableOrchestrationClient.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ async def delete(self, url: str):
6767
assert url == self._expected_url
6868
return self._response
6969

70-
async def post(self, url: str, data: Any = None):
70+
async def post(self, url: str, data: Any = None, trace_parent: str = None, trace_state: str = None):
7171
assert url == self._expected_url
7272
return self._response
7373

0 commit comments

Comments
 (0)