Skip to content

Commit 1e5d87f

Browse files
authored
Update Distributed Tracing sample (#1785)
Updated the Distributed Tracing Getting Started doc and sample function app.
1 parent babe19e commit 1e5d87f

File tree

3 files changed

+31
-51
lines changed

3 files changed

+31
-51
lines changed

samples/correlation-csharp/FunctionAppCorrelation/FunctionAppCorrelation.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@
1818
<None Update="host.json">
1919
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2020
</None>
21-
<None Update="local.settings.json.example">
22-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
23-
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
24-
</None>
2521
<None Update="local.settings.json">
2622
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2723
<CopyToPublishDirectory>Never</CopyToPublishDirectory>

samples/correlation-csharp/FunctionAppCorrelation/local.settings.json.example renamed to samples/correlation-csharp/FunctionAppCorrelation/local.settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"Values": {
44
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
55
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
6-
"APPINSIGHTS_INSTRUMENTATIONKEY": "<YOUR_APPINSGITHS_INSTRUMENTATIONKEY_HERE>"
6+
"APPINSIGHTS_INSTRUMENTATIONKEY": "<YOUR_APPINSIGHTS_INSTRUMENTATIONKEY_HERE>"
77
}
88
}

samples/correlation-csharp/getting-started.md

Lines changed: 30 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,38 @@ In this article, you use command-line tools to create a function app, then publi
88

99
# Create a function app
1010

