Skip to content

Commit

Permalink
End-to-end trace correlation support in DT.Core and DT.AzureStorage (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
cgillum committed Nov 11, 2020
1 parent 429065f commit 43e3f96
Show file tree
Hide file tree
Showing 74 changed files with 5,424 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ Icon?
ehthumbs.db
Thumbs.db
.vs/

# Publish Web output #
######################
PublishProfiles/
13 changes: 12 additions & 1 deletion DurableTask.sln
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DurableTask.SqlServer", "sr
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DurableTask.SqlServer.Tests", "test\DurableTask.SqlServer.Tests\DurableTask.SqlServer.Tests.csproj", "{B835BFA6-D9BB-47C4-8594-38EAE0157BBA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Correlation.Samples", "samples\Correlation.Samples\Correlation.Samples.csproj", "{5F88FF6A-E908-4341-89D6-FA530793077A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -239,6 +241,14 @@ Global
{B835BFA6-D9BB-47C4-8594-38EAE0157BBA}.Release|Any CPU.Build.0 = Release|Any CPU
{B835BFA6-D9BB-47C4-8594-38EAE0157BBA}.Release|x64.ActiveCfg = Release|Any CPU
{B835BFA6-D9BB-47C4-8594-38EAE0157BBA}.Release|x64.Build.0 = Release|Any CPU
{5F88FF6A-E908-4341-89D6-FA530793077A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5F88FF6A-E908-4341-89D6-FA530793077A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5F88FF6A-E908-4341-89D6-FA530793077A}.Debug|x64.ActiveCfg = Debug|Any CPU
{5F88FF6A-E908-4341-89D6-FA530793077A}.Debug|x64.Build.0 = Debug|Any CPU
{5F88FF6A-E908-4341-89D6-FA530793077A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5F88FF6A-E908-4341-89D6-FA530793077A}.Release|Any CPU.Build.0 = Release|Any CPU
{5F88FF6A-E908-4341-89D6-FA530793077A}.Release|x64.ActiveCfg = Release|Any CPU
{5F88FF6A-E908-4341-89D6-FA530793077A}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -266,9 +276,10 @@ Global
{1D52F94E-933C-411F-96C4-4960B423586F} = {C53918E6-667A-4930-837C-0018C5D6E374}
{C9F84589-3F2B-4D58-A995-BC169D16217F} = {DBCD161C-D409-48E5-924E-9B7FA1C36B84}
{B835BFA6-D9BB-47C4-8594-38EAE0157BBA} = {95C69A06-7F62-4652-A480-207B614C2869}
{5F88FF6A-E908-4341-89D6-FA530793077A} = {AF4E71A6-B16E-4488-B22D-2761101A601A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EnterpriseLibraryConfigurationToolBinariesPath = packages\TransientFaultHandling.Core.5.1.1209.1\lib\NET4
SolutionGuid = {2D63A120-9394-48D9-8CA9-1184364FB854}
EnterpriseLibraryConfigurationToolBinariesPath = packages\TransientFaultHandling.Core.5.1.1209.1\lib\NET4
EndGlobalSection
EndGlobal
53 changes: 53 additions & 0 deletions samples/Correlation.Samples/ContinueAsNewOrchestration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// ----------------------------------------------------------------------------------
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

namespace Correlation.Samples
{
using System;
using System.Runtime.Serialization;
using System.Threading.Tasks;
using DurableTask.Core;

[KnownType(typeof(HelloActivity))]
internal class ContinueAsNewOrchestration : TaskOrchestration<string, string>
{
static int counter = 0;

public override async Task<string> RunTask(OrchestrationContext context, string input)
{
string result = await context.ScheduleTask<string>(typeof(HelloActivity), input);
result = input + ":" + result;
if (counter < 3)
{
counter++;
context.ContinueAsNew(result);
}

return result;
}
}

internal class HelloActivity : TaskActivity<string, string>
{
protected override string Execute(TaskContext context, string input)
{
if (string.IsNullOrEmpty(input))
{
throw new ArgumentNullException(nameof(input));
}

Console.WriteLine($"Activity: Hello {input}");
return $"Hello, {input}!";
}
}
}
32 changes: 32 additions & 0 deletions samples/Correlation.Samples/CorrelatedExceptionExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// ----------------------------------------------------------------------------------
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

namespace Correlation.Samples
{
using System;
using System.Collections.Generic;
using System.Text;
using DurableTask.Core;
using Microsoft.ApplicationInsights.DataContracts;

public static class CorrelatedExceptionExtensions
{
public static ExceptionTelemetry CreateExceptionTelemetry(this CorrelatedExceptionDetails e)
{
var exceptionTelemetry = new ExceptionTelemetry(e.Exception);
exceptionTelemetry.Context.Operation.Id = e.OperationId;
exceptionTelemetry.Context.Operation.ParentId = e.ParentId;
return exceptionTelemetry;
}
}
}
31 changes: 31 additions & 0 deletions samples/Correlation.Samples/Correlation.Samples.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\DurableTask.AzureStorage\DurableTask.AzureStorage.csproj" />
</ItemGroup>

<ItemGroup>
<Reference Include="System.Configuration" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.12.0" />
</ItemGroup>

<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Loading

0 comments on commit 43e3f96

Please sign in to comment.