Description
Describe the bug
When using the dd-trace-dotnet in a linux docker container, along with a dotnet core application which is using the WindowsAzure.Storage nuget package (9.3.3 - latest), a StackOverflowException is thrown whenever the application attempts to use any Asnyc Methods from the WindowsAzure.Storage package.
To Reproduce
Steps to reproduce the behavior:
ConsoleApp1.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Datadog.Trace.ClrProfiler.Managed" Version="1.1.0" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
</ItemGroup>
</Project>
Program.cs
using Microsoft.WindowsAzure.Storage;
using System;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{
private static string AzureStorageConnectionString = "My-Azure-Storage-ConnectionString";
private static string ContainerName = "some-container-name";
static async Task Main(string[] args)
{
var storageAccount = CloudStorageAccount.Parse(AzureStorageConnectionString);
var cloudBlobClient = storageAccount.CreateCloudBlobClient();
var container = cloudBlobClient.GetContainerReference(ContainerName);
Console.WriteLine($"Checking if Container ({ContainerName}) Exists...");
var containerExists = await container.ExistsAsync();
Console.WriteLine($"Container ({ContainerName}) Exists: {containerExists}");
Console.WriteLine("Shutting Down.");
}
}
}
Dockerfile
FROM mcr.microsoft.com/dotnet/core/sdk:2.2 as builder
WORKDIR /src
COPY . .
RUN dotnet restore
RUN dotnet build -c Release --no-restore
RUN dotnet publish -c Release --no-build -o /app
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 AS release
WORKDIR /app
ENV ASPNETCORE_URLS=http://*:80
#Setup Datadog APM
RUN mkdir -p /tmp
RUN curl -L https://github.com/DataDog/dd-trace-dotnet/releases/download/v1.1.0/datadog-dotnet-apm_1.1.0_amd64.deb --output /tmp/datadog_apm.deb
RUN dpkg -i /tmp/datadog_apm.deb
ENV CORECLR_ENABLE_PROFILING=1
ENV CORECLR_PROFILER={846F5F1C-F9AE-4B07-969E-05C26BC060D8}
ENV CORECLR_PROFILER_PATH=/opt/datadog/Datadog.Trace.ClrProfiler.Native.so
ENV DD_INTEGRATIONS=/opt/datadog/integrations.json
COPY --from=builder /app .
CMD ["dotnet", "ConsoleApp1.dll"]
Expected behavior
When running in Visual Studio, the application should complete successfully, and display in the Console, whether or not the container exists in the Storage Account. This works correctly.
When running in Docker, having built as above with the dd-trace-dotnet...
docker build --tag dd-trace-agent-test .
docker run --rm dd-trace-agent-test
I expect the application to also run through correctly, displaying in the console whether or not the container exists in the Storage Account. This is where the application throws a StackOverflowException
.
Screenshots
Working Visual Studio Debug Console...
Failed when running in Docker with dd-trace-dotnet
Additional context
When running in Docker, but not including the dd-trace-dotnet, by commenting out the dd-trace-dotnet setup in the Dockerfile but still keeping the nuget reference in the application, the application does work correctly.
This isn't just an issue with the await container.ExistsAsync()
method either, this also happens with await container.CreateIfNotExistsAsync()
, await container.CreateAsync()
etc.
This also happens if, assuming the container is already created, trying to upload a blob etc.
var blob = container.GetBlockBlobReference("my-blob");
await blob.UploadTextAsync("Testing");
Activity