11-
Go to Azure Portal, Click the cloud shell on the right top of the Azure Portal. Open Bash.
11+
Go to the [Azure Portal](https://ms.portal.azure.com/), click the cloud shell icon on the right top of the Azure Portal, and select Bash from the dropdown if it's not already selected.
1212

1313
![Cloud Shell](images/cloud-shell.png)
1414

1515
## Create a Resource Group
1616

17-
Create a resource group.
17+
Run the following commands to create a resource group.
1818

1919
```bash
20-
ResourceGroup=DurableFunctionsQucikstart-rg
20+
ResourceGroup=DurableFunctionsQuickstart-rg
2121
Location=westus
2222
az group create --name $ResourceGroup --location $Location
2323
```
2424
## Create a Storage Account
2525

26-
Create a storage account. The storage account name should be globally unique.
26+
Run the following commands to create a storage account. The storage account name should be globally unique.
2727

2828
```bash
2929
StorageAccountName=<STORAGE_NAME>
3030
az storage account create --name $StorageAccountName --location $Location --resource-group $ResourceGroup --sku Standard_LRS
3131
```
3232

33-
## Create an Application Insights
33+
## Create an Application Insights Resource
3434
FunctionAppName should be globally unique.
3535

3636
```bash
3737
az extension add -n application-insights
38-
FunctionAppName=<FUNCION_APP_NAME>
38+
FunctionAppName=<FUNCTION_APP_NAME>
3939
InstrumentationKey=`az monitor app-insights component create --app $FunctionAppName --location $Location --kind web -g $ResourceGroup --application-type web | jq .instrumentationKey | xargs`
4040
```
4141

42-
You can see your InstrumentationKey of the Application Insights. We'll use this key at the configuration part of the sample applications.
42+
`InstrumentationKey` now holds the Application Insights instrumentation key. We'll use this key when we configure the sample app's settings.
4343

4444
```bash
4545
echo $InstrumentationKey
@@ -52,78 +52,67 @@ echo $InstrumentationKey
5252
az functionapp create --resource-group $ResourceGroup --consumption-plan-location $Location --runtime dotnet --functions-version 3 --name $FunctionAppName --storage-account $StorageAccountName --app-insights $FunctionAppName --app-insights-key $InstrumentationKey
5353
```
5454

55-
**NOTE:** The samples targeting functions version 3. Distributed Tracing works for version 2 but not for version 1.
55+
**NOTE:** The samples target Functions version 3. Distributed Tracing doesn't work for Functions version 1.
5656

5757
# Publish samples
5858

59+
Run the following commands on your local machine in a terminal of your choice.
60+
These commands will clone the `azure-functions-durable-extension` repository and create a local branch where you can make modifications to local.settings.json and host.json before publishing.
61+
5962
```bash
6063
git clone [email protected]:Azure/azure-functions-durable-extension.git
6164
cd azure-functions-durable-extension
62-
git switch -c correlation origin/correlation
65+
git checkout -b "correlation-sample"
6366
```
6467

6568
## Open the .sln file
6669

67-
Go to `samples/correlation-csharp/` then open FunctionAppCorrelation.sln with Visual Studio 2019.
70+
Navigate to `samples/correlation-csharp/` then open FunctionAppCorrelation.sln with Visual Studio 2019.
6871

69-
## Create a local.settings.json
72+
## Modify local.settings.json
7073

71-
Create your `local.settings.json` for local execution.
72-
You can copy and modify `local.settings.json.example.` Set the Application Insights Key. If you are not familiar with the Application Insights key, refer to [Create an Application Insights resource](https://docs.microsoft.com/en-us/azure/azure-monitor/app/create-new-resource).
74+
Update the `APPINSIGHTS_INSTRUMENTATIONKEY` value in `local.settings.json` with the `InstrumentationKey` created earlier.
7375

7476
```json
7577
{
7678
"IsEncrypted": false,
7779
"Values": {
7880
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
7981
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
80-
"APPINSIGHTS_INSTRUMENTATIONKEY": "<YOUR_APPINSGITHS_INSTRUMENTATIONKEY_HERE>"
82+
"APPINSIGHTS_INSTRUMENTATIONKEY": "<YOUR_APPINSIGHTS_INSTRUMENTATIONKEY_HERE>"
8183
}
8284
}
8385
```
8486

8587
## host.json
8688

87-
Configure host.json. This JSON is the sample of the Distributed Tracing with the W3C trace context. Distributed Tracing is enabled by default. You need to configure the telemetry protocol. For more details, refer [reference](reference.md).
89+
Configure host.json. The host.json sample below enables Distributed Tracing and sets [W3C Trace Context](https://github.com/Azure/azure-functions-durable-extension/blob/dev/samples/correlation-csharp/reference.md#w3ctracecontext) as the tracing protocol. The default value for `distributedTracingProtocol` is [HttpCorrelationTraceContext](https://github.com/Azure/azure-functions-durable-extension/blob/dev/samples/correlation-csharp/reference.md#httpcorrelationtracecontext).
8890

8991
```json
9092
{
93+
"version": "2.0",
9194
"extensions": {
9295
"durableTask": {
9396
"tracing": {
94-
"DistributedTracingProtocol": "W3CTraceContext"
97+
"distributedTracingEnabled": true,
98+
"distributedTracingProtocol": "W3CTraceContext"
9599
}
96100
}
97101
},
98102
"logging": {
99103
"applicationInsights": {
100104
"httpAutoCollectionOptions": {
101105
"enableW3CDistributedTracing": true
102-
}
106+
}
103107
}
104-
},
105-
"version": "2.0"
108+
}
106109
}
107110
```
108111

109112
## Storage Emulator
110113
For the local execution, you need the [Strorage Emulator](https://docs.microsoft.com/en-us/azure/storage/common/storage-use-emulator). Download it from the link and execute it before you run the functions.
111114

112-
## Configure NuGet
113-
114-
Goto the Package source on Visual Studio. Right-click FunctionAppCorrelation project, select `Manage NuGet packages...`, then click the icon.
115-
116-
![NuGet Manager](images/nuget-manager.png)
117-
118-
Add Available package sources.
119-
NOTE: Distributed Tracing is pre-release. We currently use myget.org until it is going to GA.
120-
121-
Name: azure-appservice-staging
122-
Source: https://www.myget.org/F/azure-appservice-staging/api/v3/index.json
123-
124-
During pre-release, we use `Microsoft.Azure.WebJobs.Extensions.DurableTask.Telemetry` NuGet package start with Version `2.2.0-alpha`.
125-
126-
## Push the samples to the Function App
115+
## Publish the samples to the Function App
127116

128117
Right-click the `FunctionAppCorrelation` project, then select `Publish.`
129118

@@ -137,28 +126,23 @@ Then select the target function app. Then click `OK.`
137126

138127
## Run the samples
139128

140-
Refer to [the scenario](Readme.md#sample-scenario) that includes the samples. Some scenarios do not support distributed tracing. We'll support it in the future. For executing samples, call `HttpStart_*` functions as the endpoints.
141-
142-
If you can't pick one, you can try `/api/HttpStart_sampleOrchestration` on your FunctionApp. For the complex orchestration, try `/api/HttpStart_MultiLayerOrchestrationWithRetry`
143-
144-
Refer the [Sample scenario](Readme.md#sample-scenario).
129+
Refer to the [sample scenarios section](Readme.md#sample-scenario) to find a list of available scenarios and descriptions. Please note that all scenarios are not supported yet.
130+
To execute samples, call the `HttpStart_*` functions as the endpoints. For example, you can try sending a request to the `/api/HttpStart_SimpleOrchestration` endpoint of your Function App. To run a complex orchestration, try `/api/HttpStart_MultiLayerOrchestrationWithRetry`.
145131

146132
## Diagnose the Telemetry
147133

148-
Go to your Azure Portal, then go to your Application Insights resource.
149-
Click `Search` on your left list. Filter it with `Last 30 minutes` and `Event types: Request.` You can see the `Start Orchestration` request. Click it.
134+
To see the emitted telemetry, go to the Application Insights resource in the Azure Portal. You can easily find this by going to the `DurableFunctionsQuickstart-rg` resource group.
135+
Once you have navigated to the Application Insights resource, click `Transaction Search` in the menu. Filter it with `Last 30 minutes` and `Event types: Request.` Click on the `Start Orchestration` request or any request that starts with 'Dt'.
150136

151137
![Search](images/search.png)
152138

153-
Then You can see end-to-end tracing. Click and see how it correlates with each other.
139+
You can see the end-to-end tracing here. Click and see how it correlates with each other.
154140

155141
![End To End Tracing](images/end-to-end.png)
156142

157-
**NOTE:** When you see the correlation breaks, you might wait for a while. The request telemetry of the first orchestrator comes last.
143+
**NOTE:** If you see correlation breaks, you might have to wait for the telemetry to propagate to the Application Insights Resource. The request telemetry of the first orchestrator comes last.
158144

159145
# Next Steps
160146

161147
* [Configuration](configuration.md)
162-
* [Reference](reference.md)
163-
164-
148+
* [Reference](reference.md)

0 commit comments

Comments
 (0)