diff --git a/.azure-pipelines/ultimate-pipeline.yml b/.azure-pipelines/ultimate-pipeline.yml index 1ea1946c3..838059237 100644 --- a/.azure-pipelines/ultimate-pipeline.yml +++ b/.azure-pipelines/ultimate-pipeline.yml @@ -28,7 +28,7 @@ trigger: # - Managed utility APIs (may be used transitively): - shared/src/managed-src/Datadog.Collections/* - shared/src/managed-src/Datadog.Util/* -# - Managed Logging APIs (may be used transitively): +# - Managed Logging APIs (may be used transitively): - shared/src/managed-src/Datadog.Logging.Emission/* - shared/src/managed-src/Datadog.Logging.Composition/* - shared/src/managed-src/Datadog.Logging/* @@ -509,7 +509,7 @@ stages: Start-CosmosDbEmulator -Timeout 300 displayName: 'Start CosmosDB Emulator' workingDirectory: $(Pipeline.Workspace) - + - powershell: | Write-Host "Initializing LocalDB" sqllocaldb.exe start @@ -781,7 +781,7 @@ stages: build: true baseImage: $(baseImage) command: "CleanObjFiles" - + - template: steps/restore-working-directory.yml parameters: artifact: build-linux-arm64-working-directory @@ -841,6 +841,64 @@ stages: baseImage: $(baseImage) command: "CheckBuildLogsForErrors" +- stage: exploration_tests_windows + condition: and(succeeded(), eq(variables['isScheduledBuild'], 'False'), eq(variables['runExplorationTests'], 'True')) + dependsOn: build_windows + + jobs: + - template: steps/update-github-status-jobs.yml + parameters: + jobs: [ExplorationTest] + + - job: generator + pool: + vmImage: ubuntu-18.04 + steps: + - bash: | + matrix="{" + for explorationTestUseCase in "debugger" "continuousProfiler"; do + for explorationTestName in "eshoponweb" "protobuf" "cake" "swashbuckle" "paket" ; do + name="${explorationTestUseCase//./_}_${explorationTestName}" + matrix="${matrix} '${name}':" + matrix="${matrix} { 'explorationTestUseCase': '${explorationTestUseCase}', " + matrix="${matrix} 'explorationTestName': '${explorationTestName}' }," + done + done + matrix="${matrix::-1} }" + echo "##vso[task.setVariable variable=values;isOutput=true]${matrix}" + name: mtrx + + - job: ExplorationTest + timeoutInMinutes: 100 + dependsOn: generator + strategy: + matrix: $[ dependencies.generator.outputs['mtrx.values'] ] + pool: + vmImage: windows-2019 + + # Enable the Datadog Agent service for this job + services: + dd_agent: dd_agent + + steps: + - template: steps/install-dotnet-sdks.yml + parameters: + includeX86: true + - template: steps/restore-working-directory.yml + + - script: tracer\build.cmd RunExplorationTests_$(explorationTestUseCase) -ExplorationTestName $(explorationTestName) + displayName: RunExplorationTest + + - publish: tracer/build_data + displayName: Uploading exploration_tests_windows tracer logs + artifact: exploration_tests_windows_tracer_logs_$(explorationTestUseCase)_$(explorationTestName) + condition: succeededOrFailed() + continueOnError: true + + - script: tracer\build.cmd CheckBuildLogsForErrors + displayName: Check logs for errors + + - stage: benchmarks condition: and(succeeded(), ne(variables['isNgenTestBuild'], 'True')) dependsOn: build_windows @@ -1283,6 +1341,37 @@ stages: SIGNALFX_SERVICE_NAME: dd-trace-dotnet SIGNALFX_ENV: CI +- stage: throughput_appsec + condition: and(succeeded(), ne(variables['isNgenTestBuild'], 'True')) + dependsOn: [build_linux] + pool: Throughput-AppSec + jobs: + - template: steps/update-github-status-jobs.yml + parameters: + jobs: [Linux64] + #### Throughput-AppSec Linux 64 + + - job: Linux64 + timeoutInMinutes: 60 + + steps: + - task: DownloadPipelineArtifact@2 + displayName: Download linux native binary + inputs: + artifact: linux-tracer-home-debian + path: $(System.DefaultWorkingDirectory)/tracer/tracer-home-linux + + - script: | + test ! -s "tracer/tracer-home-linux/Datadog.Trace.ClrProfiler.Native.so" && echo "tracer/tracer-home-linux/Datadog.Trace.ClrProfiler.Native.so does not exist" && exit 1 + test ! -s "tracer/tracer-home-linux/libddwaf.so" && echo "tracer/tracer-home-linux/libddwaf.so does not exist" && exit 1 + cd $(System.DefaultWorkingDirectory)/tracer/build/crank + chmod +x ./run-appsec.sh + ./run-appsec.sh "linux" + displayName: Crank + env: + DD_SERVICE: dd-trace-dotnet-appsec + + - stage: coverage condition: and(succeeded(), eq(variables['isScheduledBuild'], 'False'), ne(variables['isNgenTestBuild'], 'True')) dependsOn: [integration_tests_windows, integration_tests_windows_iis, integration_tests_linux, unit_tests_linux, unit_tests_macos, unit_tests_windows] diff --git a/.github/workflows/auto_bump_test_package_versions.yml b/.github/workflows/auto_bump_test_package_versions.yml index 779125328..e79f2d0d6 100644 --- a/.github/workflows/auto_bump_test_package_versions.yml +++ b/.github/workflows/auto_bump_test_package_versions.yml @@ -26,7 +26,7 @@ jobs: dotnet-version: '6.0.x' - name: "Regenerating package versions" - run: .\tracer\build.ps1 UpdateIntegrationsJson GeneratePackageVersions + run: .\tracer\build.ps1 UpdateIntegrationDefinitions GeneratePackageVersions - name: Create Pull Request id: pr diff --git a/.github/workflows/create_version_bump_pr.yml b/.github/workflows/create_version_bump_pr.yml index 8e809d852..62f93b168 100644 --- a/.github/workflows/create_version_bump_pr.yml +++ b/.github/workflows/create_version_bump_pr.yml @@ -34,7 +34,7 @@ jobs: run: .\tracer\build.ps1 UpdateChangeLog - name: "Bump Version" - run: .\tracer\build.ps1 UpdateIntegrationsJson UpdateVersion UpdateMsiContents + run: .\tracer\build.ps1 UpdateIntegrationDefinitions UpdateVersion UpdateMsiContents - name: "Verify Changes" id: changes diff --git a/.gitignore b/.gitignore index 5f74cf1ef..2048d9a3f 100644 --- a/.gitignore +++ b/.gitignore @@ -334,3 +334,5 @@ tracer/src/Datadog.Trace.ClrProfiler.Native/Makefile tracer/src/Datadog.Trace.ClrProfiler.Native/CMakeCache.txt tracer/src/Datadog.Trace.ClrProfiler.Native/cmake_install.cmake !tracer/src/Datadog.Trace.ClrProfiler.Native/lib/** + +.ionide/ diff --git a/Datadog.Trace.sln b/Datadog.Trace.sln index 8e3529030..e83adc296 100644 --- a/Datadog.Trace.sln +++ b/Datadog.Trace.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31702.278 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.31903.286 MinimumVisualStudioVersion = 15.0.26124.0 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Datadog.Trace.ClrProfiler.Native", "tracer\src\Datadog.Trace.ClrProfiler.Native\Datadog.Trace.ClrProfiler.Native.vcxproj", "{91B6272F-5780-4C94-8071-DBBA7B4F67F3}" ProjectSection(ProjectDependencies) = postProject @@ -92,7 +92,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Datadog.Trace.ClrProfiler.I {8276E670-FC3F-4EDE-9D51-6DAD90336C32} = {8276E670-FC3F-4EDE-9D51-6DAD90336C32} {2F3B6271-B9A3-48A3-9DB6-847F3EF41F0A} = {2F3B6271-B9A3-48A3-9DB6-847F3EF41F0A} {C0C8D381-D6B9-4C76-9428-F40F2FA93A9A} = {C0C8D381-D6B9-4C76-9428-F40F2FA93A9A} - {DF923186-5397-4E15-A95B-F15C8327ED53} = {DF923186-5397-4E15-A95B-F15C8327ED53} {8B457E8F-8716-4F29-BBE2-DD6C7BC4AC37} = {8B457E8F-8716-4F29-BBE2-DD6C7BC4AC37} {FA487690-E88C-4A57-9187-B71CB70C1AAE} = {FA487690-E88C-4A57-9187-B71CB70C1AAE} {086FF8A0-9CEE-470A-9751-78B0F1340649} = {086FF8A0-9CEE-470A-9751-78B0F1340649} @@ -176,8 +175,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.MySql", "tracer\tes {C0C8D381-D6B9-4C76-9428-F40F2FA93A9A} = {C0C8D381-D6B9-4C76-9428-F40F2FA93A9A} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TraceContext.InvalidOperationException", "tracer\test\test-applications\regression\TraceContext.InvalidOperationException\TraceContext.InvalidOperationException.csproj", "{DF923186-5397-4E15-A95B-F15C8327ED53}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.DatabaseHelper", "tracer\test\test-applications\integrations\dependency-libs\Samples.DatabaseHelper\Samples.DatabaseHelper.csproj", "{472DBA92-4FEA-4B9A-BA70-0E97B942E12D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssemblyResolveMscorlibResources.InfiniteRecursionCrash", "tracer\test\test-applications\regression\AssemblyResolveMscorlibResources.InfiniteRecursionCrash\AssemblyResolveMscorlibResources.InfiniteRecursionCrash.csproj", "{EEA89ACD-CFBB-4F60-A150-74F0A84DF028}" @@ -429,6 +426,28 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.AspNetCoreMinimalAp EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCoreSmokeTest", "tracer\test\test-applications\regression\AspNetCoreSmokeTest\AspNetCoreSmokeTest.csproj", "{BED94A61-6FD9-4103-BD35-70B4798C301C}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples.AspNet.VersionConflict", "tracer\test\test-applications\aspnet\Samples.AspNet.VersionConflict\Samples.AspNet.VersionConflict.csproj", "{FAB2B108-E5BE-4647-869B-1DC5D362252E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.VersionConflict.1x", "tracer\test\test-applications\integrations\Samples.VersionConflict.1x\Samples.VersionConflict.1x.csproj", "{6F8B63EA-98D6-4909-BE9E-F39029C29C4F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.VersionConflict.2x", "tracer\test\test-applications\integrations\Samples.VersionConflict.2x\Samples.VersionConflict.2x.csproj", "{3BC38BE0-B6FF-4B05-BC63-3614A5CF9393}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LogsInjectionHelper.VersionConflict", "tracer\test\test-applications\integrations\dependency-libs\LogsInjectionHelper.VersionConflict\LogsInjectionHelper.VersionConflict.csproj", "{E9D55D41-B161-492F-9EC7-FF2F2231A587}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LogsInjection.Serilog.VersionConflict.2x", "tracer\test\test-applications\integrations\LogsInjection.Serilog.VersionConflict.2x\LogsInjection.Serilog.VersionConflict.2x.csproj", "{268B6D05-B6D5-4D20-B2B1-0B9422A92D73}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LogsInjection.Serilog14.VersionConflict.2x", "tracer\test\test-applications\integrations\LogsInjection.Serilog14.VersionConflict.2x\LogsInjection.Serilog14.VersionConflict.2x.csproj", "{3C78C521-6507-4D3A-B92E-BC41CEE9D9F3}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LogsInjection.Log4Net.VersionConflict.2x", "tracer\test\test-applications\integrations\LogsInjection.Log4Net.VersionConflict.2x\LogsInjection.Log4Net.VersionConflict.2x.csproj", "{25B7D571-C385-4CA6-9B6A-573D3E3FF3C9}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LogsInjection.NLog.VersionConflict.2x", "tracer\test\test-applications\integrations\LogsInjection.NLog.VersionConflict.2x\LogsInjection.NLog.VersionConflict.2x.csproj", "{F19B5109-36AC-4A64-AFE6-FAF9E831C528}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LogsInjection.NLog20.VersionConflict.2x", "tracer\test\test-applications\integrations\LogsInjection.NLog20.VersionConflict.2x\LogsInjection.NLog20.VersionConflict.2x.csproj", "{0980BCDD-A231-42D1-B689-41A41BBA161A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LogsInjection.NLog10.VersionConflict.2x", "tracer\test\test-applications\integrations\LogsInjection.NLog10.VersionConflict.2x\LogsInjection.NLog10.VersionConflict.2x.csproj", "{D00DDBDA-66F5-490D-8C1C-16CC5E142170}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LogsInjection.ILogger.VersionConflict.2x", "tracer\test\test-applications\integrations\LogsInjection.ILogger.VersionConflict.2x\LogsInjection.ILogger.VersionConflict.2x.csproj", "{238F67DB-1E48-447C-B1B8-BDC692103791}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution tracer\test\test-applications\Samples.Shared\Samples.Shared.projitems*{24d3e547-8897-4111-baa2-b92f50cc13d4}*SharedItemsImports = 5 @@ -442,6 +461,7 @@ Global tracer\test\test-applications\Samples.Shared\Samples.Shared.projitems*{bbb60b0f-bf01-4499-936a-4a299a9acfd4}*SharedItemsImports = 4 tracer\test\test-applications\Samples.Shared\Samples.Shared.projitems*{c41b289a-a344-49df-a1bd-081753f9a286}*SharedItemsImports = 5 tracer\test\test-applications\Samples.Shared\Samples.Shared.projitems*{f5582f54-e911-4258-b419-5e894d338c5b}*SharedItemsImports = 4 + tracer\test\test-applications\Samples.Shared\Samples.Shared.projitems*{fab2b108-e5be-4647-869b-1dc5d362252e}*SharedItemsImports = 4 EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -841,16 +861,6 @@ Global {42FA33DD-AEA3-4FF3-8319-F30244A666A4}.Release|x64.Build.0 = Release|x64 {42FA33DD-AEA3-4FF3-8319-F30244A666A4}.Release|x86.ActiveCfg = Release|x86 {42FA33DD-AEA3-4FF3-8319-F30244A666A4}.Release|x86.Build.0 = Release|x86 - {DF923186-5397-4E15-A95B-F15C8327ED53}.Debug|Any CPU.ActiveCfg = Debug|x86 - {DF923186-5397-4E15-A95B-F15C8327ED53}.Debug|x64.ActiveCfg = Debug|x64 - {DF923186-5397-4E15-A95B-F15C8327ED53}.Debug|x64.Build.0 = Debug|x64 - {DF923186-5397-4E15-A95B-F15C8327ED53}.Debug|x86.ActiveCfg = Debug|x86 - {DF923186-5397-4E15-A95B-F15C8327ED53}.Debug|x86.Build.0 = Debug|x86 - {DF923186-5397-4E15-A95B-F15C8327ED53}.Release|Any CPU.ActiveCfg = Release|x86 - {DF923186-5397-4E15-A95B-F15C8327ED53}.Release|x64.ActiveCfg = Release|x64 - {DF923186-5397-4E15-A95B-F15C8327ED53}.Release|x64.Build.0 = Release|x64 - {DF923186-5397-4E15-A95B-F15C8327ED53}.Release|x86.ActiveCfg = Release|x86 - {DF923186-5397-4E15-A95B-F15C8327ED53}.Release|x86.Build.0 = Release|x86 {472DBA92-4FEA-4B9A-BA70-0E97B942E12D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {472DBA92-4FEA-4B9A-BA70-0E97B942E12D}.Debug|Any CPU.Build.0 = Debug|Any CPU {472DBA92-4FEA-4B9A-BA70-0E97B942E12D}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -1856,6 +1866,138 @@ Global {BED94A61-6FD9-4103-BD35-70B4798C301C}.Release|x64.Build.0 = Release|Any CPU {BED94A61-6FD9-4103-BD35-70B4798C301C}.Release|x86.ActiveCfg = Release|Any CPU {BED94A61-6FD9-4103-BD35-70B4798C301C}.Release|x86.Build.0 = Release|Any CPU + {FAB2B108-E5BE-4647-869B-1DC5D362252E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FAB2B108-E5BE-4647-869B-1DC5D362252E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FAB2B108-E5BE-4647-869B-1DC5D362252E}.Debug|x64.ActiveCfg = Debug|x64 + {FAB2B108-E5BE-4647-869B-1DC5D362252E}.Debug|x64.Build.0 = Debug|x64 + {FAB2B108-E5BE-4647-869B-1DC5D362252E}.Debug|x86.ActiveCfg = Debug|x86 + {FAB2B108-E5BE-4647-869B-1DC5D362252E}.Debug|x86.Build.0 = Debug|x86 + {FAB2B108-E5BE-4647-869B-1DC5D362252E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FAB2B108-E5BE-4647-869B-1DC5D362252E}.Release|Any CPU.Build.0 = Release|Any CPU + {FAB2B108-E5BE-4647-869B-1DC5D362252E}.Release|x64.ActiveCfg = Release|x64 + {FAB2B108-E5BE-4647-869B-1DC5D362252E}.Release|x64.Build.0 = Release|x64 + {FAB2B108-E5BE-4647-869B-1DC5D362252E}.Release|x86.ActiveCfg = Release|x86 + {FAB2B108-E5BE-4647-869B-1DC5D362252E}.Release|x86.Build.0 = Release|x86 + {6F8B63EA-98D6-4909-BE9E-F39029C29C4F}.Debug|Any CPU.ActiveCfg = Debug|x64 + {6F8B63EA-98D6-4909-BE9E-F39029C29C4F}.Debug|Any CPU.Build.0 = Debug|x64 + {6F8B63EA-98D6-4909-BE9E-F39029C29C4F}.Debug|x64.ActiveCfg = Debug|x64 + {6F8B63EA-98D6-4909-BE9E-F39029C29C4F}.Debug|x64.Build.0 = Debug|x64 + {6F8B63EA-98D6-4909-BE9E-F39029C29C4F}.Debug|x86.ActiveCfg = Debug|x86 + {6F8B63EA-98D6-4909-BE9E-F39029C29C4F}.Debug|x86.Build.0 = Debug|x86 + {6F8B63EA-98D6-4909-BE9E-F39029C29C4F}.Release|Any CPU.ActiveCfg = Release|x64 + {6F8B63EA-98D6-4909-BE9E-F39029C29C4F}.Release|Any CPU.Build.0 = Release|x64 + {6F8B63EA-98D6-4909-BE9E-F39029C29C4F}.Release|x64.ActiveCfg = Release|x64 + {6F8B63EA-98D6-4909-BE9E-F39029C29C4F}.Release|x64.Build.0 = Release|x64 + {6F8B63EA-98D6-4909-BE9E-F39029C29C4F}.Release|x86.ActiveCfg = Release|x86 + {6F8B63EA-98D6-4909-BE9E-F39029C29C4F}.Release|x86.Build.0 = Release|x86 + {3BC38BE0-B6FF-4B05-BC63-3614A5CF9393}.Debug|Any CPU.ActiveCfg = Debug|x64 + {3BC38BE0-B6FF-4B05-BC63-3614A5CF9393}.Debug|Any CPU.Build.0 = Debug|x64 + {3BC38BE0-B6FF-4B05-BC63-3614A5CF9393}.Debug|x64.ActiveCfg = Debug|x64 + {3BC38BE0-B6FF-4B05-BC63-3614A5CF9393}.Debug|x64.Build.0 = Debug|x64 + {3BC38BE0-B6FF-4B05-BC63-3614A5CF9393}.Debug|x86.ActiveCfg = Debug|x86 + {3BC38BE0-B6FF-4B05-BC63-3614A5CF9393}.Debug|x86.Build.0 = Debug|x86 + {3BC38BE0-B6FF-4B05-BC63-3614A5CF9393}.Release|Any CPU.ActiveCfg = Release|x64 + {3BC38BE0-B6FF-4B05-BC63-3614A5CF9393}.Release|Any CPU.Build.0 = Release|x64 + {3BC38BE0-B6FF-4B05-BC63-3614A5CF9393}.Release|x64.ActiveCfg = Release|x64 + {3BC38BE0-B6FF-4B05-BC63-3614A5CF9393}.Release|x64.Build.0 = Release|x64 + {3BC38BE0-B6FF-4B05-BC63-3614A5CF9393}.Release|x86.ActiveCfg = Release|x86 + {3BC38BE0-B6FF-4B05-BC63-3614A5CF9393}.Release|x86.Build.0 = Release|x86 + {E9D55D41-B161-492F-9EC7-FF2F2231A587}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E9D55D41-B161-492F-9EC7-FF2F2231A587}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E9D55D41-B161-492F-9EC7-FF2F2231A587}.Debug|x64.ActiveCfg = Debug|Any CPU + {E9D55D41-B161-492F-9EC7-FF2F2231A587}.Debug|x64.Build.0 = Debug|Any CPU + {E9D55D41-B161-492F-9EC7-FF2F2231A587}.Debug|x86.ActiveCfg = Debug|Any CPU + {E9D55D41-B161-492F-9EC7-FF2F2231A587}.Debug|x86.Build.0 = Debug|Any CPU + {E9D55D41-B161-492F-9EC7-FF2F2231A587}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E9D55D41-B161-492F-9EC7-FF2F2231A587}.Release|Any CPU.Build.0 = Release|Any CPU + {E9D55D41-B161-492F-9EC7-FF2F2231A587}.Release|x64.ActiveCfg = Release|Any CPU + {E9D55D41-B161-492F-9EC7-FF2F2231A587}.Release|x64.Build.0 = Release|Any CPU + {E9D55D41-B161-492F-9EC7-FF2F2231A587}.Release|x86.ActiveCfg = Release|Any CPU + {E9D55D41-B161-492F-9EC7-FF2F2231A587}.Release|x86.Build.0 = Release|Any CPU + {268B6D05-B6D5-4D20-B2B1-0B9422A92D73}.Debug|Any CPU.ActiveCfg = Debug|x64 + {268B6D05-B6D5-4D20-B2B1-0B9422A92D73}.Debug|Any CPU.Build.0 = Debug|x64 + {268B6D05-B6D5-4D20-B2B1-0B9422A92D73}.Debug|x64.ActiveCfg = Debug|x64 + {268B6D05-B6D5-4D20-B2B1-0B9422A92D73}.Debug|x64.Build.0 = Debug|x64 + {268B6D05-B6D5-4D20-B2B1-0B9422A92D73}.Debug|x86.ActiveCfg = Debug|x86 + {268B6D05-B6D5-4D20-B2B1-0B9422A92D73}.Debug|x86.Build.0 = Debug|x86 + {268B6D05-B6D5-4D20-B2B1-0B9422A92D73}.Release|Any CPU.ActiveCfg = Release|x64 + {268B6D05-B6D5-4D20-B2B1-0B9422A92D73}.Release|Any CPU.Build.0 = Release|x64 + {268B6D05-B6D5-4D20-B2B1-0B9422A92D73}.Release|x64.ActiveCfg = Release|x64 + {268B6D05-B6D5-4D20-B2B1-0B9422A92D73}.Release|x64.Build.0 = Release|x64 + {268B6D05-B6D5-4D20-B2B1-0B9422A92D73}.Release|x86.ActiveCfg = Release|x86 + {268B6D05-B6D5-4D20-B2B1-0B9422A92D73}.Release|x86.Build.0 = Release|x86 + {3C78C521-6507-4D3A-B92E-BC41CEE9D9F3}.Debug|Any CPU.ActiveCfg = Debug|x64 + {3C78C521-6507-4D3A-B92E-BC41CEE9D9F3}.Debug|Any CPU.Build.0 = Debug|x64 + {3C78C521-6507-4D3A-B92E-BC41CEE9D9F3}.Debug|x64.ActiveCfg = Debug|x64 + {3C78C521-6507-4D3A-B92E-BC41CEE9D9F3}.Debug|x64.Build.0 = Debug|x64 + {3C78C521-6507-4D3A-B92E-BC41CEE9D9F3}.Debug|x86.ActiveCfg = Debug|x86 + {3C78C521-6507-4D3A-B92E-BC41CEE9D9F3}.Debug|x86.Build.0 = Debug|x86 + {3C78C521-6507-4D3A-B92E-BC41CEE9D9F3}.Release|Any CPU.ActiveCfg = Release|x64 + {3C78C521-6507-4D3A-B92E-BC41CEE9D9F3}.Release|Any CPU.Build.0 = Release|x64 + {3C78C521-6507-4D3A-B92E-BC41CEE9D9F3}.Release|x64.ActiveCfg = Release|x64 + {3C78C521-6507-4D3A-B92E-BC41CEE9D9F3}.Release|x64.Build.0 = Release|x64 + {3C78C521-6507-4D3A-B92E-BC41CEE9D9F3}.Release|x86.ActiveCfg = Release|x86 + {3C78C521-6507-4D3A-B92E-BC41CEE9D9F3}.Release|x86.Build.0 = Release|x86 + {25B7D571-C385-4CA6-9B6A-573D3E3FF3C9}.Debug|Any CPU.ActiveCfg = Debug|x64 + {25B7D571-C385-4CA6-9B6A-573D3E3FF3C9}.Debug|Any CPU.Build.0 = Debug|x64 + {25B7D571-C385-4CA6-9B6A-573D3E3FF3C9}.Debug|x64.ActiveCfg = Debug|x64 + {25B7D571-C385-4CA6-9B6A-573D3E3FF3C9}.Debug|x64.Build.0 = Debug|x64 + {25B7D571-C385-4CA6-9B6A-573D3E3FF3C9}.Debug|x86.ActiveCfg = Debug|x86 + {25B7D571-C385-4CA6-9B6A-573D3E3FF3C9}.Debug|x86.Build.0 = Debug|x86 + {25B7D571-C385-4CA6-9B6A-573D3E3FF3C9}.Release|Any CPU.ActiveCfg = Release|x64 + {25B7D571-C385-4CA6-9B6A-573D3E3FF3C9}.Release|Any CPU.Build.0 = Release|x64 + {25B7D571-C385-4CA6-9B6A-573D3E3FF3C9}.Release|x64.ActiveCfg = Release|x64 + {25B7D571-C385-4CA6-9B6A-573D3E3FF3C9}.Release|x64.Build.0 = Release|x64 + {25B7D571-C385-4CA6-9B6A-573D3E3FF3C9}.Release|x86.ActiveCfg = Release|x86 + {25B7D571-C385-4CA6-9B6A-573D3E3FF3C9}.Release|x86.Build.0 = Release|x86 + {F19B5109-36AC-4A64-AFE6-FAF9E831C528}.Debug|Any CPU.ActiveCfg = Debug|x64 + {F19B5109-36AC-4A64-AFE6-FAF9E831C528}.Debug|Any CPU.Build.0 = Debug|x64 + {F19B5109-36AC-4A64-AFE6-FAF9E831C528}.Debug|x64.ActiveCfg = Debug|x64 + {F19B5109-36AC-4A64-AFE6-FAF9E831C528}.Debug|x64.Build.0 = Debug|x64 + {F19B5109-36AC-4A64-AFE6-FAF9E831C528}.Debug|x86.ActiveCfg = Debug|x86 + {F19B5109-36AC-4A64-AFE6-FAF9E831C528}.Debug|x86.Build.0 = Debug|x86 + {F19B5109-36AC-4A64-AFE6-FAF9E831C528}.Release|Any CPU.ActiveCfg = Release|x64 + {F19B5109-36AC-4A64-AFE6-FAF9E831C528}.Release|Any CPU.Build.0 = Release|x64 + {F19B5109-36AC-4A64-AFE6-FAF9E831C528}.Release|x64.ActiveCfg = Release|x64 + {F19B5109-36AC-4A64-AFE6-FAF9E831C528}.Release|x64.Build.0 = Release|x64 + {F19B5109-36AC-4A64-AFE6-FAF9E831C528}.Release|x86.ActiveCfg = Release|x86 + {F19B5109-36AC-4A64-AFE6-FAF9E831C528}.Release|x86.Build.0 = Release|x86 + {0980BCDD-A231-42D1-B689-41A41BBA161A}.Debug|Any CPU.ActiveCfg = Debug|x64 + {0980BCDD-A231-42D1-B689-41A41BBA161A}.Debug|Any CPU.Build.0 = Debug|x64 + {0980BCDD-A231-42D1-B689-41A41BBA161A}.Debug|x64.ActiveCfg = Debug|x64 + {0980BCDD-A231-42D1-B689-41A41BBA161A}.Debug|x64.Build.0 = Debug|x64 + {0980BCDD-A231-42D1-B689-41A41BBA161A}.Debug|x86.ActiveCfg = Debug|x86 + {0980BCDD-A231-42D1-B689-41A41BBA161A}.Debug|x86.Build.0 = Debug|x86 + {0980BCDD-A231-42D1-B689-41A41BBA161A}.Release|Any CPU.ActiveCfg = Release|x64 + {0980BCDD-A231-42D1-B689-41A41BBA161A}.Release|Any CPU.Build.0 = Release|x64 + {0980BCDD-A231-42D1-B689-41A41BBA161A}.Release|x64.ActiveCfg = Release|x64 + {0980BCDD-A231-42D1-B689-41A41BBA161A}.Release|x64.Build.0 = Release|x64 + {0980BCDD-A231-42D1-B689-41A41BBA161A}.Release|x86.ActiveCfg = Release|x86 + {0980BCDD-A231-42D1-B689-41A41BBA161A}.Release|x86.Build.0 = Release|x86 + {D00DDBDA-66F5-490D-8C1C-16CC5E142170}.Debug|Any CPU.ActiveCfg = Debug|x64 + {D00DDBDA-66F5-490D-8C1C-16CC5E142170}.Debug|Any CPU.Build.0 = Debug|x64 + {D00DDBDA-66F5-490D-8C1C-16CC5E142170}.Debug|x64.ActiveCfg = Debug|x64 + {D00DDBDA-66F5-490D-8C1C-16CC5E142170}.Debug|x64.Build.0 = Debug|x64 + {D00DDBDA-66F5-490D-8C1C-16CC5E142170}.Debug|x86.ActiveCfg = Debug|x86 + {D00DDBDA-66F5-490D-8C1C-16CC5E142170}.Debug|x86.Build.0 = Debug|x86 + {D00DDBDA-66F5-490D-8C1C-16CC5E142170}.Release|Any CPU.ActiveCfg = Release|x64 + {D00DDBDA-66F5-490D-8C1C-16CC5E142170}.Release|Any CPU.Build.0 = Release|x64 + {D00DDBDA-66F5-490D-8C1C-16CC5E142170}.Release|x64.ActiveCfg = Release|x64 + {D00DDBDA-66F5-490D-8C1C-16CC5E142170}.Release|x64.Build.0 = Release|x64 + {D00DDBDA-66F5-490D-8C1C-16CC5E142170}.Release|x86.ActiveCfg = Release|x86 + {D00DDBDA-66F5-490D-8C1C-16CC5E142170}.Release|x86.Build.0 = Release|x86 + {238F67DB-1E48-447C-B1B8-BDC692103791}.Debug|Any CPU.ActiveCfg = Debug|x64 + {238F67DB-1E48-447C-B1B8-BDC692103791}.Debug|Any CPU.Build.0 = Debug|x64 + {238F67DB-1E48-447C-B1B8-BDC692103791}.Debug|x64.ActiveCfg = Debug|x64 + {238F67DB-1E48-447C-B1B8-BDC692103791}.Debug|x64.Build.0 = Debug|x64 + {238F67DB-1E48-447C-B1B8-BDC692103791}.Debug|x86.ActiveCfg = Debug|x86 + {238F67DB-1E48-447C-B1B8-BDC692103791}.Debug|x86.Build.0 = Debug|x86 + {238F67DB-1E48-447C-B1B8-BDC692103791}.Release|Any CPU.ActiveCfg = Release|x64 + {238F67DB-1E48-447C-B1B8-BDC692103791}.Release|Any CPU.Build.0 = Release|x64 + {238F67DB-1E48-447C-B1B8-BDC692103791}.Release|x64.ActiveCfg = Release|x64 + {238F67DB-1E48-447C-B1B8-BDC692103791}.Release|x64.Build.0 = Release|x64 + {238F67DB-1E48-447C-B1B8-BDC692103791}.Release|x86.ActiveCfg = Release|x86 + {238F67DB-1E48-447C-B1B8-BDC692103791}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1897,7 +2039,6 @@ Global {AB8596C1-CFDA-4A5E-9E9C-74A3DF9AED77} = {9E5F0022-0A50-40BF-AC6A-C3078585ECAB} {1A5E9F40-F3A5-4B59-9898-3DCD65C459C3} = {498A300E-D036-49B7-A43D-821D1CAF11A5} {42FA33DD-AEA3-4FF3-8319-F30244A666A4} = {BAF8F246-3645-42AD-B1D0-0F7EAFBAB34A} - {DF923186-5397-4E15-A95B-F15C8327ED53} = {498A300E-D036-49B7-A43D-821D1CAF11A5} {472DBA92-4FEA-4B9A-BA70-0E97B942E12D} = {8683D82A-2BBE-4199-9C36-C59F48804F90} {EEA89ACD-CFBB-4F60-A150-74F0A84DF028} = {498A300E-D036-49B7-A43D-821D1CAF11A5} {8BDF1DE0-E6DE-48AD-AAA3-CE09CB544E2C} = {BAF8F246-3645-42AD-B1D0-0F7EAFBAB34A} @@ -2006,6 +2147,17 @@ Global {65A66859-2735-4DD6-A927-B416B7A62D0F} = {BAF8F246-3645-42AD-B1D0-0F7EAFBAB34A} {2A6D3042-C675-4EA3-A8E7-5BDD3C5758EA} = {BAF8F246-3645-42AD-B1D0-0F7EAFBAB34A} {BED94A61-6FD9-4103-BD35-70B4798C301C} = {498A300E-D036-49B7-A43D-821D1CAF11A5} + {FAB2B108-E5BE-4647-869B-1DC5D362252E} = {AFA0AB23-64F0-4AC1-9050-6CE8FE06F580} + {6F8B63EA-98D6-4909-BE9E-F39029C29C4F} = {BAF8F246-3645-42AD-B1D0-0F7EAFBAB34A} + {3BC38BE0-B6FF-4B05-BC63-3614A5CF9393} = {BAF8F246-3645-42AD-B1D0-0F7EAFBAB34A} + {E9D55D41-B161-492F-9EC7-FF2F2231A587} = {8683D82A-2BBE-4199-9C36-C59F48804F90} + {268B6D05-B6D5-4D20-B2B1-0B9422A92D73} = {BAF8F246-3645-42AD-B1D0-0F7EAFBAB34A} + {3C78C521-6507-4D3A-B92E-BC41CEE9D9F3} = {BAF8F246-3645-42AD-B1D0-0F7EAFBAB34A} + {25B7D571-C385-4CA6-9B6A-573D3E3FF3C9} = {BAF8F246-3645-42AD-B1D0-0F7EAFBAB34A} + {F19B5109-36AC-4A64-AFE6-FAF9E831C528} = {BAF8F246-3645-42AD-B1D0-0F7EAFBAB34A} + {0980BCDD-A231-42D1-B689-41A41BBA161A} = {BAF8F246-3645-42AD-B1D0-0F7EAFBAB34A} + {D00DDBDA-66F5-490D-8C1C-16CC5E142170} = {BAF8F246-3645-42AD-B1D0-0F7EAFBAB34A} + {238F67DB-1E48-447C-B1B8-BDC692103791} = {BAF8F246-3645-42AD-B1D0-0F7EAFBAB34A} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {160A1D00-1F5B-40F8-A155-621B4459D78F} diff --git a/docs/PULL_FROM_UPSTREAM.md b/docs/PULL_FROM_UPSTREAM.md index 7ef482b56..d701b2a47 100644 --- a/docs/PULL_FROM_UPSTREAM.md +++ b/docs/PULL_FROM_UPSTREAM.md @@ -18,7 +18,7 @@ * Run unit tests, commit any needed fixes, repeat until passing unit tests * Update version in `tracer\src\Datadog.Trace.ClrProfiler.Native\version.h` if the upstream bumped it. * Update `launchSettings.json` files: change `Datadog.Trace.ClrProfiler.Native.dll` to `SignalFx.Tracing.ClrProfiler.Native.dll` for `CORECLR_PROFILER_PATH` and `COR_PROFILER_PATH` - * Update versions and integrations json by running: `nuke UpdateIntegrationsJson` (remember to revert wcf and other windows-only frameworks if you are using different platform) + * Update versions and integrations json by running: `nuke UpdateIntegrationDefinitions` (remember to revert wcf and other windows-only frameworks if you are using different platform) * Run build via nuke and commit any needed fixes, until it passes: 6. If squashing cherry-pick from upstream to pass CLA check: diff --git a/docs/internal-config.md b/docs/internal-config.md index ccdf96971..5dfdc8669 100644 --- a/docs/internal-config.md +++ b/docs/internal-config.md @@ -23,6 +23,7 @@ These settings should be never used by the users. | `SIGNALFX_APPSEC_BLOCKING_ENABLED` | Enables the AppSec blocking. | `false` | | `SIGNALFX_APPSEC_ENABLED` | Enables the AppSec. | `false` | | `SIGNALFX_APPSEC_EXTRA_HEADERS` | Optional custom headers the user wants to send. | | +| `SIGNALFX_APPSEC_KEEP_TRACES` | Specifies if the AppSec traces should be explicitly kept or droped. | `true` | | `SIGNALFX_APPSEC_IPHEADER` | Optional name of the custom header to take into account for the ip address. | | | `SIGNALFX_APPSEC_RULES` | Overrides the default rules file provided. Must be a path to a valid JSON rules file. | | | `SIGNALFX_CIVISIBILITY_ENABLED` | Enable to activate CI Visibility. | `false` | @@ -30,6 +31,7 @@ These settings should be never used by the users. | `SIGNALFX_DOGSTATSD_PATH` | The DogStatsD path for when a standalone instance needs to be started. | | | `SIGNALFX_DOGSTATSD_PIPE_NAME` | The named pipe that DogStatsD binds to. | | | `SIGNALFX_DOGSTATSD_PORT` | The port of the targeted StatsD server. | `8125` | +| `SIGNALFX_INTERNAL_TRACE_VERSION_COMPATIBILITY` | Enables the compatibility with other versions of tracer. | `false` | | `SIGNALFX_TRACE_{0}_ANALYTICS_ENABLED` | Enable to activate analytics for specific integration. | `false` | | `SIGNALFX_TRACE_{0}_ANALYTICS_SAMPLE_RATE` | Set sample rate for analytics in specific integration. | | | `SIGNALFX_TRACE_AGENT_ARGS` | Comma-separated list of arguments to be passed to the Trace Agent process. | | diff --git a/nuget.config b/nuget.config index e6579a70d..ca1d67f90 100644 --- a/nuget.config +++ b/nuget.config @@ -1,4 +1,4 @@ - + diff --git a/tracer/build/PackageVersionsGeneratorDefinitions.json b/tracer/build/PackageVersionsGeneratorDefinitions.json index 9f57fa4d0..8d1cda514 100644 --- a/tracer/build/PackageVersionsGeneratorDefinitions.json +++ b/tracer/build/PackageVersionsGeneratorDefinitions.json @@ -136,7 +136,7 @@ "SampleProjectName": "Samples.MSTestTests", "NugetPackageSearchName": "MSTest.TestFramework", "MinVersion": "2.0.0", - "MaxVersionExclusive": "2.2.8" + "MaxVersionExclusive": "3.0.0" }, { "IntegrationName": "Kafka", diff --git a/tracer/build/PackageVersionsLatestMajors.g.props b/tracer/build/PackageVersionsLatestMajors.g.props index 8f49ea9f0..b8a3cc53f 100644 --- a/tracer/build/PackageVersionsLatestMajors.g.props +++ b/tracer/build/PackageVersionsLatestMajors.g.props @@ -13,51 +13,51 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely - ApiVersion=3.7.2;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=3.7.2.2;RestoreRecursive=false;BuildProjectReferences=false net461 - ApiVersion=3.7.2;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=3.7.2.2;RestoreRecursive=false;BuildProjectReferences=false netcoreapp2.1 - ApiVersion=3.7.2;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=3.7.2.2;RestoreRecursive=false;BuildProjectReferences=false netcoreapp3.0 - ApiVersion=3.7.2;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=3.7.2.2;RestoreRecursive=false;BuildProjectReferences=false netcoreapp3.1 - ApiVersion=3.7.2;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=3.7.2.2;RestoreRecursive=false;BuildProjectReferences=false net5.0 - ApiVersion=3.7.2;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=3.7.2.2;RestoreRecursive=false;BuildProjectReferences=false net6.0 - ApiVersion=2.14.0;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.14.1;RestoreRecursive=false;BuildProjectReferences=false net461 - ApiVersion=2.14.0;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.14.1;RestoreRecursive=false;BuildProjectReferences=false netcoreapp2.1 - ApiVersion=2.14.0;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.14.1;RestoreRecursive=false;BuildProjectReferences=false netcoreapp3.0 - ApiVersion=2.14.0;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.14.1;RestoreRecursive=false;BuildProjectReferences=false netcoreapp3.1 - ApiVersion=2.14.0;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.14.1;RestoreRecursive=false;BuildProjectReferences=false net5.0 - ApiVersion=2.14.0;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.14.1;RestoreRecursive=false;BuildProjectReferences=false net6.0 @@ -141,7 +141,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely net461 - ApiVersion=6.0.0;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=6.0.1;RestoreRecursive=false;BuildProjectReferences=false net461 @@ -169,7 +169,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely netcoreapp3.1 - ApiVersion=6.0.0;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=6.0.1;RestoreRecursive=false;BuildProjectReferences=false netcoreapp3.1 @@ -181,7 +181,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely net5.0 - ApiVersion=6.0.0;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=6.0.1;RestoreRecursive=false;BuildProjectReferences=false net5.0 @@ -193,7 +193,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely net6.0 - ApiVersion=6.0.0;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=6.0.1;RestoreRecursive=false;BuildProjectReferences=false net6.0 @@ -517,7 +517,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely net461 - ApiVersion=2.0.0;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.1.0;RestoreRecursive=false;BuildProjectReferences=false net461 @@ -525,7 +525,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely netcoreapp2.1 - ApiVersion=2.0.0;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.1.0;RestoreRecursive=false;BuildProjectReferences=false netcoreapp2.1 @@ -533,7 +533,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely netcoreapp3.0 - ApiVersion=2.0.0;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.1.0;RestoreRecursive=false;BuildProjectReferences=false netcoreapp3.0 @@ -541,7 +541,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely netcoreapp3.1 - ApiVersion=2.0.0;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.1.0;RestoreRecursive=false;BuildProjectReferences=false netcoreapp3.1 @@ -549,7 +549,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely net5.0 - ApiVersion=2.0.0;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.1.0;RestoreRecursive=false;BuildProjectReferences=false net5.0 @@ -557,7 +557,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely net6.0 - ApiVersion=2.0.0;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.1.0;RestoreRecursive=false;BuildProjectReferences=false net6.0 @@ -705,27 +705,27 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely net6.0 - ApiVersion=2.2.7;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.2.8;RestoreRecursive=false;BuildProjectReferences=false net461 - ApiVersion=2.2.7;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.2.8;RestoreRecursive=false;BuildProjectReferences=false netcoreapp2.1 - ApiVersion=2.2.7;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.2.8;RestoreRecursive=false;BuildProjectReferences=false netcoreapp3.0 - ApiVersion=2.2.7;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.2.8;RestoreRecursive=false;BuildProjectReferences=false netcoreapp3.1 - ApiVersion=2.2.7;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.2.8;RestoreRecursive=false;BuildProjectReferences=false net5.0 - ApiVersion=2.2.7;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.2.8;RestoreRecursive=false;BuildProjectReferences=false net6.0 diff --git a/tracer/build/PackageVersionsLatestMinors.g.props b/tracer/build/PackageVersionsLatestMinors.g.props index 755e6d615..69eec8941 100644 --- a/tracer/build/PackageVersionsLatestMinors.g.props +++ b/tracer/build/PackageVersionsLatestMinors.g.props @@ -25,7 +25,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely net461 - ApiVersion=3.7.2;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=3.7.2.2;RestoreRecursive=false;BuildProjectReferences=false net461 @@ -37,7 +37,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely netcoreapp2.1 - ApiVersion=3.7.2;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=3.7.2.2;RestoreRecursive=false;BuildProjectReferences=false netcoreapp2.1 @@ -49,7 +49,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely netcoreapp3.0 - ApiVersion=3.7.2;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=3.7.2.2;RestoreRecursive=false;BuildProjectReferences=false netcoreapp3.0 @@ -61,7 +61,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely netcoreapp3.1 - ApiVersion=3.7.2;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=3.7.2.2;RestoreRecursive=false;BuildProjectReferences=false netcoreapp3.1 @@ -73,7 +73,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely net5.0 - ApiVersion=3.7.2;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=3.7.2.2;RestoreRecursive=false;BuildProjectReferences=false net5.0 @@ -85,7 +85,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely net6.0 - ApiVersion=3.7.2;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=3.7.2.2;RestoreRecursive=false;BuildProjectReferences=false net6.0 @@ -145,7 +145,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely net461 - ApiVersion=2.14.0;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.14.1;RestoreRecursive=false;BuildProjectReferences=false net461 @@ -193,7 +193,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely netcoreapp2.1 - ApiVersion=2.14.0;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.14.1;RestoreRecursive=false;BuildProjectReferences=false netcoreapp2.1 @@ -241,7 +241,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely netcoreapp3.0 - ApiVersion=2.14.0;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.14.1;RestoreRecursive=false;BuildProjectReferences=false netcoreapp3.0 @@ -289,7 +289,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely netcoreapp3.1 - ApiVersion=2.14.0;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.14.1;RestoreRecursive=false;BuildProjectReferences=false netcoreapp3.1 @@ -337,7 +337,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely net5.0 - ApiVersion=2.14.0;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.14.1;RestoreRecursive=false;BuildProjectReferences=false net5.0 @@ -385,7 +385,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely net6.0 - ApiVersion=2.14.0;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.14.1;RestoreRecursive=false;BuildProjectReferences=false net6.0 @@ -1097,7 +1097,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely net461 - ApiVersion=6.0.0;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=6.0.1;RestoreRecursive=false;BuildProjectReferences=false net461 @@ -1137,7 +1137,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely netcoreapp3.1 - ApiVersion=6.0.0;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=6.0.1;RestoreRecursive=false;BuildProjectReferences=false netcoreapp3.1 @@ -1153,7 +1153,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely net5.0 - ApiVersion=6.0.0;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=6.0.1;RestoreRecursive=false;BuildProjectReferences=false net5.0 @@ -1169,7 +1169,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely net6.0 - ApiVersion=6.0.0;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=6.0.1;RestoreRecursive=false;BuildProjectReferences=false net6.0 @@ -2212,6 +2212,10 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely ApiVersion=2.0.0;RestoreRecursive=false;BuildProjectReferences=false net461 + + ApiVersion=2.1.0;RestoreRecursive=false;BuildProjectReferences=false + net461 + ApiVersion=1.0.1;RestoreRecursive=false;BuildProjectReferences=false netcoreapp2.1 @@ -2232,6 +2236,10 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely ApiVersion=2.0.0;RestoreRecursive=false;BuildProjectReferences=false netcoreapp2.1 + + ApiVersion=2.1.0;RestoreRecursive=false;BuildProjectReferences=false + netcoreapp2.1 + ApiVersion=1.0.1;RestoreRecursive=false;BuildProjectReferences=false netcoreapp3.0 @@ -2252,6 +2260,10 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely ApiVersion=2.0.0;RestoreRecursive=false;BuildProjectReferences=false netcoreapp3.0 + + ApiVersion=2.1.0;RestoreRecursive=false;BuildProjectReferences=false + netcoreapp3.0 + ApiVersion=1.0.1;RestoreRecursive=false;BuildProjectReferences=false netcoreapp3.1 @@ -2272,6 +2284,10 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely ApiVersion=2.0.0;RestoreRecursive=false;BuildProjectReferences=false netcoreapp3.1 + + ApiVersion=2.1.0;RestoreRecursive=false;BuildProjectReferences=false + netcoreapp3.1 + ApiVersion=1.0.1;RestoreRecursive=false;BuildProjectReferences=false net5.0 @@ -2292,6 +2308,10 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely ApiVersion=2.0.0;RestoreRecursive=false;BuildProjectReferences=false net5.0 + + ApiVersion=2.1.0;RestoreRecursive=false;BuildProjectReferences=false + net5.0 + ApiVersion=1.0.1;RestoreRecursive=false;BuildProjectReferences=false net6.0 @@ -2312,6 +2332,10 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely ApiVersion=2.0.0;RestoreRecursive=false;BuildProjectReferences=false net6.0 + + ApiVersion=2.1.0;RestoreRecursive=false;BuildProjectReferences=false + net6.0 + ApiVersion=2.0.1;RestoreRecursive=false;BuildProjectReferences=false net461 @@ -2753,7 +2777,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely net461 - ApiVersion=2.2.7;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.2.8;RestoreRecursive=false;BuildProjectReferences=false net461 @@ -2765,7 +2789,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely netcoreapp2.1 - ApiVersion=2.2.7;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.2.8;RestoreRecursive=false;BuildProjectReferences=false netcoreapp2.1 @@ -2777,7 +2801,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely netcoreapp3.0 - ApiVersion=2.2.7;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.2.8;RestoreRecursive=false;BuildProjectReferences=false netcoreapp3.0 @@ -2789,7 +2813,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely netcoreapp3.1 - ApiVersion=2.2.7;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.2.8;RestoreRecursive=false;BuildProjectReferences=false netcoreapp3.1 @@ -2801,7 +2825,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely net5.0 - ApiVersion=2.2.7;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.2.8;RestoreRecursive=false;BuildProjectReferences=false net5.0 @@ -2813,7 +2837,7 @@ NOTE: This code was generated by the GeneratePackageVersions tool. To safely net6.0 - ApiVersion=2.2.7;RestoreRecursive=false;BuildProjectReferences=false + ApiVersion=2.2.8;RestoreRecursive=false;BuildProjectReferences=false net6.0 diff --git a/tracer/build/_build/BenchmarkComparison/BenchmarkComparer.cs b/tracer/build/_build/BenchmarkComparison/BenchmarkComparer.cs index a93bcbee3..57536a38f 100644 --- a/tracer/build/_build/BenchmarkComparison/BenchmarkComparer.cs +++ b/tracer/build/_build/BenchmarkComparison/BenchmarkComparer.cs @@ -73,7 +73,7 @@ public static List MatchAndCompareResults( var baseSummariesByName = baseSummary.Results .ToDictionary(b => $"{b.Method}-{b.Toolchain}", x => x); - var diffSummariesByName = baseSummary.Results + var diffSummariesByName = diffSummary.Results .ToDictionary(b => $"{b.Method}-{b.Toolchain}", x => x); var summaryKeys = baseSummariesByName.Keys.Concat(diffSummariesByName.Keys).Distinct(); @@ -143,7 +143,7 @@ private static IEnumerable CompareAllocations( } var zero = ByteSize.FromBytes(0); - var difference = baseBytes - diffBytes; + var difference = diffBytes - baseBytes; // handle divide by zero var percentageDifference = difference == zero ? 0 : baseBytes.Bytes / difference.Bytes; diff --git a/tracer/build/_build/BenchmarkComparison/BenchmarkMarkdownGenerator.cs b/tracer/build/_build/BenchmarkComparison/BenchmarkMarkdownGenerator.cs index aa8d0e0f5..f0ae2d0a1 100644 --- a/tracer/build/_build/BenchmarkComparison/BenchmarkMarkdownGenerator.cs +++ b/tracer/build/_build/BenchmarkComparison/BenchmarkMarkdownGenerator.cs @@ -213,8 +213,8 @@ private static void WriteAllocationChangesTable( Id = result.Id, BaseAllocation = result.BaseResult.Allocated, DiffAllocation = result.DiffResult.Allocated, - Change = (baseSize - diffSize).ToString(), - PercentChange = (baseSize - diffSize).Bytes / baseSize.Bytes, + Change = (diffSize - baseSize).ToString(), + PercentChange = (diffSize - baseSize).Bytes / baseSize.Bytes, }; }) .OrderByDescending(result => result.PercentChange) diff --git a/tracer/build/_build/Build.ExplorationTests.cs b/tracer/build/_build/Build.ExplorationTests.cs new file mode 100644 index 000000000..eae31d2db --- /dev/null +++ b/tracer/build/_build/Build.ExplorationTests.cs @@ -0,0 +1,314 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Nuke.Common; +using Nuke.Common.IO; +using Nuke.Common.Tools.DotNet; +using Nuke.Common.Tooling; +using Nuke.Common.Tools.Git; +using static Nuke.Common.Tools.DotNet.DotNetTasks; + +partial class Build +{ + AbsolutePath ExplorationTestsDirectory => RootDirectory / "exploration-tests"; + + [Parameter("Indicates name of exploration test to run. If not specified, will run all tests sequentially.")] + readonly ExplorationTestName? ExplorationTestName; + + [Parameter("Indicates whether exploration tests should skip repository cloning. Useful for local development. Default false.")] + readonly bool ExplorationTestSkipClone; + + [Parameter("Indicates whether exploration tests should run on latest repository commit. Useful if you want to update tested repositories to the latest tags. Default false.", + List = false)] + readonly bool ExplorationTestCloneLatest; + + Target RunExplorationTests_Debugger + => _ => _ + .Description("Run exploration tests for debugger.") + .After(Clean, BuildTracerHome) + .Executes(() => + { + try + { + SetUpExplorationTest_Debugger(); + + var envVariables = GetEnvVariables(ExplorationTestUseCase.Debugger); + RunExplorationTestsGitCloneAndUnitTest(envVariables); + RunExplorationTestAssertions_Debugger(); + } + finally + { + MoveLogsToBuildData(); + } + + void SetUpExplorationTest_Debugger() + { + Logger.Info($"Prepare environment variables for profiler."); + //TODO TBD + } + + void RunExplorationTestAssertions_Debugger() + { + Logger.Info($"Running assertions tests for debugger."); + //TODO TBD + } + }) + ; + + + Target RunExplorationTests_ContinuousProfiler + => _ => _ + .Description("Run exploration tests for profiler.") + .After(Clean, BuildTracerHome) + .Executes(() => + { + try + { + SetUpExplorationTest_ContinuousProfiler(); + + var envVariables = GetEnvVariables(ExplorationTestUseCase.ContinuousProfiler); + RunExplorationTestsGitCloneAndUnitTest(envVariables); + RunExplorationTestAssertions_ContinuousProfiler(); + } + finally + { + MoveLogsToBuildData(); + } + + void SetUpExplorationTest_ContinuousProfiler() + { + Logger.Info($"Prepare environment variables for profiler."); + //TODO TBD + } + + void RunExplorationTestAssertions_ContinuousProfiler() + { + Logger.Info($"Running assertions tests for profiler."); + //TODO TBD + } + }) + ; + + Dictionary GetEnvVariables(ExplorationTestUseCase usecase) + { + var envVariables = new Dictionary(); + switch (usecase) + { + case ExplorationTestUseCase.Debugger: + envVariables.AddDebuggerEnvironmentVariables(TracerHomeDirectory); + break; + case ExplorationTestUseCase.ContinuousProfiler: + envVariables.AddContinuousProfilerEnvironmentVariables(TracerHomeDirectory); + break; + default: + throw new ArgumentOutOfRangeException(nameof(usecase), usecase, null); + } + + envVariables["SIGNALFX_SERVICE"]="exploration_tests"; + envVariables["SIGNALFX_VERSION"]=Version; + + envVariables.AddExtraEnvVariables(ExtraEnvVars); + return envVariables; + } + + void RunExplorationTestsGitCloneAndUnitTest(Dictionary envVariables) + { + if (ExplorationTestName.HasValue) + { + Logger.Info($"Provided exploration test name is {ExplorationTestName}."); + + var testDescription = ExplorationTestDescription.GetExplorationTestDescription(ExplorationTestName.Value); + + GitCloneAndRunUnitTest(testDescription, envVariables); + } + else + { + Logger.Info($"Exploration test name is not provided. Running all."); + + foreach (var testDescription in ExplorationTestDescription.GetAllExplorationTestDescriptions()) + { + GitCloneAndRunUnitTest(testDescription, envVariables); + } + } + } + + void GitCloneAndRunUnitTest(ExplorationTestDescription testDescription, Dictionary envVariables) + { + Logger.Info($"Running exploration test {testDescription.Name}."); + + if (Framework != null && !testDescription.IsFrameworkSupported(Framework)) + { + Logger.Warn($"This framework '{Framework}' is not listed in the project's target frameworks of {testDescription.Name}"); + return; + } + + var projectPath = GitClone(testDescription); + Logger.Info($"Test project path is {projectPath}"); + + DotNetBuild( + x => x + .SetProjectFile(projectPath) + .SetConfiguration(BuildConfiguration) + .SetProcessArgumentConfigurator(arguments => arguments.Add("-consoleLoggerParameters:ErrorsOnly")) + .When(Framework != null, settings => settings.SetFramework(Framework)) + ); + + DotNetTest( + x => + { + x = x + .When(!testDescription.IsTestedByVSTest, settings => settings.SetProjectFile(projectPath)) + .When(testDescription.IsTestedByVSTest + , settings => + { + var frameworkFolder = Framework ?? "*"; + var projectName = Path.GetFileName(projectPath); + + return settings.SetProjectFile($"{projectPath}/bin/{BuildConfiguration}/{frameworkFolder}/{projectName}.exe"); + }) + .EnableNoRestore() + .EnableNoBuild() + .SetConfiguration(BuildConfiguration) + .When(Framework != null, settings => settings.SetFramework(Framework)) + .SetProcessEnvironmentVariables(envVariables) + .SetIgnoreFilter(testDescription.TestsToIgnore) + .WithMemoryDumpAfter(5) + ; + + return x; + }); + } + + string GitClone(ExplorationTestDescription testDescription) + { + if (!ExplorationTestSkipClone) + { + var depth = testDescription.IsGitShallowCloneSupported ? "--depth 1" : ""; + var submodules = testDescription.IsGitSubmodulesRequired ? "--recurse-submodules" : ""; + var source = ExplorationTestCloneLatest ? $"-b {testDescription.GitRepositoryTag} {testDescription.GitRepositoryUrl}" : testDescription.GitRepositoryUrl; + var target = $"{ExplorationTestsDirectory}/{testDescription.Name}"; + + var cloneCommand = $"clone -q -c advice.detachedHead=false {depth} {submodules} {source} {target}"; + GitTasks.Git(cloneCommand); + } + + var projectPath = $"{ExplorationTestsDirectory}/{testDescription.Name}/{testDescription.PathToUnitTestProject}"; + if (!Directory.Exists(projectPath)) + { + throw new DirectoryNotFoundException($"Test path '{projectPath}' doesn't exist."); + } + + return projectPath; + } +} + + +public enum ExplorationTestUseCase +{ + Debugger, ContinuousProfiler +} + +public enum ExplorationTestName +{ + eShopOnWeb, protobuf, cake, swashbuckle, paket, ilspy +} + +class ExplorationTestDescription +{ + public string Name { get; set; } + + public string GitRepositoryUrl { get; set; } + public string GitRepositoryTag { get; set; } + public bool IsGitShallowCloneSupported { get; set; } + public bool IsGitSubmodulesRequired { get; set; } + + public string PathToUnitTestProject { get; set; } + public bool IsTestedByVSTest { get; set; } + public string[] TestsToIgnore { get; set; } + + + public TargetFramework[] SupportedFrameworks { get; set; } + + public bool IsFrameworkSupported(TargetFramework targetFramework) + { + return SupportedFrameworks.Any(framework => framework.Equals(targetFramework)); + } + + public static ExplorationTestDescription[] GetAllExplorationTestDescriptions() + { + return Enum.GetValues() + .Select(GetExplorationTestDescription) + .ToArray() + ; + } + + public static ExplorationTestDescription GetExplorationTestDescription(ExplorationTestName name) + { + var description = name switch + { + ExplorationTestName.eShopOnWeb => new ExplorationTestDescription() + { + Name = "eShopOnWeb", + GitRepositoryUrl = "https://github.com/dotnet-architecture/eShopOnWeb.git", + GitRepositoryTag = "netcore2.1", + IsGitShallowCloneSupported = true, + PathToUnitTestProject = "tests/UnitTests", + SupportedFrameworks = new[] { TargetFramework.NETCOREAPP2_1 }, + }, + ExplorationTestName.protobuf => new ExplorationTestDescription() + { + Name = "protobuf", + GitRepositoryUrl = "https://github.com/protocolbuffers/protobuf.git", + GitRepositoryTag = "v3.19.1", + IsGitShallowCloneSupported = true, + IsGitSubmodulesRequired = true, + PathToUnitTestProject = "csharp/src/Google.Protobuf.Test", + SupportedFrameworks = new[] { TargetFramework.NETCOREAPP2_1, TargetFramework.NET5_0, }, + }, + ExplorationTestName.cake => new ExplorationTestDescription() + { + Name = "cake", + GitRepositoryUrl = "https://github.com/cake-build/cake.git", + GitRepositoryTag = "v1.3.0", + IsGitShallowCloneSupported = true, + PathToUnitTestProject = "src/Cake.Common.Tests", + SupportedFrameworks = new[] { TargetFramework.NETCOREAPP3_1, TargetFramework.NET5_0, TargetFramework.NET6_0 }, + }, + ExplorationTestName.swashbuckle => new ExplorationTestDescription() + { + Name = "Swashbuckle.AspNetCore", + GitRepositoryUrl = "https://github.com/domaindrivendev/Swashbuckle.AspNetCore.git", + GitRepositoryTag = "v6.2.3", + IsGitShallowCloneSupported = true, + PathToUnitTestProject = "test/Swashbuckle.AspNetCore.SwaggerGen.Test", + SupportedFrameworks = new[] { TargetFramework.NET6_0 }, + }, + ExplorationTestName.paket => new ExplorationTestDescription() + { + Name = "Paket", + GitRepositoryUrl = "https://github.com/fsprojects/Paket.git", + GitRepositoryTag = "6.2.1", + IsGitShallowCloneSupported = true, + PathToUnitTestProject = "tests/Paket.Tests", + TestsToIgnore = new[] { "Loading assembly metadata works" }, + SupportedFrameworks = new[] { TargetFramework.NET461, TargetFramework.NETCOREAPP3_1 }, + }, + ExplorationTestName.ilspy => new ExplorationTestDescription() + { + Name = "ILSpy", + GitRepositoryUrl = "https://github.com/icsharpcode/ILSpy.git", + GitRepositoryTag = "v7.1", + IsGitSubmodulesRequired = true, + PathToUnitTestProject = "ICSharpCode.Decompiler.Tests", + IsTestedByVSTest = true, + TestsToIgnore = new[] { "UseMc", "_net45", "ImplicitConversions", "ExplicitConversions", "ICSharpCode_Decompiler", "NewtonsoftJson_pcl_debug", "NRefactory_CSharp", "Random_TestCase_1", "AsyncForeach", "AsyncStreams", "AsyncUsing", "CS9_ExtensionGetEnumerator", "IndexRangeTest", "InterfaceTests", "UsingVariables" }, + SupportedFrameworks = new[] { TargetFramework.NET461 }, + }, + _ => throw new ArgumentOutOfRangeException(nameof(name), name, null) + }; + + return description; + } +} + diff --git a/tracer/build/_build/Build.GitHub.cs b/tracer/build/_build/Build.GitHub.cs index e5714ca24..1dccf8af7 100644 --- a/tracer/build/_build/Build.GitHub.cs +++ b/tracer/build/_build/Build.GitHub.cs @@ -114,7 +114,7 @@ await client.Issue.Milestone.Update( Target VerifyChangedFilesFromVersionBump => _ => _ .Unlisted() .Description("Verifies that the expected files were changed") - .After(UpdateVersion, UpdateMsiContents, UpdateIntegrationsJson, UpdateChangeLog) + .After(UpdateVersion, UpdateMsiContents, UpdateIntegrationDefinitions, UpdateChangeLog) .Executes(() => { var expectedFileChanges = new [] diff --git a/tracer/build/_build/Build.Profiler.Steps.cs b/tracer/build/_build/Build.Profiler.Steps.cs index acb7a74b4..4e9e5fd3a 100644 --- a/tracer/build/_build/Build.Profiler.Steps.cs +++ b/tracer/build/_build/Build.Profiler.Steps.cs @@ -20,7 +20,7 @@ partial class Build { List projects = new(); projects.Add(SharedDirectory.GlobFiles("**/Datadog.AutoInstrumentation.ManagedLoader.csproj").Single()); - projects.Add(ProfilerDirectory.GlobFiles("**/Datadog.AutoInstrumentation.Profiler.Managed.csproj").Single()); + projects.Add(ProfilerDirectory.GlobFiles("**/Datadog.Profiler.Managed.csproj").Single()); // Build the shared managed loader DotNetBuild(s => s @@ -41,9 +41,8 @@ partial class Build .OnlyWhenStatic(() => IsWin) .Executes(() => { - var project = ProfilerDirectory.GlobFiles("**/Datadog.AutoInstrumentation.Profiler.Native.Windows.vcxproj").Single(); + var project = ProfilerDirectory.GlobFiles("**/Datadog.Profiler.Native.Windows.vcxproj").Single(); - // run: msbuild /property:Configuration=${{matrix.configuration}} /property:Platform=${{matrix.platform}} dd-continuous-profiler-dotnet\src\ProfilerEngine\Datadog.AutoInstrumentation.Profiler.Native.Windows\Datadog.AutoInstrumentation.Profiler.Native.Windows.WithTests.proj // If we're building for x64, build for x86 too var platforms = Equals(TargetPlatform, MSBuildTargetPlatform.x64) diff --git a/tracer/build/_build/Build.Shared.Steps.cs b/tracer/build/_build/Build.Shared.Steps.cs index cdc68cc71..275cc6875 100644 --- a/tracer/build/_build/Build.Shared.Steps.cs +++ b/tracer/build/_build/Build.Shared.Steps.cs @@ -20,9 +20,8 @@ partial class Build .OnlyWhenStatic(() => IsWin) .Executes(() => { - var project = ProfilerDirectory.GlobFiles("**/Datadog.AutoInstrumentation.Profiler.Native.Windows.vcxproj").Single(); + var project = ProfilerDirectory.GlobFiles("**/Datadog.Profiler.Native.Windows.vcxproj").Single(); - // run: msbuild /property:Configuration=${{matrix.configuration}} /property:Platform=${{matrix.platform}} dd-continuous-profiler-dotnet\src\ProfilerEngine\Datadog.AutoInstrumentation.Profiler.Native.Windows\Datadog.AutoInstrumentation.Profiler.Native.Windows.WithTests.proj // If we're building for x64, build for x86 too var platforms = Equals(TargetPlatform, MSBuildTargetPlatform.x64) diff --git a/tracer/build/_build/Build.Steps.cs b/tracer/build/_build/Build.Steps.cs index a1054ed47..c119314a6 100644 --- a/tracer/build/_build/Build.Steps.cs +++ b/tracer/build/_build/Build.Steps.cs @@ -271,10 +271,14 @@ partial class Build var libDdwafUri = new Uri($"https://www.nuget.org/api/v2/package/libddwaf/{LibDdwafVersion}"); var libDdwafZip = TempDirectory / "libddwaf.zip"; - using (var httpClient = new HttpClient()) + using (var client = new HttpClient()) { - await using var stream = await httpClient.GetStreamAsync(libDdwafUri); + var response = await client.GetAsync(libDdwafUri); + + response.EnsureSuccessStatusCode(); + await using var file = File.Create(libDdwafZip); + await using var stream = await response.Content.ReadAsStreamAsync(); await stream.CopyToAsync(file); } @@ -1128,6 +1132,12 @@ _ when project.Path.ToString().Contains("Samples.OracleMDA") => false, var project = Solution.GetProject(path); return project?.Name switch { + "LogsInjection.Log4Net.VersionConflict.2x" => Framework != TargetFramework.NETCOREAPP2_1, + "LogsInjection.NLog.VersionConflict.2x" => Framework != TargetFramework.NETCOREAPP2_1, + "LogsInjection.NLog10.VersionConflict.2x" => Framework == TargetFramework.NET461, + "LogsInjection.NLog20.VersionConflict.2x" => Framework == TargetFramework.NET461, + "LogsInjection.Serilog.VersionConflict.2x" => Framework != TargetFramework.NETCOREAPP2_1, + "LogsInjection.Serilog14.VersionConflict.2x" => Framework == TargetFramework.NET461, "Samples.AspNetCoreMvc21" => Framework == TargetFramework.NETCOREAPP2_1, "Samples.AspNetCoreMvc30" => Framework == TargetFramework.NETCOREAPP3_0, "Samples.AspNetCoreMvc31" => Framework == TargetFramework.NETCOREAPP3_1, diff --git a/tracer/build/_build/Build.Utilities.cs b/tracer/build/_build/Build.Utilities.cs index 78f0a986f..9dad573a5 100644 --- a/tracer/build/_build/Build.Utilities.cs +++ b/tracer/build/_build/Build.Utilities.cs @@ -99,14 +99,7 @@ partial class Build envVars["COR_PROFILER_PATH_32"] = TracerHomeDirectory / "win-x86" / "SignalFx.Tracing.ClrProfiler.Native.dll"; envVars["SIGNALFX_DOTNET_TRACER_HOME"] = TracerHomeDirectory; - if (ExtraEnvVars?.Length > 0) - { - foreach (var envVar in ExtraEnvVars) - { - var kvp = envVar.Split('='); - envVars[kvp[0]] = kvp[1]; - } - } + envVars.AddExtraEnvVariables(ExtraEnvVars); Logger.Info($"Running sample '{SampleName}' in IIS Express"); IisExpress.Value( @@ -118,45 +111,18 @@ partial class Build .Description("Builds and runs a sample app using dotnet run, enabling profiling.") .Requires(() => SampleName) .Requires(() => Framework) - .Executes(() => - { - var envVars = new Dictionary() - { - {"COR_ENABLE_PROFILING", "1"}, - {"COR_PROFILER", "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}"}, - {"COR_PROFILER_PATH_32", TracerHomeDirectory / "win-x86" / "SignalFx.Tracing.ClrProfiler.Native.dll"}, - {"COR_PROFILER_PATH_64", TracerHomeDirectory / "win-x64" / "SignalFx.Tracing.ClrProfiler.Native.dll"}, - {"CORECLR_ENABLE_PROFILING", "1"}, - {"CORECLR_PROFILER", "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}"}, - {"SIGNALFX_DOTNET_TRACER_HOME", TracerHomeDirectory }, - {"ASPNETCORE_URLS", "https://*:5003" }, - }; - - if (IsWin) - { - envVars.Add("CORECLR_PROFILER_PATH_32", TracerHomeDirectory / "win-x86" / "SignalFx.Tracing.ClrProfiler.Native.dll"); - envVars.Add("CORECLR_PROFILER_PATH_64", TracerHomeDirectory / "win-x64" / "SignalFx.Tracing.ClrProfiler.Native.dll"); - } - else - { - envVars.Add("CORECLR_PROFILER_PATH", TracerHomeDirectory / "SignalFx.Tracing.ClrProfiler.Native.so"); - } + .Executes(() => { - if (ExtraEnvVars?.Length > 0) - { - foreach (var envVar in ExtraEnvVars) - { - var kvp = envVar.Split('='); - envVars[kvp[0]] = kvp[1]; - } - } + var envVars = new Dictionary { { "ASPNETCORE_URLS", "http://*:5003" } }; + envVars.AddTracerEnvironmentVariables(TracerHomeDirectory); + envVars.AddExtraEnvVariables(ExtraEnvVars); string project = Solution.GetProject(SampleName)?.Path; if (project is not null) { Logger.Info($"Running sample '{SampleName}'"); } - else if(System.IO.File.Exists(SampleName)) + else if (System.IO.File.Exists(SampleName)) { project = SampleName; Logger.Info($"Running project '{SampleName}'"); @@ -188,13 +154,23 @@ partial class Build Target GeneratePackageVersions => _ => _ .Description("Regenerate the PackageVersions props and .cs files") - .After(UpdateIntegrationsJson) + .After(UpdateIntegrationDefinitions) .Executes(async () => { var testDir = Solution.GetProject(Projects.ClrProfilerIntegrationTests).Directory; var versionGenerator = new PackageVersionGenerator(TracerDirectory, testDir); await versionGenerator.GenerateVersions(Solution); + + var assemblies = TracerHomeDirectory + .GlobFiles("**/Datadog.Trace.dll") + .Select(x => x.ToString()) + .ToList(); + + var integrations = GenerateIntegrationDefinitions.GetAllIntegrations(assemblies); + + var dependabotProj = TracerDirectory / "dependabot" / "Datadog.Dependabot.Integrations.csproj"; + await DependabotFileManager.UpdateIntegrations(dependabotProj, integrations); }); Target UpdateVendoredCode => _ => _ @@ -210,23 +186,19 @@ partial class Build await UpdateVendorsTool.UpdateVendors(downloadDirectory, vendorDirectory); }); - Target UpdateIntegrationsJson => _ => _ + Target UpdateIntegrationDefinitions => _ => _ .Description("Update the integration definitions file") .DependsOn(Clean, Restore, CreateRequiredDirectories, CompileManagedSrc, PublishManagedProfiler) // We load the dlls from the output, so need to do a clean build - .Executes(async () => + .Executes(() => { var assemblies = TracerHomeDirectory .GlobFiles("**/SignalFx.Tracing.dll") .Select(x => x.ToString()) .ToList(); - var integrations = GenerateIntegrationDefinitions.GetAllIntegrations(assemblies); GenerateIntegrationDefinitions.Run(integrations, TracerDirectory); - - var dependabotProj = TracerDirectory / "dependabot" / "Datadog.Dependabot.Integrations.csproj"; - await DependabotFileManager.UpdateIntegrations(dependabotProj, integrations); }); Target UpdateVersion => _ => _ diff --git a/tracer/build/_build/Build.cs b/tracer/build/_build/Build.cs index bac704c94..d92fcfba2 100644 --- a/tracer/build/_build/Build.cs +++ b/tracer/build/_build/Build.cs @@ -118,6 +118,7 @@ partial class Build : NukeBuild EnsureCleanDirectory(NativeProfilerProject.Directory / "build"); EnsureCleanDirectory(NativeProfilerProject.Directory / "deps"); EnsureCleanDirectory(BuildDataDirectory); + EnsureCleanDirectory(ExplorationTestsDirectory); DeleteFile(WindowsTracerHomeZip); void DeleteReparsePoints(string path) diff --git a/tracer/build/_build/BuildExtensions.cs b/tracer/build/_build/BuildExtensions.cs deleted file mode 100644 index d357dae67..000000000 --- a/tracer/build/_build/BuildExtensions.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Nuke.Common.Tooling; -using Nuke.Common.Tools.DotNet; - -public static class BuildExtensions -{ - public static DotNetTestSettings WithMemoryDumpAfter(this DotNetTestSettings settings, int timeoutInMinutes) - { - return settings.SetProcessArgumentConfigurator( - args => - args.Add("--blame-hang") - .Add("--blame-hang-dump-type full") - .Add($"--blame-hang-timeout {timeoutInMinutes}m") - ); - } -} diff --git a/tracer/build/_build/BuildVariables.cs b/tracer/build/_build/BuildVariables.cs new file mode 100644 index 000000000..88490b158 --- /dev/null +++ b/tracer/build/_build/BuildVariables.cs @@ -0,0 +1,53 @@ +using System.Collections.Generic; +using Nuke.Common; +using Nuke.Common.IO; + +public static class BuildVariables +{ + public static void AddDebuggerEnvironmentVariables(this Dictionary envVars, AbsolutePath tracerHomeDirectory) + { + envVars.AddTracerEnvironmentVariables(tracerHomeDirectory); + envVars.Add("SINGNALFX_DEBUGGER_ENABLED", "1"); + } + + public static void AddContinuousProfilerEnvironmentVariables(this Dictionary envVars, AbsolutePath tracerHomeDirectory) + { + envVars.AddTracerEnvironmentVariables(tracerHomeDirectory); + } + + public static void AddTracerEnvironmentVariables(this Dictionary envVars, AbsolutePath tracerHomeDirectory) + { + envVars.Add("COR_ENABLE_PROFILING", "1"); + envVars.Add("COR_PROFILER", "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}"); + envVars.Add("COR_PROFILER_PATH_32", tracerHomeDirectory / "win-x86" / "SignalFx.Tracing.ClrProfiler.Native.dll"); + envVars.Add("COR_PROFILER_PATH_64", tracerHomeDirectory / "win-x64" / "SignalFx.Tracing.ClrProfiler.Native.dll"); + envVars.Add("CORECLR_ENABLE_PROFILING", "1"); + envVars.Add("CORECLR_PROFILER", "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}"); + envVars.Add("SIGNALFX_DOTNET_TRACER_HOME", tracerHomeDirectory); + + + if (EnvironmentInfo.IsWin) + { + envVars.Add("CORECLR_PROFILER_PATH_32", tracerHomeDirectory / "win-x86" / "SignalFx.Tracing.ClrProfiler.Native.dll"); + envVars.Add("CORECLR_PROFILER_PATH_64", tracerHomeDirectory / "win-x64" / "SignalFx.Tracing.ClrProfiler.Native.dll"); + } + else + { + envVars.Add("CORECLR_PROFILER_PATH", tracerHomeDirectory / "SignalFx.Tracing.ClrProfiler.Native.so"); + } + } + + public static void AddExtraEnvVariables(this Dictionary envVars, string[] extraEnvVars) + { + if (extraEnvVars == null || extraEnvVars.Length == 0) + { + return; + } + + foreach (var envVar in extraEnvVars) + { + var kvp = envVar.Split('='); + envVars[kvp[0]] = kvp[1]; + } + } +} diff --git a/tracer/build/_build/Honeypot/IntegrationGroups.cs b/tracer/build/_build/Honeypot/IntegrationGroups.cs index 92d4d6694..0edd23c44 100644 --- a/tracer/build/_build/Honeypot/IntegrationGroups.cs +++ b/tracer/build/_build/Honeypot/IntegrationGroups.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Threading.Tasks; using GeneratePackageVersions; +using Nuke.Common; namespace Honeypot { @@ -116,7 +117,10 @@ private async Task PopulatePackages() var packages = await NuGetPackageHelper.GetPackageMetadatas(searchCriteria); - var potentiallySupportedPackages = packages.Where(p => p.Identity.HasVersion).OrderByDescending(p => p.Identity.Version); + var potentiallySupportedPackages = packages + .Where(p => p.Identity.HasVersion) + .OrderByDescending(p => p.Identity.Version) + .ToList(); // TODO: Download and check referenced assemblies for assembly versions //foreach (var potentiallySupportedPackage in potentiallySupportedPackages) @@ -127,11 +131,24 @@ private async Task PopulatePackages() var latestPackage = potentiallySupportedPackages.First(); var latestVersion = new Version(latestPackage.Identity.Version.ToNormalizedString()); + var latestSupportedPackage = potentiallySupportedPackages + .FirstOrDefault(x => x.Identity.Version.Version <= MaximumAssemblyVersion); + + if (latestSupportedPackage is null) + { + Logger.Warn($"No version of {packageName} below maximum package version {MaximumAssemblyVersion}." + + $"Using latest instead"); + } + + var latestSupportedVersion = latestSupportedPackage is null + ? latestVersion + : new Version(latestSupportedPackage.Identity.Version.ToNormalizedString()); + Packages.Add(new IntegrationPackage { NugetName = latestPackage.Identity.Id, LatestNuget = latestVersion, - LatestSupportedNuget = latestVersion, + LatestSupportedNuget = latestSupportedVersion, }); } } diff --git a/tracer/build/_build/NukeExtensions/DotNetSettingsExtensions.cs b/tracer/build/_build/NukeExtensions/DotNetSettingsExtensions.cs index 8d2a77736..17a9a5cc9 100644 --- a/tracer/build/_build/NukeExtensions/DotNetSettingsExtensions.cs +++ b/tracer/build/_build/NukeExtensions/DotNetSettingsExtensions.cs @@ -1,9 +1,10 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; +using System.Text; using Nuke.Common; using Nuke.Common.IO; -using Nuke.Common.ProjectModel; using Nuke.Common.Tooling; using Nuke.Common.Tools.DotNet; using Nuke.Common.Tools.MSBuild; @@ -77,7 +78,7 @@ public static T SetProcessEnvironmentVariables(this T settings, IEnumerable(this T settings) where T: MSBuildSettings { @@ -126,4 +127,38 @@ public static T SetDotnetPath(this T settings, MSBuildTargetPlatform platform return settings.SetProcessToolPath(dotnetPath); } + + /// + /// Set filters for tests to ignore + /// + public static T SetIgnoreFilter(this T settings, string[] testsToIgnore) + where T : DotNetTestSettings + { + if (testsToIgnore != null && testsToIgnore.Any()) + { + var sb = new StringBuilder(); + foreach (var testToIgnore in testsToIgnore) + { + sb.Append("FullyQualifiedName!~"); + sb.Append(testToIgnore); + sb.Append(value: '&'); + } + + sb.Remove(sb.Length - 1, 1); + + settings = settings.SetFilter(sb.ToString()); + } + + return settings; + } + + public static DotNetTestSettings WithMemoryDumpAfter(this DotNetTestSettings settings, int timeoutInMinutes) + { + return settings.SetProcessArgumentConfigurator( + args => + args.Add("--blame-hang") + .Add("--blame-hang-dump-type full") + .Add($"--blame-hang-timeout {timeoutInMinutes}m") + ); + } } diff --git a/tracer/build/_build/PrepareRelease/SetAllVersions.cs b/tracer/build/_build/PrepareRelease/SetAllVersions.cs index 5d03db0c3..699769f94 100644 --- a/tracer/build/_build/PrepareRelease/SetAllVersions.cs +++ b/tracer/build/_build/PrepareRelease/SetAllVersions.cs @@ -136,6 +136,10 @@ public void Run() "src/Datadog.Trace.ClrProfiler.Native/dd_profiler_constants.h", FullAssemblyNameReplace); + SynchronizeVersion( + "src/Datadog.Trace.ClrProfiler.Native/dd_profiler_constants.h", + text => FunctionCallReplace(text, "WithVersion")); + // Four-part AssemblyVersion update SynchronizeVersion( "src/Datadog.Trace/TracerConstants.cs", @@ -199,6 +203,15 @@ private string FourPartAssertVersionReplace(string text) return Regex.Replace(text, patternPrefix + VersionPattern(fourPartVersion: true), versionPrefix + FourPartVersionString(), RegexOptions.Singleline); } + private string FunctionCallReplace(string text, string functionName) + { + const string split = ", "; + var pattern = @$"{functionName}\({VersionPattern(split, fourPartVersion: true)}\)"; + var replacement = $"{functionName}({FourPartVersionString(split)})"; + + return Regex.Replace(text, pattern, replacement, RegexOptions.Singleline); + } + private string FourPartVersionReplace(string text) { return Regex.Replace(text, VersionPattern(fourPartVersion: true), FourPartVersionString(), RegexOptions.Singleline); diff --git a/tracer/build/crank/Security.Samples.AspNetCoreSimpleController.yml b/tracer/build/crank/Security.Samples.AspNetCoreSimpleController.yml index 4ff448a73..c656acc69 100644 --- a/tracer/build/crank/Security.Samples.AspNetCoreSimpleController.yml +++ b/tracer/build/crank/Security.Samples.AspNetCoreSimpleController.yml @@ -19,6 +19,22 @@ jobs: - Microsoft.AspNetCore.Http.Connections scenarios: + appsec_baseline: + application: + job: server + environmentVariables: + COR_ENABLE_PROFILING: 1 + CORECLR_ENABLE_PROFILING: 1 + SIGNALFX_APPSEC_ENABLED: false + SIGNALFX_APPSEC_KEEP_TRACES: false + load: + job: bombardier + variables: + warmup: 30 + duration: 240 + serverPort: 5000 + path: /hello + appsec_noattack: application: job: server @@ -27,6 +43,7 @@ scenarios: CORECLR_ENABLE_PROFILING: 1 SIGNALFX_APPSEC_ENABLED: true SIGNALFX_APPSEC_BLOCKING_ENABLED: true + SIGNALFX_APPSEC_KEEP_TRACES: false load: job: bombardier variables: @@ -43,6 +60,7 @@ scenarios: CORECLR_ENABLE_PROFILING: 1 SIGNALFX_APPSEC_ENABLED: true SIGNALFX_APPSEC_BLOCKING_ENABLED: false + SIGNALFX_APPSEC_KEEP_TRACES: false load: job: bombardier variables: diff --git a/tracer/build/crank/run-appsec.sh b/tracer/build/crank/run-appsec.sh new file mode 100644 index 000000000..db3c56b62 --- /dev/null +++ b/tracer/build/crank/run-appsec.sh @@ -0,0 +1,45 @@ +#!/bin/bash +set -eo pipefail + +sha="$(git rev-parse HEAD)" +echo "sha=$sha" +echo "SYSTEM_PULLREQUEST_SOURCECOMMITID=$SYSTEM_PULLREQUEST_SOURCECOMMITID" +echo "BUILD_SOURCEVERSION=$BUILD_SOURCEVERSION" +echo "SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI=$SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI" +echo "BUILD_REPOSITORY_URI=$BUILD_REPOSITORY_URI" + +repo="$SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI" +commit_sha="$SYSTEM_PULLREQUEST_SOURCECOMMITID" + +if [ -z "$repo" ]; then + repo="$BUILD_REPOSITORY_URI" +fi + +if [ -z "$commit_sha" ]; then + commit_sha="$BUILD_SOURCEVERSION" +fi + +echo "Using repo=$repo commit=$commit_sha" + +repository="--application.source.repository $repo" +commit="--application.source.branchOrCommit #$commit_sha" + +if [ "$1" = "linux" ]; then + echo "Running Linux x64 throughput tests" + + crank --config Security.Samples.AspNetCoreSimpleController.yml --scenario appsec_baseline --profile linux --json appsec_baseline.json $repository $commit --property name=AspNetCoreSimpleController --property scenario=appsec_baseline --property profile=linux --property arch=x64 --variable commit_hash=$commit_sha + dd-trace --crank-import="appsec_baseline.json" + rm appsec_baseline.json + + crank --config Security.Samples.AspNetCoreSimpleController.yml --scenario appsec_noattack --profile linux --json appsec_noattack.json $repository $commit --property name=AspNetCoreSimpleController --property scenario=appsec_noattack --property profile=linux --property arch=x64 --variable commit_hash=$commit_sha + dd-trace --crank-import="appsec_noattack.json" + rm appsec_noattack.json + + crank --config Security.Samples.AspNetCoreSimpleController.yml --scenario appsec_attack_noblocking --profile linux --json appsec_attack_noblocking.json $repository $commit --property name=AspNetCoreSimpleController --property scenario=appsec_attack_noblocking --property profile=linux --property arch=x64 --variable commit_hash=$commit_sha + dd-trace --crank-import="appsec_attack_noblocking.json" + rm appsec_attack_noblocking.json + +else + echo "Unknown argument $1" + exit 1 +fi diff --git a/tracer/dependabot/Datadog.Dependabot.Integrations.csproj b/tracer/dependabot/Datadog.Dependabot.Integrations.csproj index 457fdd85c..48838ef35 100644 --- a/tracer/dependabot/Datadog.Dependabot.Integrations.csproj +++ b/tracer/dependabot/Datadog.Dependabot.Integrations.csproj @@ -23,13 +23,13 @@ - - + + - - + + @@ -68,13 +68,13 @@ - - + + - - + + @@ -133,18 +133,18 @@ - - + + - - + + - - + + diff --git a/tracer/src/Datadog.Trace.ClrProfiler.Managed.Loader/Startup.NetFramework.cs b/tracer/src/Datadog.Trace.ClrProfiler.Managed.Loader/Startup.NetFramework.cs index 07fd848de..24af75403 100644 --- a/tracer/src/Datadog.Trace.ClrProfiler.Managed.Loader/Startup.NetFramework.cs +++ b/tracer/src/Datadog.Trace.ClrProfiler.Managed.Loader/Startup.NetFramework.cs @@ -39,9 +39,16 @@ private static Assembly AssemblyResolve_ManagedProfilerDependencies(object sende } var path = Path.Combine(ManagedProfilerDirectory, $"{assemblyName}.dll"); + if (File.Exists(path)) { - StartupLogger.Debug("Loading {0}", path); + if (args.Name.StartsWith("SignalFx.Tracing, Version=") && args.Name != AssemblyName) + { + StartupLogger.Debug("Trying to load {0} which does not match the expected version ({1})", args.Name, AssemblyName); + return null; + } + + StartupLogger.Debug("Resolving {0}, loading {1}", args.Name, path); return Assembly.LoadFrom(path); } diff --git a/tracer/src/Datadog.Trace.ClrProfiler.Managed.Loader/Startup.cs b/tracer/src/Datadog.Trace.ClrProfiler.Managed.Loader/Startup.cs index 5c61c685e..3f56e2018 100644 --- a/tracer/src/Datadog.Trace.ClrProfiler.Managed.Loader/Startup.cs +++ b/tracer/src/Datadog.Trace.ClrProfiler.Managed.Loader/Startup.cs @@ -13,6 +13,8 @@ namespace Datadog.Trace.ClrProfiler.Managed.Loader /// public partial class Startup { + private const string AssemblyName = "SignalFx.Tracing, Version=0.2.0.0, Culture=neutral, PublicKeyToken=e43a27c2023d388a"; + /// /// Initializes static members of the class. /// This method also attempts to load the SignalFx.TracingTrace .NET assembly. @@ -39,13 +41,13 @@ private static void TryLoadManagedAssembly() { try { - var assembly = Assembly.Load("SignalFx.Tracing, Version=0.2.0.0, Culture=neutral, PublicKeyToken=e43a27c2023d388a"); + var assembly = Assembly.Load(AssemblyName); if (assembly != null) { // call method Datadog.Trace.ClrProfiler.Instrumentation.Initialize() var type = assembly.GetType("Datadog.Trace.ClrProfiler.Instrumentation", throwOnError: false); - var method = type?.GetRuntimeMethod("Initialize", parameters: new Type[0]); + var method = type?.GetRuntimeMethod("Initialize", parameters: Type.EmptyTypes); method?.Invoke(obj: null, parameters: null); } } diff --git a/tracer/src/Datadog.Trace.ClrProfiler.Native/clr_helpers.h b/tracer/src/Datadog.Trace.ClrProfiler.Native/clr_helpers.h index 781a7283f..3d6b20840 100644 --- a/tracer/src/Datadog.Trace.ClrProfiler.Native/clr_helpers.h +++ b/tracer/src/Datadog.Trace.ClrProfiler.Native/clr_helpers.h @@ -288,6 +288,26 @@ struct AssemblyProperty AssemblyProperty() : ppbPublicKey(nullptr), pcbPublicKey(0), pulHashAlgId(0), szName(EmptyWStr) { } + + AssemblyProperty(WSTRING szName, void* ppbPublicKey, ULONG pcbPublicKey, ULONG pulHashAlgId, DWORD assemblyFlags) : + szName(szName), + ppbPublicKey(ppbPublicKey), + pcbPublicKey(pcbPublicKey), + pulHashAlgId(pulHashAlgId), + assemblyFlags(assemblyFlags) + { + } + +public: + AssemblyProperty WithVersion(USHORT usMajorVersion, USHORT usMinorVersion, USHORT usBuildNumber, USHORT usRevisionNumber) + { + pMetaData.usMajorVersion = usMajorVersion; + pMetaData.usMinorVersion = usMinorVersion; + pMetaData.usBuildNumber = usBuildNumber; + pMetaData.usRevisionNumber = usRevisionNumber; + + return *this; + } }; struct ModuleInfo diff --git a/tracer/src/Datadog.Trace.ClrProfiler.Native/cor_profiler.cpp b/tracer/src/Datadog.Trace.ClrProfiler.Native/cor_profiler.cpp index e4b49b323..388a4ffe7 100644 --- a/tracer/src/Datadog.Trace.ClrProfiler.Native/cor_profiler.cpp +++ b/tracer/src/Datadog.Trace.ClrProfiler.Native/cor_profiler.cpp @@ -122,8 +122,9 @@ HRESULT STDMETHODCALLTYPE CorProfiler::Initialize(IUnknown* cor_profiler_info_un if (app_pool_id_value.size() > 1 && app_pool_id_value.at(0) == '~') { - Logger::Info("TRACER DIAGNOSTICS - Profiler disabled: ", environment::azure_app_services_app_pool_id, " ", - app_pool_id_value, " is recognized as an Azure App Services infrastructure process."); + Logger::Info( + "TRACER DIAGNOSTICS - Profiler disabled: ", environment::azure_app_services_app_pool_id, " ", + app_pool_id_value, " is recognized as an Azure App Services infrastructure process."); return E_FAIL; } @@ -142,7 +143,8 @@ HRESULT STDMETHODCALLTYPE CorProfiler::Initialize(IUnknown* cor_profiler_info_un if (!functions_worker_runtime_value.empty() && !IsAzureFunctionsEnabled()) { - Logger::Info("TRACER DIAGNOSTICS - Profiler disabled: Azure Functions are not officially supported. Enable instrumentation with SIGNALFX_TRACE_AZURE_FUNCTIONS_ENABLED."); + Logger::Info("TRACER DIAGNOSTICS - Profiler disabled: Azure Functions are not officially " + "supported. Enable instrumentation with DD_TRACE_AZURE_FUNCTIONS_ENABLED."); return E_FAIL; } } @@ -164,9 +166,8 @@ HRESULT STDMETHODCALLTYPE CorProfiler::Initialize(IUnknown* cor_profiler_info_un return this->CallTarget_RewriterCallback(mod, method); }; - rejit_handler = - info10 != nullptr ? std::make_unique(info10, callback) - : std::make_unique(this->info_, callback); + rejit_handler = info10 != nullptr ? std::make_unique(info10, callback) + : std::make_unique(this->info_, callback); DWORD event_mask = COR_PRF_MONITOR_JIT_COMPILATION | COR_PRF_DISABLE_TRANSPARENCY_CHECKS_UNDER_FULL_TRUST | COR_PRF_MONITOR_MODULE_LOADS | COR_PRF_MONITOR_ASSEMBLY_LOADS | COR_PRF_MONITOR_APPDOMAIN_LOADS | @@ -366,8 +367,8 @@ void CorProfiler::RewritingPInvokeMaps(const ModuleMetadata& module_metadata, co // We are in the right module, so we try to load the mdTypeDef from the target type name. mdTypeDef nativeMethodsTypeDef = mdTypeDefNil; - auto foundType = FindTypeDefByName(nativemethods_type_name, - module_metadata.assemblyName, metadata_import, nativeMethodsTypeDef); + auto foundType = + FindTypeDefByName(nativemethods_type_name, module_metadata.assemblyName, metadata_import, nativeMethodsTypeDef); if (foundType) { // Define the actual profiler file path as a ModuleRef @@ -380,10 +381,9 @@ void CorProfiler::RewritingPInvokeMaps(const ModuleMetadata& module_metadata, co { // Enumerate all methods inside the native methods type with the PInvokes Enumerator enumMethods = Enumerator( - [metadata_import, nativeMethodsTypeDef](HCORENUM* ptr, mdMethodDef arr[], ULONG max, ULONG* cnt) -> HRESULT - { - return metadata_import->EnumMethods(ptr, nativeMethodsTypeDef, arr, max, cnt); - }, [metadata_import](HCORENUM ptr) -> void { metadata_import->CloseEnum(ptr); }); + [metadata_import, nativeMethodsTypeDef](HCORENUM* ptr, mdMethodDef arr[], ULONG max, ULONG* cnt) + -> HRESULT { return metadata_import->EnumMethods(ptr, nativeMethodsTypeDef, arr, max, cnt); }, + [metadata_import](HCORENUM ptr) -> void { metadata_import->CloseEnum(ptr); }); EnumeratorIterator enumIterator = enumMethods.begin(); while (enumIterator != enumMethods.end()) @@ -407,18 +407,18 @@ void CorProfiler::RewritingPInvokeMaps(const ModuleMetadata& module_metadata, co if (SUCCEEDED(hr)) { // Define a new PInvoke map with the new ModuleRef of the actual profiler file path - hr = metadata_emit->DefinePinvokeMap(methodDef, pdwMappingFlags, - WSTRING(importName).c_str(), profiler_ref); + hr = metadata_emit->DefinePinvokeMap(methodDef, pdwMappingFlags, WSTRING(importName).c_str(), + profiler_ref); if (FAILED(hr)) { Logger::Warn("ModuleLoadFinished: DefinePinvokeMap to the actual profiler file path " - "failed, trying to restore the previous one."); + "failed, trying to restore the previous one."); hr = metadata_emit->DefinePinvokeMap(methodDef, pdwMappingFlags, - WSTRING(importName).c_str(), importModule); + WSTRING(importName).c_str(), importModule); if (FAILED(hr)) { - // We only warn that we cannot rewrite the PInvokeMap but we still continue the module load. - // These errors must be handled on the caller with a try/catch. + // We only warn that we cannot rewrite the PInvokeMap but we still continue the module + // load. These errors must be handled on the caller with a try/catch. Logger::Warn("ModuleLoadFinished: Error trying to restore the previous PInvokeMap."); } } @@ -479,12 +479,9 @@ HRESULT STDMETHODCALLTYPE CorProfiler::ModuleLoadFinished(ModuleID module_id, HR if (Logger::IsDebugEnabled()) { Logger::Debug("ModuleLoadFinished: ", module_id, " ", module_info.assembly.name, " AppDomain ", - module_info.assembly.app_domain_id, " ", module_info.assembly.app_domain_name, - std::boolalpha, - " | IsNGEN = ", module_info.IsNGEN(), - " | IsDynamic = ", module_info.IsDynamic(), - " | IsResource = ", module_info.IsResource(), - std::noboolalpha); + module_info.assembly.app_domain_id, " ", module_info.assembly.app_domain_name, std::boolalpha, + " | IsNGEN = ", module_info.IsNGEN(), " | IsDynamic = ", module_info.IsDynamic(), + " | IsResource = ", module_info.IsResource(), std::noboolalpha); } if (module_info.IsNGEN()) @@ -525,8 +522,9 @@ HRESULT STDMETHODCALLTYPE CorProfiler::ModuleLoadFinished(ModuleID module_id, HR corAssemblyProperty.szName = module_info.assembly.name; - Logger::Info("COR library: ", corAssemblyProperty.szName, " ", corAssemblyProperty.pMetaData.usMajorVersion, ".", - corAssemblyProperty.pMetaData.usMinorVersion, ".", corAssemblyProperty.pMetaData.usRevisionNumber); + Logger::Info("COR library: ", corAssemblyProperty.szName, " ", corAssemblyProperty.pMetaData.usMajorVersion, + ".", corAssemblyProperty.pMetaData.usMinorVersion, ".", + corAssemblyProperty.pMetaData.usRevisionNumber); if (rejit_handler != nullptr) { @@ -537,13 +535,13 @@ HRESULT STDMETHODCALLTYPE CorProfiler::ModuleLoadFinished(ModuleID module_id, HR } // In IIS, the startup hook will be inserted into a method in System.Web (which is domain-neutral) - // but the Datadog.Trace.ClrProfiler.Managed.Loader assembly that the startup hook loads from a + // but the SignalFx.Tracing.ClrProfiler.Managed.Loader assembly that the startup hook loads from a // byte array will be loaded into a non-shared AppDomain. // In this case, do not insert another startup hook into that non-shared AppDomain if (module_info.assembly.name == datadog_trace_clrprofiler_managed_loader_assemblyName) { - Logger::Info("ModuleLoadFinished: SignalFx.Tracing.ClrProfiler.Managed.Loader loaded into AppDomain ", app_domain_id, " ", - module_info.assembly.app_domain_name); + Logger::Info("ModuleLoadFinished: SignalFx.Tracing.ClrProfiler.Managed.Loader loaded into AppDomain ", + app_domain_id, " ", module_info.assembly.app_domain_name); first_jit_compilation_app_domains.insert(app_domain_id); return S_OK; } @@ -552,7 +550,8 @@ HRESULT STDMETHODCALLTYPE CorProfiler::ModuleLoadFinished(ModuleID module_id, HR { // We cannot obtain writable metadata interfaces on Windows Runtime modules // or instrument their IL. - Logger::Debug("ModuleLoadFinished skipping Windows Metadata module: ", module_id, " ", module_info.assembly.name); + Logger::Debug("ModuleLoadFinished skipping Windows Metadata module: ", module_id, " ", + module_info.assembly.name); return S_OK; } @@ -611,7 +610,10 @@ HRESULT STDMETHODCALLTYPE CorProfiler::ModuleLoadFinished(ModuleID module_id, HR ModuleMetadata(metadata_import, metadata_emit, assembly_import, assembly_emit, module_info.assembly.name, module_info.assembly.app_domain_id, &corAssemblyProperty, enable_by_ref_instrumentation); - Logger::Info("ModuleLoadFinished: ", managed_profiler_name, " - Fix PInvoke maps"); + const auto& assemblyImport = GetAssemblyImportMetadata(assembly_import); + const auto& assemblyVersion = assemblyImport.version.str(); + + Logger::Info("ModuleLoadFinished: ", managed_profiler_name, " v", assemblyVersion, " - Fix PInvoke maps"); #ifdef _WIN32 RewritingPInvokeMaps(module_metadata, windows_nativemethods_type); RewritingPInvokeMaps(module_metadata, appsec_windows_nativemethods_type); @@ -619,6 +621,28 @@ HRESULT STDMETHODCALLTYPE CorProfiler::ModuleLoadFinished(ModuleID module_id, HR RewritingPInvokeMaps(module_metadata, nonwindows_nativemethods_type); RewritingPInvokeMaps(module_metadata, appsec_nonwindows_nativemethods_type); #endif // _WIN32 + + if (IsVersionCompatibilityEnabled()) + { + // No need to rewrite if the target assembly matches the expected version + if (assemblyImport.version != managed_profiler_assembly_reference->version) + { + if (runtime_information_.is_core() && assemblyImport.version > managed_profiler_assembly_reference->version) + { + Logger::Debug("Skipping version conflict fix for ", assemblyVersion, + " because running on .NET Core with a higher version than expected"); + } + else + { + RewriteForDistributedTracing(module_metadata, module_id); + } + } + else + { + Logger::Debug("Skipping version conflict fix for ", assemblyVersion, + " because the version matches the expected one"); + } + } } else { @@ -656,7 +680,7 @@ HRESULT STDMETHODCALLTYPE CorProfiler::ModuleUnloadStarted(ModuleID module_id) } const auto& moduleInfo = GetModuleInfo(this->info_, module_id); - + if (moduleInfo.IsValid()) { if (Logger::IsDebugEnabled()) @@ -781,8 +805,9 @@ HRESULT STDMETHODCALLTYPE CorProfiler::JITCompilationStarted(FunctionID function const auto& module_info = GetModuleInfo(this->info_, module_id); - bool has_loader_injected_in_appdomain = first_jit_compilation_app_domains.find(module_info.assembly.app_domain_id) != - first_jit_compilation_app_domains.end(); + bool has_loader_injected_in_appdomain = + first_jit_compilation_app_domains.find(module_info.assembly.app_domain_id) != + first_jit_compilation_app_domains.end(); if (has_loader_injected_in_appdomain) { @@ -815,8 +840,8 @@ HRESULT STDMETHODCALLTYPE CorProfiler::JITCompilationStarted(FunctionID function if (Logger::IsDebugEnabled()) { - Logger::Debug("JITCompilationStarted: function_id=", function_id, " token=", function_token, " name=", caller.type.name, - ".", caller.name, "()"); + Logger::Debug("JITCompilationStarted: function_id=", function_id, " token=", function_token, + " name=", caller.type.name, ".", caller.name, "()"); } // IIS: Ensure that the startup hook is inserted into System.Web.Compilation.BuildManager.InvokePreStartInitMethods. @@ -847,8 +872,9 @@ HRESULT STDMETHODCALLTYPE CorProfiler::JITCompilationStarted(FunctionID function { bool domain_neutral_assembly = runtime_information_.is_desktop() && corlib_module_loaded && module_metadata->app_domain_id == corlib_app_domain_id; - Logger::Info("JITCompilationStarted: Startup hook registered in function_id=", function_id, " token=", function_token, - " name=", caller.type.name, ".", caller.name, "(), assembly_name=", module_metadata->assemblyName, + Logger::Info("JITCompilationStarted: Startup hook registered in function_id=", function_id, + " token=", function_token, " name=", caller.type.name, ".", caller.name, + "(), assembly_name=", module_metadata->assemblyName, " app_domain_id=", module_metadata->app_domain_id, " domain_neutral=", domain_neutral_assembly); first_jit_compilation_app_domains.insert(module_metadata->app_domain_id); @@ -856,7 +882,8 @@ HRESULT STDMETHODCALLTYPE CorProfiler::JITCompilationStarted(FunctionID function hr = RunILStartupHook(module_metadata->metadata_emit, module_id, function_token); if (FAILED(hr)) { - Logger::Warn("JITCompilationStarted: Call to RunILStartupHook() failed for ", module_id, " ", function_token); + Logger::Warn("JITCompilationStarted: Call to RunILStartupHook() failed for ", module_id, " ", + function_token); return S_OK; } @@ -923,7 +950,8 @@ HRESULT STDMETHODCALLTYPE CorProfiler::JITInlining(FunctionID callerId, Function return S_OK; } - if (is_attached_ && rejit_handler != nullptr && rejit_handler->HasModuleAndMethod(calleeModuleId, calleFunctionToken)) + if (is_attached_ && rejit_handler != nullptr && + rejit_handler->HasModuleAndMethod(calleeModuleId, calleFunctionToken)) { Logger::Debug("*** JITInlining: Inlining disabled for [ModuleId=", calleeModuleId, ", MethodDef=", TokenStr(&calleFunctionToken), "]"); @@ -983,12 +1011,13 @@ void CorProfiler::InitializeProfiler(WCHAR* id, CallTargetDefinition* items, int Version(current.targetMaximumMajor, current.targetMaximumMinor, current.targetMaximumPatch, 0); const auto& integration = IntegrationDefinition( - MethodReference(targetAssembly, targetType, targetMethod, minVersion, maxVersion, signatureTypes), - TypeReference(integrationAssembly, integrationType, {}, {})); + MethodReference(targetAssembly, targetType, targetMethod, minVersion, maxVersion, signatureTypes), + TypeReference(integrationAssembly, integrationType, {}, {})); if (Logger::IsDebugEnabled()) { - Logger::Debug(" * Target: ", targetAssembly, " | ", targetType, ".", targetMethod, "(", signatureTypes.size(), ") { ", minVersion.str(), " - ", maxVersion.str(), " } [", + Logger::Debug(" * Target: ", targetAssembly, " | ", targetType, ".", targetMethod, "(", + signatureTypes.size(), ") { ", minVersion.str(), " - ", maxVersion.str(), " } [", integrationAssembly, " | ", integrationType, "]"); } @@ -1040,9 +1069,10 @@ HRESULT STDMETHODCALLTYPE CorProfiler::GetAssemblyReferences(const WCHAR* wszAss { if (IsAzureAppServices()) { - Logger::Debug("GetAssemblyReferences skipping entire callback because this is running in Azure App Services, which " - "isn't yet supported for this feature. AssemblyPath=", - wszAssemblyPath); + Logger::Debug( + "GetAssemblyReferences skipping entire callback because this is running in Azure App Services, which " + "isn't yet supported for this feature. AssemblyPath=", + wszAssemblyPath); return S_OK; } @@ -1070,7 +1100,8 @@ HRESULT STDMETHODCALLTYPE CorProfiler::GetAssemblyReferences(const WCHAR* wszAss { if (assembly_name.rfind(skip_assembly_pattern, 0) == 0) { - Logger::Debug("GetAssemblyReferences skipping module by pattern: Name=", assembly_name, " Path=", wszAssemblyPath); + Logger::Debug("GetAssemblyReferences skipping module by pattern: Name=", assembly_name, + " Path=", wszAssemblyPath); return S_OK; } } @@ -1079,7 +1110,8 @@ HRESULT STDMETHODCALLTYPE CorProfiler::GetAssemblyReferences(const WCHAR* wszAss { if (assembly_name == skip_assembly) { - Logger::Debug("GetAssemblyReferences skipping known assembly: Name=", assembly_name, " Path=", wszAssemblyPath); + Logger::Debug("GetAssemblyReferences skipping known assembly: Name=", assembly_name, + " Path=", wszAssemblyPath); return S_OK; } } @@ -1100,7 +1132,7 @@ HRESULT STDMETHODCALLTYPE CorProfiler::GetAssemblyReferences(const WCHAR* wszAss else { assembly_metadata.szLocale = const_cast(managed_profiler_assembly_reference->locale.c_str()); - assembly_metadata.cbLocale = (DWORD)(managed_profiler_assembly_reference->locale.size()); + assembly_metadata.cbLocale = (DWORD) (managed_profiler_assembly_reference->locale.size()); } DWORD public_key_size = 8; @@ -1127,8 +1159,8 @@ HRESULT STDMETHODCALLTYPE CorProfiler::GetAssemblyReferences(const WCHAR* wszAss return S_OK; } - Logger::Debug("GetAssemblyReferences extending assembly closure for ", assembly_name, " to include ", asmRefInfo.szName, - ". Path=", wszAssemblyPath); + Logger::Debug("GetAssemblyReferences extending assembly closure for ", assembly_name, " to include ", + asmRefInfo.szName, ". Path=", wszAssemblyPath); return S_OK; } @@ -1142,7 +1174,8 @@ bool CorProfiler::IsAttached() const // Helper methods // bool CorProfiler::GetIntegrationTypeRef(ModuleMetadata& module_metadata, ModuleID module_id, - const IntegrationDefinition& integration_definition, mdTypeRef& integration_type_ref) + const IntegrationDefinition& integration_definition, + mdTypeRef& integration_type_ref) { const auto& integration_key = integration_definition.integration_type.get_cache_key(); @@ -1200,6 +1233,139 @@ bool CorProfiler::ProfilerAssemblyIsLoadedIntoAppDomain(AppDomainID app_domain_i managed_profiler_loaded_app_domains.find(app_domain_id) != managed_profiler_loaded_app_domains.end(); } +HRESULT CorProfiler::RewriteForDistributedTracing(const ModuleMetadata& module_metadata, ModuleID module_id) +{ + HRESULT hr = S_OK; + + if (IsDebugEnabled()) + { + Logger::Info("pcbPublicKey: ", managed_profiler_assembly_property.pcbPublicKey); + Logger::Info("ppbPublicKey: ", HexStr(managed_profiler_assembly_property.ppbPublicKey, + managed_profiler_assembly_property.pcbPublicKey)); + Logger::Info("pcbPublicKey: "); + const auto ppbPublicKey = (BYTE*) managed_profiler_assembly_property.ppbPublicKey; + for (auto i = 0; i < managed_profiler_assembly_property.pcbPublicKey; i++) + { + Logger::Info(" -> ", (int) ppbPublicKey[i]); + } + Logger::Info("szName: ", managed_profiler_assembly_property.szName); + + Logger::Info("Metadata.cbLocale: ", managed_profiler_assembly_property.pMetaData.cbLocale); + Logger::Info("Metadata.szLocale: ", managed_profiler_assembly_property.pMetaData.szLocale); + + if (managed_profiler_assembly_property.pMetaData.rOS != nullptr) + { + Logger::Info("Metadata.rOS.dwOSMajorVersion: ", + managed_profiler_assembly_property.pMetaData.rOS->dwOSMajorVersion); + Logger::Info("Metadata.rOS.dwOSMinorVersion: ", + managed_profiler_assembly_property.pMetaData.rOS->dwOSMinorVersion); + Logger::Info("Metadata.rOS.dwOSPlatformId: ", + managed_profiler_assembly_property.pMetaData.rOS->dwOSPlatformId); + } + + Logger::Info("Metadata.usBuildNumber: ", managed_profiler_assembly_property.pMetaData.usBuildNumber); + Logger::Info("Metadata.usMajorVersion: ", managed_profiler_assembly_property.pMetaData.usMajorVersion); + Logger::Info("Metadata.usMinorVersion: ", managed_profiler_assembly_property.pMetaData.usMinorVersion); + Logger::Info("Metadata.usRevisionNumber: ", managed_profiler_assembly_property.pMetaData.usRevisionNumber); + + Logger::Info("pulHashAlgId: ", managed_profiler_assembly_property.pulHashAlgId); + Logger::Info("sizeof(pulHashAlgId): ", sizeof(managed_profiler_assembly_property.pulHashAlgId)); + Logger::Info("assemblyFlags: ", managed_profiler_assembly_property.assemblyFlags); + } + + // + // *** Get DistributedTracer TypeDef + // + mdTypeDef distributedTracerTypeDef; + hr = module_metadata.metadata_import->FindTypeDefByName(WStr("Datadog.Trace.ClrProfiler.DistributedTracer"), + mdTokenNil, &distributedTracerTypeDef); + if (FAILED(hr)) + { + Logger::Warn("Error rewriting for Distributed Tracing on getting DistributedTracer TypeDef"); + return hr; + } + + // + // *** Import Current Version of assembly + // + mdAssemblyRef managed_profiler_assemblyRef; + hr = module_metadata.assembly_emit->DefineAssemblyRef( + managed_profiler_assembly_property.ppbPublicKey, managed_profiler_assembly_property.pcbPublicKey, + managed_profiler_assembly_property.szName.data(), &managed_profiler_assembly_property.pMetaData, + &managed_profiler_assembly_property.pulHashAlgId, sizeof(managed_profiler_assembly_property.pulHashAlgId), + managed_profiler_assembly_property.assemblyFlags, &managed_profiler_assemblyRef); + + if (FAILED(hr) || managed_profiler_assemblyRef == mdAssemblyRefNil) + { + Logger::Warn("Error rewriting for Distributed Tracing on getting ManagedProfiler AssemblyRef"); + return hr; + } + + mdTypeRef distributedTracerTypeRef; + hr = module_metadata.metadata_emit->DefineTypeRefByName( + managed_profiler_assemblyRef, WStr("Datadog.Trace.ClrProfiler.DistributedTracer"), &distributedTracerTypeRef); + + if (FAILED(hr)) + { + Logger::Warn("Error rewriting for Distributed Tracing on getting DistributedTracer TypeRef"); + return hr; + } + + // + // *** GetDistributedTrace MethodDef *** + // + COR_SIGNATURE getDistributedTracerSignature[] = {IMAGE_CEE_CS_CALLCONV_DEFAULT, 0, ELEMENT_TYPE_OBJECT}; + mdMethodDef getDistributedTraceMethodDef; + hr = module_metadata.metadata_import->FindMethod(distributedTracerTypeDef, WStr("GetDistributedTracer"), + getDistributedTracerSignature, 3, &getDistributedTraceMethodDef); + if (FAILED(hr)) + { + Logger::Warn("Error rewriting for Distributed Tracing on getting GetDistributedTracer MethodDef"); + return hr; + } + + // + // *** GetDistributedTrace MemberRef *** + // + mdMemberRef getDistributedTraceMemberRef; + hr = + module_metadata.metadata_emit->DefineMemberRef(distributedTracerTypeRef, WStr("GetDistributedTracer"), + getDistributedTracerSignature, 3, &getDistributedTraceMemberRef); + if (FAILED(hr)) + { + Logger::Warn("Error rewriting for Distributed Tracing on defining GetDistributedTracer MemberRef"); + return hr; + } + + ILRewriter getterRewriter(this->info_, nullptr, module_id, getDistributedTraceMethodDef); + getterRewriter.InitializeTiny(); + + // Modify first instruction from ldnull to call + ILRewriterWrapper getterWrapper(&getterRewriter); + getterWrapper.SetILPosition(getterRewriter.GetILList()->m_pNext); + getterWrapper.CallMember(getDistributedTraceMemberRef, false); + getterWrapper.Return(); + + hr = getterRewriter.Export(); + + if (FAILED(hr)) + { + Logger::Warn("Error rewriting GetDistributedTracer->[AutoInstrumentation]GetDistributedTracer"); + return hr; + } + + Logger::Info("Rewriting GetDistributedTracer->[AutoInstrumentation]GetDistributedTracer"); + + if (IsDumpILRewriteEnabled()) + { + Logger::Info(GetILCodes("After -> GetDistributedTracer. ", &getterRewriter, + GetFunctionInfo(module_metadata.metadata_import, getDistributedTraceMethodDef), + module_metadata)); + } + + return hr; +} + const std::string indent_values[] = { "", std::string(2 * 1, ' '), @@ -1344,8 +1510,7 @@ std::string CorProfiler::GetILCodes(const std::string& title, ILRewriter* rewrit if (cInstr->m_opcode == CEE_CALL || cInstr->m_opcode == CEE_CALLVIRT || cInstr->m_opcode == CEE_NEWOBJ) { - const auto memberInfo = - GetFunctionInfo(module_metadata.metadata_import, (mdMemberRef) cInstr->m_Arg32); + const auto memberInfo = GetFunctionInfo(module_metadata.metadata_import, (mdMemberRef) cInstr->m_Arg32); orig_sstream << " | "; orig_sstream << ToString(memberInfo.type.name); orig_sstream << "."; @@ -1445,7 +1610,8 @@ HRESULT CorProfiler::RunILStartupHook(const ComPtr& metadata_emi if (FAILED(hr)) { - Logger::Warn("RunILStartupHook: Call to ILRewriter.Export() failed for ModuleID=", module_id, " ", function_token); + Logger::Warn("RunILStartupHook: Call to ILRewriter.Export() failed for ModuleID=", module_id, " ", + function_token); return hr; } @@ -2226,7 +2392,8 @@ HRESULT CorProfiler::AddIISPreStartInitFlags(const ModuleID module_id, const mdT if (FAILED(hr)) { - Logger::Warn("RunILStartupHook: Call to ILRewriter.Export() failed for ModuleID=", module_id, " ", function_token); + Logger::Warn("RunILStartupHook: Call to ILRewriter.Export() failed for ModuleID=", module_id, " ", + function_token); return hr; } @@ -2358,8 +2525,7 @@ HRESULT STDMETHODCALLTYPE CorProfiler::ReJITError(ModuleID moduleId, mdMethodDef return S_OK; } -HRESULT STDMETHODCALLTYPE CorProfiler::JITCachedFunctionSearchStarted(FunctionID functionId, - BOOL* pbUseCachedFunction) +HRESULT STDMETHODCALLTYPE CorProfiler::JITCachedFunctionSearchStarted(FunctionID functionId, BOOL* pbUseCachedFunction) { auto _ = trace::Stats::Instance()->JITCachedFunctionSearchStartedMeasure(); if (!is_attached_ || !pbUseCachedFunction) @@ -2378,7 +2544,8 @@ HRESULT STDMETHODCALLTYPE CorProfiler::JITCachedFunctionSearchStarted(FunctionID HRESULT hr = this->info_->GetFunctionInfo(functionId, nullptr, &module_id, &function_token); if (FAILED(hr)) { - Logger::Warn("JITCachedFunctionSearchStarted: Call to ICorProfilerInfo4.GetFunctionInfo() failed for ", functionId); + Logger::Warn("JITCachedFunctionSearchStarted: Call to ICorProfilerInfo4.GetFunctionInfo() failed for ", + functionId); return S_OK; } @@ -2395,8 +2562,7 @@ HRESULT STDMETHODCALLTYPE CorProfiler::JITCachedFunctionSearchStarted(FunctionID const auto& appDomainId = module_info.assembly.app_domain_id; const bool has_loader_injected_in_appdomain = - first_jit_compilation_app_domains.find(appDomainId) != - first_jit_compilation_app_domains.end(); + first_jit_compilation_app_domains.find(appDomainId) != first_jit_compilation_app_domains.end(); if (!has_loader_injected_in_appdomain) { @@ -2492,28 +2658,27 @@ HRESULT CorProfiler::CallTarget_RewriterCallback(RejitHandlerModule* moduleHandl mdTypeRef integration_type_ref = mdTypeRefNil; if (!GetIntegrationTypeRef(module_metadata, module_id, *integration_definition, integration_type_ref)) { - Logger::Warn( - "*** CallTarget_RewriterCallback() skipping method: Integration Type Ref cannot be found for ", - " token=", function_token, " caller_name=", caller->type.name, ".", - caller->name, "()"); + Logger::Warn("*** CallTarget_RewriterCallback() skipping method: Integration Type Ref cannot be found for ", + " token=", function_token, " caller_name=", caller->type.name, ".", caller->name, "()"); return S_FALSE; } if (IsDebugEnabled()) { - Logger::Debug("*** CallTarget_RewriterCallback() Start: ", caller->type.name, ".", caller->name, "() [IsVoid=", - isVoid, ", IsStatic=", isStatic, - ", IntegrationType=", integration_definition->integration_type.name, - ", Arguments=", numArgs, "]"); + Logger::Debug("*** CallTarget_RewriterCallback() Start: ", caller->type.name, ".", caller->name, + "() [IsVoid=", isVoid, ", IsStatic=", isStatic, + ", IntegrationType=", integration_definition->integration_type.name, ", Arguments=", numArgs, + "]"); } // First we check if the managed profiler has not been loaded yet if (!ProfilerAssemblyIsLoadedIntoAppDomain(module_metadata.app_domain_id)) { - Logger::Warn("*** CallTarget_RewriterCallback() skipping method: Method replacement found but the managed profiler has " - "not yet been loaded into AppDomain with id=", - module_metadata.app_domain_id, " token=", function_token, " caller_name=", caller->type.name, ".", - caller->name, "()"); + Logger::Warn( + "*** CallTarget_RewriterCallback() skipping method: Method replacement found but the managed profiler has " + "not yet been loaded into AppDomain with id=", + module_metadata.app_domain_id, " token=", function_token, " caller_name=", caller->type.name, ".", + caller->name, "()"); return S_FALSE; } @@ -2679,7 +2844,8 @@ HRESULT CorProfiler::CallTarget_RewriterCallback(RejitHandlerModule* moduleHandl Logger::Debug("Caller Type Extend From.IsValid: ", caller->type.extend_from->IsValid()); Logger::Debug("Caller Type Extend From.Name: ", caller->type.extend_from->name); Logger::Debug("Caller Type Extend From.TokenType: ", caller->type.extend_from->token_type); - Logger::Debug("Caller Type Extend From.Spec: ", HexStr(&caller->type.extend_from->type_spec, sizeof(mdTypeSpec))); + Logger::Debug("Caller Type Extend From.Spec: ", + HexStr(&caller->type.extend_from->type_spec, sizeof(mdTypeSpec))); Logger::Debug("Caller Type Extend From.ValueType: ", caller->type.extend_from->valueType); } // @@ -2922,7 +3088,8 @@ HRESULT CorProfiler::CallTarget_RewriterCallback(RejitHandlerModule* moduleHandl if (IsDumpILRewriteEnabled()) { Logger::Info(original_code); - Logger::Info(GetILCodes("*** CallTarget_RewriterCallback(): Modified Code: ", &rewriter, *caller, module_metadata)); + Logger::Info( + GetILCodes("*** CallTarget_RewriterCallback(): Modified Code: ", &rewriter, *caller, module_metadata)); } hr = rewriter.Export(); @@ -2935,9 +3102,9 @@ HRESULT CorProfiler::CallTarget_RewriterCallback(RejitHandlerModule* moduleHandl return S_FALSE; } - Logger::Info("*** CallTarget_RewriterCallback() Finished: ", caller->type.name, ".", caller->name, "() [IsVoid=", isVoid, ", IsStatic=", isStatic, - ", IntegrationType=", integration_definition->integration_type.name, - ", Arguments=", numArgs, "]"); + Logger::Info("*** CallTarget_RewriterCallback() Finished: ", caller->type.name, ".", caller->name, + "() [IsVoid=", isVoid, ", IsStatic=", isStatic, + ", IntegrationType=", integration_definition->integration_type.name, ", Arguments=", numArgs, "]"); return S_OK; } diff --git a/tracer/src/Datadog.Trace.ClrProfiler.Native/cor_profiler.h b/tracer/src/Datadog.Trace.ClrProfiler.Native/cor_profiler.h index c88bbf4d2..b823897ba 100644 --- a/tracer/src/Datadog.Trace.ClrProfiler.Native/cor_profiler.h +++ b/tracer/src/Datadog.Trace.ClrProfiler.Native/cor_profiler.h @@ -73,6 +73,7 @@ class CorProfiler : public CorProfilerBase bool ProfilerAssemblyIsLoadedIntoAppDomain(AppDomainID app_domain_id); std::string GetILCodes(const std::string& title, ILRewriter* rewriter, const FunctionInfo& caller, const ModuleMetadata& module_metadata); + HRESULT RewriteForDistributedTracing(const ModuleMetadata& module_metadata, ModuleID module_id); // // Startup methods // diff --git a/tracer/src/Datadog.Trace.ClrProfiler.Native/dd_profiler_constants.h b/tracer/src/Datadog.Trace.ClrProfiler.Native/dd_profiler_constants.h index e4f7c3067..2a210fe3c 100644 --- a/tracer/src/Datadog.Trace.ClrProfiler.Native/dd_profiler_constants.h +++ b/tracer/src/Datadog.Trace.ClrProfiler.Native/dd_profiler_constants.h @@ -99,6 +99,19 @@ const WSTRING native_dll_filename = WStr("SignalFx.Tracing.ClrProfiler.Native.dy const WSTRING native_dll_filename = WStr("SignalFx.Tracing.ClrProfiler.Native.so"); #endif +const AssemblyProperty managed_profiler_assembly_property = AssemblyProperty( + managed_profiler_name, + new BYTE[160]{0, 36, 0, 0, 4, 128, 0, 0, 148, 0, 0, 0, 6, 2, 0, 0, 0, 36, 0, 0, + 82, 83, 65, 49, 0, 4, 0, 0, 1, 0, 1, 0, 113, 25, 157, 139, 5, 140, 14, 183, + 143, 206, 5, 141, 85, 31, 218, 167, 100, 218, 115, 54, 243, 178, 58, 94, 113, 205, 1, 61, + 202, 244, 182, 105, 61, 229, 163, 152, 162, 242, 205, 220, 5, 72, 75, 181, 86, 34, 3, 77, + 214, 74, 215, 90, 162, 58, 218, 216, 253, 227, 176, 27, 110, 33, 34, 84, 150, 63, 8, 30, + 168, 108, 125, 174, 108, 72, 0, 80, 13, 222, 89, 226, 104, 231, 249, 228, 238, 194, 224, 67, + 123, 102, 42, 57, 219, 122, 95, 191, 59, 10, 120, 157, 167, 170, 1, 81, 183, 182, 51, 111, + 204, 130, 205, 122, 20, 157, 247, 246, 102, 245, 57, 108, 141, 233, 44, 166, 68, 215, 162, 209}, + 160, 32772, 1) + .WithVersion(0, 2, 0, 0); + } // namespace trace #endif // DD_PROFILER_CONSTANTS_H diff --git a/tracer/src/Datadog.Trace.ClrProfiler.Native/environment_variables.h b/tracer/src/Datadog.Trace.ClrProfiler.Native/environment_variables.h index 1ba7b8edb..37c894032 100644 --- a/tracer/src/Datadog.Trace.ClrProfiler.Native/environment_variables.h +++ b/tracer/src/Datadog.Trace.ClrProfiler.Native/environment_variables.h @@ -93,6 +93,9 @@ namespace environment { // Sets whether to enable JIT inlining const WSTRING clr_enable_inlining = WStr("SIGNALFX_CLR_ENABLE_INLINING"); + // Enables the compatibility with other versions of Datadog.Trace + const WSTRING internal_version_compatibility = WStr("SIGNALFX_INTERNAL_TRACE_VERSION_COMPATIBILITY"); + // Sets whether to enable NGEN images. const WSTRING clr_enable_ngen = WStr("SIGNALFX_CLR_ENABLE_NGEN"); diff --git a/tracer/src/Datadog.Trace.ClrProfiler.Native/environment_variables_util.h b/tracer/src/Datadog.Trace.ClrProfiler.Native/environment_variables_util.h index 481d402f0..d98a2e9de 100644 --- a/tracer/src/Datadog.Trace.ClrProfiler.Native/environment_variables_util.h +++ b/tracer/src/Datadog.Trace.ClrProfiler.Native/environment_variables_util.h @@ -91,6 +91,11 @@ bool IsThreadSamplingEnabled() CheckIfTrue(GetEnvironmentValue(environment::thread_sampling_enabled)); } +bool IsVersionCompatibilityEnabled() +{ + ToBooleanWithDefault(GetEnvironmentValue(environment::internal_version_compatibility), true); +} + } // namespace trace #endif // DD_CLR_PROFILER_ENVIRONMENT_VARIABLES_UTIL_H_ diff --git a/tracer/src/Datadog.Trace.ClrProfiler.Native/integration.h b/tracer/src/Datadog.Trace.ClrProfiler.Native/integration.h index 9fcdb3a19..cce7c5f11 100644 --- a/tracer/src/Datadog.Trace.ClrProfiler.Native/integration.h +++ b/tracer/src/Datadog.Trace.ClrProfiler.Native/integration.h @@ -75,6 +75,11 @@ struct Version return major == other.major && minor == other.minor && build == other.build && revision == other.revision; } + inline bool operator!=(const Version& other) const + { + return !(*this == other); + } + inline WSTRING str() const { std::stringstream ss; @@ -244,8 +249,7 @@ struct TypeReference const Version min_version; const Version max_version; - TypeReference() : - min_version(Version(0, 0, 0, 0)), max_version(Version(USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX)) + TypeReference() : min_version(Version(0, 0, 0, 0)), max_version(Version(USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX)) { } @@ -280,9 +284,8 @@ struct MethodReference { } - MethodReference(const WSTRING& assembly_name, WSTRING type_name, WSTRING method_name, - Version min_version, Version max_version, - const std::vector& signature_types) : + MethodReference(const WSTRING& assembly_name, WSTRING type_name, WSTRING method_name, Version min_version, + Version max_version, const std::vector& signature_types) : type(assembly_name, type_name, min_version, max_version), method_name(method_name), signature_types(signature_types) diff --git a/tracer/src/Datadog.Trace.OpenTracing/OpenTracingSpan.cs b/tracer/src/Datadog.Trace.OpenTracing/OpenTracingSpan.cs index 5a253006a..3359ecc2f 100644 --- a/tracer/src/Datadog.Trace.OpenTracing/OpenTracingSpan.cs +++ b/tracer/src/Datadog.Trace.OpenTracing/OpenTracingSpan.cs @@ -11,9 +11,9 @@ namespace Datadog.Trace.OpenTracing { - internal class OpenTracingSpan : ISpan + internal class OpenTracingSpan : global::OpenTracing.ISpan { - internal OpenTracingSpan(Span span) + internal OpenTracingSpan(ISpan span) { Span = span; Context = new OpenTracingSpanContext(span.Context); @@ -21,31 +21,29 @@ internal OpenTracingSpan(Span span) public OpenTracingSpanContext Context { get; } - global::OpenTracing.ISpanContext ISpan.Context => Context; + global::OpenTracing.ISpanContext global::OpenTracing.ISpan.Context => Context; - internal Span Span { get; } + internal ISpan Span { get; } // TODO lucas: inline this in a separate commit, it will modify a lot of files // This is only exposed for tests - internal Span DDSpan => Span; + internal ISpan DDSpan => Span; internal string OperationName => Span.OperationName; - internal TimeSpan Duration => Span.Duration; - public string GetBaggageItem(string key) => null; - public ISpan Log(DateTimeOffset timestamp, IEnumerable> fields) => this; + public global::OpenTracing.ISpan Log(DateTimeOffset timestamp, IEnumerable> fields) => this; - public ISpan Log(string eventName) => this; + public global::OpenTracing.ISpan Log(string eventName) => this; - public ISpan Log(DateTimeOffset timestamp, string eventName) => this; + public global::OpenTracing.ISpan Log(DateTimeOffset timestamp, string eventName) => this; - public ISpan Log(IEnumerable> fields) => this; + public global::OpenTracing.ISpan Log(IEnumerable> fields) => this; - public ISpan SetBaggageItem(string key, string value) => this; + public global::OpenTracing.ISpan SetBaggageItem(string key, string value) => this; - public ISpan SetOperationName(string operationName) + public global::OpenTracing.ISpan SetOperationName(string operationName) { Span.OperationName = operationName; return this; @@ -56,42 +54,42 @@ public string GetTag(string key) return Span.GetTag(key); } - public ISpan SetTag(string key, bool value) + public global::OpenTracing.ISpan SetTag(string key, bool value) { return SetTag(key, value.ToString()); } - public ISpan SetTag(string key, double value) + public global::OpenTracing.ISpan SetTag(string key, double value) { return SetTag(key, value.ToString(CultureInfo.InvariantCulture)); } - public ISpan SetTag(string key, int value) + public global::OpenTracing.ISpan SetTag(string key, int value) { return SetTag(key, value.ToString(CultureInfo.InvariantCulture)); } - public ISpan SetTag(BooleanTag tag, bool value) + public global::OpenTracing.ISpan SetTag(BooleanTag tag, bool value) { return SetTag(tag.Key, value); } - public ISpan SetTag(IntOrStringTag tag, string value) + public global::OpenTracing.ISpan SetTag(IntOrStringTag tag, string value) { return SetTag(tag.Key, value); } - public ISpan SetTag(IntTag tag, int value) + public global::OpenTracing.ISpan SetTag(IntTag tag, int value) { return SetTag(tag.Key, value); } - public ISpan SetTag(StringTag tag, string value) + public global::OpenTracing.ISpan SetTag(StringTag tag, string value) { return SetTag(tag.Key, value); } - public ISpan SetTag(string key, string value) + public global::OpenTracing.ISpan SetTag(string key, string value) { // TODO:bertrand do we want this behavior on the Span object too ? diff --git a/tracer/src/Datadog.Trace.OpenTracing/OpenTracingSpanBuilder.cs b/tracer/src/Datadog.Trace.OpenTracing/OpenTracingSpanBuilder.cs index c74968653..7298ef9d9 100644 --- a/tracer/src/Datadog.Trace.OpenTracing/OpenTracingSpanBuilder.cs +++ b/tracer/src/Datadog.Trace.OpenTracing/OpenTracingSpanBuilder.cs @@ -46,7 +46,7 @@ public ISpanBuilder AddReference(string referenceType, global::OpenTracing.ISpan return this; } - public ISpanBuilder AsChildOf(ISpan parent) + public ISpanBuilder AsChildOf(global::OpenTracing.ISpan parent) { lock (_lock) { @@ -70,12 +70,12 @@ public ISpanBuilder IgnoreActiveSpan() return this; } - public ISpan Start() + public global::OpenTracing.ISpan Start() { lock (_lock) { ISpanContext parentContext = GetParentContext(); - Span ddSpan = _tracer.DatadogTracer.StartSpan(_operationName, parentContext, _serviceName, _start, _ignoreActiveSpan); + ISpan ddSpan = _tracer.DatadogTracer.StartSpan(_operationName, parentContext, _serviceName, _start, _ignoreActiveSpan); var otSpan = new OpenTracingSpan(ddSpan); if (_tags != null) @@ -90,12 +90,12 @@ public ISpan Start() } } - public IScope StartActive() + public global::OpenTracing.IScope StartActive() { return StartActive(finishSpanOnDispose: true); } - public IScope StartActive(bool finishSpanOnDispose) + public global::OpenTracing.IScope StartActive(bool finishSpanOnDispose) { var span = Start(); return _tracer.ScopeManager.Activate(span, finishSpanOnDispose); diff --git a/tracer/src/Datadog.Trace.OpenTracing/OpenTracingTracer.cs b/tracer/src/Datadog.Trace.OpenTracing/OpenTracingTracer.cs index f1881fa82..b17990b3c 100644 --- a/tracer/src/Datadog.Trace.OpenTracing/OpenTracingTracer.cs +++ b/tracer/src/Datadog.Trace.OpenTracing/OpenTracingTracer.cs @@ -11,18 +11,18 @@ namespace Datadog.Trace.OpenTracing { - internal class OpenTracingTracer : ITracer + internal class OpenTracingTracer : global::OpenTracing.ITracer { private static readonly IDatadogLogger Log = DatadogLogging.GetLoggerFor(); private readonly Dictionary _codecs; - public OpenTracingTracer(IDatadogTracer datadogTracer) + public OpenTracingTracer(IDatadogOpenTracingTracer datadogTracer) : this(datadogTracer, new global::OpenTracing.Util.AsyncLocalScopeManager()) { } - public OpenTracingTracer(IDatadogTracer datadogTracer, global::OpenTracing.IScopeManager scopeManager) + public OpenTracingTracer(IDatadogOpenTracingTracer datadogTracer, global::OpenTracing.IScopeManager scopeManager) { DatadogTracer = datadogTracer; DefaultServiceName = datadogTracer.DefaultServiceName; @@ -34,7 +34,7 @@ public OpenTracingTracer(IDatadogTracer datadogTracer, global::OpenTracing.IScop }; } - public IDatadogTracer DatadogTracer { get; } + public IDatadogOpenTracingTracer DatadogTracer { get; } public string DefaultServiceName { get; } @@ -42,7 +42,7 @@ public OpenTracingTracer(IDatadogTracer datadogTracer, global::OpenTracing.IScop public OpenTracingSpan ActiveSpan => (OpenTracingSpan)ScopeManager.Active?.Span; - ISpan ITracer.ActiveSpan => ScopeManager.Active?.Span; + global::OpenTracing.ISpan global::OpenTracing.ITracer.ActiveSpan => ScopeManager.Active?.Span; public ISpanBuilder BuildSpan(string operationName) { diff --git a/tracer/src/Datadog.Trace.OpenTracing/OpenTracingTracerFactory.cs b/tracer/src/Datadog.Trace.OpenTracing/OpenTracingTracerFactory.cs index a43e31ce9..ff3553fa2 100644 --- a/tracer/src/Datadog.Trace.OpenTracing/OpenTracingTracerFactory.cs +++ b/tracer/src/Datadog.Trace.OpenTracing/OpenTracingTracerFactory.cs @@ -24,7 +24,7 @@ public static class OpenTracingTracerFactory /// Default name of the service (default is the name of the executing assembly). /// Turns on all debug logging (this may have an impact on application performance). /// A Datadog compatible ITracer implementation - public static ITracer CreateTracer(Uri agentEndpoint = null, string defaultServiceName = null, bool isDebugEnabled = false) + public static global::OpenTracing.ITracer CreateTracer(Uri agentEndpoint = null, string defaultServiceName = null, bool isDebugEnabled = false) { // Keep supporting this older public method by creating a TracerConfiguration // from default sources, overwriting the specified settings, and passing that to the constructor. @@ -33,7 +33,7 @@ public static ITracer CreateTracer(Uri agentEndpoint = null, string defaultServi if (agentEndpoint != null) { - configuration.AgentUri = agentEndpoint; + configuration.ExporterSettings.AgentUri = agentEndpoint; } if (defaultServiceName != null) @@ -50,7 +50,7 @@ public static ITracer CreateTracer(Uri agentEndpoint = null, string defaultServi /// /// Existing Datadog Tracer instance /// A Datadog compatible ITracer implementation - public static ITracer WrapTracer(Tracer tracer) + public static global::OpenTracing.ITracer WrapTracer(Tracer tracer) { return new OpenTracingTracer(tracer); } diff --git a/tracer/src/Datadog.Trace.Tools.Runner/Utils.cs b/tracer/src/Datadog.Trace.Tools.Runner/Utils.cs index c8d4d8e40..48e67c575 100644 --- a/tracer/src/Datadog.Trace.Tools.Runner/Utils.cs +++ b/tracer/src/Datadog.Trace.Tools.Runner/Utils.cs @@ -315,13 +315,13 @@ public static async Task CheckAgentConnectionAsync(string agentUrl) { if (!await agentWriter.Ping().ConfigureAwait(false)) { - Console.WriteLine($"Error connecting to the Datadog Agent at {tracerSettings.AgentUri}."); + Console.WriteLine($"Error connecting to the Datadog Agent at {tracerSettings.ExporterSettings.AgentUri}."); return false; } } catch (Exception ex) { - Console.WriteLine($"Error connecting to the Datadog Agent at {tracerSettings.AgentUri}."); + Console.WriteLine($"Error connecting to the Datadog Agent at {tracerSettings.ExporterSettings.AgentUri}."); Console.WriteLine(ex); return false; } diff --git a/tracer/src/Datadog.Trace/Agent/AgentWriter.cs b/tracer/src/Datadog.Trace/Agent/AgentWriter.cs index 23f456406..1acb48c1f 100644 --- a/tracer/src/Datadog.Trace/Agent/AgentWriter.cs +++ b/tracer/src/Datadog.Trace/Agent/AgentWriter.cs @@ -206,17 +206,20 @@ private void RequestFlush() private async Task FlushBuffersTaskLoopAsync() { + Task[] tasks = new Task[3]; + tasks[0] = _serializationTask; + tasks[1] = _forceFlush.Task; + while (true) { - await Task.WhenAny( - Task.Delay(TimeSpan.FromSeconds(1)), - _serializationTask, - _forceFlush.Task) - .ConfigureAwait(false); + tasks[2] = Task.Delay(TimeSpan.FromSeconds(1)); + await Task.WhenAny(tasks).ConfigureAwait(false); + tasks[2] = null; if (_forceFlush.Task.IsCompleted) { _forceFlush = new TaskCompletionSource(TaskOptions); + tasks[1] = _forceFlush.Task; } await FlushBuffers().ConfigureAwait(false); diff --git a/tracer/src/Datadog.Trace/Agent/Api.cs b/tracer/src/Datadog.Trace/Agent/Api.cs index 8e93bdaf2..c1a38c6d8 100644 --- a/tracer/src/Datadog.Trace/Agent/Api.cs +++ b/tracer/src/Datadog.Trace/Agent/Api.cs @@ -219,7 +219,7 @@ private async Task SendTracesAsync(ArraySegment traces, int numberOf { var apiResponse = JsonConvert.DeserializeObject(responseContent); - _updateSampleRates(apiResponse?.RateByService); + _updateSampleRates(apiResponse.RateByService); _cachedResponse = responseContent; } @@ -260,7 +260,7 @@ internal bool LogPartialFlushWarningIfRequired(string agentVersion) return false; } - internal class ApiResponse + internal struct ApiResponse { [JsonProperty("rate_by_service")] public Dictionary RateByService { get; set; } diff --git a/tracer/src/Datadog.Trace/Agent/MovingAverageKeepRateCalculator.cs b/tracer/src/Datadog.Trace/Agent/MovingAverageKeepRateCalculator.cs index c1bb64129..565b115aa 100644 --- a/tracer/src/Datadog.Trace/Agent/MovingAverageKeepRateCalculator.cs +++ b/tracer/src/Datadog.Trace/Agent/MovingAverageKeepRateCalculator.cs @@ -1,13 +1,13 @@ -// +// // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // using System; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using Datadog.Trace.Logging; +using Datadog.Trace.Util; namespace Datadog.Trace.Agent { @@ -42,7 +42,7 @@ internal MovingAverageKeepRateCalculator(int windowSize, TimeSpan bucketDuration { if (windowSize < 0 || windowSize > 100) { - throw new ArgumentOutOfRangeException(nameof(windowSize), windowSize, "Must be a value between 1 and 100"); + ThrowHelper.ThrowArgumentOutOfRangeException(nameof(windowSize), windowSize, "Must be a value between 1 and 100"); } _windowSize = windowSize; @@ -67,7 +67,7 @@ public void IncrementKeeps(int count) { if (count < 0) { - throw new ArgumentOutOfRangeException(nameof(count)); + ThrowHelper.ThrowArgumentOutOfRangeException(nameof(count)); } Interlocked.Add(ref _latestKeeps, count); @@ -80,7 +80,7 @@ public void IncrementDrops(int count) { if (count < 0) { - throw new ArgumentOutOfRangeException(nameof(count)); + ThrowHelper.ThrowArgumentOutOfRangeException(nameof(count)); } Interlocked.Add(ref _latestDrops, count); diff --git a/tracer/src/Datadog.Trace/Agent/SpanBuffer.cs b/tracer/src/Datadog.Trace/Agent/SpanBuffer.cs index 266d91dee..626ffa6e1 100644 --- a/tracer/src/Datadog.Trace/Agent/SpanBuffer.cs +++ b/tracer/src/Datadog.Trace/Agent/SpanBuffer.cs @@ -5,6 +5,7 @@ using System; using System.Threading; +using Datadog.Trace.Util; using Datadog.Trace.Vendors.MessagePack; using Datadog.Trace.Vendors.MessagePack.Formatters; @@ -28,7 +29,7 @@ public SpanBuffer(int maxBufferSize, IFormatterResolver formatterResolver) { if (maxBufferSize < HeaderSize) { - throw new ArgumentException(nameof(maxBufferSize), $"Buffer size should be at least {HeaderSize}"); + ThrowHelper.ThrowArgumentException($"Buffer size should be at least {HeaderSize}", nameof(maxBufferSize)); } _maxBufferSize = maxBufferSize; @@ -45,7 +46,7 @@ public ArraySegment Data if (!_locked) { // Sanity check - headers are written when the buffer is locked - throw new InvalidOperationException("Data was extracted from the buffer without locking"); + ThrowHelper.ThrowInvalidOperationException("Data was extracted from the buffer without locking"); } return new ArraySegment(_buffer, 0, _offset); diff --git a/tracer/src/Datadog.Trace/Agent/TransportStrategy.cs b/tracer/src/Datadog.Trace/Agent/TransportStrategy.cs index 0ff4e4f41..6c1bf06a6 100644 --- a/tracer/src/Datadog.Trace/Agent/TransportStrategy.cs +++ b/tracer/src/Datadog.Trace/Agent/TransportStrategy.cs @@ -13,23 +13,21 @@ namespace Datadog.Trace.Agent { internal static class TransportStrategy { - public const string DatadogTcp = "DATADOG-TCP"; - public const string DatadogNamedPipes = "DATADOG-NAMED-PIPES"; - private static readonly IDatadogLogger Log = DatadogLogging.GetLoggerFor(); - public static IApiRequestFactory Get(ImmutableTracerSettings settings) + public static IApiRequestFactory Get(ImmutableExporterSettings settings) { - var strategy = settings.TracesTransport?.ToUpperInvariant(); + var strategy = settings.TracesTransport; switch (strategy) { - case DatadogTcp: + case TracesTransportType.CustomTcpProvider: Log.Information("Using {FactoryType} for trace transport.", nameof(TcpStreamFactory)); return new HttpStreamRequestFactory(new TcpStreamFactory(settings.AgentUri.Host, settings.AgentUri.Port), new DatadogHttpClient()); - case DatadogNamedPipes: + case TracesTransportType.WindowsNamedPipe: Log.Information("Using {FactoryType} for trace transport, with pipe name {PipeName} and timeout {Timeout}ms.", nameof(NamedPipeClientStreamFactory), settings.TracesPipeName, settings.TracesPipeTimeoutMs); return new HttpStreamRequestFactory(new NamedPipeClientStreamFactory(settings.TracesPipeName, settings.TracesPipeTimeoutMs), new DatadogHttpClient()); + case TracesTransportType.Default: default: // Defer decision to Api logic return null; diff --git a/tracer/src/Datadog.Trace/Agent/Transports/HttpStreamRequest.cs b/tracer/src/Datadog.Trace/Agent/Transports/HttpStreamRequest.cs index 5e0ab052a..f23af89f1 100644 --- a/tracer/src/Datadog.Trace/Agent/Transports/HttpStreamRequest.cs +++ b/tracer/src/Datadog.Trace/Agent/Transports/HttpStreamRequest.cs @@ -11,6 +11,7 @@ using Datadog.Trace.HttpOverStreams; using Datadog.Trace.HttpOverStreams.HttpContent; using Datadog.Trace.Logging; +using Datadog.Trace.Util; using Datadog.Trace.Vendors.Newtonsoft.Json; namespace Datadog.Trace.Agent.Transports @@ -87,7 +88,7 @@ private async Task> PostSegmentAsync(ArraySegme var contentLength = response.Content.Length; if (!contentLength.HasValue) { - throw new Exception("Content-Length is required but was not provided"); + ThrowHelper.ThrowException("Content-Length is required but was not provided"); } // buffer the entire contents for now diff --git a/tracer/src/Datadog.Trace/Agent/Zipkin/ZipkinExporter.cs b/tracer/src/Datadog.Trace/Agent/Zipkin/ZipkinExporter.cs index ced8363a7..6cf914f0d 100644 --- a/tracer/src/Datadog.Trace/Agent/Zipkin/ZipkinExporter.cs +++ b/tracer/src/Datadog.Trace/Agent/Zipkin/ZipkinExporter.cs @@ -21,7 +21,7 @@ public ZipkinExporter(ImmutableTracerSettings settings) Log.Debug("Creating new Zipkin exporter"); _settings = settings ?? throw new ArgumentNullException(nameof(settings)); - _tracesEndpoint = _settings.AgentUri; + _tracesEndpoint = _settings.ExporterSettings.AgentUri; } public async Task SendTracesAsync(Span[][] traces) diff --git a/tracer/src/Datadog.Trace/AppSec/Security.cs b/tracer/src/Datadog.Trace/AppSec/Security.cs index 756d1c6de..3fb12bf18 100644 --- a/tracer/src/Datadog.Trace/AppSec/Security.cs +++ b/tracer/src/Datadog.Trace/AppSec/Security.cs @@ -180,9 +180,9 @@ private static void LogMatchesIfDebugEnabled(WafMatch[] results, bool blocked) } } - private static void AddHeaderTags(Span span, IHeadersCollection headers, Dictionary headersToCollect) + private static void AddHeaderTags(Span span, IHeadersCollection headers, Dictionary headersToCollect, string prefix) { - var tags = PropagationExtensions.ExtractHeaderTags(headers, headersToCollect, defaultTagPrefix: PropagationExtensions.HttpResponseHeadersTagPrefix); + var tags = PropagationExtensions.ExtractHeaderTags(headers, headersToCollect, defaultTagPrefix: prefix); foreach (var tag in tags) { span.SetTag(tag.Key, tag.Value); @@ -212,7 +212,9 @@ private static void TryAddEndPoint(Span span) private void Report(ITransport transport, Span span, WafMatch[] results, bool blocked) { span.SetTag(Tags.AppSecEvent, "true"); - span.SetTraceSamplingPriority(SamplingPriority.UserKeep); + var samplingPirority = _settings.KeepTraces + ? SamplingPriority.UserKeep : SamplingPriority.AutoReject; + span.SetTraceSamplingPriority(samplingPirority); LogMatchesIfDebugEnabled(results, blocked); @@ -221,7 +223,7 @@ private void Report(ITransport transport, Span span, WafMatch[] results, bool bl span.SetTag(Tags.Origin, "appsec"); - span.SetTag(Tags.HttpUserAgent, transport.GetUserAget()); + span.SetTag(Tags.HttpUserAgent, transport.GetUserAgent()); var reportedIpInfo = transport.GetReportedIpInfo(); span.SetTag(Tags.NetworkClientIp, reportedIpInfo.IpAddress); @@ -230,14 +232,14 @@ private void Report(ITransport transport, Span span, WafMatch[] results, bool bl span.SetTag(Tags.ActorIp, ipInfo.IpAddress); var headers = transport.GetRequestHeaders(); - AddHeaderTags(span, headers, RequestHeaders); + AddHeaderTags(span, headers, RequestHeaders, PropagationExtensions.HttpRequestHeadersTagPrefix); transport.OnCompleted(() => { TryAddEndPoint(span); var headers = transport.GetResponseHeaders(); - AddHeaderTags(span, headers, ResponseHeaders); + AddHeaderTags(span, headers, ResponseHeaders, PropagationExtensions.HttpResponseHeadersTagPrefix); }); } diff --git a/tracer/src/Datadog.Trace/AppSec/SecuritySettings.cs b/tracer/src/Datadog.Trace/AppSec/SecuritySettings.cs index 66abf63b0..d8797c52d 100644 --- a/tracer/src/Datadog.Trace/AppSec/SecuritySettings.cs +++ b/tracer/src/Datadog.Trace/AppSec/SecuritySettings.cs @@ -5,9 +5,6 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Datadog.Trace.Configuration; namespace Datadog.Trace.AppSec @@ -22,7 +19,8 @@ public SecuritySettings(IConfigurationSource source) Rules = source?.GetString(ConfigurationKeys.AppSecRules); CustomIpHeader = source?.GetString(ConfigurationKeys.AppSecCustomIpHeader); var extraHeaders = source?.GetString(ConfigurationKeys.AppSecExtraHeaders); - ExtraHeaders = !string.IsNullOrEmpty(extraHeaders) ? extraHeaders.Split(',') : new string[0]; + ExtraHeaders = !string.IsNullOrEmpty(extraHeaders) ? extraHeaders.Split(',') : Array.Empty(); + KeepTraces = source?.GetBool(ConfigurationKeys.AppSecKeepTraces) ?? true; } public bool Enabled { get; set; } @@ -38,6 +36,8 @@ public SecuritySettings(IConfigurationSource source) public string Rules { get; } + public bool KeepTraces { get; } + public static SecuritySettings FromDefaultSources() { var source = GlobalSettings.CreateDefaultConfigurationSource(); diff --git a/tracer/src/Datadog.Trace/AppSec/Transports/Http/HttpTransport.Core.cs b/tracer/src/Datadog.Trace/AppSec/Transports/Http/HttpTransport.Core.cs index 7ba1cdcc4..105976570 100644 --- a/tracer/src/Datadog.Trace/AppSec/Transports/Http/HttpTransport.Core.cs +++ b/tracer/src/Datadog.Trace/AppSec/Transports/Http/HttpTransport.Core.cs @@ -46,7 +46,7 @@ public IpInfo GetReportedIpInfo() return new IpInfo(ipAddress, port); } - public string GetUserAget() + public string GetUserAgent() { return _context.Request.Headers[HeaderNames.UserAgent]; } diff --git a/tracer/src/Datadog.Trace/AppSec/Transports/Http/HttpTransport.Framework.cs b/tracer/src/Datadog.Trace/AppSec/Transports/Http/HttpTransport.Framework.cs index a3d635a77..7cec95783 100644 --- a/tracer/src/Datadog.Trace/AppSec/Transports/Http/HttpTransport.Framework.cs +++ b/tracer/src/Datadog.Trace/AppSec/Transports/Http/HttpTransport.Framework.cs @@ -40,7 +40,7 @@ public IpInfo GetReportedIpInfo() return IpExtractor.ExtractAddressAndPort(hostAddress, isSecure); } - public string GetUserAget() + public string GetUserAgent() { return _context.Request.UserAgent; } diff --git a/tracer/src/Datadog.Trace/AppSec/Transports/ITransport.cs b/tracer/src/Datadog.Trace/AppSec/Transports/ITransport.cs index f078b00bd..2d95e29fa 100644 --- a/tracer/src/Datadog.Trace/AppSec/Transports/ITransport.cs +++ b/tracer/src/Datadog.Trace/AppSec/Transports/ITransport.cs @@ -22,7 +22,7 @@ internal interface ITransport IpInfo GetReportedIpInfo(); - string GetUserAget(); + string GetUserAgent(); IHeadersCollection GetRequestHeaders(); diff --git a/tracer/src/Datadog.Trace/AppSec/Waf/Encoder.cs b/tracer/src/Datadog.Trace/AppSec/Waf/Encoder.cs index f0f75407a..0e15a3599 100644 --- a/tracer/src/Datadog.Trace/AppSec/Waf/Encoder.cs +++ b/tracer/src/Datadog.Trace/AppSec/Waf/Encoder.cs @@ -80,8 +80,9 @@ private Obj EncodeInternal(object o, List argCache, int remainingDepth) var value = o switch { + null => CreateNativeString(string.Empty), string s => CreateNativeString(s), - JValue jv => CreateNativeString(jv.Value.ToString()), + JValue jv => CreateNativeString(jv.Value?.ToString() ?? string.Empty), int i => new Obj(_wafNative.ObjectSigned(i)), long i => new Obj(_wafNative.ObjectSigned(i)), uint i => new Obj(_wafNative.ObjectUnsigned(i)), diff --git a/tracer/src/Datadog.Trace/AppSec/Waf/rule-set.json b/tracer/src/Datadog.Trace/AppSec/Waf/rule-set.json index 05f329f8c..1303ba892 100644 --- a/tracer/src/Datadog.Trace/AppSec/Waf/rule-set.json +++ b/tracer/src/Datadog.Trace/AppSec/Waf/rule-set.json @@ -285,6 +285,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "list": [ @@ -306,6 +309,7 @@ ".eslintignore", ".fbcindex", ".forward", + ".git", ".gitattributes", ".gitconfig", ".gnupg/", @@ -1481,6 +1485,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "list": [ @@ -1631,6 +1638,9 @@ }, { "address": "server.request.headers.no_cookies" + }, + { + "address": "grpc.server.request.message" } ], "regex": "^\\(\\s*\\)\\s+{", @@ -1659,8 +1669,18 @@ { "address": "server.request.headers.no_cookies", "key_path": [ - "x-filename", - "x_filename", + "x-filename" + ] + }, + { + "address": "server.request.headers.no_cookies", + "key_path": [ + "x_filename" + ] + }, + { + "address": "server.request.headers.no_cookies", + "key_path": [ "x-file-name" ] } @@ -1707,9 +1727,24 @@ { "address": "server.request.headers.no_cookies", "key_path": [ - "x-filename", - "x_filename", - "x.filename", + "x-filename" + ] + }, + { + "address": "server.request.headers.no_cookies", + "key_path": [ + "x_filename" + ] + }, + { + "address": "server.request.headers.no_cookies", + "key_path": [ + "x.filename" + ] + }, + { + "address": "server.request.headers.no_cookies", + "key_path": [ "x-file-name" ] } @@ -1750,6 +1785,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "list": [ @@ -1804,6 +1842,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "(?:HTTP_(?:ACCEPT(?:_(?:ENCODING|LANGUAGE|CHARSET))?|(?:X_FORWARDED_FO|REFERE)R|(?:USER_AGEN|HOS)T|CONNECTION|KEEP_ALIVE)|PATH_(?:TRANSLATED|INFO)|ORIG_PATH_INFO|QUERY_STRING|REQUEST_URI|AUTH_TYPE)", @@ -1840,6 +1881,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "php://(?:std(?:in|out|err)|(?:in|out)put|fd|memory|temp|filter)", @@ -1875,6 +1919,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "list": [ @@ -1954,6 +2001,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "\\b(?:s(?:e(?:t(?:_(?:e(?:xception|rror)_handler|magic_quotes_runtime|include_path)|defaultstub)|ssion_s(?:et_save_handler|tart))|qlite_(?:(?:(?:unbuffered|single|array)_)?query|create_(?:aggregate|function)|p?open|exec)|tr(?:eam_(?:context_create|socket_client)|ipc?slashes|rev)|implexml_load_(?:string|file)|ocket_c(?:onnect|reate)|h(?:ow_sourc|a1_fil)e|pl_autoload_register|ystem)|p(?:r(?:eg_(?:replace(?:_callback(?:_array)?)?|match(?:_all)?|split)|oc_(?:(?:terminat|clos|nic)e|get_status|open)|int_r)|o(?:six_(?:get(?:(?:e[gu]|g)id|login|pwnam)|mk(?:fifo|nod)|ttyname|kill)|pen)|hp(?:_(?:strip_whitespac|unam)e|version|info)|g_(?:(?:execut|prepar)e|connect|query)|a(?:rse_(?:ini_file|str)|ssthru)|utenv)|r(?:unkit_(?:function_(?:re(?:defin|nam)e|copy|add)|method_(?:re(?:defin|nam)e|copy|add)|constant_(?:redefine|add))|e(?:(?:gister_(?:shutdown|tick)|name)_function|ad(?:(?:gz)?file|_exif_data|dir))|awurl(?:de|en)code)|i(?:mage(?:createfrom(?:(?:jpe|pn)g|x[bp]m|wbmp|gif)|(?:jpe|pn)g|g(?:d2?|if)|2?wbmp|xbm)|s_(?:(?:(?:execut|write?|read)ab|fi)le|dir)|ni_(?:get(?:_all)?|set)|terator_apply|ptcembed)|g(?:et(?:_(?:c(?:urrent_use|fg_va)r|meta_tags)|my(?:[gpu]id|inode)|(?:lastmo|cw)d|imagesize|env)|z(?:(?:(?:defla|wri)t|encod|fil)e|compress|open|read)|lob)|a(?:rray_(?:u(?:intersect(?:_u?assoc)?|diff(?:_u?assoc)?)|intersect_u(?:assoc|key)|diff_u(?:assoc|key)|filter|reduce|map)|ssert(?:_options)?)|h(?:tml(?:specialchars(?:_decode)?|_entity_decode|entities)|(?:ash(?:_(?:update|hmac))?|ighlight)_file|e(?:ader_register_callback|x2bin))|f(?:i(?:le(?:(?:[acm]tim|inod)e|(?:_exist|perm)s|group)?|nfo_open)|tp_(?:nb_(?:ge|pu)|connec|ge|pu)t|(?:unction_exis|pu)ts|write|open)|o(?:b_(?:get_(?:c(?:ontents|lean)|flush)|end_(?:clean|flush)|clean|flush|start)|dbc_(?:result(?:_all)?|exec(?:ute)?|connect)|pendir)|m(?:b_(?:ereg(?:_(?:replace(?:_callback)?|match)|i(?:_replace)?)?|parse_str)|(?:ove_uploaded|d5)_file|ethod_exists|ysql_query|kdir)|e(?:x(?:if_(?:t(?:humbnail|agname)|imagetype|read_data)|ec)|scapeshell(?:arg|cmd)|rror_reporting|val)|c(?:url_(?:file_create|exec|init)|onvert_uuencode|reate_function|hr)|u(?:n(?:serialize|pack)|rl(?:de|en)code|[ak]?sort)|(?:json_(?:de|en)cod|debug_backtrac|tmpfil)e|b(?:(?:son_(?:de|en)|ase64_en)code|zopen)|var_dump)(?:\\s|/\\*.*\\*/|//.*|#.*)*\\(.*\\)", @@ -1992,6 +2042,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "[oOcC]:\\d+:\\\".+?\\\":\\d+:{[\\W\\w]*}", @@ -2028,6 +2081,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "(?i:zlib|glob|phar|ssh2|rar|ogg|expect|zip)://", @@ -2066,6 +2122,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "(?:(?:_(?:\\$\\$ND_FUNC\\$\\$_|_js_function)|(?:new\\s+Function|\\beval)\\s*\\(|String\\s*\\.\\s*fromCharCode|function\\s*\\(\\s*\\)\\s*{|this\\.constructor)|module\\.exports\\s*=)", @@ -2097,7 +2156,12 @@ { "address": "server.request.headers.no_cookies", "key_path": [ - "user-agent", + "user-agent" + ] + }, + { + "address": "server.request.headers.no_cookies", + "key_path": [ "referer" ] }, @@ -2109,6 +2173,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ] }, @@ -2137,7 +2204,12 @@ { "address": "server.request.headers.no_cookies", "key_path": [ - "user-agent", + "user-agent" + ] + }, + { + "address": "server.request.headers.no_cookies", + "key_path": [ "referer" ] }, @@ -2149,6 +2221,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "]*>[\\s\\S]*?", @@ -2181,7 +2256,12 @@ { "address": "server.request.headers.no_cookies", "key_path": [ - "user-agent", + "user-agent" + ] + }, + { + "address": "server.request.headers.no_cookies", + "key_path": [ "referer" ] }, @@ -2193,6 +2273,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "[\\s\\\"'`;\\/0-9=\\x0B\\x09\\x0C\\x3B\\x2C\\x28\\x3B]on[a-zA-Z]{3,25}[\\s\\x0B\\x09\\x0C\\x3B\\x2C\\x28\\x3B]*?=[^=]", @@ -2225,7 +2308,12 @@ { "address": "server.request.headers.no_cookies", "key_path": [ - "user-agent", + "user-agent" + ] + }, + { + "address": "server.request.headers.no_cookies", + "key_path": [ "referer" ] }, @@ -2237,6 +2325,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "[a-z]+=(?:[^:=]+:.+;)*?[^:=]+:url\\(javascript", @@ -2274,6 +2365,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "list": [ @@ -2317,6 +2411,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "(?i:<.*[:]?vmlframe.*?[\\s/+]*?src[\\s/+]*=)", @@ -2355,6 +2452,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "(?i:(?:j|&#x?0*(?:74|4A|106|6A);?)(?:\\t|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:a|&#x?0*(?:65|41|97|61);?)(?:\\t|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:v|&#x?0*(?:86|56|118|76);?)(?:\\t|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:a|&#x?0*(?:65|41|97|61);?)(?:\\t|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:s|&#x?0*(?:83|53|115|73);?)(?:\\t|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:c|&#x?0*(?:67|43|99|63);?)(?:\\t|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:r|&#x?0*(?:82|52|114|72);?)(?:\\t|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:i|&#x?0*(?:73|49|105|69);?)(?:\\t|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:p|&#x?0*(?:80|50|112|70);?)(?:\\t|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:t|&#x?0*(?:84|54|116|74);?)(?:\\t|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?::|&(?:#x?0*(?:58|3A);?|colon;)).)", @@ -2393,6 +2493,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "(?i:(?:v|&#x?0*(?:86|56|118|76);?)(?:\\t|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:b|&#x?0*(?:66|42|98|62);?)(?:\\t|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:s|&#x?0*(?:83|53|115|73);?)(?:\\t|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:c|&#x?0*(?:67|43|99|63);?)(?:\\t|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:r|&#x?0*(?:82|52|114|72);?)(?:\\t|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:i|&#x?0*(?:73|49|105|69);?)(?:\\t|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:p|&#x?0*(?:80|50|112|70);?)(?:\\t|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?:t|&#x?0*(?:84|54|116|74);?)(?:\\t|&(?:#x?0*(?:9|13|10|A|D);?|tab;|newline;))*(?::|&(?:#x?0*(?:58|3A);?|colon;)).)", @@ -2431,6 +2534,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "]", @@ -2618,6 +2736,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": ")|<.*\\+AD4-", @@ -2691,6 +2815,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "![!+ ]\\[\\]", @@ -2727,6 +2854,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ] }, @@ -2760,6 +2890,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "\\b(?:(?:m(?:s(?:ys(?:ac(?:cess(?:objects|storage|xml)|es)|(?:relationship|object|querie)s|modules2?)|db)|aster\\.\\.sysdatabases|ysql\\.db)|pg_(?:catalog|toast)|information_schema|northwind|tempdb)\\b|s(?:(?:ys(?:\\.database_name|aux)|qlite(?:_temp)?_master)\\b|chema(?:_name\\b|\\W*\\())|d(?:atabas|b_nam)e\\W*\\()", @@ -2795,6 +2928,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "(?i:sleep\\(\\s*?\\d*?\\s*?\\)|benchmark\\(.*?\\,.*?\\))", @@ -2831,6 +2967,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "(?:\\b(?:(?:c(?:onnection_id|urrent_user)|database)\\s*?\\([^\\)]*?|u(?:nion(?:[\\w(?:\\s]*?select| select @)|ser\\s*?\\([^\\)]*?)|s(?:chema\\s*?\\([^\\)]*?|elect.*?\\w?user\\()|into[\\s+]+(?:dump|out)file\\s*?[\\\"'`]|from\\W+information_schema\\W|exec(?:ute)?\\s+master\\.)|[\\\"'`](?:;?\\s*?(?:union\\b\\s*?(?:(?:distin|sele)ct|all)|having|select)\\b\\s*?[^\\s]|\\s*?!\\s*?[\\\"'`\\w])|\\s*?exec(?:ute)?.*?\\Wxp_cmdshell|\\Wiif\\s*?\\()", @@ -2866,6 +3005,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "^(?i:-0000023456|4294967295|4294967296|2147483648|2147483647|0000012345|-2147483648|-2147483649|0000023456|2.2250738585072007e-308|2.2250738585072011e-308|1e309)$", @@ -2902,6 +3044,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "(?:[\\\"'`](?:;*?\\s*?waitfor\\s+(?:delay|time)\\s+[\\\"'`]|;.*?:\\s*?goto)|alter\\s*?\\w+.*?cha(?:racte)?r\\s+set\\s+\\w+)", @@ -2937,6 +3082,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "(?i:merge.*?using\\s*?\\(|execute\\s*?immediate\\s*?[\\\"'`]|match\\s*?[\\w(?:),+-]+\\s*?against\\s*?\\()", @@ -2973,6 +3121,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "union.*?select.*?from", @@ -3008,6 +3159,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "(?:;\\s*?shutdown\\s*?(?:[#;{]|\\/\\*|--)|waitfor\\s*?delay\\s?[\\\"'`]+\\s?\\d|select\\s*?pg_sleep)", @@ -3043,6 +3197,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "(?i:(?:\\[\\$(?:ne|eq|lte?|gte?|n?in|mod|all|size|exists|type|slice|x?or|div|like|between|and)\\]))", @@ -3079,6 +3236,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "(?:^[\\W\\d]+\\s*?(?:alter\\s*(?:a(?:(?:pplication\\s*rol|ggregat)e|s(?:ymmetric\\s*ke|sembl)y|u(?:thorization|dit)|vailability\\s*group)|c(?:r(?:yptographic\\s*provider|edential)|o(?:l(?:latio|um)|nversio)n|ertificate|luster)|s(?:e(?:rv(?:ice|er)|curity|quence|ssion|arch)|y(?:mmetric\\s*key|nonym)|togroup|chema)|m(?:a(?:s(?:ter\\s*key|k)|terialized)|e(?:ssage\\s*type|thod)|odule)|l(?:o(?:g(?:file\\s*group|in)|ckdown)|a(?:ngua|r)ge|ibrary)|t(?:(?:abl(?:espac)?|yp)e|r(?:igger|usted)|hreshold|ext)|p(?:a(?:rtition|ckage)|ro(?:cedur|fil)e|ermission)|d(?:i(?:mension|skgroup)|atabase|efault|omain)|r(?:o(?:l(?:lback|e)|ute)|e(?:sourc|mot)e)|f(?:u(?:lltext|nction)|lashback|oreign)|e(?:xte(?:nsion|rnal)|(?:ndpoi|ve)nt)|in(?:dex(?:type)?|memory|stance)|b(?:roker\\s*priority|ufferpool)|x(?:ml\\s*schema|srobject)|w(?:ork(?:load)?|rapper)|hi(?:erarchy|stogram)|o(?:perator|utline)|(?:nicknam|queu)e|us(?:age|er)|group|java|view)\\b|(?:(?:(?:trunc|cre)at|renam)e|d(?:e(?:lete|sc)|rop)|(?:inser|selec)t|load)\\s+\\w+|u(?:nion\\s*(?:(?:distin|sele)ct|all)\\b|pdate\\s+\\w+))|\\b(?:(?:(?:(?:trunc|cre|upd)at|renam)e|(?:inser|selec)t|de(?:lete|sc)|alter|load)\\s+(?:group_concat|load_file|char)\\b\\s*\\(?|end\\s*?\\);)|[\\\"'`\\w]\\s+as\\b\\s*[\\\"'`\\w]+\\s*\\bfrom|[\\s(?:]load_file\\s*?\\(|[\\\"'`]\\s+regexp\\W)", @@ -3114,6 +3274,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "(?i:/\\*[!+](?:[\\w\\s=_\\-(?:)]+)?\\*/)", @@ -3189,6 +3352,9 @@ }, { "address": "server.request.headers.no_cookies" + }, + { + "address": "grpc.server.request.message" } ], "regex": "java\\.lang\\.(?:runtime|processbuilder)", @@ -3230,6 +3396,9 @@ }, { "address": "server.request.headers.no_cookies" + }, + { + "address": "grpc.server.request.message" } ], "regex": "(?:runtime|processbuilder)", @@ -3257,6 +3426,9 @@ }, { "address": "server.request.headers.no_cookies" + }, + { + "address": "grpc.server.request.message" } ], "regex": "(?:unmarshaller|base64data|java\\.)", @@ -3298,6 +3470,9 @@ }, { "address": "server.request.headers.no_cookies" + }, + { + "address": "grpc.server.request.message" } ], "list": [ @@ -3353,6 +3528,552 @@ "lowercase" ] }, + { + "id": "nfd-000-001", + "name": "Detect common directory discovery scans", + "tags": { + "type": "security_scanner", + "category": "attack_attempt" + }, + "conditions": [ + { + "operator": "match_regex", + "parameters": { + "inputs": [ + { + "address": "server.response.status" + } + ], + "regex": "^404$", + "options": { + "case_sensitive": true + } + } + }, + { + "operator": "phrase_match", + "parameters": { + "inputs": [ + { + "address": "server.request.uri.raw" + } + ], + "list": [ + "/wordpress/", + "/etc/", + "/login.php", + "/install.php", + "/administrator", + "/admin.php", + "/wp-config", + "/phpmyadmin", + "/fckeditor", + "/mysql", + "/manager/html", + ".htaccess", + "/config.php", + "/configuration", + "/cgi-bin/php", + "/search.php", + "/tinymce", + "/tiny_mce", + "/settings.php", + "../../..", + "/install/", + "/download.php", + "/webdav", + "/forum.php", + "/user.php", + "/style.php", + "/jmx-console", + "/modules.php", + "/include.php", + "/default.asp", + "/help.php", + "/database.yml", + "/database.yml.pgsql", + "/database.yml.sqlite3", + "/database.yml.sqlite", + "/database.yml.mysql", + ".%2e/", + "/view.php", + "/header.php", + "/search.asp", + "%5c%5c", + "/server/php/", + "/invoker/jmxinvokerservlet", + "/phpmyadmin/index.php", + "/data/admin/allowurl.txt", + "/verify.php", + "/misc/ajax.js", + "/.idea", + "/module.php", + "/backup.rar", + "/backup.tar", + "/backup.zip", + "/backup.7z", + "/backup.gz", + "/backup.tgz", + "/backup.tar.gz", + "waitfor%20delay", + "/calendar.php", + "/news.php", + "/dompdf.php", + "))))))))))))))))", + "/web.config", + "tree.php", + "/cgi-bin-sdb/printenv", + "/comments.php", + "/detail.asp", + "/license.txt", + "/admin.asp", + "/auth.php", + "/list.php", + "/content.php", + "/mod.php", + "/mini.php", + "/install.pgsql", + "/install.mysql", + "/install.sqlite", + "/install.sqlite3", + "/install.txt", + "/install.md", + "/doku.php", + "/main.asp", + "/myadmin", + "/force-download.php", + "/iisprotect/admin", + "/.gitignore", + "/print.php", + "/common.php", + "/mainfile.php", + "/functions.php", + "/scripts/setup.php", + "/faq.php", + "/op/op.login.php", + "/home.php", + "/includes/hnmain.inc.php3", + "/preview.php", + "/dump.rar", + "/dump.tar", + "/dump.zip", + "/dump.7z", + "/dump.gz", + "/dump.tgz", + "/dump.tar.gz", + "/thumbnail.php", + "/sendcard.php", + "/global.asax", + "/directory.php", + "/footer.php", + "/error.asp", + "/forum.asp", + "/save.php", + "/htmlsax3.php", + "/adm/krgourl.php", + "/includes/converter.inc.php", + "/nucleus/libs/pluginadmin.php", + "/base_qry_common.php", + "/fileadmin", + "/bitrix/admin/", + "/adm.php", + "/util/barcode.php", + "/action.php", + "/rss.asp", + "/downloads.php", + "/page.php", + "/snarf_ajax.php", + "/fck/editor", + "/sendmail.php", + "/detail.php", + "/iframe.php", + "/swfupload.swf", + "/jenkins/login", + "/phpmyadmin/main.php", + "/phpmyadmin/scripts/setup.php", + "/user/index.php", + "/checkout.php", + "/process.php", + "/ks_inc/ajax.js", + "/export.php", + "/register.php", + "/cart.php", + "/console.php", + "/friend.php", + "/readmsg.php", + "/install.asp", + "/dagent/downloadreport.asp", + "/system/index.php", + "/core/changelog.txt", + "/js/util.js", + "/interna.php", + "/gallery.php", + "/links.php", + "/data/admin/ver.txt", + "/language/zh-cn.xml", + "/productdetails.asp", + "/admin/template/article_more/config.htm", + "/components/com_moofaq/includes/file_includer.php", + "/licence.txt", + "/rss.xsl", + "/vtigerservice.php", + "/mysql/main.php", + "/passwiki.php", + "/scr/soustab.php", + "/global.php", + "/email.php", + "/user.asp", + "/msd", + "/products.php", + "/cultbooking.php", + "/cron.php", + "/static/js/admincp.js", + "/comment.php", + "/maintainers", + "/modules/plain/adminpart/addplain.php", + "/wp-content/plugins/ungallery/source_vuln.php", + "/upgrade.txt", + "/category.php", + "/index_logged.php", + "/members.asp", + "/script/html.js", + "/images/ad.js", + "/awstats/awstats.pl", + "/includes/esqueletos/skel_null.php", + "/modules/profile/user.php", + "/window_top.php", + "/openbrowser.php", + "/thread.php", + "tinfoil_xss", + "/includes/include.php", + "/urheber.php", + "/header.inc.php", + "/mysqldumper", + "/display.php", + "/website.php", + "/stats.php", + "/assets/plugins/mp3_id/mp3_id.php", + "/siteminderagent/forms/smpwservices.fcc" + ] + } + } + ], + "transformers": [ + "lowercase" + ] + }, + { + "id": "nfd-000-002", + "name": "Detect failed attempt to fetch readme files", + "tags": { + "type": "security_scanner", + "category": "attack_attempt" + }, + "conditions": [ + { + "operator": "match_regex", + "parameters": { + "inputs": [ + { + "address": "server.response.status" + } + ], + "regex": "^404$", + "options": { + "case_sensitive": true + } + } + }, + { + "operator": "match_regex", + "parameters": { + "inputs": [ + { + "address": "server.request.uri.raw" + } + ], + "regex": "readme\\.[\\.a-z0-9]+$", + "options": { + "case_sensitive": false + } + } + } + ], + "transformers": [] + }, + { + "id": "nfd-000-003", + "name": "Detect failed attempt to fetch Java EE resource files", + "tags": { + "type": "security_scanner", + "category": "attack_attempt" + }, + "conditions": [ + { + "operator": "match_regex", + "parameters": { + "inputs": [ + { + "address": "server.response.status" + } + ], + "regex": "^404$", + "options": { + "case_sensitive": true + } + } + }, + { + "operator": "match_regex", + "parameters": { + "inputs": [ + { + "address": "server.request.uri.raw" + } + ], + "regex": "^(?:.*web\\-inf)(?:.*web\\.xml).*$", + "options": { + "case_sensitive": false + } + } + } + ], + "transformers": [] + }, + { + "id": "nfd-000-004", + "name": "Detect failed attempt to fetch code files", + "tags": { + "type": "security_scanner", + "category": "attack_attempt" + }, + "conditions": [ + { + "operator": "match_regex", + "parameters": { + "inputs": [ + { + "address": "server.response.status" + } + ], + "regex": "^404$", + "options": { + "case_sensitive": true + } + } + }, + { + "operator": "match_regex", + "parameters": { + "inputs": [ + { + "address": "server.request.uri.raw" + } + ], + "regex": "\\.(java|pyc?|rb|class)\\b", + "options": { + "case_sensitive": false + } + } + } + ], + "transformers": [] + }, + { + "id": "nfd-000-005", + "name": "Detect failed attempt to fetch source code archives", + "tags": { + "type": "security_scanner", + "category": "attack_attempt" + }, + "conditions": [ + { + "operator": "match_regex", + "parameters": { + "inputs": [ + { + "address": "server.response.status" + } + ], + "regex": "^404$", + "options": { + "case_sensitive": true + } + } + }, + { + "operator": "match_regex", + "parameters": { + "inputs": [ + { + "address": "server.request.uri.raw" + } + ], + "regex": "\\.(sql|log|ndb|gz|zip|tar\\.gz|tar|regVV|reg|conf|bz2|ini|db|war|bat|inc|btr|server|ds|conf|config|admin|master|sln|bak)\\b(?:[^.]|$)", + "options": { + "case_sensitive": false + } + } + } + ], + "transformers": [] + }, + { + "id": "nfd-000-006", + "name": "Detect failed attempt to fetch sensitive files", + "tags": { + "type": "security_scanner", + "category": "attack_attempt" + }, + "conditions": [ + { + "operator": "match_regex", + "parameters": { + "inputs": [ + { + "address": "server.response.status" + } + ], + "regex": "^404$", + "options": { + "case_sensitive": true + } + } + }, + { + "operator": "match_regex", + "parameters": { + "inputs": [ + { + "address": "server.request.uri.raw" + } + ], + "regex": "\\.(cgi|bat|dll|exe|key|cert|crt|pem|der|pkcs|pkcs|pkcs[0-9]*|nsf|jsa|war|java|class|vb|vba|so|git|svn|hg|cvs)([^a-zA-Z0-9_]|$)", + "options": { + "case_sensitive": false + } + } + } + ], + "transformers": [] + }, + { + "id": "nfd-000-007", + "name": "Detect failed attempt to fetch archives", + "tags": { + "type": "security_scanner", + "category": "attack_attempt" + }, + "conditions": [ + { + "operator": "match_regex", + "parameters": { + "inputs": [ + { + "address": "server.response.status" + } + ], + "regex": "^404$", + "options": { + "case_sensitive": true + } + } + }, + { + "operator": "match_regex", + "parameters": { + "inputs": [ + { + "address": "server.request.uri.raw" + } + ], + "regex": "/[\\d\\-_]*\\.(rar|tar|zip|7z|gz|tgz|tar.gz)", + "options": { + "case_sensitive": false + } + } + } + ], + "transformers": [] + }, + { + "id": "nfd-000-008", + "name": "Detect failed attempt to trigger incorrect application behavior", + "tags": { + "type": "security_scanner", + "category": "attack_attempt" + }, + "conditions": [ + { + "operator": "match_regex", + "parameters": { + "inputs": [ + { + "address": "server.response.status" + } + ], + "regex": "^404$", + "options": { + "case_sensitive": true + } + } + }, + { + "operator": "match_regex", + "parameters": { + "inputs": [ + { + "address": "server.request.uri.raw" + } + ], + "regex": "(/(administrator/components/com.*\\.php|response\\.write\\(.+\\))|select\\(.+\\)from|\\(.*sleep\\(.+\\)|(%[a-zA-Z0-9]{2}[a-zA-Z]{0,1})+\\))", + "options": { + "case_sensitive": false + } + } + } + ], + "transformers": [] + }, + { + "id": "nfd-000-009", + "name": "Detect failed attempt to leak the structure of the application", + "tags": { + "type": "security_scanner", + "category": "attack_attempt" + }, + "conditions": [ + { + "operator": "match_regex", + "parameters": { + "inputs": [ + { + "address": "server.response.status" + } + ], + "regex": "^404$", + "options": { + "case_sensitive": true + } + } + }, + { + "operator": "match_regex", + "parameters": { + "inputs": [ + { + "address": "server.request.uri.raw" + } + ], + "regex": "/(login\\.rol|LICENSE|[\\w-]+\\.(plx|pwd))$", + "options": { + "case_sensitive": false + } + } + } + ], + "transformers": [] + }, { "id": "sqr-000-001", "name": "SSRF: Try to access the credential manager of the main cloud services", @@ -3372,6 +4093,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "(?i)^\\W*((http|ftp)s?://)?\\W*((::f{4}:)?(169|(0x)?0*a9|0+251)\\.?(254|(0x)?0*fe|0+376)[0-9a-fx\\.:]+|metadata\\.google\\.internal|metadata\\.goog)\\W*/", @@ -3405,6 +4129,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "require\\(['\"][\\w\\.]+['\"]\\)|process\\.\\w+\\([\\w\\.]*\\)|\\.toString\\(\\)", @@ -3463,6 +4190,9 @@ }, { "address": "server.request.headers.no_cookies" + }, + { + "address": "grpc.server.request.message" } ], "regex": "(?i)[&|]\\s*type\\s+%\\w+%\\\\+\\w+\\.ini\\s*[&|]" @@ -3494,6 +4224,9 @@ }, { "address": "server.request.headers.no_cookies" + }, + { + "address": "grpc.server.request.message" } ], "regex": "(?i)[&|]\\s*cat\\s+\\/etc\\/[\\w\\.\\/]*passwd\\s*[&|]" @@ -3525,6 +4258,9 @@ }, { "address": "server.request.headers.no_cookies" + }, + { + "address": "grpc.server.request.message" } ], "regex": "(?i)[&|]\\s*timeout\\s+/t\\s+\\d+\\s*[&|]" @@ -3543,7 +4279,6 @@ }, "conditions": [ { - "operator": "match_regex", "parameters": { "inputs": [ { @@ -3554,13 +4289,17 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "http(s?):\\/\\/([A-Za-z0-9\\.\\-\\_]+|\\[[A-Fa-f0-9\\:]+\\]|):5986\\/wsman", "options": { "min_length": 4 } - } + }, + "operator": "match_regex" } ], "transformers": [] @@ -3584,6 +4323,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "^(jar:)?(http|https):\\/\\/([0-9oq]{1,5}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}|[0-9]{1,10}|localhost)(:[0-9]{1,5})?(\\/.*|)$" @@ -3614,6 +4356,9 @@ }, { "address": "server.request.path_params" + }, + { + "address": "grpc.server.request.message" } ], "regex": "^(jar:)?(http|https):\\/\\/((\\[)?[:0-9a-f\\.x]{2,}(\\])?)(:[0-9]{1,5})?(\\/.*)?$" @@ -3647,6 +4392,9 @@ }, { "address": "server.request.headers.no_cookies" + }, + { + "address": "grpc.server.request.message" } ], "regex": "^(http|https):\\/\\/(.*burpcollaborator\\.net|localtest\\.me|mail\\.ebc\\.apple\\.com|bugbounty\\.dod\\.network|.*\\.[nx]ip\\.io)" @@ -3680,6 +4428,9 @@ }, { "address": "server.request.headers.no_cookies" + }, + { + "address": "grpc.server.request.message" } ], "regex": "^(jar:)?((file|netdoc):\\/\\/[\\\\\\/]+|(dict|gopher|ldap|sftp|tftp):\\/\\/.*:[0-9]{1,5})" @@ -3691,6 +4442,43 @@ "lowercase" ] }, + { + "id": "sqr-000-017", + "name": "JNDI: Attempt to exploit log4j CVE-2021-44228", + "tags": { + "type": "java_code_injection", + "category": "attack_attempt" + }, + "conditions": [ + { + "parameters": { + "inputs": [ + { + "address": "server.request.uri.raw" + }, + { + "address": "server.request.query" + }, + { + "address": "server.request.body" + }, + { + "address": "server.request.path_params" + }, + { + "address": "server.request.headers.no_cookies" + }, + { + "address": "grpc.server.request.message" + } + ], + "regex": "\\${[^j]*j[^n]*n[^d]*d[^i]*i[^:]*:[^}]*}" + }, + "operator": "match_regex" + } + ], + "transformers": [] + }, { "id": "ua0-600-0xx", "name": "Joomla exploitation tool", diff --git a/tracer/src/Datadog.Trace/AspNet/TracingHttpModule.cs b/tracer/src/Datadog.Trace/AspNet/TracingHttpModule.cs index eb22b037f..1983781ea 100644 --- a/tracer/src/Datadog.Trace/AspNet/TracingHttpModule.cs +++ b/tracer/src/Datadog.Trace/AspNet/TracingHttpModule.cs @@ -55,8 +55,12 @@ public TracingHttpModule() /// The operation name to be used for the trace/span data generated public TracingHttpModule(string operationName) { - _requestOperationName = operationName ?? throw new ArgumentNullException(nameof(operationName)); + if (operationName is null) + { + ThrowHelper.ThrowArgumentNullException(nameof(operationName)); + } + _requestOperationName = operationName; _httpContextScopeKey = string.Concat("__SignalFx.Tracing.AspNet.TracingHttpModule-", _requestOperationName); } @@ -106,7 +110,7 @@ private void OnBeginRequest(object sender, EventArgs eventArgs) var tagsFromHeaders = Enumerable.Empty>(); var propagator = tracer.TracerManager.Propagator; - if (tracer.ActiveScope == null) + if (tracer.InternalActiveScope == null) { try { @@ -126,7 +130,7 @@ private void OnBeginRequest(object sender, EventArgs eventArgs) string url = httpRequest.Url.ToString(); // Upstream uses RawUrl, ie. the part of the URL following the domain information. var tags = new WebTags(); - scope = tracer.StartActiveWithTags(httpMethod, propagatedContext, tags: tags); + scope = tracer.StartActiveInternal(httpMethod, propagatedContext, tags: tags); // Leave resourceName blank for now - we'll update it in OnEndRequest scope.Span.DecorateWebServerSpan(resourceName: null, httpMethod, host, url, tags, tagsFromHeaders, httpRequest.UserHostAddress); scope.Span.LogicScope = _requestOperationName; diff --git a/tracer/src/Datadog.Trace/Ci/Agent/CIAgentWriter.cs b/tracer/src/Datadog.Trace/Ci/Agent/CIAgentWriter.cs index d4e1c63ea..e370013d4 100644 --- a/tracer/src/Datadog.Trace/Ci/Agent/CIAgentWriter.cs +++ b/tracer/src/Datadog.Trace/Ci/Agent/CIAgentWriter.cs @@ -4,7 +4,6 @@ // using System; -using System.Collections.Generic; using System.Threading.Tasks; using Datadog.Trace.Agent; using Datadog.Trace.Ci.Tags; @@ -20,8 +19,8 @@ internal class CIAgentWriter : IAgentWriter public CIAgentWriter(ImmutableTracerSettings settings, ISampler sampler) { - _isPartialFlushEnabled = settings.PartialFlushEnabled; - var api = new Api(settings.AgentUri, TransportStrategy.Get(settings), null, rates => sampler.SetDefaultSampleRates(rates), _isPartialFlushEnabled); + _isPartialFlushEnabled = settings.ExporterSettings.PartialFlushEnabled; + var api = new Api(settings.ExporterSettings.AgentUri, TransportStrategy.Get(settings.ExporterSettings), null, rates => sampler.SetDefaultSampleRates(rates), _isPartialFlushEnabled); _agentWriter = new AgentWriter(api, null, maxBufferSize: settings.TraceBufferSize); } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IAmazonWebServiceResponse.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IAmazonWebServiceResponse.cs index 9631feea9..80306bb6f 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IAmazonWebServiceResponse.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IAmazonWebServiceResponse.cs @@ -3,7 +3,6 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; using System.Net; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AWS.SDK @@ -11,9 +10,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AWS.SDK /// /// AmazonWebServiceResponse interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IAmazonWebServiceResponse + internal interface IAmazonWebServiceResponse { /// /// Gets the length of the content diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IClientConfig.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IClientConfig.cs index 8ed5084e4..7c59a973f 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IClientConfig.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IClientConfig.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AWS.SDK { /// /// IClientConfig interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IClientConfig + internal interface IClientConfig { /// /// Gets the region endpoint of the config diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IExecutionContext.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IExecutionContext.cs index 4aa0cf4a6..ea04664fa 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IExecutionContext.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IExecutionContext.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AWS.SDK { /// /// IExecutionContext interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IExecutionContext + internal interface IExecutionContext { /// /// Gets the RequestContext diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IRegionEndpoint.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IRegionEndpoint.cs index 8a39613bb..d8d5394ce 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IRegionEndpoint.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IRegionEndpoint.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AWS.SDK { /// /// IRegionEndpoint interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IRegionEndpoint + internal interface IRegionEndpoint { /// /// Gets the system name of the region endpoint diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IRequest.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IRequest.cs index 23510420f..3208276bb 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IRequest.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IRequest.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AWS.SDK { /// /// IRequest interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IRequest + internal interface IRequest { /// /// Gets the HTTP method diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IRequestContext.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IRequestContext.cs index a14f84098..684260dca 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IRequestContext.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IRequestContext.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AWS.SDK { /// /// IRequestContext interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IRequestContext + internal interface IRequestContext { /// /// Gets the client config diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IResponseContext.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IResponseContext.cs index cdf5f7b1b..e42676895 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IResponseContext.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IResponseContext.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AWS.SDK { /// /// IResponseContext interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IResponseContext + internal interface IResponseContext { /// /// Gets the SDK response diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IResponseMetadata.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IResponseMetadata.cs index af10e20dc..044d70230 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IResponseMetadata.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/IResponseMetadata.cs @@ -4,16 +4,13 @@ // using System.Collections.Generic; -using System.ComponentModel; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AWS.SDK { /// /// ResponseMetadata interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IResponseMetadata + internal interface IResponseMetadata { /// /// Gets the ID of the request diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/RuntimePipelineInvokeAsyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/RuntimePipelineInvokeAsyncIntegration.cs index 7434a7955..3bd213ec9 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/RuntimePipelineInvokeAsyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/RuntimePipelineInvokeAsyncIntegration.cs @@ -36,7 +36,7 @@ public class RuntimePipelineInvokeAsyncIntegration /// Instance value, aka `this` of the instrumented method /// The execution context for the AWS SDK operation /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TExecutionContext executionContext) + internal static CallTargetState OnMethodBegin(TTarget instance, TExecutionContext executionContext) where TExecutionContext : IExecutionContext, IDuckType { if (executionContext.Instance is null) @@ -44,7 +44,7 @@ public static CallTargetState OnMethodBegin(TTarget return CallTargetState.GetDefault(); } - var scope = Tracer.Instance.ActiveScope; + var scope = Tracer.Instance.InternalActiveScope; if (scope?.Span.Tags is AwsSdkTags tags) { tags.Region = executionContext.RequestContext.ClientConfig.RegionEndpoint?.SystemName; @@ -63,7 +63,7 @@ public static CallTargetState OnMethodBegin(TTarget /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TResponse OnAsyncMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) + internal static TResponse OnAsyncMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) where TResponse : IAmazonWebServiceResponse { if (state.Scope?.Span.Tags is AwsSdkTags tags) diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/RuntimePipelineInvokeSyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/RuntimePipelineInvokeSyncIntegration.cs index 1d810518e..661febe59 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/RuntimePipelineInvokeSyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SDK/RuntimePipelineInvokeSyncIntegration.cs @@ -36,7 +36,7 @@ public class RuntimePipelineInvokeSyncIntegration /// Instance value, aka `this` of the instrumented method /// The execution context for the AWS SDK operation /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TExecutionContext executionContext) + internal static CallTargetState OnMethodBegin(TTarget instance, TExecutionContext executionContext) where TExecutionContext : IExecutionContext, IDuckType { if (executionContext.Instance is null) @@ -44,7 +44,7 @@ public static CallTargetState OnMethodBegin(TTarget return CallTargetState.GetDefault(); } - var scope = Tracer.Instance.ActiveScope; + var scope = Tracer.Instance.InternalActiveScope; if (scope?.Span.Tags is AwsSdkTags tags) { tags.Region = executionContext.RequestContext.ClientConfig.RegionEndpoint?.SystemName; @@ -63,7 +63,7 @@ public static CallTargetState OnMethodBegin(TTarget /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TResponseContext responseContext, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TResponseContext responseContext, Exception exception, CallTargetState state) where TResponseContext : IResponseContext { if (state.Scope?.Span.Tags is AwsSdkTags tags) diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/AwsSqsCommon.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/AwsSqsCommon.cs index 8102cc1e5..32686e623 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/AwsSqsCommon.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/AwsSqsCommon.cs @@ -34,11 +34,9 @@ public static Scope CreateScope(Tracer tracer, string operation, out AwsSqsTags try { - Span parent = tracer.ActiveScope?.Span; - tags = new AwsSqsTags(); string serviceName = tracer.Settings.GetServiceName(tracer, DatadogAwsSqsServiceName); - scope = tracer.StartActiveWithTags(SqsOperationName, parent: parentContext, tags: tags, serviceName: serviceName); + scope = tracer.StartActiveInternal(SqsOperationName, parent: parentContext, tags: tags, serviceName: serviceName); var span = scope.Span; span.Type = SpanTypes.Http; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ContextPropagation.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ContextPropagation.cs index 947842987..3070b447c 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ContextPropagation.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ContextPropagation.cs @@ -5,10 +5,7 @@ // Modified by Splunk Inc. -using System; using System.Collections; -using System.Collections.Generic; -using System.Linq; using System.Text; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AWS.SQS diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/CreateQueueAsyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/CreateQueueAsyncIntegration.cs index adee2aafc..2e7c79616 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/CreateQueueAsyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/CreateQueueAsyncIntegration.cs @@ -39,7 +39,7 @@ public class CreateQueueAsyncIntegration /// The request for the SQS operation /// CancellationToken value /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TCreateQueueRequest request, CancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, TCreateQueueRequest request, CancellationToken cancellationToken) where TCreateQueueRequest : ICreateQueueRequest, IDuckType { if (request.Instance is null) @@ -63,7 +63,7 @@ public static CallTargetState OnMethodBegin(TTarge /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TResponse OnAsyncMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) + internal static TResponse OnAsyncMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) where TResponse : ICreateQueueResponse { if (state.Scope?.Span.Tags is AwsSqsTags tags) diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/CreateQueueIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/CreateQueueIntegration.cs index a21b08edb..526c32fc9 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/CreateQueueIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/CreateQueueIntegration.cs @@ -37,7 +37,7 @@ public class CreateQueueIntegration /// Instance value, aka `this` of the instrumented method /// The request for the SQS operation /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TCreateQueueRequest request) + internal static CallTargetState OnMethodBegin(TTarget instance, TCreateQueueRequest request) where TCreateQueueRequest : ICreateQueueRequest, IDuckType { if (request.Instance is null) @@ -61,7 +61,7 @@ public static CallTargetState OnMethodBegin(TTarge /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) where TResponse : ICreateQueueResponse { if (state.Scope?.Span.Tags is AwsSqsTags tags) diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/DeleteMessageAsyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/DeleteMessageAsyncIntegration.cs index 985049bd1..e28b0b640 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/DeleteMessageAsyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/DeleteMessageAsyncIntegration.cs @@ -39,7 +39,7 @@ public class DeleteMessageAsyncIntegration /// The request for the SQS operation /// CancellationToken value /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TDeleteMessageRequest request, CancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, TDeleteMessageRequest request, CancellationToken cancellationToken) where TDeleteMessageRequest : IAmazonSQSRequestWithQueueUrl, IDuckType { if (request.Instance is null) @@ -63,7 +63,7 @@ public static CallTargetState OnMethodBegin(TTar /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TResponse OnAsyncMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) + internal static TResponse OnAsyncMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return response; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/DeleteMessageBatchAsyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/DeleteMessageBatchAsyncIntegration.cs index 0fec700b9..26fec3681 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/DeleteMessageBatchAsyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/DeleteMessageBatchAsyncIntegration.cs @@ -39,7 +39,7 @@ public class DeleteMessageBatchAsyncIntegration /// The request for the SQS operation /// CancellationToken value /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TDeleteMessageBatchRequest request, CancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, TDeleteMessageBatchRequest request, CancellationToken cancellationToken) where TDeleteMessageBatchRequest : IAmazonSQSRequestWithQueueUrl, IDuckType { if (request.Instance is null) @@ -63,7 +63,7 @@ public static CallTargetState OnMethodBegin /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TResponse OnAsyncMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) + internal static TResponse OnAsyncMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return response; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/DeleteMessageBatchIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/DeleteMessageBatchIntegration.cs index 15aaddedc..5e61cd803 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/DeleteMessageBatchIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/DeleteMessageBatchIntegration.cs @@ -37,7 +37,7 @@ public class DeleteMessageBatchIntegration /// Instance value, aka `this` of the instrumented method /// The request for the SQS operation /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TDeleteMessageBatchRequest request) + internal static CallTargetState OnMethodBegin(TTarget instance, TDeleteMessageBatchRequest request) where TDeleteMessageBatchRequest : IAmazonSQSRequestWithQueueUrl, IDuckType { if (request.Instance is null) @@ -61,7 +61,7 @@ public static CallTargetState OnMethodBegin /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return new CallTargetReturn(response); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/DeleteMessageIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/DeleteMessageIntegration.cs index 2e0968a3a..947af9956 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/DeleteMessageIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/DeleteMessageIntegration.cs @@ -37,7 +37,7 @@ public class DeleteMessageIntegration /// Instance value, aka `this` of the instrumented method /// The request for the SQS operation /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TDeleteMessageRequest request) + internal static CallTargetState OnMethodBegin(TTarget instance, TDeleteMessageRequest request) where TDeleteMessageRequest : IAmazonSQSRequestWithQueueUrl, IDuckType { if (request.Instance is null) @@ -61,7 +61,7 @@ public static CallTargetState OnMethodBegin(TTar /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return new CallTargetReturn(response); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/DeleteQueueAsyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/DeleteQueueAsyncIntegration.cs index 26c7406da..401f13ebf 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/DeleteQueueAsyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/DeleteQueueAsyncIntegration.cs @@ -39,7 +39,7 @@ public class DeleteQueueAsyncIntegration /// The request for the SQS operation /// CancellationToken value /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TDeleteQueueRequest request, CancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, TDeleteQueueRequest request, CancellationToken cancellationToken) where TDeleteQueueRequest : IAmazonSQSRequestWithQueueUrl, IDuckType { if (request.Instance is null) @@ -63,7 +63,7 @@ public static CallTargetState OnMethodBegin(TTarge /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TResponse OnAsyncMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) + internal static TResponse OnAsyncMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return response; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/DeleteQueueIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/DeleteQueueIntegration.cs index 4b74eb706..bb1fdf9c3 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/DeleteQueueIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/DeleteQueueIntegration.cs @@ -37,7 +37,7 @@ public class DeleteQueueIntegration /// Instance value, aka `this` of the instrumented method /// The request for the SQS operation /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TDeleteQueueRequest request) + internal static CallTargetState OnMethodBegin(TTarget instance, TDeleteQueueRequest request) where TDeleteQueueRequest : IAmazonSQSRequestWithQueueUrl, IDuckType { if (request.Instance is null) @@ -61,7 +61,7 @@ public static CallTargetState OnMethodBegin(TTarge /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return new CallTargetReturn(response); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/IAmazonSQSRequestWithQueueUrl.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/IAmazonSQSRequestWithQueueUrl.cs index de5a0049b..ab5686ccf 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/IAmazonSQSRequestWithQueueUrl.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/IAmazonSQSRequestWithQueueUrl.cs @@ -3,21 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AWS.SQS { /// /// Interface for ducktyping AmazonSQSRequest implementations with the QueueUrl property /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IAmazonSQSRequestWithQueueUrl + internal interface IAmazonSQSRequestWithQueueUrl { /// /// Gets the URL of the queue diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/IContainsMessageAttributes.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/IContainsMessageAttributes.cs index 4336d27c6..f0fc47ab1 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/IContainsMessageAttributes.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/IContainsMessageAttributes.cs @@ -4,16 +4,13 @@ // using System.Collections; -using System.ComponentModel; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AWS.SQS { /// /// MessageAttributes interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IContainsMessageAttributes + internal interface IContainsMessageAttributes { /// /// Gets or sets the message attributes diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ICreateQueueRequest.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ICreateQueueRequest.cs index a2950d16e..047b3c30a 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ICreateQueueRequest.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ICreateQueueRequest.cs @@ -4,16 +4,13 @@ // using System.Collections.Generic; -using System.ComponentModel; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AWS.SQS { /// /// CreateQueueRequest interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface ICreateQueueRequest + internal interface ICreateQueueRequest { /// /// Gets the name of the queue diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ICreateQueueResponse.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ICreateQueueResponse.cs index 58b65bfdd..98b03d372 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ICreateQueueResponse.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ICreateQueueResponse.cs @@ -3,7 +3,6 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; using Datadog.Trace.ClrProfiler.AutoInstrumentation.AWS.SDK; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AWS.SQS @@ -11,9 +10,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AWS.SQS /// /// CreateQueueResponse interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface ICreateQueueResponse : IAmazonWebServiceResponse + internal interface ICreateQueueResponse : IAmazonWebServiceResponse { /// /// Gets the URL of the created Amazon SQS queue diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ISendMessageBatchRequest.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ISendMessageBatchRequest.cs index 8b0deb680..2aecbfd35 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ISendMessageBatchRequest.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ISendMessageBatchRequest.cs @@ -4,16 +4,13 @@ // using System.Collections; -using System.ComponentModel; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AWS.SQS { /// /// SendMessageBatchRequest interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface ISendMessageBatchRequest : IAmazonSQSRequestWithQueueUrl + internal interface ISendMessageBatchRequest : IAmazonSQSRequestWithQueueUrl { /// /// Gets the message entries diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ISendMessageRequest.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ISendMessageRequest.cs index 88d4ca1ab..c4d117b96 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ISendMessageRequest.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ISendMessageRequest.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AWS.SQS { /// /// SendMessageRequest interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface ISendMessageRequest : IAmazonSQSRequestWithQueueUrl, IContainsMessageAttributes + internal interface ISendMessageRequest : IAmazonSQSRequestWithQueueUrl, IContainsMessageAttributes { } } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ReceiveMessageAsyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ReceiveMessageAsyncIntegration.cs index 5943633b7..71e253bc6 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ReceiveMessageAsyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ReceiveMessageAsyncIntegration.cs @@ -39,7 +39,7 @@ public class ReceiveMessageAsyncIntegration /// The request for the SQS operation /// CancellationToken value /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TReceiveMessageRequest request, CancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, TReceiveMessageRequest request, CancellationToken cancellationToken) where TReceiveMessageRequest : IAmazonSQSRequestWithQueueUrl, IDuckType { if (request.Instance is null) @@ -63,7 +63,7 @@ public static CallTargetState OnMethodBegin(TTa /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TResponse OnAsyncMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) + internal static TResponse OnAsyncMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return response; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ReceiveMessageIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ReceiveMessageIntegration.cs index 1b3c512c8..89ed1cf84 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ReceiveMessageIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/ReceiveMessageIntegration.cs @@ -37,7 +37,7 @@ public class ReceiveMessageIntegration /// Instance value, aka `this` of the instrumented method /// The request for the SQS operation /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TReceiveMessageRequest request) + internal static CallTargetState OnMethodBegin(TTarget instance, TReceiveMessageRequest request) where TReceiveMessageRequest : IAmazonSQSRequestWithQueueUrl, IDuckType { if (request.Instance is null) @@ -61,7 +61,7 @@ public static CallTargetState OnMethodBegin(TTa /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return new CallTargetReturn(response); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/SendMessageAsyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/SendMessageAsyncIntegration.cs index 2cfcc8db0..c9ba3f1de 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/SendMessageAsyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/SendMessageAsyncIntegration.cs @@ -39,7 +39,7 @@ public class SendMessageAsyncIntegration /// The request for the SQS operation /// CancellationToken value /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TSendMessageRequest request, CancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, TSendMessageRequest request, CancellationToken cancellationToken) { if (request is null) { @@ -69,7 +69,7 @@ public static CallTargetState OnMethodBegin(TTarge /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TResponse OnAsyncMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) + internal static TResponse OnAsyncMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return response; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/SendMessageBatchAsyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/SendMessageBatchAsyncIntegration.cs index 9dd3874ee..850779edb 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/SendMessageBatchAsyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/SendMessageBatchAsyncIntegration.cs @@ -39,7 +39,7 @@ public class SendMessageBatchAsyncIntegration /// The request for the SQS operation /// CancellationToken value /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TSendMessageBatchRequest request, CancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, TSendMessageBatchRequest request, CancellationToken cancellationToken) { if (request is null) { @@ -56,7 +56,7 @@ public static CallTargetState OnMethodBegin(T for (int i = 0; i < requestProxy.Entries.Count; i++) { var entry = requestProxy.Entries[i].DuckCast(); - ContextPropagation.InjectHeadersIntoMessage(entry, scope?.Span?.Context); + ContextPropagation.InjectHeadersIntoMessage(entry, scope.Span.Context); } } @@ -73,7 +73,7 @@ public static CallTargetState OnMethodBegin(T /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TResponse OnAsyncMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) + internal static TResponse OnAsyncMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return response; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/SendMessageBatchIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/SendMessageBatchIntegration.cs index cb3e438c9..128e3502e 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/SendMessageBatchIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/SendMessageBatchIntegration.cs @@ -37,7 +37,7 @@ public class SendMessageBatchIntegration /// Instance value, aka `this` of the instrumented method /// The request for the SQS operation /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TSendMessageBatchRequest request) + internal static CallTargetState OnMethodBegin(TTarget instance, TSendMessageBatchRequest request) { if (request is null) { @@ -54,7 +54,7 @@ public static CallTargetState OnMethodBegin(T for (int i = 0; i < requestProxy.Entries.Count; i++) { var entry = requestProxy.Entries[i].DuckCast(); - ContextPropagation.InjectHeadersIntoMessage(entry, scope?.Span?.Context); + ContextPropagation.InjectHeadersIntoMessage(entry, scope.Span.Context); } } @@ -71,7 +71,7 @@ public static CallTargetState OnMethodBegin(T /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return new CallTargetReturn(response); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/SendMessageIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/SendMessageIntegration.cs index 28e946f28..64d1bdd0c 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/SendMessageIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AWS/SQS/SendMessageIntegration.cs @@ -37,7 +37,7 @@ public class SendMessageIntegration /// Instance value, aka `this` of the instrumented method /// The request for the SQS operation /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TSendMessageRequest request) + internal static CallTargetState OnMethodBegin(TTarget instance, TSendMessageRequest request) { if (request is null) { @@ -67,7 +67,7 @@ public static CallTargetState OnMethodBegin(TTarge /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return new CallTargetReturn(response); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/AdoNetClientInstrumentMethodAttribute.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/AdoNetClientInstrumentMethodAttribute.cs index 83a26c7a9..d5b1279dc 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/AdoNetClientInstrumentMethodAttribute.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/AdoNetClientInstrumentMethodAttribute.cs @@ -4,7 +4,6 @@ // using System; -using Datadog.Trace.Configuration; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet { @@ -19,9 +18,9 @@ public AdoNetClientInstrumentMethodAttribute(Type adoNetClientDataType) MinimumVersion = AdoNetClientData.MinimumVersion; MaximumVersion = AdoNetClientData.MaximumVersion; - // Not used for ADO.NET integration. + // Informational only. // Integration name is determined by type of DbCommand in DbScopeFactory - IntegrationName = null; + IntegrationName = AdoNetClientData.IntegrationName; } protected IAdoNetClientData AdoNetClientData { get; } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/AdoNetConstants.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/AdoNetConstants.cs index 7aec8ceef..16eaab227 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/AdoNetConstants.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/AdoNetConstants.cs @@ -3,14 +3,16 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // +using Datadog.Trace.Configuration; + namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet { internal static class AdoNetConstants { internal struct SystemDataClientData : IAdoNetClientData { - // note: not a real integration id, cannot be used for configuration - public string IntegrationName => "AdoNet"; + // note: not a real integration id, cannot currently be used for configuration + public string IntegrationName => nameof(IntegrationId.AdoNet); public string AssemblyName => "System.Data"; @@ -27,8 +29,8 @@ internal struct SystemDataClientData : IAdoNetClientData internal struct SystemDataCommonClientData : IAdoNetClientData { - // note: not a real integration id, cannot be used for configuration - public string IntegrationName => "AdoNet"; + // note: not a real integration id, cannot currently be used for configuration + public string IntegrationName => nameof(IntegrationId.AdoNet); public string AssemblyName => "System.Data.Common"; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteNonQueryAsyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteNonQueryAsyncIntegration.cs index a95274e4e..d57e07e84 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteNonQueryAsyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteNonQueryAsyncIntegration.cs @@ -26,7 +26,7 @@ public class CommandExecuteNonQueryAsyncIntegration /// Instance value, aka `this` of the instrumented method. /// CancellationToken value /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, CancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, CancellationToken cancellationToken) { return new CallTargetState(DbScopeFactory.Cache.CreateDbCommandScope(Tracer.Instance, (IDbCommand)instance)); } @@ -41,7 +41,7 @@ public static CallTargetState OnMethodBegin(TTarget instance, Cancellat /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return returnValue; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteNonQueryIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteNonQueryIntegration.cs index c7a9d3ff7..52fcb26c5 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteNonQueryIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteNonQueryIntegration.cs @@ -24,7 +24,7 @@ public class CommandExecuteNonQueryIntegration /// Type of the target /// Instance value, aka `this` of the instrumented method. /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance) + internal static CallTargetState OnMethodBegin(TTarget instance) { return new CallTargetState(DbScopeFactory.Cache.CreateDbCommandScope(Tracer.Instance, (IDbCommand)instance)); } @@ -39,7 +39,7 @@ public static CallTargetState OnMethodBegin(TTarget instance) /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return new CallTargetReturn(returnValue); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteNonQueryWithBehaviorIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteNonQueryWithBehaviorIntegration.cs index b1f3191c2..9f0ca9a87 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteNonQueryWithBehaviorIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteNonQueryWithBehaviorIntegration.cs @@ -26,7 +26,7 @@ public class CommandExecuteNonQueryWithBehaviorIntegration /// Instance value, aka `this` of the instrumented method. /// Command behavior /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TBehavior commandBehavior) + internal static CallTargetState OnMethodBegin(TTarget instance, TBehavior commandBehavior) { return new CallTargetState(DbScopeFactory.Cache.CreateDbCommandScope(Tracer.Instance, (IDbCommand)instance)); } @@ -41,7 +41,7 @@ public static CallTargetState OnMethodBegin(TTarget instance /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return new CallTargetReturn(returnValue); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderAsyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderAsyncIntegration.cs index b87a8aad5..17a6b806e 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderAsyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderAsyncIntegration.cs @@ -6,7 +6,6 @@ using System; using System.ComponentModel; using System.Data; -using System.Threading; using Datadog.Trace.ClrProfiler.CallTarget; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet @@ -25,7 +24,7 @@ public class CommandExecuteReaderAsyncIntegration /// Type of the target /// Instance value, aka `this` of the instrumented method. /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance) + internal static CallTargetState OnMethodBegin(TTarget instance) { return new CallTargetState(DbScopeFactory.Cache.CreateDbCommandScope(Tracer.Instance, (IDbCommand)instance)); } @@ -40,7 +39,7 @@ public static CallTargetState OnMethodBegin(TTarget instance) /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return returnValue; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderIntegration.cs index a445c21b0..1bcc9d4b7 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderIntegration.cs @@ -24,7 +24,7 @@ public class CommandExecuteReaderIntegration /// Type of the target /// Instance value, aka `this` of the instrumented method. /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance) + internal static CallTargetState OnMethodBegin(TTarget instance) { return new CallTargetState(DbScopeFactory.Cache.CreateDbCommandScope(Tracer.Instance, (IDbCommand)instance)); } @@ -39,7 +39,7 @@ public static CallTargetState OnMethodBegin(TTarget instance) /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return new CallTargetReturn(returnValue); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration.cs index e905a3b97..50e440346 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration.cs @@ -29,7 +29,7 @@ public class CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration /// Command behavior /// CancellationToken value /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TBehavior commandBehavior, CancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, TBehavior commandBehavior, CancellationToken cancellationToken) { return new CallTargetState(DbScopeFactory.Cache.CreateDbCommandScope(Tracer.Instance, (IDbCommand)instance)); } @@ -44,7 +44,7 @@ public static CallTargetState OnMethodBegin(TTarget instance /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return returnValue; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderWithBehaviorAsyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderWithBehaviorAsyncIntegration.cs index 553abacb5..f4ec6f953 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderWithBehaviorAsyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderWithBehaviorAsyncIntegration.cs @@ -26,7 +26,7 @@ public class CommandExecuteReaderWithBehaviorAsyncIntegration /// Instance value, aka `this` of the instrumented method. /// Command behavior /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TBehavior commandBehavior) + internal static CallTargetState OnMethodBegin(TTarget instance, TBehavior commandBehavior) { return new CallTargetState(DbScopeFactory.Cache.CreateDbCommandScope(Tracer.Instance, (IDbCommand)instance)); } @@ -41,7 +41,7 @@ public static CallTargetState OnMethodBegin(TTarget instance /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return returnValue; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderWithBehaviorIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderWithBehaviorIntegration.cs index 4ac86dadf..06378b866 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderWithBehaviorIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderWithBehaviorIntegration.cs @@ -27,7 +27,7 @@ public class CommandExecuteReaderWithBehaviorIntegration /// Instance value, aka `this` of the instrumented method. /// Command behavior /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TBehavior commandBehavior) + internal static CallTargetState OnMethodBegin(TTarget instance, TBehavior commandBehavior) { return new CallTargetState(DbScopeFactory.Cache.CreateDbCommandScope(Tracer.Instance, (IDbCommand)instance)); } @@ -42,7 +42,7 @@ public static CallTargetState OnMethodBegin(TTarget instance /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return new CallTargetReturn(returnValue); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderWithCancellationAsyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderWithCancellationAsyncIntegration.cs index 8f993e91f..3413534b3 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderWithCancellationAsyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderWithCancellationAsyncIntegration.cs @@ -26,7 +26,7 @@ public class CommandExecuteReaderWithCancellationAsyncIntegration /// Instance value, aka `this` of the instrumented method. /// CancellationToken value /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, CancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, CancellationToken cancellationToken) { return new CallTargetState(DbScopeFactory.Cache.CreateDbCommandScope(Tracer.Instance, (IDbCommand)instance)); } @@ -41,7 +41,7 @@ public static CallTargetState OnMethodBegin(TTarget instance, Cancellat /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return returnValue; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteScalarAsyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteScalarAsyncIntegration.cs index 0892f8c17..20c6526dd 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteScalarAsyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteScalarAsyncIntegration.cs @@ -26,7 +26,7 @@ public class CommandExecuteScalarAsyncIntegration /// Instance value, aka `this` of the instrumented method. /// CancellationToken value /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, CancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, CancellationToken cancellationToken) { return new CallTargetState(DbScopeFactory.Cache.CreateDbCommandScope(Tracer.Instance, (IDbCommand)instance)); } @@ -41,7 +41,7 @@ public static CallTargetState OnMethodBegin(TTarget instance, Cancellat /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return returnValue; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteScalarIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteScalarIntegration.cs index 5d1689c73..234b8795b 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteScalarIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteScalarIntegration.cs @@ -24,7 +24,7 @@ public class CommandExecuteScalarIntegration /// Type of the target /// Instance value, aka `this` of the instrumented method. /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance) + internal static CallTargetState OnMethodBegin(TTarget instance) { return new CallTargetState(DbScopeFactory.Cache.CreateDbCommandScope(Tracer.Instance, (IDbCommand)instance)); } @@ -39,7 +39,7 @@ public static CallTargetState OnMethodBegin(TTarget instance) /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return new CallTargetReturn(returnValue); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteScalarWithBehaviorIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteScalarWithBehaviorIntegration.cs index e7541f395..ebf5fed53 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteScalarWithBehaviorIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteScalarWithBehaviorIntegration.cs @@ -26,7 +26,7 @@ public class CommandExecuteScalarWithBehaviorIntegration /// Instance value, aka `this` of the instrumented method. /// Command behavior /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TBehavior commandBehavior) + internal static CallTargetState OnMethodBegin(TTarget instance, TBehavior commandBehavior) { return new CallTargetState(DbScopeFactory.Cache.CreateDbCommandScope(Tracer.Instance, (IDbCommand)instance)); } @@ -41,7 +41,7 @@ public static CallTargetState OnMethodBegin(TTarget instance /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return new CallTargetReturn(returnValue); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/DbScopeFactory.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/DbScopeFactory.cs index 6da40041a..82d259d56 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/DbScopeFactory.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/DbScopeFactory.cs @@ -4,11 +4,14 @@ // using System; +using System.Collections.Generic; using System.Data; using System.Diagnostics.CodeAnalysis; using Datadog.Trace.Configuration; using Datadog.Trace.ExtensionMethods; using Datadog.Trace.Logging; +using Datadog.Trace.Tagging; +using Datadog.Trace.Util; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet { @@ -16,9 +19,9 @@ internal static class DbScopeFactory { private static readonly IDatadogLogger Log = DatadogLogging.GetLoggerFor(typeof(DbScopeFactory)); - private static Scope CreateDbCommandScope(Tracer tracer, IDbCommand command, IntegrationId integrationId, string dbType, string operationName) + private static Scope CreateDbCommandScope(Tracer tracer, IDbCommand command, IntegrationId integrationId, string dbType, string operationName, string serviceName, ref DbCommandCache.TagsCacheItem tagsFromConnectionString) { - if (!tracer.Settings.IsIntegrationEnabled(integrationId)) + if (!tracer.Settings.IsIntegrationEnabled(integrationId) || !tracer.Settings.IsIntegrationEnabled(IntegrationId.AdoNet)) { // integration disabled, don't create a scope, skip this span return null; @@ -28,7 +31,7 @@ private static Scope CreateDbCommandScope(Tracer tracer, IDbCommand command, Int try { - Span parent = tracer.ActiveScope?.Span; + Span parent = tracer.InternalActiveScope?.Span; if (IsDbAlreadyInstrumented(parent, dbType, command.CommandText)) { @@ -38,17 +41,15 @@ private static Scope CreateDbCommandScope(Tracer tracer, IDbCommand command, Int return null; } - string serviceName = tracer.Settings.GetServiceName(tracer, dbType); - var tags = new SqlTags { DbType = dbType, - InstrumentationName = integrationId.ToString() + InstrumentationName = IntegrationRegistry.GetName(integrationId) }; tags.SetAnalyticsSampleRate(integrationId, tracer.Settings, enabledWithGlobalSetting: false); - scope = tracer.StartActiveWithTags(operationName, tags: tags, serviceName: serviceName); + scope = tracer.StartActiveInternal(operationName, tags: tags, serviceName: serviceName); scope.Span.AddTagsFromDbCommand(command); } catch (Exception ex) @@ -111,6 +112,12 @@ public static class Cache private static readonly string DbTypeName; private static readonly string OperationName; private static readonly IntegrationId IntegrationId; + + // ServiceName cache + private static KeyValuePair _serviceNameCache; + + // ConnectionString tags cache + private static KeyValuePair _tagsByConnectionStringCache; // ReSharper restore StaticMemberInGenericType static Cache() @@ -134,7 +141,15 @@ public static Scope CreateDbCommandScope(Tracer tracer, IDbCommand command) if (commandType == CommandType) { // use the cached values if command.GetType() == typeof(TCommand) - return DbScopeFactory.CreateDbCommandScope(tracer, command, IntegrationId, DbTypeName, OperationName); + var tagsFromConnectionString = GetTagsFromConnectionString(command); + return DbScopeFactory.CreateDbCommandScope( + tracer: tracer, + command: command, + integrationId: IntegrationId, + dbType: DbTypeName, + operationName: OperationName, + serviceName: GetServiceName(tracer, DbTypeName), + tagsFromConnectionString: ref tagsFromConnectionString); } // if command.GetType() != typeof(TCommand), we are probably instrumenting a method @@ -142,11 +157,68 @@ public static Scope CreateDbCommandScope(Tracer tracer, IDbCommand command) if (TryGetIntegrationDetails(commandType.FullName, out var integrationId, out var dbTypeName)) { var operationName = $"{dbTypeName}.query"; - return DbScopeFactory.CreateDbCommandScope(tracer, command, integrationId.Value, dbTypeName, operationName); + var tagsFromConnectionString = GetTagsFromConnectionString(command); + return DbScopeFactory.CreateDbCommandScope( + tracer: tracer, + command: command, + integrationId: integrationId.Value, + dbType: dbTypeName, + operationName: operationName, + serviceName: GetServiceName(tracer, dbTypeName), + tagsFromConnectionString: ref tagsFromConnectionString); } return null; } + + private static string GetServiceName(Tracer tracer, string dbTypeName) + { + if (!tracer.Settings.TryGetServiceName(dbTypeName, out string serviceName)) + { + if (DbTypeName != dbTypeName) + { + // We cannot cache in the base class + return tracer.DefaultServiceName; + } + + var serviceNameCache = _serviceNameCache; + + // If not a base class + if (serviceNameCache.Key == tracer.DefaultServiceName) + { + // Service has not changed + // Fastpath + return serviceNameCache.Value; + } + + // We create or replace the cache with the new service name + // Slowpath + var defaultServiceName = tracer.DefaultServiceName; + serviceName = defaultServiceName; + _serviceNameCache = new KeyValuePair(defaultServiceName, serviceName); + } + + return serviceName; + } + + private static DbCommandCache.TagsCacheItem GetTagsFromConnectionString(IDbCommand command) + { + var connectionString = command.Connection?.ConnectionString; + + // Check if the connection string is the one in the cache + var tagsByConnectionString = _tagsByConnectionStringCache; + if (tagsByConnectionString.Key == connectionString) + { + // Fastpath + return tagsByConnectionString.Value; + } + + // Cache the new tags by connection string + // Slowpath + var tags = DbCommandCache.GetTagsFromDbCommand(command); + _tagsByConnectionStringCache = new KeyValuePair(connectionString, tags); + return tags; + } } } } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/AerospikeCommon.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/AerospikeCommon.cs index 0e85e6161..aa81eff2b 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/AerospikeCommon.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/AerospikeCommon.cs @@ -6,7 +6,6 @@ // Modified by Splunk Inc. using System; -using System.Text; using Datadog.Trace.Configuration; using Datadog.Trace.DuckTyping; using Datadog.Trace.Logging; @@ -38,7 +37,7 @@ public static Scope CreateScope(Tracer tracer, TTarget target) { var tags = new AerospikeTags(); var serviceName = tracer.Settings.GetServiceName(tracer, ServiceName); - scope = tracer.StartActiveWithTags(OperationName, tags: tags, serviceName: serviceName); + scope = tracer.StartActiveInternal(OperationName, tags: tags, serviceName: serviceName); var span = scope.Span; span.LogicScope = OperationName; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/AsyncCommandIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/AsyncCommandIntegration.cs index 2eab4a481..146ca992d 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/AsyncCommandIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/AsyncCommandIntegration.cs @@ -31,7 +31,7 @@ public class AsyncCommandIntegration /// Type of the target /// Instance value, aka `this` of the instrumented method. /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance) + internal static CallTargetState OnMethodBegin(TTarget instance) { return new CallTargetState(AerospikeCommon.CreateScope(Tracer.Instance, instance)); } @@ -44,7 +44,7 @@ public static CallTargetState OnMethodBegin(TTarget instance) /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A default CallTargetReturn to satisfy the CallTarget contract - public static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return CallTargetReturn.GetDefault(); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/HasKey.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/HasKey.cs index 3d1d67c89..f534c4eea 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/HasKey.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/HasKey.cs @@ -3,18 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -#pragma warning disable SA1600 // Elements should be documented - -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Aerospike { - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] [DuckCopy] - public struct HasKey + internal struct HasKey { [DuckField(Name = "key")] public Key Key; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/HasKeys.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/HasKeys.cs index 3d5651bfc..aad2eb29a 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/HasKeys.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/HasKeys.cs @@ -3,19 +3,13 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -#pragma warning disable SA1600 // Elements should be documented - using System.Collections; -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Aerospike { - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] [DuckCopy] - public struct HasKeys + internal struct HasKeys { [DuckField(Name = "keys")] public IEnumerable Keys; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/HasStatement.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/HasStatement.cs index 627571224..54a422d1b 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/HasStatement.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/HasStatement.cs @@ -3,18 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -#pragma warning disable SA1600 // Elements should be documented - -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Aerospike { - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] [DuckCopy] - public struct HasStatement + internal struct HasStatement { [DuckField(Name = "statement")] public Statement Statement; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/Key.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/Key.cs index 1c1586a7e..60fd730e3 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/Key.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/Key.cs @@ -3,18 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; using Datadog.Trace.DuckTyping; -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -#pragma warning disable SA1600 // Elements should be documented - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Aerospike { - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] [DuckCopy] - public struct Key + internal struct Key { [DuckField(Name = "ns")] public string Ns; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/Statement.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/Statement.cs index c9a4c366e..6c4cae604 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/Statement.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/Statement.cs @@ -3,19 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -#pragma warning disable SA1600 // Elements should be documented - using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Aerospike { - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] [DuckCopy] - public struct Statement + internal struct Statement { [DuckField(Name = "setName")] public string SetName; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/SyncCommandIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/SyncCommandIntegration.cs index 5e9968ecb..e8fd34f70 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/SyncCommandIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Aerospike/SyncCommandIntegration.cs @@ -31,7 +31,7 @@ public class SyncCommandIntegration /// Type of the target /// Instance value, aka `this` of the instrumented method. /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance) + internal static CallTargetState OnMethodBegin(TTarget instance) { return new CallTargetState(AerospikeCommon.CreateScope(Tracer.Instance, instance)); } @@ -44,7 +44,7 @@ public static CallTargetState OnMethodBegin(TTarget instance) /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A default CallTargetReturn to satisfy the CallTarget contract - public static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return CallTargetReturn.GetDefault(); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ApiController_ExecuteAsync_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ApiController_ExecuteAsync_Integration.cs index 0baaf13bb..9c5b31b28 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ApiController_ExecuteAsync_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ApiController_ExecuteAsync_Integration.cs @@ -11,12 +11,9 @@ using System.Threading; using System.Web; using Datadog.Trace.ClrProfiler.CallTarget; -using Datadog.Trace.ClrProfiler.Emit; using Datadog.Trace.Configuration; using Datadog.Trace.DuckTyping; using Datadog.Trace.ExtensionMethods; -using Datadog.Trace.Headers; -using Datadog.Trace.Propagation; using Datadog.Trace.Tagging; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNet @@ -54,7 +51,7 @@ public class ApiController_ExecuteAsync_Integration /// The context of the controller /// The cancellation token /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TController controllerContext, CancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, TController controllerContext, CancellationToken cancellationToken) where TController : IHttpControllerContext { // Make sure to box the controllerContext proxy only once @@ -81,7 +78,7 @@ public static CallTargetState OnMethodBegin(TTarget instan /// Calltarget state value /// A response value, in an async scenario will be T of Task of T [PreserveContext] - public static TResponse OnAsyncMethodEnd(TTarget instance, TResponse responseMessage, Exception exception, CallTargetState state) + internal static TResponse OnAsyncMethodEnd(TTarget instance, TResponse responseMessage, Exception exception, CallTargetState state) { var scope = state.Scope; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/AspNetMvcIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/AspNetMvcIntegration.cs index 913edb5c0..9a8e49d02 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/AspNetMvcIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/AspNetMvcIntegration.cs @@ -8,7 +8,6 @@ #if NETFRAMEWORK using System; using System.Collections.Generic; -using System.ComponentModel; using System.Linq; using System.Web.Routing; using Datadog.Trace.AspNet; @@ -23,9 +22,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNet /// /// The ASP.NET MVC integration. /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public static class AspNetMvcIntegration + internal static class AspNetMvcIntegration { internal const string HttpContextKey = "__SignalFx.Tracing.ClrProfiler.Integrations.AspNetMvcIntegration"; @@ -41,7 +38,7 @@ public static class AspNetMvcIntegration /// /// The System.Web.Mvc.ControllerContext that was passed as an argument to the instrumented method. /// A new scope used to instrument an MVC action. - public static Scope CreateScope(ControllerContextStruct controllerContext) + internal static Scope CreateScope(ControllerContextStruct controllerContext) { Scope scope = null; @@ -138,7 +135,7 @@ public static Scope CreateScope(ControllerContextStruct controllerContext) var tracer = Tracer.Instance; var tagsFromHeaders = Enumerable.Empty>(); - if (tracer.ActiveScope == null) + if (tracer.InternalActiveScope == null) { try { @@ -155,7 +152,7 @@ public static Scope CreateScope(ControllerContextStruct controllerContext) } var tags = new AspNetTags(); - scope = Tracer.Instance.StartActiveWithTags(resourceName, propagatedContext, tags: tags); + scope = Tracer.Instance.StartActiveInternal(resourceName, propagatedContext, tags: tags); span = scope.Span; span.DecorateWebServerSpan( diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/AspNetWebApi2Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/AspNetWebApi2Integration.cs index 2584a4db6..77aa0b6f4 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/AspNetWebApi2Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/AspNetWebApi2Integration.cs @@ -8,7 +8,6 @@ #if NETFRAMEWORK using System; using System.Collections.Generic; -using System.ComponentModel; using System.Linq; using System.Web; using Datadog.Trace.AspNet; @@ -23,9 +22,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNet /// /// Contains instrumentation wrappers for ASP.NET Web API 5. /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public static class AspNetWebApi2Integration + internal static class AspNetWebApi2Integration { private const string OperationName = "aspnet-webapi.request"; @@ -50,7 +47,7 @@ internal static Scope CreateScope(IHttpControllerContext controllerContext, out SpanContext propagatedContext = null; var tagsFromHeaders = Enumerable.Empty>(); - if (request != null && tracer.ActiveScope == null) + if (request != null && tracer.InternalActiveScope == null) { try { @@ -68,7 +65,7 @@ internal static Scope CreateScope(IHttpControllerContext controllerContext, out } tags = new AspNetTags(); - scope = tracer.StartActiveWithTags(OperationName, propagatedContext, tags: tags); + scope = tracer.StartActiveInternal(OperationName, propagatedContext, tags: tags); UpdateSpan(controllerContext, scope.Span, tags, tagsFromHeaders); tags.SetAnalyticsSampleRate(IntegrationId, tracer.Settings, enabledWithGlobalSetting: true); @@ -147,10 +144,13 @@ internal static void UpdateSpan(IHttpControllerContext controllerContext, Span s span.LogicScope = OperationName; span.OperationName = resourceName; - tags.AspNetAction = action; - tags.AspNetController = controller; - tags.AspNetArea = area; - tags.AspNetRoute = route; + if (tags is not null) + { + tags.AspNetAction = action; + tags.AspNetController = controller; + tags.AspNetArea = area; + tags.AspNetRoute = route; + } // set the resource name in the HttpContext so TracingHttpModule can update root span var httpContext = System.Web.HttpContext.Current; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/AsyncControllerActionInvoker_BeginInvokeAction_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/AsyncControllerActionInvoker_BeginInvokeAction_Integration.cs index 45586724e..89176e85a 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/AsyncControllerActionInvoker_BeginInvokeAction_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/AsyncControllerActionInvoker_BeginInvokeAction_Integration.cs @@ -8,12 +8,9 @@ using System.ComponentModel; using System.Web; using Datadog.Trace.AppSec; -using Datadog.Trace.AppSec.Transport.Http; using Datadog.Trace.ClrProfiler.CallTarget; using Datadog.Trace.Configuration; using Datadog.Trace.DuckTyping; -using Datadog.Trace.Util; -using Datadog.Trace.Util.Http; using Datadog.Trace.Vendors.Serilog; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNet @@ -53,7 +50,7 @@ public class AsyncControllerActionInvoker_BeginInvokeAction_Integration /// Async callback /// The state of the method /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TContext controllerContext, string actionName, AsyncCallback callback, object state) + internal static CallTargetState OnMethodBegin(TTarget instance, TContext controllerContext, string actionName, AsyncCallback callback, object state) { Scope scope = null; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/AsyncControllerActionInvoker_EndInvokeAction_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/AsyncControllerActionInvoker_EndInvokeAction_Integration.cs index c65fe9f08..6a445db6b 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/AsyncControllerActionInvoker_EndInvokeAction_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/AsyncControllerActionInvoker_EndInvokeAction_Integration.cs @@ -49,7 +49,7 @@ public class AsyncControllerActionInvoker_EndInvokeAction_Integration /// Exception instance in case the original code threw an exception. /// Calltarget state value /// Return value of the method - public static CallTargetReturn OnMethodEnd(TTarget instance, TResult returnValue, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TResult returnValue, Exception exception, CallTargetState state) { Scope scope = null; var httpContext = HttpContext.Current; @@ -74,6 +74,7 @@ public static CallTargetReturn OnMethodEnd(TTarget in // We don't know how long it'll take for ASP.NET to invoke the callback, // so we store the real finish time. var now = scope.Span.Context.TraceContext.UtcNow; + httpContext.AddOnRequestCompleted(h => OnRequestCompleted(h, scope, now)); } else diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ControllerContextStruct.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ControllerContextStruct.cs index 3d498f7ca..9608116cb 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ControllerContextStruct.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ControllerContextStruct.cs @@ -4,7 +4,6 @@ // #if NETFRAMEWORK -using System.ComponentModel; using System.Web; using System.Web.Routing; using Datadog.Trace.DuckTyping; @@ -15,9 +14,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNet /// ControllerContext struct copy target for ducktyping /// [DuckCopy] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct ControllerContextStruct + internal struct ControllerContextStruct { /// /// Gets the HttpContext diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ExceptionHandlerExtensions_HandleAsync_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ExceptionHandlerExtensions_HandleAsync_Integration.cs index 2970c1435..2fb7923c0 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ExceptionHandlerExtensions_HandleAsync_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ExceptionHandlerExtensions_HandleAsync_Integration.cs @@ -44,7 +44,7 @@ public class ExceptionHandlerExtensions_HandleAsync_Integration /// The exception context value /// CancellationToken value /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TExceptionHandler handler, TExceptionContext context, CancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, TExceptionHandler handler, TExceptionContext context, CancellationToken cancellationToken) where TExceptionContext : IExceptionContext { var scope = Tracer.Instance.ActiveScope; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/HttpConfigurationStruct.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/HttpConfigurationStruct.cs index 578ef32b9..991030ff5 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/HttpConfigurationStruct.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/HttpConfigurationStruct.cs @@ -4,7 +4,6 @@ // using System.Collections; -using System.ComponentModel; using System.Reflection; using Datadog.Trace.DuckTyping; @@ -14,9 +13,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNet /// System.Web.Http.HttpConfiguration /// [DuckCopy] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct HttpConfigurationStruct + internal struct HttpConfigurationStruct { /// /// Gets the MessageHandlers collection diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/HttpHeadersCollection.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/HttpHeadersCollection.cs index c7e9a1902..0ce8e9dd5 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/HttpHeadersCollection.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/HttpHeadersCollection.cs @@ -4,10 +4,10 @@ // #if NETFRAMEWORK -using System; using System.Collections.Generic; using System.Linq; using Datadog.Trace.Headers; +using Datadog.Trace.Util; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNet { @@ -17,7 +17,12 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNet public HttpHeadersCollection(IRequestHeaders headers) { - _headers = headers ?? throw new ArgumentNullException(nameof(headers)); + if (headers is null) + { + ThrowHelper.ThrowArgumentNullException(nameof(headers)); + } + + _headers = headers; } public IEnumerable GetValues(string name) diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/HttpMethodStruct.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/HttpMethodStruct.cs index c704e96d4..79de02767 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/HttpMethodStruct.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/HttpMethodStruct.cs @@ -4,7 +4,6 @@ // #if NETFRAMEWORK -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNet @@ -13,9 +12,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNet /// Http method struct copy target for ducktyping /// [DuckCopy] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct HttpMethodStruct + internal struct HttpMethodStruct { /// /// Gets the http method in string diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/HttpModule_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/HttpModule_Integration.cs index 023bfcf47..8a23ebc27 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/HttpModule_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/HttpModule_Integration.cs @@ -46,7 +46,7 @@ public class HttpModule_Integration /// The methods to be invoked /// The function to set the environment culture /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TCollection methods, TFunc setHostingEnvironmentCultures) + internal static CallTargetState OnMethodBegin(TTarget instance, TCollection methods, TFunc setHostingEnvironmentCultures) { if (Interlocked.Exchange(ref _firstInitialization, 0) != 1) { diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IExceptionContext.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IExceptionContext.cs index c3ced5248..a00b65b1a 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IExceptionContext.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IExceptionContext.cs @@ -4,16 +4,13 @@ // using System; -using System.ComponentModel; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNet { /// /// System.Web.Http.ExceptionHandling.ExceptionContext interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IExceptionContext + internal interface IExceptionContext { /// /// Gets the exception diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IHttpContext.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IHttpContext.cs index 60554c4b0..dfda8c603 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IHttpContext.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IHttpContext.cs @@ -4,7 +4,6 @@ // using System.Collections; -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNet @@ -13,9 +12,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNet /// System.Web.HttpContext interface for ducktyping /// [DuckCopy] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct IHttpContext + internal struct IHttpContext { /// /// Gets the items dictionary diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IHttpControllerContext.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IHttpControllerContext.cs index b8b495ac5..a52b74b09 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IHttpControllerContext.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IHttpControllerContext.cs @@ -3,19 +3,13 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - #if NETFRAMEWORK -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNet { /// /// HttpControllerContext interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IHttpControllerContext + internal interface IHttpControllerContext { IHttpRequestMessage Request { get; } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IHttpRequestMessage.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IHttpRequestMessage.cs index 0e08ac5e5..e28ec5443 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IHttpRequestMessage.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IHttpRequestMessage.cs @@ -5,16 +5,13 @@ #if NETFRAMEWORK using System; -using System.ComponentModel; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNet { /// /// HttpRequestMessage interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IHttpRequestMessage + internal interface IHttpRequestMessage { /// /// Gets the Http Method diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IHttpRoute.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IHttpRoute.cs index 6f8c688a7..fcfb6ff38 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IHttpRoute.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IHttpRoute.cs @@ -3,19 +3,13 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - #if NETFRAMEWORK -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNet { /// /// IHttpRoute proxy for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IHttpRoute + internal interface IHttpRoute { string RouteTemplate { get; } } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IHttpRouteData.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IHttpRouteData.cs index ec4d41876..dde503ad9 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IHttpRouteData.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IHttpRouteData.cs @@ -4,19 +4,14 @@ // #if NETFRAMEWORK -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - using System.Collections.Generic; -using System.ComponentModel; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNet { /// /// IHttpRouteData interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IHttpRouteData + internal interface IHttpRouteData { IHttpRoute Route { get; } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IRequestHeaders.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IRequestHeaders.cs index e4b4e4e82..c706df8e8 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IRequestHeaders.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IRequestHeaders.cs @@ -5,22 +5,25 @@ #if NETFRAMEWORK using System.Collections.Generic; -using System.ComponentModel; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNet { /// /// RequestHeaders interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IRequestHeaders + internal interface IRequestHeaders { /// /// Gets the host from the HTTP request /// string Host { get; } + /// + /// Gets the useragent from the HTTP request. + /// Cast it as object as we only need to call ToString + /// + object UserAgent { get; } + /// /// Try get values from the headers /// diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IThreadContext.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IThreadContext.cs index 87ed6d889..38d2e9e27 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IThreadContext.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/IThreadContext.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNet { /// /// System.Web.HttpApplication interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IThreadContext + internal interface IThreadContext { /// /// Gets the HttpContext of the thread context diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ThreadContext_AssociateWithCurrentThread_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ThreadContext_AssociateWithCurrentThread_Integration.cs index cc4031afb..7d7788f4b 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ThreadContext_AssociateWithCurrentThread_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ThreadContext_AssociateWithCurrentThread_Integration.cs @@ -35,11 +35,11 @@ public class ThreadContext_AssociateWithCurrentThread_Integration /// Instance value, aka `this` of the instrumented method. /// A flag to set the impersonation context /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, bool setImpersonationContext) + internal static CallTargetState OnMethodBegin(TTarget instance, bool setImpersonationContext) where TTarget : IThreadContext { var httpContext = instance.HttpContext; - if (httpContext.Items[HttpContextScopeKey] is Scope scope && ((IDatadogTracer)Tracer.Instance).ScopeManager is IScopeRawAccess rawAccess) + if (httpContext.Items[HttpContextScopeKey] is Scope scope && Tracer.Instance.ScopeManager is IScopeRawAccess rawAccess) { rawAccess.Active = scope; } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ThreadContext_DisassociateFromCurrentThread_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ThreadContext_DisassociateFromCurrentThread_Integration.cs index b17cf5591..d39cc932a 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ThreadContext_DisassociateFromCurrentThread_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ThreadContext_DisassociateFromCurrentThread_Integration.cs @@ -33,10 +33,10 @@ public class ThreadContext_DisassociateFromCurrentThread_Integration /// Type of the target /// Instance value, aka `this` of the instrumented method. /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance) + internal static CallTargetState OnMethodBegin(TTarget instance) where TTarget : IThreadContext { - if (((IDatadogTracer)Tracer.Instance).ScopeManager is IScopeRawAccess rawAccess) + if (Tracer.Instance.ScopeManager is IScopeRawAccess rawAccess) { rawAccess.Active = null; } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/AzureFunctionsCommon.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/AzureFunctionsCommon.cs index bb224fe30..d946d9540 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/AzureFunctionsCommon.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/AzureFunctionsCommon.cs @@ -5,7 +5,6 @@ #if !NETFRAMEWORK using System; -using Datadog.Trace.AppSec; using Datadog.Trace.ClrProfiler.CallTarget; using Datadog.Trace.Configuration; using Datadog.Trace.Logging; @@ -126,15 +125,15 @@ internal static Scope CreateScope(Tracer tracer, IFunctionInstance instanceParam BindingSource = bindingSourceType.FullName }; - if (tracer.ActiveScope == null) + if (tracer.InternalActiveScope == null) { // This is the root scope tags.SetAnalyticsSampleRate(IntegrationId, tracer.Settings, enabledWithGlobalSetting: false); - scope = tracer.StartActiveWithTags(OperationName, tags: tags); + scope = tracer.StartActiveInternal(OperationName, tags: tags); } else { - scope = tracer.StartActive(OperationName); + scope = tracer.StartActiveInternal(OperationName); foreach (var tagProperty in AzureFunctionsTags.AzureFunctionsExtraTags) { scope.Root.Span.SetTag(tagProperty.Key, tagProperty.Getter(tags)); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/AzureFunctionsExecutionReason.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/AzureFunctionsExecutionReason.cs index fd9bbd78f..ba6fae5ac 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/AzureFunctionsExecutionReason.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/AzureFunctionsExecutionReason.cs @@ -3,17 +3,13 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - #if !NETFRAMEWORK namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Azure.Functions { /// /// Enum for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public enum AzureFunctionsExecutionReason + internal enum AzureFunctionsExecutionReason { /// Indicates a function executed because of an automatic trigger. AutomaticTrigger, diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/AzureFunctionsExecutorTryExecuteAsyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/AzureFunctionsExecutorTryExecuteAsyncIntegration.cs index e5ca4a997..c71f215ec 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/AzureFunctionsExecutorTryExecuteAsyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/AzureFunctionsExecutorTryExecuteAsyncIntegration.cs @@ -8,7 +8,6 @@ using System.ComponentModel; using System.Threading; using Datadog.Trace.ClrProfiler.CallTarget; -using Datadog.Trace.Configuration; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Azure.Functions { @@ -37,7 +36,7 @@ public class AzureFunctionsExecutorTryExecuteAsyncIntegration /// First argument /// Second argument /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TFunction functionInstance, CancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, TFunction functionInstance, CancellationToken cancellationToken) where TFunction : IFunctionInstance { return AzureFunctionsCommon.OnFunctionExecutionBegin(instance, functionInstance); @@ -53,7 +52,7 @@ public static CallTargetState OnMethodBegin(TTarget instance /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { state.Scope?.DisposeWithException(exception); return returnValue; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/FunctionInvocationMiddlewareInvokeIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/FunctionInvocationMiddlewareInvokeIntegration.cs index 92768c936..f7ff44815 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/FunctionInvocationMiddlewareInvokeIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/FunctionInvocationMiddlewareInvokeIntegration.cs @@ -6,7 +6,6 @@ #if !NETFRAMEWORK using System; using System.ComponentModel; -using System.Threading; using Datadog.Trace.ClrProfiler.CallTarget; using Microsoft.AspNetCore.Http; @@ -35,7 +34,7 @@ public class FunctionInvocationMiddlewareInvokeIntegration /// Instance value, aka `this` of the instrumented method. /// First argument /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, HttpContext httpContext) + internal static CallTargetState OnMethodBegin(TTarget instance, HttpContext httpContext) { return AzureFunctionsCommon.OnFunctionMiddlewareBegin(instance, httpContext); } @@ -50,7 +49,7 @@ public static CallTargetState OnMethodBegin(TTarget instance, HttpConte /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { state.Scope?.DisposeWithException(exception); return returnValue; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/IFunctionDescriptor.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/IFunctionDescriptor.cs index b9ef0b38e..f42a8405e 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/IFunctionDescriptor.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/IFunctionDescriptor.cs @@ -3,17 +3,13 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - #if !NETFRAMEWORK namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Azure.Functions { /// /// For duck typing /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IFunctionDescriptor + internal interface IFunctionDescriptor { /// Gets the ID of the function. string Id { get; } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/IFunctionInstance.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/IFunctionInstance.cs index 8f2447369..cb39d760a 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/IFunctionInstance.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/IFunctionInstance.cs @@ -6,16 +6,13 @@ #if !NETFRAMEWORK using System; using System.Collections.Generic; -using System.ComponentModel; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Azure.Functions { /// /// For duck typing /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IFunctionInstance + internal interface IFunctionInstance { /// /// Gets Function unique id diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/ClientQueryIteratorsIntegrations.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/ClientQueryIteratorsIntegrations.cs index 88ef41685..eebfd1afb 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/ClientQueryIteratorsIntegrations.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/ClientQueryIteratorsIntegrations.cs @@ -65,7 +65,7 @@ public class ClientQueryIteratorsIntegrations /// Cancellation token /// Query request options /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TQueryDefinition queryDefinition, string cancellationToken, TQueryRequestOptions queryRequestOptions) + internal static CallTargetState OnMethodBegin(TTarget instance, TQueryDefinition queryDefinition, string cancellationToken, TQueryRequestOptions queryRequestOptions) { return CosmosCommon.CreateClientCallStateExt(instance, queryDefinition); } @@ -80,7 +80,7 @@ public static CallTargetState OnMethodBeginException instance in case the original code threw an exception. /// Calltarget state value /// A response value - public static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { state.Scope?.DisposeWithException(exception); return new CallTargetReturn(returnValue); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/ContainerNewStruct.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/ContainerNewStruct.cs index 2363f00fb..9e0bec11b 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/ContainerNewStruct.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/ContainerNewStruct.cs @@ -3,13 +3,7 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.CosmosDb @@ -18,9 +12,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.CosmosDb /// Microsoft.Azure.Cosmos.Container for duck typing /// [DuckCopy] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct ContainerNewStruct + internal struct ContainerNewStruct { /// /// Gets the Id of the Cosmos container diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/ContainerOldStruct.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/ContainerOldStruct.cs index 02c60cbda..b6299682c 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/ContainerOldStruct.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/ContainerOldStruct.cs @@ -3,13 +3,7 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.CosmosDb @@ -18,9 +12,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.CosmosDb /// Microsoft.Azure.Cosmos.Container for duck typing /// [DuckCopy] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct ContainerOldStruct + internal struct ContainerOldStruct { /// /// Gets the Id of the Cosmos container diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/ContainerQueryIteratorsIntegrations.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/ContainerQueryIteratorsIntegrations.cs index ff3be3997..ef554893f 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/ContainerQueryIteratorsIntegrations.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/ContainerQueryIteratorsIntegrations.cs @@ -66,7 +66,7 @@ public class ContainerQueryIteratorsIntegrations /// Cancellation token /// Query request options /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TQueryDefinition queryDefinition, string cancellationToken, TQueryRequestOptions queryRequestOptions) + internal static CallTargetState OnMethodBegin(TTarget instance, TQueryDefinition queryDefinition, string cancellationToken, TQueryRequestOptions queryRequestOptions) { return CosmosCommon.CreateContainerCallStateExt(instance, queryDefinition); } @@ -81,7 +81,7 @@ public static CallTargetState OnMethodBeginException instance in case the original code threw an exception. /// Calltarget state value /// A response value - public static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { state.Scope?.DisposeWithException(exception); return new CallTargetReturn(returnValue); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/CosmosClientStruct.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/CosmosClientStruct.cs index 889f476fe..4dc90e46d 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/CosmosClientStruct.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/CosmosClientStruct.cs @@ -4,12 +4,7 @@ // using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.CosmosDb @@ -18,9 +13,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.CosmosDb /// Microsoft.Azure.Cosmos.CosmosClient /// [DuckCopy] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct CosmosClientStruct + internal struct CosmosClientStruct { /// /// Gets the endpoint Uri for the Azure Cosmos DB service. diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/CosmosCommon.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/CosmosCommon.cs index d56f0c6a0..a9c46dd95 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/CosmosCommon.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/CosmosCommon.cs @@ -96,7 +96,7 @@ private static CallTargetState CreateCosmosDbCallState -using System.ComponentModel; using System.Reflection; using Datadog.Trace.DuckTyping; @@ -13,9 +12,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.CosmosDb /// Microsoft.Azure.Cosmos.CosmosClientContext for duck typing /// [DuckCopy] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct CosmosContextClientStruct + internal struct CosmosContextClientStruct { /// /// Gets the CosmosClient diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/DatabaseNewStruct.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/DatabaseNewStruct.cs index 67129ab12..98fea7ad1 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/DatabaseNewStruct.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/DatabaseNewStruct.cs @@ -3,13 +3,7 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.CosmosDb @@ -18,9 +12,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.CosmosDb /// Microsoft.Azure.Cosmos.Database for duct typing /// [DuckCopy] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct DatabaseNewStruct + internal struct DatabaseNewStruct { /// /// Gets the Id of the Cosmos database diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/DatabaseOldStruct.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/DatabaseOldStruct.cs index 59550a997..2f2ae2304 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/DatabaseOldStruct.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/DatabaseOldStruct.cs @@ -3,13 +3,7 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.CosmosDb @@ -18,9 +12,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.CosmosDb /// Microsoft.Azure.Cosmos.Database for duct typing /// [DuckCopy] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct DatabaseOldStruct + internal struct DatabaseOldStruct { /// /// Gets the Id of the Cosmos database diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/DatabaseQueryIteratorsIntegrations.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/DatabaseQueryIteratorsIntegrations.cs index 7187e2cca..671800dd0 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/DatabaseQueryIteratorsIntegrations.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/DatabaseQueryIteratorsIntegrations.cs @@ -86,7 +86,7 @@ public class DatabaseQueryIteratorsIntegrations /// Cancellation token /// Query request options /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TQueryDefinition queryDefinition, string cancellationToken, TQueryRequestOptions queryRequestOptions) + internal static CallTargetState OnMethodBegin(TTarget instance, TQueryDefinition queryDefinition, string cancellationToken, TQueryRequestOptions queryRequestOptions) { return CosmosCommon.CreateDatabaseCallStateExt(instance, queryDefinition); } @@ -101,7 +101,7 @@ public static CallTargetState OnMethodBeginException instance in case the original code threw an exception. /// Calltarget state value /// A response value - public static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { state.Scope?.DisposeWithException(exception); return new CallTargetReturn(returnValue); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/QueryDefinitionStruct.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/QueryDefinitionStruct.cs index 66425e36b..b6afdf45a 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/QueryDefinitionStruct.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/CosmosDb/QueryDefinitionStruct.cs @@ -3,13 +3,7 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.CosmosDb @@ -18,9 +12,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.CosmosDb /// Microsoft.Azure.Cosmos.QueryDefinition for duck typing /// [DuckCopy] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct QueryDefinitionStruct + internal struct QueryDefinitionStruct { /// /// Gets the text of the Azure Cosmos DB SQL query. diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/ClusterNodeIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/ClusterNodeIntegration.cs index 4581b6a2d..61f07f32c 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/ClusterNodeIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/ClusterNodeIntegration.cs @@ -63,7 +63,7 @@ public class ClusterNodeIntegration /// Type of the operation /// Type of the cancellationToken /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TOperation operation, TCancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, TOperation operation, TCancellationToken cancellationToken) { return CouchbaseCommon.CommonOnMethodBeginV3(operation); } @@ -78,7 +78,7 @@ public static CallTargetState OnMethodBeginException instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { return CouchbaseCommon.CommonOnMethodEnd(returnValue, exception, state); } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/ClusterNodeIntegrationBis.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/ClusterNodeIntegrationBis.cs index 738565ae6..bc01dc618 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/ClusterNodeIntegrationBis.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/ClusterNodeIntegrationBis.cs @@ -47,7 +47,7 @@ public class ClusterNodeIntegrationBis /// Type of the connection /// Type of the cancellationToken /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TConnection connection, TOperation operation, TCancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, TConnection connection, TOperation operation, TCancellationToken cancellationToken) { return CouchbaseCommon.CommonOnMethodBeginV3(operation); } @@ -62,7 +62,7 @@ public static CallTargetState OnMethodBeginException instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { return CouchbaseCommon.CommonOnMethodEnd(returnValue, exception, state); } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/ClusterNodeIntegrationTer.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/ClusterNodeIntegrationTer.cs index b464b50f5..1677052f1 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/ClusterNodeIntegrationTer.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/ClusterNodeIntegrationTer.cs @@ -43,7 +43,7 @@ public class ClusterNodeIntegrationTer /// Type of the target /// Type of the operation /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TOperation operation) + internal static CallTargetState OnMethodBegin(TTarget instance, TOperation operation) { return CouchbaseCommon.CommonOnMethodBeginV3(operation); } @@ -58,7 +58,7 @@ public static CallTargetState OnMethodBegin(TTarget instanc /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { return CouchbaseCommon.CommonOnMethodEnd(returnValue, exception, state); } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/CouchbaseCommon.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/CouchbaseCommon.cs index f91579404..8a75b89c8 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/CouchbaseCommon.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/CouchbaseCommon.cs @@ -85,7 +85,7 @@ private static CallTargetState CommonOnMethodBegin(CouchbaseTags tags) { var tracer = Tracer.Instance; var serviceName = tracer.Settings.GetServiceName(tracer, ServiceName); - var scope = tracer.StartActiveWithTags(OperationName, serviceName: serviceName, tags: tags); + var scope = tracer.StartActiveInternal(OperationName, serviceName: serviceName, tags: tags); scope.Span.Type = SpanTypes.Db; scope.Span.ResourceName = tags.OperationCode; return new CallTargetState(scope); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/IIOServiceExecuteAsyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/IIOServiceExecuteAsyncIntegration.cs index 20256bcd9..a783b04f1 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/IIOServiceExecuteAsyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/IIOServiceExecuteAsyncIntegration.cs @@ -6,9 +6,6 @@ using System; using System.ComponentModel; using Datadog.Trace.ClrProfiler.CallTarget; -using Datadog.Trace.Configuration; -using Datadog.Trace.Logging; -using Datadog.Trace.Tagging; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Couchbase { @@ -82,7 +79,7 @@ public class IIOServiceExecuteAsyncIntegration /// Type of the target /// Type of the operation /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TOperation operation) + internal static CallTargetState OnMethodBegin(TTarget instance, TOperation operation) { return CouchbaseCommon.CommonOnMethodBegin(operation); } @@ -97,7 +94,7 @@ public static CallTargetState OnMethodBegin(TTarget instanc /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { return CouchbaseCommon.CommonOnMethodEnd(returnValue, exception, state); } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/IIOServiceExecuteAsyncIntegrationBis.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/IIOServiceExecuteAsyncIntegrationBis.cs index 13a4f69c1..0757b5706 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/IIOServiceExecuteAsyncIntegrationBis.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/IIOServiceExecuteAsyncIntegrationBis.cs @@ -54,7 +54,7 @@ public class IIOServiceExecuteAsyncIntegrationBis /// Type of the operation /// Type of the connection /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TOperation operation, TConnection connection) + internal static CallTargetState OnMethodBegin(TTarget instance, TOperation operation, TConnection connection) { return CouchbaseCommon.CommonOnMethodBegin(operation); } @@ -69,7 +69,7 @@ public static CallTargetState OnMethodBegin(TT /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { return CouchbaseCommon.CommonOnMethodEnd(returnValue, exception, state); } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/IIOServiceExecuteIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/IIOServiceExecuteIntegration.cs index 01c29c957..6a07bb358 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/IIOServiceExecuteIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/IIOServiceExecuteIntegration.cs @@ -6,9 +6,6 @@ using System; using System.ComponentModel; using Datadog.Trace.ClrProfiler.CallTarget; -using Datadog.Trace.Configuration; -using Datadog.Trace.DuckTyping; -using Datadog.Trace.Logging; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Couchbase { @@ -82,7 +79,7 @@ public class IIOServiceExecuteIntegration /// Type of the target /// Type of the operation /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TOperation operation) + internal static CallTargetState OnMethodBegin(TTarget instance, TOperation operation) { return CouchbaseCommon.CommonOnMethodBegin(operation); } @@ -97,7 +94,7 @@ public static CallTargetState OnMethodBegin(TTarget instanc /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TOperationResult tResult, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TOperationResult tResult, Exception exception, CallTargetState state) { return CouchbaseCommon.CommonOnMethodEndSync(tResult, exception, state); } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/IIOServiceExecuteIntegrationBis.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/IIOServiceExecuteIntegrationBis.cs index c5685388d..f123d6719 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/IIOServiceExecuteIntegrationBis.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/IIOServiceExecuteIntegrationBis.cs @@ -6,7 +6,6 @@ using System; using System.ComponentModel; using Datadog.Trace.ClrProfiler.CallTarget; -using Datadog.Trace.Logging; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Couchbase { @@ -55,7 +54,7 @@ public class IIOServiceExecuteIntegrationBis /// Type of the operation /// Type of the connection /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TOperation operation, TConnection connection) + internal static CallTargetState OnMethodBegin(TTarget instance, TOperation operation, TConnection connection) { return CouchbaseCommon.CommonOnMethodBegin(operation); } @@ -70,7 +69,7 @@ public static CallTargetState OnMethodBegin(TT /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TOperationResult result, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TOperationResult result, Exception exception, CallTargetState state) { return CouchbaseCommon.CommonOnMethodEndSync(result, exception, state); } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/OperationCode.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/OperationCode.cs index b5bd5a3c5..6e0828772 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/OperationCode.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/OperationCode.cs @@ -3,18 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -#pragma warning disable SA1602 // Enumeration items should be documented namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Couchbase { /// /// Couchbase OperationCode copy /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public enum OperationCode : byte + internal enum OperationCode : byte { Get = 0x00, Set = 0x01, diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/OperationStruct.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/OperationStruct.cs index 9fd5b3c25..450827ab4 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/OperationStruct.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/OperationStruct.cs @@ -3,7 +3,6 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; using System.Net; using Datadog.Trace.DuckTyping; @@ -13,9 +12,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Couchbase /// Ducktyping of Couchbase.IO.Operations.IOperation and generic implementations /// [DuckCopy] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct OperationStruct + internal struct OperationStruct { /// /// Gets the Operation Code diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/OperationStructV3.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/OperationStructV3.cs index 2c73ffb15..a4f8c4fc9 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/OperationStructV3.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/OperationStructV3.cs @@ -3,7 +3,6 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Couchbase @@ -12,9 +11,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Couchbase /// Ducktyping of Couchbase.Core.Operations.IOperation in V3 /// [DuckCopy] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct OperationStructV3 + internal struct OperationStructV3 { /// /// Gets the Operation Code diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/ResultStruct.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/ResultStruct.cs index 178861238..29e5c608e 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/ResultStruct.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Couchbase/ResultStruct.cs @@ -3,11 +3,7 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -#pragma warning disable SA1600 // Elements should be documented - using System; -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Couchbase @@ -16,9 +12,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Couchbase /// Ducktyping of Couchbase.IResult and generic implementations /// [DuckCopy] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct ResultStruct + internal struct ResultStruct { /// /// Gets a value indicating whether the operation was succesful. diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/ElasticsearchNetCommon.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/ElasticsearchNetCommon.cs index 8d9be1122..5c9cd87d7 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/ElasticsearchNetCommon.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/ElasticsearchNetCommon.cs @@ -63,7 +63,7 @@ public static Scope CreateScope(Tracer tracer, IntegrationId integrationId, stri try { var operationName = requestName ?? OperationName; - scope = tracer.StartActiveWithTags(operationName, serviceName: serviceName, tags: tags); + scope = tracer.StartActiveInternal(operationName, serviceName: serviceName, tags: tags); var span = scope.Span; span.LogicScope = OperationName; span.ResourceName = requestName ?? path ?? string.Empty; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/HttpMethod.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/HttpMethod.cs index 2af5962a8..bd467444c 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/HttpMethod.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/HttpMethod.cs @@ -3,18 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -#pragma warning disable SA1602 // Enumeration items should be documented namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Elasticsearch { /// /// HTTP method /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public enum HttpMethod + internal enum HttpMethod { GET, POST, diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/IRequestData.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/IRequestData.cs index adb09a874..c40a6cf00 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/IRequestData.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/IRequestData.cs @@ -4,16 +4,13 @@ // using System; -using System.ComponentModel; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Elasticsearch { /// /// Version-agnostic interface for Elasticsearch RequestData /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IRequestData + internal interface IRequestData { /// /// Gets the path of the request diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/RequestPipelineStruct.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/RequestPipelineStruct.cs index 552dba2ed..950c89239 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/RequestPipelineStruct.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/RequestPipelineStruct.cs @@ -3,10 +3,6 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -#pragma warning disable SA1600 // Elements should be documented - -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Elasticsearch @@ -15,9 +11,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Elasticsearch /// Duck-copy struct for RequestPipeline /// [DuckCopy] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct RequestPipelineStruct + internal struct RequestPipelineStruct { public object RequestParameters; } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V5/RequestDataV5.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V5/RequestDataV5.cs index 1a45edfd6..4f912e9f8 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V5/RequestDataV5.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V5/RequestDataV5.cs @@ -3,10 +3,7 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -#pragma warning disable SA1600 // Elements should be documented using System; -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Elasticsearch.V5 @@ -14,9 +11,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Elasticsearch.V5 /// /// Duck-copy struct for RequestData /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct RequestDataV5 : IRequestData + internal struct RequestDataV5 : IRequestData { private Proxy _data; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V5/RequestPipeline_CallElasticsearchAsync_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V5/RequestPipeline_CallElasticsearchAsync_Integration.cs index 6b612221f..49e0c62de 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V5/RequestPipeline_CallElasticsearchAsync_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V5/RequestPipeline_CallElasticsearchAsync_Integration.cs @@ -37,7 +37,7 @@ public class RequestPipeline_CallElasticsearchAsync_Integration /// The request data /// The cancellation token /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TRequestData requestData, CancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, TRequestData requestData, CancellationToken cancellationToken) { var scope = ElasticsearchNetCommon.CreateScope(Tracer.Instance, ElasticsearchV5Constants.IntegrationId, instance.DuckCast(), new RequestDataV5(requestData)); @@ -54,7 +54,7 @@ public static CallTargetState OnMethodBegin(TTarget insta /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TExecutionResult OnAsyncMethodEnd(TTarget instance, TExecutionResult executionResult, Exception exception, CallTargetState state) + internal static TExecutionResult OnAsyncMethodEnd(TTarget instance, TExecutionResult executionResult, Exception exception, CallTargetState state) { state.Scope.SetDbStatementFromRequestData(state.State); state.Scope.DisposeWithException(exception); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V5/RequestPipeline_CallElasticsearch_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V5/RequestPipeline_CallElasticsearch_Integration.cs index 6b5293ee1..047e5982e 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V5/RequestPipeline_CallElasticsearch_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V5/RequestPipeline_CallElasticsearch_Integration.cs @@ -35,7 +35,7 @@ public class RequestPipeline_CallElasticsearch_Integration /// Instance value, aka `this` of the instrumented method. /// The request data /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TRequestData requestData) + internal static CallTargetState OnMethodBegin(TTarget instance, TRequestData requestData) { var scope = ElasticsearchNetCommon.CreateScope(Tracer.Instance, ElasticsearchV5Constants.IntegrationId, instance.DuckCast(), new RequestDataV5(requestData)); @@ -52,7 +52,7 @@ public static CallTargetState OnMethodBegin(TTarget insta /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) { state.Scope.SetDbStatementFromRequestData(state.State); state.Scope.DisposeWithException(exception); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V6/RequestDataV6.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V6/RequestDataV6.cs index eea179029..7f721f36b 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V6/RequestDataV6.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V6/RequestDataV6.cs @@ -3,10 +3,7 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -#pragma warning disable SA1600 // Elements should be documented using System; -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Elasticsearch.V6 @@ -14,9 +11,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Elasticsearch.V6 /// /// Duck-copy struct for RequestData /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct RequestDataV6 : IRequestData + internal struct RequestDataV6 : IRequestData { private Proxy _data; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V6/RequestPipeline_CallElasticsearchAsync_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V6/RequestPipeline_CallElasticsearchAsync_Integration.cs index 99360c11e..acfdca8ff 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V6/RequestPipeline_CallElasticsearchAsync_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V6/RequestPipeline_CallElasticsearchAsync_Integration.cs @@ -37,7 +37,7 @@ public class RequestPipeline_CallElasticsearchAsync_Integration /// The request data /// The cancellation token /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TRequestData requestData, CancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, TRequestData requestData, CancellationToken cancellationToken) { var scope = ElasticsearchNetCommon.CreateScope(Tracer.Instance, ElasticsearchV6Constants.IntegrationId, instance.DuckCast(), new RequestDataV6(requestData)); @@ -54,7 +54,7 @@ public static CallTargetState OnMethodBegin(TTarget insta /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TExecutionResult OnAsyncMethodEnd(TTarget instance, TExecutionResult executionResult, Exception exception, CallTargetState state) + internal static TExecutionResult OnAsyncMethodEnd(TTarget instance, TExecutionResult executionResult, Exception exception, CallTargetState state) { state.Scope.SetDbStatementFromRequestData(state.State); state.Scope.DisposeWithException(exception); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V6/RequestPipeline_CallElasticsearch_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V6/RequestPipeline_CallElasticsearch_Integration.cs index 8a0ab0a72..2ac27cb92 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V6/RequestPipeline_CallElasticsearch_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V6/RequestPipeline_CallElasticsearch_Integration.cs @@ -35,7 +35,7 @@ public class RequestPipeline_CallElasticsearch_Integration /// Instance value, aka `this` of the instrumented method. /// The request data /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TRequestData requestData) + internal static CallTargetState OnMethodBegin(TTarget instance, TRequestData requestData) { var scope = ElasticsearchNetCommon.CreateScope(Tracer.Instance, ElasticsearchV6Constants.IntegrationId, instance.DuckCast(), new RequestDataV6(requestData)); @@ -52,7 +52,7 @@ public static CallTargetState OnMethodBegin(TTarget insta /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) { state.Scope.SetDbStatementFromRequestData(state.State); state.Scope.DisposeWithException(exception); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V7/IApiCallDetails.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V7/IApiCallDetails.cs index 0dc0efe32..2a8df49cc 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V7/IApiCallDetails.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V7/IApiCallDetails.cs @@ -3,17 +3,11 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -#pragma warning disable SA1600 // Elements should be documented - using System; -using System.ComponentModel; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Elasticsearch.V7 { - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IApiCallDetails + internal interface IApiCallDetails { public Uri Uri { get; } } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V7/IElasticsearchResponse.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V7/IElasticsearchResponse.cs index ae35b460f..126d782ff 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V7/IElasticsearchResponse.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V7/IElasticsearchResponse.cs @@ -3,16 +3,9 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -#pragma warning disable SA1600 // Elements should be documented - -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Elasticsearch.V7 { - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IElasticsearchResponse + internal interface IElasticsearchResponse { IApiCallDetails ApiCall { get; } } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V7/Transport_RequestAsync_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V7/Transport_RequestAsync_Integration.cs index dbfd15692..7062fd675 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V7/Transport_RequestAsync_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V7/Transport_RequestAsync_Integration.cs @@ -41,7 +41,7 @@ public class Transport_RequestAsync_Integration /// The payload of the request /// The parameters of the request /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, THttpMethod method, string path, CancellationToken cancellationToken, TPostData postData, TRequestParameters requestParameters) + internal static CallTargetState OnMethodBegin(TTarget instance, THttpMethod method, string path, CancellationToken cancellationToken, TPostData postData, TRequestParameters requestParameters) { var scope = ElasticsearchNetCommon.CreateScope(Tracer.Instance, ElasticsearchV7Constants.IntegrationId, path, method.ToString(), requestParameters, out var tags); @@ -58,7 +58,7 @@ public static CallTargetState OnMethodBeginException instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TResponse OnAsyncMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) + internal static TResponse OnAsyncMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) where TResponse : IElasticsearchResponse { var uri = response?.ApiCall?.Uri?.ToString(); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V7/Transport_Request_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V7/Transport_Request_Integration.cs index bb7845e83..ca8e411a5 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V7/Transport_Request_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Elasticsearch/V7/Transport_Request_Integration.cs @@ -39,7 +39,7 @@ public class Transport_Request_Integration /// The payload of the request /// The parameters of the request /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, THttpMethod method, string path, TPostData postData, TRequestParameters requestParameters) + internal static CallTargetState OnMethodBegin(TTarget instance, THttpMethod method, string path, TPostData postData, TRequestParameters requestParameters) { var scope = ElasticsearchNetCommon.CreateScope(Tracer.Instance, ElasticsearchV7Constants.IntegrationId, path, method.ToString(), requestParameters, out var tags); @@ -56,7 +56,7 @@ public static CallTargetState OnMethodBeginException instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) where TResponse : IElasticsearchResponse { var uri = response?.ApiCall?.Uri?.ToString(); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/ErrorLocationStruct.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/ErrorLocationStruct.cs index 3bb406399..2416aefea 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/ErrorLocationStruct.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/ErrorLocationStruct.cs @@ -3,7 +3,6 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.GraphQL @@ -12,9 +11,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.GraphQL /// GraphQL.ErrorLocation interface for ducktyping /// [DuckCopy] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct ErrorLocationStruct + internal struct ErrorLocationStruct { /// /// Gets the line number of the document where the error occurred diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/ExecuteAsyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/ExecuteAsyncIntegration.cs index b58a270a2..b877b765c 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/ExecuteAsyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/ExecuteAsyncIntegration.cs @@ -41,7 +41,7 @@ public class ExecuteAsyncIntegration /// Instance value, aka `this` of the instrumented method. /// The execution context of the GraphQL operation. /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TContext context) + internal static CallTargetState OnMethodBegin(TTarget instance, TContext context) where TContext : IExecutionContext { return new CallTargetState(scope: GraphQLCommon.CreateScopeFromExecuteAsync(Tracer.Instance, context), state: context); @@ -57,7 +57,7 @@ public static CallTargetState OnMethodBegin(TTarget instance, /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TExecutionResult OnAsyncMethodEnd(TTarget instance, TExecutionResult executionResult, Exception exception, CallTargetState state) + internal static TExecutionResult OnAsyncMethodEnd(TTarget instance, TExecutionResult executionResult, Exception exception, CallTargetState state) { Scope scope = state.Scope; if (state.Scope is null) diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/GraphQLCommon.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/GraphQLCommon.cs index ff7658c9a..54bf2d592 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/GraphQLCommon.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/GraphQLCommon.cs @@ -45,7 +45,7 @@ internal static Scope CreateScopeFromValidate(Tracer tracer, IDocument document) try { var tags = new GraphQLTags(); - scope = tracer.StartActiveWithTags(ValidateOperationName, tags: tags); + scope = tracer.StartActiveInternal(ValidateOperationName, tags: tags); var span = scope.Span; span.LogicScope = ValidateOperationName; @@ -82,7 +82,7 @@ internal static Scope CreateScopeFromExecuteAsync(Tracer tracer, IExecutionConte : $"{operationType} {operationName}"; var tags = new GraphQLTags(); - scope = tracer.StartActiveWithTags(operation, tags: tags); + scope = tracer.StartActiveInternal(operation, tags: tags); var span = scope.Span; span.Type = SpanTypes.GraphQL; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/GraphQLExecuteAsyncAttribute.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/GraphQLExecuteAsyncAttribute.cs index 0a5b8bc65..e808f67d3 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/GraphQLExecuteAsyncAttribute.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/GraphQLExecuteAsyncAttribute.cs @@ -3,12 +3,6 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.GraphQL { internal class GraphQLExecuteAsyncAttribute : InstrumentMethodAttribute diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IDocument.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IDocument.cs index b9c6b40b0..3e7585056 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IDocument.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IDocument.cs @@ -3,21 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.GraphQL { /// /// GraphQL.Language.AST.Document interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IDocument + internal interface IDocument { /// /// Gets the original query from the document diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IExecutionContext.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IExecutionContext.cs index 721a75204..9916363e0 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IExecutionContext.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IExecutionContext.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.GraphQL { /// /// GraphQL.Execution.ExecutionContext interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IExecutionContext + internal interface IExecutionContext { /// /// Gets the document associated with the execution context diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IExecutionError.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IExecutionError.cs index f189118d3..a221bfa0a 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IExecutionError.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IExecutionError.cs @@ -4,16 +4,13 @@ // using System.Collections; -using System.ComponentModel; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.GraphQL { /// /// GraphQL.ExecutionError interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IExecutionError + internal interface IExecutionError { /// /// Gets a code for the error diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IExecutionErrors.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IExecutionErrors.cs index 692b08a33..918f60ab4 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IExecutionErrors.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IExecutionErrors.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.GraphQL { /// /// GraphQL.ExecutionErrors interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IExecutionErrors + internal interface IExecutionErrors { /// /// Gets the number of errors diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IOperation.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IOperation.cs index fd262c71d..ea6be2ca7 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IOperation.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IOperation.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.GraphQL { /// /// GraphQL.Language.AST.Operation interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IOperation + internal interface IOperation { /// /// Gets the name of the operation diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IValidationResult.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IValidationResult.cs index 3a625292d..100266079 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IValidationResult.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IValidationResult.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.GraphQL { /// /// GraphQL.Validation.IValidationResult interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IValidationResult + internal interface IValidationResult { /// /// Gets the execution errors diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IValidationResultTuple.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IValidationResultTuple.cs index 0291577dc..1a8f68891 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IValidationResultTuple.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/IValidationResultTuple.cs @@ -3,10 +3,6 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -#pragma warning disable SA1600 // Elements should be documented -#pragma warning disable 1591 - -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.GraphQL @@ -14,9 +10,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.GraphQL /// /// ValueTuple returned by DocumentValidator in GraphQL4 /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IValidationResultTuple + internal interface IValidationResultTuple { [DuckField] public IValidationResult Item1 { get; } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/OperationTypeProxy.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/OperationTypeProxy.cs index 75f365bde..b00aef83c 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/OperationTypeProxy.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/OperationTypeProxy.cs @@ -3,13 +3,6 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.GraphQL { /// @@ -18,9 +11,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.GraphQL /// to be decorated with the correct operation. Since the original type is public, /// we not expect changes between minor versions of the GraphQL library. /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public enum OperationTypeProxy + internal enum OperationTypeProxy { /// /// A query operation. diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/ValidateAsync4Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/ValidateAsync4Integration.cs index 9929a2646..8f0335028 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/ValidateAsync4Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/ValidateAsync4Integration.cs @@ -45,7 +45,7 @@ public class ValidateAsync4Integration /// The user context /// The input variables /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TSchema schema, TDocument document, TVariables variables, TRules rules, TUserContext userContext, TInputs inputs) + internal static CallTargetState OnMethodBegin(TTarget instance, TSchema schema, TDocument document, TVariables variables, TRules rules, TUserContext userContext, TInputs inputs) where TDocument : IDocument { return new CallTargetState(GraphQLCommon.CreateScopeFromValidate(Tracer.Instance, document)); @@ -61,7 +61,7 @@ public static CallTargetState OnMethodBeginException instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TValidationResult OnAsyncMethodEnd(TTarget instance, TValidationResult validationResult, Exception exception, CallTargetState state) + internal static TValidationResult OnAsyncMethodEnd(TTarget instance, TValidationResult validationResult, Exception exception, CallTargetState state) where TValidationResult : IValidationResultTuple { var scope = state.Scope; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/ValidateAsyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/ValidateAsyncIntegration.cs index 68e98c57d..23c741c28 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/ValidateAsyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/ValidateAsyncIntegration.cs @@ -44,7 +44,7 @@ public class ValidateAsyncIntegration /// The user context /// The input variables /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, string originalQuery, TSchema schema, TDocument document, TRules rules, TUserContext userContext, TInputs inputs) + internal static CallTargetState OnMethodBegin(TTarget instance, string originalQuery, TSchema schema, TDocument document, TRules rules, TUserContext userContext, TInputs inputs) where TDocument : IDocument { return new CallTargetState(GraphQLCommon.CreateScopeFromValidate(Tracer.Instance, document)); @@ -60,7 +60,7 @@ public static CallTargetState OnMethodBeginException instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TValidationResult OnAsyncMethodEnd(TTarget instance, TValidationResult validationResult, Exception exception, CallTargetState state) + internal static TValidationResult OnAsyncMethodEnd(TTarget instance, TValidationResult validationResult, Exception exception, CallTargetState state) where TValidationResult : IValidationResult { var scope = state.Scope; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/ValidateIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/ValidateIntegration.cs index ebd643c4b..11319de0c 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/ValidateIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/GraphQL/ValidateIntegration.cs @@ -6,7 +6,6 @@ using System; using System.ComponentModel; using Datadog.Trace.ClrProfiler.CallTarget; -using Datadog.Trace.Configuration; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.GraphQL { @@ -45,7 +44,7 @@ public class ValidateIntegration /// The user context /// The input variables /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, string originalQuery, TSchema schema, TDocument document, TRules rules, TUserContext userContext, TInputs inputs) + internal static CallTargetState OnMethodBegin(TTarget instance, string originalQuery, TSchema schema, TDocument document, TRules rules, TUserContext userContext, TInputs inputs) where TDocument : IDocument { return new CallTargetState(GraphQLCommon.CreateScopeFromValidate(Tracer.Instance, document)); @@ -61,7 +60,7 @@ public static CallTargetState OnMethodBeginException instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TValidationResult validationResult, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TValidationResult validationResult, Exception exception, CallTargetState state) where TValidationResult : IValidationResult { Scope scope = state.Scope; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/CurlHandler/CurlHandlerIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/CurlHandler/CurlHandlerIntegration.cs index 6498c36d5..1f8ce0a9d 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/CurlHandler/CurlHandlerIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/CurlHandler/CurlHandlerIntegration.cs @@ -41,7 +41,7 @@ public class CurlHandlerIntegration /// HttpRequest message instance /// CancellationToken value /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TRequest requestMessage, CancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, TRequest requestMessage, CancellationToken cancellationToken) where TRequest : IHttpRequestMessage { return HttpMessageHandlerCommon.OnMethodBegin(instance, requestMessage, cancellationToken, IntegrationId, IsIntegrationEnabledFunc); @@ -57,7 +57,7 @@ public static CallTargetState OnMethodBegin(TTarget instance, /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TResponse OnAsyncMethodEnd(TTarget instance, TResponse responseMessage, Exception exception, CallTargetState state) + internal static TResponse OnAsyncMethodEnd(TTarget instance, TResponse responseMessage, Exception exception, CallTargetState state) where TResponse : IHttpResponseMessage { return HttpMessageHandlerCommon.OnMethodEnd(instance, responseMessage, exception, state); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/HttpClientHandler/HttpClientHandlerIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/HttpClientHandler/HttpClientHandlerIntegration.cs index e677b6ce1..29892ba24 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/HttpClientHandler/HttpClientHandlerIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/HttpClientHandler/HttpClientHandlerIntegration.cs @@ -39,7 +39,7 @@ public class HttpClientHandlerIntegration /// HttpRequest message instance /// CancellationToken value /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TRequest requestMessage, CancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, TRequest requestMessage, CancellationToken cancellationToken) where TRequest : IHttpRequestMessage { return HttpMessageHandlerCommon.OnMethodBegin(instance, requestMessage, cancellationToken, IntegrationId); @@ -55,7 +55,7 @@ public static CallTargetState OnMethodBegin(TTarget instance, /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TResponse OnAsyncMethodEnd(TTarget instance, TResponse responseMessage, Exception exception, CallTargetState state) + internal static TResponse OnAsyncMethodEnd(TTarget instance, TResponse responseMessage, Exception exception, CallTargetState state) where TResponse : IHttpResponseMessage { return HttpMessageHandlerCommon.OnMethodEnd(instance, responseMessage, exception, state); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/HttpClientHandler/HttpClientHandlerSyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/HttpClientHandler/HttpClientHandlerSyncIntegration.cs index d69c81086..b2a48034c 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/HttpClientHandler/HttpClientHandlerSyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/HttpClientHandler/HttpClientHandlerSyncIntegration.cs @@ -39,7 +39,7 @@ public class HttpClientHandlerSyncIntegration /// HttpRequest message instance /// CancellationToken value /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TRequest requestMessage, CancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, TRequest requestMessage, CancellationToken cancellationToken) where TRequest : IHttpRequestMessage { return HttpMessageHandlerCommon.OnMethodBegin(instance, requestMessage, cancellationToken, IntegrationId); @@ -55,7 +55,7 @@ public static CallTargetState OnMethodBegin(TTarget instance, /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TResponse responseMessage, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TResponse responseMessage, Exception exception, CallTargetState state) where TResponse : IHttpResponseMessage { return new CallTargetReturn(HttpMessageHandlerCommon.OnMethodEnd(instance, responseMessage, exception, state)); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/HttpHeadersCollection.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/HttpHeadersCollection.cs index f24802983..4d199eecc 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/HttpHeadersCollection.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/HttpHeadersCollection.cs @@ -3,10 +3,10 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System; using System.Collections.Generic; using System.Linq; using Datadog.Trace.Headers; +using Datadog.Trace.Util; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Http.HttpClient { @@ -16,7 +16,12 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Http.HttpClient public HttpHeadersCollection(IRequestHeaders headers) { - _headers = headers ?? throw new ArgumentNullException(nameof(headers)); + if (headers is null) + { + ThrowHelper.ThrowArgumentNullException(nameof(headers)); + } + + _headers = headers; } public IEnumerable GetValues(string name) diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/HttpMethodStruct.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/HttpMethodStruct.cs index c22ae708b..432062bd9 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/HttpMethodStruct.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/HttpMethodStruct.cs @@ -3,7 +3,6 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Http.HttpClient @@ -12,9 +11,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Http.HttpClient /// Http method struct copy target for ducktyping /// [DuckCopy] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct HttpMethodStruct + internal struct HttpMethodStruct { /// /// Gets the http method in string diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/IHttpRequestMessage.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/IHttpRequestMessage.cs index d5fd22227..13f5f5e62 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/IHttpRequestMessage.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/IHttpRequestMessage.cs @@ -4,7 +4,6 @@ // using System; -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Http.HttpClient @@ -12,9 +11,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Http.HttpClient /// /// HttpRequestMessage interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IHttpRequestMessage : IDuckType + internal interface IHttpRequestMessage : IDuckType { /// /// Gets the Http Method diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/IHttpResponseMessage.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/IHttpResponseMessage.cs index 1bff3e966..6529969bf 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/IHttpResponseMessage.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/IHttpResponseMessage.cs @@ -3,7 +3,6 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Http.HttpClient @@ -11,9 +10,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Http.HttpClient /// /// HttpResponseMessage interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IHttpResponseMessage : IDuckType + internal interface IHttpResponseMessage : IDuckType { /// /// Gets the status code of the http response diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/IRequestHeaders.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/IRequestHeaders.cs index 6785c6a6e..6386eeeff 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/IRequestHeaders.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/IRequestHeaders.cs @@ -4,16 +4,13 @@ // using System.Collections.Generic; -using System.ComponentModel; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Http.HttpClient { /// /// RequestHeaders interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IRequestHeaders + internal interface IRequestHeaders { /// /// Try get values from the headers diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/SocketsHttpHandler/SocketsHttpHandlerIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/SocketsHttpHandler/SocketsHttpHandlerIntegration.cs index 79836c701..00cce9242 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/SocketsHttpHandler/SocketsHttpHandlerIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/SocketsHttpHandler/SocketsHttpHandlerIntegration.cs @@ -41,7 +41,7 @@ public class SocketsHttpHandlerIntegration /// HttpRequest message instance /// CancellationToken value /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TRequest requestMessage, CancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, TRequest requestMessage, CancellationToken cancellationToken) where TRequest : IHttpRequestMessage { return HttpMessageHandlerCommon.OnMethodBegin(instance, requestMessage, cancellationToken, IntegrationId, IsIntegrationEnabledFunc); @@ -57,7 +57,7 @@ public static CallTargetState OnMethodBegin(TTarget instance, /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TResponse OnAsyncMethodEnd(TTarget instance, TResponse responseMessage, Exception exception, CallTargetState state) + internal static TResponse OnAsyncMethodEnd(TTarget instance, TResponse responseMessage, Exception exception, CallTargetState state) where TResponse : IHttpResponseMessage { return HttpMessageHandlerCommon.OnMethodEnd(instance, responseMessage, exception, state); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/SocketsHttpHandler/SocketsHttpHandlerSyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/SocketsHttpHandler/SocketsHttpHandlerSyncIntegration.cs index 4cfdc73d5..a25e1efff 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/SocketsHttpHandler/SocketsHttpHandlerSyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/SocketsHttpHandler/SocketsHttpHandlerSyncIntegration.cs @@ -41,7 +41,7 @@ public class SocketsHttpHandlerSyncIntegration /// HttpRequest message instance /// CancellationToken value /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TRequest requestMessage, CancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, TRequest requestMessage, CancellationToken cancellationToken) where TRequest : IHttpRequestMessage { return HttpMessageHandlerCommon.OnMethodBegin(instance, requestMessage, cancellationToken, IntegrationId, IsIntegrationEnabledFunc); @@ -57,7 +57,7 @@ public static CallTargetState OnMethodBegin(TTarget instance, /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TResponse responseMessage, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TResponse responseMessage, Exception exception, CallTargetState state) where TResponse : IHttpResponseMessage { return new CallTargetReturn(HttpMessageHandlerCommon.OnMethodEnd(instance, responseMessage, exception, state)); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/WinHttpHandler/WinHttpHandlerIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/WinHttpHandler/WinHttpHandlerIntegration.cs index ce048477f..07fedd255 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/WinHttpHandler/WinHttpHandlerIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/HttpClient/WinHttpHandler/WinHttpHandlerIntegration.cs @@ -41,7 +41,7 @@ public class WinHttpHandlerIntegration /// HttpRequest message instance /// CancellationToken value /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TRequest requestMessage, CancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, TRequest requestMessage, CancellationToken cancellationToken) where TRequest : IHttpRequestMessage { return HttpMessageHandlerCommon.OnMethodBegin(instance, requestMessage, cancellationToken, IntegrationId, IsIntegrationEnabledFunc); @@ -57,7 +57,7 @@ public static CallTargetState OnMethodBegin(TTarget instance, /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TResponse OnAsyncMethodEnd(TTarget instance, TResponse responseMessage, Exception exception, CallTargetState state) + internal static TResponse OnAsyncMethodEnd(TTarget instance, TResponse responseMessage, Exception exception, CallTargetState state) where TResponse : IHttpResponseMessage { return HttpMessageHandlerCommon.OnMethodEnd(instance, responseMessage, exception, state); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/HttpWebRequest_BeginGetRequestStream_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/HttpWebRequest_BeginGetRequestStream_Integration.cs index e43e87ef1..3c95f9dab 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/HttpWebRequest_BeginGetRequestStream_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/HttpWebRequest_BeginGetRequestStream_Integration.cs @@ -46,7 +46,7 @@ public class HttpWebRequest_BeginGetRequestStream_Integration /// The AsyncCallback delegate /// An object containing state information for this asynchronous request /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, AsyncCallback callback, object state) + internal static CallTargetState OnMethodBegin(TTarget instance, AsyncCallback callback, object state) { if (instance is HttpWebRequest request && WebRequestCommon.IsTracingEnabled(request)) { diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/HttpWebRequest_BeginGetResponse_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/HttpWebRequest_BeginGetResponse_Integration.cs index 0a2843e84..797753d37 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/HttpWebRequest_BeginGetResponse_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/HttpWebRequest_BeginGetResponse_Integration.cs @@ -39,7 +39,7 @@ public class HttpWebRequest_BeginGetResponse_Integration /// The AsyncCallback delegate /// An object containing state information for this asynchronous request /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, AsyncCallback callback, object state) + internal static CallTargetState OnMethodBegin(TTarget instance, AsyncCallback callback, object state) { if (instance is HttpWebRequest request && WebRequestCommon.IsTracingEnabled(request)) { diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/HttpWebRequest_EndGetResponse_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/HttpWebRequest_EndGetResponse_Integration.cs index 51c9b5f56..7f31da549 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/HttpWebRequest_EndGetResponse_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/HttpWebRequest_EndGetResponse_Integration.cs @@ -43,7 +43,7 @@ public class HttpWebRequest_EndGetResponse_Integration /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) where TTarget : IHttpWebRequest, IDuckType { if (instance.Instance is HttpWebRequest request && WebRequestCommon.IsTracingEnabled(request)) @@ -78,7 +78,6 @@ public static CallTargetReturn OnMethodEnd(TTarget in if (setSamplingPriority) { scope.Span.SetTraceSamplingPriority(existingSpanContext.SamplingPriority.Value); - scope.Span.Context.TraceContext.LockSamplingPriority(); } if (returnValue is HttpWebResponse response) diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/HttpWebRequest_GetRequestStream_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/HttpWebRequest_GetRequestStream_Integration.cs index 4a5563fdb..bbad2ee9b 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/HttpWebRequest_GetRequestStream_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/HttpWebRequest_GetRequestStream_Integration.cs @@ -42,7 +42,7 @@ public class HttpWebRequest_GetRequestStream_Integration /// Type of the target /// Instance value, aka `this` of the instrumented method. /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance) + internal static CallTargetState OnMethodBegin(TTarget instance) { if (instance is HttpWebRequest request && WebRequestCommon.IsTracingEnabled(request)) { diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/HttpWebRequest_GetResponse_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/HttpWebRequest_GetResponse_Integration.cs index ed5fad2d4..5289ea711 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/HttpWebRequest_GetResponse_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/HttpWebRequest_GetResponse_Integration.cs @@ -42,7 +42,7 @@ public class HttpWebRequest_GetResponse_Integration /// Type of the target /// Instance value, aka `this` of the instrumented method. /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance) + internal static CallTargetState OnMethodBegin(TTarget instance) { return WebRequestCommon.GetResponse_OnMethodBegin(instance); } @@ -57,7 +57,7 @@ public static CallTargetState OnMethodBegin(TTarget instance) /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { if (state.Scope != null) { diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/IHttpWebRequest.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/IHttpWebRequest.cs index a9fca9ab4..0339d3751 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/IHttpWebRequest.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/IHttpWebRequest.cs @@ -3,7 +3,6 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Http.WebRequest @@ -11,9 +10,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Http.WebRequest /// /// Duck type interface for HttpWebRequest /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IHttpWebRequest + internal interface IHttpWebRequest { /// /// Gets the time the HttpWebRequest was created in Ticks (UTC) diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/WebRequestCommon.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/WebRequestCommon.cs index a85d6d4a6..1c6481630 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/WebRequestCommon.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/WebRequestCommon.cs @@ -58,7 +58,6 @@ public static CallTargetState GetResponse_OnMethodBegin(TTarget instanc if (setSamplingPriority) { scope.Span.SetTraceSamplingPriority(spanContext.SamplingPriority.Value); - scope.Span.Context.TraceContext.LockSamplingPriority(); } // add distributed tracing headers to the HTTP request diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/WebRequest_GetResponseAsync_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/WebRequest_GetResponseAsync_Integration.cs index 369b3be9d..1c7a8e96f 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/WebRequest_GetResponseAsync_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Http/WebRequest/WebRequest_GetResponseAsync_Integration.cs @@ -44,7 +44,7 @@ public class WebRequest_GetResponseAsync_Integration /// Type of the target /// Instance value, aka `this` of the instrumented method. /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance) + internal static CallTargetState OnMethodBegin(TTarget instance) { return WebRequestCommon.GetResponse_OnMethodBegin(instance); } @@ -59,7 +59,7 @@ public static CallTargetState OnMethodBegin(TTarget instance) /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { if (state.Scope != null) { diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IConsumeException.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IConsumeException.cs index 925134650..e10f056e6 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IConsumeException.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IConsumeException.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Kafka { /// /// ConsumeException interface for duck-typing /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IConsumeException + internal interface IConsumeException { /// /// Gets the consume result associated with the consume request diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IConsumeResult.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IConsumeResult.cs index 4f453a63f..e3684a89c 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IConsumeResult.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IConsumeResult.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Kafka { /// /// ConsumeResult for duck-typing /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IConsumeResult + internal interface IConsumeResult { /// /// Gets the topic diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IDeliveryReport.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IDeliveryReport.cs index 41a9d7b4e..f05997ea5 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IDeliveryReport.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IDeliveryReport.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Kafka { /// /// DeliveryReport interface for duck-typing /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IDeliveryReport : IDeliveryResult + internal interface IDeliveryReport : IDeliveryResult { /// /// Gets the Error associated with the delivery report diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IDeliveryResult.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IDeliveryResult.cs index b10ba94a5..b90a87c5c 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IDeliveryResult.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IDeliveryResult.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Kafka { /// /// DeliveryResult interface for duck-typing /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IDeliveryResult + internal interface IDeliveryResult { /// /// Gets the Kafka partition. diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IError.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IError.cs index c6801dd3e..b0a79a254 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IError.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IError.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Kafka { /// /// Error interface for duck-typing /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IError + internal interface IError { /// /// Gets a value indicating whether the error is really an error diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IHeaders.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IHeaders.cs index e56b6fa14..7a6167c54 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IHeaders.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IHeaders.cs @@ -1,18 +1,14 @@ -// +// // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Kafka { /// /// Headers interface for duck-typing /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IHeaders + internal interface IHeaders { /// /// Adds a header to the collection diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IMessage.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IMessage.cs index e832170d4..65c64309b 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IMessage.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IMessage.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Kafka { /// /// Message interface for duck-typing /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IMessage + internal interface IMessage { /// /// Gets the value of the message diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IProduceException.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IProduceException.cs index 97db4bf40..d9660fe24 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IProduceException.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/IProduceException.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Kafka { /// /// ProduceException interface for duck-typing /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IProduceException + internal interface IProduceException { /// /// Gets the delivery result associated with the produce request diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/ITimestamp.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/ITimestamp.cs index d4ab6919e..e37ccb56a 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/ITimestamp.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/ITimestamp.cs @@ -1,10 +1,9 @@ -// +// // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // using System; -using System.ComponentModel; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Kafka { @@ -12,9 +11,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Kafka /// Timestamp struct for duck-typing /// Requires boxing, but necessary as we need to duck-type too /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface ITimestamp + internal interface ITimestamp { /// /// Gets the timestamp type diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/ITopicPartition.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/ITopicPartition.cs index 5fd485ebe..543aa2e3f 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/ITopicPartition.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/ITopicPartition.cs @@ -1,18 +1,14 @@ -// +// // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Kafka { /// /// TopicPartition interface for duck-typing /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface ITopicPartition + internal interface ITopicPartition { /// /// Gets the Kafka topic name. diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/ITypedDeliveryHandlerShimAction.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/ITypedDeliveryHandlerShimAction.cs index 93a5a7ecc..3c02c27c8 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/ITypedDeliveryHandlerShimAction.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/ITypedDeliveryHandlerShimAction.cs @@ -3,8 +3,6 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System; -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Kafka @@ -12,9 +10,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Kafka /// /// TypedDeliveryHandlerShim_Action for duck-typing /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface ITypedDeliveryHandlerShimAction + internal interface ITypedDeliveryHandlerShimAction { /// /// Sets the delivery report handler diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaConsumerCloseIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaConsumerCloseIntegration.cs index 4696069e7..734aeacbe 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaConsumerCloseIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaConsumerCloseIntegration.cs @@ -1,4 +1,4 @@ -// +// // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // @@ -6,7 +6,6 @@ using System; using System.ComponentModel; using Datadog.Trace.ClrProfiler.CallTarget; -using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Kafka { @@ -32,7 +31,7 @@ public class KafkaConsumerCloseIntegration /// Type of the target /// Instance value, aka `this` of the instrumented method. /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance) + internal static CallTargetState OnMethodBegin(TTarget instance) { // If we are already in a consumer scope, close it. KafkaHelper.CloseConsumerScope(Tracer.Instance); @@ -47,7 +46,7 @@ public static CallTargetState OnMethodBegin(TTarget instance) /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) { return CallTargetReturn.GetDefault(); } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaConsumerConsumeIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaConsumerConsumeIntegration.cs index 055902a0c..3371c28a9 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaConsumerConsumeIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaConsumerConsumeIntegration.cs @@ -1,4 +1,4 @@ -// +// // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // @@ -7,7 +7,6 @@ using System.ComponentModel; using Datadog.Trace.ClrProfiler.CallTarget; using Datadog.Trace.DuckTyping; -using Datadog.Trace.Logging; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Kafka { @@ -34,7 +33,7 @@ public class KafkaConsumerConsumeIntegration /// Instance value, aka `this` of the instrumented method. /// The maximum period of time the call may block. /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, int millisecondsTimeout) + internal static CallTargetState OnMethodBegin(TTarget instance, int millisecondsTimeout) { // If we are already in a consumer scope, close it, and start a new one on method exit. KafkaHelper.CloseConsumerScope(Tracer.Instance); @@ -51,7 +50,7 @@ public static CallTargetState OnMethodBegin(TTarget instance, int milli /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) where TResponse : IConsumeResult, IDuckType { IConsumeResult consumeResult = response.Instance is not null ? response : null; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaConsumerDisposeIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaConsumerDisposeIntegration.cs index e1636f853..020df9dd2 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaConsumerDisposeIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaConsumerDisposeIntegration.cs @@ -1,4 +1,4 @@ -// +// // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // @@ -31,7 +31,7 @@ public class KafkaConsumerDisposeIntegration /// Type of the target /// Instance value, aka `this` of the instrumented method. /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance) + internal static CallTargetState OnMethodBegin(TTarget instance) { // If we are already in a consumer scope, close it. KafkaHelper.CloseConsumerScope(Tracer.Instance); @@ -46,7 +46,7 @@ public static CallTargetState OnMethodBegin(TTarget instance) /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) { return CallTargetReturn.GetDefault(); } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaConsumerUnsubscribeIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaConsumerUnsubscribeIntegration.cs index f60dd5caa..5478248c9 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaConsumerUnsubscribeIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaConsumerUnsubscribeIntegration.cs @@ -1,4 +1,4 @@ -// +// // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // @@ -31,7 +31,7 @@ public class KafkaConsumerUnsubscribeIntegration /// Type of the target /// Instance value, aka `this` of the instrumented method. /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance) + internal static CallTargetState OnMethodBegin(TTarget instance) { // If we are already in a consumer scope, close it. KafkaHelper.CloseConsumerScope(Tracer.Instance); @@ -46,7 +46,7 @@ public static CallTargetState OnMethodBegin(TTarget instance) /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) { return CallTargetReturn.GetDefault(); } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaHelper.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaHelper.cs index ba6c2354c..152d2218c 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaHelper.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaHelper.cs @@ -49,7 +49,7 @@ internal static Scope CreateProducerScope(Tracer tracer, ITopicPartition topicPa var isMissingTopic = string.IsNullOrEmpty(topic); var operationName = isMissingTopic ? $"(default) {OperationSend}" : $"{topic} {OperationSend}"; - scope = tracer.StartActiveWithTags( + scope = tracer.StartActiveInternal( operationName, tags: tags, serviceName: serviceName, @@ -134,7 +134,7 @@ internal static Scope CreateConsumerScope( var isMissingTopic = string.IsNullOrEmpty(topic); var operationName = isMissingTopic ? $"(default) {OperationReceive}" : $"{topic} {OperationReceive}"; - scope = tracer.StartActiveWithTags(operationName, parent: propagatedContext, tags: tags, serviceName: serviceName); + scope = tracer.StartActiveInternal(operationName, parent: propagatedContext, tags: tags, serviceName: serviceName); string resourceName = $"Consume Topic {(isMissingTopic ? "kafka" : topic)}"; @@ -193,7 +193,7 @@ internal static void CloseConsumerScope(Tracer tracer) return; } - var activeScope = tracer.ActiveScope; + var activeScope = tracer.InternalActiveScope; var currentSpan = activeScope?.Span; if (currentSpan == null || !ReferenceEquals(currentSpan.LogicScope, KafkaConstants.ConsumeOperationName)) { diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaProduceAsyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaProduceAsyncIntegration.cs index 49a8dde1e..7566f4487 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaProduceAsyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaProduceAsyncIntegration.cs @@ -39,7 +39,7 @@ public class KafkaProduceAsyncIntegration /// Message instance /// CancellationToken instance /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TTopicPartition topicPartition, TMessage message, CancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, TTopicPartition topicPartition, TMessage message, CancellationToken cancellationToken) where TMessage : IMessage { Scope scope = KafkaHelper.CreateProducerScope( @@ -67,8 +67,8 @@ public static CallTargetState OnMethodBegin( /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TResponse OnAsyncMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) - where TResponse : IDeliveryResult + internal static TResponse OnAsyncMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) + where TResponse : IDeliveryResult { if (state.Scope?.Span?.Tags is KafkaTags tags) { diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaProduceSyncDeliveryHandlerIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaProduceSyncDeliveryHandlerIntegration.cs index 989dbff77..6de069500 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaProduceSyncDeliveryHandlerIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaProduceSyncDeliveryHandlerIntegration.cs @@ -1,4 +1,4 @@ -// +// // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // @@ -44,7 +44,7 @@ public class KafkaProduceSyncDeliveryHandlerIntegration /// The message value /// The delivery handler instance /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, string topic, TKey key, TValue value, TActionOfDeliveryReport handler) + internal static CallTargetState OnMethodBegin(TTarget instance, string topic, TKey key, TValue value, TActionOfDeliveryReport handler) { if (handler is null) { @@ -57,7 +57,7 @@ public static CallTargetState OnMethodBeginException instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) { if (state.State is Action updateHandlerAction && instance.TryDuckCast(out var shim)) @@ -116,7 +116,7 @@ public static CallTargetReturn OnMethodEnd(TTarget instance, Exception /// A that can be manipulated when the action is invoked /// Type of the delivery report /// The wrapped action - public static Action WrapAction(Action originalHandler, Span span) + internal static Action WrapAction(Action originalHandler, Span span) { return new Action( value => @@ -170,7 +170,7 @@ static CachedWrapperDelegate() // Get the Action WrapHelper.WrapAction(Action value) methodinfo var wrapActionMethod = typeof(KafkaProduceSyncDeliveryHandlerIntegration) - .GetMethod(nameof(WrapAction), BindingFlags.Public | BindingFlags.Static); + .GetMethod(nameof(WrapAction), BindingFlags.NonPublic | BindingFlags.Static); // Create the generic method using the inner generic types of TActionDelegate => TParam wrapActionMethod = wrapActionMethod.MakeGenericMethod(typeof(TActionDelegate).GetGenericArguments()); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaProduceSyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaProduceSyncIntegration.cs index 920b9a8ac..3ac5b6e2d 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaProduceSyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/KafkaProduceSyncIntegration.cs @@ -38,7 +38,7 @@ public class KafkaProduceSyncIntegration /// Message instance /// Delivery Handler instance /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TTopicPartition topicPartition, TMessage message, TDeliveryHandler deliveryHandler) + internal static CallTargetState OnMethodBegin(TTarget instance, TTopicPartition topicPartition, TMessage message, TDeliveryHandler deliveryHandler) where TMessage : IMessage { // manually doing duck cast here so we have access to the _original_ TopicPartition type @@ -66,7 +66,7 @@ public static CallTargetState OnMethodBeginException instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return CallTargetReturn.GetDefault(); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/Offset.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/Offset.cs index 023d8f84c..4d6fd490a 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/Offset.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/Offset.cs @@ -1,9 +1,8 @@ -// +// // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; using Datadog.Trace.DuckTyping; // ReSharper disable SA1310 @@ -13,9 +12,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Kafka /// Partition for duck-typing /// [DuckCopy] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct Offset + internal struct Offset { private const long RdKafkaOffsetBeginning = -2; private const long RdKafkaOffsetEnd = -1; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/Partition.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/Partition.cs index f8c4e31c1..ab434798a 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/Partition.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Kafka/Partition.cs @@ -1,9 +1,8 @@ -// +// // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Kafka @@ -12,9 +11,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Kafka /// Partition for duck-typing /// [DuckCopy] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct Partition + internal struct Partition { /// /// Gets the int value corresponding to this partition diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/ILogger/LoggerExternalScopeProviderForEachScopeIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/ILogger/LoggerExternalScopeProviderForEachScopeIntegration.cs index 1f54e35bb..6fe11f2e2 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/ILogger/LoggerExternalScopeProviderForEachScopeIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/ILogger/LoggerExternalScopeProviderForEachScopeIntegration.cs @@ -35,7 +35,7 @@ public class LoggerExternalScopeProviderForEachScopeIntegration /// The callback to be invoked per scope /// The state to pass to the callback /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TAction callback, TState state) + internal static CallTargetState OnMethodBegin(TTarget instance, TAction callback, TState state) { LoggerIntegrationCommon.AddScope(Tracer.Instance, callback, state); return new CallTargetState(scope: null, state: null); @@ -49,7 +49,7 @@ public static CallTargetState OnMethodBegin(TTarget in /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) { return CallTargetReturn.GetDefault(); } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/ILogger/LoggerFactoryScopeProviderForEachScopeIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/ILogger/LoggerFactoryScopeProviderForEachScopeIntegration.cs index fdc9227ee..623a7d5d8 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/ILogger/LoggerFactoryScopeProviderForEachScopeIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/ILogger/LoggerFactoryScopeProviderForEachScopeIntegration.cs @@ -35,7 +35,7 @@ public class LoggerFactoryScopeProviderForEachScopeIntegration /// The callback to be invoked per scope /// The state to pass to the callback /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TAction callback, TState state) + internal static CallTargetState OnMethodBegin(TTarget instance, TAction callback, TState state) { LoggerIntegrationCommon.AddScope(Tracer.Instance, callback, state); return new CallTargetState(scope: null, state: null); @@ -49,7 +49,7 @@ public static CallTargetState OnMethodBegin(TTarget in /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) { return CallTargetReturn.GetDefault(); } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/Log4Net/AppenderAttachedImplIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/Log4Net/AppenderAttachedImplIntegration.cs index 918cb4681..37a0d6b97 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/Log4Net/AppenderAttachedImplIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/Log4Net/AppenderAttachedImplIntegration.cs @@ -3,6 +3,8 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // +// Modified by Splunk Inc. + using System; using System.ComponentModel; using Datadog.Trace.ClrProfiler.CallTarget; @@ -33,7 +35,7 @@ public class AppenderAttachedImplIntegration /// Instance value, aka `this` of the instrumented method. /// The logging event /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TLoggingEvent loggingEvent) + internal static CallTargetState OnMethodBegin(TTarget instance, TLoggingEvent loggingEvent) where TLoggingEvent : ILoggingEvent { var tracer = Tracer.Instance; @@ -66,7 +68,7 @@ public static CallTargetState OnMethodBegin(TTarget inst /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { return new CallTargetReturn(returnValue); } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/Log4Net/ILoggingEvent.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/Log4Net/ILoggingEvent.cs index 75b7a7920..fc9c99a72 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/Log4Net/ILoggingEvent.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/Log4Net/ILoggingEvent.cs @@ -4,16 +4,13 @@ // using System.Collections; -using System.ComponentModel; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Log4Net { /// /// log4net.Core.LoggingEvent interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface ILoggingEvent + internal interface ILoggingEvent { /// /// Gets the properties of the logging event diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/NLog/LogsInjection/DiagnosticContextHelper.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/NLog/LogsInjection/DiagnosticContextHelper.cs new file mode 100644 index 000000000..f32961035 --- /dev/null +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/NLog/LogsInjection/DiagnosticContextHelper.cs @@ -0,0 +1,144 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +// Modified by Splunk Inc. + +using System; +using System.Collections.Generic; +using System.Reflection; +using Datadog.Trace.DuckTyping; +using Datadog.Trace.Logging; + +namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Logging.NLog.LogsInjection +{ + internal static class DiagnosticContextHelper + { + private static readonly IDatadogLogger Log = DatadogLogging.GetLoggerFor(typeof(DiagnosticContextHelper)); + + public static MappedDiagnosticsLogicalContextSetterProxy GetMdlcProxy(Assembly nlogAssembly) + { + var mdlcType = nlogAssembly.GetType("NLog.MappedDiagnosticsLogicalContext"); + if (mdlcType is not null) + { + // NLog 4.3+ + var createTypeResult = DuckType.GetOrCreateProxyType(typeof(MappedDiagnosticsLogicalContextSetterProxy), mdlcType); + if (createTypeResult.Success) + { + // NLog 4.6+ + return createTypeResult.CreateInstance(instance: null); + } + } + + return null; + } + + public static MappedDiagnosticsContextSetterProxy GetMdcProxy(Assembly nlogAssembly) + { + var mdcType = nlogAssembly.GetType("NLog.MappedDiagnosticsContext"); + if (mdcType is not null) + { + // NLog 2.0+ + var createTypeResult = DuckType.GetOrCreateProxyType(typeof(MappedDiagnosticsContextSetterProxy), mdcType); + if (createTypeResult.Success) + { + return createTypeResult.CreateInstance(instance: null); + } + } + + mdcType = nlogAssembly.GetType("NLog.MDC"); + if (mdcType is not null) + { + // NLog 1.0+ + var createTypeResult = DuckType.GetOrCreateProxyType(typeof(MappedDiagnosticsContextSetterProxy), mdcType); + if (createTypeResult.Success) + { + return createTypeResult.CreateInstance(instance: null); + } + } + + return null; + } + + public static bool SetMdcState(MappedDiagnosticsContextSetterProxy mdc, Tracer tracer) + { + var removeSpanId = false; + mdc.Set(CorrelationIdentifier.ServiceKey, tracer.DefaultServiceName ?? string.Empty); + mdc.Set(CorrelationIdentifier.VersionKey, tracer.Settings.ServiceVersion ?? string.Empty); + mdc.Set(CorrelationIdentifier.EnvKey, tracer.Settings.Environment ?? string.Empty); + + var span = tracer.ActiveScope?.Span; + if (span is not null) + { + removeSpanId = true; + mdc.Set(CorrelationIdentifier.TraceIdKey, span.TraceId.ToString()); + mdc.Set(CorrelationIdentifier.SpanIdKey, span.SpanId.ToString()); + } + + return removeSpanId; + } + + public static IDisposable SetMdlcState(MappedDiagnosticsLogicalContextSetterProxy mdlc, Tracer tracer) + { + var spanContext = tracer.DistributedSpanContext; + var array = spanContext is null + ? new KeyValuePair[3] + : new KeyValuePair[5]; + + array[0] = new KeyValuePair(CorrelationIdentifier.ServiceKey, tracer.DefaultServiceName ?? string.Empty); + array[1] = new KeyValuePair(CorrelationIdentifier.VersionKey, tracer.Settings.ServiceVersion ?? string.Empty); + array[2] = new KeyValuePair(CorrelationIdentifier.EnvKey, tracer.Settings.Environment ?? string.Empty); + + var span = tracer.ActiveScope?.Span; + if (span is not null) + { + array[3] = new KeyValuePair(CorrelationIdentifier.TraceIdKey, span.TraceId.ToString()); + array[4] = new KeyValuePair(CorrelationIdentifier.SpanIdKey, span.SpanId.ToString()); + } + + var state = mdlc.SetScoped(array); + return state; + } + + public static void RemoveMdcState(MappedDiagnosticsContextSetterProxy mdc, bool removeTraceIds) + { + mdc.Remove(CorrelationIdentifier.ServiceKey); + mdc.Remove(CorrelationIdentifier.VersionKey); + mdc.Remove(CorrelationIdentifier.EnvKey); + + if (removeTraceIds) + { + mdc.Remove(CorrelationIdentifier.TraceIdKey); + mdc.Remove(CorrelationIdentifier.SpanIdKey); + } + } + + internal static class Cache + { + static Cache() + { + var nlogAssembly = typeof(TMarker).Assembly; + + if (GetMdlcProxy(nlogAssembly) is { } mdlcProxy) + { + Mdlc = mdlcProxy; + return; + } + + if (GetMdcProxy(nlogAssembly) is { } mdcProxy) + { + Mdc = mdcProxy; + return; + } + + // Something is very awry, but don't throw, just don't inject logs + Log.Warning("Failed to create proxies for both MDLC and MDC using TMarker={TMarker}, TMarker.Assembly={Assembly}. No automatic logs injection will occur for this assembly.", typeof(TMarker), nlogAssembly); + } + + public static MappedDiagnosticsLogicalContextSetterProxy Mdlc { get; } + + public static MappedDiagnosticsContextSetterProxy Mdc { get; } + } + } +} diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/NLog/LogsInjection/LoggerImplWriteIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/NLog/LogsInjection/LoggerImplWriteIntegration.cs new file mode 100644 index 000000000..a2ce9e0b7 --- /dev/null +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/NLog/LogsInjection/LoggerImplWriteIntegration.cs @@ -0,0 +1,85 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using System; +using System.ComponentModel; +using Datadog.Trace.ClrProfiler.CallTarget; + +namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Logging.NLog.LogsInjection +{ + /// + /// LoggerImpl.Write calltarget instrumentation + /// + [InstrumentMethod( + AssemblyName = "NLog", + TypeName = "NLog.LoggerImpl", + MethodName = "Write", + ReturnTypeName = ClrNames.Void, + ParameterTypeNames = new[] { ClrNames.Type, "NLog.Internal.TargetWithFilterChain", "NLog.LogEventInfo", "NLog.LogFactory" }, + MinimumVersion = "1.0.0.505", + MaximumVersion = "4.*.*", + IntegrationName = "NLog")] + [Browsable(false)] + [EditorBrowsable(EditorBrowsableState.Never)] + public class LoggerImplWriteIntegration + { + /// + /// OnMethodBegin callback + /// + /// Type of the target + /// The type of the TargetWithFilterChain + /// The type of the LogEventInfo + /// The type of the LogFactory + /// Instance value, aka `this` of the instrumented method. + /// The instance of the logger type + /// The instance of the targets for the level + /// The logging event instance + /// The LogFactory instance + /// Calltarget state value + internal static CallTargetState OnMethodBegin(TTarget instance, Type loggerType, TTargets targetsForLevel, TLogEventInfo logEvent, TLogFactory factory) + { + var tracer = Tracer.Instance; + + if (tracer.Settings.LogsInjectionEnabled) + { + if (DiagnosticContextHelper.Cache.Mdlc is { } mdlc) + { + var state = DiagnosticContextHelper.SetMdlcState(mdlc, tracer); + return new CallTargetState(scope: null, state); + } + + if (DiagnosticContextHelper.Cache.Mdc is { } mdc) + { + var removeSpanId = DiagnosticContextHelper.SetMdcState(mdc, tracer); + return new CallTargetState(scope: null, removeSpanId); + } + } + + return CallTargetState.GetDefault(); + } + + /// + /// OnMethodEnd callback + /// + /// Type of the target + /// Instance value, aka `this` of the instrumented method. + /// Exception instance in case the original code threw an exception. + /// Calltarget state value + /// A response value, in an async scenario will be T of Task of T + internal static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) + { + if (state.State is IDisposable disposable) + { + disposable.Dispose(); + } + else if (state.State is bool removeTraceIds && DiagnosticContextHelper.Cache.Mdc is { } mdc) + { + DiagnosticContextHelper.RemoveMdcState(mdc, removeTraceIds); + } + + return CallTargetReturn.GetDefault(); + } + } +} diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/NLog/LogsInjection/MappedDiagnosticsContextSetterProxy.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/NLog/LogsInjection/MappedDiagnosticsContextSetterProxy.cs new file mode 100644 index 000000000..36e8732fa --- /dev/null +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/NLog/LogsInjection/MappedDiagnosticsContextSetterProxy.cs @@ -0,0 +1,30 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Logging.NLog.LogsInjection +{ + /// + /// Duck type for MappedDiagnosticsContext in NLog 1.0+ + /// + internal class MappedDiagnosticsContextSetterProxy + { + /// + /// Sets the current thread MDC item to the specified value. + /// + /// Item name. + /// Item value. + public virtual void Set(string item, string value) + { + } + + /// + /// Removes the specified item from current thread MDC. + /// + /// Item name. + public virtual void Remove(string item) + { + } + } +} diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/NLog/LogsInjection/MappedDiagnosticsLogicalContextSetterProxy.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/NLog/LogsInjection/MappedDiagnosticsLogicalContextSetterProxy.cs new file mode 100644 index 000000000..5fb9a24c0 --- /dev/null +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/NLog/LogsInjection/MappedDiagnosticsLogicalContextSetterProxy.cs @@ -0,0 +1,26 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using System; +using System.Collections.Generic; + +namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Logging.NLog.LogsInjection +{ + /// + /// Duck type for MappedDiagnosticsLogicalContext in NLog 4.6+ + /// + internal class MappedDiagnosticsLogicalContextSetterProxy + { + /// + /// Updates the current logical context with multiple items in single operation + /// + /// . + /// >An that can be used to remove the item from the current logical context (null if no items). + public virtual IDisposable SetScoped(IReadOnlyList> items) + { + return null; + } + } +} diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/Serilog/LogsInjection/LogEventProxy.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/Serilog/LogsInjection/LogEventProxy.cs new file mode 100644 index 000000000..261b10683 --- /dev/null +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/Serilog/LogsInjection/LogEventProxy.cs @@ -0,0 +1,23 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using System.Collections; +using Datadog.Trace.DuckTyping; + +namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Logging.Serilog.LogsInjection +{ + /// + /// Ducktyping proxy for https://github.com/serilog/serilog/blob/1aabe1d6bde10382233fb2a50e0e2c6e0c9b8287/src/Serilog/Events/LogEvent.cs + /// + [DuckCopy] + internal struct LogEventProxy + { + /// + /// Gets the log Properties collection + /// + [DuckField(Name = "_properties")] + public IDictionary Properties; + } +} diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/Serilog/LogsInjection/LoggerDispatchInstrumentation.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/Serilog/LogsInjection/LoggerDispatchInstrumentation.cs new file mode 100644 index 000000000..12b8d7977 --- /dev/null +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/Serilog/LogsInjection/LoggerDispatchInstrumentation.cs @@ -0,0 +1,80 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +// Modified by Splunk Inc. + +using System.Collections; +using System.ComponentModel; +using Datadog.Trace.ClrProfiler.CallTarget; +using Datadog.Trace.DuckTyping; + +namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Logging.Serilog.LogsInjection +{ + /// + /// LoggerFactoryScopeProvider.ForEach<TState> calltarget instrumentation + /// + [InstrumentMethod( + AssemblyName = "Serilog", + TypeName = "Serilog.Core.Pipeline.Logger", + MethodName = "Dispatch", + ReturnTypeName = ClrNames.Void, + ParameterTypeNames = new[] { "Serilog.Events.LogEvent" }, + // Support for property names with underscores begins with Serilog package 1.4.16 / AssemblyVersion 1.4.0.0 / commit https://github.com/serilog/serilog/commit/8e8ecb32a194ac5360502ab467ada5a683ce35ba + MinimumVersion = "1.4.0.0", + MaximumVersion = "1.*.*", + IntegrationName = "Serilog")] + [InstrumentMethod( + AssemblyName = "Serilog", + TypeName = "Serilog.Core.Logger", + MethodName = "Dispatch", + ReturnTypeName = ClrNames.Void, + ParameterTypeNames = new[] { "Serilog.Events.LogEvent" }, + MinimumVersion = "2.0.0", + MaximumVersion = "2.*.*", + IntegrationName = "Serilog")] + [Browsable(false)] + [EditorBrowsable(EditorBrowsableState.Never)] + public class LoggerDispatchInstrumentation + { + /// + /// OnMethodBegin callback + /// + /// Type of the target + /// The type of the LogEvent + /// Instance value, aka `this` of the instrumented method. + /// The logging event + /// Calltarget state value + internal static CallTargetState OnMethodBegin(TTarget instance, TLogEvent loggingEvent) + { + var tracer = Tracer.Instance; + + if (tracer.Settings.LogsInjectionEnabled) + { + var dict = loggingEvent.DuckCast().Properties; + AddPropertyIfAbsent(dict, CorrelationIdentifier.SerilogServiceKey, tracer.DefaultServiceName); + AddPropertyIfAbsent(dict, CorrelationIdentifier.SerilogVersionKey, tracer.Settings.ServiceVersion); + AddPropertyIfAbsent(dict, CorrelationIdentifier.SerilogEnvKey, tracer.Settings.Environment); + + var span = tracer.ActiveScope?.Span; + if (span is not null) + { + AddPropertyIfAbsent(dict, CorrelationIdentifier.TraceIdKey, span.TraceId.ToString()); + AddPropertyIfAbsent(dict, CorrelationIdentifier.SpanIdKey, span.SpanId.ToString()); + } + } + + return new CallTargetState(scope: null, state: null); + + static void AddPropertyIfAbsent(IDictionary dict, string key, string value) + { + if (!dict.Contains(key)) + { + var property = SerilogLogPropertyHelper.CreateScalarValue(value ?? string.Empty); + dict.Add(key, property); + } + } + } + } +} diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/Serilog/LogsInjection/SerilogLogPropertyHelper.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/Serilog/LogsInjection/SerilogLogPropertyHelper.cs new file mode 100644 index 000000000..c332ccae7 --- /dev/null +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/Serilog/LogsInjection/SerilogLogPropertyHelper.cs @@ -0,0 +1,45 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using System; +using System.Reflection.Emit; +using Datadog.Trace.DuckTyping; + +namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Logging.Serilog.LogsInjection +{ + internal static class SerilogLogPropertyHelper + { + // ReSharper disable once StaticMemberInGenericType + private static readonly Func CreateScalarValueWith; + + static SerilogLogPropertyHelper() + { + // Initialize delegate for creating a MessageAttributeValue object + var assembly = typeof(TMarkerType).Assembly; + var scalarValueType = assembly.GetType("Serilog.Events.ScalarValue"); + var scalarValueConstructor = scalarValueType.GetConstructor(new[] { typeof(object) }); + + DynamicMethod createLogEventPropertyMethod = new DynamicMethod( + "SerilogLogPropertyHelper", + returnType: scalarValueType, + parameterTypes: new Type[] { typeof(string) }, + typeof(DuckType).Module, + true); + + ILGenerator createScalarValueIl = createLogEventPropertyMethod.GetILGenerator(); + + createScalarValueIl.Emit(OpCodes.Ldarg_0); // value + createScalarValueIl.Emit(OpCodes.Newobj, scalarValueConstructor); + createScalarValueIl.Emit(OpCodes.Ret); + + CreateScalarValueWith = (Func)createLogEventPropertyMethod.CreateDelegate(typeof(Func)); + } + + public static object CreateScalarValue(string value) + { + return CreateScalarValueWith(value); + } + } +} diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/MongoDb/IWireProtocol_ExecuteAsync_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/MongoDb/IWireProtocol_ExecuteAsync_Integration.cs index e85f1a41f..38985d0ca 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/MongoDb/IWireProtocol_ExecuteAsync_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/MongoDb/IWireProtocol_ExecuteAsync_Integration.cs @@ -47,7 +47,7 @@ public class IWireProtocol_ExecuteAsync_Integration /// The cancellation token /// Type of the target /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, object connection, CancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, object connection, CancellationToken cancellationToken) { var scope = MongoDbIntegration.CreateScope(instance, connection); @@ -64,7 +64,7 @@ public static CallTargetState OnMethodBegin(TTarget instance, object co /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { var scope = state.Scope; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/MongoDb/IWireProtocol_Execute_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/MongoDb/IWireProtocol_Execute_Integration.cs index 98df2d95f..95d287ee3 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/MongoDb/IWireProtocol_Execute_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/MongoDb/IWireProtocol_Execute_Integration.cs @@ -29,7 +29,7 @@ public class IWireProtocol_Execute_Integration /// The cancellation token /// Type of the target /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, object connection, CancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, object connection, CancellationToken cancellationToken) { var scope = MongoDbIntegration.CreateScope(instance, connection); @@ -44,7 +44,7 @@ public static CallTargetState OnMethodBegin(TTarget instance, object co /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) { var scope = state.Scope; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/MongoDb/IWireProtocol_Generic_Execute_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/MongoDb/IWireProtocol_Generic_Execute_Integration.cs index a67a0d70a..e146b221b 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/MongoDb/IWireProtocol_Generic_Execute_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/MongoDb/IWireProtocol_Generic_Execute_Integration.cs @@ -44,7 +44,7 @@ public class IWireProtocol_Generic_Execute_Integration /// The cancellation token /// Type of the target /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, object connection, CancellationToken cancellationToken) + internal static CallTargetState OnMethodBegin(TTarget instance, object connection, CancellationToken cancellationToken) { var scope = MongoDbIntegration.CreateScope(instance, connection); @@ -61,7 +61,7 @@ public static CallTargetState OnMethodBegin(TTarget instance, object co /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { var scope = state.Scope; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/MongoDb/MongoDbIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/MongoDb/MongoDbIntegration.cs index 9228ae71e..ea0f33ee9 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/MongoDb/MongoDbIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/MongoDb/MongoDbIntegration.cs @@ -6,20 +6,18 @@ // Modified by Splunk Inc. using System; -using System.ComponentModel; using System.Net; using Datadog.Trace.ClrProfiler.Emit; using Datadog.Trace.Configuration; using Datadog.Trace.Logging; +using Datadog.Trace.Util; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.MongoDb { /// /// Tracing integration for MongoDB.Driver.Core. /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public static class MongoDbIntegration + internal static class MongoDbIntegration { internal const string IntegrationName = nameof(Configuration.IntegrationId.MongoDb); @@ -28,6 +26,7 @@ public static class MongoDbIntegration internal const string Major2Minor2 = "2.2"; // Synchronous methods added in 2.2 internal const string MongoDbClientAssembly = "MongoDB.Driver.Core"; + private const string IWireProtocolGeneric = "MongoDB.Driver.Core.WireProtocol.IWireProtocol`1"; private const string DefaultOperationName = "mongodb.query"; private const string ServiceName = "mongodb"; @@ -158,7 +157,7 @@ internal static Scope CreateScope(object wireProtocol, object connection) try { var tags = new MongoDbTags(); - scope = tracer.StartActiveWithTags(operationName ?? DefaultOperationName, serviceName: serviceName, tags: tags); + scope = tracer.StartActiveInternal(operationName ?? DefaultOperationName, serviceName: serviceName, tags: tags); var span = scope.Span; span.LogicScope = DefaultOperationName; span.Type = SpanTypes.MongoDb; @@ -183,7 +182,7 @@ internal static Scope CreateScope(object wireProtocol, object connection) private static Scope GetActiveMongoDbScope(Tracer tracer) { - var scope = tracer.ActiveScope; + var scope = tracer.InternalActiveScope; var parent = scope?.Span; @@ -196,5 +195,35 @@ private static Scope GetActiveMongoDbScope(Tracer tracer) return null; } + + private static Type[] GetGenericsFromWireProtocol(Type wireProtocolType) + { + var interfaces = wireProtocolType.GetInterfaces(); + Type typeWeInstrument = null; + + for (var i = 0; i < interfaces.Length; i++) + { + if (string.Equals($"{interfaces[i].Namespace}.{interfaces[i].Name}", IWireProtocolGeneric)) + { + typeWeInstrument = interfaces[i]; + break; + } + } + + if (typeWeInstrument == null) + { + // We're likely in a non-generic context + return null; + } + + var genericArgs = typeWeInstrument.GetGenericArguments(); + + if (genericArgs.Length == 0) + { + ThrowHelper.ThrowArgumentException($"Expected generics to determine TaskResult from {wireProtocolType.AssemblyQualifiedName}"); + } + + return genericArgs; + } } } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/IMessageQueue.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/IMessageQueue.cs index 20d3ed7b7..47727a344 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/IMessageQueue.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/IMessageQueue.cs @@ -3,17 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System; -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Msmq { /// /// message queue proxy /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IMessageQueue + internal interface IMessageQueue { /// /// Gets a value indicating whether the queue accepts only transactions. diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/MessageQueueTransactionType.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/MessageQueueTransactionType.cs index f7600d695..1643a367d 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/MessageQueueTransactionType.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/MessageQueueTransactionType.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Msmq { /// /// message queue transaction type /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public enum MessageQueueTransactionType + internal enum MessageQueueTransactionType { /// /// Operation will not be transactional diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/MessageQueue_Purge_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/MessageQueue_Purge_Integration.cs index 83667d694..e7d7749e6 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/MessageQueue_Purge_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/MessageQueue_Purge_Integration.cs @@ -6,9 +6,6 @@ using System; using System.ComponentModel; using Datadog.Trace.ClrProfiler.CallTarget; -using Datadog.Trace.Configuration; -using Datadog.Trace.Logging; -using Datadog.Trace.Tagging; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Msmq { @@ -35,7 +32,7 @@ public class MessageQueue_Purge_Integration /// Message queue /// Instance value, aka `this` of the instrumented method. /// Calltarget state value - public static CallTargetState OnMethodBegin(TMessageQueue instance) + internal static CallTargetState OnMethodBegin(TMessageQueue instance) where TMessageQueue : IMessageQueue { var scope = MsmqCommon.CreateScope(Tracer.Instance, Command, SpanKinds.Client, instance); @@ -50,7 +47,7 @@ public static CallTargetState OnMethodBegin(TMessageQueue instanc /// Exception instance in case the original code threw an exception. /// Calltarget state value /// CallTargetReturn - public static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return CallTargetReturn.GetDefault(); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/MessageQueue_ReceiveCurrent_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/MessageQueue_ReceiveCurrent_Integration.cs index 2f2a34bb9..936eaa49b 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/MessageQueue_ReceiveCurrent_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/MessageQueue_ReceiveCurrent_Integration.cs @@ -4,16 +4,8 @@ // using System; -using System.Collections.Generic; using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Datadog.Trace.ClrProfiler.CallTarget; -using Datadog.Trace.Configuration; -using Datadog.Trace.DuckTyping; -using Datadog.Trace.Logging; -using Datadog.Trace.Tagging; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Msmq { @@ -48,7 +40,7 @@ public class MessageQueue_ReceiveCurrent_Integration /// transaction /// type of transaction /// Calltarget state value - public static CallTargetState OnMethodBegin(TMessageQueue instance, TimeSpan timeout, int action, object cursorHandle, object messagePropertyFilter, object messageQueueTransaction, MessageQueueTransactionType messageQueueTransactionType) + internal static CallTargetState OnMethodBegin(TMessageQueue instance, TimeSpan timeout, int action, object cursorHandle, object messagePropertyFilter, object messageQueueTransaction, MessageQueueTransactionType messageQueueTransactionType) where TMessageQueue : IMessageQueue { var scope = MsmqCommon.CreateScope(Tracer.Instance, action != 0 ? CommandPeek : CommandReceive, SpanKinds.Consumer, instance); @@ -65,7 +57,7 @@ public static CallTargetState OnMethodBegin(TMessageQueue instanc /// Exception instance in case the original code threw an exception. /// Calltarget state value /// CallTargetReturn - public static CallTargetReturn OnMethodEnd(TTarget instance, TResult messageResult, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TResult messageResult, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return new CallTargetReturn(messageResult); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/MessageQueue_SendInternal_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/MessageQueue_SendInternal_Integration.cs index 4bc49b8b0..10e3dfdb6 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/MessageQueue_SendInternal_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/MessageQueue_SendInternal_Integration.cs @@ -6,7 +6,6 @@ using System; using System.ComponentModel; using Datadog.Trace.ClrProfiler.CallTarget; -using Datadog.Trace.Configuration; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Msmq { @@ -37,7 +36,7 @@ public class MessageQueue_SendInternal_Integration /// Message queue transaction can be null /// Message queue transaction type can be null /// Calltarget state value - public static CallTargetState OnMethodBegin(TMessageQueue instance, object message, object messageQueueTransaction, MessageQueueTransactionType messageQueueTransactionType) + internal static CallTargetState OnMethodBegin(TMessageQueue instance, object message, object messageQueueTransaction, MessageQueueTransactionType messageQueueTransactionType) where TMessageQueue : IMessageQueue { var scope = MsmqCommon.CreateScope(Tracer.Instance, Command, SpanKinds.Producer, instance, messageQueueTransaction != null || messageQueueTransactionType != MessageQueueTransactionType.None); @@ -52,7 +51,7 @@ public static CallTargetState OnMethodBegin(TMessageQueue instanc /// Exception instance in case the original code threw an exception. /// Calltarget state value /// CallTargetReturn - public static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return CallTargetReturn.GetDefault(); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/MsmqCommon.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/MsmqCommon.cs index 749d61127..fe38d6c27 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/MsmqCommon.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/MsmqCommon.cs @@ -4,8 +4,6 @@ // using System; -using System.Text; -using Datadog.Trace.Configuration; using Datadog.Trace.Logging; using Datadog.Trace.Tagging; @@ -41,7 +39,7 @@ internal static Scope CreateScope(Tracer tracer, string command, var serviceName = tracer.Settings.GetServiceName(tracer, MsmqConstants.ServiceName); - scope = tracer.StartActiveWithTags(MsmqConstants.OperationName, serviceName: serviceName, tags: tags); + scope = tracer.StartActiveInternal(MsmqConstants.OperationName, serviceName: serviceName, tags: tags); var span = scope.Span; span.Type = SpanTypes.Queue; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/MsmqConstants.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/MsmqConstants.cs index ee634b8ef..237f112e2 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/MsmqConstants.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Msmq/MsmqConstants.cs @@ -3,8 +3,6 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System; -using System.Text; using Datadog.Trace.Configuration; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Msmq diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/BasicDeliverIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/BasicDeliverIntegration.cs index 7c7e73f89..5fe744222 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/BasicDeliverIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/BasicDeliverIntegration.cs @@ -47,7 +47,7 @@ public class BasicDeliverIntegration /// The message properties. /// The message body. /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, string consumerTag, ulong deliveryTag, bool redelivered, string exchange, string routingKey, TBasicProperties basicProperties, TBody body) + internal static CallTargetState OnMethodBegin(TTarget instance, string consumerTag, ulong deliveryTag, bool redelivered, string exchange, string routingKey, TBasicProperties basicProperties, TBody body) where TBasicProperties : IBasicProperties where TBody : IBody // ReadOnlyMemory body in 6.0.0 { @@ -86,7 +86,7 @@ public static CallTargetState OnMethodBegin(TT /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A default CallTargetReturn to satisfy the CallTarget contract - public static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return CallTargetReturn.GetDefault(); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/BasicGetIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/BasicGetIntegration.cs index 6246500a5..75c7df5f6 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/BasicGetIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/BasicGetIntegration.cs @@ -42,7 +42,7 @@ public class BasicGetIntegration /// The queue name of the message /// The original autoAck argument /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, string queue, bool autoAck) + internal static CallTargetState OnMethodBegin(TTarget instance, string queue, bool autoAck) { return new CallTargetState(scope: null, state: queue, startTime: DateTimeOffset.UtcNow); } @@ -57,7 +57,7 @@ public static CallTargetState OnMethodBegin(TTarget instance, string qu /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A default CallTargetReturn to satisfy the CallTarget contract - public static CallTargetReturn OnMethodEnd(TTarget instance, TResult basicGetResult, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TResult basicGetResult, Exception exception, CallTargetState state) where TResult : IBasicGetResult, IDuckType { string queue = (string)state.State; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/BasicPublishIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/BasicPublishIntegration.cs index f6d392205..6a48dda20 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/BasicPublishIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/BasicPublishIntegration.cs @@ -45,7 +45,7 @@ public class BasicPublishIntegration /// The message properties. /// The message body. /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, string exchange, string routingKey, bool mandatory, TBasicProperties basicProperties, TBody body) + internal static CallTargetState OnMethodBegin(TTarget instance, string exchange, string routingKey, bool mandatory, TBasicProperties basicProperties, TBody body) where TBasicProperties : IBasicProperties, IDuckType where TBody : IBody, IDuckType // Versions < 6.0.0: TBody is byte[] // Versions >= 6.0.0: TBody is ReadOnlyMemory { @@ -88,7 +88,7 @@ public static CallTargetState OnMethodBegin(TT /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A default CallTargetReturn to satisfy the CallTarget contract - public static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return CallTargetReturn.GetDefault(); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/ExchangeDeclareIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/ExchangeDeclareIntegration.cs index 069306c5a..2a07e7937 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/ExchangeDeclareIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/ExchangeDeclareIntegration.cs @@ -42,7 +42,7 @@ public class ExchangeDeclareIntegration /// The original nowait setting /// The original arguments setting /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, string exchange, string type, bool passive, bool durable, bool autoDelete, bool @internal, bool nowait, IDictionary arguments) + internal static CallTargetState OnMethodBegin(TTarget instance, string exchange, string type, bool passive, bool durable, bool autoDelete, bool @internal, bool nowait, IDictionary arguments) { return new CallTargetState(RabbitMQIntegration.CreateScope(Tracer.Instance, out _, Command, SpanKinds.Client, exchange: exchange)); } @@ -55,7 +55,7 @@ public static CallTargetState OnMethodBegin(TTarget instance, string ex /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A default CallTargetReturn to satisfy the CallTarget contract - public static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return CallTargetReturn.GetDefault(); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/IBasicGetResult.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/IBasicGetResult.cs index 34135001d..266bc86b6 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/IBasicGetResult.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/IBasicGetResult.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.RabbitMQ { /// /// BasicGetResult interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IBasicGetResult + internal interface IBasicGetResult { /// /// Gets the message body of the result diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/IBasicProperties.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/IBasicProperties.cs index af7bac8ad..413dfb4dc 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/IBasicProperties.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/IBasicProperties.cs @@ -6,16 +6,13 @@ // Modified by Splunk Inc. using System.Collections.Generic; -using System.ComponentModel; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.RabbitMQ { /// /// BasicProperties interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IBasicProperties + internal interface IBasicProperties { /// /// Gets or sets the headers of the message diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/IBody.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/IBody.cs index e15fdc1ac..496b9f00e 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/IBody.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/IBody.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.RabbitMQ { /// /// Body interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IBody + internal interface IBody { /// /// Gets the length of the message body diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/QueueBindIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/QueueBindIntegration.cs index d588a9973..382e60bb6 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/QueueBindIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/QueueBindIntegration.cs @@ -38,7 +38,7 @@ public class QueueBindIntegration /// The original routingKey argument. /// The original arguments setting /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, string queue, string exchange, string routingKey, IDictionary arguments) + internal static CallTargetState OnMethodBegin(TTarget instance, string queue, string exchange, string routingKey, IDictionary arguments) { return new CallTargetState(RabbitMQIntegration.CreateScope(Tracer.Instance, out _, Command, SpanKinds.Client, queue: queue, exchange: exchange, routingKey: routingKey)); } @@ -51,7 +51,7 @@ public static CallTargetState OnMethodBegin(TTarget instance, string qu /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A default CallTargetReturn to satisfy the CallTarget contract - public static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return CallTargetReturn.GetDefault(); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/QueueDeclareIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/QueueDeclareIntegration.cs index 5df086bdb..811a0402e 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/QueueDeclareIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/QueueDeclareIntegration.cs @@ -41,7 +41,7 @@ public class QueueDeclareIntegration /// The original nowait setting /// The original arguments setting /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, string queue, bool passive, bool durable, bool exclusive, bool autoDelete, bool nowait, IDictionary arguments) + internal static CallTargetState OnMethodBegin(TTarget instance, string queue, bool passive, bool durable, bool exclusive, bool autoDelete, bool nowait, IDictionary arguments) { return new CallTargetState(RabbitMQIntegration.CreateScope(Tracer.Instance, out _, Command, SpanKinds.Client, queue: queue)); } @@ -54,7 +54,7 @@ public static CallTargetState OnMethodBegin(TTarget instance, string qu /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A default CallTargetReturn to satisfy the CallTarget contract - public static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return CallTargetReturn.GetDefault(); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/RabbitMQIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/RabbitMQIntegration.cs index 4a32c5235..299255f48 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/RabbitMQIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/RabbitMQIntegration.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using Datadog.Trace.Configuration; using Datadog.Trace.DuckTyping; using Datadog.Trace.Logging; @@ -16,9 +15,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.RabbitMQ /// /// Tracing integration for RabbitMQ.Client /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public static class RabbitMQIntegration + internal static class RabbitMQIntegration { internal const string IntegrationName = nameof(Configuration.IntegrationId.RabbitMQ); @@ -53,8 +50,6 @@ internal static Scope CreateScope(Tracer tracer, out RabbitMQTags tags, string c try { - Span parent = tracer.ActiveScope?.Span; - tags = new RabbitMQTags(spanKind); string operation = CommandToOperation(command); string operationName = string.IsNullOrWhiteSpace(exchange) @@ -62,7 +57,7 @@ internal static Scope CreateScope(Tracer tracer, out RabbitMQTags tags, string c : $"{exchange} {operation}"; string serviceName = tracer.Settings.GetServiceName(tracer, ServiceName); - scope = tracer.StartActiveWithTags(operationName, parent: parentContext, tags: tags, serviceName: serviceName, startTime: startTime); + scope = tracer.StartActiveInternal(operationName, parent: parentContext, tags: tags, serviceName: serviceName, startTime: startTime); var span = scope.Span; span.Type = SpanTypes.Queue; @@ -142,7 +137,7 @@ internal static void SetTagsFromBasicProperties(RabbitMQTags tags, IBasicPropert #pragma warning disable SA1201 // Elements must appear in the correct order #pragma warning disable SA1600 // Elements must be documented [DuckCopy] - public struct BasicGetResultStruct + internal struct BasicGetResultStruct { /// /// Gets the message body of the result @@ -156,7 +151,7 @@ public struct BasicGetResultStruct } [DuckCopy] - public struct BodyStruct + internal struct BodyStruct { /// /// Gets the length of the message body diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/RedisHelper.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/RedisHelper.cs index a0c7382ec..a2d71a758 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/RedisHelper.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/RedisHelper.cs @@ -53,7 +53,7 @@ internal static Scope CreateScope(Tracer tracer, IntegrationId integrationId, st command = rawCommand; } - scope = tracer.StartActiveWithTags(command ?? OperationName, serviceName: tracer.DefaultServiceName, tags: tags); + scope = tracer.StartActiveInternal(command ?? OperationName, serviceName: tracer.DefaultServiceName, tags: tags); var span = scope.Span; span.Type = SpanTypes.Redis; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/ServiceStack/IRedisNativeClient.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/ServiceStack/IRedisNativeClient.cs index c767c703b..4422ad911 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/ServiceStack/IRedisNativeClient.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/ServiceStack/IRedisNativeClient.cs @@ -1,18 +1,14 @@ -// +// // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Redis.ServiceStack { /// /// Redis native client for duck typing /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IRedisNativeClient + internal interface IRedisNativeClient { /// /// Gets Client Hostname diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/ServiceStack/RedisNativeClientSendReceiveIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/ServiceStack/RedisNativeClientSendReceiveIntegration.cs index 7300ba654..1c4d8bfb0 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/ServiceStack/RedisNativeClientSendReceiveIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/ServiceStack/RedisNativeClientSendReceiveIntegration.cs @@ -44,7 +44,7 @@ public class RedisNativeClientSendReceiveIntegration /// Complete pipeline function instance /// Send without read boolean /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, byte[][] cmdWithBinaryArgs, TFunc fn, TAction completePipelineFn, bool sendWithoutRead) + internal static CallTargetState OnMethodBegin(TTarget instance, byte[][] cmdWithBinaryArgs, TFunc fn, TAction completePipelineFn, bool sendWithoutRead) where TTarget : IRedisNativeClient { Scope scope = RedisHelper.CreateScope(Tracer.Instance, IntegrationId, instance.Host ?? string.Empty, instance.Port.ToString(CultureInfo.InvariantCulture), GetRawCommand(cmdWithBinaryArgs)); @@ -66,7 +66,7 @@ public static CallTargetState OnMethodBegin(TTarget ins /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return new CallTargetReturn(response); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/ConnectionMultiplexerExecuteAsyncImplIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/ConnectionMultiplexerExecuteAsyncImplIntegration.cs index 0cf28cec6..d5204385f 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/ConnectionMultiplexerExecuteAsyncImplIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/ConnectionMultiplexerExecuteAsyncImplIntegration.cs @@ -51,7 +51,7 @@ public class ConnectionMultiplexerExecuteAsyncImplIntegration /// State instance /// Server endpoint instance /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TMessage message, TProcessor resultProcessor, object state, TServerEndPoint serverEndPoint) + internal static CallTargetState OnMethodBegin(TTarget instance, TMessage message, TProcessor resultProcessor, object state, TServerEndPoint serverEndPoint) where TTarget : IConnectionMultiplexer where TMessage : IMessageData { @@ -77,7 +77,7 @@ public static CallTargetState OnMethodBeginException instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TResponse OnAsyncMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) + internal static TResponse OnAsyncMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return response; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/ConnectionMultiplexerExecuteSyncImplIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/ConnectionMultiplexerExecuteSyncImplIntegration.cs index f8746cb93..2b7ddae57 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/ConnectionMultiplexerExecuteSyncImplIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/ConnectionMultiplexerExecuteSyncImplIntegration.cs @@ -50,7 +50,7 @@ public class ConnectionMultiplexerExecuteSyncImplIntegration /// Result processor instance /// Server endpoint instance /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TMessage message, TProcessor resultProcessor, TServerEndPoint serverEndPoint) + internal static CallTargetState OnMethodBegin(TTarget instance, TMessage message, TProcessor resultProcessor, TServerEndPoint serverEndPoint) where TTarget : IConnectionMultiplexer where TMessage : IMessageData { @@ -76,7 +76,7 @@ public static CallTargetState OnMethodBeginException instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return new CallTargetReturn(response); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/IConnectionMultiplexer.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/IConnectionMultiplexer.cs index dfeaf6aef..b544f2b7f 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/IConnectionMultiplexer.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/IConnectionMultiplexer.cs @@ -1,18 +1,14 @@ -// +// // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Redis.StackExchange { /// /// Connection multiplexer ducktype structure /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IConnectionMultiplexer + internal interface IConnectionMultiplexer { /// /// Gets the conection configuration diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/IMessageData.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/IMessageData.cs index 08a969e42..614e61c4c 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/IMessageData.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/IMessageData.cs @@ -1,18 +1,14 @@ -// +// // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Redis.StackExchange { /// /// Message data interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IMessageData + internal interface IMessageData { /// /// Gets message command and key diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/IRedisBase.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/IRedisBase.cs index ac44ba27f..dcb7009ad 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/IRedisBase.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/IRedisBase.cs @@ -3,7 +3,6 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Redis.StackExchange @@ -11,9 +10,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Redis.StackExchange /// /// RedisBase interface for ducktyping /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IRedisBase + internal interface IRedisBase { /// /// Gets multiplexer data structure diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/MultiplexerData.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/MultiplexerData.cs index 705fb1e99..9b8e09b54 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/MultiplexerData.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/MultiplexerData.cs @@ -1,9 +1,8 @@ -// +// // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Redis.StackExchange @@ -12,9 +11,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Redis.StackExchange /// Multiplexer data structure for duck typing /// [DuckCopy] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct MultiplexerData + internal struct MultiplexerData { /// /// Multiplexer configuration diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/RedisExecuteAsyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/RedisExecuteAsyncIntegration.cs index 2b993ec51..4ae40ac3b 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/RedisExecuteAsyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/RedisExecuteAsyncIntegration.cs @@ -34,7 +34,7 @@ public class RedisExecuteAsyncIntegration /// Result processor instance /// Server endpoint instance /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TMessage message, TProcessor resultProcessor, TServerEndPoint serverEndPoint) + internal static CallTargetState OnMethodBegin(TTarget instance, TMessage message, TProcessor resultProcessor, TServerEndPoint serverEndPoint) where TTarget : IRedisBase where TMessage : IMessageData { @@ -60,7 +60,7 @@ public static CallTargetState OnMethodBeginException instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TResponse OnAsyncMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) + internal static TResponse OnAsyncMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return response; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/RedisExecuteSyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/RedisExecuteSyncIntegration.cs index 96e076b85..f8c42454d 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/RedisExecuteSyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/RedisExecuteSyncIntegration.cs @@ -32,7 +32,7 @@ public class RedisExecuteSyncIntegration /// Result processor instance /// Server endpoint instance /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TMessage message, TProcessor resultProcessor, TServerEndPoint serverEndPoint) + internal static CallTargetState OnMethodBegin(TTarget instance, TMessage message, TProcessor resultProcessor, TServerEndPoint serverEndPoint) where TTarget : IRedisBase where TMessage : IMessageData { @@ -58,7 +58,7 @@ public static CallTargetState OnMethodBeginException instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TResponse response, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return new CallTargetReturn(response); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/StackExchangeRedisHelper.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/StackExchangeRedisHelper.cs index a81d1a97a..00071755b 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/StackExchangeRedisHelper.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/StackExchange/StackExchangeRedisHelper.cs @@ -3,7 +3,6 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System; using System.Linq; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Redis.StackExchange diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/ITestMethod.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/ITestMethod.cs index c0a503b26..d9223821e 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/ITestMethod.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/ITestMethod.cs @@ -4,7 +4,6 @@ // using System; -using System.ComponentModel; using System.Reflection; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.MsTestV2 @@ -12,9 +11,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.MsTestV2 /// /// TestMethod ducktype interface /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface ITestMethod + internal interface ITestMethod { /// /// Gets the test method name diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/ITestMethodRunner.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/ITestMethodRunner.cs index 6279f2ba1..bfb40dd5d 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/ITestMethodRunner.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/ITestMethodRunner.cs @@ -3,7 +3,6 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.MsTestV2 @@ -11,9 +10,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.MsTestV2 /// /// TestMethodRunner ducktype interface /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface ITestMethodRunner + internal interface ITestMethodRunner { /// /// Gets the TestMethodInfo instance diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/MsTestIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/MsTestIntegration.cs index be46a5cfd..8c05608f7 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/MsTestIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/MsTestIntegration.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; using System.Reflection; +using System.Threading; using Datadog.Trace.Ci; using Datadog.Trace.Ci.Tags; using Datadog.Trace.Configuration; @@ -21,6 +22,8 @@ internal static class MsTestIntegration internal const IntegrationId IntegrationId = Configuration.IntegrationId.MsTestV2; internal static readonly IDatadogLogger Log = DatadogLogging.GetLoggerFor(typeof(MsTestIntegration)); + internal static readonly ThreadLocal IsTestMethodRunnableThreadLocal = new ThreadLocal(); + internal static bool IsEnabled => CIVisibility.IsRunning && Tracer.Instance.Settings.IsIntegrationEnabled(IntegrationId); internal static Scope OnMethodBegin(TTestMethod testMethodInfo, Type type) @@ -33,7 +36,7 @@ internal static Scope OnMethodBegin(TTestMethod testMethodInfo, Typ string testSuite = testMethodInfo.TestClassName; string testName = testMethodInfo.TestMethodName; - Scope scope = Tracer.Instance.StartActive("mstest.test", serviceName: Tracer.Instance.DefaultServiceName); + Scope scope = Tracer.Instance.StartActiveInternal("mstest.test", serviceName: Tracer.Instance.DefaultServiceName); Span span = scope.Span; span.Type = SpanTypes.Test; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestCategoryAttributeStruct.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestCategoryAttributeStruct.cs index 523bc1536..edbc87f41 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestCategoryAttributeStruct.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestCategoryAttributeStruct.cs @@ -4,7 +4,6 @@ // using System.Collections.Generic; -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.MsTestV2 @@ -13,9 +12,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.MsTestV2 /// TestCategoryAttribute ducktype struct /// [DuckCopy] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct TestCategoryAttributeStruct + internal struct TestCategoryAttributeStruct { /// /// Gets the test categories diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestMethodAttributeExecuteIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestMethodAttributeExecuteIntegration.cs index 46b1d3911..315c8c90f 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestMethodAttributeExecuteIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestMethodAttributeExecuteIntegration.cs @@ -25,7 +25,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.MsTestV2 IntegrationName = MsTestIntegration.IntegrationName)] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] - public class TestMethodAttributeExecuteIntegration + public static class TestMethodAttributeExecuteIntegration { /// /// OnMethodBegin callback @@ -35,7 +35,7 @@ public class TestMethodAttributeExecuteIntegration /// Instance value, aka `this` of the instrumented method. /// Test method instance /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TTestMethod testMethod) + internal static CallTargetState OnMethodBegin(TTarget instance, TTestMethod testMethod) where TTestMethod : ITestMethod, IDuckType { if (!MsTestIntegration.IsEnabled) @@ -48,7 +48,7 @@ public static CallTargetState OnMethodBegin(TTarget instan } /// - /// OnAsyncMethodEnd callback + /// OnMethodEnd callback /// /// Type of the target /// Type of the return value @@ -57,7 +57,7 @@ public static CallTargetState OnMethodBegin(TTarget instan /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { if (MsTestIntegration.IsEnabled) { @@ -68,6 +68,7 @@ public static CallTargetReturn OnMethodEnd(TTarget in if (returnValueArray.Length == 1) { object testResultObject = returnValueArray.GetValue(0); + if (testResultObject != null && testResultObject.TryDuckCast(out var testResult)) { diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestMethodRunnerExecuteIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestMethodRunnerExecuteIntegration.cs index cda183f59..b17d5d771 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestMethodRunnerExecuteIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestMethodRunnerExecuteIntegration.cs @@ -12,39 +12,23 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.MsTestV2 { /// - /// Microsoft.VisualStudio.TestPlatform.TestFramework.Execute calltarget instrumentation + /// Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestMethodRunner.Execute calltarget instrumentation /// [InstrumentMethod( AssemblyName = "Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter", TypeName = "Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestMethodRunner", MethodName = "Execute", - ReturnTypeName = "Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel.UnitTestResult", + ReturnTypeName = "Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel.UnitTestResult[]", ParameterTypeNames = new string[0], MinimumVersion = "14.0.0", MaximumVersion = "14.*.*", IntegrationName = MsTestIntegration.IntegrationName)] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] - public class TestMethodRunnerExecuteIntegration + public static class TestMethodRunnerExecuteIntegration { /// - /// OnMethodBegin callback - /// - /// Type of the target - /// Instance value, aka `this` of the instrumented method. - /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance) - { - if (!MsTestIntegration.IsEnabled) - { - return CallTargetState.GetDefault(); - } - - return new CallTargetState((Scope)null, instance); - } - - /// - /// OnAsyncMethodEnd callback + /// OnMethodEnd callback /// /// Type of the target /// Type of the return value @@ -53,25 +37,28 @@ public static CallTargetState OnMethodBegin(TTarget instance) /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) where TTarget : ITestMethodRunner { + if (!MsTestIntegration.IsEnabled) + { + return new CallTargetReturn(returnValue); + } + if (returnValue is Array returnValueArray && returnValueArray.Length == 1) { object unitTestResultObject = returnValueArray.GetValue(0); + if (unitTestResultObject != null && unitTestResultObject.TryDuckCast(out var unitTestResult)) { var outcome = unitTestResult.Outcome; if (outcome == UnitTestResultOutcome.Inconclusive || outcome == UnitTestResultOutcome.NotRunnable || outcome == UnitTestResultOutcome.Ignored) { // This instrumentation catches all tests being ignored - if (state.State != null && state.State.TryDuckCast(out var testMethodRunner)) - { - var scope = MsTestIntegration.OnMethodBegin(testMethodRunner.TestMethodInfo, testMethodRunner.GetType()); - scope.Span.SetTag(TestTags.Status, TestTags.StatusSkip); - scope.Span.SetTag(TestTags.SkipReason, unitTestResult.ErrorMessage); - scope.Dispose(); - } + var scope = MsTestIntegration.OnMethodBegin(instance.TestMethodInfo, instance.GetType()); + scope.Span.SetTag(TestTags.Status, TestTags.StatusSkip); + scope.Span.SetTag(TestTags.SkipReason, unitTestResult.ErrorMessage); + scope.Dispose(); } } } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestPropertyAttributeStruct.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestPropertyAttributeStruct.cs index 7f7d37119..eea0ea0e8 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestPropertyAttributeStruct.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestPropertyAttributeStruct.cs @@ -3,7 +3,6 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.MsTestV2 @@ -12,9 +11,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.MsTestV2 /// TestPropertyAttribute ducktype struct /// [DuckCopy] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct TestPropertyAttributeStruct + internal struct TestPropertyAttributeStruct { /// /// Gets the name. diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestResultStruct.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestResultStruct.cs index 06b7b6db0..b1c52d2b4 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestResultStruct.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestResultStruct.cs @@ -4,7 +4,6 @@ // using System; -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.MsTestV2 @@ -13,9 +12,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.MsTestV2 /// TestResult ducktype struct /// [DuckCopy] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct TestResultStruct + internal struct TestResultStruct { /// /// Gets the outcome enum diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/UnitTestOutcome.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/UnitTestOutcome.cs index 9ee6bc7da..fa42f7206 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/UnitTestOutcome.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/UnitTestOutcome.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.MsTestV2 { /// /// Unit test outcomes /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public enum UnitTestOutcome : int + internal enum UnitTestOutcome : int { /// /// Test was executed, but there were issues. diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/UnitTestResultOutcome.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/UnitTestResultOutcome.cs index 30497a52e..5779cda28 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/UnitTestResultOutcome.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/UnitTestResultOutcome.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.MsTestV2 { /// /// UnitTestResult Outcome /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public enum UnitTestResultOutcome + internal enum UnitTestResultOutcome { /// /// Error diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/UnitTestResultStruct.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/UnitTestResultStruct.cs index 3ca0c5d61..37cb20fb3 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/UnitTestResultStruct.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/UnitTestResultStruct.cs @@ -3,8 +3,6 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System; -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.MsTestV2 @@ -13,9 +11,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.MsTestV2 /// UnitTestResult ducktype struct /// [DuckCopy] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct UnitTestResultStruct + internal struct UnitTestResultStruct { /// /// Gets the error message diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/UnitTestRunnerIsTestMethodRunnableIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/UnitTestRunnerIsTestMethodRunnableIntegration.cs new file mode 100644 index 000000000..0effedce2 --- /dev/null +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/UnitTestRunnerIsTestMethodRunnableIntegration.cs @@ -0,0 +1,49 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using System.ComponentModel; +using Datadog.Trace.ClrProfiler.CallTarget; + +namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.MsTestV2 +{ + /// + /// Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.UnitTestRunner.IsTestMethodRunnable calltarget instrumentation + /// + [InstrumentMethod( + AssemblyName = "Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter", + TypeName = "Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.UnitTestRunner", + MethodName = "IsTestMethodRunnable", + ReturnTypeName = ClrNames.Bool, + ParameterTypeNames = new string[] { "Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel.TestMethod", "Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestMethodInfo", "Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel.UnitTestResult[]&" }, + MinimumVersion = "14.0.0", + MaximumVersion = "14.*.*", + IntegrationName = MsTestIntegration.IntegrationName)] + [Browsable(false)] + [EditorBrowsable(EditorBrowsableState.Never)] + public static class UnitTestRunnerIsTestMethodRunnableIntegration + { + /// + /// OnMethodBegin callback + /// + /// Type of the target + /// Type of the arg1 + /// Type of the arg2 + /// Type of the arg3 + /// Instance value, aka `this` of the instrumented method. + /// Test method argument + /// Test method info argument + /// Not runnable result argument + /// Calltarget state value + internal static CallTargetState OnMethodBegin(TTarget instance, TArg1 testMethod, TArg2 testMethodInfo, ref TArg3 notRunnableResult) + { + if (MsTestIntegration.IsEnabled) + { + MsTestIntegration.IsTestMethodRunnableThreadLocal.Value = testMethodInfo; + } + + return CallTargetState.GetDefault(); + } + } +} diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/UnitTestRunnerRunCleanupIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/UnitTestRunnerRunCleanupIntegration.cs index 42dd91674..08eaf5969 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/UnitTestRunnerRunCleanupIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/UnitTestRunnerRunCleanupIntegration.cs @@ -23,7 +23,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.MsTestV2 IntegrationName = MsTestIntegration.IntegrationName)] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] - public class UnitTestRunnerRunCleanupIntegration + public static class UnitTestRunnerRunCleanupIntegration { /// /// OnAsyncMethodEnd callback @@ -35,7 +35,7 @@ public class UnitTestRunnerRunCleanupIntegration /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { Common.FlushSpans(MsTestIntegration.IntegrationId); return new CallTargetReturn(returnValue); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/UnitTestRunnerRunSingleTestIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/UnitTestRunnerRunSingleTestIntegration.cs new file mode 100644 index 000000000..39ae7c4db --- /dev/null +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/UnitTestRunnerRunSingleTestIntegration.cs @@ -0,0 +1,72 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using System; +using System.ComponentModel; +using Datadog.Trace.Ci.Tags; +using Datadog.Trace.ClrProfiler.CallTarget; +using Datadog.Trace.DuckTyping; + +namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.MsTestV2 +{ + /// + /// Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.UnitTestRunner.RunSingleTest calltarget instrumentation + /// + [InstrumentMethod( + AssemblyName = "Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter", + TypeName = "Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.UnitTestRunner", + MethodName = "RunSingleTest", + ReturnTypeName = "Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel.UnitTestResult[]", + ParameterTypeNames = new string[] { "Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel.TestMethod", "System.Collections.Generic.IDictionary`2[System.String,System.Object]" }, + MinimumVersion = "14.0.0", + MaximumVersion = "14.*.*", + IntegrationName = MsTestIntegration.IntegrationName)] + [Browsable(false)] + [EditorBrowsable(EditorBrowsableState.Never)] + public static class UnitTestRunnerRunSingleTestIntegration + { + /// + /// OnMethodEnd callback + /// + /// Type of the target + /// Type of the return value + /// Instance value, aka `this` of the instrumented method. + /// Return value + /// Exception instance in case the original code threw an exception. + /// Calltarget state value + /// A response value, in an async scenario will be T of Task of T + internal static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + { + if (!MsTestIntegration.IsEnabled) + { + return new CallTargetReturn(returnValue); + } + + var objTestMethodInfo = MsTestIntegration.IsTestMethodRunnableThreadLocal.Value; + MsTestIntegration.IsTestMethodRunnableThreadLocal.Value = null; + if (objTestMethodInfo is not null && returnValue is Array returnValueArray && returnValueArray.Length == 1) + { + object unitTestResultObject = returnValueArray.GetValue(0); + + if (unitTestResultObject != null && + unitTestResultObject.TryDuckCast(out var unitTestResult) && + objTestMethodInfo.TryDuckCast(out var testMethodInfo)) + { + var outcome = unitTestResult.Outcome; + if (outcome == UnitTestResultOutcome.Inconclusive || outcome == UnitTestResultOutcome.NotRunnable || outcome == UnitTestResultOutcome.Ignored) + { + // This instrumentation catches all tests being ignored + var scope = MsTestIntegration.OnMethodBegin(testMethodInfo, instance.GetType()); + scope.Span.SetTag(TestTags.Status, TestTags.StatusSkip); + scope.Span.SetTag(TestTags.SkipReason, unitTestResult.ErrorMessage); + scope.Dispose(); + } + } + } + + return new CallTargetReturn(returnValue); + } + } +} diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/FailureSite.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/FailureSite.cs index 755997d5f..c67f951f0 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/FailureSite.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/FailureSite.cs @@ -3,17 +3,13 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.NUnit { /// /// The FailureSite enum indicates the stage of a test /// in which an error or failure occurred. /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public enum FailureSite + internal enum FailureSite { /// /// Failure in the test itself diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/ICompositeWorkItem.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/ICompositeWorkItem.cs index 4ad1541d3..fe592f415 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/ICompositeWorkItem.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/ICompositeWorkItem.cs @@ -4,16 +4,13 @@ // using System.Collections; -using System.ComponentModel; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.NUnit { /// /// DuckTyping interface for NUnit.Framework.Internal.Execution.CompositeWorkItem /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface ICompositeWorkItem : IWorkItem + internal interface ICompositeWorkItem : IWorkItem { /// /// Gets the List of Child WorkItems diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/IMethodInfo.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/IMethodInfo.cs index 50db6c353..1fdeac974 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/IMethodInfo.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/IMethodInfo.cs @@ -3,7 +3,6 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; using System.Reflection; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.NUnit @@ -11,9 +10,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.NUnit /// /// DuckTyping interface for NUnit.Framework.Interfaces.IMethodInfo /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IMethodInfo + internal interface IMethodInfo { /// /// Gets the MethodInfo for this method. diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/IPropertyBag.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/IPropertyBag.cs index cd21c112d..96d3793ec 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/IPropertyBag.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/IPropertyBag.cs @@ -5,16 +5,13 @@ using System.Collections; using System.Collections.Generic; -using System.ComponentModel; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.NUnit { /// /// DuckTyping interface for NUnit.Framework.Interfaces.IPropertyBag /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IPropertyBag + internal interface IPropertyBag { /// /// Gets a collection containing all the keys in the property set diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/IResultState.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/IResultState.cs index 201a29aa5..4bcec4c0d 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/IResultState.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/IResultState.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.NUnit { /// /// DuckTyping interface for NUnit.Framework.Interfaces.ResultState /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IResultState + internal interface IResultState { /// /// Gets the TestStatus for the test. diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/ITest.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/ITest.cs index 7264c8415..15967a474 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/ITest.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/ITest.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.NUnit { /// /// DuckTyping interface for NUnit.Framework.Internal.Test /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface ITest + internal interface ITest { /// /// Gets the test name diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/ITestExecutionContext.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/ITestExecutionContext.cs index af03c8306..1227a4a96 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/ITestExecutionContext.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/ITestExecutionContext.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.NUnit { /// /// DuckTyping interface for NUnit.Framework.Internal.TestExecutionContext /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface ITestExecutionContext + internal interface ITestExecutionContext { /// /// Gets the current test diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/ITestResult.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/ITestResult.cs index 34833b84d..23833ac49 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/ITestResult.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/ITestResult.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.NUnit { /// /// DuckTyping interface for NUnit.Framework.Internal.TestResult /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface ITestResult + internal interface ITestResult { /// /// Gets the test with which this result is associated. diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/ITestSuite.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/ITestSuite.cs index 34fa5da44..bf1da1efb 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/ITestSuite.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/ITestSuite.cs @@ -4,16 +4,13 @@ // using System.Collections; -using System.ComponentModel; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.NUnit { /// /// DuckTyping interface for NUnit.Framework.Internal.TestSuite /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface ITestSuite : ITest + internal interface ITestSuite : ITest { /// /// Gets the children tests diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/IWorkItem.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/IWorkItem.cs index 68f5936a6..bec791dae 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/IWorkItem.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/IWorkItem.cs @@ -1,18 +1,14 @@ -// +// // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.NUnit { /// /// DuckTyping interface for NUnit.Framework.Internal.Execution.WorkItem /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IWorkItem + internal interface IWorkItem { /// /// Gets the test result diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/NUnitCompositeWorkItemSkipChildrenIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/NUnitCompositeWorkItemSkipChildrenIntegration.cs index b3588872c..0ee3763cf 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/NUnitCompositeWorkItemSkipChildrenIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/NUnitCompositeWorkItemSkipChildrenIntegration.cs @@ -41,7 +41,7 @@ public class NUnitCompositeWorkItemSkipChildrenIntegration /// Result state instance /// Message instance /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TSuite testSuite, TResultState resultState, string message) + internal static CallTargetState OnMethodBegin(TTarget instance, TSuite testSuite, TResultState resultState, string message) { if (testSuite is not null) { @@ -108,7 +108,7 @@ public static CallTargetState OnMethodBegin(TTarg /// Exception instance in case the original code threw an exception. /// Calltarget state value /// Return value of the method - public static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) { if (state.State != null) { diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/NUnitIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/NUnitIntegration.cs index b080b0a03..c28c34d51 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/NUnitIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/NUnitIntegration.cs @@ -49,7 +49,7 @@ internal static Scope CreateScope(ITest currentTest, Type targetType) string skipReason = null; - Scope scope = Tracer.Instance.StartActive("nunit.test", serviceName: Tracer.Instance.DefaultServiceName); + Scope scope = Tracer.Instance.StartActiveInternal("nunit.test", serviceName: Tracer.Instance.DefaultServiceName); Span span = scope.Span; span.Type = SpanTypes.Test; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/NUnitSkipCommandExecuteIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/NUnitSkipCommandExecuteIntegration.cs index a09e021a7..6ff3c4f12 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/NUnitSkipCommandExecuteIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/NUnitSkipCommandExecuteIntegration.cs @@ -33,7 +33,7 @@ public class NUnitSkipCommandExecuteIntegration /// Instance value, aka `this` of the instrumented method. /// Execution context instance /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TContext executionContext) + internal static CallTargetState OnMethodBegin(TTarget instance, TContext executionContext) where TContext : ITestExecutionContext { if (!NUnitIntegration.IsEnabled) @@ -54,7 +54,7 @@ public static CallTargetState OnMethodBegin(TTarget instance, /// Exception instance in case the original code threw an exception. /// Calltarget state value /// Return value of the method - public static CallTargetReturn OnMethodEnd(TTarget instance, TResult returnValue, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TResult returnValue, Exception exception, CallTargetState state) { Scope scope = state.Scope; if (scope != null) diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/NUnitTestAdapterUnloadIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/NUnitTestAdapterUnloadIntegration.cs index e17936eeb..9d51b380b 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/NUnitTestAdapterUnloadIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/NUnitTestAdapterUnloadIntegration.cs @@ -18,7 +18,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.NUnit MethodName = "Unload", ReturnTypeName = ClrNames.Void, MinimumVersion = "3.0.0", - MaximumVersion = "3.*.*", + MaximumVersion = "4.*.*", IntegrationName = NUnitIntegration.IntegrationName)] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] @@ -32,7 +32,7 @@ public class NUnitTestAdapterUnloadIntegration /// Exception instance in case the original code threw an exception. /// Calltarget state value /// Return value of the method - public static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, Exception exception, CallTargetState state) { Common.FlushSpans(NUnitIntegration.IntegrationId); return CallTargetReturn.GetDefault(); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/NUnitTestAssemblyRunnerWaitForCompletionIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/NUnitTestAssemblyRunnerWaitForCompletionIntegration.cs index 85dca905d..94415575e 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/NUnitTestAssemblyRunnerWaitForCompletionIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/NUnitTestAssemblyRunnerWaitForCompletionIntegration.cs @@ -35,7 +35,7 @@ public class NUnitTestAssemblyRunnerWaitForCompletionIntegration /// Exception instance in case the original code threw an exception. /// Calltarget state value /// Return value of the method - public static CallTargetReturn OnMethodEnd(TTarget instance, TResult returnValue, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TResult returnValue, Exception exception, CallTargetState state) { Common.FlushSpans(NUnitIntegration.IntegrationId); return new CallTargetReturn(returnValue); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/NUnitTestMethodCommandExecuteIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/NUnitTestMethodCommandExecuteIntegration.cs index 1c29447ee..ea661fcc5 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/NUnitTestMethodCommandExecuteIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/NUnitTestMethodCommandExecuteIntegration.cs @@ -33,7 +33,7 @@ public class NUnitTestMethodCommandExecuteIntegration /// Instance value, aka `this` of the instrumented method. /// Execution context instance /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TContext executionContext) + internal static CallTargetState OnMethodBegin(TTarget instance, TContext executionContext) where TContext : ITestExecutionContext { if (!NUnitIntegration.IsEnabled) @@ -54,7 +54,7 @@ public static CallTargetState OnMethodBegin(TTarget instance, /// Exception instance in case the original code threw an exception. /// Calltarget state value /// Return value of the method - public static CallTargetReturn OnMethodEnd(TTarget instance, TResult returnValue, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TResult returnValue, Exception exception, CallTargetState state) { Scope scope = state.Scope; if (scope != null) diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/TestStatus.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/TestStatus.cs index 0e54e8f48..6581a6aed 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/TestStatus.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/TestStatus.cs @@ -3,16 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; - namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.NUnit { /// /// The TestStatus enum indicates the result of running a test /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public enum TestStatus + internal enum TestStatus { /// /// The test was inconclusive diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/IExceptionAggregator.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/IExceptionAggregator.cs index c78978801..1c16c6546 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/IExceptionAggregator.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/IExceptionAggregator.cs @@ -4,16 +4,13 @@ // using System; -using System.ComponentModel; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.XUnit { /// /// Exception aggregator interface /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public interface IExceptionAggregator + internal interface IExceptionAggregator { /// /// Extract exception diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/TestCaseStruct.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/TestCaseStruct.cs index fed4b6c6f..69bafcf58 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/TestCaseStruct.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/TestCaseStruct.cs @@ -4,7 +4,6 @@ // using System.Collections.Generic; -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.XUnit @@ -13,9 +12,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.XUnit /// TestCase structure /// [DuckCopy] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct TestCaseStruct + internal struct TestCaseStruct { /// /// Display name diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/TestInvokerStruct.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/TestInvokerStruct.cs index 20aa50b7a..a353d383c 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/TestInvokerStruct.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/TestInvokerStruct.cs @@ -4,7 +4,6 @@ // using System; -using System.ComponentModel; using System.Reflection; using Datadog.Trace.DuckTyping; @@ -14,9 +13,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.XUnit /// TestInvoker`1 structure /// [DuckCopy] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct TestInvokerStruct + internal struct TestInvokerStruct { /// /// Test class Type diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/TestRunnerStruct.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/TestRunnerStruct.cs index 37fc43108..8f26e33ae 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/TestRunnerStruct.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/TestRunnerStruct.cs @@ -4,7 +4,6 @@ // using System; -using System.ComponentModel; using System.Reflection; using Datadog.Trace.DuckTyping; @@ -14,9 +13,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.XUnit /// TestRunner`1 structure /// [DuckCopy] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public struct TestRunnerStruct + internal struct TestRunnerStruct { /// /// Test class Type diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/XUnitIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/XUnitIntegration.cs index 4777753ba..b40fa61fd 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/XUnitIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/XUnitIntegration.cs @@ -27,7 +27,7 @@ internal static Scope CreateScope(ref TestRunnerStruct runnerInstance, Type targ string testFramework = "xUnit"; - Scope scope = Tracer.Instance.StartActive("xunit.test", serviceName: Tracer.Instance.DefaultServiceName); + Scope scope = Tracer.Instance.StartActiveInternal("xunit.test", serviceName: Tracer.Instance.DefaultServiceName); Span span = scope.Span; span.Type = SpanTypes.Test; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/XUnitTestAssemblyFinishedCtorIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/XUnitTestAssemblyFinishedCtorIntegration.cs index 3214fe3c5..abc136cd1 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/XUnitTestAssemblyFinishedCtorIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/XUnitTestAssemblyFinishedCtorIntegration.cs @@ -3,7 +3,6 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System; using System.ComponentModel; using Datadog.Trace.ClrProfiler.CallTarget; @@ -43,7 +42,7 @@ public static class XUnitTestAssemblyFinishedCtorIntegration /// Tests failed /// Tests skipped /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TArg1 testCases, TArg2 testAssembly, TArg3 executionTime, TArg4 testsRun, TArg5 testsFailed, TArg6 testsSkipped) + internal static CallTargetState OnMethodBegin(TTarget instance, TArg1 testCases, TArg2 testAssembly, TArg3 executionTime, TArg4 testsRun, TArg5 testsFailed, TArg6 testsSkipped) { Common.FlushSpans(XUnitIntegration.IntegrationId); return CallTargetState.GetDefault(); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/XUnitTestAssemblyRunnerRunTestCollectionAsyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/XUnitTestAssemblyRunnerRunTestCollectionAsyncIntegration.cs index 24e0ec08a..6319532b2 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/XUnitTestAssemblyRunnerRunTestCollectionAsyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/XUnitTestAssemblyRunnerRunTestCollectionAsyncIntegration.cs @@ -35,7 +35,7 @@ public static class XUnitTestAssemblyRunnerRunTestCollectionAsyncIntegration /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static TReturn OnAsyncMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { Common.FlushSpans(XUnitIntegration.IntegrationId); return returnValue; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/XUnitTestInvokerRunAsyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/XUnitTestInvokerRunAsyncIntegration.cs index d6ba08d38..39f80d6ac 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/XUnitTestInvokerRunAsyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/XUnitTestInvokerRunAsyncIntegration.cs @@ -35,7 +35,7 @@ public static class XUnitTestInvokerRunAsyncIntegration /// Type of the target /// Instance value, aka `this` of the instrumented method. /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance) + internal static CallTargetState OnMethodBegin(TTarget instance) { if (!XUnitIntegration.IsEnabled) { @@ -64,7 +64,7 @@ public static CallTargetState OnMethodBegin(TTarget instance) /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static decimal OnAsyncMethodEnd(TTarget instance, decimal returnValue, Exception exception, CallTargetState state) + internal static decimal OnAsyncMethodEnd(TTarget instance, decimal returnValue, Exception exception, CallTargetState state) { Scope scope = state.Scope; if (scope != null) diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/XUnitTestRunnerRunAsyncIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/XUnitTestRunnerRunAsyncIntegration.cs index 860074ee0..4cb0b408b 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/XUnitTestRunnerRunAsyncIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/XUnit/XUnitTestRunnerRunAsyncIntegration.cs @@ -30,7 +30,7 @@ public static class XUnitTestRunnerRunAsyncIntegration /// Type of the target /// Instance value, aka `this` of the instrumented method. /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance) + internal static CallTargetState OnMethodBegin(TTarget instance) { if (XUnitIntegration.IsEnabled) { diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/AsyncMethodInvoker_InvokeBegin_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/AsyncMethodInvoker_InvokeBegin_Integration.cs index 4fe620fec..294a3569f 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/AsyncMethodInvoker_InvokeBegin_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/AsyncMethodInvoker_InvokeBegin_Integration.cs @@ -6,10 +6,8 @@ #if NETFRAMEWORK using System; using System.ComponentModel; -using System.Reflection; using Datadog.Trace.ClrProfiler.CallTarget; using Datadog.Trace.ClrProfiler.Emit; -using Datadog.Trace.Configuration; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Wcf { @@ -39,7 +37,7 @@ public class AsyncMethodInvoker_InvokeBegin_Integration /// Callback argument /// State argument /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, object instanceArg, object[] inputs, AsyncCallback callback, object state) + internal static CallTargetState OnMethodBegin(TTarget instance, object instanceArg, object[] inputs, AsyncCallback callback, object state) { // TODO Just use the OperationContext.Current object to get the span information // context.IncomingMessageHeaders contains: diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/AsyncMethodInvoker_InvokeEnd_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/AsyncMethodInvoker_InvokeEnd_Integration.cs index a425429a8..b8c8e1407 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/AsyncMethodInvoker_InvokeEnd_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/AsyncMethodInvoker_InvokeEnd_Integration.cs @@ -6,9 +6,7 @@ #if NETFRAMEWORK using System; using System.ComponentModel; -using System.Reflection; using Datadog.Trace.ClrProfiler.CallTarget; -using Datadog.Trace.Configuration; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Wcf { @@ -38,9 +36,9 @@ public class AsyncMethodInvoker_InvokeEnd_Integration /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { - var scope = Tracer.Instance.ActiveScope; + var scope = Tracer.Instance.InternalActiveScope; scope.DisposeWithException(exception); return new CallTargetReturn(returnValue); } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/ChannelHandlerIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/ChannelHandlerIntegration.cs index c5921d168..18428f7fd 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/ChannelHandlerIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/ChannelHandlerIntegration.cs @@ -7,17 +7,8 @@ #if NETFRAMEWORK using System; -using System.Collections.Generic; using System.ComponentModel; -using System.Linq; -using System.Net; using Datadog.Trace.ClrProfiler.CallTarget; -using Datadog.Trace.ClrProfiler.Emit; -using Datadog.Trace.Configuration; -using Datadog.Trace.ExtensionMethods; -using Datadog.Trace.Logging; -using Datadog.Trace.Propagation; -using Datadog.Trace.Tagging; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Wcf { @@ -49,7 +40,7 @@ public class ChannelHandlerIntegration /// RequestContext instance /// OperationContext instance /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, TRequestContext request, TOperationContext currentOperationContext) + internal static CallTargetState OnMethodBegin(TTarget instance, TRequestContext request, TOperationContext currentOperationContext) { if (Tracer.Instance.Settings.DelayWcfInstrumentationEnabled) { @@ -69,7 +60,7 @@ public static CallTargetState OnMethodBeginException instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return new CallTargetReturn(returnValue); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/SyncMethodInvokerIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/SyncMethodInvokerIntegration.cs index 5372cca58..1d0617516 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/SyncMethodInvokerIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/SyncMethodInvokerIntegration.cs @@ -6,10 +6,8 @@ #if NETFRAMEWORK using System; using System.ComponentModel; -using System.Reflection; using Datadog.Trace.ClrProfiler.CallTarget; using Datadog.Trace.ClrProfiler.Emit; -using Datadog.Trace.Configuration; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Wcf { @@ -38,7 +36,7 @@ public class SyncMethodInvokerIntegration /// Input arguments /// Output arguments /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, object instanceArg, object[] inputs, ref object[] outputs) + internal static CallTargetState OnMethodBegin(TTarget instance, object instanceArg, object[] inputs, ref object[] outputs) { // TODO Just use the OperationContext.Current object to get the span information // context.IncomingMessageHeaders contains: @@ -66,7 +64,7 @@ public static CallTargetState OnMethodBegin(TTarget instance, object in /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) + internal static CallTargetReturn OnMethodEnd(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return new CallTargetReturn(returnValue); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/TaskMethodInvokerIntegration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/TaskMethodInvokerIntegration.cs index 85736cf05..c2981ffb1 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/TaskMethodInvokerIntegration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/TaskMethodInvokerIntegration.cs @@ -6,10 +6,8 @@ #if NETFRAMEWORK using System; using System.ComponentModel; -using System.Reflection; using Datadog.Trace.ClrProfiler.CallTarget; using Datadog.Trace.ClrProfiler.Emit; -using Datadog.Trace.Configuration; namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Wcf { @@ -37,7 +35,7 @@ public class TaskMethodInvokerIntegration /// RequestContext instance /// Input arguments /// Calltarget state value - public static CallTargetState OnMethodBegin(TTarget instance, object instanceArg, object[] inputs) + internal static CallTargetState OnMethodBegin(TTarget instance, object instanceArg, object[] inputs) { // TODO Just use the OperationContext.Current object to get the span information // context.IncomingMessageHeaders contains: @@ -65,7 +63,7 @@ public static CallTargetState OnMethodBegin(TTarget instance, object in /// Exception instance in case the original code threw an exception. /// Calltarget state value /// A response value, in an async scenario will be T of Task of T - public static TResponse OnAsyncMethodEnd(TTarget instance, TResponse returnValue, Exception exception, CallTargetState state) + internal static TResponse OnAsyncMethodEnd(TTarget instance, TResponse returnValue, Exception exception, CallTargetState state) { state.Scope.DisposeWithException(exception); return returnValue; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/WcfCommon.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/WcfCommon.cs index 70f2b02b0..98529fa03 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/WcfCommon.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/WcfCommon.cs @@ -94,7 +94,7 @@ internal static Scope CreateScope(object requestContext) : DefaultOperationName; var tags = new WebTags(); - scope = tracer.StartActiveWithTags(operationName, propagatedContext, tags: tags); + scope = tracer.StartActiveInternal(operationName, propagatedContext, tags: tags); var span = scope.Span; span.LogicScope = DefaultOperationName; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutomaticTracer.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutomaticTracer.cs new file mode 100644 index 000000000..0f802bdae --- /dev/null +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutomaticTracer.cs @@ -0,0 +1,125 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +// Modified by Splunk Inc. + +using System; +using System.Collections.Generic; +using System.Threading; +using Datadog.Trace.DuckTyping; +using Datadog.Trace.Logging; + +namespace Datadog.Trace.ClrProfiler +{ + internal class AutomaticTracer : CommonTracer, IAutomaticTracer, IDistributedTracer + { + private static readonly AsyncLocal> DistributedTrace = new(); + private static readonly IDatadogLogger Log = DatadogLogging.GetLoggerFor(typeof(AutomaticTracer)); + + private static string _runtimeId; + + private ICommonTracer _child; + + bool IDistributedTracer.IsChildTracer => false; + + IReadOnlyDictionary IDistributedTracer.GetSpanContextRaw() + { + if (_child is null) + { + return null; + } + else + { + return DistributedTrace.Value; + } + } + + IScope IDistributedTracer.GetActiveScope() + { + // The automatic tracer doesn't need to get the manual active trace + return null; + } + + SpanContext IDistributedTracer.GetSpanContext() + { + if (_child is null) + { + return null; + } + + var value = DistributedTrace.Value; + + if (value is SpanContext spanContext) + { + return spanContext; + } + + return Tracer.Instance.TracerManager.Propagator.Extract(value, (headers, key) => new List { headers[key] }); + } + + void IDistributedTracer.SetSpanContext(IReadOnlyDictionary value) + { + // This is a performance optimization. See comment in GetDistributedTrace() about potential race condition + if (_child != null) + { + DistributedTrace.Value = value; + } + } + + SamplingPriority? IDistributedTracer.GetSamplingPriority() + { + return (SamplingPriority?)_child?.GetSamplingPriority(); + } + + void IDistributedTracer.SetSamplingPriority(SamplingPriority? samplingPriority) + { + _child?.SetSamplingPriority((int?)samplingPriority); + } + + string IDistributedTracer.GetRuntimeId() => GetAutomaticRuntimeId(); + + public object GetAutomaticActiveScope() + { + return Tracer.Instance.InternalActiveScope; + } + + /// + /// Gets the internal distributed trace object + /// + /// Shared distributed trace object instance + public IReadOnlyDictionary GetDistributedTrace() + { + // There is a subtle race condition: + // in a server application, the automated instrumentation can be loaded first (to process the incoming request) + // In that case, IDistributedTracer.SetSpanContext will do nothing because the child tracer is not initialized yet. + // Then manual instrumentation is loaded, and DistributedTrace.Value does not contain the parent trace. + // To fix this, if DistributedTrace.Value is null, we also check if there's an active scope just in case. + // This is a compromise: we add an additional asynclocal read for the manual tracer when there is no parent trace, + // but it allows us to remove the asynclocal write for the automatic tracer when running without manual instrumentation. + + return DistributedTrace.Value ?? Tracer.Instance.InternalActiveScope?.Span?.Context; + } + + /// + /// Sets the internal distributed trace object + /// + /// Shared distributed trace object instance + public void SetDistributedTrace(IReadOnlyDictionary value) + { + if (_child != null) + { + DistributedTrace.Value = value; + } + } + + public void Register(object manualTracer) + { + Log.Information("Registering {child} as child tracer", manualTracer.GetType()); + _child = manualTracer.DuckCast(); + } + + public string GetAutomaticRuntimeId() => LazyInitializer.EnsureInitialized(ref _runtimeId, () => Guid.NewGuid().ToString()); + } +} diff --git a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/CallTargetInvoker.cs b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/CallTargetInvoker.cs index 782a08f71..0876e8608 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/CallTargetInvoker.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/CallTargetInvoker.cs @@ -5,10 +5,8 @@ using System; using System.ComponentModel; -using System.Diagnostics; using System.Runtime.CompilerServices; using Datadog.Trace.ClrProfiler.CallTarget.Handlers; -using Datadog.Trace.Util; namespace Datadog.Trace.ClrProfiler.CallTarget { diff --git a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/CallTargetState.cs b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/CallTargetState.cs index b684cbb1d..f3392d9f9 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/CallTargetState.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/CallTargetState.cs @@ -4,6 +4,7 @@ // using System; +using System.Collections.Generic; using System.ComponentModel; using System.Runtime.CompilerServices; @@ -21,16 +22,19 @@ public readonly struct CallTargetState private readonly object _state; private readonly DateTimeOffset? _startTime; + private readonly IReadOnlyDictionary _previousDistributedSpanContext; + /// /// Initializes a new instance of the struct. /// /// Scope instance - public CallTargetState(Scope scope) + internal CallTargetState(Scope scope) { _previousScope = null; _scope = scope; _state = null; _startTime = null; + _previousDistributedSpanContext = null; } /// @@ -38,12 +42,13 @@ public CallTargetState(Scope scope) /// /// Scope instance /// Object state instance - public CallTargetState(Scope scope, object state) + internal CallTargetState(Scope scope, object state) { _previousScope = null; _scope = scope; _state = state; _startTime = null; + _previousDistributedSpanContext = null; } /// @@ -52,26 +57,28 @@ public CallTargetState(Scope scope, object state) /// Scope instance /// Object state instance /// The intended start time of the scope, intended for scopes created in the OnMethodEnd handler - public CallTargetState(Scope scope, object state, DateTimeOffset? startTime) + internal CallTargetState(Scope scope, object state, DateTimeOffset? startTime) { _previousScope = null; _scope = scope; _state = state; _startTime = startTime; + _previousDistributedSpanContext = null; } - internal CallTargetState(Scope previousScope, CallTargetState state) + internal CallTargetState(Scope previousScope, IReadOnlyDictionary previousDistributedSpanContext, CallTargetState state) { _previousScope = previousScope; _scope = state._scope; _state = state._state; _startTime = state._startTime; + _previousDistributedSpanContext = previousDistributedSpanContext; } /// /// Gets the CallTarget BeginMethod scope /// - public Scope Scope => _scope; + internal Scope Scope => _scope; /// /// Gets the CallTarget BeginMethod state @@ -85,6 +92,8 @@ internal CallTargetState(Scope previousScope, CallTargetState state) internal Scope PreviousScope => _previousScope; + internal IReadOnlyDictionary PreviousDistributedSpanContext => _previousDistributedSpanContext; + /// /// Gets the default call target state (used by the native side to initialize the locals) /// diff --git a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler.cs b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler.cs index 2c34fa586..1476223d2 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler.cs @@ -42,7 +42,7 @@ static BeginMethodHandler() [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static CallTargetState Invoke(TTarget instance) { - return new CallTargetState(Tracer.Instance.ActiveScope, _invokeDelegate(instance)); + return new CallTargetState(Tracer.Instance.InternalActiveScope, Tracer.Instance.DistributedSpanContext, _invokeDelegate(instance)); } } } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`1.cs b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`1.cs index b447b2fef..5ffab8cc1 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`1.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`1.cs @@ -43,7 +43,7 @@ static BeginMethodHandler() [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static CallTargetState Invoke(TTarget instance, ref TArg1 arg1) { - return new CallTargetState(Tracer.Instance.ActiveScope, _invokeDelegate(instance, ref arg1)); + return new CallTargetState(Tracer.Instance.InternalActiveScope, Tracer.Instance.DistributedSpanContext, _invokeDelegate(instance, ref arg1)); } } } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`2.cs b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`2.cs index f284a9e31..35320e60e 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`2.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`2.cs @@ -44,7 +44,7 @@ static BeginMethodHandler() [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static CallTargetState Invoke(TTarget instance, ref TArg1 arg1, ref TArg2 arg2) { - return new CallTargetState(Tracer.Instance.ActiveScope, _invokeDelegate(instance, ref arg1, ref arg2)); + return new CallTargetState(Tracer.Instance.InternalActiveScope, Tracer.Instance.DistributedSpanContext, _invokeDelegate(instance, ref arg1, ref arg2)); } } } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`3.cs b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`3.cs index 31b7d3d97..dc9d95818 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`3.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`3.cs @@ -45,7 +45,7 @@ static BeginMethodHandler() [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static CallTargetState Invoke(TTarget instance, ref TArg1 arg1, ref TArg2 arg2, ref TArg3 arg3) { - return new CallTargetState(Tracer.Instance.ActiveScope, _invokeDelegate(instance, ref arg1, ref arg2, ref arg3)); + return new CallTargetState(Tracer.Instance.InternalActiveScope, Tracer.Instance.DistributedSpanContext, _invokeDelegate(instance, ref arg1, ref arg2, ref arg3)); } } } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`4.cs b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`4.cs index 7aa635e92..4f1d27a26 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`4.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`4.cs @@ -46,7 +46,7 @@ static BeginMethodHandler() [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static CallTargetState Invoke(TTarget instance, ref TArg1 arg1, ref TArg2 arg2, ref TArg3 arg3, ref TArg4 arg4) { - return new CallTargetState(Tracer.Instance.ActiveScope, _invokeDelegate(instance, ref arg1, ref arg2, ref arg3, ref arg4)); + return new CallTargetState(Tracer.Instance.InternalActiveScope, Tracer.Instance.DistributedSpanContext, _invokeDelegate(instance, ref arg1, ref arg2, ref arg3, ref arg4)); } } } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`5.cs b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`5.cs index a3f7f07e8..437ff2ed2 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`5.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`5.cs @@ -47,7 +47,7 @@ static BeginMethodHandler() [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static CallTargetState Invoke(TTarget instance, ref TArg1 arg1, ref TArg2 arg2, ref TArg3 arg3, ref TArg4 arg4, ref TArg5 arg5) { - return new CallTargetState(Tracer.Instance.ActiveScope, _invokeDelegate(instance, ref arg1, ref arg2, ref arg3, ref arg4, ref arg5)); + return new CallTargetState(Tracer.Instance.InternalActiveScope, Tracer.Instance.DistributedSpanContext, _invokeDelegate(instance, ref arg1, ref arg2, ref arg3, ref arg4, ref arg5)); } } } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`6.cs b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`6.cs index 7845aed39..004718e24 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`6.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`6.cs @@ -48,7 +48,7 @@ static BeginMethodHandler() [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static CallTargetState Invoke(TTarget instance, ref TArg1 arg1, ref TArg2 arg2, ref TArg3 arg3, ref TArg4 arg4, ref TArg5 arg5, ref TArg6 arg6) { - return new CallTargetState(Tracer.Instance.ActiveScope, _invokeDelegate(instance, ref arg1, ref arg2, ref arg3, ref arg4, ref arg5, ref arg6)); + return new CallTargetState(Tracer.Instance.InternalActiveScope, Tracer.Instance.DistributedSpanContext, _invokeDelegate(instance, ref arg1, ref arg2, ref arg3, ref arg4, ref arg5, ref arg6)); } } } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`7.cs b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`7.cs index 6b6b5015e..41b189717 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`7.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`7.cs @@ -49,7 +49,7 @@ static BeginMethodHandler() [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static CallTargetState Invoke(TTarget instance, ref TArg1 arg1, ref TArg2 arg2, ref TArg3 arg3, ref TArg4 arg4, ref TArg5 arg5, ref TArg6 arg6, ref TArg7 arg7) { - return new CallTargetState(Tracer.Instance.ActiveScope, _invokeDelegate(instance, ref arg1, ref arg2, ref arg3, ref arg4, ref arg5, ref arg6, ref arg7)); + return new CallTargetState(Tracer.Instance.InternalActiveScope, Tracer.Instance.DistributedSpanContext, _invokeDelegate(instance, ref arg1, ref arg2, ref arg3, ref arg4, ref arg5, ref arg6, ref arg7)); } } } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`8.cs b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`8.cs index afad7304c..08664d3fc 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`8.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodHandler`8.cs @@ -50,7 +50,7 @@ static BeginMethodHandler() [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static CallTargetState Invoke(TTarget instance, ref TArg1 arg1, ref TArg2 arg2, ref TArg3 arg3, ref TArg4 arg4, ref TArg5 arg5, ref TArg6 arg6, ref TArg7 arg7, ref TArg8 arg8) { - return new CallTargetState(Tracer.Instance.ActiveScope, _invokeDelegate(instance, ref arg1, ref arg2, ref arg3, ref arg4, ref arg5, ref arg6, ref arg7, ref arg8)); + return new CallTargetState(Tracer.Instance.InternalActiveScope, Tracer.Instance.DistributedSpanContext, _invokeDelegate(instance, ref arg1, ref arg2, ref arg3, ref arg4, ref arg5, ref arg6, ref arg7, ref arg8)); } } } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodSlowHandler.cs b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodSlowHandler.cs index 4f56300c7..4a9716aeb 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodSlowHandler.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/BeginMethodSlowHandler.cs @@ -41,7 +41,7 @@ static BeginMethodSlowHandler() [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static CallTargetState Invoke(TTarget instance, object[] arguments) { - return new CallTargetState(Tracer.Instance.ActiveScope, _invokeDelegate(instance, arguments)); + return new CallTargetState(Tracer.Instance.InternalActiveScope, Tracer.Instance.DistributedSpanContext, _invokeDelegate(instance, arguments)); } } } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/EndMethodHandler`1.cs b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/EndMethodHandler`1.cs index d2f5d654e..6c67bfc42 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/EndMethodHandler`1.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/EndMethodHandler`1.cs @@ -75,11 +75,12 @@ internal static CallTargetReturn Invoke(TTarget instance, TReturn retur { returnValue = _continuationGenerator.SetContinuation(instance, returnValue, exception, state); - // Restore previous scope if there is a continuation + // Restore previous scope and the previous DistributedTrace if there is a continuation // This is used to mimic the ExecutionContext copy from the StateMachine - if (((IDatadogTracer)Tracer.Instance).ScopeManager is IScopeRawAccess rawAccess) + if (Tracer.Instance.ScopeManager is IScopeRawAccess rawAccess) { rawAccess.Active = state.PreviousScope; + DistributedTracer.Instance.SetSpanContext(state.PreviousDistributedSpanContext); } } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/IntegrationMapper.cs b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/IntegrationMapper.cs index 136dcb26b..637876657 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/IntegrationMapper.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/CallTarget/Handlers/IntegrationMapper.cs @@ -11,6 +11,7 @@ using Datadog.Trace.DuckTyping; using Datadog.Trace.ExtensionMethods; using Datadog.Trace.Logging; +using Datadog.Trace.Util; namespace Datadog.Trace.ClrProfiler.CallTarget.Handlers { @@ -49,27 +50,27 @@ internal static DynamicMethod CreateBeginMethodDelegate(Type integrationType, Ty if (onMethodBeginMethodInfo.ReturnType != typeof(CallTargetState)) { - throw new ArgumentException($"The return type of the method: {BeginMethodName} in type: {integrationType.FullName} is not {nameof(CallTargetState)}"); + ThrowHelper.ThrowArgumentException($"The return type of the method: {BeginMethodName} in type: {integrationType.FullName} is not {nameof(CallTargetState)}"); } Type[] genericArgumentsTypes = onMethodBeginMethodInfo.GetGenericArguments(); if (genericArgumentsTypes.Length < 1) { - throw new ArgumentException($"The method: {BeginMethodName} in type: {integrationType.FullName} doesn't have the generic type for the instance type."); + ThrowHelper.ThrowArgumentException($"The method: {BeginMethodName} in type: {integrationType.FullName} doesn't have the generic type for the instance type."); } ParameterInfo[] onMethodBeginParameters = onMethodBeginMethodInfo.GetParameters(); if (onMethodBeginParameters.Length < argumentsTypes.Length) { - throw new ArgumentException($"The method: {BeginMethodName} with {onMethodBeginParameters.Length} parameters in type: {integrationType.FullName} has less parameters than required."); + ThrowHelper.ThrowArgumentException($"The method: {BeginMethodName} with {onMethodBeginParameters.Length} parameters in type: {integrationType.FullName} has less parameters than required."); } else if (onMethodBeginParameters.Length > argumentsTypes.Length + 1) { - throw new ArgumentException($"The method: {BeginMethodName} with {onMethodBeginParameters.Length} parameters in type: {integrationType.FullName} has more parameters than required."); + ThrowHelper.ThrowArgumentException($"The method: {BeginMethodName} with {onMethodBeginParameters.Length} parameters in type: {integrationType.FullName} has more parameters than required."); } else if (onMethodBeginParameters.Length != argumentsTypes.Length && onMethodBeginParameters[0].ParameterType != genericArgumentsTypes[0]) { - throw new ArgumentException($"The first generic argument for method: {BeginMethodName} in type: {integrationType.FullName} must be the same as the first parameter for the instance value."); + ThrowHelper.ThrowArgumentException($"The first generic argument for method: {BeginMethodName} in type: {integrationType.FullName} must be the same as the first parameter for the instance value."); } List callGenericTypes = new List(); @@ -143,7 +144,7 @@ internal static DynamicMethod CreateBeginMethodDelegate(Type integrationType, Ty } else { - throw new InvalidCastException($"DuckType constraints cannot be used in ByRef arguments. ({targetParameterTypeConstraint})"); + ThrowHelper.ThrowInvalidCastException($"DuckType constraints cannot be used in ByRef arguments. ({targetParameterTypeConstraint})"); } } else @@ -153,7 +154,7 @@ internal static DynamicMethod CreateBeginMethodDelegate(Type integrationType, Ty if (!trgParameterType.IsAssignableFrom(srcParameterType) && (!(srcParameterType.IsEnum && trgParameterType.IsEnum))) { - throw new InvalidCastException($"The target parameter {targetParameterType} can't be assigned from {sourceParameterType}"); + ThrowHelper.ThrowInvalidCastException($"The target parameter {targetParameterType} can't be assigned from {sourceParameterType}"); } } @@ -174,7 +175,7 @@ internal static DynamicMethod CreateBeginMethodDelegate(Type integrationType, Ty } else { - throw new InvalidCastException($"DuckType constraints is not supported on ByRef parameters. The target parameter {targetParameterType} can't be assigned from {sourceParameterType}"); + ThrowHelper.ThrowInvalidCastException($"DuckType constraints is not supported on ByRef parameters. The target parameter {targetParameterType} can't be assigned from {sourceParameterType}"); } } @@ -212,13 +213,13 @@ internal static DynamicMethod CreateSlowBeginMethodDelegate(Type integrationType if (onMethodBeginMethodInfo.ReturnType != typeof(CallTargetState)) { - throw new ArgumentException($"The return type of the method: {BeginMethodName} in type: {integrationType.FullName} is not {nameof(CallTargetState)}"); + ThrowHelper.ThrowArgumentException($"The return type of the method: {BeginMethodName} in type: {integrationType.FullName} is not {nameof(CallTargetState)}"); } Type[] genericArgumentsTypes = onMethodBeginMethodInfo.GetGenericArguments(); if (genericArgumentsTypes.Length < 1) { - throw new ArgumentException($"The method: {BeginMethodName} in type: {integrationType.FullName} doesn't have the generic type for the instance type."); + ThrowHelper.ThrowArgumentException($"The method: {BeginMethodName} in type: {integrationType.FullName} doesn't have the generic type for the instance type."); } ParameterInfo[] onMethodBeginParameters = onMethodBeginMethodInfo.GetParameters(); @@ -324,33 +325,33 @@ internal static DynamicMethod CreateEndMethodDelegate(Type integrationType, Type if (onMethodEndMethodInfo.ReturnType != typeof(CallTargetReturn)) { - throw new ArgumentException($"The return type of the method: {EndMethodName} in type: {integrationType.FullName} is not {nameof(CallTargetReturn)}"); + ThrowHelper.ThrowArgumentException($"The return type of the method: {EndMethodName} in type: {integrationType.FullName} is not {nameof(CallTargetReturn)}"); } Type[] genericArgumentsTypes = onMethodEndMethodInfo.GetGenericArguments(); if (genericArgumentsTypes.Length != 1) { - throw new ArgumentException($"The method: {EndMethodName} in type: {integrationType.FullName} must have a single generic type for the instance type."); + ThrowHelper.ThrowArgumentException($"The method: {EndMethodName} in type: {integrationType.FullName} must have a single generic type for the instance type."); } ParameterInfo[] onMethodEndParameters = onMethodEndMethodInfo.GetParameters(); if (onMethodEndParameters.Length < 2) { - throw new ArgumentException($"The method: {EndMethodName} with {onMethodEndParameters.Length} parameters in type: {integrationType.FullName} has less parameters than required."); + ThrowHelper.ThrowArgumentException($"The method: {EndMethodName} with {onMethodEndParameters.Length} parameters in type: {integrationType.FullName} has less parameters than required."); } else if (onMethodEndParameters.Length > 3) { - throw new ArgumentException($"The method: {EndMethodName} with {onMethodEndParameters.Length} parameters in type: {integrationType.FullName} has more parameters than required."); + ThrowHelper.ThrowArgumentException($"The method: {EndMethodName} with {onMethodEndParameters.Length} parameters in type: {integrationType.FullName} has more parameters than required."); } if (onMethodEndParameters[onMethodEndParameters.Length - 2].ParameterType != typeof(Exception)) { - throw new ArgumentException($"The Exception type parameter of the method: {EndMethodName} in type: {integrationType.FullName} is missing."); + ThrowHelper.ThrowArgumentException($"The Exception type parameter of the method: {EndMethodName} in type: {integrationType.FullName} is missing."); } if (onMethodEndParameters[onMethodEndParameters.Length - 1].ParameterType != typeof(CallTargetState)) { - throw new ArgumentException($"The CallTargetState type parameter of the method: {EndMethodName} in type: {integrationType.FullName} is missing."); + ThrowHelper.ThrowArgumentException($"The CallTargetState type parameter of the method: {EndMethodName} in type: {integrationType.FullName} is missing."); } List callGenericTypes = new List(); @@ -426,33 +427,33 @@ internal static DynamicMethod CreateEndMethodDelegate(Type integrationType, Type if (onMethodEndMethodInfo.ReturnType.GetGenericTypeDefinition() != typeof(CallTargetReturn<>)) { - throw new ArgumentException($"The return type of the method: {EndMethodName} in type: {integrationType.FullName} is not {nameof(CallTargetReturn)}"); + ThrowHelper.ThrowArgumentException($"The return type of the method: {EndMethodName} in type: {integrationType.FullName} is not {nameof(CallTargetReturn)}"); } Type[] genericArgumentsTypes = onMethodEndMethodInfo.GetGenericArguments(); if (genericArgumentsTypes.Length < 1 || genericArgumentsTypes.Length > 2) { - throw new ArgumentException($"The method: {EndMethodName} in type: {integrationType.FullName} must have the generic type for the instance type."); + ThrowHelper.ThrowArgumentException($"The method: {EndMethodName} in type: {integrationType.FullName} must have the generic type for the instance type."); } ParameterInfo[] onMethodEndParameters = onMethodEndMethodInfo.GetParameters(); if (onMethodEndParameters.Length < 3) { - throw new ArgumentException($"The method: {EndMethodName} with {onMethodEndParameters.Length} parameters in type: {integrationType.FullName} has less parameters than required."); + ThrowHelper.ThrowArgumentException($"The method: {EndMethodName} with {onMethodEndParameters.Length} parameters in type: {integrationType.FullName} has less parameters than required."); } else if (onMethodEndParameters.Length > 4) { - throw new ArgumentException($"The method: {EndMethodName} with {onMethodEndParameters.Length} parameters in type: {integrationType.FullName} has more parameters than required."); + ThrowHelper.ThrowArgumentException($"The method: {EndMethodName} with {onMethodEndParameters.Length} parameters in type: {integrationType.FullName} has more parameters than required."); } if (onMethodEndParameters[onMethodEndParameters.Length - 2].ParameterType != typeof(Exception)) { - throw new ArgumentException($"The Exception type parameter of the method: {EndMethodName} in type: {integrationType.FullName} is missing."); + ThrowHelper.ThrowArgumentException($"The Exception type parameter of the method: {EndMethodName} in type: {integrationType.FullName} is missing."); } if (onMethodEndParameters[onMethodEndParameters.Length - 1].ParameterType != typeof(CallTargetState)) { - throw new ArgumentException($"The CallTargetState type parameter of the method: {EndMethodName} in type: {integrationType.FullName} is missing."); + ThrowHelper.ThrowArgumentException($"The CallTargetState type parameter of the method: {EndMethodName} in type: {integrationType.FullName} is missing."); } List callGenericTypes = new List(); @@ -494,7 +495,7 @@ internal static DynamicMethod CreateEndMethodDelegate(Type integrationType, Type } else if (onMethodEndParameters[returnParameterIndex].ParameterType != returnType) { - throw new ArgumentException($"The ReturnValue type parameter of the method: {EndMethodName} in type: {integrationType.FullName} is invalid. [{onMethodEndParameters[returnParameterIndex].ParameterType} != {returnType}]"); + ThrowHelper.ThrowArgumentException($"The ReturnValue type parameter of the method: {EndMethodName} in type: {integrationType.FullName} is invalid. [{onMethodEndParameters[returnParameterIndex].ParameterType} != {returnType}]"); } DynamicMethod callMethod = new DynamicMethod( @@ -570,33 +571,33 @@ internal static CreateAsyncEndMethodResult CreateAsyncEndMethodDelegate(Type int if (!onAsyncMethodEndMethodInfo.ReturnType.IsGenericParameter && onAsyncMethodEndMethodInfo.ReturnType != returnType) { - throw new ArgumentException($"The return type of the method: {EndAsyncMethodName} in type: {integrationType.FullName} is not {returnType}"); + ThrowHelper.ThrowArgumentException($"The return type of the method: {EndAsyncMethodName} in type: {integrationType.FullName} is not {returnType}"); } Type[] genericArgumentsTypes = onAsyncMethodEndMethodInfo.GetGenericArguments(); if (genericArgumentsTypes.Length < 1 || genericArgumentsTypes.Length > 2) { - throw new ArgumentException($"The method: {EndAsyncMethodName} in type: {integrationType.FullName} must have the generic type for the instance type."); + ThrowHelper.ThrowArgumentException($"The method: {EndAsyncMethodName} in type: {integrationType.FullName} must have the generic type for the instance type."); } ParameterInfo[] onAsyncMethodEndParameters = onAsyncMethodEndMethodInfo.GetParameters(); if (onAsyncMethodEndParameters.Length < 3) { - throw new ArgumentException($"The method: {EndAsyncMethodName} with {onAsyncMethodEndParameters.Length} parameters in type: {integrationType.FullName} has less parameters than required."); + ThrowHelper.ThrowArgumentException($"The method: {EndAsyncMethodName} with {onAsyncMethodEndParameters.Length} parameters in type: {integrationType.FullName} has less parameters than required."); } else if (onAsyncMethodEndParameters.Length > 4) { - throw new ArgumentException($"The method: {EndAsyncMethodName} with {onAsyncMethodEndParameters.Length} parameters in type: {integrationType.FullName} has more parameters than required."); + ThrowHelper.ThrowArgumentException($"The method: {EndAsyncMethodName} with {onAsyncMethodEndParameters.Length} parameters in type: {integrationType.FullName} has more parameters than required."); } if (onAsyncMethodEndParameters[onAsyncMethodEndParameters.Length - 2].ParameterType != typeof(Exception)) { - throw new ArgumentException($"The Exception type parameter of the method: {EndAsyncMethodName} in type: {integrationType.FullName} is missing."); + ThrowHelper.ThrowArgumentException($"The Exception type parameter of the method: {EndAsyncMethodName} in type: {integrationType.FullName} is missing."); } if (onAsyncMethodEndParameters[onAsyncMethodEndParameters.Length - 1].ParameterType != typeof(CallTargetState)) { - throw new ArgumentException($"The CallTargetState type parameter of the method: {EndAsyncMethodName} in type: {integrationType.FullName} is missing."); + ThrowHelper.ThrowArgumentException($"The CallTargetState type parameter of the method: {EndAsyncMethodName} in type: {integrationType.FullName} is missing."); } bool preserveContext = onAsyncMethodEndMethodInfo.GetCustomAttribute() != null; @@ -640,7 +641,7 @@ internal static CreateAsyncEndMethodResult CreateAsyncEndMethodDelegate(Type int } else if (onAsyncMethodEndParameters[returnParameterIndex].ParameterType != returnType) { - throw new ArgumentException($"The ReturnValue type parameter of the method: {EndAsyncMethodName} in type: {integrationType.FullName} is invalid. [{onAsyncMethodEndParameters[returnParameterIndex].ParameterType} != {returnType}]"); + ThrowHelper.ThrowArgumentException($"The ReturnValue type parameter of the method: {EndAsyncMethodName} in type: {integrationType.FullName} is invalid. [{onAsyncMethodEndParameters[returnParameterIndex].ParameterType} != {returnType}]"); } DynamicMethod callMethod = new DynamicMethod( diff --git a/tracer/src/Datadog.Trace/ClrProfiler/ClrNames.cs b/tracer/src/Datadog.Trace/ClrProfiler/ClrNames.cs index c17ac50f1..03baa216e 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/ClrNames.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/ClrNames.cs @@ -45,5 +45,7 @@ internal static class ClrNames public const string GenericParameterTask = "System.Threading.Tasks.Task`1"; public const string ObjectTask = "System.Threading.Tasks.Task`1"; public const string Int32Task = "System.Threading.Tasks.Task`1"; + + public const string Type = "System.Type"; } } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/CommonTracer.cs b/tracer/src/Datadog.Trace/ClrProfiler/CommonTracer.cs new file mode 100644 index 000000000..2c1b1aa3c --- /dev/null +++ b/tracer/src/Datadog.Trace/ClrProfiler/CommonTracer.cs @@ -0,0 +1,29 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +namespace Datadog.Trace.ClrProfiler +{ + /// + /// This class contains methods implemented by both the automatic and manual tracer. + /// It is used for duplex communication. + /// + internal abstract class CommonTracer : ICommonTracer + { + public int? GetSamplingPriority() + { + return (int?)Tracer.Instance.InternalActiveScope?.Span.Context?.TraceContext?.SamplingPriority; + } + + public void SetSamplingPriority(int? samplingPriority) + { + var traceContext = Tracer.Instance.InternalActiveScope?.Span.Context?.TraceContext; + + if (traceContext != null) + { + traceContext.SetSamplingPriority((SamplingPriority?)samplingPriority, notifyDistributedTracer: false); + } + } + } +} diff --git a/tracer/src/Datadog.Trace/ClrProfiler/DistributedTracer.cs b/tracer/src/Datadog.Trace/ClrProfiler/DistributedTracer.cs new file mode 100644 index 000000000..d6db5768d --- /dev/null +++ b/tracer/src/Datadog.Trace/ClrProfiler/DistributedTracer.cs @@ -0,0 +1,66 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using System; +using System.ComponentModel; +using Datadog.Trace.DuckTyping; +using Datadog.Trace.Logging; + +namespace Datadog.Trace.ClrProfiler +{ + /// + /// Used to distribute traces across multiple versions of the tracer + /// + [Browsable(false)] + [EditorBrowsable(EditorBrowsableState.Never)] + public static class DistributedTracer + { + private static readonly IDatadogLogger Log = DatadogLogging.GetLoggerFor(typeof(DistributedTracer)); + + static DistributedTracer() + { + try + { + var parent = GetDistributedTracer(); + + if (parent == null) + { + Log.Information("Building automatic tracer"); + Instance = new AutomaticTracer(); + } + else + { + var parentTracer = parent.DuckCast(); + + Log.Information("Building manual tracer, connected to {assembly}", parent.GetType().Assembly); + + Instance = new ManualTracer(parentTracer); + } + } + catch (Exception ex) + { + Log.Error(ex, "Error while building the tracer, falling back to automatic"); + Instance = new AutomaticTracer(); + } + } + + internal static IDistributedTracer Instance { get; private set; } + + /// + /// Get the instance of IDistributedTracer. This method will be rewritten by the profiler. + /// + /// Don't ever change the return type of this method, + /// as this would require special handling by the profiler. + /// The instance of IDistributedTracer + [Browsable(false)] + [EditorBrowsable(EditorBrowsableState.Never)] + public static object GetDistributedTracer() => Instance; + + internal static void SetInstanceOnlyForTests(IDistributedTracer instance) + { + Instance = instance; + } + } +} diff --git a/tracer/src/Datadog.Trace/ClrProfiler/Emit/DelegateMetadata.cs b/tracer/src/Datadog.Trace/ClrProfiler/Emit/DelegateMetadata.cs index 71647c2b1..ba7792311 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/Emit/DelegateMetadata.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/Emit/DelegateMetadata.cs @@ -4,6 +4,7 @@ // using System; +using Datadog.Trace.Util; namespace Datadog.Trace.ClrProfiler.Emit { @@ -23,8 +24,8 @@ public static DelegateMetadata Create() Type delegateType = typeof(TDelegate); Type[] genericTypeArguments = delegateType.GenericTypeArguments; - Type[] parameterTypes; - Type returnType; + Type[] parameterTypes = null; + Type returnType = null; if (delegateType.Name.StartsWith("Func`")) { @@ -42,7 +43,7 @@ public static DelegateMetadata Create() } else { - throw new Exception($"Only Func<> or Action<> are supported in {nameof(DelegateMetadata)}."); + ThrowHelper.ThrowException($"Only Func<> or Action<> are supported in {nameof(DelegateMetadata)}."); } return new DelegateMetadata() diff --git a/tracer/src/Datadog.Trace/ClrProfiler/Emit/DynamicMethodBuilder.cs b/tracer/src/Datadog.Trace/ClrProfiler/Emit/DynamicMethodBuilder.cs index eb43aa3f3..b0579ce6b 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/Emit/DynamicMethodBuilder.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/Emit/DynamicMethodBuilder.cs @@ -10,6 +10,7 @@ using System.Linq; using System.Reflection; using System.Reflection.Emit; +using Datadog.Trace.Util; namespace Datadog.Trace.ClrProfiler.Emit { @@ -71,8 +72,8 @@ public static TDelegate CreateMethodCallDelegate( Type delegateType = typeof(TDelegate); Type[] genericTypeArguments = delegateType.GenericTypeArguments; - Type[] parameterTypes; - Type returnType; + Type[] parameterTypes = null; + Type returnType = null; if (delegateType.Name.StartsWith("Func`")) { @@ -90,7 +91,7 @@ public static TDelegate CreateMethodCallDelegate( } else { - throw new Exception($"Only Func<> or Action<> are supported in {nameof(CreateMethodCallDelegate)}."); + ThrowHelper.ThrowException($"Only Func<> or Action<> are supported in {nameof(CreateMethodCallDelegate)}."); } // find any method that matches by name and parameter types @@ -213,7 +214,7 @@ public static TDelegate CreateMethodCallDelegate( } else { - throw new NotSupportedException($"OpCode {callOpCode} not supported when calling a method."); + ThrowHelper.ThrowNotSupportedException($"OpCode {callOpCode} not supported when calling a method."); } if (methodInfo.ReturnType.IsValueType && !returnType.IsValueType) @@ -222,11 +223,11 @@ public static TDelegate CreateMethodCallDelegate( } else if (methodInfo.ReturnType.IsValueType && returnType.IsValueType && methodInfo.ReturnType != returnType) { - throw new ArgumentException($"Cannot convert the target method's return type {methodInfo.ReturnType.FullName} (valuetype) to the delegate method's return type {returnType.FullName} (valuetype)"); + ThrowHelper.ThrowArgumentException($"Cannot convert the target method's return type {methodInfo.ReturnType.FullName} (valuetype) to the delegate method's return type {returnType.FullName} (valuetype)"); } else if (!methodInfo.ReturnType.IsValueType && returnType.IsValueType) { - throw new ArgumentException($"Cannot reliably convert the target method's return type {methodInfo.ReturnType.FullName} (reference type) to the delegate method's return type {returnType.FullName} (value type)"); + ThrowHelper.ThrowArgumentException($"Cannot reliably convert the target method's return type {methodInfo.ReturnType.FullName} (reference type) to the delegate method's return type {returnType.FullName} (value type)"); } else if (!methodInfo.ReturnType.IsValueType && !returnType.IsValueType && methodInfo.ReturnType != returnType) { diff --git a/tracer/src/Datadog.Trace/ClrProfiler/Emit/MemberResult.cs b/tracer/src/Datadog.Trace/ClrProfiler/Emit/MemberResult.cs index 03cc62795..5cf127453 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/Emit/MemberResult.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/Emit/MemberResult.cs @@ -4,6 +4,7 @@ // using System; +using Datadog.Trace.Util; namespace Datadog.Trace.ClrProfiler.Emit { @@ -24,10 +25,18 @@ public MemberResult(T value) HasValue = true; } - public T Value => - HasValue - ? _value - : throw new InvalidOperationException("Reflected member not found."); + public T Value + { + get + { + if (!HasValue) + { + ThrowHelper.ThrowInvalidOperationException("Reflected member not found."); + } + + return _value; + } + } public T GetValueOrDefault() { diff --git a/tracer/src/Datadog.Trace/ClrProfiler/Emit/ObjectExtensions.cs b/tracer/src/Datadog.Trace/ClrProfiler/Emit/ObjectExtensions.cs index 6657025e4..6171d8de1 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/Emit/ObjectExtensions.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/Emit/ObjectExtensions.cs @@ -293,10 +293,20 @@ public PropertyFetcherCacheKey(Type type1, Type type2, string name) public PropertyFetcherCacheKey(Type type1, Type type2, Type type3, string name) { - Type1 = type1 ?? throw new ArgumentNullException(nameof(type1)); + if (type1 is null) + { + ThrowHelper.ThrowArgumentNullException(nameof(type1)); + } + + if (name is null) + { + ThrowHelper.ThrowArgumentNullException(nameof(name)); + } + + Type1 = type1; Type2 = type2; Type3 = type3; - Name = name ?? throw new ArgumentNullException(nameof(name)); + Name = name; } public bool Equals(PropertyFetcherCacheKey other) diff --git a/tracer/src/Datadog.Trace/ClrProfiler/IAutomaticTracer.cs b/tracer/src/Datadog.Trace/ClrProfiler/IAutomaticTracer.cs new file mode 100644 index 000000000..3de8ef63e --- /dev/null +++ b/tracer/src/Datadog.Trace/ClrProfiler/IAutomaticTracer.cs @@ -0,0 +1,22 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using System.Collections.Generic; + +namespace Datadog.Trace.ClrProfiler +{ + internal interface IAutomaticTracer : ICommonTracer + { + string GetAutomaticRuntimeId(); + + object GetAutomaticActiveScope(); + + IReadOnlyDictionary GetDistributedTrace(); + + void SetDistributedTrace(IReadOnlyDictionary trace); + + void Register(object manualTracer); + } +} diff --git a/tracer/src/Datadog.Trace/ClrProfiler/ICommonTracer.cs b/tracer/src/Datadog.Trace/ClrProfiler/ICommonTracer.cs new file mode 100644 index 000000000..44a45b45f --- /dev/null +++ b/tracer/src/Datadog.Trace/ClrProfiler/ICommonTracer.cs @@ -0,0 +1,14 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +namespace Datadog.Trace.ClrProfiler +{ + internal interface ICommonTracer + { + int? GetSamplingPriority(); + + void SetSamplingPriority(int? samplingPriority); + } +} diff --git a/tracer/src/Datadog.Trace/ClrProfiler/IDistributedTracer.cs b/tracer/src/Datadog.Trace/ClrProfiler/IDistributedTracer.cs new file mode 100644 index 000000000..fcad01231 --- /dev/null +++ b/tracer/src/Datadog.Trace/ClrProfiler/IDistributedTracer.cs @@ -0,0 +1,28 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using System.Collections.Generic; + +namespace Datadog.Trace.ClrProfiler +{ + internal interface IDistributedTracer + { + bool IsChildTracer { get; } + + IReadOnlyDictionary GetSpanContextRaw(); + + SpanContext GetSpanContext(); + + IScope GetActiveScope(); + + void SetSpanContext(IReadOnlyDictionary value); + + SamplingPriority? GetSamplingPriority(); + + void SetSamplingPriority(SamplingPriority? samplingPriority); + + string GetRuntimeId(); + } +} diff --git a/tracer/src/Datadog.Trace/ClrProfiler/InstrumentMethodAttribute.cs b/tracer/src/Datadog.Trace/ClrProfiler/InstrumentMethodAttribute.cs index 6663e0a49..bd2d44ada 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/InstrumentMethodAttribute.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/InstrumentMethodAttribute.cs @@ -5,6 +5,7 @@ using System; using System.ComponentModel; +using Datadog.Trace.Util; namespace Datadog.Trace.ClrProfiler { @@ -32,7 +33,8 @@ public string AssemblyName case 1: return AssemblyNames[0]; default: - throw new NotSupportedException("Multiple assemblies are not supported using this property. Use AssemblyNames property instead."); + ThrowHelper.ThrowNotSupportedException("Multiple assemblies are not supported using this property. Use AssemblyNames property instead."); + return null; } } set => AssemblyNames = new[] { value }; diff --git a/tracer/src/Datadog.Trace/ClrProfiler/InstrumentationDefinitions.Generated.cs b/tracer/src/Datadog.Trace/ClrProfiler/InstrumentationDefinitions.Generated.cs index d77430ff0..6fb95c465 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/InstrumentationDefinitions.Generated.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/InstrumentationDefinitions.Generated.cs @@ -11,101 +11,13 @@ private static NativeCallTargetDefinition[] GetDefinitionsArray() { return new NativeCallTargetDefinition[] { - // - new("Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient.SqlCommand", "ExecuteDbDataReader", new[] { "System.Data.Common.DbDataReader", "System.Data.CommandBehavior" }, 1, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), - new("Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient.SqlCommand", "ExecuteDbDataReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior", "System.Threading.CancellationToken" }, 1, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration"), - new("Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient.SqlCommand", "ExecuteNonQuery", new[] { "System.Int32" }, 1, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryIntegration"), - new("Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient.SqlCommand", "ExecuteNonQueryAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 1, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryAsyncIntegration"), - new("Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient.SqlCommand", "ExecuteReader", new[] { "Microsoft.Data.SqlClient.SqlDataReader" }, 1, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderIntegration"), - new("Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient.SqlCommand", "ExecuteReader", new[] { "Microsoft.Data.SqlClient.SqlDataReader", "System.Data.CommandBehavior" }, 1, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), - new("Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient.SqlCommand", "ExecuteReaderAsync", new[] { "System.Threading.Tasks.Task`1" }, 1, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderAsyncIntegration"), - new("Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient.SqlCommand", "ExecuteReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 1, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithCancellationAsyncIntegration"), - new("Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient.SqlCommand", "ExecuteReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior" }, 1, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAsyncIntegration"), - new("Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient.SqlCommand", "ExecuteReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior", "System.Threading.CancellationToken" }, 1, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration"), - new("Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient.SqlCommand", "ExecuteScalar", new[] { "System.Object" }, 1, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarIntegration"), - new("Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient.SqlCommand", "ExecuteScalarAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 1, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarAsyncIntegration"), - new("Microsoft.Data.Sqlite", "Microsoft.Data.Sqlite.SqliteCommand", "ExecuteDbDataReader", new[] { "System.Data.Common.DbDataReader", "System.Data.CommandBehavior" }, 2, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), - new("Microsoft.Data.Sqlite", "Microsoft.Data.Sqlite.SqliteCommand", "ExecuteDbDataReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior", "System.Threading.CancellationToken" }, 2, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration"), - new("Microsoft.Data.Sqlite", "Microsoft.Data.Sqlite.SqliteCommand", "ExecuteNonQuery", new[] { "System.Int32" }, 2, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryIntegration"), - new("Microsoft.Data.Sqlite", "Microsoft.Data.Sqlite.SqliteCommand", "ExecuteReader", new[] { "Microsoft.Data.Sqlite.SqliteDataReader" }, 2, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderIntegration"), - new("Microsoft.Data.Sqlite", "Microsoft.Data.Sqlite.SqliteCommand", "ExecuteReader", new[] { "Microsoft.Data.Sqlite.SqliteDataReader", "System.Data.CommandBehavior" }, 2, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), - new("Microsoft.Data.Sqlite", "Microsoft.Data.Sqlite.SqliteCommand", "ExecuteReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior", "System.Threading.CancellationToken" }, 2, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration"), - new("Microsoft.Data.Sqlite", "Microsoft.Data.Sqlite.SqliteCommand", "ExecuteScalar", new[] { "System.Object" }, 2, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarIntegration"), - new("MySql.Data", "MySql.Data.MySqlClient.MySqlCommand", "ExecuteDbDataReader", new[] { "System.Data.Common.DbDataReader", "System.Data.CommandBehavior" }, 6, 7, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), - new("MySql.Data", "MySql.Data.MySqlClient.MySqlCommand", "ExecuteDbDataReader", new[] { "System.Data.Common.DbDataReader", "System.Data.CommandBehavior" }, 8, 0, 0, 8, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), - new("MySql.Data", "MySql.Data.MySqlClient.MySqlCommand", "ExecuteNonQuery", new[] { "System.Int32" }, 6, 7, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryIntegration"), - new("MySql.Data", "MySql.Data.MySqlClient.MySqlCommand", "ExecuteNonQuery", new[] { "System.Int32" }, 8, 0, 0, 8, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryIntegration"), - new("MySql.Data", "MySql.Data.MySqlClient.MySqlCommand", "ExecuteReader", new[] { "MySql.Data.MySqlClient.MySqlDataReader" }, 6, 7, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderIntegration"), - new("MySql.Data", "MySql.Data.MySqlClient.MySqlCommand", "ExecuteReader", new[] { "MySql.Data.MySqlClient.MySqlDataReader" }, 8, 0, 0, 8, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderIntegration"), - new("MySql.Data", "MySql.Data.MySqlClient.MySqlCommand", "ExecuteReader", new[] { "MySql.Data.MySqlClient.MySqlDataReader", "System.Data.CommandBehavior" }, 6, 7, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), - new("MySql.Data", "MySql.Data.MySqlClient.MySqlCommand", "ExecuteReader", new[] { "MySql.Data.MySqlClient.MySqlDataReader", "System.Data.CommandBehavior" }, 8, 0, 0, 8, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), - new("MySql.Data", "MySql.Data.MySqlClient.MySqlCommand", "ExecuteScalar", new[] { "System.Object" }, 6, 7, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarIntegration"), - new("MySql.Data", "MySql.Data.MySqlClient.MySqlCommand", "ExecuteScalar", new[] { "System.Object" }, 8, 0, 0, 8, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarIntegration"), - new("MySqlConnector", "MySqlConnector.MySqlCommand", "ExecuteDbDataReader", new[] { "System.Data.Common.DbDataReader", "System.Data.CommandBehavior" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), - new("MySqlConnector", "MySqlConnector.MySqlCommand", "ExecuteDbDataReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior", "System.Threading.CancellationToken" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration"), - new("MySqlConnector", "MySqlConnector.MySqlCommand", "ExecuteNonQuery", new[] { "System.Int32" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryIntegration"), - new("MySqlConnector", "MySqlConnector.MySqlCommand", "ExecuteNonQueryAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryAsyncIntegration"), - new("MySqlConnector", "MySqlConnector.MySqlCommand", "ExecuteReader", new[] { "MySqlConnector.MySqlDataReader" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderIntegration"), - new("MySqlConnector", "MySqlConnector.MySqlCommand", "ExecuteReader", new[] { "MySqlConnector.MySqlDataReader", "System.Data.CommandBehavior" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), - new("MySqlConnector", "MySqlConnector.MySqlCommand", "ExecuteReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithCancellationAsyncIntegration"), - new("MySqlConnector", "MySqlConnector.MySqlCommand", "ExecuteReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior", "System.Threading.CancellationToken" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration"), - new("MySqlConnector", "MySqlConnector.MySqlCommand", "ExecuteScalar", new[] { "System.Object" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarIntegration"), - new("MySqlConnector", "MySqlConnector.MySqlCommand", "ExecuteScalarAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarAsyncIntegration"), - new("Npgsql", "Npgsql.NpgsqlCommand", "ExecuteDbDataReader", new[] { "System.Data.Common.DbDataReader", "System.Data.CommandBehavior" }, 4, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), - new("Npgsql", "Npgsql.NpgsqlCommand", "ExecuteDbDataReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior", "System.Threading.CancellationToken" }, 4, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration"), - new("Npgsql", "Npgsql.NpgsqlCommand", "ExecuteNonQuery", new[] { "System.Int32" }, 4, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryIntegration"), - new("Npgsql", "Npgsql.NpgsqlCommand", "ExecuteNonQueryAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 4, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryAsyncIntegration"), - new("Npgsql", "Npgsql.NpgsqlCommand", "ExecuteReader", new[] { "Npgsql.NpgsqlDataReader" }, 4, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderIntegration"), - new("Npgsql", "Npgsql.NpgsqlCommand", "ExecuteReader", new[] { "Npgsql.NpgsqlDataReader", "System.Data.CommandBehavior" }, 4, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), - new("Npgsql", "Npgsql.NpgsqlCommand", "ExecuteReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior", "System.Threading.CancellationToken" }, 4, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration"), - new("Npgsql", "Npgsql.NpgsqlCommand", "ExecuteScalar", new[] { "System.Object" }, 4, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarIntegration"), - new("Npgsql", "Npgsql.NpgsqlCommand", "ExecuteScalarAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 4, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarAsyncIntegration"), - new("Oracle.DataAccess", "Oracle.DataAccess.Client.OracleCommand", "ExecuteDbDataReader", new[] { "System.Data.Common.DbDataReader", "System.Data.CommandBehavior" }, 4, 122, 0, 4, 122, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), - new("Oracle.DataAccess", "Oracle.DataAccess.Client.OracleCommand", "ExecuteNonQuery", new[] { "System.Int32" }, 4, 122, 0, 4, 122, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryIntegration"), - new("Oracle.DataAccess", "Oracle.DataAccess.Client.OracleCommand", "ExecuteReader", new[] { "Oracle.DataAccess.Client.OracleDataReader" }, 4, 122, 0, 4, 122, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderIntegration"), - new("Oracle.DataAccess", "Oracle.DataAccess.Client.OracleCommand", "ExecuteReader", new[] { "Oracle.DataAccess.Client.OracleDataReader", "System.Data.CommandBehavior" }, 4, 122, 0, 4, 122, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), - new("Oracle.DataAccess", "Oracle.DataAccess.Client.OracleCommand", "ExecuteScalar", new[] { "System.Object" }, 4, 122, 0, 4, 122, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarIntegration"), - new("Oracle.ManagedDataAccess", "Oracle.ManagedDataAccess.Client.OracleCommand", "ExecuteDbDataReader", new[] { "System.Data.Common.DbDataReader", "System.Data.CommandBehavior" }, 4, 122, 0, 4, 122, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), - new("Oracle.ManagedDataAccess", "Oracle.ManagedDataAccess.Client.OracleCommand", "ExecuteDbDataReader", new[] { "System.Data.Common.DbDataReader", "System.Data.CommandBehavior" }, 2, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), - new("Oracle.ManagedDataAccess", "Oracle.ManagedDataAccess.Client.OracleCommand", "ExecuteNonQuery", new[] { "System.Int32" }, 4, 122, 0, 4, 122, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryIntegration"), - new("Oracle.ManagedDataAccess", "Oracle.ManagedDataAccess.Client.OracleCommand", "ExecuteNonQuery", new[] { "System.Int32" }, 2, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryIntegration"), - new("Oracle.ManagedDataAccess", "Oracle.ManagedDataAccess.Client.OracleCommand", "ExecuteReader", new[] { "Oracle.ManagedDataAccess.Client.OracleDataReader" }, 4, 122, 0, 4, 122, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderIntegration"), - new("Oracle.ManagedDataAccess", "Oracle.ManagedDataAccess.Client.OracleCommand", "ExecuteReader", new[] { "Oracle.ManagedDataAccess.Client.OracleDataReader" }, 2, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderIntegration"), - new("Oracle.ManagedDataAccess", "Oracle.ManagedDataAccess.Client.OracleCommand", "ExecuteReader", new[] { "Oracle.ManagedDataAccess.Client.OracleDataReader", "System.Data.CommandBehavior" }, 4, 122, 0, 4, 122, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), - new("Oracle.ManagedDataAccess", "Oracle.ManagedDataAccess.Client.OracleCommand", "ExecuteReader", new[] { "Oracle.ManagedDataAccess.Client.OracleDataReader", "System.Data.CommandBehavior" }, 2, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), - new("Oracle.ManagedDataAccess", "Oracle.ManagedDataAccess.Client.OracleCommand", "ExecuteScalar", new[] { "System.Object" }, 4, 122, 0, 4, 122, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarIntegration"), - new("Oracle.ManagedDataAccess", "Oracle.ManagedDataAccess.Client.OracleCommand", "ExecuteScalar", new[] { "System.Object" }, 2, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarIntegration"), + // AdoNet new("System.Data", "System.Data.Common.DbCommand", "ExecuteDbDataReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior", "System.Threading.CancellationToken" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration"), new("System.Data", "System.Data.Common.DbCommand", "ExecuteNonQueryAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryAsyncIntegration"), new("System.Data", "System.Data.Common.DbCommand", "ExecuteScalarAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarAsyncIntegration"), - new("System.Data", "System.Data.SqlClient.SqlCommand", "ExecuteDbDataReader", new[] { "System.Data.Common.DbDataReader", "System.Data.CommandBehavior" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), - new("System.Data", "System.Data.SqlClient.SqlCommand", "ExecuteDbDataReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior", "System.Threading.CancellationToken" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration"), - new("System.Data", "System.Data.SqlClient.SqlCommand", "ExecuteNonQuery", new[] { "System.Int32" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryIntegration"), - new("System.Data", "System.Data.SqlClient.SqlCommand", "ExecuteNonQueryAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryAsyncIntegration"), - new("System.Data", "System.Data.SqlClient.SqlCommand", "ExecuteReader", new[] { "System.Data.SqlClient.SqlDataReader" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderIntegration"), - new("System.Data", "System.Data.SqlClient.SqlCommand", "ExecuteReader", new[] { "System.Data.SqlClient.SqlDataReader", "System.Data.CommandBehavior" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), - new("System.Data", "System.Data.SqlClient.SqlCommand", "ExecuteReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior", "System.Threading.CancellationToken" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration"), - new("System.Data", "System.Data.SqlClient.SqlCommand", "ExecuteScalar", new[] { "System.Object" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarIntegration"), - new("System.Data", "System.Data.SqlClient.SqlCommand", "ExecuteScalarAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarAsyncIntegration"), new("System.Data.Common", "System.Data.Common.DbCommand", "ExecuteDbDataReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior", "System.Threading.CancellationToken" }, 4, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration"), new("System.Data.Common", "System.Data.Common.DbCommand", "ExecuteNonQueryAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 4, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryAsyncIntegration"), new("System.Data.Common", "System.Data.Common.DbCommand", "ExecuteScalarAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 4, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarAsyncIntegration"), - new("System.Data.SqlClient", "System.Data.SqlClient.SqlCommand", "ExecuteDbDataReader", new[] { "System.Data.Common.DbDataReader", "System.Data.CommandBehavior" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), - new("System.Data.SqlClient", "System.Data.SqlClient.SqlCommand", "ExecuteDbDataReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior", "System.Threading.CancellationToken" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration"), - new("System.Data.SqlClient", "System.Data.SqlClient.SqlCommand", "ExecuteNonQuery", new[] { "System.Int32" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryIntegration"), - new("System.Data.SqlClient", "System.Data.SqlClient.SqlCommand", "ExecuteNonQueryAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryAsyncIntegration"), - new("System.Data.SqlClient", "System.Data.SqlClient.SqlCommand", "ExecuteReader", new[] { "System.Data.SqlClient.SqlDataReader" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderIntegration"), - new("System.Data.SqlClient", "System.Data.SqlClient.SqlCommand", "ExecuteReader", new[] { "System.Data.SqlClient.SqlDataReader", "System.Data.CommandBehavior" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), - new("System.Data.SqlClient", "System.Data.SqlClient.SqlCommand", "ExecuteReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior", "System.Threading.CancellationToken" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration"), - new("System.Data.SqlClient", "System.Data.SqlClient.SqlCommand", "ExecuteScalar", new[] { "System.Object" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarIntegration"), - new("System.Data.SqlClient", "System.Data.SqlClient.SqlCommand", "ExecuteScalarAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarAsyncIntegration"), - new("System.Data.SQLite", "System.Data.SQLite.SQLiteCommand", "ExecuteDbDataReader", new[] { "System.Data.Common.DbDataReader", "System.Data.CommandBehavior" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), - new("System.Data.SQLite", "System.Data.SQLite.SQLiteCommand", "ExecuteNonQuery", new[] { "System.Int32" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryIntegration"), - new("System.Data.SQLite", "System.Data.SQLite.SQLiteCommand", "ExecuteNonQuery", new[] { "System.Int32", "System.Data.CommandBehavior" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryWithBehaviorIntegration"), - new("System.Data.SQLite", "System.Data.SQLite.SQLiteCommand", "ExecuteReader", new[] { "System.Data.SQLite.SQLiteDataReader" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderIntegration"), - new("System.Data.SQLite", "System.Data.SQLite.SQLiteCommand", "ExecuteReader", new[] { "System.Data.SQLite.SQLiteDataReader", "System.Data.CommandBehavior" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), - new("System.Data.SQLite", "System.Data.SQLite.SQLiteCommand", "ExecuteScalar", new[] { "System.Object" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarIntegration"), - new("System.Data.SQLite", "System.Data.SQLite.SQLiteCommand", "ExecuteScalar", new[] { "System.Object", "System.Data.CommandBehavior" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarWithBehaviorIntegration"), // Aerospike new("AerospikeClient", "Aerospike.Client.AsyncCommand", "ExecuteCommand", new[] { "System.Void" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.Aerospike.AsyncCommandIntegration"), @@ -251,16 +163,71 @@ private static NativeCallTargetDefinition[] GetDefinitionsArray() new("System.Messaging", "System.Messaging.MessageQueue", "SendInternal", new[] { "System.Void", "System.Object", "System.Messaging.MessageQueueTransaction", "System.Messaging.MessageQueueTransactionType" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.Msmq.MessageQueue_SendInternal_Integration"), // MsTestV2 - new("Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter", "Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestMethodRunner", "Execute", new[] { "Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel.UnitTestResult" }, 14, 0, 0, 14, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.MsTestV2.TestMethodRunnerExecuteIntegration"), + new("Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter", "Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestMethodRunner", "Execute", new[] { "Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel.UnitTestResult[]" }, 14, 0, 0, 14, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.MsTestV2.TestMethodRunnerExecuteIntegration"), + new("Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter", "Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.UnitTestRunner", "IsTestMethodRunnable", new[] { "System.Boolean", "Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel.TestMethod", "Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestMethodInfo", "Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel.UnitTestResult[]&" }, 14, 0, 0, 14, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.MsTestV2.UnitTestRunnerIsTestMethodRunnableIntegration"), new("Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter", "Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.UnitTestRunner", "RunCleanup", new[] { "Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.RunCleanupResult" }, 14, 0, 0, 14, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.MsTestV2.UnitTestRunnerRunCleanupIntegration"), + new("Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter", "Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.UnitTestRunner", "RunSingleTest", new[] { "Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel.UnitTestResult[]", "Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel.TestMethod", "System.Collections.Generic.IDictionary`2[System.String,System.Object]" }, 14, 0, 0, 14, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.MsTestV2.UnitTestRunnerRunSingleTestIntegration"), new("Microsoft.VisualStudio.TestPlatform.TestFramework", "Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute", "Execute", new[] { "Microsoft.VisualStudio.TestTools.UnitTesting.TestResult", "Microsoft.VisualStudio.TestTools.UnitTesting.ITestMethod" }, 14, 0, 0, 14, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.MsTestV2.TestMethodAttributeExecuteIntegration"), + // MySql + new("MySql.Data", "MySql.Data.MySqlClient.MySqlCommand", "ExecuteDbDataReader", new[] { "System.Data.Common.DbDataReader", "System.Data.CommandBehavior" }, 6, 7, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), + new("MySql.Data", "MySql.Data.MySqlClient.MySqlCommand", "ExecuteDbDataReader", new[] { "System.Data.Common.DbDataReader", "System.Data.CommandBehavior" }, 8, 0, 0, 8, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), + new("MySql.Data", "MySql.Data.MySqlClient.MySqlCommand", "ExecuteNonQuery", new[] { "System.Int32" }, 6, 7, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryIntegration"), + new("MySql.Data", "MySql.Data.MySqlClient.MySqlCommand", "ExecuteNonQuery", new[] { "System.Int32" }, 8, 0, 0, 8, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryIntegration"), + new("MySql.Data", "MySql.Data.MySqlClient.MySqlCommand", "ExecuteReader", new[] { "MySql.Data.MySqlClient.MySqlDataReader" }, 6, 7, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderIntegration"), + new("MySql.Data", "MySql.Data.MySqlClient.MySqlCommand", "ExecuteReader", new[] { "MySql.Data.MySqlClient.MySqlDataReader" }, 8, 0, 0, 8, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderIntegration"), + new("MySql.Data", "MySql.Data.MySqlClient.MySqlCommand", "ExecuteReader", new[] { "MySql.Data.MySqlClient.MySqlDataReader", "System.Data.CommandBehavior" }, 6, 7, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), + new("MySql.Data", "MySql.Data.MySqlClient.MySqlCommand", "ExecuteReader", new[] { "MySql.Data.MySqlClient.MySqlDataReader", "System.Data.CommandBehavior" }, 8, 0, 0, 8, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), + new("MySql.Data", "MySql.Data.MySqlClient.MySqlCommand", "ExecuteScalar", new[] { "System.Object" }, 6, 7, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarIntegration"), + new("MySql.Data", "MySql.Data.MySqlClient.MySqlCommand", "ExecuteScalar", new[] { "System.Object" }, 8, 0, 0, 8, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarIntegration"), + new("MySqlConnector", "MySqlConnector.MySqlCommand", "ExecuteDbDataReader", new[] { "System.Data.Common.DbDataReader", "System.Data.CommandBehavior" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), + new("MySqlConnector", "MySqlConnector.MySqlCommand", "ExecuteDbDataReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior", "System.Threading.CancellationToken" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration"), + new("MySqlConnector", "MySqlConnector.MySqlCommand", "ExecuteNonQuery", new[] { "System.Int32" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryIntegration"), + new("MySqlConnector", "MySqlConnector.MySqlCommand", "ExecuteNonQueryAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryAsyncIntegration"), + new("MySqlConnector", "MySqlConnector.MySqlCommand", "ExecuteReader", new[] { "MySqlConnector.MySqlDataReader" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderIntegration"), + new("MySqlConnector", "MySqlConnector.MySqlCommand", "ExecuteReader", new[] { "MySqlConnector.MySqlDataReader", "System.Data.CommandBehavior" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), + new("MySqlConnector", "MySqlConnector.MySqlCommand", "ExecuteReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithCancellationAsyncIntegration"), + new("MySqlConnector", "MySqlConnector.MySqlCommand", "ExecuteReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior", "System.Threading.CancellationToken" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration"), + new("MySqlConnector", "MySqlConnector.MySqlCommand", "ExecuteScalar", new[] { "System.Object" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarIntegration"), + new("MySqlConnector", "MySqlConnector.MySqlCommand", "ExecuteScalarAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarAsyncIntegration"), + + // NLog + new("NLog", "NLog.LoggerImpl", "Write", new[] { "System.Void", "System.Type", "NLog.Internal.TargetWithFilterChain", "NLog.LogEventInfo", "NLog.LogFactory" }, 1, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.Logging.NLog.LogsInjection.LoggerImplWriteIntegration"), + + // Npgsql + new("Npgsql", "Npgsql.NpgsqlCommand", "ExecuteDbDataReader", new[] { "System.Data.Common.DbDataReader", "System.Data.CommandBehavior" }, 4, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), + new("Npgsql", "Npgsql.NpgsqlCommand", "ExecuteDbDataReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior", "System.Threading.CancellationToken" }, 4, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration"), + new("Npgsql", "Npgsql.NpgsqlCommand", "ExecuteNonQuery", new[] { "System.Int32" }, 4, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryIntegration"), + new("Npgsql", "Npgsql.NpgsqlCommand", "ExecuteNonQueryAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 4, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryAsyncIntegration"), + new("Npgsql", "Npgsql.NpgsqlCommand", "ExecuteReader", new[] { "Npgsql.NpgsqlDataReader" }, 4, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderIntegration"), + new("Npgsql", "Npgsql.NpgsqlCommand", "ExecuteReader", new[] { "Npgsql.NpgsqlDataReader", "System.Data.CommandBehavior" }, 4, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), + new("Npgsql", "Npgsql.NpgsqlCommand", "ExecuteReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior", "System.Threading.CancellationToken" }, 4, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration"), + new("Npgsql", "Npgsql.NpgsqlCommand", "ExecuteScalar", new[] { "System.Object" }, 4, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarIntegration"), + new("Npgsql", "Npgsql.NpgsqlCommand", "ExecuteScalarAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 4, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarAsyncIntegration"), + // NUnit new("nunit.framework", "NUnit.Framework.Api.NUnitTestAssemblyRunner", "WaitForCompletion", new[] { "System.Boolean", "System.Int32" }, 3, 0, 0, 3, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.NUnit.NUnitTestAssemblyRunnerWaitForCompletionIntegration"), new("nunit.framework", "NUnit.Framework.Internal.Commands.SkipCommand", "Execute", new[] { "NUnit.Framework.Internal.TestResult", "NUnit.Framework.Internal.TestExecutionContext" }, 3, 0, 0, 3, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.NUnit.NUnitSkipCommandExecuteIntegration"), new("nunit.framework", "NUnit.Framework.Internal.Commands.TestMethodCommand", "Execute", new[] { "NUnit.Framework.Internal.TestResult", "NUnit.Framework.Internal.TestExecutionContext" }, 3, 0, 0, 3, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.NUnit.NUnitTestMethodCommandExecuteIntegration"), new("nunit.framework", "NUnit.Framework.Internal.Execution.CompositeWorkItem", "SkipChildren", new[] { "System.Void", "_", "NUnit.Framework.Interfaces.ResultState", "System.String" }, 3, 0, 0, 3, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.NUnit.NUnitCompositeWorkItemSkipChildrenIntegration"), - new("NUnit3.TestAdapter", "NUnit.VisualStudio.TestAdapter.NUnitTestAdapter", "Unload", new[] { "System.Void" }, 3, 0, 0, 3, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.NUnit.NUnitTestAdapterUnloadIntegration"), + new("NUnit3.TestAdapter", "NUnit.VisualStudio.TestAdapter.NUnitTestAdapter", "Unload", new[] { "System.Void" }, 3, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.Testing.NUnit.NUnitTestAdapterUnloadIntegration"), + + // Oracle + new("Oracle.DataAccess", "Oracle.DataAccess.Client.OracleCommand", "ExecuteDbDataReader", new[] { "System.Data.Common.DbDataReader", "System.Data.CommandBehavior" }, 4, 122, 0, 4, 122, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), + new("Oracle.DataAccess", "Oracle.DataAccess.Client.OracleCommand", "ExecuteNonQuery", new[] { "System.Int32" }, 4, 122, 0, 4, 122, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryIntegration"), + new("Oracle.DataAccess", "Oracle.DataAccess.Client.OracleCommand", "ExecuteReader", new[] { "Oracle.DataAccess.Client.OracleDataReader" }, 4, 122, 0, 4, 122, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderIntegration"), + new("Oracle.DataAccess", "Oracle.DataAccess.Client.OracleCommand", "ExecuteReader", new[] { "Oracle.DataAccess.Client.OracleDataReader", "System.Data.CommandBehavior" }, 4, 122, 0, 4, 122, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), + new("Oracle.DataAccess", "Oracle.DataAccess.Client.OracleCommand", "ExecuteScalar", new[] { "System.Object" }, 4, 122, 0, 4, 122, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarIntegration"), + new("Oracle.ManagedDataAccess", "Oracle.ManagedDataAccess.Client.OracleCommand", "ExecuteDbDataReader", new[] { "System.Data.Common.DbDataReader", "System.Data.CommandBehavior" }, 4, 122, 0, 4, 122, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), + new("Oracle.ManagedDataAccess", "Oracle.ManagedDataAccess.Client.OracleCommand", "ExecuteDbDataReader", new[] { "System.Data.Common.DbDataReader", "System.Data.CommandBehavior" }, 2, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), + new("Oracle.ManagedDataAccess", "Oracle.ManagedDataAccess.Client.OracleCommand", "ExecuteNonQuery", new[] { "System.Int32" }, 4, 122, 0, 4, 122, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryIntegration"), + new("Oracle.ManagedDataAccess", "Oracle.ManagedDataAccess.Client.OracleCommand", "ExecuteNonQuery", new[] { "System.Int32" }, 2, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryIntegration"), + new("Oracle.ManagedDataAccess", "Oracle.ManagedDataAccess.Client.OracleCommand", "ExecuteReader", new[] { "Oracle.ManagedDataAccess.Client.OracleDataReader" }, 4, 122, 0, 4, 122, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderIntegration"), + new("Oracle.ManagedDataAccess", "Oracle.ManagedDataAccess.Client.OracleCommand", "ExecuteReader", new[] { "Oracle.ManagedDataAccess.Client.OracleDataReader" }, 2, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderIntegration"), + new("Oracle.ManagedDataAccess", "Oracle.ManagedDataAccess.Client.OracleCommand", "ExecuteReader", new[] { "Oracle.ManagedDataAccess.Client.OracleDataReader", "System.Data.CommandBehavior" }, 4, 122, 0, 4, 122, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), + new("Oracle.ManagedDataAccess", "Oracle.ManagedDataAccess.Client.OracleCommand", "ExecuteReader", new[] { "Oracle.ManagedDataAccess.Client.OracleDataReader", "System.Data.CommandBehavior" }, 2, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), + new("Oracle.ManagedDataAccess", "Oracle.ManagedDataAccess.Client.OracleCommand", "ExecuteScalar", new[] { "System.Object" }, 4, 122, 0, 4, 122, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarIntegration"), + new("Oracle.ManagedDataAccess", "Oracle.ManagedDataAccess.Client.OracleCommand", "ExecuteScalar", new[] { "System.Object" }, 2, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarIntegration"), // RabbitMQ new("RabbitMQ.Client", "RabbitMQ.Client.Events.EventingBasicConsumer", "HandleBasicDeliver", new[] { "System.Void", "System.String", "System.UInt64", "System.Boolean", "System.String", "System.String", "RabbitMQ.Client.IBasicProperties", "_" }, 3, 6, 9, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.RabbitMQ.BasicDeliverIntegration"), @@ -270,9 +237,61 @@ private static NativeCallTargetDefinition[] GetDefinitionsArray() new("RabbitMQ.Client", "RabbitMQ.Client.Impl.ModelBase", "BasicGet", new[] { "RabbitMQ.Client.BasicGetResult", "System.String", "System.Boolean" }, 3, 6, 9, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.RabbitMQ.BasicGetIntegration"), new("RabbitMQ.Client", "RabbitMQ.Client.Impl.ModelBase", "QueueBind", new[] { "System.Void", "System.String", "System.String", "System.String", "System.Collections.Generic.IDictionary`2[System.String,System.Object]" }, 3, 6, 9, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.RabbitMQ.QueueBindIntegration"), + // Serilog + new("Serilog", "Serilog.Core.Logger", "Dispatch", new[] { "System.Void", "Serilog.Events.LogEvent" }, 2, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.Logging.Serilog.LogsInjection.LoggerDispatchInstrumentation"), + new("Serilog", "Serilog.Core.Pipeline.Logger", "Dispatch", new[] { "System.Void", "Serilog.Events.LogEvent" }, 1, 4, 0, 1, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.Logging.Serilog.LogsInjection.LoggerDispatchInstrumentation"), + // ServiceStackRedis new("ServiceStack.Redis", "ServiceStack.Redis.RedisNativeClient", "SendReceive", new[] { "T", "System.Byte[][]", "System.Func`1[!!0]", "System.Action`1[System.Func`1[!!0]]", "System.Boolean" }, 4, 0, 0, 5, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.Redis.ServiceStack.RedisNativeClientSendReceiveIntegration"), + // SqlClient + new("Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient.SqlCommand", "ExecuteDbDataReader", new[] { "System.Data.Common.DbDataReader", "System.Data.CommandBehavior" }, 1, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), + new("Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient.SqlCommand", "ExecuteDbDataReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior", "System.Threading.CancellationToken" }, 1, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration"), + new("Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient.SqlCommand", "ExecuteNonQuery", new[] { "System.Int32" }, 1, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryIntegration"), + new("Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient.SqlCommand", "ExecuteNonQueryAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 1, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryAsyncIntegration"), + new("Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient.SqlCommand", "ExecuteReader", new[] { "Microsoft.Data.SqlClient.SqlDataReader" }, 1, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderIntegration"), + new("Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient.SqlCommand", "ExecuteReader", new[] { "Microsoft.Data.SqlClient.SqlDataReader", "System.Data.CommandBehavior" }, 1, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), + new("Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient.SqlCommand", "ExecuteReaderAsync", new[] { "System.Threading.Tasks.Task`1" }, 1, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderAsyncIntegration"), + new("Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient.SqlCommand", "ExecuteReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 1, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithCancellationAsyncIntegration"), + new("Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient.SqlCommand", "ExecuteReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior" }, 1, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAsyncIntegration"), + new("Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient.SqlCommand", "ExecuteReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior", "System.Threading.CancellationToken" }, 1, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration"), + new("Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient.SqlCommand", "ExecuteScalar", new[] { "System.Object" }, 1, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarIntegration"), + new("Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient.SqlCommand", "ExecuteScalarAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 1, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarAsyncIntegration"), + new("System.Data", "System.Data.SqlClient.SqlCommand", "ExecuteDbDataReader", new[] { "System.Data.Common.DbDataReader", "System.Data.CommandBehavior" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), + new("System.Data", "System.Data.SqlClient.SqlCommand", "ExecuteDbDataReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior", "System.Threading.CancellationToken" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration"), + new("System.Data", "System.Data.SqlClient.SqlCommand", "ExecuteNonQuery", new[] { "System.Int32" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryIntegration"), + new("System.Data", "System.Data.SqlClient.SqlCommand", "ExecuteNonQueryAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryAsyncIntegration"), + new("System.Data", "System.Data.SqlClient.SqlCommand", "ExecuteReader", new[] { "System.Data.SqlClient.SqlDataReader" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderIntegration"), + new("System.Data", "System.Data.SqlClient.SqlCommand", "ExecuteReader", new[] { "System.Data.SqlClient.SqlDataReader", "System.Data.CommandBehavior" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), + new("System.Data", "System.Data.SqlClient.SqlCommand", "ExecuteReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior", "System.Threading.CancellationToken" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration"), + new("System.Data", "System.Data.SqlClient.SqlCommand", "ExecuteScalar", new[] { "System.Object" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarIntegration"), + new("System.Data", "System.Data.SqlClient.SqlCommand", "ExecuteScalarAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarAsyncIntegration"), + new("System.Data.SqlClient", "System.Data.SqlClient.SqlCommand", "ExecuteDbDataReader", new[] { "System.Data.Common.DbDataReader", "System.Data.CommandBehavior" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), + new("System.Data.SqlClient", "System.Data.SqlClient.SqlCommand", "ExecuteDbDataReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior", "System.Threading.CancellationToken" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration"), + new("System.Data.SqlClient", "System.Data.SqlClient.SqlCommand", "ExecuteNonQuery", new[] { "System.Int32" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryIntegration"), + new("System.Data.SqlClient", "System.Data.SqlClient.SqlCommand", "ExecuteNonQueryAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryAsyncIntegration"), + new("System.Data.SqlClient", "System.Data.SqlClient.SqlCommand", "ExecuteReader", new[] { "System.Data.SqlClient.SqlDataReader" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderIntegration"), + new("System.Data.SqlClient", "System.Data.SqlClient.SqlCommand", "ExecuteReader", new[] { "System.Data.SqlClient.SqlDataReader", "System.Data.CommandBehavior" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), + new("System.Data.SqlClient", "System.Data.SqlClient.SqlCommand", "ExecuteReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior", "System.Threading.CancellationToken" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration"), + new("System.Data.SqlClient", "System.Data.SqlClient.SqlCommand", "ExecuteScalar", new[] { "System.Object" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarIntegration"), + new("System.Data.SqlClient", "System.Data.SqlClient.SqlCommand", "ExecuteScalarAsync", new[] { "System.Threading.Tasks.Task`1", "System.Threading.CancellationToken" }, 4, 0, 0, 4, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarAsyncIntegration"), + + // Sqlite + new("Microsoft.Data.Sqlite", "Microsoft.Data.Sqlite.SqliteCommand", "ExecuteDbDataReader", new[] { "System.Data.Common.DbDataReader", "System.Data.CommandBehavior" }, 2, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), + new("Microsoft.Data.Sqlite", "Microsoft.Data.Sqlite.SqliteCommand", "ExecuteDbDataReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior", "System.Threading.CancellationToken" }, 2, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration"), + new("Microsoft.Data.Sqlite", "Microsoft.Data.Sqlite.SqliteCommand", "ExecuteNonQuery", new[] { "System.Int32" }, 2, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryIntegration"), + new("Microsoft.Data.Sqlite", "Microsoft.Data.Sqlite.SqliteCommand", "ExecuteReader", new[] { "Microsoft.Data.Sqlite.SqliteDataReader" }, 2, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderIntegration"), + new("Microsoft.Data.Sqlite", "Microsoft.Data.Sqlite.SqliteCommand", "ExecuteReader", new[] { "Microsoft.Data.Sqlite.SqliteDataReader", "System.Data.CommandBehavior" }, 2, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), + new("Microsoft.Data.Sqlite", "Microsoft.Data.Sqlite.SqliteCommand", "ExecuteReaderAsync", new[] { "System.Threading.Tasks.Task`1", "System.Data.CommandBehavior", "System.Threading.CancellationToken" }, 2, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration"), + new("Microsoft.Data.Sqlite", "Microsoft.Data.Sqlite.SqliteCommand", "ExecuteScalar", new[] { "System.Object" }, 2, 0, 0, 6, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarIntegration"), + new("System.Data.SQLite", "System.Data.SQLite.SQLiteCommand", "ExecuteDbDataReader", new[] { "System.Data.Common.DbDataReader", "System.Data.CommandBehavior" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), + new("System.Data.SQLite", "System.Data.SQLite.SQLiteCommand", "ExecuteNonQuery", new[] { "System.Int32" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryIntegration"), + new("System.Data.SQLite", "System.Data.SQLite.SQLiteCommand", "ExecuteNonQuery", new[] { "System.Int32", "System.Data.CommandBehavior" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteNonQueryWithBehaviorIntegration"), + new("System.Data.SQLite", "System.Data.SQLite.SQLiteCommand", "ExecuteReader", new[] { "System.Data.SQLite.SQLiteDataReader" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderIntegration"), + new("System.Data.SQLite", "System.Data.SQLite.SQLiteCommand", "ExecuteReader", new[] { "System.Data.SQLite.SQLiteDataReader", "System.Data.CommandBehavior" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteReaderWithBehaviorIntegration"), + new("System.Data.SQLite", "System.Data.SQLite.SQLiteCommand", "ExecuteScalar", new[] { "System.Object" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarIntegration"), + new("System.Data.SQLite", "System.Data.SQLite.SQLiteCommand", "ExecuteScalar", new[] { "System.Object", "System.Data.CommandBehavior" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet.CommandExecuteScalarWithBehaviorIntegration"), + // StackExchangeRedis new("StackExchange.Redis", "StackExchange.Redis.ConnectionMultiplexer", "ExecuteAsyncImpl", new[] { "System.Threading.Tasks.Task`1", "StackExchange.Redis.Message", "StackExchange.Redis.ResultProcessor`1[!!0]", "System.Object", "StackExchange.Redis.ServerEndPoint" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.Redis.StackExchange.ConnectionMultiplexerExecuteAsyncImplIntegration"), new("StackExchange.Redis", "StackExchange.Redis.ConnectionMultiplexer", "ExecuteSyncImpl", new[] { "T", "StackExchange.Redis.Message", "StackExchange.Redis.ResultProcessor`1[!!0]", "StackExchange.Redis.ServerEndPoint" }, 1, 0, 0, 2, 65535, 65535, assemblyFullName, "Datadog.Trace.ClrProfiler.AutoInstrumentation.Redis.StackExchange.ConnectionMultiplexerExecuteSyncImplIntegration"), diff --git a/tracer/src/Datadog.Trace/ClrProfiler/ManualTracer.cs b/tracer/src/Datadog.Trace/ClrProfiler/ManualTracer.cs new file mode 100644 index 000000000..985442258 --- /dev/null +++ b/tracer/src/Datadog.Trace/ClrProfiler/ManualTracer.cs @@ -0,0 +1,95 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using System; +using System.Collections.Generic; +using Datadog.Trace.DuckTyping; +using Datadog.Trace.Logging; +using Datadog.Trace.Util; + +namespace Datadog.Trace.ClrProfiler +{ + internal class ManualTracer : CommonTracer, IDistributedTracer + { + private static readonly IDatadogLogger Log = DatadogLogging.GetLoggerFor(typeof(ManualTracer)); + + private readonly IAutomaticTracer _parent; + + internal ManualTracer(IAutomaticTracer parent) + { + if (parent is null) + { + ThrowHelper.ThrowArgumentNullException(nameof(parent)); + } + + _parent = parent; + _parent.Register(this); + } + + bool IDistributedTracer.IsChildTracer => true; + + IScope IDistributedTracer.GetActiveScope() + { + var activeTrace = _parent.GetDistributedTrace(); + + if (activeTrace is SpanContext) + { + // This is a local trace, no need to mock anything + return null; + } + + // We don't own the active trace, get the scope from the parent and mock it + var activeScope = _parent.GetAutomaticActiveScope(); + + if (activeScope is null) + { + return null; + } + + try + { + return activeScope.DuckCast(); + } + catch (Exception ex) + { + Log.Warning(ex, "Error while trying to ducktype the parent scope"); + return null; + } + } + + IReadOnlyDictionary IDistributedTracer.GetSpanContextRaw() => _parent.GetDistributedTrace(); + + SpanContext IDistributedTracer.GetSpanContext() + { + var values = _parent.GetDistributedTrace(); + + if (values is SpanContext spanContext) + { + return spanContext; + } + else + { + return Tracer.Instance.TracerManager.Propagator.Extract(values, (headers, key) => new List { headers[key] }); + } + } + + void IDistributedTracer.SetSpanContext(IReadOnlyDictionary value) + { + _parent.SetDistributedTrace(value); + } + + SamplingPriority? IDistributedTracer.GetSamplingPriority() + { + return (SamplingPriority?)_parent.GetSamplingPriority(); + } + + void IDistributedTracer.SetSamplingPriority(SamplingPriority? samplingPriority) + { + _parent.SetSamplingPriority((int?)samplingPriority); + } + + string IDistributedTracer.GetRuntimeId() => _parent.GetAutomaticRuntimeId(); + } +} diff --git a/tracer/src/Datadog.Trace/ClrProfiler/NativeCallTargetDefinition.cs b/tracer/src/Datadog.Trace/ClrProfiler/NativeCallTargetDefinition.cs index d8f255f27..517d21464 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/NativeCallTargetDefinition.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/NativeCallTargetDefinition.cs @@ -8,6 +8,31 @@ namespace Datadog.Trace.ClrProfiler { + // ! ██ + // ██░░██ + // ██░░░░░░██ + // ██░░░░░░░░░░██ + // ██░░░░░░░░░░██ + // ██░░░░░░░░░░░░░░██ + // ██░░░░░░██████░░░░░░██ + // ██░░░░░░██████░░░░░░██ + // ██░░░░░░░░██████░░░░░░░░██ + // ██░░░░░░░░██████░░░░░░░░██ + // ██░░░░░░░░░░██████░░░░░░░░░░██ + // ██░░░░░░░░░░░░██████░░░░░░░░░░░░██ + // ██░░░░░░░░░░░░██████░░░░░░░░░░░░██ + // ██░░░░░░░░░░░░░░██████░░░░░░░░░░░░░░██ + // ██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██ + // ██░░░░░░░░░░░░░░░░██████░░░░░░░░░░░░░░░░██ + // ██░░░░░░░░░░░░░░░░██████░░░░░░░░░░░░░░░░██ + // ██░░░░░░░░░░░░░░░░░░██████░░░░░░░░░░░░░░░░░░██ + // ██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██ + // ██████████████████████████████████████████ + // + // If you happen to change the layout of this structure, + // this will lead to an AccessViolationException in netCore when using a more recent version of the nuget. + // If you need to modify the definition, create a new interface NativeCallTargetDefinition# that will be consumed by the native layer + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] internal struct NativeCallTargetDefinition { diff --git a/tracer/src/Datadog.Trace/ClrProfiler/ScopeFactory.cs b/tracer/src/Datadog.Trace/ClrProfiler/ScopeFactory.cs index 578c857ec..aec620cfd 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/ScopeFactory.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/ScopeFactory.cs @@ -26,7 +26,7 @@ internal static class ScopeFactory public static Scope GetActiveHttpScope(Tracer tracer) { - var scope = tracer.ActiveScope; + var scope = tracer.InternalActiveScope; var parent = scope?.Span; @@ -81,7 +81,7 @@ internal static Span CreateInactiveOutboundHttpSpan(Tracer tracer, string httpMe { tags = null; - if (!tracer.Settings.IsIntegrationEnabled(integrationId) || PlatformHelpers.PlatformStrategy.ShouldSkipClientSpan(tracer.ActiveScope) || HttpBypassHelper.UriContainsAnyOf(requestUri, tracer.Settings.HttpClientExcludedUrlSubstrings)) + if (!tracer.Settings.IsIntegrationEnabled(integrationId) || PlatformHelpers.PlatformStrategy.ShouldSkipClientSpan(tracer.InternalActiveScope) || HttpBypassHelper.UriContainsAnyOf(requestUri, tracer.Settings.HttpClientExcludedUrlSubstrings)) { // integration disabled, don't create a scope, skip this trace return null; diff --git a/tracer/src/Datadog.Trace/Configuration/CompositeConfigurationSource.cs b/tracer/src/Datadog.Trace/Configuration/CompositeConfigurationSource.cs index 5d0d1e446..2dfb5957b 100644 --- a/tracer/src/Datadog.Trace/Configuration/CompositeConfigurationSource.cs +++ b/tracer/src/Datadog.Trace/Configuration/CompositeConfigurationSource.cs @@ -8,6 +8,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; +using Datadog.Trace.Util; namespace Datadog.Trace.Configuration { @@ -24,7 +25,7 @@ public class CompositeConfigurationSource : IConfigurationSource, IEnumerableThe configuration source to add. public void Add(IConfigurationSource source) { - if (source == null) { throw new ArgumentNullException(nameof(source)); } + if (source == null) { ThrowHelper.ThrowArgumentNullException(nameof(source)); } _sources.Add(source); } @@ -36,7 +37,7 @@ public void Add(IConfigurationSource source) /// The configuration source to insert. public void Insert(int index, IConfigurationSource item) { - if (item == null) { throw new ArgumentNullException(nameof(item)); } + if (item == null) { ThrowHelper.ThrowArgumentNullException(nameof(item)); } _sources.Insert(index, item); } diff --git a/tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.Exporter.cs b/tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.Exporter.cs new file mode 100644 index 000000000..7daf18d14 --- /dev/null +++ b/tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.Exporter.cs @@ -0,0 +1,99 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +// Modified by Splunk Inc. + +namespace Datadog.Trace.Configuration +{ + /// + /// String constants for standard Datadog configuration keys. + /// + internal static partial class ConfigurationKeys + { + /// + /// Configuration key for the Agent host where the Tracer can send traces. + /// Overridden by if present. + /// Default value is "localhost". + /// + /// + public const string AgentHost = "SIGNALFX_AGENT_HOST"; + + /// + /// Configuration key for the Agent port where the Tracer can send traces. + /// Default value is 8126. + /// + /// + public const string AgentPort = "SIGNALFX_TRACE_AGENT_PORT"; + + /// + /// Configuration key for the named pipe where the Tracer can send traces. + /// Default value is null. + /// + /// + public const string TracesPipeName = "SIGNALFX_TRACE_PIPE_NAME"; + + /// + /// Configuration key for setting the timeout in milliseconds for named pipes communication. + /// Default value is 0. + /// + /// + public const string TracesPipeTimeoutMs = "SIGNALFX_TRACE_PIPE_TIMEOUT_MS"; + + /// + /// Configuration key for the named pipe that DogStatsD binds to. + /// Default value is null. + /// + /// + public const string MetricsPipeName = "SIGNALFX_DOGSTATSD_PIPE_NAME"; + + /// + /// Sibling setting for . + /// Used to force a specific port binding for the Trace Agent. + /// Default value is 8126. + /// + /// + public const string TraceAgentPortKey = "SIGNALFX_APM_RECEIVER_PORT"; + + /// + /// Configuration key for the URL where the Tracer can send metrics. + /// + /// + public const string MetricsEndpointUrl = "SIGNALFX_METRICS_ENDPOINT_URL"; + + /// + /// Configuration key for the Agent URL where the Tracer can send traces. + /// Overrides values in and if present. + /// Default value is "http://localhost:8126". + /// + /// + public const string AgentUri = "SIGNALFX_TRACE_AGENT_URL"; + + /// + /// Configuration key for the trace endpoint. Same as created + /// for compatibility of previous version of SignalFx .NET Tracing. + /// + /// + public const string EndpointUrl = "SIGNALFX_ENDPOINT_URL"; + + /// + /// Configuration key for the DogStatsd port where the Tracer can send metrics. + /// Default value is 8125. + /// + /// + public const string DogStatsdPort = "SIGNALFX_DOGSTATSD_PORT"; + + /// + /// Configuration key to enable sending partial traces to the agent + /// + /// + public const string PartialFlushEnabled = "SIGNALFX_TRACE_PARTIAL_FLUSH_ENABLED"; + + /// + /// Configuration key to set the minimum number of closed spans in a trace before it's partially flushed + /// + /// + public const string PartialFlushMinSpans = "SIGNALFX_TRACE_PARTIAL_FLUSH_MIN_SPANS"; + } +} diff --git a/tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.cs b/tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.cs index 3f91b7065..395293753 100644 --- a/tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.cs +++ b/tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.cs @@ -12,7 +12,7 @@ namespace Datadog.Trace.Configuration /// /// String constants for standard Datadog configuration keys. /// - public static class ConfigurationKeys + internal static partial class ConfigurationKeys { /// /// Configuration key for the path to the configuration file. @@ -85,6 +85,13 @@ public static class ConfigurationKeys /// public const string AppSecExtraHeaders = "SIGNALFX_APPSEC_EXTRA_HEADERS"; + /// + /// Specifies if the AppSec traces should be explicitly kept or droped. + /// Default is true, to keep all traces, false will drop all traces. + /// For internal testing only. + /// + internal const string AppSecKeepTraces = "SIGNALFX_APPSEC_KEEP_TRACES"; + /// /// Configuration key for enabling or disabling the Tracer's debug mode. /// Default is value is false (disabled). @@ -127,71 +134,6 @@ public static class ConfigurationKeys /// public const string DisabledIntegrations = "SIGNALFX_DISABLED_INTEGRATIONS"; - /// - /// Configuration key for the Agent host where the Tracer can send traces. - /// Overridden by if present. - /// Default value is "localhost". - /// - /// - public const string AgentHost = "SIGNALFX_AGENT_HOST"; - - /// - /// Configuration key for the Agent port where the Tracer can send traces. - /// Default value is 8126. - /// - /// - public const string AgentPort = "SIGNALFX_TRACE_AGENT_PORT"; - - /// - /// Configuration key for the named pipe where the Tracer can send traces. - /// Default value is null. - /// - /// - public const string TracesPipeName = "SIGNALFX_TRACE_PIPE_NAME"; - - /// - /// Configuration key for setting the timeout in milliseconds for named pipes communication. - /// Default value is 0. - /// - /// - public const string TracesPipeTimeoutMs = "SIGNALFX_TRACE_PIPE_TIMEOUT_MS"; - - /// - /// Configuration key for the named pipe that DogStatsD binds to. - /// Default value is null. - /// - /// - public const string MetricsPipeName = "SIGNALFX_DOGSTATSD_PIPE_NAME"; - - /// - /// Sibling setting for . - /// Used to force a specific port binding for the Trace Agent. - /// Default value is 8126. - /// - /// - public const string TraceAgentPortKey = "SIGNALFX_APM_RECEIVER_PORT"; - - /// - /// Configuration key for the Agent URL where the Tracer can send traces. - /// Overrides values in and if present. - /// Default value is "http://localhost:8126". - /// - /// - public const string AgentUri = "SIGNALFX_TRACE_AGENT_URL"; - - /// - /// Configuration key for the URL where the Tracer can send metrics. - /// - /// - public const string MetricsEndpointUrl = "SIGNALFX_METRICS_ENDPOINT_URL"; - - /// - /// Configuration key for the trace endpoint. Same as created - /// for compatibility of previous version of SignalFx .NET Tracing. - /// - /// - public const string EndpointUrl = "SIGNALFX_ENDPOINT_URL"; - /// /// Configuration key for enabling or disabling default Analytics. /// @@ -283,12 +225,6 @@ public static class ConfigurationKeys /// public const string GlobalSamplingRate = "SIGNALFX_TRACE_SAMPLE_RATE"; - /// - /// Configuration key for the DogStatsd port where the Tracer can send metrics. - /// Default value is 8125. - /// - public const string DogStatsdPort = "SIGNALFX_DOGSTATSD_PORT"; - /// /// Configuration key for enabling or disabling internal metrics sent to DogStatsD. /// Default value is false (disabled). @@ -420,18 +356,6 @@ public static class ConfigurationKeys /// public const string HttpClientErrorStatusCodes = "SIGNALFX_HTTP_CLIENT_ERROR_STATUSES"; - /// - /// Configuration key to enable sending partial traces to the agent - /// - /// - public const string PartialFlushEnabled = "SIGNALFX_TRACE_PARTIAL_FLUSH_ENABLED"; - - /// - /// Configuration key to set the minimum number of closed spans in a trace before it's partially flushed - /// - /// - public const string PartialFlushMinSpans = "SIGNALFX_TRACE_PARTIAL_FLUSH_MIN_SPANS"; - /// /// Configuration key to enable or disable the creation of a span context on exiting a successful Kafka /// Consumer.Consume() call, and closing the scope on entering Consumer.Consume(). diff --git a/tracer/src/Datadog.Trace/Configuration/ExporterSettings.cs b/tracer/src/Datadog.Trace/Configuration/ExporterSettings.cs new file mode 100644 index 000000000..c97ca5cf9 --- /dev/null +++ b/tracer/src/Datadog.Trace/Configuration/ExporterSettings.cs @@ -0,0 +1,235 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +// Modified by Splunk Inc. + +using System; +using Datadog.Trace.Vendors.StatsdClient.Transport; + +namespace Datadog.Trace.Configuration +{ + /// + /// Contains exporter settings. + /// + public class ExporterSettings + { + private int _partialFlushMinSpans; + + /// + /// The default host value for . + /// + public const string DefaultAgentHost = "localhost"; + + /// + /// The default port value for . + /// + public const int DefaultAgentPort = 9411; + + /// + /// The default port value for dogstatsd. + /// + internal const int DefaultDogstatsdPort = 8125; + + /// + /// Initializes a new instance of the class with default values. + /// + public ExporterSettings() + : this(null) + { + } + + /// + /// Initializes a new instance of the class + /// using the specified to initialize values. + /// + /// The to use when retrieving configuration values. + public ExporterSettings(IConfigurationSource source) + { + var isWindows = FrameworkDescription.Instance.OSPlatform == OSPlatform.Windows; + ConfigureTraceTransport(source, isWindows); + ConfigureMetricsTransport(source, isWindows); + + PartialFlushEnabled = source?.GetBool(ConfigurationKeys.PartialFlushEnabled) + // default value + ?? false; + + var partialFlushMinSpans = source?.GetInt32(ConfigurationKeys.PartialFlushMinSpans); + + if ((partialFlushMinSpans ?? 0) <= 0) + { + PartialFlushMinSpans = 500; + } + } + + /// + /// Gets or sets the Uri where the Tracer can connect to the Agent. + /// Default is "http://localhost:8126". + /// + /// + /// + /// + public Uri AgentUri { get; set; } + + /// + /// Gets or sets the windows pipe name where the Tracer can connect to the Agent. + /// Default is null. + /// + /// + public string TracesPipeName { get; set; } + + /// + /// Gets or sets the Uri where the Tracer can send metrics. + /// + /// + public Uri MetricsEndpointUrl { get; set; } + + /// + /// Gets or sets the timeout in milliseconds for the windows named pipe requests. + /// Default is 100. + /// + /// + public int TracesPipeTimeoutMs { get; set; } + + /// + /// Gets or sets the windows pipe name where the Tracer can send stats. + /// Default is null. + /// + /// + public string MetricsPipeName { get; set; } + + /// + /// Gets or sets the port where the DogStatsd server is listening for connections. + /// Default is 8125. + /// + /// + public int DogStatsdPort { get; set; } + + /// + /// Gets or sets a value indicating whether partial flush is enabled + /// + public bool PartialFlushEnabled { get; set; } + + /// + /// Gets or sets the minimum number of closed spans in a trace before it's partially flushed + /// + public int PartialFlushMinSpans + { + get => _partialFlushMinSpans; + set + { + if (value <= 0) + { + throw new ArgumentException("The value must be strictly greater than 0", nameof(PartialFlushMinSpans)); + } + + _partialFlushMinSpans = value; + } + } + + /// + /// Gets or sets the transport used to send traces to the Agent. + /// + internal TracesTransportType TracesTransport { get; set; } + + /// + /// Gets or sets the transport used to connect to the DogStatsD. + /// Default is TransportStrategy.Tcp. + /// + internal TransportType MetricsTransport { get; set; } + + private void ConfigureMetricsTransport(IConfigurationSource source, bool isWindows) + { + var metricsTransport = TransportType.UDP; // default + + var dogStatsdPort = source?.GetInt32(ConfigurationKeys.DogStatsdPort); + + // Agent port is set to zero in places like AAS where it's needed to prevent port conflict + // The agent will fail to start if it can not bind a port + if (dogStatsdPort == 0) + { + MetricsPipeName = source?.GetString(ConfigurationKeys.MetricsPipeName); + + if (MetricsPipeName != null) + { + metricsTransport = TransportType.NamedPipe; + } + } + else + { + DogStatsdPort = dogStatsdPort ?? DefaultDogstatsdPort; + } + + MetricsTransport = metricsTransport; + + var metricsEndpointUrl = source?.GetString(ConfigurationKeys.MetricsEndpointUrl) ?? + // default value + "http://localhost:9943/v2/datapoint"; + MetricsEndpointUrl = new Uri(metricsEndpointUrl); + } + + private void ConfigureTraceTransport(IConfigurationSource source, bool isWindows) + { + TracesTransportType? traceTransport = null; + + var agentHost = source?.GetString(ConfigurationKeys.AgentHost) ?? + // backwards compatibility for names used in the past + source?.GetString("SIGNALFX_TRACE_AGENT_HOSTNAME") ?? + // default value + DefaultAgentHost; + + var agentPort = source?.GetInt32(ConfigurationKeys.AgentPort) ?? + // backwards compatibility for names used in the past + source?.GetInt32("SIGNALFX_TRACE_AGENT_PORT") ?? + // default value + DefaultAgentPort; + + var agentUri = source?.GetString(ConfigurationKeys.AgentUri) ?? + source?.GetString(ConfigurationKeys.EndpointUrl) ?? + // default value + $"http://{agentHost}:{agentPort}/api/v2/spans"; + + AgentUri = new Uri(agentUri); + + if (string.Equals(AgentUri.Host, "localhost", StringComparison.OrdinalIgnoreCase)) + { + // Replace localhost with 127.0.0.1 to avoid DNS resolution. + // When ipv6 is enabled, localhost is first resolved to ::1, which fails + // because the trace agent is only bound to ipv4. + // This causes delays when sending traces. + var builder = new UriBuilder(agentUri) { Host = "127.0.0.1" }; + AgentUri = builder.Uri; + } + + // Agent port is set to zero in places like AAS where it's needed to prevent port conflict + // The agent will fail to start if it can not bind a port + var hasExplicitTcpConfig = agentPort != 0 && agentHost != null; + + if (hasExplicitTcpConfig) + { + // If there is any explicit configuration for TCP, prioritize it + traceTransport = TracesTransportType.Default; + } + else if (isWindows) + { + // Check for explicit windows named pipe config + TracesPipeName = source?.GetString(ConfigurationKeys.TracesPipeName); + + if (TracesPipeName != null) + { + traceTransport = TracesTransportType.WindowsNamedPipe; + } + + TracesPipeTimeoutMs = source?.GetInt32(ConfigurationKeys.TracesPipeTimeoutMs) +#if DEBUG + ?? 20_000; +#else + ?? 500; +#endif + } + + TracesTransport = traceTransport ?? TracesTransportType.Default; + } + } +} diff --git a/tracer/src/Datadog.Trace/Configuration/ImmutableExporterSettings.cs b/tracer/src/Datadog.Trace/Configuration/ImmutableExporterSettings.cs new file mode 100644 index 000000000..d4449b79c --- /dev/null +++ b/tracer/src/Datadog.Trace/Configuration/ImmutableExporterSettings.cs @@ -0,0 +1,113 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +// Modified by Splunk Inc. + +using System; + +namespace Datadog.Trace.Configuration +{ + /// + /// Contains exporter related settings. + /// + public class ImmutableExporterSettings + { + /// + /// Initializes a new instance of the class + /// using the specified to initialize values. + /// + /// The to use when retrieving configuration values. + public ImmutableExporterSettings(IConfigurationSource source) + : this(new ExporterSettings(source)) + { + } + + /// + /// Initializes a new instance of the class from + /// a TracerSettings instance. + /// + /// The tracer settings to use to populate the immutable tracer settings + public ImmutableExporterSettings(ExporterSettings settings) + { + AgentUri = settings.AgentUri; + + TracesTransport = settings.TracesTransport; + TracesPipeName = settings.TracesPipeName; + TracesPipeTimeoutMs = settings.TracesPipeTimeoutMs; + + MetricsEndpointUrl = settings.MetricsEndpointUrl; + MetricsTransport = settings.MetricsTransport; + MetricsPipeName = settings.MetricsPipeName; + DogStatsdPort = settings.DogStatsdPort; + + PartialFlushEnabled = settings.PartialFlushEnabled; + PartialFlushMinSpans = settings.PartialFlushMinSpans; + } + + /// + /// Gets the Uri where the Tracer can connect to the Agent. + /// Default is "http://localhost:8126". + /// + /// + /// + /// + public Uri AgentUri { get; } + + /// + /// Gets the Uri where the Tracer can connect to the metrics Agent. + /// + /// + public Uri MetricsEndpointUrl { get; } + + /// + /// Gets the windows pipe name where the Tracer can connect to the Agent. + /// Default is null. + /// + /// + public string TracesPipeName { get; } + + /// + /// Gets the timeout in milliseconds for the windows named pipe requests. + /// Default is 100. + /// + /// + public int TracesPipeTimeoutMs { get; } + + /// + /// Gets the windows pipe name where the Tracer can send stats. + /// Default is null. + /// + /// + public string MetricsPipeName { get; } + + /// + /// Gets the port where the DogStatsd server is listening for connections. + /// Default is 8125. + /// + /// + public int DogStatsdPort { get; } + + /// + /// Gets a value indicating whether partial flush is enabled + /// + public bool PartialFlushEnabled { get; } + + /// + /// Gets the minimum number of closed spans in a trace before it's partially flushed + /// + public int PartialFlushMinSpans { get; } + + /// + /// Gets the transport used to send traces to the Agent. + /// + internal TracesTransportType TracesTransport { get; } + + /// + /// Gets the transport used to connect to the DogStatsD. + /// Default is TransportStrategy.Tcp. + /// + internal Vendors.StatsdClient.Transport.TransportType MetricsTransport { get; } + } +} diff --git a/tracer/src/Datadog.Trace/Configuration/ImmutableTracerSettings.cs b/tracer/src/Datadog.Trace/Configuration/ImmutableTracerSettings.cs index 6b5622a77..168f68c09 100644 --- a/tracer/src/Datadog.Trace/Configuration/ImmutableTracerSettings.cs +++ b/tracer/src/Datadog.Trace/Configuration/ImmutableTracerSettings.cs @@ -41,13 +41,9 @@ public ImmutableTracerSettings(TracerSettings settings) ServiceName = settings.ServiceName; ServiceVersion = settings.ServiceVersion; TraceEnabled = settings.TraceEnabled; - AgentUri = settings.AgentUri; - MetricsEndpointUrl = settings.MetricsEndpointUrl; - MetricsExporter = settings.MetricsExporter; + ExporterSettings = new ImmutableExporterSettings(settings.ExporterSettings); TracesTransport = settings.TracesTransport; - TracesPipeName = settings.TracesPipeName; - TracesPipeTimeoutMs = settings.TracesPipeTimeoutMs; - MetricsPipeName = settings.MetricsPipeName; + MetricsExporter = settings.MetricsExporter; #pragma warning disable 618 // App analytics is deprecated, but still used AnalyticsEnabled = settings.AnalyticsEnabled; #pragma warning restore 618 @@ -58,11 +54,8 @@ public ImmutableTracerSettings(TracerSettings settings) Integrations = new ImmutableIntegrationSettingsCollection(settings.Integrations, settings.DisabledIntegrationNames); GlobalTags = new ReadOnlyDictionary(settings.GlobalTags); HeaderTags = new ReadOnlyDictionary(settings.HeaderTags); - DogStatsdPort = settings.DogStatsdPort; TracerMetricsEnabled = settings.TracerMetricsEnabled; RuntimeMetricsEnabled = settings.RuntimeMetricsEnabled; - PartialFlushEnabled = settings.PartialFlushEnabled; - PartialFlushMinSpans = settings.PartialFlushMinSpans; KafkaCreateConsumerScopeEnabled = settings.KafkaCreateConsumerScopeEnabled; StartupDiagnosticLogEnabled = settings.StartupDiagnosticLogEnabled; HttpClientExcludedUrlSubstrings = settings.HttpClientExcludedUrlSubstrings; @@ -118,19 +111,9 @@ public ImmutableTracerSettings(TracerSettings settings) public bool TraceEnabled { get; } /// - /// Gets the Uri where the Tracer can connect to the Agent. - /// Default is "http://localhost:8126". - /// - /// - /// - /// - public Uri AgentUri { get; } - - /// - /// Gets the Uri where the Tracer can connect to the metrics Agent. + /// Gets the exporter settings that dictate how the tracer exports data. /// - /// - public Uri MetricsEndpointUrl { get; } + public ImmutableExporterSettings ExporterSettings { get; } /// /// Gets the key used to determine the transport for sending traces. @@ -139,27 +122,6 @@ public ImmutableTracerSettings(TracerSettings settings) /// public string TracesTransport { get; } - /// - /// Gets the windows pipe name where the Tracer can connect to the Agent. - /// Default is null. - /// - /// - public string TracesPipeName { get; } - - /// - /// Gets the timeout in milliseconds for the windows named pipe requests. - /// Default is 100. - /// - /// - public int TracesPipeTimeoutMs { get; } - - /// - /// Gets the windows pipe name where the Tracer can send stats. - /// Default is null. - /// - /// - public string MetricsPipeName { get; } - /// /// Gets a value indicating whether default Analytics are enabled. /// Settings this value is a shortcut for setting @@ -212,35 +174,12 @@ public ImmutableTracerSettings(TracerSettings settings) /// public IReadOnlyDictionary HeaderTags { get; } - /// - /// Gets the port where the DogStatsd server is listening for connections. - /// Default is 8125. - /// - /// - public int DogStatsdPort { get; } - /// /// Gets a value indicating whether internal metrics /// are enabled and sent to DogStatsd. /// public bool TracerMetricsEnabled { get; } - /// - /// Gets a value indicating whether runtime metrics - /// are enabled and sent to DogStatsd. - /// - public bool RuntimeMetricsEnabled { get; } - - /// - /// Gets a value indicating whether partial flush is enabled - /// - public bool PartialFlushEnabled { get; } - - /// - /// Gets the minimum number of closed spans in a trace before it's partially flushed - /// - public int PartialFlushMinSpans { get; } - /// /// Gets a value indicating whether a span context should be created on exiting a successful Kafka /// Consumer.Consume() call, and closed on entering Consumer.Consume(). @@ -253,6 +192,12 @@ public ImmutableTracerSettings(TracerSettings settings) /// public bool StartupDiagnosticLogEnabled { get; } + /// + /// Gets a value indicating whether runtime metrics + /// are enabled and sent to DogStatsd. + /// + internal bool RuntimeMetricsEnabled { get; } + /// /// Gets the comma separated list of url patterns to skip tracing. /// @@ -424,5 +369,10 @@ internal string GetServiceName(Tracer tracer, string serviceName) { return ServiceNameMappings.GetServiceName(tracer.DefaultServiceName, serviceName); } + + internal bool TryGetServiceName(string key, out string serviceName) + { + return ServiceNameMappings.TryGetServiceName(key, out serviceName); + } } } diff --git a/tracer/src/Datadog.Trace/Configuration/IntegrationId.cs b/tracer/src/Datadog.Trace/Configuration/IntegrationId.cs index 000c95563..f5d94ccdd 100644 --- a/tracer/src/Datadog.Trace/Configuration/IntegrationId.cs +++ b/tracer/src/Datadog.Trace/Configuration/IntegrationId.cs @@ -12,6 +12,7 @@ internal enum IntegrationId WinHttpHandler, CurlHandler, AspNetCore, + AdoNet, AspNet, AspNetMvc, AspNetWebApi2, diff --git a/tracer/src/Datadog.Trace/Configuration/IntegrationSettings.cs b/tracer/src/Datadog.Trace/Configuration/IntegrationSettings.cs index 8f5f33687..c61ece430 100644 --- a/tracer/src/Datadog.Trace/Configuration/IntegrationSettings.cs +++ b/tracer/src/Datadog.Trace/Configuration/IntegrationSettings.cs @@ -6,6 +6,7 @@ // Modified by Splunk Inc. using System; +using Datadog.Trace.Util; namespace Datadog.Trace.Configuration { @@ -21,7 +22,12 @@ public class IntegrationSettings /// The to use when retrieving configuration values. public IntegrationSettings(string integrationName, IConfigurationSource source) { - IntegrationName = integrationName ?? throw new ArgumentNullException(nameof(integrationName)); + if (integrationName is null) + { + ThrowHelper.ThrowArgumentNullException(nameof(integrationName)); + } + + IntegrationName = integrationName; if (source == null) { diff --git a/tracer/src/Datadog.Trace/Configuration/ServiceNames.cs b/tracer/src/Datadog.Trace/Configuration/ServiceNames.cs index c11e11a6d..db763722d 100644 --- a/tracer/src/Datadog.Trace/Configuration/ServiceNames.cs +++ b/tracer/src/Datadog.Trace/Configuration/ServiceNames.cs @@ -35,6 +35,17 @@ public string GetServiceName(string applicationName, string key) } } + public bool TryGetServiceName(string key, out string name) + { + if (_mappings is not null && _mappings.TryGetValue(key, out name)) + { + return true; + } + + name = null; + return false; + } + public void SetServiceNameMappings(IEnumerable> mappings) { lock (_lock) diff --git a/tracer/src/Datadog.Trace/Configuration/TracerSettings.cs b/tracer/src/Datadog.Trace/Configuration/TracerSettings.cs index 1f36265fb..23f8a7c75 100644 --- a/tracer/src/Datadog.Trace/Configuration/TracerSettings.cs +++ b/tracer/src/Datadog.Trace/Configuration/TracerSettings.cs @@ -23,20 +23,8 @@ namespace Datadog.Trace.Configuration /// public class TracerSettings { - /// - /// The default host value for . - /// - public const string DefaultAgentHost = "localhost"; - - /// - /// The default port value for . - /// - public const int DefaultAgentPort = 9411; - private const int DefaultRecordedValueMaxLength = 12000; - private int _partialFlushMinSpans; - /// /// Initializes a new instance of the class with default values. /// @@ -75,45 +63,7 @@ public TracerSettings(IConfigurationSource source) Integrations = new IntegrationSettingsCollection(source); - var agentHost = source?.GetString(ConfigurationKeys.AgentHost) ?? - // backwards compatibility for names used in the past - source?.GetString("SIGNALFX_TRACE_AGENT_HOSTNAME") ?? - // default value - DefaultAgentHost; - - var agentPort = source?.GetInt32(ConfigurationKeys.AgentPort) ?? - // backwards compatibility for names used in the past - source?.GetInt32("SIGNALFX_TRACE_AGENT_PORT") ?? - // default value - DefaultAgentPort; - - var agentUri = source?.GetString(ConfigurationKeys.AgentUri) ?? - source?.GetString(ConfigurationKeys.EndpointUrl) ?? - // default value - $"http://{agentHost}:{agentPort}/api/v2/spans"; - - AgentUri = new Uri(agentUri); - - TracesPipeName = source?.GetString(ConfigurationKeys.TracesPipeName); - - TracesPipeTimeoutMs = source?.GetInt32(ConfigurationKeys.TracesPipeTimeoutMs) -#if DEBUG - ?? 20_000; -#else - ?? 500; -#endif - - TracesTransport = source?.GetString(ConfigurationKeys.TracesTransport); - - if (string.Equals(AgentUri.Host, "localhost", StringComparison.OrdinalIgnoreCase)) - { - // Replace localhost with 127.0.0.1 to avoid DNS resolution. - // When ipv6 is enabled, localhost is first resolved to ::1, which fails - // because the trace agent is only bound to ipv4. - // This causes delays when sending traces. - var builder = new UriBuilder(agentUri) { Host = "127.0.0.1" }; - AgentUri = builder.Uri; - } + ExporterSettings = new ExporterSettings(source); #pragma warning disable 618 // App analytics is deprecated, but still used AnalyticsEnabled = source?.GetBool(ConfigurationKeys.GlobalAnalyticsEnabled) ?? @@ -152,15 +102,6 @@ public TracerSettings(IConfigurationSource source) ServiceNameMappings = new ServiceNames(serviceNameMappings); - DogStatsdPort = source?.GetInt32(ConfigurationKeys.DogStatsdPort) ?? - // default value - 8125; - - var metricsEndpointUrl = source?.GetString(ConfigurationKeys.MetricsEndpointUrl) ?? - // default value - "http://localhost:9943/v2/datapoint"; - MetricsEndpointUrl = new Uri(metricsEndpointUrl); - MetricsExporter = source.GetTypedValue(ConfigurationKeys.MetricsExporter); TracerMetricsEnabled = source?.GetBool(ConfigurationKeys.TracerMetricsEnabled) ?? @@ -223,18 +164,8 @@ public TracerSettings(IConfigurationSource source) RouteTemplateResourceNamesEnabled = source?.GetBool(ConfigurationKeys.FeatureFlags.RouteTemplateResourceNamesEnabled) ?? true; - TraceResponseHeaderEnabled = source?.GetBool(ConfigurationKeys.TraceResponseHeaderEnabled) ?? true; - - PartialFlushEnabled = source?.GetBool(ConfigurationKeys.PartialFlushEnabled) - // default value - ?? false; - - var partialFlushMinSpans = source?.GetInt32(ConfigurationKeys.PartialFlushMinSpans); - - if ((partialFlushMinSpans ?? 0) <= 0) - { - PartialFlushMinSpans = 500; - } + TraceResponseHeaderEnabled = source?.GetBool(ConfigurationKeys.TraceResponseHeaderEnabled) + ?? true; KafkaCreateConsumerScopeEnabled = source?.GetBool(ConfigurationKeys.KafkaCreateConsumerScopeEnabled) ?? true; // default @@ -290,19 +221,9 @@ public TracerSettings(IConfigurationSource source) public HashSet DisabledIntegrationNames { get; set; } /// - /// Gets or sets the Uri where the Tracer can connect to the Agent. - /// Default is "http://localhost:8126". - /// - /// - /// - /// - public Uri AgentUri { get; set; } - - /// - /// Gets or sets the Uri where the Tracer can send metrics. + /// Gets or sets the transport settings that dictate how the tracer connects to the agent. /// - /// - public Uri MetricsEndpointUrl { get; set; } + public ExporterSettings ExporterSettings { get; set; } /// /// Gets or sets the key used to determine the transport for sending traces. @@ -311,27 +232,6 @@ public TracerSettings(IConfigurationSource source) /// public string TracesTransport { get; set; } - /// - /// Gets or sets the windows pipe name where the Tracer can connect to the Agent. - /// Default is null. - /// - /// - public string TracesPipeName { get; set; } - - /// - /// Gets or sets the timeout in milliseconds for the windows named pipe requests. - /// Default is 100. - /// - /// - public int TracesPipeTimeoutMs { get; set; } - - /// - /// Gets or sets the windows pipe name where the Tracer can send stats. - /// Default is null. - /// - /// - public string MetricsPipeName { get; set; } - /// /// Gets or sets a value indicating whether default Analytics are enabled. /// Settings this value is a shortcut for setting @@ -384,13 +284,6 @@ public TracerSettings(IConfigurationSource source) /// public IDictionary HeaderTags { get; set; } - /// - /// Gets or sets the port where the DogStatsd server is listening for connections. - /// Default is 8125. - /// - /// - public int DogStatsdPort { get; set; } - /// /// Gets or sets a value indicating whether internal metrics /// are enabled and sent to DogStatsd. @@ -457,28 +350,6 @@ public bool DiagnosticSourceEnabled set { } } - /// - /// Gets or sets a value indicating whether partial flush is enabled - /// - public bool PartialFlushEnabled { get; set; } - - /// - /// Gets or sets the minimum number of closed spans in a trace before it's partially flushed - /// - public int PartialFlushMinSpans - { - get => _partialFlushMinSpans; - set - { - if (value <= 0) - { - throw new ArgumentException("The value must be strictly greater than 0", nameof(PartialFlushMinSpans)); - } - - _partialFlushMinSpans = value; - } - } - /// /// Gets or sets a value indicating whether a span context should be created on exiting a successful Kafka /// Consumer.Consume() call, and closed on entering Consumer.Consume(). diff --git a/tracer/src/Datadog.Trace/Configuration/TracesTransportType.cs b/tracer/src/Datadog.Trace/Configuration/TracesTransportType.cs new file mode 100644 index 000000000..c7ee806f5 --- /dev/null +++ b/tracer/src/Datadog.Trace/Configuration/TracesTransportType.cs @@ -0,0 +1,31 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +namespace Datadog.Trace.Configuration +{ + /// + /// Available types of transports. + /// + internal enum TracesTransportType + { + /// + /// Default transport. + /// Defers transport logic to agent API. + /// + Default, + + /// + /// Experimental TCP strategy for HttpStreamRequestFactory. + /// Potential candidate for removing reliance on System.Net.Http. + /// + CustomTcpProvider, + + /// + /// Windows Named Pipe strategy for HttpStreamRequestFactory. + /// Transport used primarily for Azure App Service. + /// + WindowsNamedPipe + } +} diff --git a/tracer/src/Datadog.Trace/DiagnosticListeners/AspNetCoreDiagnosticObserver.cs b/tracer/src/Datadog.Trace/DiagnosticListeners/AspNetCoreDiagnosticObserver.cs index 5eea0dc5b..7cf33bbad 100644 --- a/tracer/src/Datadog.Trace/DiagnosticListeners/AspNetCoreDiagnosticObserver.cs +++ b/tracer/src/Datadog.Trace/DiagnosticListeners/AspNetCoreDiagnosticObserver.cs @@ -11,9 +11,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using System.Text; using Datadog.Trace.AppSec; -using Datadog.Trace.AppSec.Transport.Http; using Datadog.Trace.Configuration; using Datadog.Trace.DuckTyping; using Datadog.Trace.ExtensionMethods; @@ -23,7 +21,6 @@ using Datadog.Trace.Propagation; using Datadog.Trace.Tagging; using Datadog.Trace.Util; -using Datadog.Trace.Util.Http; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.Abstractions; using Microsoft.AspNetCore.Routing; @@ -489,10 +486,7 @@ private static Span StartMvcCoreSpan(Tracer tracer, Span parentSpan, BeforeActio { // Create a child span for the MVC action var mvcSpanTags = new AspNetCoreMvcTags(); - - // Upstream sets a good value for span name later when filling up the resource name, the name - // will be updated at that time. - var mvcScope = tracer.StartActiveWithTags(MvcOperationName, parentSpan.Context, tags: mvcSpanTags); + var mvcScope = tracer.StartActiveInternal(MvcOperationName, parentSpan.Context, tags: mvcSpanTags); var span = mvcScope.Span; span.Type = SpanTypes.Web; span.LogicScope = MvcOperationName; @@ -567,7 +561,7 @@ private static Span StartMvcCoreSpan(Tracer tracer, Span parentSpan, BeforeActio controllerName: controllerName, actionName: actionName); - resourceName = $"{parentTags.HttpMethod} {request.PathBase.Value}{resourcePathName}"; + resourceName = $"{parentTags.HttpMethod} {request.PathBase.ToUriComponent()}{resourcePathName}"; aspNetRoute = routeTemplate?.TemplateText.ToLowerInvariant(); } } @@ -650,7 +644,7 @@ private void OnRoutingEndpointMatched(object arg) return; } - Span span = tracer.ActiveScope?.Span; + Span span = tracer.InternalActiveScope?.Span; if (span != null) { @@ -743,7 +737,7 @@ private void OnRoutingEndpointMatched(object arg) controllerName: controllerName, actionName: actionName); - var resourceName = $"{tags.HttpMethod} {request.PathBase}{resourcePathName}"; + var resourceName = $"{tags.HttpMethod} {request.PathBase.ToUriComponent()}{resourcePathName}"; // NOTE: We could set the controller/action/area tags on the parent span // But instead we re-extract them in the MVC endpoint as these are MVC @@ -776,7 +770,7 @@ private void OnMvcBeforeAction(object arg) return; } - Span parentSpan = tracer.ActiveScope?.Span; + Span parentSpan = tracer.InternalActiveScope?.Span; if (parentSpan != null && arg.TryDuckCast(out var typedArg)) { @@ -815,7 +809,7 @@ private void OnMvcAfterAction(object arg) return; } - var scope = tracer.ActiveScope; + var scope = tracer.InternalActiveScope; if (scope is not null && ReferenceEquals(scope.Span.LogicScope, MvcOperationName)) { @@ -832,7 +826,7 @@ private void OnHostingHttpRequestInStop(object arg) return; } - var scope = tracer.ActiveScope; + var scope = tracer.InternalActiveScope; if (scope != null) { @@ -869,7 +863,7 @@ private void OnHostingUnhandledException(object arg) return; } - var span = tracer.ActiveScope?.Span; + var span = tracer.InternalActiveScope?.Span; if (span != null && arg.TryDuckCast(out var unhandledStruct)) { @@ -887,28 +881,28 @@ private void OnHostingUnhandledException(object arg) } [DuckCopy] - public struct HttpRequestInStartStruct + internal struct HttpRequestInStartStruct { [Duck(BindingFlags = DuckAttribute.DefaultFlags | BindingFlags.IgnoreCase)] public HttpContext HttpContext; } [DuckCopy] - public struct HttpRequestInStopStruct + internal struct HttpRequestInStopStruct { [Duck(BindingFlags = DuckAttribute.DefaultFlags | BindingFlags.IgnoreCase)] public HttpContext HttpContext; } [DuckCopy] - public struct UnhandledExceptionStruct + internal struct UnhandledExceptionStruct { [Duck(BindingFlags = DuckAttribute.DefaultFlags | BindingFlags.IgnoreCase)] public Exception Exception; } [DuckCopy] - public struct BeforeActionStruct + internal struct BeforeActionStruct { [Duck(BindingFlags = DuckAttribute.DefaultFlags | BindingFlags.IgnoreCase)] public HttpContext HttpContext; @@ -921,14 +915,14 @@ public struct BeforeActionStruct } [DuckCopy] - public struct BadHttpRequestExceptionStruct + internal struct BadHttpRequestExceptionStruct { [Duck(BindingFlags = DuckAttribute.DefaultFlags | BindingFlags.IgnoreCase | BindingFlags.NonPublic)] public int StatusCode; } [DuckCopy] - public struct HttpRequestInEndpointMatchedStruct + internal struct HttpRequestInEndpointMatchedStruct { [Duck(BindingFlags = DuckAttribute.DefaultFlags | BindingFlags.IgnoreCase)] public HttpContext HttpContext; @@ -939,13 +933,13 @@ public struct HttpRequestInEndpointMatchedStruct /// /// [DuckCopy] - public struct EndpointFeatureStruct + internal struct EndpointFeatureStruct { public RouteEndpoint Endpoint; } [DuckCopy] - public struct HttpRequestStruct + internal struct HttpRequestStruct { public string Method; public RouteValueDictionary RouteValues; @@ -956,7 +950,7 @@ public struct HttpRequestStruct /// Proxy for https://github1s.com/dotnet/aspnetcore/blob/v3.0.3/src/Http/Routing/src/Patterns/RoutePatternPathSegment.cs /// [DuckCopy] - public struct RoutePatternPathSegmentStruct + internal struct RoutePatternPathSegmentStruct { public IEnumerable Parts; } @@ -966,7 +960,7 @@ public struct RoutePatternPathSegmentStruct /// and https://github1s.com/dotnet/aspnetcore/blob/v3.0.3/src/Http/Routing/src/Patterns/RoutePatternSeparatorPart.cs /// [DuckCopy] - public struct RoutePatternContentPartStruct + internal struct RoutePatternContentPartStruct { public string Content; } @@ -975,7 +969,7 @@ public struct RoutePatternContentPartStruct /// Proxy for https://github1s.com/dotnet/aspnetcore/blob/v3.0.3/src/Http/Routing/src/Patterns/RoutePatternParameterPart.cs /// [DuckCopy] - public struct RoutePatternParameterPartStruct + internal struct RoutePatternParameterPartStruct { public string Name; public bool IsOptional; diff --git a/tracer/src/Datadog.Trace/DiagnosticListeners/DiagnosticManager.cs b/tracer/src/Datadog.Trace/DiagnosticListeners/DiagnosticManager.cs index 8026f9bbf..fa63131c9 100644 --- a/tracer/src/Datadog.Trace/DiagnosticListeners/DiagnosticManager.cs +++ b/tracer/src/Datadog.Trace/DiagnosticListeners/DiagnosticManager.cs @@ -9,6 +9,7 @@ using System.Diagnostics; using System.Linq; using Datadog.Trace.Logging; +using Datadog.Trace.Util; using Datadog.Trace.Vendors.Serilog.Events; namespace Datadog.Trace.DiagnosticListeners @@ -25,7 +26,7 @@ public DiagnosticManager(IEnumerable diagnosticSubscribers) { if (diagnosticSubscribers == null) { - throw new ArgumentNullException(nameof(diagnosticSubscribers)); + ThrowHelper.ThrowArgumentNullException(nameof(diagnosticSubscribers)); } _diagnosticObservers = diagnosticSubscribers.Where(x => x.IsSubscriberEnabled()); diff --git a/tracer/src/Datadog.Trace/DiagnosticListeners/EndpointFeatureProxy.cs b/tracer/src/Datadog.Trace/DiagnosticListeners/EndpointFeatureProxy.cs index f5030f109..3641d92bb 100644 --- a/tracer/src/Datadog.Trace/DiagnosticListeners/EndpointFeatureProxy.cs +++ b/tracer/src/Datadog.Trace/DiagnosticListeners/EndpointFeatureProxy.cs @@ -1,9 +1,8 @@ -// +// // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.DiagnosticListeners @@ -13,9 +12,7 @@ namespace Datadog.Trace.DiagnosticListeners /// explicitly, e.g. by https://github.com/dotnet/aspnetcore/blob/v3.0.3/src/Servers/Kestrel/Core/src/Internal/Http/HttpProtocol.FeatureCollection.cs /// Also see AspNetCoreDiagnosticObserver.EndpointFeatureStruct /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public class EndpointFeatureProxy + internal class EndpointFeatureProxy { /// /// Delegates to IEndpointFeature.Endpoint; diff --git a/tracer/src/Datadog.Trace/DiagnosticListeners/RouteEndpoint.cs b/tracer/src/Datadog.Trace/DiagnosticListeners/RouteEndpoint.cs index 5cf92a963..b28dac4d9 100644 --- a/tracer/src/Datadog.Trace/DiagnosticListeners/RouteEndpoint.cs +++ b/tracer/src/Datadog.Trace/DiagnosticListeners/RouteEndpoint.cs @@ -1,9 +1,8 @@ -// +// // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.DiagnosticListeners @@ -11,10 +10,8 @@ namespace Datadog.Trace.DiagnosticListeners /// /// Endpoint for duck typing /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] [DuckCopy] - public struct RouteEndpoint + internal struct RouteEndpoint { /// /// Delegates to Endpoint.RoutePattern; diff --git a/tracer/src/Datadog.Trace/DiagnosticListeners/RoutePattern.cs b/tracer/src/Datadog.Trace/DiagnosticListeners/RoutePattern.cs index d663239dc..79fbe48f8 100644 --- a/tracer/src/Datadog.Trace/DiagnosticListeners/RoutePattern.cs +++ b/tracer/src/Datadog.Trace/DiagnosticListeners/RoutePattern.cs @@ -1,10 +1,9 @@ -// +// // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // using System.Collections; -using System.ComponentModel; using Datadog.Trace.DuckTyping; namespace Datadog.Trace.DiagnosticListeners @@ -12,10 +11,8 @@ namespace Datadog.Trace.DiagnosticListeners /// /// RoutePattern for duck typing /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] [DuckCopy] - public struct RoutePattern + internal struct RoutePattern { /// /// Gets the list of IReadOnlyList<RoutePatternPathSegment> diff --git a/tracer/src/Datadog.Trace/ExtensionMethods/DictionaryExtensions.cs b/tracer/src/Datadog.Trace/ExtensionMethods/DictionaryExtensions.cs index 356a9ae93..7e0276a6a 100644 --- a/tracer/src/Datadog.Trace/ExtensionMethods/DictionaryExtensions.cs +++ b/tracer/src/Datadog.Trace/ExtensionMethods/DictionaryExtensions.cs @@ -7,6 +7,7 @@ using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; +using Datadog.Trace.Util; namespace Datadog.Trace.ExtensionMethods { @@ -16,7 +17,7 @@ public static TValue GetValueOrDefault(this IDictionary(this IDictionary dictionary, obje { if (dictionary == null) { - throw new ArgumentNullException(nameof(dictionary)); + ThrowHelper.ThrowArgumentNullException(nameof(dictionary)); } return dictionary.TryGetValue(key, out TValue value) @@ -40,7 +41,7 @@ public static bool TryGetValue(this IDictionary dictionary, object key, { if (dictionary == null) { - throw new ArgumentNullException(nameof(dictionary)); + ThrowHelper.ThrowArgumentNullException(nameof(dictionary)); } object valueObj; diff --git a/tracer/src/Datadog.Trace/ExtensionMethods/NameValueCollectionExtensions.cs b/tracer/src/Datadog.Trace/ExtensionMethods/NameValueCollectionExtensions.cs index 940358b60..14e5ff6fc 100644 --- a/tracer/src/Datadog.Trace/ExtensionMethods/NameValueCollectionExtensions.cs +++ b/tracer/src/Datadog.Trace/ExtensionMethods/NameValueCollectionExtensions.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Specialized; using Datadog.Trace.Headers; +using Datadog.Trace.Util; namespace Datadog.Trace.ExtensionMethods { @@ -23,7 +24,7 @@ public static NameValueHeadersCollection Wrap(this NameValueCollection collectio { if (collection == null) { - throw new ArgumentNullException(nameof(collection)); + ThrowHelper.ThrowArgumentNullException(nameof(collection)); } return new NameValueHeadersCollection(collection); diff --git a/tracer/src/Datadog.Trace/ExtensionMethods/SpanExtensions.cs b/tracer/src/Datadog.Trace/ExtensionMethods/SpanExtensions.cs index a5df0b02e..73921efcb 100644 --- a/tracer/src/Datadog.Trace/ExtensionMethods/SpanExtensions.cs +++ b/tracer/src/Datadog.Trace/ExtensionMethods/SpanExtensions.cs @@ -11,41 +11,24 @@ using System.Data.Common; using Datadog.Trace.Configuration; using Datadog.Trace.Headers; -using Datadog.Trace.Logging; using Datadog.Trace.Propagation; using Datadog.Trace.Tagging; using Datadog.Trace.Util; +using Datadog.Trace.Vendors.Serilog; namespace Datadog.Trace.ExtensionMethods { /// - /// Extension methods for the class. + /// Extension methods for the class. /// public static class SpanExtensions { - private static readonly IDatadogLogger Log = DatadogLogging.GetLoggerFor(typeof(SpanExtensions)); - - /// - /// Sets the sampling priority for the trace that contains the specified . - /// - /// A span that belongs to the trace. - /// The new sampling priority for the trace. - public static void SetTraceSamplingPriority(this Span span, SamplingPriority samplingPriority) - { - if (span == null) { throw new ArgumentNullException(nameof(span)); } - - if (span.Context.TraceContext != null) - { - span.Context.TraceContext.SamplingPriority = samplingPriority; - } - } - /// /// Adds standard tags to a span with values taken from the specified . /// /// The span to add the tags to. /// The db command to get tags values from. - public static void AddTagsFromDbCommand(this Span span, IDbCommand command) + public static void AddTagsFromDbCommand(this ISpan span, IDbCommand command) { var commandText = command.CommandText; span.ResourceName = commandText; @@ -53,16 +36,30 @@ public static void AddTagsFromDbCommand(this Span span, IDbCommand command) span.SetTag(Tags.DbStatement, commandText); - var tags = DbCommandCache.GetTagsFromDbCommand(command); + var tag = DbCommandCache.GetTagsFromDbCommand(command); - foreach (var pair in tags) + span.SetTag(Tags.DbName, tag.DbName); + span.SetTag(Tags.DbUser, tag.DbUser); + span.SetTag(Tags.OutHost, tag.OutHost); + } + + /// + /// Sets the sampling priority for the trace that contains the specified . + /// + /// A span that belongs to the trace. + /// The new sampling priority for the trace. + public static void SetTraceSamplingPriority(this ISpan span, SamplingPriority samplingPriority) + { + if (span == null) { ThrowHelper.ThrowArgumentNullException(nameof(span)); } + + if (span.Context is SpanContext spanContext && spanContext.TraceContext != null) { - span.SetTag(pair.Key, pair.Value); + spanContext.TraceContext.SamplingPriority = samplingPriority; } } internal static void DecorateWebServerSpan( - this Span span, + this ISpan span, string resourceName, string method, string host, @@ -74,9 +71,12 @@ internal static void DecorateWebServerSpan( span.Type = SpanTypes.Web; span.ResourceName = resourceName?.Trim(); - tags.HttpMethod = method; - tags.HttpRequestHeadersHost = host; - tags.HttpUrl = httpUrl; + if (tags is not null) + { + tags.HttpMethod = method; + tags.HttpRequestHeadersHost = host; + tags.HttpUrl = httpUrl; + } tags.PeerIp = remoteIp; @@ -86,7 +86,7 @@ internal static void DecorateWebServerSpan( } } - internal static void SetHeaderTags(this Span span, T headers, IReadOnlyDictionary headerTags, string defaultTagPrefix) + internal static void SetHeaderTags(this ISpan span, T headers, IReadOnlyDictionary headerTags, string defaultTagPrefix) where T : IHeadersCollection { if (headerTags is not null && !headerTags.IsEmpty()) diff --git a/tracer/src/Datadog.Trace/ExtensionMethods/StringExtensions.cs b/tracer/src/Datadog.Trace/ExtensionMethods/StringExtensions.cs index 9188e6cc9..8f9759ad1 100644 --- a/tracer/src/Datadog.Trace/ExtensionMethods/StringExtensions.cs +++ b/tracer/src/Datadog.Trace/ExtensionMethods/StringExtensions.cs @@ -6,6 +6,7 @@ using System; using System.Text; using System.Text.RegularExpressions; +using Datadog.Trace.Util; namespace Datadog.Trace.ExtensionMethods { @@ -20,7 +21,7 @@ internal static class StringExtensions /// A new string with removed from the end, if found. Otherwise, . public static string TrimEnd(this string value, string suffix, StringComparison comparisonType) { - if (value == null) { throw new ArgumentNullException(nameof(value)); } + if (value == null) { ThrowHelper.ThrowArgumentNullException(nameof(value)); } return !string.IsNullOrEmpty(suffix) && value.EndsWith(suffix, comparisonType) ? value.Substring(0, value.Length - suffix.Length) @@ -36,7 +37,7 @@ public static string TrimEnd(this string value, string suffix, StringComparison /// true or false if is one of the accepted values; null otherwise. public static bool? ToBoolean(this string value) { - if (value == null) { throw new ArgumentNullException(nameof(value)); } + if (value == null) { ThrowHelper.ThrowArgumentNullException(nameof(value)); } if (value.Length == 0) { diff --git a/tracer/src/Datadog.Trace/ExtensionMethods/WebHeadersExtensions.cs b/tracer/src/Datadog.Trace/ExtensionMethods/WebHeadersExtensions.cs index 87626fe95..f1c2fb082 100644 --- a/tracer/src/Datadog.Trace/ExtensionMethods/WebHeadersExtensions.cs +++ b/tracer/src/Datadog.Trace/ExtensionMethods/WebHeadersExtensions.cs @@ -8,6 +8,7 @@ using System; using System.Net; using Datadog.Trace.Headers; +using Datadog.Trace.Util; namespace Datadog.Trace.ExtensionMethods { @@ -25,7 +26,7 @@ public static WebHeadersCollection Wrap(this WebHeaderCollection headers) { if (headers == null) { - throw new ArgumentNullException(nameof(headers)); + ThrowHelper.ThrowArgumentNullException(nameof(headers)); } return new WebHeadersCollection(headers); diff --git a/tracer/src/Datadog.Trace/Headers/NameValueHeadersCollection.cs b/tracer/src/Datadog.Trace/Headers/NameValueHeadersCollection.cs index 7795ee921..b58bc77c6 100644 --- a/tracer/src/Datadog.Trace/Headers/NameValueHeadersCollection.cs +++ b/tracer/src/Datadog.Trace/Headers/NameValueHeadersCollection.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; +using Datadog.Trace.Util; namespace Datadog.Trace.Headers { @@ -16,7 +17,12 @@ namespace Datadog.Trace.Headers public NameValueHeadersCollection(NameValueCollection headers) { - _headers = headers ?? throw new ArgumentNullException(nameof(headers)); + if (headers is null) + { + ThrowHelper.ThrowArgumentNullException(nameof(headers)); + } + + _headers = headers; } public IEnumerable GetValues(string name) diff --git a/tracer/src/Datadog.Trace/Headers/WebHeadersCollection.cs b/tracer/src/Datadog.Trace/Headers/WebHeadersCollection.cs index 5764b4432..943a9b499 100644 --- a/tracer/src/Datadog.Trace/Headers/WebHeadersCollection.cs +++ b/tracer/src/Datadog.Trace/Headers/WebHeadersCollection.cs @@ -9,6 +9,7 @@ using System.Collections.Generic; using System.Linq; using System.Net; +using Datadog.Trace.Util; namespace Datadog.Trace.Headers { @@ -18,7 +19,12 @@ namespace Datadog.Trace.Headers public WebHeadersCollection(WebHeaderCollection headers) { - _headers = headers ?? throw new ArgumentNullException(nameof(headers)); + if (headers is null) + { + ThrowHelper.ThrowArgumentNullException(nameof(headers)); + } + + _headers = headers; } public IEnumerable GetValues(string name) diff --git a/tracer/src/Datadog.Trace/HttpOverStreams/DatadogHttpClient.cs b/tracer/src/Datadog.Trace/HttpOverStreams/DatadogHttpClient.cs index 38289799d..9ef58a6e3 100644 --- a/tracer/src/Datadog.Trace/HttpOverStreams/DatadogHttpClient.cs +++ b/tracer/src/Datadog.Trace/HttpOverStreams/DatadogHttpClient.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Datadog.Trace.HttpOverStreams.HttpContent; using Datadog.Trace.Logging; +using Datadog.Trace.Util; namespace Datadog.Trace.HttpOverStreams { @@ -79,7 +80,7 @@ async Task GoNextChar() var bytesRead = await responseStream.ReadAsync(chArray, offset: 0, count: 1).ConfigureAwait(false); if (bytesRead == 0) { - throw new InvalidOperationException($"Unexpected end of stream at position {streamPosition}"); + ThrowHelper.ThrowInvalidOperationException($"Unexpected end of stream at position {streamPosition}"); } currentChar = Encoding.ASCII.GetChars(chArray)[0]; @@ -91,7 +92,7 @@ async Task SkipUntil(int requiredStreamPosition) var requiredBytes = requiredStreamPosition - streamPosition; if (requiredBytes < 0) { - throw new ArgumentOutOfRangeException(nameof(requiredStreamPosition), "StreamPosition already exceeds requiredStreamPosition"); + ThrowHelper.ThrowArgumentOutOfRangeException("StreamPosition already exceeds requiredStreamPosition", nameof(requiredStreamPosition)); } var bytesRemaining = requiredBytes; @@ -102,7 +103,7 @@ async Task SkipUntil(int requiredStreamPosition) lastBytesRead = await responseStream.ReadAsync(chArray, offset: 0, count: bytesToRead).ConfigureAwait(false); if (lastBytesRead == 0) { - throw new InvalidOperationException($"Unexpected end of stream at position {streamPosition}"); + ThrowHelper.ThrowInvalidOperationException($"Unexpected end of stream at position {streamPosition}"); } bytesRemaining -= lastBytesRead; @@ -146,7 +147,7 @@ async Task IsNewLine() if (!currentChar.Equals(DatadogHttpValues.LineFeed)) { - throw new Exception($"Unexpected character {currentChar} in headers: CR must be followed by LF"); + ThrowHelper.ThrowException($"Unexpected character {currentChar} in headers: CR must be followed by LF"); } return true; @@ -170,7 +171,7 @@ async Task IsNewLine() if (!int.TryParse(potentialStatusCode, out var statusCode)) { - throw new DatadogHttpRequestException("Invalid response, can't parse status code. Line was:" + potentialStatusCode); + DatadogHttpRequestException.Throw("Invalid response, can't parse status code. Line was:" + potentialStatusCode); } // Skip to reason diff --git a/tracer/src/Datadog.Trace/HttpOverStreams/DatadogHttpRequestException.cs b/tracer/src/Datadog.Trace/HttpOverStreams/DatadogHttpRequestException.cs index d28b52279..64283e32a 100644 --- a/tracer/src/Datadog.Trace/HttpOverStreams/DatadogHttpRequestException.cs +++ b/tracer/src/Datadog.Trace/HttpOverStreams/DatadogHttpRequestException.cs @@ -4,6 +4,9 @@ // using System; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; namespace Datadog.Trace.HttpOverStreams { @@ -13,5 +16,13 @@ public DatadogHttpRequestException(string message) : base(message) { } + + [MethodImpl(MethodImplOptions.NoInlining)] + [DebuggerHidden] + [DoesNotReturn] + public static void Throw(string message) + { + throw new DatadogHttpRequestException(message); + } } } diff --git a/tracer/src/Datadog.Trace/HttpOverStreams/HttpContent/BufferContent.cs b/tracer/src/Datadog.Trace/HttpOverStreams/HttpContent/BufferContent.cs index 9e17659f9..b55da5847 100644 --- a/tracer/src/Datadog.Trace/HttpOverStreams/HttpContent/BufferContent.cs +++ b/tracer/src/Datadog.Trace/HttpOverStreams/HttpContent/BufferContent.cs @@ -6,6 +6,7 @@ using System; using System.IO; using System.Threading.Tasks; +using Datadog.Trace.Util; namespace Datadog.Trace.HttpOverStreams.HttpContent { @@ -29,7 +30,7 @@ public Task CopyToAsync(byte[] buffer) { if (_buffer.Count > buffer.Length) { - throw new ArgumentOutOfRangeException( + ThrowHelper.ThrowArgumentOutOfRangeException( nameof(buffer), $"Buffer of size {buffer.Length} is not large enough to hold content of size {_buffer.Count}"); } diff --git a/tracer/src/Datadog.Trace/HttpOverStreams/HttpContent/StreamContent.cs b/tracer/src/Datadog.Trace/HttpOverStreams/HttpContent/StreamContent.cs index e1ffb7829..1363c80f7 100644 --- a/tracer/src/Datadog.Trace/HttpOverStreams/HttpContent/StreamContent.cs +++ b/tracer/src/Datadog.Trace/HttpOverStreams/HttpContent/StreamContent.cs @@ -6,6 +6,7 @@ using System; using System.IO; using System.Threading.Tasks; +using Datadog.Trace.Util; namespace Datadog.Trace.HttpOverStreams.HttpContent { @@ -30,12 +31,12 @@ public async Task CopyToAsync(byte[] buffer) { if (!Length.HasValue) { - throw new InvalidOperationException("Unable to CopyToAsync with buffer when content Length is unknown"); + ThrowHelper.ThrowInvalidOperationException("Unable to CopyToAsync with buffer when content Length is unknown"); } if (Length > buffer.Length) { - throw new ArgumentException($"Provided buffer was smaller {buffer.Length} than the content length {Length}"); + ThrowHelper.ThrowArgumentException($"Provided buffer was smaller {buffer.Length} than the content length {Length}"); } var length = 0; diff --git a/tracer/src/Datadog.Trace/IDatadogOpenTracingTracer.cs b/tracer/src/Datadog.Trace/IDatadogOpenTracingTracer.cs new file mode 100644 index 000000000..73c60048f --- /dev/null +++ b/tracer/src/Datadog.Trace/IDatadogOpenTracingTracer.cs @@ -0,0 +1,22 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using System; +using Datadog.Trace.Propagation; + +namespace Datadog.Trace +{ + /// + /// Internal interface for keeping a consistent Tracer API between the Datadog.Trace.OpenTracing assembly and the Datadog.Trace assemblies + /// + internal interface IDatadogOpenTracingTracer + { + string DefaultServiceName { get; } + + IPropagator Propagator { get; } + + ISpan StartSpan(string operationName, ISpanContext parent, string serviceName, DateTimeOffset? startTime, bool ignoreActiveScope); + } +} diff --git a/tracer/src/Datadog.Trace/IDatadogTracer.cs b/tracer/src/Datadog.Trace/IDatadogTracer.cs index 8c3f46212..5035f74d1 100644 --- a/tracer/src/Datadog.Trace/IDatadogTracer.cs +++ b/tracer/src/Datadog.Trace/IDatadogTracer.cs @@ -12,39 +12,18 @@ namespace Datadog.Trace { + /// + /// Internal interface used for mocking the Tracer in , its associated tests, + /// and the AgentWriterTests + /// internal interface IDatadogTracer { string DefaultServiceName { get; } - IScopeManager ScopeManager { get; } - ISampler Sampler { get; } - IPropagator Propagator { get; } - ImmutableTracerSettings Settings { get; } - Span StartSpan(string operationName); - - Span StartSpan(string operationName, ISpanContext parent); - - Span StartSpan(string operationName, ISpanContext parent, string serviceName, DateTimeOffset? startTime, bool ignoreActiveScope); - void Write(ArraySegment span); - - /// - /// Make a span the active span and return its new scope. - /// - /// The span to activate. - /// A Scope object wrapping this span. - Scope ActivateSpan(Span span); - - /// - /// Make a span the active span and return its new scope. - /// - /// The span to activate. - /// Determines whether closing the returned scope will also finish the span. - /// A Scope object wrapping this span. - Scope ActivateSpan(Span span, bool finishOnClose); } } diff --git a/tracer/src/Datadog.Trace/IScope.cs b/tracer/src/Datadog.Trace/IScope.cs new file mode 100644 index 000000000..5460e470f --- /dev/null +++ b/tracer/src/Datadog.Trace/IScope.cs @@ -0,0 +1,28 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using System; + +namespace Datadog.Trace +{ + /// + /// A scope is a handle used to manage the concept of an active span. + /// Meaning that at a given time at most one span is considered active and + /// all newly created spans that are not created with the ignoreActiveSpan + /// parameter will be automatically children of the active span. + /// + public interface IScope : IDisposable + { + /// + /// Gets the active span wrapped in this scope + /// + ISpan Span { get; } + + /// + /// Closes the current scope and makes its parent scope active + /// + void Close(); + } +} diff --git a/tracer/src/Datadog.Trace/ISpan.cs b/tracer/src/Datadog.Trace/ISpan.cs new file mode 100644 index 000000000..3724bc156 --- /dev/null +++ b/tracer/src/Datadog.Trace/ISpan.cs @@ -0,0 +1,109 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using System; + +namespace Datadog.Trace +{ + /// + /// A Span represents a logical unit of work in the system. It may be + /// related to other spans by parent/children relationships. The span + /// tracks the duration of an operation as well as associated metadata in + /// the form of a resource name, a service name, and user defined tags. + /// + public interface ISpan : IDisposable + { + /// + /// Gets or sets operation name + /// + string OperationName { get; set; } + + /// + /// Gets or sets the resource name + /// + string ResourceName { get; set; } + + /// + /// Gets or sets the type of request this span represents (ex: web, db). + /// Not to be confused with span kind. + /// + /// + string Type { get; set; } + + /// + /// Gets or sets a value indicating whether this span represents an error + /// + bool Error { get; set; } + + /// + /// Gets or sets the service name. + /// + string ServiceName { get; set; } + + /// + /// Gets the trace's unique identifier. + /// + TraceId TraceId { get; } + + /// + /// Gets the span's unique identifier. + /// + ulong SpanId { get; } + + /// + /// Gets the span's span context + /// + ISpanContext Context { get; } + + /// + /// Gets or sets the span's logic scope, ie. the source code, used to + /// populate the span. + /// + /// + /// Not used in upstream, added to be used in tests to select the specific + /// logic being tested. + /// + string LogicScope { get; set; } + + /// + /// Gets or sets the span's execution status + /// + SpanStatus Status { get; set; } + + /// + /// Add a the specified tag to this span. + /// + /// The tag's key. + /// The tag's value. + /// This span to allow method chaining. + ISpan SetTag(string key, string value); + + /// + /// Record the end time of the span and flushes it to the backend. + /// After the span has been finished all modifications will be ignored. + /// + void Finish(); + + /// + /// Explicitly set the end time of the span and flushes it to the backend. + /// After the span has been finished all modifications will be ignored. + /// + /// Explicit value for the end time of the Span + void Finish(DateTimeOffset finishTimestamp); + + /// + /// Add the StackTrace and other exception metadata to the span + /// + /// The exception. + void SetException(Exception exception); + + /// + /// Gets the value (or default/null if the key is not a valid tag) of a tag with the key value passed + /// + /// The tag's key + /// The value for the tag with the key specified, or null if the tag does not exist + string GetTag(string key); + } +} diff --git a/tracer/src/Datadog.Trace/ITraceContext.cs b/tracer/src/Datadog.Trace/ITraceContext.cs index 4e553d22b..0e9c57ee1 100644 --- a/tracer/src/Datadog.Trace/ITraceContext.cs +++ b/tracer/src/Datadog.Trace/ITraceContext.cs @@ -19,7 +19,7 @@ internal interface ITraceContext void CloseSpan(Span span); - void LockSamplingPriority(); + void SetSamplingPriority(SamplingPriority? samplingPriority, bool notifyDistributedTracer = true); TimeSpan ElapsedSince(DateTimeOffset date); } diff --git a/tracer/src/Datadog.Trace/ITracer.cs b/tracer/src/Datadog.Trace/ITracer.cs new file mode 100644 index 000000000..eb10fb646 --- /dev/null +++ b/tracer/src/Datadog.Trace/ITracer.cs @@ -0,0 +1,40 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using Datadog.Trace.Configuration; + +namespace Datadog.Trace +{ + /// + /// The tracer is responsible for creating spans and flushing them to the Datadog agent + /// + public interface ITracer + { + /// + /// Gets the active scope + /// + IScope ActiveScope { get; } + + /// + /// Gets this tracer's settings. + /// + ImmutableTracerSettings Settings { get; } + + /// + /// This creates a new span with the given parameters and makes it active. + /// + /// The span's operation name + /// A scope wrapping the newly created span + IScope StartActive(string operationName); + + /// + /// This creates a new span with the given parameters and makes it active. + /// + /// The span's operation name + /// Settings for the new + /// A scope wrapping the newly created span + IScope StartActive(string operationName, SpanCreationSettings settings); + } +} diff --git a/tracer/src/Datadog.Trace/Logging/Internal/DatadogLogging.cs b/tracer/src/Datadog.Trace/Logging/Internal/DatadogLogging.cs index 8afdfb159..1ff6c8b7f 100644 --- a/tracer/src/Datadog.Trace/Logging/Internal/DatadogLogging.cs +++ b/tracer/src/Datadog.Trace/Logging/Internal/DatadogLogging.cs @@ -82,7 +82,7 @@ static DatadogLogging() loggerConfiguration = loggerConfiguration .WriteTo.File( managedLogPath, - outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{Exception} {Properties}{NewLine}", + outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj} {Exception} {Properties}{NewLine}", rollingInterval: RollingInterval.Day, rollOnFileSizeLimit: true, fileSizeLimitBytes: MaxLogFileSize, @@ -110,7 +110,7 @@ static DatadogLogging() loggerConfiguration.Enrich.WithProperty("Process", $"[{domainMetadata.ProcessId} {domainMetadata.ProcessName}]"); loggerConfiguration.Enrich.WithProperty("AppDomain", $"[{domainMetadata.AppDomainId} {domainMetadata.AppDomainName}]"); #if NETCOREAPP - loggerConfiguration.Enrich.WithProperty("AssemblyLoadContext", System.Runtime.Loader.AssemblyLoadContext.GetLoadContext(typeof(DatadogLogging).Assembly).Name); + loggerConfiguration.Enrich.WithProperty("AssemblyLoadContext", System.Runtime.Loader.AssemblyLoadContext.GetLoadContext(typeof(DatadogLogging).Assembly)?.ToString()); #endif loggerConfiguration.Enrich.WithProperty("TracerVersion", TracerConstants.AssemblyVersion); } diff --git a/tracer/src/Datadog.Trace/Logging/Internal/LogRateLimiter.cs b/tracer/src/Datadog.Trace/Logging/Internal/LogRateLimiter.cs index 3372e0c5d..238826440 100644 --- a/tracer/src/Datadog.Trace/Logging/Internal/LogRateLimiter.cs +++ b/tracer/src/Datadog.Trace/Logging/Internal/LogRateLimiter.cs @@ -20,7 +20,7 @@ public LogRateLimiter(int secondsBetweenLogs) { if (secondsBetweenLogs < 1) { - throw new ArgumentException("Must have positive number of seconds between logs", nameof(secondsBetweenLogs)); + ThrowHelper.ThrowArgumentException("Must have positive number of seconds between logs", nameof(secondsBetweenLogs)); } _secondsBetweenLogs = secondsBetweenLogs; diff --git a/tracer/src/Datadog.Trace/Logging/LogsInjection/CustomNLogLogProvider.cs b/tracer/src/Datadog.Trace/Logging/LogsInjection/CustomNLogLogProvider.cs deleted file mode 100644 index bc1f128ef..000000000 --- a/tracer/src/Datadog.Trace/Logging/LogsInjection/CustomNLogLogProvider.cs +++ /dev/null @@ -1,88 +0,0 @@ -// -// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. -// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. -// - -using System; -using System.Linq.Expressions; -using Datadog.Trace.Logging.LogProviders; - -namespace Datadog.Trace.Logging -{ - /// - /// - /// Log provider that performs more efficient logs injection by adding a custom type - /// into the NLog MDC which can later be rendered with the properties of the active - /// Datadog scope. - /// - /// - /// - /// Note: This logger is intended to be used when the application uses NLog >= 4.1. - /// When the application uses NLog versions older than 4.1, use - /// which utilizes the original - /// Set(string, string) API to perform logs injection. - /// - /// - internal class CustomNLogLogProvider : NLogLogProvider, ILogProviderWithEnricher - { - public ILogEnricher CreateEnricher() => new LogEnricher(this); - - internal static new bool IsLoggerAvailable() => - NLogLogProvider.IsLoggerAvailable() && IsSetObjectAvailable(); - - protected override OpenMdc GetOpenMdcMethod() - { - // This is a copy/paste of the base GetOpenMdcMethod, but calling Set(string, object) instead of Set(string, string) - - var keyParam = Expression.Parameter(typeof(string), "key"); - - var ndlcContextType = FindType("NLog.NestedDiagnosticsLogicalContext", "NLog"); - if (ndlcContextType != null) - { - var pushObjectMethod = ndlcContextType.GetMethod("PushObject", typeof(object)); - if (pushObjectMethod != null) - { - // NLog 4.6 introduces SetScoped with correct handling of logical callcontext (MDLC) - var mdlcContextType = FindType("NLog.MappedDiagnosticsLogicalContext", "NLog"); - if (mdlcContextType != null) - { - var setScopedMethod = mdlcContextType.GetMethod("SetScoped", typeof(string), typeof(object)); - if (setScopedMethod != null) - { - var valueObjParam = Expression.Parameter(typeof(object), "value"); - var setScopedMethodCall = Expression.Call(null, setScopedMethod, keyParam, valueObjParam); - var setMethodLambda = Expression.Lambda>(setScopedMethodCall, keyParam, valueObjParam).Compile(); - return (key, value, _) => setMethodLambda(key, value); - } - } - } - } - - var mdcContextType = FindType("NLog.MappedDiagnosticsContext", "NLog"); - var setMethod = mdcContextType.GetMethod("Set", typeof(string), typeof(object)); - var removeMethod = mdcContextType.GetMethod("Remove", typeof(string)); - var valueParam = Expression.Parameter(typeof(object), "value"); - var setMethodCall = Expression.Call(null, setMethod, keyParam, valueParam); - var removeMethodCall = Expression.Call(null, removeMethod, keyParam); - - var set = Expression - .Lambda>(setMethodCall, keyParam, valueParam) - .Compile(); - var remove = Expression - .Lambda>(removeMethodCall, keyParam) - .Compile(); - - return (key, value, _) => - { - set(key, value); - return new DisposableAction(() => remove(key)); - }; - } - - private static bool IsSetObjectAvailable() - { - var mdcContextType = FindType("NLog.MappedDiagnosticsContext", "NLog"); - return mdcContextType?.GetMethod("Set", typeof(string), typeof(object)) != null; - } - } -} diff --git a/tracer/src/Datadog.Trace/Logging/LogsInjection/CustomSerilogLogProvider.cs b/tracer/src/Datadog.Trace/Logging/LogsInjection/CustomSerilogLogProvider.cs deleted file mode 100644 index a235fabdd..000000000 --- a/tracer/src/Datadog.Trace/Logging/LogsInjection/CustomSerilogLogProvider.cs +++ /dev/null @@ -1,94 +0,0 @@ -// -// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. -// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. -// - -using System; -using System.Linq.Expressions; -using System.Reflection; -using System.Runtime.CompilerServices; -using Datadog.Trace.Logging.LogProviders; - -namespace Datadog.Trace.Logging -{ - internal class CustomSerilogLogProvider : SerilogLogProvider, ILogProviderWithEnricher - { - private static readonly IDisposable NoopDisposableInstance = new DisposableAction(); - private static readonly Version SupportedSerilogAssemblyVersion = new Version("2.0.0.0"); - private static Func _pushMethod; - private readonly bool _wrapEnricher; - - public CustomSerilogLogProvider() - { - var logEnricherType = GetLogEnricherType(); - if (GetPushMethodInfo() is MethodInfo pushMethodInfo) - { - _wrapEnricher = false; - _pushMethod = GeneratePushDelegate(pushMethodInfo, logEnricherType); - } - else if (GetPushPropertiesMethodInfo() is MethodInfo pushPropertiesMethodInfo) - { - _wrapEnricher = true; - _pushMethod = GeneratePushDelegate(pushPropertiesMethodInfo, logEnricherType.MakeArrayType()); - } - else - { - _wrapEnricher = false; - _pushMethod = (enricher) => NoopDisposableInstance; - } - } - - public IDisposable OpenContext(object enricher) - { - return _pushMethod(enricher); - } - - public ILogEnricher CreateEnricher() => new SerilogEnricher(this, _wrapEnricher); - - internal static Type GetLogEnricherType() => Type.GetType("Serilog.Core.ILogEventEnricher, Serilog"); - - internal static new bool IsLoggerAvailable() => - SerilogLogProvider.IsLoggerAvailable() && SerilogAssemblySupported() && (GetPushMethodInfo() != null || GetPushPropertiesMethodInfo() != null); - - private static MethodInfo GetPushMethodInfo() - { - var ndcContextType = Type.GetType("Serilog.Context.LogContext, Serilog"); - return ndcContextType?.GetMethod("Push", GetLogEnricherType()); - } - - private static MethodInfo GetPushPropertiesMethodInfo() - { - var ndcContextType = FindType("Serilog.Context.LogContext", new[] { "Serilog", "Serilog.FullNetFx" }); - return ndcContextType?.GetMethod("PushProperties", GetLogEnricherType().MakeArrayType()); - } - - private static Func GeneratePushDelegate(MethodInfo methodInfo, Type argumentTargetType) - { - var enricherParam = Expression.Parameter(typeof(object), "enricher"); - var castEnricherParam = Expression.Convert(enricherParam, argumentTargetType); - var pushMethodCall = Expression.Call(null, methodInfo, castEnricherParam); - - var push = Expression.Lambda>( - pushMethodCall, - enricherParam) - .Compile(); - - return push; - } - - private static bool SerilogAssemblySupported() - { - var ndcContextType = FindType("Serilog.Context.LogContext", new[] { "Serilog", "Serilog.FullNetFx" }); - var serilogVersion = ndcContextType.Assembly.GetName().Version; - return serilogVersion >= SupportedSerilogAssemblyVersion; - } - - internal class NoOpDisposable : IDisposable - { - public void Dispose() - { - // Do nothing - } - } - } -} diff --git a/tracer/src/Datadog.Trace/Logging/LogsInjection/FallbackNLogLogProvider.cs b/tracer/src/Datadog.Trace/Logging/LogsInjection/FallbackNLogLogProvider.cs deleted file mode 100644 index 0da7c70a3..000000000 --- a/tracer/src/Datadog.Trace/Logging/LogsInjection/FallbackNLogLogProvider.cs +++ /dev/null @@ -1,82 +0,0 @@ -// -// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. -// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. -// - -using System; -using System.Linq.Expressions; -using Datadog.Trace.Logging.LogProviders; - -namespace Datadog.Trace.Logging -{ - /// - /// - /// Log provider that enhances the built-in LibLog NLogLogProvider by adding - /// MDC support for NLog 1.0. The built-in NLogLogProvider only looked for - /// API's present on NLog 2.0 and newer. - /// - /// - /// - /// Note: This logger is intended to be used when the application uses NLog < 4.1. - /// When the application uses NLog versions 4.1 and newer, use - /// which utilizes the Set(string, object) - /// API to perform logs injection more efficiently. - /// - /// - internal class FallbackNLogLogProvider : NLogLogProvider - { - protected override OpenMdc GetOpenMdcMethod() - { - // This is a copy/paste of the base GetOpenMdcMethod, with an additional NLog 1.x fallback - var keyParam = Expression.Parameter(typeof(string), "key"); - - var ndlcContextType = FindType("NLog.NestedDiagnosticsLogicalContext", "NLog"); - if (ndlcContextType != null) - { - var pushObjectMethod = ndlcContextType.GetMethod("PushObject", typeof(object)); - if (pushObjectMethod != null) - { - // NLog 4.6 introduces SetScoped with correct handling of logical callcontext (MDLC) - var mdlcContextType = FindType("NLog.MappedDiagnosticsLogicalContext", "NLog"); - if (mdlcContextType != null) - { - var setScopedMethod = mdlcContextType.GetMethod("SetScoped", typeof(string), typeof(object)); - if (setScopedMethod != null) - { - var valueObjParam = Expression.Parameter(typeof(object), "value"); - var setScopedMethodCall = Expression.Call(null, setScopedMethod, keyParam, valueObjParam); - var setMethodLambda = Expression.Lambda>(setScopedMethodCall, keyParam, valueObjParam).Compile(); - return (key, value, _) => setMethodLambda(key, value); - } - } - } - } - - var mdcContextType = FindType("NLog.MappedDiagnosticsContext", "NLog"); - if (mdcContextType is null) - { - // Modification: Add fallback for NLog version 1.x - mdcContextType = FindType("NLog.MDC", "NLog"); - } - - var setMethod = mdcContextType.GetMethod("Set", typeof(string), typeof(string)); - var removeMethod = mdcContextType.GetMethod("Remove", typeof(string)); - var valueParam = Expression.Parameter(typeof(string), "value"); - var setMethodCall = Expression.Call(null, setMethod, keyParam, valueParam); - var removeMethodCall = Expression.Call(null, removeMethod, keyParam); - - var set = Expression - .Lambda>(setMethodCall, keyParam, valueParam) - .Compile(); - var remove = Expression - .Lambda>(removeMethodCall, keyParam) - .Compile(); - - return (key, value, _) => - { - set(key, value.ToString()); - return new DisposableAction(() => remove(key)); - }; - } - } -} diff --git a/tracer/src/Datadog.Trace/Logging/LogsInjection/LibLogScopeEventSubscriber.cs b/tracer/src/Datadog.Trace/Logging/LogsInjection/LibLogScopeEventSubscriber.cs index e8a2c498e..26198ab37 100644 --- a/tracer/src/Datadog.Trace/Logging/LogsInjection/LibLogScopeEventSubscriber.cs +++ b/tracer/src/Datadog.Trace/Logging/LogsInjection/LibLogScopeEventSubscriber.cs @@ -266,37 +266,26 @@ private static void InitResolvers() // - NLog // - Log4net - // Register the custom Serilog provider LogProvider.LogProviderResolvers.Insert( 0, - Tuple.Create( - CustomSerilogLogProvider.IsLoggerAvailable, - () => new CustomSerilogLogProvider())); - - LogProvider.LogProviderResolvers.Insert( - 1, Tuple.Create( NoOpSerilogLogProvider.IsLoggerAvailable, () => new NoOpSerilogLogProvider())); - // Register the custom NLog providers - LogProvider.LogProviderResolvers.Insert( - 2, - Tuple.Create( - CustomNLogLogProvider.IsLoggerAvailable, - () => new CustomNLogLogProvider())); - + // Register the no-op NLog provider + // Automatic logs injection will be handled by automatic instrumentation so make + // sure that calls to the LibLog Log Provider result in no-ops LogProvider.LogProviderResolvers.Insert( - 3, + 1, Tuple.Create( - FallbackNLogLogProvider.IsLoggerAvailable, - () => new FallbackNLogLogProvider())); + NoOpNLogLogProvider.IsLoggerAvailable, + () => new NoOpNLogLogProvider())); // Register the no-op log4net provider // Automatic logs injection will be handled by automatic instrumentation so make // sure that calls to the LibLog Log Provider result in no-ops LogProvider.LogProviderResolvers.Insert( - 4, + 2, Tuple.Create( NoOpLog4NetLogProvider.IsLoggerAvailable, () => new NoOpLog4NetLogProvider())); @@ -309,18 +298,6 @@ private void SetDefaultValues() private void RemoveLastCorrelationIdentifierContext() { - if (_logProvider is CustomSerilogLogProvider) - { - if (_scopeManager.Active == null) - { - // We closed the last span - _currentEnricher.Value?.Dispose(); - _currentEnricher.Value = null; - } - - return; - } - // TODO: Debug logs for (int i = 0; i < _numPropertiesSetOnSpanEvent; i++) { diff --git a/tracer/src/Datadog.Trace/Logging/LogsInjection/NoOpNLogLogProvider.cs b/tracer/src/Datadog.Trace/Logging/LogsInjection/NoOpNLogLogProvider.cs new file mode 100644 index 000000000..d94e93ce6 --- /dev/null +++ b/tracer/src/Datadog.Trace/Logging/LogsInjection/NoOpNLogLogProvider.cs @@ -0,0 +1,23 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using System; +using Datadog.Trace.Logging.LogProviders; + +namespace Datadog.Trace.Logging +{ + internal class NoOpNLogLogProvider : NLogLogProvider + { + private static readonly IDisposable NoopDisposableInstance = new DisposableAction(); + +#pragma warning disable SA1313 // Parameter names should begin with lower-case letter + protected override OpenMdc GetOpenMdcMethod() + { + // Make this log provider a no-op so the automatic instrumentation does all the work + return (_, __, ___) => NoopDisposableInstance; + } +#pragma warning restore SA1313 // Parameter names should begin with lower-case letter + } +} diff --git a/tracer/src/Datadog.Trace/Logging/LogsInjection/NoOpSerilogLogProvider.cs b/tracer/src/Datadog.Trace/Logging/LogsInjection/NoOpSerilogLogProvider.cs index 05fde4046..80a897a7b 100644 --- a/tracer/src/Datadog.Trace/Logging/LogsInjection/NoOpSerilogLogProvider.cs +++ b/tracer/src/Datadog.Trace/Logging/LogsInjection/NoOpSerilogLogProvider.cs @@ -8,19 +8,9 @@ namespace Datadog.Trace.Logging { - /// - /// Log provider that performs a no-op on all logs injection for Serilog versions before 2.0 - /// because the default behavior may throw unhandled exceptions when cross-AppDomain calls - /// are made. Prefer disabling the feature over taking a chance that the application's avoids - /// cross-AppDomain calls. - /// internal class NoOpSerilogLogProvider : SerilogLogProvider { private static readonly IDisposable NoopDisposableInstance = new DisposableAction(); - private static readonly Version SupportedSerilogAssemblyVersion = new Version("2.0.0.0"); - - internal static new bool IsLoggerAvailable() => - SerilogLogProvider.IsLoggerAvailable() && !SerilogAssemblySupported(); #pragma warning disable SA1313 // Parameter names should begin with lower-case letter protected override OpenMdc GetOpenMdcMethod() @@ -28,12 +18,5 @@ protected override OpenMdc GetOpenMdcMethod() return (_, __, ___) => NoopDisposableInstance; } #pragma warning restore SA1313 // Parameter names should begin with lower-case letter - - private static bool SerilogAssemblySupported() - { - var ndcContextType = FindType("Serilog.Context.LogContext", new[] { "Serilog", "Serilog.FullNetFx" }); - var serilogVersion = ndcContextType.Assembly.GetName().Version; - return serilogVersion >= SupportedSerilogAssemblyVersion; - } } } diff --git a/tracer/src/Datadog.Trace/Logging/LogsInjection/SerilogEnricher.cs b/tracer/src/Datadog.Trace/Logging/LogsInjection/SerilogEnricher.cs deleted file mode 100644 index 7782627f6..000000000 --- a/tracer/src/Datadog.Trace/Logging/LogsInjection/SerilogEnricher.cs +++ /dev/null @@ -1,143 +0,0 @@ -// -// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. -// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. -// - -// Modified by Splunk Inc. - -#pragma warning disable SA1201 // Elements should appear in the correct order - -using System; -using System.Linq.Expressions; -using Datadog.Trace.DuckTyping; -using Datadog.Trace.Logging.LogProviders; - -namespace Datadog.Trace.Logging -{ - internal class SerilogEnricher : ILogEnricher - { - private readonly CustomSerilogLogProvider _logProvider; - private readonly bool _wrapEnricher; - private readonly Func _valueFactory; - private readonly Func _propertyFactory; - - private IScopeManager _scopeManager; - private object _serviceProperty; - private object _versionProperty; - private object _environmentProperty; - - private object _serilogEventEnricher; - - public SerilogEnricher(CustomSerilogLogProvider logProvider, bool wrapEnricher) - { - _logProvider = logProvider; - _wrapEnricher = wrapEnricher; - - var logEventPropertyType = Type.GetType("Serilog.Events.LogEventProperty, Serilog"); - - if (logEventPropertyType == null) - { - throw new LibLogException("Serilog.Events.LogEventProperty not found"); - } - - var logEventPropertyValueType = Type.GetType("Serilog.Events.LogEventPropertyValue, Serilog"); - - if (logEventPropertyValueType == null) - { - throw new LibLogException("Serilog.Events.LogEventPropertyValue not found"); - } - - var scalarValueType = Type.GetType("Serilog.Events.ScalarValue, Serilog"); - - if (scalarValueType == null) - { - throw new LibLogException("Serilog.Events.ScalarValue not found"); - } - - _valueFactory = BuildValueFactory(scalarValueType); - _propertyFactory = BuildPropertyFactory(logEventPropertyType, logEventPropertyValueType); - } - - public void Initialize(IScopeManager scopeManager, string defaultServiceName, string version, string env) - { - _scopeManager = scopeManager; - - _serviceProperty = _propertyFactory(CorrelationIdentifier.SerilogServiceKey, _valueFactory(defaultServiceName)); - _versionProperty = _propertyFactory(CorrelationIdentifier.SerilogVersionKey, _valueFactory(version)); - _environmentProperty = _propertyFactory(CorrelationIdentifier.SerilogEnvKey, _valueFactory(env)); - - var logEnricherType = CustomSerilogLogProvider.GetLogEnricherType(); - _serilogEventEnricher = this.DuckImplement(logEnricherType); - - if (_wrapEnricher) - { - var array = Array.CreateInstance(logEnricherType, 1); - array.SetValue(_serilogEventEnricher, 0); - _serilogEventEnricher = array; - } - } - - public IDisposable Register() - { - return _logProvider.OpenContext(_serilogEventEnricher); - } - - [DuckReverseMethod(ParameterTypeNames = new[] { "Serilog.Events.LogEvent, Serilog", "Serilog.Core.ILogEventPropertyFactory, Serilog" })] - public void Enrich(ILogEvent logEvent, object propertyFactory) - { - var activeScope = _scopeManager.Active; - - if (activeScope == null) - { - return; - } - - var traceIdProperty = _propertyFactory(CorrelationIdentifier.TraceIdKey, _valueFactory(activeScope.Span.TraceId.ToString())); - var spanIdProperty = _propertyFactory(CorrelationIdentifier.SpanIdKey, _valueFactory(activeScope.Span.SpanId.ToString())); - - logEvent.AddPropertyIfAbsent(_serviceProperty); - logEvent.AddPropertyIfAbsent(_versionProperty); - logEvent.AddPropertyIfAbsent(_environmentProperty); - logEvent.AddPropertyIfAbsent(traceIdProperty); - logEvent.AddPropertyIfAbsent(spanIdProperty); - } - - private static Func BuildPropertyFactory(Type logEventPropertyType, Type logEventPropertyValueType) - { - // Create an expression to call `new LogEventProperty(string name, LogEventPropertyValuevalue)` - var nameParam = Expression.Parameter(typeof(string), "name"); - var propertyValueParam = Expression.Parameter(typeof(object), "value"); - - var constructor = logEventPropertyType.GetConstructor(new[] { typeof(string), logEventPropertyValueType }); - - var castPropertyValueParam = Expression.Convert(propertyValueParam, logEventPropertyValueType); - var newExpression = Expression.New(constructor, nameParam, castPropertyValueParam); - - return Expression.Lambda>( - newExpression, - nameParam, - propertyValueParam) - .Compile(); - } - - private static Func BuildValueFactory(Type scalarValueType) - { - // Create an expression to call `new ScalarValue(object value)` - var valueParam = Expression.Parameter(typeof(object), "value"); - - var constructor = scalarValueType.GetConstructor(new[] { typeof(object) }); - - var newExpression = Expression.New(constructor, valueParam); - - return Expression.Lambda>( - newExpression, - valueParam) - .Compile(); - } - - public interface ILogEvent - { - void AddPropertyIfAbsent(object property); - } - } -} diff --git a/tracer/src/Datadog.Trace/PlatformHelpers/AspNetCoreHttpRequestHandler.cs b/tracer/src/Datadog.Trace/PlatformHelpers/AspNetCoreHttpRequestHandler.cs index 8ea52365d..9df558ff5 100644 --- a/tracer/src/Datadog.Trace/PlatformHelpers/AspNetCoreHttpRequestHandler.cs +++ b/tracer/src/Datadog.Trace/PlatformHelpers/AspNetCoreHttpRequestHandler.cs @@ -74,7 +74,7 @@ private SpanContext ExtractPropagatedContext(HttpRequest request) return null; } - private IEnumerable> ExtractHeaderTags(HttpRequest request, IDatadogTracer tracer) + private IEnumerable> ExtractHeaderTags(HttpRequest request, Tracer tracer) { var settings = tracer.Settings; @@ -122,7 +122,7 @@ public Scope StartAspNetCorePipelineScope(Tracer tracer, HttpContext httpContext tags = new AspNetCoreTags(); } - var scope = tracer.StartActiveWithTags($"HTTP {httpMethod}", propagatedContext, tags: tags); + var scope = tracer.StartActiveInternal($"HTTP {httpMethod}", propagatedContext, tags: tags); scope.Span.LogicScope = _requestInOperationName; // TODO: investigate if can be simplified diff --git a/tracer/src/Datadog.Trace/Propagation/B3SpanContextPropagator.cs b/tracer/src/Datadog.Trace/Propagation/B3SpanContextPropagator.cs index 60876c128..86762403a 100644 --- a/tracer/src/Datadog.Trace/Propagation/B3SpanContextPropagator.cs +++ b/tracer/src/Datadog.Trace/Propagation/B3SpanContextPropagator.cs @@ -38,9 +38,6 @@ public virtual void Inject(SpanContext context, T carrier, Action public const string TracingEnabled = "x-datadog-tracing-enabled"; + + /// + /// Origin of the distributed trace. + /// + public const string UserAgent = "User-Agent"; } } diff --git a/tracer/src/Datadog.Trace/Propagation/DDHttpHeaderNames.cs b/tracer/src/Datadog.Trace/Propagation/DDHttpHeaderNames.cs index 3a0620b9e..679ae1d9e 100644 --- a/tracer/src/Datadog.Trace/Propagation/DDHttpHeaderNames.cs +++ b/tracer/src/Datadog.Trace/Propagation/DDHttpHeaderNames.cs @@ -1,8 +1,10 @@ -// +// // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // +// Modified by Splunk Inc. + namespace Datadog.Trace.Propagation { /// diff --git a/tracer/src/Datadog.Trace/Propagation/DDSpanContextPropagator.cs b/tracer/src/Datadog.Trace/Propagation/DDSpanContextPropagator.cs index 2be424479..47d747c3a 100644 --- a/tracer/src/Datadog.Trace/Propagation/DDSpanContextPropagator.cs +++ b/tracer/src/Datadog.Trace/Propagation/DDSpanContextPropagator.cs @@ -41,9 +41,6 @@ public void Inject(SpanContext context, T carrier, Action if (setter == null) { throw new ArgumentNullException(nameof(setter)); } - // lock sampling priority when span propagates. - context.TraceContext?.LockSamplingPriority(); - setter(carrier, DDHttpHeaderNames.TraceId, context.TraceId.ToString()); setter(carrier, DDHttpHeaderNames.ParentId, context.SpanId.ToString(InvariantCulture)); diff --git a/tracer/src/Datadog.Trace/Propagation/W3CSpanContextPropagator.cs b/tracer/src/Datadog.Trace/Propagation/W3CSpanContextPropagator.cs index 9fcde4f63..8a1a80f07 100644 --- a/tracer/src/Datadog.Trace/Propagation/W3CSpanContextPropagator.cs +++ b/tracer/src/Datadog.Trace/Propagation/W3CSpanContextPropagator.cs @@ -53,9 +53,6 @@ public static string GetFormattedTraceParent(SpanContext context) /// public virtual void Inject(SpanContext context, T carrier, Action setter) { - // lock sampling priority when span propagates. - context.TraceContext?.LockSamplingPriority(); - setter(carrier, W3CHeaderNames.TraceParent, GetFormattedTraceParent(context)); if (!string.IsNullOrEmpty(context.TraceState)) { diff --git a/tracer/src/Datadog.Trace/Scope.IScope.cs b/tracer/src/Datadog.Trace/Scope.IScope.cs new file mode 100644 index 000000000..f56076f87 --- /dev/null +++ b/tracer/src/Datadog.Trace/Scope.IScope.cs @@ -0,0 +1,26 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +namespace Datadog.Trace +{ + /// + /// A scope is a handle used to manage the concept of an active span. + /// Meaning that at a given time at most one span is considered active and + /// all newly created spans that are not created with the ignoreActiveSpan + /// parameter will be automatically children of the active span. + /// + internal partial class Scope : IScope + { + /// + /// Gets the active span wrapped in this scope + /// + ISpan IScope.Span => Span; + + /// + /// Closes the current scope and makes its parent scope active + /// + void IScope.Close() => Close(); + } +} diff --git a/tracer/src/Datadog.Trace/Scope.cs b/tracer/src/Datadog.Trace/Scope.cs index 9de19eb6c..d32a19019 100644 --- a/tracer/src/Datadog.Trace/Scope.cs +++ b/tracer/src/Datadog.Trace/Scope.cs @@ -3,8 +3,6 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System; - namespace Datadog.Trace { /// @@ -13,7 +11,7 @@ namespace Datadog.Trace /// all newly created spans that are not created with the ignoreActiveSpan /// parameter will be automatically children of the active span. /// - public class Scope : IDisposable + internal partial class Scope : IScope { private readonly IScopeManager _scopeManager; private readonly bool _finishOnClose; @@ -29,25 +27,12 @@ internal Scope(Scope parent, Span span, IScopeManager scopeManager, bool finishO /// /// Gets the active span wrapped in this scope /// - public Span Span { get; } + internal Span Span { get; } internal Scope Parent { get; } internal Scope Root => Parent?.Root ?? this; - /// - /// Closes the current scope and makes its parent scope active - /// - public void Close() - { - _scopeManager.Close(this); - - if (_finishOnClose) - { - Span.Finish(); - } - } - /// /// Closes the current scope and makes its parent scope active /// @@ -63,5 +48,18 @@ public void Dispose() // TODO: Log? only in test/debug? How should Close() concerns be handled (i.e. independent?) } } + + /// + /// Closes the current scope and makes its parent scope active + /// + internal void Close() + { + _scopeManager.Close(this); + + if (_finishOnClose) + { + Span.Finish(); + } + } } } diff --git a/tracer/src/Datadog.Trace/ScopeManagerBase.cs b/tracer/src/Datadog.Trace/ScopeManagerBase.cs index 740f4de87..988112412 100644 --- a/tracer/src/Datadog.Trace/ScopeManagerBase.cs +++ b/tracer/src/Datadog.Trace/ScopeManagerBase.cs @@ -4,6 +4,8 @@ // using System; +using System.Collections.Generic; +using Datadog.Trace.ClrProfiler; using Datadog.Trace.Logging; namespace Datadog.Trace @@ -46,6 +48,7 @@ public Scope Activate(Span span, bool finishOnClose) SpanOpened?.Invoke(this, scopeOpenedArgs); Active = scope; + DistributedTracer.Instance.SetSpanContext(scope.Span.Context); if (newParent != null) { @@ -72,6 +75,10 @@ public void Close(Scope scope) // if the scope that was just closed was the active scope, // set its parent as the new active scope Active = scope.Parent; + + // scope.Parent is null for distributed traces, so use scope.Span.Context.Parent + DistributedTracer.Instance.SetSpanContext(scope.Span.Context.Parent as SpanContext); + SpanDeactivated?.Invoke(this, new SpanEventArgs(scope.Span)); if (!isRootSpan) diff --git a/tracer/src/Datadog.Trace/ServiceFabric/ServiceRemotingHelpers.cs b/tracer/src/Datadog.Trace/ServiceFabric/ServiceRemotingHelpers.cs index a2ea496c5..d536f68cb 100644 --- a/tracer/src/Datadog.Trace/ServiceFabric/ServiceRemotingHelpers.cs +++ b/tracer/src/Datadog.Trace/ServiceFabric/ServiceRemotingHelpers.cs @@ -147,7 +147,7 @@ public static void FinishSpan(EventArgs? e, string spanKind) { try { - var scope = Tracer.Instance.ActiveScope; + var scope = Tracer.Instance.InternalActiveScope; if (scope == null) { diff --git a/tracer/src/Datadog.Trace/Span.ISpan.cs b/tracer/src/Datadog.Trace/Span.ISpan.cs new file mode 100644 index 000000000..58cb1b667 --- /dev/null +++ b/tracer/src/Datadog.Trace/Span.ISpan.cs @@ -0,0 +1,77 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using System; + +namespace Datadog.Trace +{ + /// + /// A Span represents a logical unit of work in the system. It may be + /// related to other spans by parent/children relationships. The span + /// tracks the duration of an operation as well as associated metadata in + /// the form of a resource name, a service name, and user defined tags. + /// + internal partial class Span : ISpan + { + /// + string ISpan.OperationName + { + get => OperationName; + set => OperationName = value; + } + + /// + string ISpan.ResourceName + { + get => ResourceName; + set => ResourceName = value; + } + + /// + string ISpan.Type + { + get => Type; + set => Type = value; + } + + /// + bool ISpan.Error + { + get => Error; + set => Error = value; + } + + /// + string ISpan.ServiceName + { + get => ServiceName; + set => ServiceName = value; + } + + /// + TraceId ISpan.TraceId => TraceId; + + /// + ulong ISpan.SpanId => SpanId; + + /// + ISpanContext ISpan.Context => Context; + + /// + ISpan ISpan.SetTag(string key, string value) => SetTag(key, value); + + /// + void ISpan.Finish() => Finish(); + + /// + void ISpan.Finish(DateTimeOffset finishTimestamp) => Finish(finishTimestamp); + + /// + void ISpan.SetException(Exception exception) => SetException(exception); + + /// + string ISpan.GetTag(string key) => GetTag(key); + } +} diff --git a/tracer/src/Datadog.Trace/Span.cs b/tracer/src/Datadog.Trace/Span.cs index 2c8ad87df..be478c70b 100644 --- a/tracer/src/Datadog.Trace/Span.cs +++ b/tracer/src/Datadog.Trace/Span.cs @@ -22,7 +22,7 @@ namespace Datadog.Trace /// tracks the duration of an operation as well as associated metadata in /// the form of a resource name, a service name, and user defined tags. /// - public class Span : IDisposable + internal partial class Span : ISpan { private static readonly IDatadogLogger Log = DatadogLogging.GetLoggerFor(); private static readonly bool IsLogLevelDebugEnabled = Log.IsEnabled(LogEventLevel.Debug); @@ -60,29 +60,31 @@ internal Span(SpanContext context, DateTimeOffset? start, ITags tags) /// /// Gets or sets operation name /// - public string OperationName { get; set; } + internal string OperationName { get; set; } /// /// Gets or sets the resource name /// - public string ResourceName { get; set; } + internal string ResourceName { get; set; } /// /// Gets or sets the type of request this span represents (ex: web, db). /// Not to be confused with span kind. /// /// - public string Type { get; set; } + internal string Type { get; set; } /// /// Gets or sets the span's execution status /// public SpanStatus Status { get; set; } + internal bool Error { get; set; } + /// /// Gets or sets the service name. /// - public string ServiceName + internal string ServiceName { get => Context.ServiceName; set => Context.ServiceName = value; @@ -96,7 +98,7 @@ public string ServiceName /// /// Gets the span's unique identifier. /// - public ulong SpanId => Context.SpanId; + internal ulong SpanId => Context.SpanId; /// /// Gets local root span id, i.e. the SpanId of the span that is the root of the local, non-reentrant @@ -130,6 +132,15 @@ internal ulong RootSpanId internal bool IsTopLevel => Context.Parent == null || Context.Parent.ServiceName != ServiceName; + /// + /// Record the end time of the span and flushes it to the backend. + /// After the span has been finished all modifications will be ignored. + /// + public void Dispose() + { + Finish(); + } + /// /// Returns a that represents this instance. /// @@ -162,7 +173,7 @@ public override string ToString() /// The tag's key. /// The tag's value. /// This span to allow method chaining. - public Span SetTag(string key, string value) + internal ISpan SetTag(string key, string value) { if (IsFinished) { @@ -276,7 +287,7 @@ public Span SetTag(string key, string value) /// Record the end time of the span and flushes it to the backend. /// After the span has been finished all modifications will be ignored. /// - public void Finish() + internal void Finish() { Finish(Context.TraceContext.ElapsedSince(StartTime)); } @@ -286,25 +297,16 @@ public void Finish() /// After the span has been finished all modifications will be ignored. /// /// Explicit value for the end time of the Span - public void Finish(DateTimeOffset finishTimestamp) + internal void Finish(DateTimeOffset finishTimestamp) { Finish(finishTimestamp - StartTime); } - /// - /// Record the end time of the span and flushes it to the backend. - /// After the span has been finished all modifications will be ignored. - /// - public void Dispose() - { - Finish(); - } - /// /// Add the StackTrace and other exception metadata to the span /// /// The exception. - public void SetException(Exception exception) + internal void SetException(Exception exception) { if (exception != null) { @@ -332,7 +334,7 @@ public void SetException(Exception exception) /// /// The tag's key /// The value for the tag with the key specified, or null if the tag does not exist - public string GetTag(string key) + internal string GetTag(string key) { switch (key) { diff --git a/tracer/src/Datadog.Trace/SpanContext.cs b/tracer/src/Datadog.Trace/SpanContext.cs index 737ddb11c..ef60ae85a 100644 --- a/tracer/src/Datadog.Trace/SpanContext.cs +++ b/tracer/src/Datadog.Trace/SpanContext.cs @@ -5,7 +5,8 @@ // Modified by Splunk Inc. -using Datadog.Trace.Logging; +using System.Collections; +using System.Collections.Generic; using Datadog.Trace.Util; namespace Datadog.Trace @@ -13,9 +14,9 @@ namespace Datadog.Trace /// /// The SpanContext contains all the information needed to express relationships between spans inside or outside the process boundaries. /// - public class SpanContext : ISpanContext + public class SpanContext : ISpanContext, IReadOnlyDictionary { - private static readonly IDatadogLogger Log = DatadogLogging.GetLoggerFor(); + private static readonly string[] KeyNames = { "trace-id", "parent-id", "sampling-priority", "origin" }; /// /// Initializes a new instance of the class @@ -140,5 +141,97 @@ private SpanContext(TraceId? traceId, string serviceName) /// Returns null for local contexts. /// internal SamplingPriority? SamplingPriority { get; } + + /// + int IReadOnlyCollection>.Count => KeyNames.Length; + + /// + IEnumerable IReadOnlyDictionary.Keys => KeyNames; + + /// + IEnumerable IReadOnlyDictionary.Values + { + get + { + foreach (var key in KeyNames) + { + yield return ((IReadOnlyDictionary)this)[key]; + } + } + } + + /// + string IReadOnlyDictionary.this[string key] + { + get + { + if (((IReadOnlyDictionary)this).TryGetValue(key, out var value)) + { + return value; + } + + ThrowHelper.ThrowKeyNotFoundException($"Key not found: {key}"); + return default; + } + } + + /// + IEnumerator> IEnumerable>.GetEnumerator() + { + var dictionary = (IReadOnlyDictionary)this; + + foreach (var key in KeyNames) + { + yield return new KeyValuePair(key, dictionary[key]); + } + } + + /// + IEnumerator IEnumerable.GetEnumerator() + { + return ((IReadOnlyDictionary)this).GetEnumerator(); + } + + /// + bool IReadOnlyDictionary.ContainsKey(string key) + { + foreach (var k in KeyNames) + { + if (k == key) + { + return true; + } + } + + return false; + } + + /// + bool IReadOnlyDictionary.TryGetValue(string key, out string value) + { + switch (key) + { + case "trace-id": + value = TraceId.ToString(); + return true; + + case "parent-id": + value = SpanId.ToString(); + return true; + + case "sampling-priority": + var samplingPriority = SamplingPriority; + + value = samplingPriority != null ? ((int)samplingPriority.Value).ToString() : null; + return true; + + case "origin": + value = Origin; + return true; + } + + value = null; + return false; + } } } diff --git a/tracer/src/Datadog.Trace/SpanCreationSettings.cs b/tracer/src/Datadog.Trace/SpanCreationSettings.cs new file mode 100644 index 000000000..fc12f937d --- /dev/null +++ b/tracer/src/Datadog.Trace/SpanCreationSettings.cs @@ -0,0 +1,32 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using System; + +namespace Datadog.Trace +{ + /// + /// Settings to use when creating a new and + /// + public struct SpanCreationSettings + { + /// + /// Gets or sets an explicit start time for the span. If not set, uses the current time. + /// + public DateTimeOffset? StartTime { get; set; } + + /// + /// Gets or sets the span's parent. If not set, the current active span context will be used, + /// or a new one will be created if none is currently active. + /// + public ISpanContext Parent { get; set; } + + /// + /// Gets or sets whether closing the scope will close the contained span. + /// If not set, defaults to true. + /// + public bool? FinishOnClose { get; set; } + } +} diff --git a/tracer/src/Datadog.Trace/ClrProfiler/SqlTags.cs b/tracer/src/Datadog.Trace/Tagging/SqlTags.cs similarity index 95% rename from tracer/src/Datadog.Trace/ClrProfiler/SqlTags.cs rename to tracer/src/Datadog.Trace/Tagging/SqlTags.cs index 72e926977..cab269802 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/SqlTags.cs +++ b/tracer/src/Datadog.Trace/Tagging/SqlTags.cs @@ -5,9 +5,8 @@ using Datadog.Trace.Configuration; using Datadog.Trace.ExtensionMethods; -using Datadog.Trace.Tagging; -namespace Datadog.Trace.ClrProfiler +namespace Datadog.Trace.Tagging { internal class SqlTags : InstrumentationTags { diff --git a/tracer/src/Datadog.Trace/Tags.cs b/tracer/src/Datadog.Trace/Tags.cs index 139e658af..2bd04ccfd 100644 --- a/tracer/src/Datadog.Trace/Tags.cs +++ b/tracer/src/Datadog.Trace/Tags.cs @@ -30,12 +30,12 @@ public static class Tags public const string Version = "version"; /// - /// SingalFx Language tag, applied to root spans. + /// SignalFx Language tag, applied to root spans. /// public const string SignalFxLibrary = "signalfx.tracing.library"; /// - /// SingalFx Version tag, applied to root spans. + /// SignalFx Version tag, applied to root spans. /// public const string SignalFxVersion = "signalfx.tracing.version"; diff --git a/tracer/src/Datadog.Trace/TraceContext.cs b/tracer/src/Datadog.Trace/TraceContext.cs index 3b2d9f955..29445b3e0 100644 --- a/tracer/src/Datadog.Trace/TraceContext.cs +++ b/tracer/src/Datadog.Trace/TraceContext.cs @@ -5,6 +5,7 @@ using System; using System.Diagnostics; +using Datadog.Trace.ClrProfiler; using Datadog.Trace.Logging; using Datadog.Trace.PlatformHelpers; using Datadog.Trace.Tagging; @@ -22,7 +23,6 @@ internal class TraceContext : ITraceContext private int _openSpans; private SamplingPriority? _samplingPriority; - private bool _samplingPriorityLocked; public TraceContext(IDatadogTracer tracer) { @@ -37,18 +37,13 @@ public TraceContext(IDatadogTracer tracer) /// /// Gets or sets sampling priority. - /// Once the sampling priority is locked with , - /// further attempts to set this are ignored. /// public SamplingPriority? SamplingPriority { get => _samplingPriority; set { - if (!_samplingPriorityLocked) - { - _samplingPriority = value; - } + SetSamplingPriority(value); } } @@ -71,7 +66,6 @@ public void AddSpan(Span span) // this is a root span created from a propagated context that contains a sampling priority. // lock sampling priority when a span is started from a propagated trace. _samplingPriority = context.SamplingPriority; - LockSamplingPriority(); } else { @@ -89,13 +83,10 @@ public void AddSpan(Span span) public void CloseSpan(Span span) { - bool ShouldTriggerPartialFlush() => Tracer.Settings.PartialFlushEnabled && _spans.Count >= Tracer.Settings.PartialFlushMinSpans; + bool ShouldTriggerPartialFlush() => Tracer.Settings.ExporterSettings.PartialFlushEnabled && _spans.Count >= Tracer.Settings.ExporterSettings.PartialFlushMinSpans; if (span == RootSpan) { - // lock sampling priority and set metric when root span finishes - LockSamplingPriority(); - if (_samplingPriority == null) { Log.Warning("Cannot set span metric for sampling priority before it has been set."); @@ -152,15 +143,13 @@ public void CloseSpan(Span span) } } - public void LockSamplingPriority() + public void SetSamplingPriority(SamplingPriority? samplingPriority, bool notifyDistributedTracer = true) { - if (_samplingPriority == null) - { - Log.Warning("Cannot lock sampling priority before it has been set."); - } - else + _samplingPriority = samplingPriority; + + if (notifyDistributedTracer) { - _samplingPriorityLocked = true; + DistributedTracer.Instance.SetSamplingPriority(samplingPriority); } } diff --git a/tracer/src/Datadog.Trace/Tracer.cs b/tracer/src/Datadog.Trace/Tracer.cs index 29ab575ac..7f301dcfd 100644 --- a/tracer/src/Datadog.Trace/Tracer.cs +++ b/tracer/src/Datadog.Trace/Tracer.cs @@ -10,10 +10,13 @@ using System.Threading; using System.Threading.Tasks; using Datadog.Trace.Agent; +using Datadog.Trace.ClrProfiler; using Datadog.Trace.Configuration; +using Datadog.Trace.Logging; using Datadog.Trace.Propagation; using Datadog.Trace.Sampling; using Datadog.Trace.Tagging; +using Datadog.Trace.Util; using Datadog.Trace.Vendors.StatsdClient; namespace Datadog.Trace @@ -21,9 +24,9 @@ namespace Datadog.Trace /// /// The tracer is responsible for creating spans and flushing them to the Datadog agent /// - public class Tracer : IDatadogTracer + public class Tracer : ITracer, IDatadogTracer, IDatadogOpenTracingTracer { - private static string _runtimeId; + private static readonly IDatadogLogger Log = DatadogLogging.GetLoggerFor(typeof(Tracer)); /// /// The number of Tracer instances that have been created and not yet destroyed. @@ -141,7 +144,7 @@ public static Tracer Instance // Kept for safety reasons if (_instance is { TracerManager: ILockedTracer }) { - throw new InvalidOperationException("The current tracer instance cannot be replaced."); + ThrowHelper.ThrowInvalidOperationException("The current tracer instance cannot be replaced."); } _instance = value; @@ -150,14 +153,35 @@ public static Tracer Instance } } - internal static string RuntimeId => LazyInitializer.EnsureInitialized(ref _runtimeId, () => Guid.NewGuid().ToString()); + internal static string RuntimeId => DistributedTracer.Instance.GetRuntimeId(); internal static int LiveTracerCount => _liveTracerCount; /// /// Gets the active scope /// - public Scope ActiveScope => TracerManager.ScopeManager.Active; + public IScope ActiveScope + { + get + { + return DistributedTracer.Instance.GetActiveScope() ?? InternalActiveScope; + } + } + + /// + /// Gets the active span context dictionary by consulting DistributedTracer.Instance + /// + internal IReadOnlyDictionary DistributedSpanContext => DistributedTracer.Instance.GetSpanContextRaw() ?? InternalActiveScope?.Span?.Context; + + /// + /// Gets the active scope + /// + internal Scope InternalActiveScope => TracerManager.ScopeManager.Active; + + /// + /// Gets the tracer's scope manager, which determines which span is currently active, if any. + /// + internal IScopeManager ScopeManager => TracerManager.ScopeManager; /// /// Gets the default service name for traces where a service name is not specified. @@ -170,9 +194,14 @@ public static Tracer Instance public ImmutableTracerSettings Settings => TracerManager.Settings; /// - /// Gets the tracer's scope manager, which determines which span is currently active, if any. + /// Gets the active scope /// - IScopeManager IDatadogTracer.ScopeManager => TracerManager.ScopeManager; + IScope ITracer.ActiveScope => ActiveScope; + + /// + /// Gets this tracer's settings. + /// + ImmutableTracerSettings ITracer.Settings => Settings; /// /// Gets the instance used by this instance. @@ -182,7 +211,7 @@ public static Tracer Instance /// /// Gets the instance used by this instance. /// - IPropagator IDatadogTracer.Propagator => TracerManager.Propagator; + IPropagator IDatadogOpenTracingTracer.Propagator => TracerManager.Propagator; internal TracerManager TracerManager => _tracerManager ?? TracerManager.Instance; @@ -211,30 +240,35 @@ internal static void UnsafeSetTracerInstance(Tracer instance) } } + /// + IScope ITracer.StartActive(string operationName) => StartActive(operationName); + + /// + IScope ITracer.StartActive(string operationName, SpanCreationSettings settings) => StartActive(operationName, settings); + /// - /// Make a span the active span and return its new scope. + /// This creates a new span with the given parameters and makes it active. /// - /// The span to activate. - /// A Scope object wrapping this span. - Scope IDatadogTracer.ActivateSpan(Span span) + /// The span's operation name + /// A scope wrapping the newly created span + public IScope StartActive(string operationName) { - return ActivateSpan(span); + return StartActive(operationName, parent: null, serviceName: null, startTime: null, ignoreActiveScope: false, finishOnClose: true); } /// - /// Make a span the active span and return its new scope. + /// This creates a new span with the given parameters and makes it active. /// - /// The span to activate. - /// Determines whether closing the returned scope will also finish the span. - /// A Scope object wrapping this span. - public Scope ActivateSpan(Span span, bool finishOnClose = true) + /// The span's operation name + /// Settings for the new + /// A scope wrapping the newly created span + public IScope StartActive(string operationName, SpanCreationSettings settings) { - return TracerManager.ScopeManager.Activate(span, finishOnClose); + return StartActive(operationName, settings.Parent, serviceName: null, settings.StartTime, ignoreActiveScope: false, finishOnClose: settings.FinishOnClose ?? true); } /// - /// This is a shortcut for - /// and , it creates a new span with the given parameters and makes it active. + /// This creates a new span with the given parameters and makes it active. /// /// The span's operation name /// The span's parent @@ -243,35 +277,14 @@ public Scope ActivateSpan(Span span, bool finishOnClose = true) /// If set the span will not be a child of the currently active span /// If set to false, closing the returned scope will not close the enclosed span /// A scope wrapping the newly created span - public Scope StartActive(string operationName, ISpanContext parent = null, string serviceName = null, DateTimeOffset? startTime = null, bool ignoreActiveScope = false, bool finishOnClose = true) + internal Scope StartActive(string operationName, ISpanContext parent = null, string serviceName = null, DateTimeOffset? startTime = null, bool ignoreActiveScope = false, bool finishOnClose = true) { - var span = StartSpan(operationName, parent, serviceName, startTime, ignoreActiveScope); + var span = StartSpan(operationName, parent: parent, serviceName: serviceName, startTime: startTime, ignoreActiveScope: ignoreActiveScope); return TracerManager.ScopeManager.Activate(span, finishOnClose); } /// - /// Creates a new with the specified parameters. - /// - /// The span's operation name - /// The newly created span - Span IDatadogTracer.StartSpan(string operationName) - { - return StartSpan(operationName); - } - - /// - /// Creates a new with the specified parameters. - /// - /// The span's operation name - /// The span's parent - /// The newly created span - Span IDatadogTracer.StartSpan(string operationName, ISpanContext parent) - { - return StartSpan(operationName, parent); - } - - /// - /// Creates a new with the specified parameters. + /// Creates a new with the specified parameters. /// /// The span's operation name /// The span's parent @@ -279,9 +292,9 @@ Span IDatadogTracer.StartSpan(string operationName, ISpanContext parent) /// An explicit start time for that span /// If set the span will not be a child of the currently active span /// The newly created span - public Span StartSpan(string operationName, ISpanContext parent = null, string serviceName = null, DateTimeOffset? startTime = null, bool ignoreActiveScope = false) + ISpan IDatadogOpenTracingTracer.StartSpan(string operationName, ISpanContext parent, string serviceName, DateTimeOffset? startTime, bool ignoreActiveScope) { - return StartSpan(operationName, tags: null, parent, serviceName, startTime, ignoreActiveScope, spanId: null); + return StartSpan(operationName, parent, serviceName, startTime, ignoreActiveScope); } /// @@ -303,11 +316,36 @@ void IDatadogTracer.Write(ArraySegment trace) } } + /// + /// Make a span the active span and return its new scope. + /// + /// The span to activate. + /// Determines whether closing the returned scope will also finish the span. + /// A Scope object wrapping this span. + internal Scope ActivateSpan(Span span, bool finishOnClose = true) + { + return TracerManager.ScopeManager.Activate(span, finishOnClose); + } + + /// + /// Creates a new with the specified parameters. + /// + /// The span's operation name + /// The span's parent + /// The span's service name + /// An explicit start time for that span + /// If set the span will not be a child of the currently active span + /// The newly created span + internal Span StartSpan(string operationName, ISpanContext parent = null, string serviceName = null, DateTimeOffset? startTime = null, bool ignoreActiveScope = false) + { + return StartSpan(operationName, tags: null, parent, serviceName, startTime, ignoreActiveScope, spanId: null); + } + internal SpanContext CreateSpanContext(ISpanContext parent = null, string serviceName = null, bool ignoreActiveScope = false, TraceId? traceId = null, ulong? spanId = null) { if (parent == null && !ignoreActiveScope) { - parent = TracerManager.ScopeManager.Active?.Span?.Context; + parent = DistributedTracer.Instance.GetSpanContext() ?? TracerManager.ScopeManager.Active?.Span?.Context; } ITraceContext traceContext; @@ -317,21 +355,21 @@ internal SpanContext CreateSpanContext(ISpanContext parent = null, string servic // otherwise start a new trace context if (parent is SpanContext parentSpanContext) { - traceContext = parentSpanContext.TraceContext ?? - new TraceContext(this) { SamplingPriority = parentSpanContext.SamplingPriority }; + traceContext = parentSpanContext.TraceContext + ?? new TraceContext(this) { SamplingPriority = parentSpanContext.SamplingPriority ?? DistributedTracer.Instance.GetSamplingPriority() }; } else { - traceContext = new TraceContext(this); + traceContext = new TraceContext(this) { SamplingPriority = DistributedTracer.Instance.GetSamplingPriority() }; } - var finalServiceName = serviceName ?? parent?.ServiceName ?? DefaultServiceName; + var finalServiceName = serviceName ?? DefaultServiceName; var spanContext = new SpanContext(parent, traceContext, finalServiceName, traceId: traceId, spanId: spanId); return spanContext; } - internal Scope StartActiveWithTags(string operationName, ISpanContext parent = null, string serviceName = null, DateTimeOffset? startTime = null, bool ignoreActiveScope = false, bool finishOnClose = true, ITags tags = null, ulong? spanId = null) + internal Scope StartActiveInternal(string operationName, ISpanContext parent = null, string serviceName = null, DateTimeOffset? startTime = null, bool ignoreActiveScope = false, bool finishOnClose = true, ITags tags = null, ulong? spanId = null) { var span = StartSpan(operationName, tags, parent, serviceName, startTime, ignoreActiveScope, spanId: spanId); return TracerManager.ScopeManager.Activate(span, finishOnClose); diff --git a/tracer/src/Datadog.Trace/TracerManager.cs b/tracer/src/Datadog.Trace/TracerManager.cs index f4afb09a2..398ccb4ef 100644 --- a/tracer/src/Datadog.Trace/TracerManager.cs +++ b/tracer/src/Datadog.Trace/TracerManager.cs @@ -20,6 +20,7 @@ using Datadog.Trace.Propagation; using Datadog.Trace.RuntimeMetrics; using Datadog.Trace.Sampling; +using Datadog.Trace.Util; using Datadog.Trace.Vendors.Newtonsoft.Json; using Datadog.Trace.Vendors.StatsdClient; @@ -272,10 +273,10 @@ private static async Task WriteDiagnosticLog(TracerManager instance) writer.WriteValue(instance.DefaultServiceName); writer.WritePropertyName("agent_url"); - writer.WriteValue(instanceSettings.AgentUri); + writer.WriteValue(instanceSettings.ExporterSettings.AgentUri); writer.WritePropertyName("metrics_agent_url"); - writer.WriteValue(instanceSettings.MetricsEndpointUrl); + writer.WriteValue(instanceSettings.ExporterSettings.MetricsEndpointUrl); writer.WritePropertyName("debug"); writer.WriteValue(GlobalSettings.Source.DebugEnabled); @@ -332,10 +333,10 @@ private static async Task WriteDiagnosticLog(TracerManager instance) writer.WriteValue(instanceSettings.RouteTemplateResourceNamesEnabled); writer.WritePropertyName("partialflush_enabled"); - writer.WriteValue(instanceSettings.PartialFlushEnabled); + writer.WriteValue(instanceSettings.ExporterSettings.PartialFlushEnabled); writer.WritePropertyName("partialflush_minspans"); - writer.WriteValue(instanceSettings.PartialFlushMinSpans); + writer.WriteValue(instanceSettings.ExporterSettings.PartialFlushMinSpans); writer.WritePropertyName("runtime_id"); writer.WriteValue(Tracer.RuntimeId); @@ -375,7 +376,7 @@ private static TracerManager CreateInitializedTracer(ImmutableTracerSettings set { if (_instance is ILockedTracer) { - throw new InvalidOperationException("The current tracer instance cannot be replaced."); + ThrowHelper.ThrowInvalidOperationException("The current tracer instance cannot be replaced."); } var newManager = factory.CreateTracerManager(settings, _instance); diff --git a/tracer/src/Datadog.Trace/TracerManagerFactory.cs b/tracer/src/Datadog.Trace/TracerManagerFactory.cs index 93112c0dc..68f01ce9e 100644 --- a/tracer/src/Datadog.Trace/TracerManagerFactory.cs +++ b/tracer/src/Datadog.Trace/TracerManagerFactory.cs @@ -12,6 +12,7 @@ using Datadog.Trace.Abstractions; using Datadog.Trace.Agent; using Datadog.Trace.Agent.Zipkin; +using Datadog.Trace.ClrProfiler; using Datadog.Trace.Configuration; using Datadog.Trace.Conventions; using Datadog.Trace.DogStatsd; @@ -72,16 +73,16 @@ internal TracerManager CreateTracerManager( var traceIdConvention = GetTraceIdConvention(settings.Convention); statsd = settings.TracerMetricsEnabled - ? (statsd ?? CreateDogStatsdClient(settings, defaultServiceName, settings.DogStatsdPort)) + ? (statsd ?? CreateDogStatsdClient(settings, defaultServiceName, settings.ExporterSettings.DogStatsdPort)) : null; sampler ??= GetSampler(settings); var propagator = CreateCompositePropagator(settings, traceIdConvention); agentWriter ??= GetAgentWriter(settings, statsd, sampler); scopeManager ??= new AsyncLocalScopeManager(settings.ThreadSamplingEnabled); - if (settings.RuntimeMetricsEnabled) + if (settings.RuntimeMetricsEnabled && !DistributedTracer.Instance.IsChildTracer) { - runtimeMetrics ??= new RuntimeMetricsWriter(statsd ?? CreateDogStatsdClient(settings, defaultServiceName, settings.DogStatsdPort), TimeSpan.FromSeconds(10)); + runtimeMetrics ??= new RuntimeMetricsWriter(statsd ?? CreateDogStatsdClient(settings, defaultServiceName, settings.ExporterSettings.DogStatsdPort), TimeSpan.FromSeconds(10)); } if (settings.LogsInjectionEnabled) @@ -149,8 +150,8 @@ protected virtual IAgentWriter GetAgentWriter(ImmutableTracerSettings settings, case ExporterType.Zipkin: return new ExporterWriter(new ZipkinExporter(settings), metrics); default: - var apiRequestFactory = TransportStrategy.Get(settings); - var api = new Api(settings.AgentUri, apiRequestFactory, statsd, rates => sampler.SetDefaultSampleRates(rates), settings.PartialFlushEnabled); + var apiRequestFactory = TransportStrategy.Get(settings.ExporterSettings); + var api = new Api(settings.ExporterSettings.AgentUri, apiRequestFactory, statsd, rates => sampler.SetDefaultSampleRates(rates), settings.ExporterSettings.PartialFlushEnabled); return new AgentWriter(api, metrics, maxBufferSize: settings.TraceBufferSize); } } @@ -194,7 +195,7 @@ private static IDogStatsd CreateDogStatsdClient(ImmutableTracerSettings settings if (settings.MetricsExporter == MetricsExporterType.SignalFx) { - var reporter = new SignalFxReporter(settings.MetricsEndpointUrl, settings.SignalFxAccessToken); + var reporter = new SignalFxReporter(settings.ExporterSettings.MetricsEndpointUrl, settings.SignalFxAccessToken); var metricSender = new SignalFxMetricSender(reporter, constantTags.ToArray()); return new SignalFxStats(metricSender); } @@ -213,7 +214,7 @@ private static IDogStatsd CreateDogStatsdClient(ImmutableTracerSettings settings { statsd.Configure(new StatsdConfig { - StatsdServerName = settings.AgentUri.DnsSafeHost, + StatsdServerName = settings.ExporterSettings.AgentUri.DnsSafeHost, StatsdPort = port, ConstantTags = constantTags.ToArray() }); diff --git a/tracer/src/Datadog.Trace/Util/DbCommandCache.cs b/tracer/src/Datadog.Trace/Util/DbCommandCache.cs index 4250e8735..e3b52be47 100644 --- a/tracer/src/Datadog.Trace/Util/DbCommandCache.cs +++ b/tracer/src/Datadog.Trace/Util/DbCommandCache.cs @@ -19,12 +19,12 @@ internal static class DbCommandCache private static readonly IDatadogLogger Log = DatadogLogging.GetLoggerFor(typeof(DbCommandCache)); - private static ConcurrentDictionary[]> _cache = new(); + private static ConcurrentDictionary _cache = new(); /// /// Gets or sets the underlying cache, to be used for unit tests /// - internal static ConcurrentDictionary[]> Cache + internal static ConcurrentDictionary Cache { get { @@ -37,13 +37,13 @@ internal static ConcurrentDictionary[]> Cac } } - public static KeyValuePair[] GetTagsFromDbCommand(IDbCommand command) + public static TagsCacheItem GetTagsFromDbCommand(IDbCommand command) { var connectionString = command.Connection?.ConnectionString; if (connectionString is null) { - return Array.Empty>(); + return default; } var cache = _cache; @@ -76,25 +76,15 @@ public static KeyValuePair[] GetTagsFromDbCommand(IDbCommand com return ExtractTagsFromConnectionString(connectionString); } - private static KeyValuePair[] ExtractTagsFromConnectionString(string connectionString) + private static TagsCacheItem ExtractTagsFromConnectionString(string connectionString) { // Parse the connection string var builder = new DbConnectionStringBuilder { ConnectionString = connectionString }; - return new[] - { - new KeyValuePair( - Tags.DbName, - GetConnectionStringValue(builder, "Database", "Initial Catalog", "InitialCatalog")), - - new KeyValuePair( - Tags.DbUser, - GetConnectionStringValue(builder, "User ID", "UserID")), - - new KeyValuePair( - Tags.OutHost, - GetConnectionStringValue(builder, "Server", "Data Source", "DataSource", "Network Address", "NetworkAddress", "Address", "Addr", "Host")) - }; + return new TagsCacheItem( + dbName: GetConnectionStringValue(builder, "Database", "Initial Catalog", "InitialCatalog"), + dbUser: GetConnectionStringValue(builder, "User ID", "UserID"), + outHost: GetConnectionStringValue(builder, "Server", "Data Source", "DataSource", "Network Address", "NetworkAddress", "Address", "Addr", "Host")); } private static string GetConnectionStringValue(DbConnectionStringBuilder builder, params string[] names) @@ -110,5 +100,19 @@ private static string GetConnectionStringValue(DbConnectionStringBuilder builder return null; } + + internal readonly struct TagsCacheItem + { + public readonly string DbName; + public readonly string DbUser; + public readonly string OutHost; + + public TagsCacheItem(string dbName, string dbUser, string outHost) + { + DbName = dbName; + DbUser = dbUser; + OutHost = outHost; + } + } } } diff --git a/tracer/src/Datadog.Trace/Util/Http/HttpRequestExtensions.Core.cs b/tracer/src/Datadog.Trace/Util/Http/HttpRequestExtensions.Core.cs index 5b2b7299a..0c6350a9d 100644 --- a/tracer/src/Datadog.Trace/Util/Http/HttpRequestExtensions.Core.cs +++ b/tracer/src/Datadog.Trace/Util/Http/HttpRequestExtensions.Core.cs @@ -24,21 +24,22 @@ internal static Dictionary PrepareArgsForWaf(this HttpRequest re var headersDic = new Dictionary(request.Headers.Keys.Count); foreach (var k in request.Headers.Keys) { - if (!k.Equals("cookie", System.StringComparison.OrdinalIgnoreCase)) + var currentKey = k ?? string.Empty; + if (!currentKey.Equals("cookie", System.StringComparison.OrdinalIgnoreCase)) { - var key = k.ToLowerInvariant(); + currentKey = currentKey.ToLowerInvariant(); #if NETCOREAPP - if (!headersDic.TryAdd(key, request.Headers[key])) + if (!headersDic.TryAdd(currentKey, request.Headers[currentKey])) { #else - if (!headersDic.ContainsKey(key)) + if (!headersDic.ContainsKey(currentKey)) { - headersDic.Add(key, request.Headers[key]); + headersDic.Add(currentKey, request.Headers[currentKey]); } else { #endif - Log.Warning("Header {key} couldn't be added as argument to the waf", key); + Log.Warning("Header {key} couldn't be added as argument to the waf", currentKey); } } } @@ -47,10 +48,11 @@ internal static Dictionary PrepareArgsForWaf(this HttpRequest re for (var i = 0; i < request.Cookies.Count; i++) { var cookie = request.Cookies.ElementAt(i); - var keyExists = cookiesDic.TryGetValue(cookie.Key, out var value); + var currentKey = cookie.Key ?? string.Empty; + var keyExists = cookiesDic.TryGetValue(currentKey, out var value); if (!keyExists) { - cookiesDic.Add(cookie.Key, new List { cookie.Value ?? string.Empty }); + cookiesDic.Add(currentKey, new List { cookie.Value ?? string.Empty }); } else { @@ -58,21 +60,25 @@ internal static Dictionary PrepareArgsForWaf(this HttpRequest re } } - var queryStringDic = new Dictionary(request.Query.Count); + var queryStringDic = new Dictionary>(request.Query.Count); foreach (var kvp in request.Query) { -#if NETCOREAPP - if (!queryStringDic.TryAdd(kvp.Key, kvp.Value)) + var value = kvp.Value; + var currentKey = kvp.Key ?? string.Empty; + // a query string like ?test only fills the key part, in IIS it only fills the value part, aligning behaviors here (also waf tests on values only) + if (string.IsNullOrEmpty(value)) { -#else - if (!queryStringDic.ContainsKey(kvp.Key)) + value = currentKey; + currentKey = string.Empty; + } + + if (!queryStringDic.TryGetValue(currentKey, out var list)) { - queryStringDic.Add(kvp.Key, kvp.Value); + queryStringDic.Add(currentKey, new List { value }); } else { -#endif - Log.Warning("Query string with {key} couldn't be added as argument to the waf", kvp.Key); + list.Add(value); } } diff --git a/tracer/src/Datadog.Trace/Util/Http/HttpRequestExtensions.Framework.cs b/tracer/src/Datadog.Trace/Util/Http/HttpRequestExtensions.Framework.cs index d9e69c08b..2d39d1938 100644 --- a/tracer/src/Datadog.Trace/Util/Http/HttpRequestExtensions.Framework.cs +++ b/tracer/src/Datadog.Trace/Util/Http/HttpRequestExtensions.Framework.cs @@ -21,18 +21,19 @@ internal static Dictionary PrepareArgsForWaf(this HttpRequest re { var headersDic = new Dictionary(request.Headers.Keys.Count); var headerKeys = request.Headers.Keys; - foreach (string k in headerKeys) + foreach (string originalKey in headerKeys) { - if (!k.Equals("cookie", System.StringComparison.OrdinalIgnoreCase)) + var keyForDictionary = originalKey ?? string.Empty; + if (!keyForDictionary.Equals("cookie", System.StringComparison.OrdinalIgnoreCase)) { - var key = k.ToLowerInvariant(); - if (!headersDic.ContainsKey(key)) + keyForDictionary = keyForDictionary.ToLowerInvariant(); + if (!headersDic.ContainsKey(keyForDictionary)) { - headersDic.Add(key, request.Headers.GetValues(key)); + headersDic.Add(keyForDictionary, request.Headers.GetValues(originalKey)); } else { - Log.Warning("Header {key} couldn't be added as argument to the waf", key); + Log.Warning("Header {key} couldn't be added as argument to the waf", keyForDictionary); } } } @@ -41,6 +42,7 @@ internal static Dictionary PrepareArgsForWaf(this HttpRequest re for (var i = 0; i < request.Cookies.Count; i++) { var cookie = request.Cookies[i]; + var keyForDictionary = cookie.Name ?? string.Empty; var keyExists = cookiesDic.TryGetValue(cookie.Name, out var value); if (!keyExists) { @@ -53,20 +55,21 @@ internal static Dictionary PrepareArgsForWaf(this HttpRequest re } var queryDic = new Dictionary(request.QueryString.AllKeys.Length); - foreach (var k in request.QueryString.AllKeys) + foreach (var originalKey in request.QueryString.AllKeys) { - var values = request.QueryString.GetValues(k); - if (!queryDic.ContainsKey(k)) + var values = request.QueryString.GetValues(originalKey); + var keyForDictionary = originalKey ?? string.Empty; + if (!queryDic.ContainsKey(keyForDictionary)) { - queryDic.Add(k, values); + queryDic.Add(keyForDictionary, values); } else { - Log.Warning("Query string {key} couldn't be added as argument to the waf", k); + Log.Warning("Query string {key} couldn't be added as argument to the waf", keyForDictionary); } } - var dict = new Dictionary + var dict = new Dictionary(capacity: 5) { { AddressesConstants.RequestMethod, request.HttpMethod diff --git a/tracer/src/Datadog.Trace/Util/ThrowHelper.cs b/tracer/src/Datadog.Trace/Util/ThrowHelper.cs new file mode 100644 index 000000000..e244eb80a --- /dev/null +++ b/tracer/src/Datadog.Trace/Util/ThrowHelper.cs @@ -0,0 +1,71 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; + +namespace Datadog.Trace.Util +{ + internal class ThrowHelper + { + [MethodImpl(MethodImplOptions.NoInlining)] + [DebuggerHidden] + [DoesNotReturn] + internal static void ThrowArgumentNullException(string paramName) => throw new ArgumentNullException(paramName); + + [MethodImpl(MethodImplOptions.NoInlining)] + [DebuggerHidden] + [DoesNotReturn] + internal static void ThrowArgumentOutOfRangeException(string paramName) => throw new ArgumentOutOfRangeException(paramName); + + [MethodImpl(MethodImplOptions.NoInlining)] + [DebuggerHidden] + [DoesNotReturn] + internal static void ThrowArgumentOutOfRangeException(string paramName, string message) => throw new ArgumentOutOfRangeException(paramName, message); + + [MethodImpl(MethodImplOptions.NoInlining)] + [DebuggerHidden] + [DoesNotReturn] + internal static void ThrowArgumentOutOfRangeException(string paramName, object actualValue, string message) => throw new ArgumentOutOfRangeException(paramName, actualValue, message); + + [MethodImpl(MethodImplOptions.NoInlining)] + [DebuggerHidden] + [DoesNotReturn] + internal static void ThrowArgumentException(string message) => throw new ArgumentException(message); + + [MethodImpl(MethodImplOptions.NoInlining)] + [DebuggerHidden] + [DoesNotReturn] + internal static void ThrowArgumentException(string message, string paramName) => throw new ArgumentException(message, paramName); + + [MethodImpl(MethodImplOptions.NoInlining)] + [DebuggerHidden] + [DoesNotReturn] + internal static void ThrowInvalidOperationException(string message) => throw new InvalidOperationException(message); + + [MethodImpl(MethodImplOptions.NoInlining)] + [DebuggerHidden] + [DoesNotReturn] + internal static void ThrowException(string message) => throw new Exception(message); + + [MethodImpl(MethodImplOptions.NoInlining)] + [DebuggerHidden] + [DoesNotReturn] + internal static void ThrowInvalidCastException(string message) => throw new InvalidCastException(message); + + [MethodImpl(MethodImplOptions.NoInlining)] + [DebuggerHidden] + [DoesNotReturn] + internal static void ThrowNotSupportedException(string message) => throw new NotSupportedException(message); + + [MethodImpl(MethodImplOptions.NoInlining)] + [DebuggerHidden] + [DoesNotReturn] + internal static void ThrowKeyNotFoundException(string message) => throw new KeyNotFoundException(message); + } +} diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AWS/AwsSqsTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AWS/AwsSqsTests.cs index 2e515d4f9..79548841b 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AWS/AwsSqsTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AWS/AwsSqsTests.cs @@ -125,8 +125,7 @@ public AwsSqsTests(ITestOutputHelper output) [Trait("Category", "EndToEnd")] public void SubmitsTraces(string packageVersion) { - int agentPort = TcpPortProvider.GetOpenPort(); - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion)) { var spans = agent.WaitForSpans(_expectedSpans.Count, operationName: "sqs.request"); diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/DapperTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/DapperTests.cs index 9d69f2ee1..0ea14834b 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/DapperTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/DapperTests.cs @@ -29,9 +29,7 @@ public void SubmitsTraces() const string expectedOperationName = dbType + ".query"; const string expectedServiceName = "Samples.Dapper"; - int agentPort = TcpPortProvider.GetOpenPort(); - - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (RunSampleAndWaitForExit(agent.Port)) { var spans = agent.WaitForSpans(expectedSpanCount, operationName: expectedOperationName); @@ -58,9 +56,7 @@ public void SubmitsTracesWithNetStandard() const string expectedOperationName = dbType + ".query"; const string expectedServiceName = "Samples.Dapper"; - int agentPort = TcpPortProvider.GetOpenPort(); - - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (RunSampleAndWaitForExit(agent.Port)) { var spans = agent.WaitForSpans(expectedSpanCount, operationName: expectedOperationName); diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/FakeCommandTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/FakeCommandTests.cs index 733333490..090e4b033 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/FakeCommandTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/FakeCommandTests.cs @@ -28,9 +28,7 @@ public void SubmitsTraces() const string expectedOperationName = dbType + ".query"; const string expectedServiceName = "Samples.FakeDbCommand"; - int agentPort = TcpPortProvider.GetOpenPort(); - - using var agent = new MockTracerAgent(agentPort); + using var agent = EnvironmentHelper.GetMockAgent(); using var process = RunSampleAndWaitForExit(agent.Port); var spans = agent.WaitForSpans(expectedSpanCount); diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/MicrosoftDataSqlClientTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/MicrosoftDataSqlClientTests.cs index 45c2aa12e..7f0e61870 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/MicrosoftDataSqlClientTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/MicrosoftDataSqlClientTests.cs @@ -62,8 +62,7 @@ public void SubmitsTraces(string packageVersion) const string expectedOperationName = dbType + ".query"; const string expectedServiceName = "Samples.Microsoft.Data.SqlClient"; - int agentPort = TcpPortProvider.GetOpenPort(); - using var agent = new MockTracerAgent(agentPort); + using var agent = EnvironmentHelper.GetMockAgent(); using var process = RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion); var spans = agent.WaitForSpans(expectedSpanCount, operationName: expectedOperationName); int actualSpanCount = spans.Count(s => s.ParentId.HasValue); // Remove unexpected DB spans from the calculation @@ -92,8 +91,7 @@ public void IntegrationDisabled() SetEnvironmentVariable($"SIGNALFX_TRACE_{nameof(IntegrationId.SqlClient)}_ENABLED", "false"); string packageVersion = PackageVersions.MicrosoftDataSqlClient.First()[0] as string; - int agentPort = TcpPortProvider.GetOpenPort(); - using var agent = new MockTracerAgent(agentPort); + using var agent = EnvironmentHelper.GetMockAgent(); using var process = RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion); var spans = agent.WaitForSpans(totalSpanCount, returnAllOperations: true); diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/MicrosoftDataSqliteTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/MicrosoftDataSqliteTests.cs index 9f4737cd0..4633526df 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/MicrosoftDataSqliteTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/MicrosoftDataSqliteTests.cs @@ -44,8 +44,7 @@ public void SubmitsTraces(string packageVersion) const string expectedOperationName = dbType + ".query"; const string expectedServiceName = "Samples.Microsoft.Data.Sqlite"; - int agentPort = TcpPortProvider.GetOpenPort(); - using var agent = new MockTracerAgent(agentPort); + using var agent = EnvironmentHelper.GetMockAgent(); using var process = RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion); var spans = agent.WaitForSpans(expectedSpanCount, operationName: expectedOperationName); @@ -74,8 +73,7 @@ public void IntegrationDisabled() SetEnvironmentVariable($"SIGNALFX_TRACE_{nameof(IntegrationId.Sqlite)}_ENABLED", "false"); string packageVersion = PackageVersions.MicrosoftDataSqlite.First()[0] as string; - int agentPort = TcpPortProvider.GetOpenPort(); - using var agent = new MockTracerAgent(agentPort); + using var agent = EnvironmentHelper.GetMockAgent(); using var process = RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion); var spans = agent.WaitForSpans(totalSpanCount, returnAllOperations: true); diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/MySqlCommandTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/MySqlCommandTests.cs index c15f0efcd..bc1fcaf9f 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/MySqlCommandTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/MySqlCommandTests.cs @@ -76,8 +76,7 @@ public void IntegrationDisabled() SetEnvironmentVariable($"SIGNALFX_TRACE_{nameof(IntegrationId.MySql)}_ENABLED", "false"); - int agentPort = TcpPortProvider.GetOpenPort(); - using var agent = new MockTracerAgent(agentPort); + using var agent = EnvironmentHelper.GetMockAgent(); // don't use the first package version which is 6.x and is not supported on ARM64. // use the default package version for the sample, currently 8.0.17. @@ -112,9 +111,7 @@ private void SubmitsTraces(string packageVersion) const string expectedOperationName = dbType + ".query"; const string expectedServiceName = "Samples.MySql"; - int agentPort = TcpPortProvider.GetOpenPort(); - - using var agent = new MockTracerAgent(agentPort); + using var agent = EnvironmentHelper.GetMockAgent(); using var process = RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion); var spans = agent.WaitForSpans(expectedSpanCount, operationName: expectedOperationName); int actualSpanCount = spans.Count(s => s.ParentId.HasValue && !s.Resource.Equals("SHOW WARNINGS", StringComparison.OrdinalIgnoreCase)); // Remove unexpected DB spans from the calculation diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/MySqlConnectorTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/MySqlConnectorTests.cs index 51b8637a3..fce3bde1b 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/MySqlConnectorTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/MySqlConnectorTests.cs @@ -48,8 +48,7 @@ public void SubmitsTraces(string packageVersion) const string expectedOperationName = dbType + ".query"; const string expectedServiceName = "Samples.MySqlConnector"; - int agentPort = TcpPortProvider.GetOpenPort(); - using var agent = new MockTracerAgent(agentPort); + using var agent = EnvironmentHelper.GetMockAgent(); using var process = RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion); var spans = agent.WaitForSpans(expectedSpanCount, operationName: expectedOperationName); int actualSpanCount = spans.Count(s => s.ParentId.HasValue && !s.Resource.Equals("SHOW WARNINGS", StringComparison.OrdinalIgnoreCase)); // Remove unexpected DB spans from the calculation @@ -77,8 +76,7 @@ public void IntegrationDisabled() SetEnvironmentVariable($"SIGNALFX_TRACE_{nameof(IntegrationId.MySql)}_ENABLED", "false"); string packageVersion = PackageVersions.MySqlConnector.First()[0] as string; - int agentPort = TcpPortProvider.GetOpenPort(); - using var agent = new MockTracerAgent(agentPort); + using var agent = EnvironmentHelper.GetMockAgent(); using var process = RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion); var spans = agent.WaitForSpans(totalSpanCount, returnAllOperations: true); diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/NpgsqlCommandTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/NpgsqlCommandTests.cs index 9724e8c04..7a057b7da 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/NpgsqlCommandTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/NpgsqlCommandTests.cs @@ -45,9 +45,7 @@ public void SubmitsTraces(string packageVersion) const string dbType = "postgresql"; const string expectedOperationName = dbType + ".query"; const string expectedServiceName = "Samples.Npgsql"; - - int agentPort = TcpPortProvider.GetOpenPort(); - using var agent = new MockTracerAgent(agentPort); + using var agent = EnvironmentHelper.GetMockAgent(); using var process = RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion); var spans = agent.WaitForSpans(expectedSpanCount, operationName: expectedOperationName); int actualSpanCount = spans.Count(s => s.ParentId.HasValue); // Remove unexpected DB spans from the calculation @@ -76,8 +74,7 @@ public void IntegrationDisabled() SetEnvironmentVariable($"SIGNALFX_TRACE_{nameof(IntegrationId.Npgsql)}_ENABLED", "false"); string packageVersion = PackageVersions.Npgsql.First()[0] as string; - int agentPort = TcpPortProvider.GetOpenPort(); - using var agent = new MockTracerAgent(agentPort); + using var agent = EnvironmentHelper.GetMockAgent(); using var process = RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion); var spans = agent.WaitForSpans(totalSpanCount, returnAllOperations: true); diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/SqlCommand20Tests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/SqlCommand20Tests.cs index c5812026c..df98c3f76 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/SqlCommand20Tests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/SqlCommand20Tests.cs @@ -32,9 +32,7 @@ public void SubmitsTraces() const string dbType = "mssql"; const string expectedOperationName = dbType + ".query"; const string expectedServiceName = "Samples.SqlServer.NetFramework20"; - - int agentPort = TcpPortProvider.GetOpenPort(); - using var agent = new MockTracerAgent(agentPort); + using var agent = EnvironmentHelper.GetMockAgent(); using var process = RunSampleAndWaitForExit(agent.Port); var spans = agent.WaitForSpans(expectedSpanCount, operationName: expectedOperationName); @@ -60,9 +58,7 @@ public void IntegrationDisabled() const string expectedOperationName = "mssql.query"; SetEnvironmentVariable($"SIGNALFX_TRACE_{nameof(IntegrationId.SqlClient)}_ENABLED", "false"); - - int agentPort = TcpPortProvider.GetOpenPort(); - using var agent = new MockTracerAgent(agentPort); + using var agent = EnvironmentHelper.GetMockAgent(); using var process = RunSampleAndWaitForExit(agent.Port); var spans = agent.WaitForSpans(totalSpanCount, returnAllOperations: true); diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/SystemDataSqlClientTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/SystemDataSqlClientTests.cs index 1c94b8c88..639715d16 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/SystemDataSqlClientTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/SystemDataSqlClientTests.cs @@ -52,9 +52,7 @@ public void SubmitsTraces(string packageVersion) const string dbType = "mssql"; const string expectedOperationName = dbType + ".query"; const string expectedServiceName = "Samples.SqlServer"; - - int agentPort = TcpPortProvider.GetOpenPort(); - using var agent = new MockTracerAgent(agentPort); + using var agent = EnvironmentHelper.GetMockAgent(); using var process = RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion); var spans = agent.WaitForSpans(expectedSpanCount, operationName: expectedOperationName); @@ -82,8 +80,7 @@ public void IntegrationDisabled() SetEnvironmentVariable($"SIGNALFX_TRACE_{nameof(IntegrationId.SqlClient)}_ENABLED", "false"); string packageVersion = PackageVersions.SystemDataSqlClient.First()[0] as string; - int agentPort = TcpPortProvider.GetOpenPort(); - using var agent = new MockTracerAgent(agentPort); + using var agent = EnvironmentHelper.GetMockAgent(); using var process = RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion); var spans = agent.WaitForSpans(totalSpanCount, returnAllOperations: true); diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/SystemDataSqliteTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/SystemDataSqliteTests.cs index ce8f3effb..da0004fbf 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/SystemDataSqliteTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/SystemDataSqliteTests.cs @@ -32,9 +32,7 @@ public void SubmitsTraces() const string dbType = "sqlite"; const string expectedOperationName = dbType + ".query"; const string expectedServiceName = "Samples.SQLite.Core"; - - int agentPort = TcpPortProvider.GetOpenPort(); - using var agent = new MockTracerAgent(agentPort); + using var agent = EnvironmentHelper.GetMockAgent(); using var process = RunSampleAndWaitForExit(agent.Port); var spans = agent.WaitForSpans(expectedSpanCount, operationName: expectedOperationName); @@ -61,9 +59,7 @@ public void IntegrationDisabled() const string expectedOperationName = "sqlite.query"; SetEnvironmentVariable($"SIGNALFX_TRACE_{nameof(IntegrationId.Sqlite)}_ENABLED", "false"); - - int agentPort = TcpPortProvider.GetOpenPort(); - using var agent = new MockTracerAgent(agentPort); + using var agent = EnvironmentHelper.GetMockAgent(); using var process = RunSampleAndWaitForExit(agent.Port); var spans = agent.WaitForSpans(totalSpanCount, returnAllOperations: true); diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AerospikeTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AerospikeTests.cs index 62650c221..9777f0bb5 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AerospikeTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AerospikeTests.cs @@ -28,9 +28,7 @@ public AerospikeTests(ITestOutputHelper output) [Trait("Category", "ArmUnsupported")] public void SubmitTraces(string packageVersion) { - int agentPort = TcpPortProvider.GetOpenPort(); - - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion)) { var expectedSpans = new List diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AspNet/AspNetMvc4Tests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AspNet/AspNetMvc4Tests.cs index a2448b5a7..e5a2adbc8 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AspNet/AspNetMvc4Tests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AspNet/AspNetMvc4Tests.cs @@ -7,7 +7,6 @@ #pragma warning disable SA1402 // File may only contain a single class #pragma warning disable SA1649 // File name must match first type name using System.Net; -using System.Runtime.InteropServices; using System.Threading.Tasks; using Datadog.Trace.Configuration; using Datadog.Trace.TestHelpers; @@ -70,7 +69,7 @@ public AspNetMvc4Tests(IisFixture iisFixture, ITestOutputHelper output, bool cla _iisFixture.TryStartIis(this, classicMode ? IisAppType.AspNetClassic : IisAppType.AspNetIntegrated); _testName = nameof(AspNetMvc4Tests) + (classicMode ? ".Classic" : ".Integrated") - + (enableRouteTemplateResourceNames ? ".NoFF" : ".WithFF"); + + (enableRouteTemplateResourceNames ? ".WithFF" : ".NoFF"); } public static TheoryData Data() => new() diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AspNet/AspNetMvc5Tests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AspNet/AspNetMvc5Tests.cs index 6384feb00..5cd85541d 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AspNet/AspNetMvc5Tests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AspNet/AspNetMvc5Tests.cs @@ -71,7 +71,7 @@ public AspNetMvc5Tests(IisFixture iisFixture, ITestOutputHelper output, bool cla _iisFixture.TryStartIis(this, classicMode ? IisAppType.AspNetClassic : IisAppType.AspNetIntegrated); _testName = nameof(AspNetMvc5Tests) + (classicMode ? ".Classic" : ".Integrated") - + (enableRouteTemplateResourceNames ? ".NoFF" : ".WithFF"); + + (enableRouteTemplateResourceNames ? ".WithFF" : ".NoFF"); } public static TheoryData Data() => new() diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AspNet/AspNetWebApi2Tests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AspNet/AspNetWebApi2Tests.cs index 06a094ff3..792e8d8db 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AspNet/AspNetWebApi2Tests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AspNet/AspNetWebApi2Tests.cs @@ -71,7 +71,7 @@ public AspNetWebApi2Tests(IisFixture iisFixture, ITestOutputHelper output, bool _iisFixture.TryStartIis(this, classicMode ? IisAppType.AspNetClassic : IisAppType.AspNetIntegrated); _testName = nameof(AspNetWebApi2Tests) + (classicMode ? ".Classic" : ".Integrated") - + (enableRouteTemplateResourceNames ? ".NoFF" : ".WithFF"); + + (enableRouteTemplateResourceNames ? ".WithFF" : ".NoFF"); } public static TheoryData Data() => new() diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AspNet/OwinWebApi2Tests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AspNet/OwinWebApi2Tests.cs index 3d1ed87c9..67408f69c 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AspNet/OwinWebApi2Tests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AspNet/OwinWebApi2Tests.cs @@ -12,7 +12,6 @@ using System.Diagnostics; using System.Net; using System.Net.Http; -using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; using Datadog.Trace.Configuration; @@ -54,11 +53,12 @@ public OwinWebApi2Tests(OwinFixture fixture, ITestOutputHelper output, bool enab { SetServiceVersion("1.0.0"); SetEnvironmentVariable(ConfigurationKeys.FeatureFlags.RouteTemplateResourceNamesEnabled, enableRouteTemplateResourceNames.ToString()); + SetEnvironmentVariable(ConfigurationKeys.HeaderTags, CommonHttpHeaderNames.UserAgent + ":http_useragent"); _fixture = fixture; _output = output; _testName = nameof(OwinWebApi2Tests) - + (enableRouteTemplateResourceNames ? ".NoFF" : ".WithFF"); + + (enableRouteTemplateResourceNames ? ".WithFF" : ".NoFF"); } public static TheoryData Data() => new() @@ -127,6 +127,7 @@ public OwinFixture() { _httpClient = new HttpClient(); _httpClient.DefaultRequestHeaders.Add(CommonHttpHeaderNames.TracingEnabled, "false"); + _httpClient.DefaultRequestHeaders.Add(CommonHttpHeaderNames.UserAgent, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36"); } public MockTracerAgent Agent { get; private set; } diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/CI/MsTestV2Tests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/CI/MsTestV2Tests.cs index cf13cc4e7..dc4ee9bac 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/CI/MsTestV2Tests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/CI/MsTestV2Tests.cs @@ -33,7 +33,7 @@ public MsTestV2Tests(ITestOutputHelper output) [Trait("Category", "TestIntegrations")] public void SubmitTraces(string packageVersion) { - var version = string.IsNullOrEmpty(packageVersion) ? new Version("2.0.0") : new Version(packageVersion); + var version = string.IsNullOrEmpty(packageVersion) ? new Version("2.2.8") : new Version(packageVersion); List spans = null; var expectedSpanCount = version.CompareTo(new Version("2.2.5")) < 0 ? 13 : 15; @@ -43,9 +43,7 @@ public void SubmitTraces(string packageVersion) SetEnvironmentVariable("SIGNALFX_TRACE_DEBUG", "1"); SetEnvironmentVariable("SIGNALFX_DUMP_ILREWRITE_ENABLED", "1"); - int agentPort = TcpPortProvider.GetOpenPort(); - - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (ProcessResult processResult = RunDotnetTestSampleAndWaitForExit(agent.Port, packageVersion: packageVersion)) { spans = agent.WaitForSpans(expectedSpanCount) @@ -79,10 +77,10 @@ public void SubmitTraces(string packageVersion) // check the version AssertTargetSpanEqual(targetSpan, "version", "1.0.0"); - // check the SingalFx library name + // check the SignalFx library name AssertTargetSpanEqual(targetSpan, "signalfx.tracing.library", "dotnet-tracing"); - // check the SingalFx library version + // check the SignalFx library version AssertTargetSpanEqual(targetSpan, "signalfx.tracing.version", "0.2.0.0"); // checks the runtime id tag diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/CI/NUnitTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/CI/NUnitTests.cs index 1484e1ae5..5843f8595 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/CI/NUnitTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/CI/NUnitTests.cs @@ -58,9 +58,7 @@ public void SubmitTraces(string packageVersion) SetEnvironmentVariable("SIGNALFX_TRACE_DEBUG", "1"); SetEnvironmentVariable("SIGNALFX_DUMP_ILREWRITE_ENABLED", "1"); - int agentPort = TcpPortProvider.GetOpenPort(); - - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (ProcessResult processResult = RunDotnetTestSampleAndWaitForExit(agent.Port, packageVersion: packageVersion)) { spans = agent.WaitForSpans(ExpectedSpanCount) @@ -94,10 +92,10 @@ public void SubmitTraces(string packageVersion) // check the version AssertTargetSpanEqual(targetSpan, "version", "1.0.0"); - // check the SingalFx library name + // check the SignalFx library name AssertTargetSpanEqual(targetSpan, "signalfx.tracing.library", "dotnet-tracing"); - // check the SingalFx library version + // check the SignalFx library version AssertTargetSpanEqual(targetSpan, "signalfx.tracing.version", "0.2.0.0"); // checks the runtime id tag diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/CI/XUnitTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/CI/XUnitTests.cs index daacedcdf..534109a4e 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/CI/XUnitTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/CI/XUnitTests.cs @@ -42,9 +42,7 @@ public void SubmitTraces(string packageVersion) SetEnvironmentVariable("SIGNALFX_TRACE_DEBUG", "1"); SetEnvironmentVariable("SIGNALFX_DUMP_ILREWRITE_ENABLED", "1"); - int agentPort = TcpPortProvider.GetOpenPort(); - - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (ProcessResult processResult = RunDotnetTestSampleAndWaitForExit(agent.Port, packageVersion: packageVersion)) { spans = agent.WaitForSpans(ExpectedSpanCount) @@ -80,10 +78,10 @@ public void SubmitTraces(string packageVersion) // check the version AssertTargetSpanEqual(targetSpan, "version", "1.0.0"); - // check the SingalFx library name + // check the SignalFx library name AssertTargetSpanEqual(targetSpan, "signalfx.tracing.library", "dotnet-tracing"); - // check the SingalFx library version + // check the SignalFx library version AssertTargetSpanEqual(targetSpan, "signalfx.tracing.version", "0.2.0.0"); // checks the origin tag diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/CallTargetNativeTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/CallTargetNativeTests.cs index e2a90b978..0f8c35801 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/CallTargetNativeTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/CallTargetNativeTests.cs @@ -35,10 +35,8 @@ public static IEnumerable MethodArgumentsData() [MemberData(nameof(MethodArgumentsData))] public void MethodArgumentsInstrumentation(int numberOfArguments, bool fastPath) { - int agentPort = TcpPortProvider.GetOpenPort(); - - using (new MockTracerAgent(agentPort)) - using (var processResult = RunSampleAndWaitForExit(agentPort, arguments: numberOfArguments.ToString())) + using (var agent = EnvironmentHelper.GetMockAgent()) + using (var processResult = RunSampleAndWaitForExit(agent.Port, arguments: numberOfArguments.ToString())) { string beginMethodString = $"ProfilerOK: BeginMethod\\({numberOfArguments}\\)"; if (!fastPath) @@ -85,10 +83,8 @@ public void MethodArgumentsInstrumentation(int numberOfArguments, bool fastPath) [SkippableFact] public void MethodRefArguments() { - int agentPort = TcpPortProvider.GetOpenPort(); - - using (new MockTracerAgent(agentPort)) - using (var processResult = RunSampleAndWaitForExit(agentPort, arguments: "withref")) + using (var agent = EnvironmentHelper.GetMockAgent()) + using (var processResult = RunSampleAndWaitForExit(agent.Port, arguments: "withref")) { int beginMethodCount = Regex.Matches(processResult.StandardOutput, $"ProfilerOK: BeginMethod\\({1}\\)").Count; int begin2MethodCount = Regex.Matches(processResult.StandardOutput, $"ProfilerOK: BeginMethod\\({2}\\)").Count; @@ -114,10 +110,8 @@ public void MethodRefArguments() [SkippableFact] public void MethodOutArguments() { - int agentPort = TcpPortProvider.GetOpenPort(); - - using (new MockTracerAgent(agentPort)) - using (var processResult = RunSampleAndWaitForExit(agentPort, arguments: "without")) + using (var agent = EnvironmentHelper.GetMockAgent()) + using (var processResult = RunSampleAndWaitForExit(agent.Port, arguments: "without")) { int beginMethodCount = Regex.Matches(processResult.StandardOutput, $"ProfilerOK: BeginMethod\\({1}\\)").Count; int begin2MethodCount = Regex.Matches(processResult.StandardOutput, $"ProfilerOK: BeginMethod\\({2}\\)").Count; diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/CosmosTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/CosmosTests.cs index 5480e13ab..7652be569 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/CosmosTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/CosmosTests.cs @@ -28,8 +28,7 @@ public CosmosTests(ITestOutputHelper output) // for some reason, the elumator needs a warm up run when piloted by the x86 client if (!Environment.Is64BitProcess) { - int agentPort = TcpPortProvider.GetOpenPort(); - using var agent = new MockTracerAgent(agentPort); + using var agent = EnvironmentHelper.GetMockAgent(); using var processResult = RunSampleAndWaitForExit(agent.Port, arguments: $"{TestPrefix}"); } } @@ -43,9 +42,7 @@ public CosmosTests(ITestOutputHelper output) public void SubmitsTraces(string packageVersion) { var expectedSpanCount = 14; - - int agentPort = TcpPortProvider.GetOpenPort(); - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (RunSampleAndWaitForExit(agent.Port, arguments: $"{TestPrefix}", packageVersion: packageVersion)) { var spans = agent.WaitForSpans(expectedSpanCount, operationName: ExpectedOperationName); diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Couchbase3Tests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Couchbase3Tests.cs index 1675084ae..b5987df54 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Couchbase3Tests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Couchbase3Tests.cs @@ -36,8 +36,7 @@ public static System.Collections.Generic.IEnumerable GetCouchbase() [Trait("Category", "ArmUnsupported")] public void SubmitTraces(string packageVersion) { - int agentPort = TcpPortProvider.GetOpenPort(); - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion)) { var spans = agent.WaitForSpans(9, 500) diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/CouchbaseTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/CouchbaseTests.cs index 1f3ab593c..b1cf59eac 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/CouchbaseTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/CouchbaseTests.cs @@ -36,8 +36,7 @@ public static System.Collections.Generic.IEnumerable GetCouchbase() [Trait("Category", "ArmUnsupported")] public void SubmitTraces(string packageVersion) { - int agentPort = TcpPortProvider.GetOpenPort(); - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion)) { var spans = agent.WaitForSpans(13, 500); diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Elasticsearch5Tests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Elasticsearch5Tests.cs index 49851774b..a18f9406f 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Elasticsearch5Tests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Elasticsearch5Tests.cs @@ -40,9 +40,7 @@ public void SubmitsTraces(string packageVersion, bool tagQueries) { SetEnvironmentVariable("SIGNALFX_INSTRUMENTATION_ELASTICSEARCH_TAG_QUERIES", tagQueries.ToString().ToLowerInvariant()); - int agentPort = TcpPortProvider.GetOpenPort(); - - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion)) { var expected = new List(); @@ -193,12 +191,11 @@ public void SubmitsTraces(string packageVersion, bool tagQueries) [Trait("Category", "ArmUnsupported")] public void IntegrationDisabled() { - int agentPort = TcpPortProvider.GetOpenPort(); string packageVersion = PackageVersions.ElasticSearch5.First()[0] as string; SetEnvironmentVariable($"SIGNALFX_TRACE_{nameof(IntegrationId.ElasticsearchNet)}_ENABLED", "false"); - using var agent = new MockTracerAgent(agentPort); + using var agent = EnvironmentHelper.GetMockAgent(); using var process = RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion); var spans = agent.WaitForSpans(1).Where(s => s.Type == "elasticsearch").ToList(); diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Elasticsearch6Tests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Elasticsearch6Tests.cs index dd94dd0d1..3d2d5edef 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Elasticsearch6Tests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Elasticsearch6Tests.cs @@ -41,9 +41,7 @@ public void SubmitsTraces(string packageVersion, bool tagQueries) { SetEnvironmentVariable("SIGNALFX_INSTRUMENTATION_ELASTICSEARCH_TAG_QUERIES", tagQueries.ToString().ToLowerInvariant()); - int agentPort = TcpPortProvider.GetOpenPort(); - - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion)) { var expected = new List(); @@ -210,12 +208,9 @@ public void SubmitsTraces(string packageVersion, bool tagQueries) [Trait("Category", "ArmUnsupported")] public void IntegrationDisabled() { - int agentPort = TcpPortProvider.GetOpenPort(); string packageVersion = PackageVersions.ElasticSearch6.First()[0] as string; - SetEnvironmentVariable($"SIGNALFX_TRACE_{nameof(IntegrationId.ElasticsearchNet)}_ENABLED", "false"); - - using var agent = new MockTracerAgent(agentPort); + using var agent = EnvironmentHelper.GetMockAgent(); using var process = RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion); var spans = agent.WaitForSpans(1).Where(s => s.Type == "elasticsearch").ToList(); diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Elasticsearch7Tests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Elasticsearch7Tests.cs index d6e7fb0ec..842d708d7 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Elasticsearch7Tests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Elasticsearch7Tests.cs @@ -29,9 +29,7 @@ public Elasticsearch7Tests(ITestOutputHelper output) [Trait("Category", "EndToEnd")] public void SubmitsTraces(string packageVersion) { - int agentPort = TcpPortProvider.GetOpenPort(); - - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion)) { var expected = new List(); @@ -158,12 +156,9 @@ public void SubmitsTraces(string packageVersion) [Trait("Category", "ArmUnsupported")] public void IntegrationDisabled() { - int agentPort = TcpPortProvider.GetOpenPort(); string packageVersion = PackageVersions.ElasticSearch7.First()[0] as string; - SetEnvironmentVariable($"SIGNALFX_TRACE_{nameof(IntegrationId.ElasticsearchNet)}_ENABLED", "false"); - - using var agent = new MockTracerAgent(agentPort); + using var agent = EnvironmentHelper.GetMockAgent(); using var process = RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion); var spans = agent.WaitForSpans(1).Where(s => s.Type == "elasticsearch").ToList(); diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/GraphQLTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/GraphQLTests.cs index 82662cf1f..9c65ab6fd 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/GraphQLTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/GraphQLTests.cs @@ -71,10 +71,9 @@ protected GraphQLTests(string sampleAppName, ITestOutputHelper output) [Trait("RunOnWindows", "True")] public void SubmitsTraces() { - int agentPort = TcpPortProvider.GetOpenPort(); int aspNetCorePort = TcpPortProvider.GetOpenPort(); - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (Process process = StartSample(agent.Port, arguments: null, packageVersion: string.Empty, aspNetCorePort: aspNetCorePort)) { var wh = new EventWaitHandle(false, EventResetMode.AutoReset); diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/HttpMessageHandlerTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/HttpMessageHandlerTests.cs index 1f575856d..1a2a38679 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/HttpMessageHandlerTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/HttpMessageHandlerTests.cs @@ -57,13 +57,10 @@ public void HttpClient_SubmitsTraces(InstrumentationOptions instrumentation, boo const string expectedOperationName = "http.request"; const string expectedServiceName = "Samples.HttpMessageHandler"; - int agentPort = TcpPortProvider.GetOpenPort(); int httpPort = TcpPortProvider.GetOpenPort(); - - Output.WriteLine($"Assigning port {agentPort} for the agentPort."); Output.WriteLine($"Assigning port {httpPort} for the httpPort."); - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (ProcessResult processResult = RunSampleAndWaitForExit(agent.Port, arguments: $"Port={httpPort}")) { var spans = agent.WaitForSpans(expectedSpanCount, operationName: expectedOperationName); @@ -97,11 +94,9 @@ public void TracingDisabled_DoesNotSubmitsTraces(InstrumentationOptions instrume ConfigureInstrumentation(instrumentation, enableSocketsHandler); const string expectedOperationName = "http.request"; - - int agentPort = TcpPortProvider.GetOpenPort(); int httpPort = TcpPortProvider.GetOpenPort(); - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (ProcessResult processResult = RunSampleAndWaitForExit(agent.Port, arguments: $"TracingDisabled Port={httpPort}")) { var spans = agent.WaitForSpans(1, 2000, operationName: expectedOperationName); diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/ILoggerTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/ILoggerTests.cs index 6ac67d3f7..e68fefb42 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/ILoggerTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/ILoggerTests.cs @@ -39,14 +39,28 @@ public ILoggerTests(ITestOutputHelper output) [Trait("RunOnWindows", "True")] public void InjectsLogs() { - int agentPort = TcpPortProvider.GetOpenPort(); - using (var agent = new MockTracerAgent(agentPort)) + // One of the traces starts by manual opening a span when the background service starts, + // and then it sends a HTTP request to the server. + // On .NET Framework, we do not yet automatically instrument AspNetCore so instead of + // having one distributed trace, the result is two separate traces. So expect one more trace + // when running on .NET Framework + + // We also log inside of the web server handling, so in .NET Core expect one more log line +#if NETFRAMEWORK + var expectedCorrelatedTraceCount = 3; + var expectedCorrelatedSpanCount = 3; +#else + var expectedCorrelatedTraceCount = 2; + var expectedCorrelatedSpanCount = 4; +#endif + + using (var agent = EnvironmentHelper.GetMockAgent()) using (RunSampleAndWaitForExit(agent.Port, aspNetCorePort: 0)) { var spans = agent.WaitForSpans(1, 2500); spans.Should().HaveCountGreaterOrEqualTo(1); - ValidateLogCorrelation(spans, _logFiles); + ValidateLogCorrelation(spans, _logFiles, expectedCorrelatedTraceCount, expectedCorrelatedSpanCount); } } } diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/KafkaTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/KafkaTests.cs index fb765a44f..a4567541d 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/KafkaTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/KafkaTests.cs @@ -48,9 +48,8 @@ public KafkaTests(ITestOutputHelper output) public void SubmitsTraces(string packageVersion) { var topic = $"sample-topic-{TestPrefix}-{packageVersion}".Replace('.', '-'); - var agentPort = TcpPortProvider.GetOpenPort(); - using var agent = new MockTracerAgent(agentPort); + using var agent = EnvironmentHelper.GetMockAgent(); using var processResult = RunSampleAndWaitForExit(agent.Port, arguments: topic, packageVersion: packageVersion); var allSpans = agent.WaitForSpans(TotalExpectedSpanCount, timeoutInMilliseconds: 10_000); diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Log4NetTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Log4NetTests.cs index 8997fe74b..32dfcf5c5 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Log4NetTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Log4NetTests.cs @@ -59,8 +59,10 @@ public void InjectsLogsWhenEnabled(string packageVersion) { SetEnvironmentVariable("SIGNALFX_LOGS_INJECTION", "true"); - int agentPort = TcpPortProvider.GetOpenPort(); - using (var agent = new MockTracerAgent(agentPort)) + var expectedCorrelatedTraceCount = 1; + var expectedCorrelatedSpanCount = 1; + + using (var agent = EnvironmentHelper.GetMockAgent()) using (RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion)) { var spans = agent.WaitForSpans(1, 2500); @@ -69,15 +71,15 @@ public void InjectsLogsWhenEnabled(string packageVersion) #if NETFRAMEWORK if (!string.IsNullOrWhiteSpace(packageVersion) && new Version(packageVersion) >= new Version("2.0.5")) { - ValidateLogCorrelation(spans, _nlog205LogFileTests, packageVersion); + ValidateLogCorrelation(spans, _nlog205LogFileTests, expectedCorrelatedTraceCount, expectedCorrelatedSpanCount, packageVersion); } else { - ValidateLogCorrelation(spans, _nlogPre205LogFileTests, packageVersion); + ValidateLogCorrelation(spans, _nlogPre205LogFileTests, expectedCorrelatedTraceCount, expectedCorrelatedSpanCount, packageVersion); } #else // Regardless of package version, for .NET Core just assert against raw log lines - ValidateLogCorrelation(spans, _nlogPre205LogFileTests, packageVersion); + ValidateLogCorrelation(spans, _nlogPre205LogFileTests, expectedCorrelatedTraceCount, expectedCorrelatedSpanCount, packageVersion); #endif } } @@ -90,8 +92,10 @@ public void DoesNotInjectLogsWhenDisabled(string packageVersion) { SetEnvironmentVariable("SIGNALFX_LOGS_INJECTION", "false"); - int agentPort = TcpPortProvider.GetOpenPort(); - using (var agent = new MockTracerAgent(agentPort)) + var expectedCorrelatedTraceCount = 0; + var expectedCorrelatedSpanCount = 0; + + using (var agent = EnvironmentHelper.GetMockAgent()) using (RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion)) { var spans = agent.WaitForSpans(1, 2500); @@ -100,15 +104,15 @@ public void DoesNotInjectLogsWhenDisabled(string packageVersion) #if NETFRAMEWORK if (!string.IsNullOrWhiteSpace(packageVersion) && new Version(packageVersion) >= new Version("2.0.5")) { - ValidateLogCorrelation(spans, _nlog205LogFileTests, packageVersion, disableLogCorrelation: true); + ValidateLogCorrelation(spans, _nlog205LogFileTests, expectedCorrelatedTraceCount, expectedCorrelatedSpanCount, packageVersion, disableLogCorrelation: true); } else { - ValidateLogCorrelation(spans, _nlogPre205LogFileTests, packageVersion, disableLogCorrelation: true); + ValidateLogCorrelation(spans, _nlogPre205LogFileTests, expectedCorrelatedTraceCount, expectedCorrelatedSpanCount, packageVersion, disableLogCorrelation: true); } #else // Regardless of package version, for .NET Core just assert against raw log lines - ValidateLogCorrelation(spans, _nlogPre205LogFileTests, packageVersion, disableLogCorrelation: true); + ValidateLogCorrelation(spans, _nlogPre205LogFileTests, expectedCorrelatedTraceCount, expectedCorrelatedSpanCount, packageVersion, disableLogCorrelation: true); #endif } } diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/LogsInjectionTestBase.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/LogsInjectionTestBase.cs index ea83f81e2..8aa16afb0 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/LogsInjectionTestBase.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/LogsInjectionTestBase.cs @@ -97,6 +97,8 @@ public string[] GetLogFileContents(string logFile) public void ValidateLogCorrelation( IReadOnlyCollection spans, IEnumerable logFileTestCases, + int expectedCorrelatedTraceCount, + int expectedCorrelatedSpanCount, string packageVersion = "", bool disableLogCorrelation = false, Func additionalInjectedLogFilter = null) @@ -152,6 +154,8 @@ public void ValidateLogCorrelation( var traceIdRegex = string.Format(test.RegexFormat, traceIdProperty, @"("")?([0-9a-f]{2,})(?(1)\1|)"); // Match a string of hexadecimal or decimal signs or string of hexadecimal or decimal signs surrounded by double quotes. See https://stackoverflow.com/a/3569031 var spanIdRegex = string.Format(test.RegexFormat, spanIdProperty, @"("")?(\d\d+)(?(1)\1|)"); // Match a string of digits or string of digits surrounded by double quotes. See https://stackoverflow.com/a/3569031 + HashSet traceIdSet = new(); + HashSet spanIdSet = new(); foreach (var log in tracedLogs) { switch (test.TracedLogTypes) @@ -163,6 +167,12 @@ public void ValidateLogCorrelation( .And.MatchRegex(serviceRegex) .And.MatchRegex(traceIdRegex) .And.MatchRegex(spanIdRegex); + + var logTraceId = Regex.Match(log, traceIdRegex).Groups[2].Value; + traceIdSet.Add(logTraceId); + + var logSpanId = Regex.Match(log, spanIdRegex).Groups[2].Value; + spanIdSet.Add(logSpanId); break; case TracedLogTypes.NotCorrelated: log.Should() @@ -177,6 +187,9 @@ public void ValidateLogCorrelation( } } + traceIdSet.Should().HaveCount(expectedCorrelatedTraceCount); + spanIdSet.Should().HaveCount(expectedCorrelatedSpanCount); + // If logs are correlated, expect all SpanIDs in the traced logs to be represented in span list if (test.TracedLogTypes == TracedLogTypes.Correlated) { diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/MongoDbTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/MongoDbTests.cs index b21432cae..d739f1964 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/MongoDbTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/MongoDbTests.cs @@ -43,8 +43,7 @@ public void SubmitsTraces(string packageVersion, bool tagCommands) { SetEnvironmentVariable("SIGNALFX_INSTRUMENTATION_MONGODB_TAG_COMMANDS", tagCommands.ToString().ToLowerInvariant()); - int agentPort = TcpPortProvider.GetOpenPort(); - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion)) { var manualNames = new HashSet() { "sync-calls", "sync-calls-execute", "async-calls", "async-calls-execute" }; diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/MsmqTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/MsmqTests.cs index eb0fa46fd..732b70a72 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/MsmqTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/MsmqTests.cs @@ -45,8 +45,7 @@ public void SubmitTraces() var transactionalTraces = 0; var nonTransactionalTraces = 0; - var agentPort = TcpPortProvider.GetOpenPort(); - using var agent = new MockTracerAgent(agentPort); + using var agent = EnvironmentHelper.GetMockAgent(); using var processResult = RunSampleAndWaitForExit(agent.Port, arguments: $"5 5"); var spans = agent.WaitForSpans(totalTransactions); diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/MultiDomainHostTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/MultiDomainHostTests.cs index 03e539ecd..fe23b17ae 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/MultiDomainHostTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/MultiDomainHostTests.cs @@ -96,13 +96,10 @@ public void DoesNotCrashInBadConfiguration(string targetFramework) // Set bad configuration SetEnvironmentVariable("SIGNALFX_DOTNET_TRACER_HOME", Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); - int agentPort = TcpPortProvider.GetOpenPort(); int httpPort = TcpPortProvider.GetOpenPort(); - - Output.WriteLine($"Assigning port {agentPort} for the agentPort."); Output.WriteLine($"Assigning port {httpPort} for the httpPort."); - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (RunSampleAndWaitForExit(agent.Port, framework: targetFramework)) { } @@ -115,10 +112,7 @@ private void RunSampleAndAssertAgainstExpectations(string targetFramework, Dicti var actualMap = new Dictionary(); - int agentPort = TcpPortProvider.GetOpenPort(); - Output.WriteLine($"Assigning port {agentPort} for the agentPort."); - - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (RunSampleAndWaitForExit(agent.Port, framework: targetFramework)) { var spans = agent.WaitForSpans(expectedSpanCount); diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/NLogTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/NLogTests.cs index 7e038109b..aa25a9c39 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/NLogTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/NLogTests.cs @@ -14,34 +14,14 @@ namespace Datadog.Trace.ClrProfiler.IntegrationTests { public class NLogTests : LogsInjectionTestBase { - private readonly LogFileTest[] _nlogPre40LogFileTests = - { - new LogFileTest() - { - FileName = "log-textFile.log", - RegexFormat = @"{0}: {1}", - UnTracedLogTypes = UnTracedLogTypes.EmptyProperties, - PropertiesUseSerilogNaming = false - } - }; - - private readonly LogFileTest[] _nlog40LogFileTests = - { - new LogFileTest() - { - FileName = "log-textFile.log", - RegexFormat = @"{0}: {1}", - UnTracedLogTypes = UnTracedLogTypes.EmptyProperties, - PropertiesUseSerilogNaming = false - }, - new LogFileTest() - { - FileName = "log-jsonFile.log", - RegexFormat = @"""{0}"": {1}", - UnTracedLogTypes = UnTracedLogTypes.None, - PropertiesUseSerilogNaming = false - } - }; + private readonly LogFileTest _textFile = new() + { + FileName = "log-textFile.log", + RegexFormat = @"{0}: {1}", + // txt format can't conditionally add properties + UnTracedLogTypes = UnTracedLogTypes.EmptyProperties, + PropertiesUseSerilogNaming = false + }; public NLogTests(ITestOutputHelper output) : base(output, "LogsInjection.NLog") @@ -57,21 +37,17 @@ public void InjectsLogsWhenEnabled(string packageVersion) { SetEnvironmentVariable("SIGNALFX_LOGS_INJECTION", "true"); - int agentPort = TcpPortProvider.GetOpenPort(); - using (var agent = new MockTracerAgent(agentPort)) + var expectedCorrelatedTraceCount = 1; + var expectedCorrelatedSpanCount = 1; + + using (var agent = EnvironmentHelper.GetMockAgent()) using (RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion)) { var spans = agent.WaitForSpans(1, 2500); Assert.True(spans.Count >= 1, $"Expecting at least 1 span, only received {spans.Count}"); - if (string.IsNullOrWhiteSpace(packageVersion) || new Version(packageVersion) >= new Version("4.0.0")) - { - ValidateLogCorrelation(spans, _nlog40LogFileTests, packageVersion); - } - else - { - ValidateLogCorrelation(spans, _nlogPre40LogFileTests, packageVersion); - } + var testFiles = GetTestFiles(packageVersion); + ValidateLogCorrelation(spans, testFiles, expectedCorrelatedTraceCount, expectedCorrelatedSpanCount, packageVersion); } } @@ -83,22 +59,55 @@ public void DoesNotInjectLogsWhenDisabled(string packageVersion) { SetEnvironmentVariable("SIGNALFX_LOGS_INJECTION", "false"); - int agentPort = TcpPortProvider.GetOpenPort(); - using (var agent = new MockTracerAgent(agentPort)) + var expectedCorrelatedTraceCount = 0; + var expectedCorrelatedSpanCount = 0; + + using (var agent = EnvironmentHelper.GetMockAgent()) using (RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion)) { var spans = agent.WaitForSpans(1, 2500); Assert.True(spans.Count >= 1, $"Expecting at least 1 span, only received {spans.Count}"); - if (string.IsNullOrWhiteSpace(packageVersion) || new Version(packageVersion) >= new Version("4.0.0")) - { - ValidateLogCorrelation(spans, _nlog40LogFileTests, packageVersion, disableLogCorrelation: true); - } - else - { - ValidateLogCorrelation(spans, _nlogPre40LogFileTests, packageVersion, disableLogCorrelation: true); - } + var testFiles = GetTestFiles(packageVersion, logsInjectionEnabled: false); + ValidateLogCorrelation(spans, testFiles, expectedCorrelatedTraceCount, expectedCorrelatedSpanCount, packageVersion, disableLogCorrelation: true); + } + } + + private LogFileTest[] GetTestFiles(string packageVersion, bool logsInjectionEnabled = true) + { + if (packageVersion is null or "") + { +#if NETFRAMEWORK + packageVersion = "1.0.0.505"; +#else + packageVersion = "4.5.0"; +#endif + } + + var version = new Version(packageVersion); + if (version < new Version("4.0.0")) + { + // pre 4.0 can't write to json file + return new[] { _textFile }; } + + var unTracedLogType = logsInjectionEnabled switch + { + // When logs injection is enabled, untraced logs get env, service etc + true => UnTracedLogTypes.EnvServiceTracingPropertiesOnly, + // When logs injection is enabled, no enrichment + false => UnTracedLogTypes.None, + }; + + return new[] { _textFile, GetJsonTestFile(unTracedLogType) }; } + + private LogFileTest GetJsonTestFile(UnTracedLogTypes unTracedLogType) => new() + { + FileName = "log-jsonFile.log", + RegexFormat = @"""{0}"": {1}", + UnTracedLogTypes = unTracedLogType, + PropertiesUseSerilogNaming = false + }; } } diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/NativeProfilerChecks.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/NativeProfilerChecks.cs index 14a9bd723..a9e2b6a16 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/NativeProfilerChecks.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/NativeProfilerChecks.cs @@ -22,10 +22,9 @@ public NativeProfilerChecks(ITestOutputHelper output) public void RunChecksProject() { SetEnvironmentVariable("SIGNALFX_TRACE_DEBUG", "1"); - int agentPort = TcpPortProvider.GetOpenPort(); - using (var agent = new MockTracerAgent(agentPort)) - using (var processResult = RunSampleAndWaitForExit(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) + using (var processResult = RunSampleAndWaitForExit(agent.Port)) { Assert.True(processResult.ExitCode == 0, $"Process exited with code {processResult.ExitCode}"); } diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/PackageVersionsLatestMajors.g.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/PackageVersionsLatestMajors.g.cs index 75de32e3a..363d1c689 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/PackageVersionsLatestMajors.g.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/PackageVersionsLatestMajors.g.cs @@ -27,22 +27,22 @@ public class PackageVersionsLatestMajors new object[] { string.Empty }, #else #if NET461 - new object[] { "3.7.2" }, + new object[] { "3.7.2.2" }, #endif #if NETCOREAPP2_1 - new object[] { "3.7.2" }, + new object[] { "3.7.2.2" }, #endif #if NETCOREAPP3_0 - new object[] { "3.7.2" }, + new object[] { "3.7.2.2" }, #endif #if NETCOREAPP3_1 - new object[] { "3.7.2" }, + new object[] { "3.7.2.2" }, #endif #if NET5_0 - new object[] { "3.7.2" }, + new object[] { "3.7.2.2" }, #endif #if NET6_0 - new object[] { "3.7.2" }, + new object[] { "3.7.2.2" }, #endif #endif }; @@ -55,22 +55,22 @@ public class PackageVersionsLatestMajors new object[] { string.Empty }, #else #if NET461 - new object[] { "2.14.0" }, + new object[] { "2.14.1" }, #endif #if NETCOREAPP2_1 - new object[] { "2.14.0" }, + new object[] { "2.14.1" }, #endif #if NETCOREAPP3_0 - new object[] { "2.14.0" }, + new object[] { "2.14.1" }, #endif #if NETCOREAPP3_1 - new object[] { "2.14.0" }, + new object[] { "2.14.1" }, #endif #if NET5_0 - new object[] { "2.14.0" }, + new object[] { "2.14.1" }, #endif #if NET6_0 - new object[] { "2.14.0" }, + new object[] { "2.14.1" }, #endif #endif }; @@ -169,7 +169,7 @@ public class PackageVersionsLatestMajors #if NET461 new object[] { "4.1.10" }, new object[] { "5.0.11" }, - new object[] { "6.0.0" }, + new object[] { "6.0.1" }, #endif #if NETCOREAPP2_1 new object[] { "4.1.10" }, @@ -182,17 +182,17 @@ public class PackageVersionsLatestMajors #if NETCOREAPP3_1 new object[] { "4.1.10" }, new object[] { "5.0.11" }, - new object[] { "6.0.0" }, + new object[] { "6.0.1" }, #endif #if NET5_0 new object[] { "4.1.10" }, new object[] { "5.0.11" }, - new object[] { "6.0.0" }, + new object[] { "6.0.1" }, #endif #if NET6_0 new object[] { "4.1.10" }, new object[] { "5.0.11" }, - new object[] { "6.0.0" }, + new object[] { "6.0.1" }, #endif #endif }; @@ -417,27 +417,27 @@ public class PackageVersionsLatestMajors #else #if NET461 new object[] { "1.3.14" }, - new object[] { "2.0.0" }, + new object[] { "2.1.0" }, #endif #if NETCOREAPP2_1 new object[] { "1.3.14" }, - new object[] { "2.0.0" }, + new object[] { "2.1.0" }, #endif #if NETCOREAPP3_0 new object[] { "1.3.14" }, - new object[] { "2.0.0" }, + new object[] { "2.1.0" }, #endif #if NETCOREAPP3_1 new object[] { "1.3.14" }, - new object[] { "2.0.0" }, + new object[] { "2.1.0" }, #endif #if NET5_0 new object[] { "1.3.14" }, - new object[] { "2.0.0" }, + new object[] { "2.1.0" }, #endif #if NET6_0 new object[] { "1.3.14" }, - new object[] { "2.0.0" }, + new object[] { "2.1.0" }, #endif #endif }; @@ -552,22 +552,22 @@ public class PackageVersionsLatestMajors new object[] { string.Empty }, #else #if NET461 - new object[] { "2.2.7" }, + new object[] { "2.2.8" }, #endif #if NETCOREAPP2_1 - new object[] { "2.2.7" }, + new object[] { "2.2.8" }, #endif #if NETCOREAPP3_0 - new object[] { "2.2.7" }, + new object[] { "2.2.8" }, #endif #if NETCOREAPP3_1 - new object[] { "2.2.7" }, + new object[] { "2.2.8" }, #endif #if NET5_0 - new object[] { "2.2.7" }, + new object[] { "2.2.8" }, #endif #if NET6_0 - new object[] { "2.2.7" }, + new object[] { "2.2.8" }, #endif #endif }; diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/PackageVersionsLatestMinors.g.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/PackageVersionsLatestMinors.g.cs index c60e3dd93..b8b66ff73 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/PackageVersionsLatestMinors.g.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/PackageVersionsLatestMinors.g.cs @@ -30,32 +30,32 @@ public class PackageVersionsLatestMinors new object[] { "3.1.0.13" }, new object[] { "3.3.103.26" }, new object[] { "3.5.1.28" }, - new object[] { "3.7.2" }, + new object[] { "3.7.2.2" }, #endif #if NETCOREAPP2_1 new object[] { "3.3.103.26" }, new object[] { "3.5.1.28" }, - new object[] { "3.7.2" }, + new object[] { "3.7.2.2" }, #endif #if NETCOREAPP3_0 new object[] { "3.3.103.26" }, new object[] { "3.5.1.28" }, - new object[] { "3.7.2" }, + new object[] { "3.7.2.2" }, #endif #if NETCOREAPP3_1 new object[] { "3.3.103.26" }, new object[] { "3.5.1.28" }, - new object[] { "3.7.2" }, + new object[] { "3.7.2.2" }, #endif #if NET5_0 new object[] { "3.3.103.26" }, new object[] { "3.5.1.28" }, - new object[] { "3.7.2" }, + new object[] { "3.7.2.2" }, #endif #if NET6_0 new object[] { "3.3.103.26" }, new object[] { "3.5.1.28" }, - new object[] { "3.7.2" }, + new object[] { "3.7.2.2" }, #endif #endif }; @@ -82,7 +82,7 @@ public class PackageVersionsLatestMinors new object[] { "2.11.6" }, new object[] { "2.12.5" }, new object[] { "2.13.3" }, - new object[] { "2.14.0" }, + new object[] { "2.14.1" }, #endif #if NETCOREAPP2_1 new object[] { "2.3.0" }, @@ -96,7 +96,7 @@ public class PackageVersionsLatestMinors new object[] { "2.11.6" }, new object[] { "2.12.5" }, new object[] { "2.13.3" }, - new object[] { "2.14.0" }, + new object[] { "2.14.1" }, #endif #if NETCOREAPP3_0 new object[] { "2.3.0" }, @@ -110,7 +110,7 @@ public class PackageVersionsLatestMinors new object[] { "2.11.6" }, new object[] { "2.12.5" }, new object[] { "2.13.3" }, - new object[] { "2.14.0" }, + new object[] { "2.14.1" }, #endif #if NETCOREAPP3_1 new object[] { "2.3.0" }, @@ -124,7 +124,7 @@ public class PackageVersionsLatestMinors new object[] { "2.11.6" }, new object[] { "2.12.5" }, new object[] { "2.13.3" }, - new object[] { "2.14.0" }, + new object[] { "2.14.1" }, #endif #if NET5_0 new object[] { "2.3.0" }, @@ -138,7 +138,7 @@ public class PackageVersionsLatestMinors new object[] { "2.11.6" }, new object[] { "2.12.5" }, new object[] { "2.13.3" }, - new object[] { "2.14.0" }, + new object[] { "2.14.1" }, #endif #if NET6_0 new object[] { "2.3.0" }, @@ -152,7 +152,7 @@ public class PackageVersionsLatestMinors new object[] { "2.11.6" }, new object[] { "2.12.5" }, new object[] { "2.13.3" }, - new object[] { "2.14.0" }, + new object[] { "2.14.1" }, #endif #endif }; @@ -408,7 +408,7 @@ public class PackageVersionsLatestMinors new object[] { "4.0.12" }, new object[] { "4.1.10" }, new object[] { "5.0.11" }, - new object[] { "6.0.0" }, + new object[] { "6.0.1" }, #endif #if NETCOREAPP2_1 new object[] { "4.0.12" }, @@ -424,19 +424,19 @@ public class PackageVersionsLatestMinors new object[] { "4.0.12" }, new object[] { "4.1.10" }, new object[] { "5.0.11" }, - new object[] { "6.0.0" }, + new object[] { "6.0.1" }, #endif #if NET5_0 new object[] { "4.0.12" }, new object[] { "4.1.10" }, new object[] { "5.0.11" }, - new object[] { "6.0.0" }, + new object[] { "6.0.1" }, #endif #if NET6_0 new object[] { "4.0.12" }, new object[] { "4.1.10" }, new object[] { "5.0.11" }, - new object[] { "6.0.0" }, + new object[] { "6.0.1" }, #endif #endif }; @@ -841,6 +841,7 @@ public class PackageVersionsLatestMinors new object[] { "1.2.1" }, new object[] { "1.3.14" }, new object[] { "2.0.0" }, + new object[] { "2.1.0" }, #endif #if NETCOREAPP2_1 new object[] { "1.0.1" }, @@ -848,6 +849,7 @@ public class PackageVersionsLatestMinors new object[] { "1.2.1" }, new object[] { "1.3.14" }, new object[] { "2.0.0" }, + new object[] { "2.1.0" }, #endif #if NETCOREAPP3_0 new object[] { "1.0.1" }, @@ -855,6 +857,7 @@ public class PackageVersionsLatestMinors new object[] { "1.2.1" }, new object[] { "1.3.14" }, new object[] { "2.0.0" }, + new object[] { "2.1.0" }, #endif #if NETCOREAPP3_1 new object[] { "1.0.1" }, @@ -862,6 +865,7 @@ public class PackageVersionsLatestMinors new object[] { "1.2.1" }, new object[] { "1.3.14" }, new object[] { "2.0.0" }, + new object[] { "2.1.0" }, #endif #if NET5_0 new object[] { "1.0.1" }, @@ -869,6 +873,7 @@ public class PackageVersionsLatestMinors new object[] { "1.2.1" }, new object[] { "1.3.14" }, new object[] { "2.0.0" }, + new object[] { "2.1.0" }, #endif #if NET6_0 new object[] { "1.0.1" }, @@ -876,6 +881,7 @@ public class PackageVersionsLatestMinors new object[] { "1.2.1" }, new object[] { "1.3.14" }, new object[] { "2.0.0" }, + new object[] { "2.1.0" }, #endif #endif }; @@ -1064,32 +1070,32 @@ public class PackageVersionsLatestMinors #if NET461 new object[] { "2.0.0" }, new object[] { "2.1.2" }, - new object[] { "2.2.7" }, + new object[] { "2.2.8" }, #endif #if NETCOREAPP2_1 new object[] { "2.0.0" }, new object[] { "2.1.2" }, - new object[] { "2.2.7" }, + new object[] { "2.2.8" }, #endif #if NETCOREAPP3_0 new object[] { "2.0.0" }, new object[] { "2.1.2" }, - new object[] { "2.2.7" }, + new object[] { "2.2.8" }, #endif #if NETCOREAPP3_1 new object[] { "2.0.0" }, new object[] { "2.1.2" }, - new object[] { "2.2.7" }, + new object[] { "2.2.8" }, #endif #if NET5_0 new object[] { "2.0.0" }, new object[] { "2.1.2" }, - new object[] { "2.2.7" }, + new object[] { "2.2.8" }, #endif #if NET6_0 new object[] { "2.0.0" }, new object[] { "2.1.2" }, - new object[] { "2.2.7" }, + new object[] { "2.2.8" }, #endif #endif }; diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/RabbitMQTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/RabbitMQTests.cs index 4aa9b36b2..3c410b7a3 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/RabbitMQTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/RabbitMQTests.cs @@ -52,8 +52,7 @@ public void SubmitsTraces(string packageVersion) int emptyBasicGetCount = 0; - int agentPort = TcpPortProvider.GetOpenPort(); - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (RunSampleAndWaitForExit(agent.Port, arguments: $"{TestPrefix}", packageVersion: packageVersion)) { var spans = agent.WaitForSpans(expectedSpanCount); // Do not filter on operation name because they will vary depending on instrumented method diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/RuntimeMetricsTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/RuntimeMetricsTests.cs index 11dca15f6..79da13506 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/RuntimeMetricsTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/RuntimeMetricsTests.cs @@ -62,14 +62,8 @@ public void SubmitsMetrics() [Trait("RunOnWindows", "True")] public void MetricsDisabled() { - int agentPort = TcpPortProvider.GetOpenPort(); - - Output.WriteLine($"Assigning port {agentPort} for the agentPort."); - SetEnvironmentVariable("SIGNALFX_RUNTIME_METRICS_ENABLED", "0"); - - using var agent = new MockTracerAgent(agentPort, useStatsd: true); - Output.WriteLine($"Assigning port {agent.StatsdPort} for the statsdPort."); + using var agent = EnvironmentHelper.GetMockAgent(useStatsD: true); using var processResult = RunSampleAndWaitForExit(agent.Port, agent.StatsdPort); var requests = agent.StatsdRequests; diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/SerilogTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/SerilogTests.cs index a6b4c3cfa..e5d75da43 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/SerilogTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/SerilogTests.cs @@ -16,35 +16,14 @@ namespace Datadog.Trace.ClrProfiler.IntegrationTests { public class SerilogTests : LogsInjectionTestBase { - private readonly LogFileTest[] _log200FileTests = - { - new LogFileTest() - { - FileName = "log-textFile.log", - RegexFormat = @"{0}: {1}", - UnTracedLogTypes = UnTracedLogTypes.EmptyProperties, - PropertiesUseSerilogNaming = true - }, - new LogFileTest() - { - FileName = "log-jsonFile.log", - RegexFormat = @"""{0}"":{1}", - UnTracedLogTypes = UnTracedLogTypes.None, - PropertiesUseSerilogNaming = true - } - }; - - private readonly LogFileTest[] _logPre200FileTests = - { + private readonly LogFileTest _txtFile = new LogFileTest() { FileName = "log-textFile.log", RegexFormat = @"{0}: {1}", - TracedLogTypes = TracedLogTypes.NotCorrelated, UnTracedLogTypes = UnTracedLogTypes.EmptyProperties, PropertiesUseSerilogNaming = true - } - }; + }; public SerilogTests(ITestOutputHelper output) : base(output, "LogsInjection.Serilog") @@ -60,22 +39,17 @@ public void InjectsLogsWhenEnabled(string packageVersion) { SetEnvironmentVariable("SIGNALFX_LOGS_INJECTION", "true"); - int agentPort = TcpPortProvider.GetOpenPort(); - using (var agent = new MockTracerAgent(agentPort)) + var expectedCorrelatedTraceCount = 1; + var expectedCorrelatedSpanCount = 1; + + using (var agent = EnvironmentHelper.GetMockAgent()) using (RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion)) { var spans = agent.WaitForSpans(1, 2500); Assert.True(spans.Count >= 1, $"Expecting at least 1 span, only received {spans.Count}"); - if (PackageSupportsLogsInjection(packageVersion)) - { - ValidateLogCorrelation(spans, _log200FileTests, packageVersion); - } - else - { - // We do not expect logs injection for Serilog versions < 2.0.0 so filter out all logs - ValidateLogCorrelation(spans, _logPre200FileTests, packageVersion); - } + var logFiles = GetLogFiles(packageVersion, logsInjectionEnabled: true); + ValidateLogCorrelation(spans, logFiles, expectedCorrelatedTraceCount, expectedCorrelatedSpanCount, packageVersion); } } @@ -87,32 +61,48 @@ public void DoesNotInjectLogsWhenDisabled(string packageVersion) { SetEnvironmentVariable("SIGNALFX_LOGS_INJECTION", "false"); - int agentPort = TcpPortProvider.GetOpenPort(); - using (var agent = new MockTracerAgent(agentPort)) + var expectedCorrelatedTraceCount = 0; + var expectedCorrelatedSpanCount = 0; + + using (var agent = EnvironmentHelper.GetMockAgent()) using (RunSampleAndWaitForExit(agent.Port, packageVersion: packageVersion)) { var spans = agent.WaitForSpans(1, 2500); Assert.True(spans.Count >= 1, $"Expecting at least 1 span, only received {spans.Count}"); - if (PackageSupportsLogsInjection(packageVersion)) - { - ValidateLogCorrelation(spans, _log200FileTests, packageVersion, disableLogCorrelation: true); - } - else - { - // We do not expect logs injection for Serilog versions < 2.0.0 so filter out all logs - ValidateLogCorrelation(spans, _logPre200FileTests, packageVersion, disableLogCorrelation: true); - } + var logFiles = GetLogFiles(packageVersion, logsInjectionEnabled: false); + ValidateLogCorrelation(spans, logFiles, expectedCorrelatedTraceCount, expectedCorrelatedSpanCount, packageVersion, disableLogCorrelation: true); } } - private static bool PackageSupportsLogsInjection(string packageVersion) + private LogFileTest[] GetLogFiles(string packageVersion, bool logsInjectionEnabled) + { + var isPost200 = #if NETCOREAPP - // enabled in default version for .NET Core - => string.IsNullOrWhiteSpace(packageVersion) || new Version(packageVersion) >= new Version("2.0.0"); + // enabled in default version for .NET Core + string.IsNullOrWhiteSpace(packageVersion) || new Version(packageVersion) >= new Version("2.0.0"); #else - // disabled dor default version in .NET Framework - => !string.IsNullOrWhiteSpace(packageVersion) && new Version(packageVersion) >= new Version("2.0.0"); + !string.IsNullOrWhiteSpace(packageVersion) && new Version(packageVersion) >= new Version("2.0.0"); #endif + if (!isPost200) + { + // no json file, always the same format + return new[] { _txtFile }; + } + + var unTracedLogFormat = logsInjectionEnabled + ? UnTracedLogTypes.EnvServiceTracingPropertiesOnly + : UnTracedLogTypes.None; + + var jsonFile = new LogFileTest() + { + FileName = "log-jsonFile.log", + RegexFormat = @"""{0}"":{1}", + UnTracedLogTypes = unTracedLogFormat, + PropertiesUseSerilogNaming = true + }; + + return new[] { _txtFile, jsonFile }; + } } } diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/ServiceMappingTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/ServiceMappingTests.cs index bf7f15e47..4392b4476 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/ServiceMappingTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/ServiceMappingTests.cs @@ -32,14 +32,10 @@ public void RenamesService() const string expectedOperationName = "http.request"; const string expectedServiceName = "my-custom-client"; - int agentPort = TcpPortProvider.GetOpenPort(); int httpPort = TcpPortProvider.GetOpenPort(); - var extraArgs = string.Empty; - - Output.WriteLine($"Assigning port {agentPort} for the agentPort."); Output.WriteLine($"Assigning port {httpPort} for the httpPort."); - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (RunSampleAndWaitForExit(agent.Port, arguments: $"Port={httpPort}")) { var spans = agent.WaitForSpans(expectedSpanCount, operationName: expectedOperationName); diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/ServiceStackRedisTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/ServiceStackRedisTests.cs index fc132ef0c..7ceac33d1 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/ServiceStackRedisTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/ServiceStackRedisTests.cs @@ -28,9 +28,7 @@ public ServiceStackRedisTests(ITestOutputHelper output) [Trait("Category", "EndToEnd")] public void SubmitsTraces(string packageVersion) { - int agentPort = TcpPortProvider.GetOpenPort(); - - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (RunSampleAndWaitForExit(agent.Port, arguments: $"{TestPrefix}", packageVersion: packageVersion)) { // note: ignore the INFO command because it's timing is unpredictable (on Linux?) diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/SmokeTests/SmokeTestBase.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/SmokeTests/SmokeTestBase.cs index 3872d13ae..57e06452c 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/SmokeTests/SmokeTestBase.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/SmokeTests/SmokeTestBase.cs @@ -61,14 +61,12 @@ protected void CheckForSmoke(bool shouldDeserializeTraces = true) // clear all relevant environment variables to start with a clean slate EnvironmentHelper.ClearProfilerEnvironmentVariables(); - int agentPort = TcpPortProvider.GetOpenPort(); int aspNetCorePort = TcpPortProvider.GetOpenPort(); // unused for now - Output.WriteLine($"Assigning port {agentPort} for the agentPort."); Output.WriteLine($"Assigning port {aspNetCorePort} for the aspNetCorePort."); ProcessResult result; - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) { agent.ShouldDeserializeTraces = shouldDeserializeTraces; @@ -77,7 +75,7 @@ protected void CheckForSmoke(bool shouldDeserializeTraces = true) { // Initialize StartInfo process.StartInfo.FileName = executable; - EnvironmentHelper.SetEnvironmentVariables(agentPort, aspNetCorePort, statsdPort: null, process.StartInfo.EnvironmentVariables, processToProfile: executable); + EnvironmentHelper.SetEnvironmentVariables(agent.Port, aspNetCorePort, statsdPort: null, process.StartInfo.EnvironmentVariables, processToProfile: executable); if (EnvironmentHelper.IsCoreClr()) { // Command becomes: dotnet.exe diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/SmokeTests/TraceContextSmokeTest.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/SmokeTests/TraceContextSmokeTest.cs deleted file mode 100644 index 46ba3d7a6..000000000 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/SmokeTests/TraceContextSmokeTest.cs +++ /dev/null @@ -1,32 +0,0 @@ -// -// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. -// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. -// - -using Datadog.Trace.TestHelpers; -using Xunit; -using Xunit.Abstractions; - -namespace Datadog.Trace.ClrProfiler.IntegrationTests.SmokeTests -{ - public class TraceContextSmokeTest : SmokeTestBase - { - public TraceContextSmokeTest(ITestOutputHelper output) - : base(output, "TraceContext.InvalidOperationException", maxTestRunSeconds: 120 * 10) - { - } - - [Fact(Skip ="Skipping until this test is refactored into a different assembly. The load may be interrupting the rest of the test suite.")] - [Trait("Category", "Smoke")] - public void NoExceptions() - { - if (!EnvironmentHelper.IsCoreClr()) - { - Output.WriteLine("Ignored for .NET Framework"); - return; - } - - CheckForSmoke(shouldDeserializeTraces: false); - } - } -} diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/StackExchangeRedisTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/StackExchangeRedisTests.cs index cc8990343..2f1c32dc0 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/StackExchangeRedisTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/StackExchangeRedisTests.cs @@ -30,9 +30,7 @@ public StackExchangeRedisTests(ITestOutputHelper output) [Trait("Category", "EndToEnd")] public void SubmitsTraces(string packageVersion) { - int agentPort = TcpPortProvider.GetOpenPort(); - - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (RunSampleAndWaitForExit(agent.Port, arguments: $"{TestPrefix}", packageVersion: packageVersion)) { var expected = new TupleList diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/AspNetVersionConflictTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/AspNetVersionConflictTests.cs new file mode 100644 index 000000000..bf00c8434 --- /dev/null +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/AspNetVersionConflictTests.cs @@ -0,0 +1,247 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +#if NETFRAMEWORK + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; +using System.Threading.Tasks; +using Datadog.Trace.TestHelpers; +using FluentAssertions; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using Xunit; +using Xunit.Abstractions; + +namespace Datadog.Trace.ClrProfiler.IntegrationTests.VersionConflict +{ + [Collection("IisTests")] + public class AspNetVersionConflictTests : TestHelper, IClassFixture + { + private readonly IisFixture _iisFixture; + + public AspNetVersionConflictTests(IisFixture iisFixture, ITestOutputHelper output) + : base("AspNet.VersionConflict", @"test\test-applications\aspnet", output) + { + SetServiceVersion("1.0.0"); + + _iisFixture = iisFixture; + _iisFixture.ShutdownPath = "/home/shutdown"; + // There is an issue in the TracingHttpModule that causes the parent trace to be locked, making the test useless + // This code is not run when IIS is in classic mode, so using that as a workaround + _iisFixture.TryStartIis(this, IisAppType.AspNetClassic); + } + + [Fact(Skip = "VersionConflict tests are not ready to work without official next ver release")] + // [SkippableFact] + [Trait("Category", "EndToEnd")] + [Trait("RunOnWindows", "True")] + [Trait("LoadFromGAC", "True")] + public async Task SubmitsTraces() + { + // 4 spans for the base request: aspnet.request / aspnet-mvc.request / Manual / Manual-Inner / http.request + // + 2 spans for the outgoing request: aspnet.request / aspnet-mvc.request + const int expectedSpans = 8; + + var spans = await GetWebServerSpans("/home/sendrequest", _iisFixture.Agent, _iisFixture.HttpPort, System.Net.HttpStatusCode.OK, expectedSpans, filterServerSpans: false); + + foreach (var span in spans) + { + Output.WriteLine($"Name:{span.Name} - TraceId:{span.TraceId} - SpanID:{span.SpanId} - ParentId:{span.ParentId} - Resource:{span.Resource}"); + } + + spans.Should().HaveCount(expectedSpans); + + // Using Single to make sure there is no orphaned span + var rootSpan = spans.Single(s => s.ParentId == null); + + rootSpan.Name.Should().Be("aspnet.request"); + rootSpan.Tags.Should().ContainKey(Tags.RuntimeId); + + var runtimeId = rootSpan.Tags[Tags.RuntimeId]; + Guid.TryParse(runtimeId, out _).Should().BeTrue(); + + spans.Where(s => s.Name == "aspnet.request") + .Should() + .OnlyContain(s => s.Tags[Tags.RuntimeId] == runtimeId); + + var mvcSpan = spans.Single(s => s.ParentId == rootSpan.SpanId); + + mvcSpan.TraceId.Should().Be(rootSpan.TraceId); + mvcSpan.Name.Should().Be("aspnet-mvc.request"); + + var manualSpan = spans.Single(s => s.ParentId == mvcSpan.SpanId); + + manualSpan.TraceId.Should().Be(rootSpan.TraceId); + manualSpan.Name.Should().Be("Manual"); + + var manualInnerSpan = spans.Single(s => s.ParentId == manualSpan.SpanId); + + manualInnerSpan.TraceId.Should().Be(rootSpan.TraceId); + manualInnerSpan.Name.Should().Be("Manual-Inner"); + + var automaticOuterSpan = spans.Single(s => s.ParentId == manualInnerSpan.SpanId); + + automaticOuterSpan.TraceId.Should().Be(rootSpan.TraceId); + automaticOuterSpan.Name.Should().Be("Automatic-Outer"); + automaticOuterSpan.Tags[Tags.RuntimeId].Should().Be(runtimeId); + + var httpSpan = spans.Single(s => s.ParentId == automaticOuterSpan.SpanId); + + httpSpan.TraceId.Should().Be(rootSpan.TraceId); + httpSpan.Name.Should().Be("http.request"); + httpSpan.Tags[Tags.RuntimeId].Should().Be(runtimeId); + } + + [Theory(Skip = "VersionConflict tests are not ready to work without official next ver release")] + // [SkippableTheory] + [InlineData(true)] + [InlineData(false)] + [Trait("Category", "EndToEnd")] + [Trait("RunOnWindows", "True")] + [Trait("LoadFromGAC", "True")] + public async Task Sampling(bool parentTrace) + { + // 6 spans for the base request: aspnet.request / aspnet-mvc.request / Manual / http.request / http.request / Child + // + 2 * 2 spans for the outgoing requests: aspnet.request / aspnet-mvc.request + const int expectedSpans = 10; + + var spans = await GetWebServerSpans($"/home/sampling?parentTrace={parentTrace}", _iisFixture.Agent, _iisFixture.HttpPort, System.Net.HttpStatusCode.OK, expectedSpans, filterServerSpans: false); + + foreach (var span in spans) + { + var samplingPriority = string.Empty; + + if (span.Metrics.ContainsKey(Metrics.SamplingPriority)) + { + samplingPriority = span.Metrics[Metrics.SamplingPriority].ToString(); + } + + Output.WriteLine($"{span.Name} - {span.TraceId} - {span.SpanId} - {span.ParentId} - {span.Resource} - {samplingPriority}"); + } + + // Validate the correct hierarchy of spans + var rootSpan = spans.Single(s => s.ParentId == null && s.Name == "aspnet.request"); + var mvcSpan = spans.Single(s => s.ParentId == rootSpan.SpanId); + mvcSpan.TraceId.Should().Be(rootSpan.TraceId); + mvcSpan.Name.Should().Be("aspnet-mvc.request"); + + // The manual span will be in the same trace when parentTrace=true, + // or the start of a new trace when parentTrace=false + var manualSpan = spans.Single(s => s.Name == "Manual"); + var secondTraceId = parentTrace ? rootSpan.TraceId : manualSpan.TraceId; + + manualSpan.TraceId.Should().Be(secondTraceId); + manualSpan.Name.Should().Be("Manual"); + + var nestedSpans = spans.Where(s => s.ParentId == manualSpan.SpanId).OrderBy(s => s.Start).ToArray(); + nestedSpans.Should().HaveCount(3); + + // Validate the first http request and its subspans + var firstHttpSpan = nestedSpans[0]; + + firstHttpSpan.TraceId.Should().Be(secondTraceId); + firstHttpSpan.Name.Should().Be("http.request"); + + // Validate the second http request and its subspans + var secondHttpSpan = nestedSpans[1]; + + secondHttpSpan.TraceId.Should().Be(secondTraceId); + secondHttpSpan.Name.Should().Be("http.request"); + + var manualInnerSpan = nestedSpans[2]; + + manualInnerSpan.TraceId.Should().Be(secondTraceId); + manualInnerSpan.Name.Should().Be("Child"); + + // Make sure there is no extra root span + var rootTraces = spans.Where(s => s.ParentId == null).ToList(); + + rootTraces.Should().HaveCount(parentTrace ? 1 : 2); + + // One HttpClient span should be UserKeep, the other UserReject + var httpSpans = spans.Where(s => s.Name == "http.request"); + httpSpans.Should() + .HaveCount(2) + .And.ContainSingle(s => s.Metrics[Metrics.SamplingPriority] == (double)SamplingPriority.UserKeep) + .And.ContainSingle(s => s.Metrics[Metrics.SamplingPriority] == (double)SamplingPriority.UserReject); + + // Check that the sampling priority got propagated to the target service + var targetSpans = spans.Where(s => s.Name == "aspnet.request" && s.ParentId != null); + targetSpans.Should() + .HaveCount(2) + .And.ContainSingle(s => s.Metrics[Metrics.SamplingPriority] == (double)SamplingPriority.UserKeep) + .And.ContainSingle(s => s.Metrics[Metrics.SamplingPriority] == (double)SamplingPriority.UserReject); + + // The sampling priority for the root trace should be UserReject + // Depending on the parentTrace argument, the root trace is either the manual one or the automatic one + var rootTrace = parentTrace ? rootTraces.Single() : rootTraces.First(s => s.Name == "Manual"); + rootTrace.Metrics[Metrics.SamplingPriority].Should().Be((double)SamplingPriority.UserReject); + } + + [Fact(Skip = "VersionConflict tests are not ready to work without official next ver release")] + // [SkippableFact] + [Trait("Category", "EndToEnd")] + [Trait("RunOnWindows", "True")] + [Trait("LoadFromGAC", "True")] + + public async Task ParentScope() + { + // aspnet.request + aspnet-mvc.request + const int expectedSpans = 2; + + var testStart = DateTime.UtcNow; + using var client = new HttpClient(); + + var response = await client.GetAsync($"http://localhost:{_iisFixture.HttpPort}/home/parentScope"); + var content = await response.Content.ReadAsStringAsync(); + + response.StatusCode.Should().Be(System.Net.HttpStatusCode.OK, $"server returned an error: {content}"); + + var spans = _iisFixture.Agent.WaitForSpans(expectedSpans, minDateTime: testStart, returnAllOperations: true); + + spans.Should().HaveCount(expectedSpans); + + var mvcSpan = spans.Single(s => s.Name == "aspnet-mvc.request"); + + mvcSpan.Tags.Should().Contain(new KeyValuePair("Test", "OK")); + + var rootSpan = spans.Single(s => s.Name == "aspnet.request"); + + rootSpan.Metrics.Should().Contain(new KeyValuePair(Metrics.SamplingPriority, (double)SamplingPriority.UserKeep)); + + var result = JObject.Parse(content); + + result.Should().NotBeNull(); + + result["OperationName"].Value().Should().Be(mvcSpan.Name); + result["ResourceName"].Value().Should().Be(mvcSpan.Resource); + result["ServiceName"].Value().Should().Be(mvcSpan.Service); + } + + private static bool VerifySpan(MockTracerAgent.Span span, bool parentTrace) + { + if (!span.Metrics.ContainsKey(Metrics.SamplingPriority)) + { + return true; + } + + if (!parentTrace) + { + // The root asp.net trace has an automatic priority + if (span.Name == "aspnet.request" && span.Resource == "GET /home/sampling") + { + return span.Metrics[Metrics.SamplingPriority] == 1; + } + } + + return span.Metrics[Metrics.SamplingPriority] == 2; + } + } +} + +#endif diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/ILoggerVersionConflict2xTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/ILoggerVersionConflict2xTests.cs new file mode 100644 index 000000000..82fb9ad16 --- /dev/null +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/ILoggerVersionConflict2xTests.cs @@ -0,0 +1,66 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using Datadog.Trace.TestHelpers; +using FluentAssertions; +using Xunit; +using Xunit.Abstractions; + +namespace Datadog.Trace.ClrProfiler.IntegrationTests.VersionConflict +{ + // ReSharper disable once InconsistentNaming + public class ILoggerVersionConflict2xTests : LogsInjectionTestBase + { + private readonly LogFileTest[] _logFiles = + { + new LogFileTest + { + FileName = "simple.log", + RegexFormat = @"""{0}"":{1}", + UnTracedLogTypes = UnTracedLogTypes.EnvServiceTracingPropertiesOnly, + // Upstream uses Serilog format. Splunk's backend prefers keys with '.' in the name. + PropertiesUseSerilogNaming = false + }, + }; + + public ILoggerVersionConflict2xTests(ITestOutputHelper output) + : base(output, "LogsInjection.ILogger.VersionConflict.2x") + { + SetServiceVersion("1.0.0"); + SetEnvironmentVariable("SIGNALFX_LOGS_INJECTION", "true"); + } + + [Fact(Skip = "VersionConflict tests are not ready to work without official next ver release")] + // [SkippableFact] + [Trait("Category", "EndToEnd")] + [Trait("RunOnWindows", "True")] + public void InjectsLogs() + { + // One of the traces starts by manual opening a span when the background service starts, + // and then it sends a HTTP request to the server. + // On .NET Framework, we do not yet automatically instrument AspNetCore so instead of + // having one distributed trace, the result is two separate traces. So expect one more trace + // when running on .NET Framework + + // We also log inside of the web server handling, so in .NET Core expect one more log line +#if NETFRAMEWORK + var expectedCorrelatedTraceCount = 3; + var expectedCorrelatedSpanCount = 3; +#else + var expectedCorrelatedTraceCount = 2; + var expectedCorrelatedSpanCount = 4; +#endif + + using (var agent = EnvironmentHelper.GetMockAgent()) + using (RunSampleAndWaitForExit(agent.Port, aspNetCorePort: 0)) + { + var spans = agent.WaitForSpans(1, 2500); + spans.Should().HaveCountGreaterOrEqualTo(1); + + ValidateLogCorrelation(spans, _logFiles, expectedCorrelatedTraceCount, expectedCorrelatedSpanCount); + } + } + } +} diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/Log4NetVersionConflict2xTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/Log4NetVersionConflict2xTests.cs new file mode 100644 index 000000000..cccd3857e --- /dev/null +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/Log4NetVersionConflict2xTests.cs @@ -0,0 +1,62 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +#if !NETCOREAPP2_1 +using Datadog.Trace.TestHelpers; +using Xunit; +using Xunit.Abstractions; + +namespace Datadog.Trace.ClrProfiler.IntegrationTests.VersionConflict +{ + public class Log4NetVersionConflict2xTests : LogsInjectionTestBase + { + private readonly LogFileTest[] _nlog205LogFileTests = + { + new LogFileTest() + { + FileName = "log-textFile.log", + RegexFormat = @"{0}: {1}", + UnTracedLogTypes = UnTracedLogTypes.EmptyProperties, + PropertiesUseSerilogNaming = false + }, + new LogFileTest() + { + FileName = "log-jsonFile.log", + RegexFormat = @"""{0}"":{1}", + UnTracedLogTypes = UnTracedLogTypes.EnvServiceTracingPropertiesOnly, + PropertiesUseSerilogNaming = false + } + }; + + public Log4NetVersionConflict2xTests(ITestOutputHelper output) + : base(output, "LogsInjection.Log4Net.VersionConflict.2x") + { + SetServiceVersion("1.0.0"); + } + + [Fact(Skip = "VersionConflict tests are not ready to work without official next ver release")] + // [SkippableFact] + [Trait("Category", "EndToEnd")] + [Trait("RunOnWindows", "True")] + public void InjectsLogsWhenEnabled() + { + SetEnvironmentVariable("SIGNALFX_LOGS_INJECTION", "true"); + + var expectedCorrelatedTraceCount = 1; + var expectedCorrelatedSpanCount = 8; + + int agentPort = TcpPortProvider.GetOpenPort(); + using (var agent = new MockTracerAgent(agentPort)) + using (RunSampleAndWaitForExit(agent.Port)) + { + var spans = agent.WaitForSpans(1, 2500); + Assert.True(spans.Count >= 1, $"Expecting at least 1 span, only received {spans.Count}"); + + ValidateLogCorrelation(spans, _nlog205LogFileTests, expectedCorrelatedTraceCount, expectedCorrelatedSpanCount); + } + } + } +} +#endif diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/NLog10VersionConflict2xTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/NLog10VersionConflict2xTests.cs new file mode 100644 index 000000000..007969a59 --- /dev/null +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/NLog10VersionConflict2xTests.cs @@ -0,0 +1,55 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +#if NETFRAMEWORK +using Datadog.Trace.TestHelpers; +using Xunit; +using Xunit.Abstractions; + +namespace Datadog.Trace.ClrProfiler.IntegrationTests.VersionConflict +{ + public class NLog10VersionConflict2xTests : LogsInjectionTestBase + { + private readonly LogFileTest[] _nlogPre40LogFileTests = + { + new LogFileTest() + { + FileName = "log-textFile.log", + RegexFormat = @"{0}: {1}", + UnTracedLogTypes = UnTracedLogTypes.EmptyProperties, + PropertiesUseSerilogNaming = false + } + }; + + public NLog10VersionConflict2xTests(ITestOutputHelper output) + : base(output, "LogsInjection.NLog10.VersionConflict.2x") + { + SetServiceVersion("1.0.0"); + } + + [Fact(Skip = "VersionConflict tests are not ready to work without official next ver release")] + // [SkippableFact] + [Trait("Category", "EndToEnd")] + [Trait("RunOnWindows", "True")] + public void InjectsLogsWhenEnabled() + { + SetEnvironmentVariable("SIGNALFX_LOGS_INJECTION", "true"); + + var expectedCorrelatedTraceCount = 1; + var expectedCorrelatedSpanCount = 8; + + int agentPort = TcpPortProvider.GetOpenPort(); + using (var agent = new MockTracerAgent(agentPort)) + using (RunSampleAndWaitForExit(agent.Port)) + { + var spans = agent.WaitForSpans(1, 2500); + Assert.True(spans.Count >= 1, $"Expecting at least 1 span, only received {spans.Count}"); + + ValidateLogCorrelation(spans, _nlogPre40LogFileTests, expectedCorrelatedTraceCount, expectedCorrelatedSpanCount); + } + } + } +} +#endif diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/NLog20VersionConflict2xTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/NLog20VersionConflict2xTests.cs new file mode 100644 index 000000000..f7d791c2f --- /dev/null +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/NLog20VersionConflict2xTests.cs @@ -0,0 +1,55 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +#if NETFRAMEWORK +using Datadog.Trace.TestHelpers; +using Xunit; +using Xunit.Abstractions; + +namespace Datadog.Trace.ClrProfiler.IntegrationTests.VersionConflict +{ + public class NLog20VersionConflict2xTests : LogsInjectionTestBase + { + private readonly LogFileTest[] _nlogPre40LogFileTests = + { + new LogFileTest() + { + FileName = "log-textFile.log", + RegexFormat = @"{0}: {1}", + UnTracedLogTypes = UnTracedLogTypes.EmptyProperties, + PropertiesUseSerilogNaming = false + } + }; + + public NLog20VersionConflict2xTests(ITestOutputHelper output) + : base(output, "LogsInjection.NLog20.VersionConflict.2x") + { + SetServiceVersion("1.0.0"); + } + + [Fact(Skip = "VersionConflict tests are not ready to work without official next ver release")] + // [SkippableFact] + [Trait("Category", "EndToEnd")] + [Trait("RunOnWindows", "True")] + public void InjectsLogsWhenEnabled() + { + SetEnvironmentVariable("SIGNALFX_LOGS_INJECTION", "true"); + + var expectedCorrelatedTraceCount = 1; + var expectedCorrelatedSpanCount = 8; + + int agentPort = TcpPortProvider.GetOpenPort(); + using (var agent = new MockTracerAgent(agentPort)) + using (RunSampleAndWaitForExit(agent.Port)) + { + var spans = agent.WaitForSpans(1, 2500); + Assert.True(spans.Count >= 1, $"Expecting at least 1 span, only received {spans.Count}"); + + ValidateLogCorrelation(spans, _nlogPre40LogFileTests, expectedCorrelatedTraceCount, expectedCorrelatedSpanCount); + } + } + } +} +#endif diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/NLogVersionConflict2xTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/NLogVersionConflict2xTests.cs new file mode 100644 index 000000000..1094be85f --- /dev/null +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/NLogVersionConflict2xTests.cs @@ -0,0 +1,62 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +#if !NETCOREAPP2_1 +using Datadog.Trace.TestHelpers; +using Xunit; +using Xunit.Abstractions; + +namespace Datadog.Trace.ClrProfiler.IntegrationTests.VersionConflict +{ + public class NLogVersionConflict2xTests : LogsInjectionTestBase + { + private readonly LogFileTest[] _nlog40LogFileTests = + { + new LogFileTest() + { + FileName = "log-textFile.log", + RegexFormat = @"{0}: {1}", + UnTracedLogTypes = UnTracedLogTypes.EmptyProperties, + PropertiesUseSerilogNaming = false + }, + new LogFileTest() + { + FileName = "log-jsonFile.log", + RegexFormat = @"""{0}"": {1}", + UnTracedLogTypes = UnTracedLogTypes.EnvServiceTracingPropertiesOnly, + PropertiesUseSerilogNaming = false + } + }; + + public NLogVersionConflict2xTests(ITestOutputHelper output) + : base(output, "LogsInjection.NLog.VersionConflict.2x") + { + SetServiceVersion("1.0.0"); + } + + [Fact(Skip = "VersionConflict tests are not ready to work without official next ver release")] + // [SkippableFact] + [Trait("Category", "EndToEnd")] + [Trait("RunOnWindows", "True")] + public void InjectsLogsWhenEnabled() + { + SetEnvironmentVariable("SIGNALFX_LOGS_INJECTION", "true"); + + var expectedCorrelatedTraceCount = 1; + var expectedCorrelatedSpanCount = 8; + + int agentPort = TcpPortProvider.GetOpenPort(); + using (var agent = new MockTracerAgent(agentPort)) + using (RunSampleAndWaitForExit(agent.Port)) + { + var spans = agent.WaitForSpans(1, 2500); + Assert.True(spans.Count >= 1, $"Expecting at least 1 span, only received {spans.Count}"); + + ValidateLogCorrelation(spans, _nlog40LogFileTests, expectedCorrelatedTraceCount, expectedCorrelatedSpanCount); + } + } + } +} +#endif diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/Serilog14VersionConflict2xTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/Serilog14VersionConflict2xTests.cs new file mode 100644 index 000000000..3c4c5f805 --- /dev/null +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/Serilog14VersionConflict2xTests.cs @@ -0,0 +1,55 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +#if NETFRAMEWORK +using Datadog.Trace.TestHelpers; +using Xunit; +using Xunit.Abstractions; + +namespace Datadog.Trace.ClrProfiler.IntegrationTests.VersionConflict +{ + public class Serilog14VersionConflict2xTests : LogsInjectionTestBase + { + private readonly LogFileTest[] _log200FileTests = + { + new LogFileTest() + { + FileName = "log-textFile.log", + RegexFormat = @"{0}: {1}", + UnTracedLogTypes = UnTracedLogTypes.EmptyProperties, + PropertiesUseSerilogNaming = true + } + }; + + public Serilog14VersionConflict2xTests(ITestOutputHelper output) + : base(output, "LogsInjection.Serilog14.VersionConflict.2x") + { + SetServiceVersion("1.0.0"); + } + + [Fact(Skip = "VersionConflict tests are not ready to work without official next ver release")] + // [SkippableFact] + [Trait("Category", "EndToEnd")] + [Trait("RunOnWindows", "True")] + public void InjectsLogsWhenEnabled() + { + SetEnvironmentVariable("SIGNALFX_LOGS_INJECTION", "true"); + + var expectedCorrelatedTraceCount = 1; + var expectedCorrelatedSpanCount = 8; + + int agentPort = TcpPortProvider.GetOpenPort(); + using (var agent = new MockTracerAgent(agentPort)) + using (RunSampleAndWaitForExit(agent.Port)) + { + var spans = agent.WaitForSpans(1, 2500); + Assert.True(spans.Count >= 1, $"Expecting at least 1 span, only received {spans.Count}"); + + ValidateLogCorrelation(spans, _log200FileTests, expectedCorrelatedTraceCount, expectedCorrelatedSpanCount); + } + } + } +} +#endif diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/SerilogVersionConflict2xTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/SerilogVersionConflict2xTests.cs new file mode 100644 index 000000000..9b89b4766 --- /dev/null +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/SerilogVersionConflict2xTests.cs @@ -0,0 +1,62 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +#if !NETCOREAPP2_1 +using Datadog.Trace.TestHelpers; +using Xunit; +using Xunit.Abstractions; + +namespace Datadog.Trace.ClrProfiler.IntegrationTests.VersionConflict +{ + public class SerilogVersionConflict2xTests : LogsInjectionTestBase + { + private readonly LogFileTest[] _log200FileTests = + { + new LogFileTest() + { + FileName = "log-textFile.log", + RegexFormat = @"{0}: {1}", + UnTracedLogTypes = UnTracedLogTypes.EmptyProperties, + PropertiesUseSerilogNaming = true + }, + new LogFileTest() + { + FileName = "log-jsonFile.log", + RegexFormat = @"""{0}"":{1}", + UnTracedLogTypes = UnTracedLogTypes.EnvServiceTracingPropertiesOnly, + PropertiesUseSerilogNaming = true + } + }; + + public SerilogVersionConflict2xTests(ITestOutputHelper output) + : base(output, "LogsInjection.Serilog.VersionConflict.2x") + { + SetServiceVersion("1.0.0"); + } + + [Fact(Skip = "VersionConflict tests are not ready to work without official next ver release")] + // [SkippableFact] + [Trait("Category", "EndToEnd")] + [Trait("RunOnWindows", "True")] + public void InjectsLogsWhenEnabled() + { + SetEnvironmentVariable("SIGNALFX_LOGS_INJECTION", "true"); + + var expectedCorrelatedTraceCount = 1; + var expectedCorrelatedSpanCount = 8; + + int agentPort = TcpPortProvider.GetOpenPort(); + using (var agent = new MockTracerAgent(agentPort)) + using (RunSampleAndWaitForExit(agent.Port)) + { + var spans = agent.WaitForSpans(1, 2500); + Assert.True(spans.Count >= 1, $"Expecting at least 1 span, only received {spans.Count}"); + + ValidateLogCorrelation(spans, _log200FileTests, expectedCorrelatedTraceCount, expectedCorrelatedSpanCount); + } + } + } +} +#endif diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/VersionConflict1xTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/VersionConflict1xTests.cs new file mode 100644 index 000000000..07dcfcd53 --- /dev/null +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/VersionConflict1xTests.cs @@ -0,0 +1,46 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using System.Linq; +using Datadog.Trace.TestHelpers; +using FluentAssertions; +using Xunit; +using Xunit.Abstractions; + +namespace Datadog.Trace.ClrProfiler.IntegrationTests.VersionConflict +{ + public class VersionConflict1xTests : TestHelper + { + public VersionConflict1xTests(ITestOutputHelper output) + : base("VersionConflict.1x", output) + { + } + + [Fact(Skip = "VersionConflict tests are not ready to work without official next ver release")] + public void SubmitTraces() + { + // 1 manual span + 1 http span + const int expectedSpanCount = 2; + + using (var agent = EnvironmentHelper.GetMockAgent()) + using (var processResult = RunSampleAndWaitForExit(agent.Port)) + { + var spans = agent.WaitForSpans(expectedSpanCount); + + spans.Should().HaveCount(expectedSpanCount); + + // The version conflict fix does not work with the 1.x branch, so http traces should be orphaned + + var httpSpan = spans.Single(s => s.Name == "http.request"); + + httpSpan.ParentId.Should().BeNull(); + + var manualSpan = spans.Single(s => s.Name == "Manual"); + + manualSpan.Metrics[Metrics.SamplingPriority].Should().Be((double)SamplingPriority.UserReject); + } + } + } +} diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/VersionConflict2xTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/VersionConflict2xTests.cs new file mode 100644 index 000000000..ff6a18008 --- /dev/null +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/VersionConflict/VersionConflict2xTests.cs @@ -0,0 +1,97 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using System; +using System.Linq; +using Datadog.Trace.TestHelpers; +using FluentAssertions; +using Xunit; +using Xunit.Abstractions; + +namespace Datadog.Trace.ClrProfiler.IntegrationTests.VersionConflict +{ + public class VersionConflict2xTests : TestHelper + { + public VersionConflict2xTests(ITestOutputHelper output) + : base("VersionConflict.2x", output) + { + } + + [Fact(Skip = "VersionConflict tests are not ready to work without official next ver release")] + public void SubmitTraces() + { + // 1 manual span + 2 http spans + const int expectedSpanCount = 3; + + using (var agent = EnvironmentHelper.GetMockAgent()) + using (var processResult = RunSampleAndWaitForExit(agent.Port)) + { + var spans = agent.WaitForSpans(expectedSpanCount); + + foreach (var span in spans) + { + var samplingPriority = string.Empty; + + if (span.Metrics.ContainsKey(Metrics.SamplingPriority)) + { + samplingPriority = span.Metrics[Metrics.SamplingPriority].ToString(); + } + + Output.WriteLine($"{span.Name} - {span.TraceId} - {span.SpanId} - {span.ParentId} - {span.Resource} - {samplingPriority}"); + } + + spans.Should().HaveCount(expectedSpanCount); + + // Check that no trace is orphaned + var rootSpan = spans.Single(s => s.ParentId == null); + + rootSpan.Name.Should().Be("Manual"); + rootSpan.Metrics.Should().ContainKey(Metrics.SamplingPriority); + rootSpan.Metrics[Metrics.SamplingPriority].Should().Be((double)SamplingPriority.UserReject); + + var httpSpans = spans.Where(s => s.Name == "http.request").ToList(); + + // There is a difference in behavior between .NET Framework and .NET Core + // This happens because the version of the nuget is higher than the version of the automatic tracer + // When that's the case, only the nuget tracer is loaded, and we're not actually in a version conflict situation. + // When version 2.1 of the tracer ships, we can go back to the test and add a case using nuget 2.0, + // which will actually test the version conflict behavior. + +#if NETCOREAPP + httpSpans.Should() + .HaveCount(2) + .And.OnlyContain(s => s.ParentId == rootSpan.SpanId && s.TraceId == rootSpan.TraceId) + .And.OnlyContain(s => !s.Metrics.ContainsKey(Metrics.SamplingPriority)); +#else + httpSpans.Should() + .HaveCount(2) + .And.OnlyContain(s => s.ParentId == rootSpan.SpanId && s.TraceId == rootSpan.TraceId) + .And.ContainSingle(s => s.Metrics[Metrics.SamplingPriority] == (double)SamplingPriority.UserKeep) + .And.ContainSingle(s => s.Metrics[Metrics.SamplingPriority] == (double)SamplingPriority.UserReject); +#endif + + // Check the headers of the outbound http requests + var outputLines = processResult.StandardOutput.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); + + outputLines.Should().HaveCount(2); + + var firstHttpSpan = httpSpans.Single(s => s.Resource.EndsWith("/a")); + var secondHttpSpan = httpSpans.Single(s => s.Resource.EndsWith("/b")); + + outputLines[0].Should().Be($"{firstHttpSpan.TraceId}/{firstHttpSpan.SpanId}/2"); + outputLines[1].Should().Be($"{secondHttpSpan.TraceId}/{secondHttpSpan.SpanId}/-1"); + + rootSpan.Tags.Should().ContainKey(Tags.RuntimeId); + + var runtimeId = rootSpan.Tags[Tags.RuntimeId]; + Guid.TryParse(runtimeId, out _).Should().BeTrue(); + + httpSpans.Should().OnlyContain( + s => s.Tags[Tags.RuntimeId] == runtimeId, + "runtime id should be synchronized across versions of the tracer"); + } + } + } +} diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/WcfTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/WcfTests.cs index a3ac9a451..ae8560e33 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/WcfTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/WcfTests.cs @@ -71,10 +71,9 @@ public async Task SubmitsTraces(string binding, bool enableNewWcfInstrumentation const string expectedLogicScope = "wcf.request"; - int agentPort = TcpPortProvider.GetOpenPort(); int wcfPort = 8585; - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (RunSampleAndWaitForExit(agent.Port, arguments: $"{binding} Port={wcfPort}")) { // Filter out WCF spans unrelated to the actual request handling, and filter them before returning spans diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/WebRequest20Tests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/WebRequest20Tests.cs index 3eb1e0c52..0f1d9600e 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/WebRequest20Tests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/WebRequest20Tests.cs @@ -34,13 +34,10 @@ public void SubmitsTraces() const string expectedOperationName = "http.request"; const string expectedServiceName = "Samples.WebRequest.NetFramework20"; - int agentPort = TcpPortProvider.GetOpenPort(); int httpPort = TcpPortProvider.GetOpenPort(); - - Output.WriteLine($"Assigning port {agentPort} for the agentPort."); Output.WriteLine($"Assigning port {httpPort} for the httpPort."); - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (ProcessResult processResult = RunSampleAndWaitForExit(agent.Port, arguments: $"Port={httpPort}")) { var spans = agent.WaitForSpans(expectedSpanCount, operationName: expectedOperationName); @@ -66,10 +63,9 @@ public void TracingDisabled_DoesNotSubmitsTraces() { const string expectedOperationName = "http.request"; - int agentPort = TcpPortProvider.GetOpenPort(); int httpPort = TcpPortProvider.GetOpenPort(); - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (ProcessResult processResult = RunSampleAndWaitForExit(agent.Port, arguments: $"TracingDisabled Port={httpPort}")) { var spans = agent.WaitForSpans(1, 3000, operationName: expectedOperationName); diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/WebRequestTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/WebRequestTests.cs index 3ba73dc45..5988d20b6 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/WebRequestTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/WebRequestTests.cs @@ -37,13 +37,10 @@ public void SubmitsTraces() const string expectedOperationName = "http.request"; const string expectedServiceName = "Samples.WebRequest"; - int agentPort = TcpPortProvider.GetOpenPort(); int httpPort = TcpPortProvider.GetOpenPort(); - - Output.WriteLine($"Assigning port {agentPort} for the agentPort."); Output.WriteLine($"Assigning port {httpPort} for the httpPort."); - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (ProcessResult processResult = RunSampleAndWaitForExit(agent.Port, arguments: $"Port={httpPort}")) { var spans = agent.WaitForSpans(expectedSpanCount, operationName: expectedOperationName).OrderBy(s => s.Start); @@ -71,10 +68,9 @@ public void TracingDisabled_DoesNotSubmitsTraces() { const string expectedOperationName = "http.request"; - int agentPort = TcpPortProvider.GetOpenPort(); int httpPort = TcpPortProvider.GetOpenPort(); - using (var agent = new MockTracerAgent(agentPort)) + using (var agent = EnvironmentHelper.GetMockAgent()) using (ProcessResult processResult = RunSampleAndWaitForExit(agent.Port, arguments: $"TracingDisabled Port={httpPort}")) { var spans = agent.WaitForSpans(1, 3000, operationName: expectedOperationName); diff --git a/tracer/test/Datadog.Trace.ClrProfiler.Managed.Tests/DbScopeFactoryTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.Managed.Tests/DbScopeFactoryTests.cs index 7e9cd856f..fa62a3ad5 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.Managed.Tests/DbScopeFactoryTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.Managed.Tests/DbScopeFactoryTests.cs @@ -69,6 +69,23 @@ public void CreateDbCommandScope_SetsDbStatementBasedOnCommandText() Assert.Equal("test_command", scope.Span.Tags.GetTag(Tags.DbStatement)); } + [Theory] + [MemberData(nameof(GetDbCommands))] + public void CreateDbCommandScope_ReturnNullForAdoNetDisabledIntegration(IDbCommand command, string integrationName, string dbType) + { + // HACK: avoid analyzer warning about not using arguments + _ = dbType; + + var tracerSettings = new TracerSettings(); + tracerSettings.Integrations[integrationName].Enabled = true; + tracerSettings.Integrations[nameof(IntegrationId.AdoNet)].Enabled = false; + var tracer = TracerHelper.Create(tracerSettings); + + // Create scope + using var scope = CreateDbCommandScope(tracer, command); + Assert.Null(scope); + } + [Theory] [MemberData(nameof(GetDbCommands))] public void CreateDbCommandScope_UsesReplacementServiceNameWhenProvided(IDbCommand command, string integrationName, string dbType) diff --git a/tracer/test/Datadog.Trace.ClrProfiler.Managed.Tests/TypeNameTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.Managed.Tests/TypeNameTests.cs index 20926bbc6..4f4453673 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.Managed.Tests/TypeNameTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.Managed.Tests/TypeNameTests.cs @@ -44,6 +44,7 @@ public static IEnumerable GetConstTypeAssociations() yield return new object[] { ClrNames.ObjectTask, "System.Threading.Tasks.Task`1" }; yield return new object[] { ClrNames.Int32Task, "System.Threading.Tasks.Task`1" }; yield return new object[] { ClrNames.TimeSpan, "System.TimeSpan" }; + yield return new object[] { ClrNames.Type, typeof(Type) }; } [Fact] diff --git a/tracer/test/Datadog.Trace.IntegrationTests/ContainerTaggingTests.cs b/tracer/test/Datadog.Trace.IntegrationTests/ContainerTaggingTests.cs index b280c29d9..3d97b74a6 100644 --- a/tracer/test/Datadog.Trace.IntegrationTests/ContainerTaggingTests.cs +++ b/tracer/test/Datadog.Trace.IntegrationTests/ContainerTaggingTests.cs @@ -40,7 +40,10 @@ public async Task Http_Headers_Contain_ContainerId() var settings = new TracerSettings { - AgentUri = new Uri($"http://localhost:{agent.Port}"), + ExporterSettings = new ExporterSettings() + { + AgentUri = new Uri($"http://localhost:{agent.Port}"), + }, Exporter = ExporterType.DatadogAgent }; var tracer = new Tracer(settings, agentWriter: null, sampler: null, scopeManager: null, statsd: null); diff --git a/tracer/test/Datadog.Trace.IntegrationTests/DatadogHttpClientTests.cs b/tracer/test/Datadog.Trace.IntegrationTests/DatadogHttpClientTests.cs index 8f6cb3463..f3d3cff1f 100644 --- a/tracer/test/Datadog.Trace.IntegrationTests/DatadogHttpClientTests.cs +++ b/tracer/test/Datadog.Trace.IntegrationTests/DatadogHttpClientTests.cs @@ -32,8 +32,11 @@ public async Task DatadogHttpClient_CanSendTracesToAgent() { var settings = new TracerSettings { - AgentUri = new Uri($"http://localhost:{agent.Port}"), - TracesTransport = TransportStrategy.DatadogTcp, + ExporterSettings = new ExporterSettings() + { + AgentUri = new Uri($"http://localhost:{agent.Port}"), + TracesTransport = TracesTransportType.CustomTcpProvider, + } }; var tracer = new Tracer(settings, agentWriter: null, sampler: null, scopeManager: null, statsd: null); diff --git a/tracer/test/Datadog.Trace.IntegrationTests/SendTracesToZipkinCollector.cs b/tracer/test/Datadog.Trace.IntegrationTests/SendTracesToZipkinCollector.cs index 8af0e661a..869b63659 100644 --- a/tracer/test/Datadog.Trace.IntegrationTests/SendTracesToZipkinCollector.cs +++ b/tracer/test/Datadog.Trace.IntegrationTests/SendTracesToZipkinCollector.cs @@ -16,7 +16,7 @@ public SendTracesToZipkinCollector() { int collectorPort = 9411; var settings = new TracerSettings(); - settings.AgentUri = new Uri($"http://localhost:{collectorPort}/api/v2/spans"); + settings.ExporterSettings.AgentUri = new Uri($"http://localhost:{collectorPort}/api/v2/spans"); var exporter = new ZipkinExporter(settings.Build()); var exporterWriter = new ExporterWriter(exporter, new NullMetrics()); _tracer = new Tracer(new TracerSettings(), exporterWriter, sampler: null, scopeManager: null, statsd: null); diff --git a/tracer/test/Datadog.Trace.OpenTracing.IntegrationTests/OpenTracingSendTracesToAgent.cs b/tracer/test/Datadog.Trace.OpenTracing.IntegrationTests/OpenTracingSendTracesToAgent.cs index 125418fb6..daa0c5c50 100644 --- a/tracer/test/Datadog.Trace.OpenTracing.IntegrationTests/OpenTracingSendTracesToAgent.cs +++ b/tracer/test/Datadog.Trace.OpenTracing.IntegrationTests/OpenTracingSendTracesToAgent.cs @@ -26,7 +26,10 @@ public void MinimalSpan() { Exporter = ExporterType.DatadogAgent, Convention = ConventionType.Datadog, - AgentUri = new Uri($"http://127.0.0.1:{agent.Port}"), + ExporterSettings = new ExporterSettings() + { + AgentUri = new Uri($"http://127.0.0.1:{agent.Port}"), + }, TracerMetricsEnabled = false, }; @@ -55,7 +58,10 @@ public void CustomServiceName() { Exporter = ExporterType.DatadogAgent, Convention = ConventionType.Datadog, - AgentUri = new Uri($"http://127.0.0.1:{agent.Port}"), + ExporterSettings = new ExporterSettings() + { + AgentUri = new Uri($"http://127.0.0.1:{agent.Port}"), + }, TracerMetricsEnabled = false, }; @@ -86,7 +92,10 @@ public void Utf8Everywhere() { Exporter = ExporterType.DatadogAgent, Convention = ConventionType.Datadog, - AgentUri = new Uri($"http://127.0.0.1:{agent.Port}"), + ExporterSettings = new ExporterSettings() + { + AgentUri = new Uri($"http://127.0.0.1:{agent.Port}"), + }, TracerMetricsEnabled = false, }; @@ -119,9 +128,11 @@ private static void CompareSpans(MockTracerAgent.Span receivedSpan, OpenTracingS Resource = span.ResourceName, Service = span.ServiceName, Type = span.Type, - Tags = span.Tags, - }, - config => config.Excluding(span => span.Tags.Metrics)); + // TODO investigate if tags should be checked here + // Tags = span.Tags, + }); + + // config => config.Excluding(span => span.Tags.Metrics)); } } } diff --git a/tracer/test/Datadog.Trace.OpenTracing.Tests/Datadog.Trace.OpenTracing.Tests.csproj b/tracer/test/Datadog.Trace.OpenTracing.Tests/Datadog.Trace.OpenTracing.Tests.csproj index 3bda276b4..a165d4237 100644 --- a/tracer/test/Datadog.Trace.OpenTracing.Tests/Datadog.Trace.OpenTracing.Tests.csproj +++ b/tracer/test/Datadog.Trace.OpenTracing.Tests/Datadog.Trace.OpenTracing.Tests.csproj @@ -13,4 +13,8 @@ + + + + diff --git a/tracer/test/Datadog.Trace.OpenTracing.Tests/OpenTracingSpanBuilderTests.cs b/tracer/test/Datadog.Trace.OpenTracing.Tests/OpenTracingSpanBuilderTests.cs index 8e6a8895a..e3a3e7d7a 100644 --- a/tracer/test/Datadog.Trace.OpenTracing.Tests/OpenTracingSpanBuilderTests.cs +++ b/tracer/test/Datadog.Trace.OpenTracing.Tests/OpenTracingSpanBuilderTests.cs @@ -61,10 +61,13 @@ public void Start_AsChildOfSpan_ChildReferencesParent() .AsChildOf(root) .Start(); - Assert.Null(root.DDSpan.Context.ParentId); + var rootParentId = ((Span)root.Span).Context.ParentId; + var childParentId = ((Span)child.Span).Context.ParentId; + + Assert.Null(rootParentId); Assert.NotEqual(0, root.DDSpan.Context.SpanId); - Assert.NotEqual(TraceId.Zero, root.DDSpan.Context.TraceId); - Assert.Equal(root.DDSpan.Context.SpanId, child.DDSpan.Context.ParentId); + Assert.NotEqual(TraceId.Zero, root.DDSpan.Context.TraceId); + Assert.Equal(root.DDSpan.Context.SpanId, childParentId); Assert.Equal(root.DDSpan.Context.TraceId, child.DDSpan.Context.TraceId); Assert.NotEqual(0, child.DDSpan.Context.SpanId); } @@ -77,10 +80,13 @@ public void Start_AsChildOfSpanContext_ChildReferencesParent() .AsChildOf(root.Context) .Start(); - Assert.Null(root.DDSpan.Context.ParentId); + var rootParentId = ((Span)root.Span).Context.ParentId; + var childParentId = ((Span)child.Span).Context.ParentId; + + Assert.Null(rootParentId); Assert.NotEqual(0, root.DDSpan.Context.SpanId); - Assert.NotEqual(TraceId.Zero, root.DDSpan.Context.TraceId); - Assert.Equal(root.DDSpan.Context.SpanId, child.DDSpan.Context.ParentId); + Assert.NotEqual(TraceId.Zero, root.DDSpan.Context.TraceId); + Assert.Equal(root.DDSpan.Context.SpanId, childParentId); Assert.Equal(root.DDSpan.Context.TraceId, child.DDSpan.Context.TraceId); Assert.NotEqual(0, child.DDSpan.Context.SpanId); } @@ -93,10 +99,13 @@ public void Start_ReferenceAsChildOf_ChildReferencesParent() .AddReference(References.ChildOf, root.Context) .Start(); - Assert.Null(root.DDSpan.Context.ParentId); + var rootParentId = ((Span)root.Span).Context.ParentId; + var childParentId = ((Span)child.Span).Context.ParentId; + + Assert.Null(rootParentId); Assert.NotEqual(0, root.DDSpan.Context.SpanId); - Assert.NotEqual(TraceId.Zero, root.DDSpan.Context.TraceId); - Assert.Equal(root.DDSpan.Context.SpanId, child.DDSpan.Context.ParentId); + Assert.NotEqual(TraceId.Zero, root.DDSpan.Context.TraceId); + Assert.Equal(root.DDSpan.Context.SpanId, childParentId); Assert.Equal(root.DDSpan.Context.TraceId, child.DDSpan.Context.TraceId); Assert.NotEqual(0, child.DDSpan.Context.SpanId); } @@ -128,39 +137,41 @@ public void Start_SettingService_ServiceIsSet() } [Fact] - public void Start_SettingServiceInParent_ImplicitChildInheritServiceName() + public void Start_SettingServiceInParent_ChildDoesNotInheritServiceName() { - IScope root = _tracer.BuildSpan(null) + var root = _tracer.BuildSpan(null) .WithTag(DatadogTags.ServiceName, "MyService") .StartActive(finishSpanOnDispose: true); - IScope child = _tracer.BuildSpan(null) + var child = _tracer.BuildSpan(null) .StartActive(finishSpanOnDispose: true); Assert.Equal("MyService", ((OpenTracingSpan)root.Span).Span.ServiceName); - Assert.Equal("MyService", ((OpenTracingSpan)child.Span).Span.ServiceName); + Assert.NotEqual("MyService", ((OpenTracingSpan)child.Span).Span.ServiceName); + Assert.Equal(DefaultServiceName, ((OpenTracingSpan)child.Span).Span.ServiceName); } [Fact] - public void Start_SettingServiceInParent_ExplicitChildInheritServiceName() + public void Start_SettingServiceInParent_ExplicitChildDoesNotInheritServiceName() { - IScope root = _tracer.BuildSpan(null) + var root = _tracer.BuildSpan(null) .WithTag(DatadogTags.ServiceName, "MyService") .StartActive(finishSpanOnDispose: true); - IScope child = _tracer.BuildSpan(null) + var child = _tracer.BuildSpan(null) .AsChildOf(root.Span) .StartActive(finishSpanOnDispose: true); Assert.Equal("MyService", ((OpenTracingSpan)root.Span).Span.ServiceName); - Assert.Equal("MyService", ((OpenTracingSpan)child.Span).Span.ServiceName); + Assert.NotEqual("MyService", ((OpenTracingSpan)child.Span).Span.ServiceName); + Assert.Equal(DefaultServiceName, ((OpenTracingSpan)child.Span).Span.ServiceName); } [Fact] public void Start_SettingServiceInParent_NotChildDontInheritServiceName() { - ISpan span1 = _tracer.BuildSpan(null) + var span1 = _tracer.BuildSpan(null) .WithTag(DatadogTags.ServiceName, "MyService") .Start(); - IScope root = _tracer.BuildSpan(null) + var root = _tracer.BuildSpan(null) .StartActive(finishSpanOnDispose: true); Assert.Equal("MyService", ((OpenTracingSpan)span1).Span.ServiceName); @@ -219,7 +230,8 @@ public void Start_WithStartTimeStamp_TimeStampProperlySet() .WithStartTimestamp(startTime) .Start(); - Assert.Equal(startTime, span.DDSpan.StartTime); + var ddSpan = (Span)span.Span; + Assert.Equal(startTime, ddSpan.StartTime); } [Fact] diff --git a/tracer/test/Datadog.Trace.OpenTracing.Tests/OpenTracingSpanTests.cs b/tracer/test/Datadog.Trace.OpenTracing.Tests/OpenTracingSpanTests.cs index 8df029785..514ba5263 100644 --- a/tracer/test/Datadog.Trace.OpenTracing.Tests/OpenTracingSpanTests.cs +++ b/tracer/test/Datadog.Trace.OpenTracing.Tests/OpenTracingSpanTests.cs @@ -30,7 +30,7 @@ public OpenTracingSpanTests() [Fact] public void SetTag_Tags_TagsAreProperlySet() { - ISpan span = GetScope("Op1").Span; + var span = GetScope("Op1").Span; span.SetTag("StringKey", "What's tracing"); span.SetTag("IntKey", 42); @@ -47,7 +47,7 @@ public void SetTag_Tags_TagsAreProperlySet() [Fact] public void SetTag_SpecialTags_ServiceNameSetsService() { - ISpan span = GetScope("Op1").Span; + var span = GetScope("Op1").Span; const string value = "value"; span.SetTag(DatadogTags.ServiceName, value); @@ -59,7 +59,7 @@ public void SetTag_SpecialTags_ServiceNameSetsService() [Fact] public void SetTag_SpecialTags_ServiceVersionSetsVersion() { - ISpan span = GetScope("Op1").Span; + var span = GetScope("Op1").Span; const string value = "value"; span.SetTag(DatadogTags.ServiceVersion, value); @@ -72,7 +72,7 @@ public void SetTag_SpecialTags_ServiceVersionSetsVersion() [Fact] public void SetOperationName_ValidOperationName_OperationNameIsProperlySet() { - ISpan span = GetScope("Op0").Span; + var span = GetScope("Op0").Span; span.SetOperationName("Op1"); @@ -85,10 +85,12 @@ public void Finish_StartTimeInThePastWithNoEndTime_DurationProperlyComputed() TimeSpan expectedDuration = TimeSpan.FromMinutes(1); var startTime = DateTimeOffset.UtcNow - expectedDuration; - ISpan span = GetScope("Op1", startTime).Span; + var span = GetScope("Op1", startTime).Span; span.Finish(); - double durationDifference = Math.Abs((((OpenTracingSpan)span).Duration - expectedDuration).TotalMilliseconds); + var otSpan = (OpenTracingSpan)span; + var ddSpan = (Span)otSpan.Span; + double durationDifference = Math.Abs((ddSpan.Duration - expectedDuration).TotalMilliseconds); Assert.True(durationDifference < 100); } @@ -111,10 +113,12 @@ public void Finish_EndTimeProvided_SpanWritenWithCorrectDuration() var startTime = DateTimeOffset.UtcNow; var endTime = startTime.AddMilliseconds(10); - ISpan span = GetScope("Op1", startTime).Span; + var span = GetScope("Op1", startTime).Span; span.Finish(endTime); - Assert.Equal(endTime - startTime, ((OpenTracingSpan)span).Duration); + var otSpan = (OpenTracingSpan)span; + var ddSpan = (Span)otSpan.Span; + Assert.Equal(endTime - startTime, ddSpan.Duration); } [Fact] @@ -123,10 +127,12 @@ public void Finish_EndTimeInThePast_DurationIs0() var startTime = DateTimeOffset.UtcNow; var endTime = startTime.AddMilliseconds(-10); - ISpan span = GetScope("Op1", startTime).Span; + var span = GetScope("Op1", startTime).Span; span.Finish(endTime); - Assert.Equal(TimeSpan.Zero, ((OpenTracingSpan)span).Duration); + var otSpan = (OpenTracingSpan)span; + var ddSpan = (Span)otSpan.Span; + Assert.Equal(TimeSpan.Zero, ddSpan.Duration); } [Fact] @@ -134,21 +140,22 @@ public void Dispose_ExitUsing_SpanWriten() { OpenTracingSpan span; - using (IScope scope = GetScope("Op1")) + using (var scope = GetScope("Op1")) { span = (OpenTracingSpan)scope.Span; } - Assert.True(span.Duration > TimeSpan.Zero); + var ddSpan = (Span)span.Span; + Assert.True(ddSpan.Duration > TimeSpan.Zero); } [Fact] public void Context_TwoCalls_ContextStaysEqual() { - ISpan span; + global::OpenTracing.ISpan span; global::OpenTracing.ISpanContext firstContext; - using (IScope scope = GetScope("Op1")) + using (var scope = GetScope("Op1")) { span = scope.Span; firstContext = span.Context; @@ -159,7 +166,7 @@ public void Context_TwoCalls_ContextStaysEqual() Assert.Same(firstContext, secondContext); } - private IScope GetScope(string operationName, DateTimeOffset? startTime = null) + private global::OpenTracing.IScope GetScope(string operationName, DateTimeOffset? startTime = null) { ISpanBuilder spanBuilder = new OpenTracingSpanBuilder(_tracer, operationName); diff --git a/tracer/test/Datadog.Trace.OpenTracing.Tests/OpenTracingTracerTests.cs b/tracer/test/Datadog.Trace.OpenTracing.Tests/OpenTracingTracerTests.cs index d963a7770..cbb4603c8 100644 --- a/tracer/test/Datadog.Trace.OpenTracing.Tests/OpenTracingTracerTests.cs +++ b/tracer/test/Datadog.Trace.OpenTracing.Tests/OpenTracingTracerTests.cs @@ -55,40 +55,40 @@ public void BuildSpan_NoParameter_DefaultParameters() [Fact] public void BuildSpan_OneChild_ChildParentProperlySet() { - IScope root = _tracer + var root = _tracer .BuildSpan("Root") .StartActive(finishSpanOnDispose: true); - IScope child = _tracer + var child = _tracer .BuildSpan("Child") .StartActive(finishSpanOnDispose: true); - Span rootDatadogSpan = ((OpenTracingSpan)root.Span).Span; - Span childDatadogSpan = ((OpenTracingSpan)child.Span).Span; + Span rootDatadogSpan = (Span)((OpenTracingSpan)root.Span).Span; + Span childDatadogSpan = (Span)((OpenTracingSpan)child.Span).Span; - Assert.Equal(rootDatadogSpan.Context.TraceContext, (ITraceContext)childDatadogSpan.Context.TraceContext); + Assert.Equal(rootDatadogSpan.Context.TraceContext, childDatadogSpan.Context.TraceContext); Assert.Equal(rootDatadogSpan.Context.SpanId, childDatadogSpan.Context.ParentId); } [Fact] public void BuildSpan_2ChildrenOfRoot_ChildrenParentProperlySet() { - IScope root = _tracer + var root = _tracer .BuildSpan("Root") .StartActive(finishSpanOnDispose: true); - IScope child1 = _tracer + var child1 = _tracer .BuildSpan("Child1") .StartActive(finishSpanOnDispose: true); child1.Dispose(); - IScope child2 = _tracer + var child2 = _tracer .BuildSpan("Child2") .StartActive(finishSpanOnDispose: true); - Span rootDatadogSpan = ((OpenTracingSpan)root.Span).Span; - Span child1DatadogSpan = ((OpenTracingSpan)child1.Span).Span; - Span child2DatadogSpan = ((OpenTracingSpan)child2.Span).Span; + Span rootDatadogSpan = (Span)((OpenTracingSpan)root.Span).Span; + Span child1DatadogSpan = (Span)((OpenTracingSpan)child1.Span).Span; + Span child2DatadogSpan = (Span)((OpenTracingSpan)child2.Span).Span; Assert.Same(rootDatadogSpan.Context.TraceContext, child1DatadogSpan.Context.TraceContext); Assert.Equal(rootDatadogSpan.Context.SpanId, child1DatadogSpan.Context.ParentId); @@ -99,19 +99,19 @@ public void BuildSpan_2ChildrenOfRoot_ChildrenParentProperlySet() [Fact] public void BuildSpan_2LevelChildren_ChildrenParentProperlySet() { - IScope root = _tracer + var root = _tracer .BuildSpan("Root") .StartActive(finishSpanOnDispose: true); - IScope child1 = _tracer + var child1 = _tracer .BuildSpan("Child1") .StartActive(finishSpanOnDispose: true); - IScope child2 = _tracer + var child2 = _tracer .BuildSpan("Child2") .StartActive(finishSpanOnDispose: true); - Span rootDatadogSpan = ((OpenTracingSpan)root.Span).Span; - Span child1DatadogSpan = ((OpenTracingSpan)child1.Span).Span; - Span child2DatadogSpan = ((OpenTracingSpan)child2.Span).Span; + Span rootDatadogSpan = (Span)((OpenTracingSpan)root.Span).Span; + Span child1DatadogSpan = (Span)((OpenTracingSpan)child1.Span).Span; + Span child2DatadogSpan = (Span)((OpenTracingSpan)child2.Span).Span; Assert.Same(rootDatadogSpan.Context.TraceContext, child1DatadogSpan.Context.TraceContext); Assert.Equal(rootDatadogSpan.Context.SpanId, child1DatadogSpan.Context.ParentId); @@ -124,7 +124,7 @@ public async Task BuildSpan_AsyncChildrenCreation_ChildrenParentProperlySet() { var tcs = new TaskCompletionSource(); - IScope root = _tracer + var root = _tracer .BuildSpan("Root") .StartActive(finishSpanOnDispose: true); @@ -136,18 +136,20 @@ public async Task BuildSpan_AsyncChildrenCreation_ChildrenParentProperlySet() var tasks = Enumerable.Range(0, 10).Select(x => createSpanAsync(_tracer)).ToArray(); var syncChild = (OpenTracingSpan)_tracer.BuildSpan("SyncChild").Start(); + var syncChildSpanContext = ((Span)syncChild.Span).Context; tcs.SetResult(true); - Span rootDatadogSpan = ((OpenTracingSpan)root.Span).Span; + Span rootDatadogSpan = (Span)((OpenTracingSpan)root.Span).Span; - Assert.Equal(rootDatadogSpan.Context.TraceContext, (ITraceContext)syncChild.DDSpan.Context.TraceContext); - Assert.Equal(rootDatadogSpan.Context.SpanId, syncChild.DDSpan.Context.ParentId); + Assert.Equal(rootDatadogSpan.Context.TraceContext, syncChildSpanContext.TraceContext); + Assert.Equal(rootDatadogSpan.Context.SpanId, syncChildSpanContext.ParentId); foreach (var task in tasks) { var span = await task; - Assert.Equal(rootDatadogSpan.Context.TraceContext, (ITraceContext)span.DDSpan.Context.TraceContext); - Assert.Equal(rootDatadogSpan.Context.SpanId, span.DDSpan.Context.ParentId); + var spanContext = ((Span)syncChild.Span).Context; + Assert.Equal(rootDatadogSpan.Context.TraceContext, spanContext.TraceContext); + Assert.Equal(rootDatadogSpan.Context.SpanId, spanContext.ParentId); } } @@ -243,7 +245,7 @@ public void StartActive_NoServiceName_DefaultServiceName() [Fact] public void SetDefaultServiceName() { - ITracer tracer = OpenTracingTracerFactory.CreateTracer(defaultServiceName: "DefaultServiceName"); + var tracer = OpenTracingTracerFactory.CreateTracer(defaultServiceName: "DefaultServiceName"); var scope = tracer.BuildSpan("Operation") .StartActive(); @@ -283,7 +285,7 @@ public void SetServiceName_SetTag() [Fact] public void OverrideDefaultServiceName_WithTag() { - ITracer tracer = OpenTracingTracerFactory.CreateTracer(defaultServiceName: "DefaultServiceName"); + var tracer = OpenTracingTracerFactory.CreateTracer(defaultServiceName: "DefaultServiceName"); var scope = tracer.BuildSpan("Operation") .WithTag(DatadogTags.ServiceName, "MyAwesomeService") @@ -298,7 +300,7 @@ public void OverrideDefaultServiceName_WithTag() [Fact] public void OverrideDefaultServiceName_SetTag() { - ITracer tracer = OpenTracingTracerFactory.CreateTracer(defaultServiceName: "DefaultServiceName"); + var tracer = OpenTracingTracerFactory.CreateTracer(defaultServiceName: "DefaultServiceName"); var scope = tracer.BuildSpan("Operation") .StartActive(); @@ -311,7 +313,7 @@ public void OverrideDefaultServiceName_SetTag() } [Fact] - public void InheritParentServiceName_WithTag() + public void DoesNotInheritParentServiceName_WithTag() { var parentScope = _tracer.BuildSpan("ParentOperation") .WithTag(DatadogTags.ServiceName, "MyAwesomeService") @@ -321,14 +323,13 @@ public void InheritParentServiceName_WithTag() .AsChildOf(parentScope.Span) .StartActive(); - var otSpan = (OpenTracingSpan)childScope.Span; - var ddSpan = otSpan.Span; - - Assert.Equal("MyAwesomeService", ddSpan.ServiceName); + Assert.Equal("MyAwesomeService", ((OpenTracingSpan)parentScope.Span).Span.ServiceName); + Assert.NotEqual("MyAwesomeService", ((OpenTracingSpan)childScope.Span).Span.ServiceName); + Assert.Equal(_tracer.DefaultServiceName, ((OpenTracingSpan)childScope.Span).Span.ServiceName); } [Fact] - public void InheritParentServiceName_SetTag() + public void DoesNotInheritParentServiceName_SetTag() { var parentScope = _tracer.BuildSpan("ParentOperation") .StartActive(); @@ -339,16 +340,16 @@ public void InheritParentServiceName_SetTag() .AsChildOf(parentScope.Span) .StartActive(); - var otSpan = (OpenTracingSpan)childScope.Span; - var ddSpan = otSpan.Span; - - Assert.Equal("MyAwesomeService", ddSpan.ServiceName); + Assert.Equal("MyAwesomeService", ((OpenTracingSpan)parentScope.Span).Span.ServiceName); + Assert.NotEqual("MyAwesomeService", ((OpenTracingSpan)childScope.Span).Span.ServiceName); + Assert.Equal(_tracer.DefaultServiceName, ((OpenTracingSpan)childScope.Span).Span.ServiceName); } [Fact] public void Parent_OverrideDefaultServiceName_WithTag() { - ITracer tracer = OpenTracingTracerFactory.CreateTracer(defaultServiceName: "DefaultServiceName"); + const string defaultServiceName = "DefaultServiceName"; + var tracer = OpenTracingTracerFactory.CreateTracer(defaultServiceName: defaultServiceName); var parentScope = tracer.BuildSpan("ParentOperation") .WithTag(DatadogTags.ServiceName, "MyAwesomeService") @@ -358,16 +359,16 @@ public void Parent_OverrideDefaultServiceName_WithTag() .AsChildOf(parentScope.Span) .StartActive(); - var otSpan = (OpenTracingSpan)childScope.Span; - var ddSpan = otSpan.Span; - - Assert.Equal("MyAwesomeService", ddSpan.ServiceName); + Assert.Equal("MyAwesomeService", ((OpenTracingSpan)parentScope.Span).Span.ServiceName); + Assert.NotEqual("MyAwesomeService", ((OpenTracingSpan)childScope.Span).Span.ServiceName); + Assert.Equal(defaultServiceName, ((OpenTracingSpan)childScope.Span).Span.ServiceName); } [Fact] public void Parent_OverrideDefaultServiceName_SetTag() { - ITracer tracer = OpenTracingTracerFactory.CreateTracer(defaultServiceName: "DefaultServiceName"); + const string defaultServiceName = "DefaultServiceName"; + var tracer = OpenTracingTracerFactory.CreateTracer(defaultServiceName: defaultServiceName); var parentScope = tracer.BuildSpan("ParentOperation") .StartActive(); @@ -378,10 +379,9 @@ public void Parent_OverrideDefaultServiceName_SetTag() .AsChildOf(parentScope.Span) .StartActive(); - var otSpan = (OpenTracingSpan)childScope.Span; - var ddSpan = otSpan.Span; - - Assert.Equal("MyAwesomeService", ddSpan.ServiceName); + Assert.Equal("MyAwesomeService", ((OpenTracingSpan)parentScope.Span).Span.ServiceName); + Assert.NotEqual("MyAwesomeService", ((OpenTracingSpan)childScope.Span).Span.ServiceName); + Assert.Equal(defaultServiceName, ((OpenTracingSpan)childScope.Span).Span.ServiceName); } } } diff --git a/tracer/test/Datadog.Trace.OpenTracing.Tests/PublicApiTests.cs b/tracer/test/Datadog.Trace.OpenTracing.Tests/PublicApiTests.cs new file mode 100644 index 000000000..74188ccc7 --- /dev/null +++ b/tracer/test/Datadog.Trace.OpenTracing.Tests/PublicApiTests.cs @@ -0,0 +1,17 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using Datadog.Trace.Tests; + +namespace Datadog.Trace.OpenTracing.Tests +{ + public class PublicApiTests : PublicApiTestsBase + { + public PublicApiTests() + : base(typeof(OpenTracingTracer).Assembly) + { + } + } +} diff --git a/tracer/test/Datadog.Trace.OpenTracing.Tests/Snapshots/PublicApiTests.PublicApiHasNotChanged.verified.txt b/tracer/test/Datadog.Trace.OpenTracing.Tests/Snapshots/PublicApiTests.PublicApiHasNotChanged.verified.txt new file mode 100644 index 000000000..976a2d717 --- /dev/null +++ b/tracer/test/Datadog.Trace.OpenTracing.Tests/Snapshots/PublicApiTests.PublicApiHasNotChanged.verified.txt @@ -0,0 +1,24 @@ +[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/signalfx/signalfx-dotnet-tracing.git")] + +namespace Datadog.Trace.OpenTracing +{ + public static class DatadogTags + { + public const string ResourceName = "resource.name"; + public const string ServiceName = "service.name"; + public const string ServiceVersion = "service.version"; + public const string SpanType = "span.type"; + } + public class OpenTracingHttpHeadersCarrier : OpenTracing.Propagation.ITextMap, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + { + public OpenTracingHttpHeadersCarrier(System.Net.Http.Headers.HttpHeaders headers) { } + public string Get(string key) { } + public System.Collections.Generic.IEnumerator> GetEnumerator() { } + public void Set(string key, string value) { } + } + public static class OpenTracingTracerFactory + { + public static OpenTracing.ITracer CreateTracer(System.Uri agentEndpoint = null, string defaultServiceName = null, bool isDebugEnabled = false) { } + public static OpenTracing.ITracer WrapTracer(Datadog.Trace.Tracer tracer) { } + } +} \ No newline at end of file diff --git a/tracer/test/Datadog.Trace.Security.IntegrationTests/AspNetBase.cs b/tracer/test/Datadog.Trace.Security.IntegrationTests/AspNetBase.cs index 61f24ad6f..eb26152dd 100644 --- a/tracer/test/Datadog.Trace.Security.IntegrationTests/AspNetBase.cs +++ b/tracer/test/Datadog.Trace.Security.IntegrationTests/AspNetBase.cs @@ -22,6 +22,7 @@ namespace Datadog.Trace.Security.IntegrationTests { public class AspNetBase : TestHelper { + protected const string DefaultAttackUrl = "/Health/?arg=[$slice]"; private readonly HttpClient _httpClient; private readonly string _shutdownPath; private int _httpPort; @@ -33,6 +34,10 @@ public AspNetBase(string sampleName, ITestOutputHelper outputHelper, string shut { _httpClient = new HttpClient(); _shutdownPath = shutdownPath; + + // adding these header so we can later assert it was collect properly + _httpClient.DefaultRequestHeaders.Add("X-FORWARDED", "86.242.244.246"); + _httpClient.DefaultRequestHeaders.Add("user-agent", "Mistake Not..."); } public async Task RunOnSelfHosted(bool enableSecurity, bool enableBlocking) @@ -77,13 +82,13 @@ public void Dispose() _agent?.Dispose(); } - public async Task TestBlockedRequestAsync(MockTracerAgent agent, bool enableSecurity, HttpStatusCode expectedStatusCode, int expectedSpans, IEnumerable> assertOnSpans) + public async Task TestBlockedRequestAsync(MockTracerAgent agent, bool enableSecurity, HttpStatusCode expectedStatusCode, int expectedSpans, IEnumerable> assertOnSpans, string url) { - Func> attack = () => SubmitRequest("/Health/?arg=[$slice]"); + Func> attack = () => SubmitRequest(url); var resultRequests = await Task.WhenAll(attack(), attack(), attack(), attack(), attack()); agent.SpanFilters.Add(s => s.Tags.ContainsKey("http.url") && s.Tags["http.url"].IndexOf("Health", StringComparison.InvariantCultureIgnoreCase) > 0); var spans = agent.WaitForSpans(expectedSpans); - Assert.Equal(expectedSpans, spans.Count()); + Assert.Equal(expectedSpans, spans.Count); var expectedAppSecEvents = enableSecurity ? 5 : 0; var actualAppSecEvents = 0; @@ -92,17 +97,18 @@ public async Task TestBlockedRequestAsync(MockTracerAgent agent, bool enableSecu foreach (var span in spans) { - foreach (var assert in assertOnSpans) - { - assert(span); - } - // not all tags will have security events, only the route ones var gotTag = span.Tags.TryGetValue(Tags.AppSecJson, out var json); if (gotTag) { actualAppSecEvents++; + // we only really care about these asserts if we're on an appsec span + foreach (var assert in assertOnSpans) + { + assert(span); + } + var jsonObj = JsonConvert.DeserializeObject(json); var item = jsonObj.Triggers.FirstOrDefault(); @@ -111,6 +117,23 @@ public async Task TestBlockedRequestAsync(MockTracerAgent agent, bool enableSecu var attackEvent = item; var shouldBlock = expectedStatusCode == HttpStatusCode.Forbidden; Assert.Equal("Finds basic MongoDB SQL injection attempts", attackEvent.Rule.Name); + + // presences of json tag implies span should carry other security tags + var securityTags = new Dictionary() + { + { "appsec.event", "true" }, + { "_dd.origin", "appsec" }, + { "http.useragent", "Mistake Not..." }, + { "actor.ip", "86.242.244.246" }, + { "http.request.headers.host", $"localhost:{_httpPort}" }, + { "http.request.headers.x-forwarded", "86.242.244.246" }, + { "http.request.headers.user-agent", "Mistake Not..." }, + }; + foreach (var kvp in securityTags) + { + Assert.True(span.Tags.TryGetValue(kvp.Key, out var tagValue), $"The tag {kvp.Key} was not found"); + Assert.Equal(kvp.Value, tagValue); + } } } diff --git a/tracer/test/Datadog.Trace.Security.IntegrationTests/AspNetCore2.cs b/tracer/test/Datadog.Trace.Security.IntegrationTests/AspNetCore2.cs index 39765485b..21da9c83c 100644 --- a/tracer/test/Datadog.Trace.Security.IntegrationTests/AspNetCore2.cs +++ b/tracer/test/Datadog.Trace.Security.IntegrationTests/AspNetCore2.cs @@ -27,16 +27,30 @@ public AspNetCore2(ITestOutputHelper outputHelper) [InlineData(true, false, HttpStatusCode.OK)] [InlineData(false, true, HttpStatusCode.OK)] [InlineData(false, false, HttpStatusCode.OK)] + [InlineData(true, false, HttpStatusCode.OK, "/Health/?test&[$slice]")] [Trait("RunOnWindows", "True")] [Trait("Category", "ArmUnsupported")] - public async Task TestSecurity(bool enableSecurity, bool enableBlocking, HttpStatusCode expectedStatusCode) + public async Task TestSecurity(bool enableSecurity, bool enableBlocking, HttpStatusCode expectedStatusCode, string url = DefaultAttackUrl) { var agent = await RunOnSelfHosted(enableSecurity, enableBlocking); - await TestBlockedRequestAsync(agent, enableSecurity, expectedStatusCode, 5, new Action[] + await TestBlockedRequestAsync(agent, enableSecurity, expectedStatusCode, expectedSpans: 5, url: url, assertOnSpans: new Action[] { s => Assert.Equal("aspnet_core.request", s.LogicScope), s => Assert.Equal("Samples.AspNetCore2", s.Service), - s => Assert.Equal("web", s.Type) + s => Assert.Equal("web", s.Type), + s => + { + var securityTags = new Dictionary + { + { "network.client.ip", "127.0.0.1" }, + { "http.response.headers.content-type", "text/plain; charset=utf-8" }, + }; + foreach (var kvp in securityTags) + { + Assert.True(s.Tags.TryGetValue(kvp.Key, out var tagValue), $"The tag {kvp.Key} was not found"); + Assert.Equal(kvp.Value, tagValue); + } + }, }); } } diff --git a/tracer/test/Datadog.Trace.Security.IntegrationTests/AspNetCore5.cs b/tracer/test/Datadog.Trace.Security.IntegrationTests/AspNetCore5.cs index 362775f38..ccded3192 100644 --- a/tracer/test/Datadog.Trace.Security.IntegrationTests/AspNetCore5.cs +++ b/tracer/test/Datadog.Trace.Security.IntegrationTests/AspNetCore5.cs @@ -30,16 +30,31 @@ public AspNetCore5(ITestOutputHelper outputHelper) [InlineData(true, false, HttpStatusCode.OK)] [InlineData(false, true, HttpStatusCode.OK)] [InlineData(false, false, HttpStatusCode.OK)] + [InlineData(true, false, HttpStatusCode.OK, "/Health/?test&[$slice]")] [Trait("RunOnWindows", "True")] [Trait("Category", "ArmUnsupported")] - public async Task TestSecurity(bool enableSecurity, bool enableBlocking, HttpStatusCode expectedStatusCode) + public async Task TestSecurity(bool enableSecurity, bool enableBlocking, HttpStatusCode expectedStatusCode, string url = DefaultAttackUrl) { var agent = await RunOnSelfHosted(enableSecurity, enableBlocking); - await TestBlockedRequestAsync(agent, enableSecurity, expectedStatusCode, 5, new Action[] + await TestBlockedRequestAsync(agent, enableSecurity, expectedStatusCode, 5, url: url, assertOnSpans: new Action[] { s => Assert.Equal("aspnet_core.request", s.LogicScope), s => Assert.Equal("Samples.AspNetCore5", s.Service), - s => Assert.Equal("web", s.Type) + s => Assert.Equal("web", s.Type), + s => Assert.Equal(enableSecurity ? "GET /health" : "aspnet_core.request", s.Name), + s => + { + var securityTags = new Dictionary + { + { "network.client.ip", "127.0.0.1" }, + { "http.response.headers.content-type", "text/plain; charset=utf-8" }, + }; + foreach (var kvp in securityTags) + { + Assert.True(s.Tags.TryGetValue(kvp.Key, out var tagValue), $"The tag {kvp.Key} was not found"); + Assert.Equal(kvp.Value, tagValue); + } + }, }); } } diff --git a/tracer/test/Datadog.Trace.Security.IntegrationTests/AspNetMvc5.cs b/tracer/test/Datadog.Trace.Security.IntegrationTests/AspNetMvc5.cs index 156501296..6a964b422 100644 --- a/tracer/test/Datadog.Trace.Security.IntegrationTests/AspNetMvc5.cs +++ b/tracer/test/Datadog.Trace.Security.IntegrationTests/AspNetMvc5.cs @@ -6,9 +6,7 @@ #if NET461 using System; using System.Collections.Generic; -using System.Linq; using System.Net; -using System.Net.Http; using System.Runtime.InteropServices; using System.Threading.Tasks; using Datadog.Trace.TestHelpers; @@ -98,16 +96,30 @@ public AspNetMvc5(IisFixture iisFixture, ITestOutputHelper output, bool classicM [Trait("Category", "EndToEnd")] [Trait("RunOnWindows", "True")] [Trait("LoadFromGAC", "True")] - [Fact] - public Task TestSecurity() + [Theory] + [InlineData("/Health/?test&[$slice]")] + [InlineData] + public Task TestSecurity(string url = DefaultAttackUrl) { // if blocking is enabled, request stops before reaching asp net mvc integrations intercepting before action methods, so no more spans are generated // NOTE: by integrating the latest version of the WAF, blocking was disabled, as it does not support blocking yet - return TestBlockedRequestAsync(_iisFixture.Agent, _enableSecurity, _enableSecurity && _blockingEnabled ? HttpStatusCode.OK : HttpStatusCode.OK, _enableSecurity && _blockingEnabled ? 10 : 10, new Action[] + return TestBlockedRequestAsync(_iisFixture.Agent, _enableSecurity, _enableSecurity && _blockingEnabled ? HttpStatusCode.OK : HttpStatusCode.OK, _enableSecurity && _blockingEnabled ? 10 : 10, url: url, assertOnSpans: new Action[] { s => Assert.Matches("aspnet(-mvc)?.request", s.LogicScope ?? s.Name), s => Assert.Equal("sample", s.Service), - s => Assert.Equal("web", s.Type) + s => Assert.Equal("web", s.Type), + s => + { + var securityTags = new Dictionary() + { + { "network.client.ip", "::1" }, + }; + foreach (var kvp in securityTags) + { + Assert.True(s.Tags.TryGetValue(kvp.Key, out var tagValue), $"The tag {kvp.Key} was not found"); + Assert.Equal(kvp.Value, tagValue); + } + }, }); } } diff --git a/tracer/test/Datadog.Trace.TestHelpers/Datadog.Trace.TestHelpers.csproj b/tracer/test/Datadog.Trace.TestHelpers/Datadog.Trace.TestHelpers.csproj index 8ecbdb9ba..b654cb9a5 100644 --- a/tracer/test/Datadog.Trace.TestHelpers/Datadog.Trace.TestHelpers.csproj +++ b/tracer/test/Datadog.Trace.TestHelpers/Datadog.Trace.TestHelpers.csproj @@ -4,6 +4,7 @@ + diff --git a/tracer/test/Datadog.Trace.TestHelpers/EnvironmentHelper.cs b/tracer/test/Datadog.Trace.TestHelpers/EnvironmentHelper.cs index ef0d7d6c0..f61395ae8 100644 --- a/tracer/test/Datadog.Trace.TestHelpers/EnvironmentHelper.cs +++ b/tracer/test/Datadog.Trace.TestHelpers/EnvironmentHelper.cs @@ -19,7 +19,6 @@ namespace Datadog.Trace.TestHelpers { public class EnvironmentHelper { - private static readonly Assembly ExecutingAssembly = Assembly.GetExecutingAssembly(); private static readonly string RuntimeFrameworkDescription = RuntimeInformation.FrameworkDescription.ToLower(); private readonly ITestOutputHelper _output; @@ -361,7 +360,7 @@ public string GetDotnetExe() Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "dotnet", "dotnet.exe"), - _ => "dotnet", + _ => "dotnet", }; public string GetSampleProjectDirectory() @@ -435,5 +434,21 @@ public string GetTargetFramework() return $"net{_major}{_minor}{_patch ?? string.Empty}"; } + + public MockTracerAgent GetMockAgent(bool useStatsD = false) + { + // Strategy pattern for agent transports goes here + var agentPort = TcpPortProvider.GetOpenPort(); + var agent = new MockTracerAgent(agentPort, useStatsd: useStatsD); + + _output.WriteLine($"Assigned port {agent.Port} for the agentPort."); + + if (useStatsD) + { + _output.WriteLine($"Assigning port {agent.StatsdPort} for the statsdPort."); + } + + return agent; + } } } diff --git a/tracer/test/Datadog.Trace.TestHelpers/Factories/SpanFactory.cs b/tracer/test/Datadog.Trace.TestHelpers/Factories/SpanFactory.cs index 18c3fdbf4..a91d21c6b 100644 --- a/tracer/test/Datadog.Trace.TestHelpers/Factories/SpanFactory.cs +++ b/tracer/test/Datadog.Trace.TestHelpers/Factories/SpanFactory.cs @@ -1,3 +1,5 @@ +// Modified by Splunk Inc. + using System; using Datadog.Trace.Tagging; using Moq; @@ -6,12 +8,12 @@ namespace Datadog.Trace.TestHelpers.Factories { public static class SpanFactory { - public static Span CreateSpan() + internal static Span CreateSpan() { return CreateSpan(Mock.Of()); } - public static Span CreateSpan(ISpanContext parentContext) + internal static Span CreateSpan(ISpanContext parentContext) { var spanContext = new SpanContext(parentContext, Mock.Of(), serviceName: null); diff --git a/tracer/test/Datadog.Trace.TestHelpers/PublicApiTestsBase.cs b/tracer/test/Datadog.Trace.TestHelpers/PublicApiTestsBase.cs new file mode 100644 index 000000000..f5b55b445 --- /dev/null +++ b/tracer/test/Datadog.Trace.TestHelpers/PublicApiTestsBase.cs @@ -0,0 +1,134 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using System; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.Versioning; +using FluentAssertions; +using PublicApiGenerator; +using Xunit; + +namespace Datadog.Trace.Tests +{ + public abstract class PublicApiTestsBase + { + private static readonly ApiGeneratorOptions ApiGeneratorOptions = new ApiGeneratorOptions + { + ExcludeAttributes = new[] { typeof(InternalsVisibleToAttribute).FullName, }, + }; + + private readonly Assembly _assembly; + private readonly string _filePath; + + public PublicApiTestsBase(Assembly assembly, [CallerFilePath] string filePath = null) + { + _assembly = assembly; + _filePath = filePath; + } + + [Fact] + public void PublicApiHasNotChanged() + { + var browsableTypes = _assembly.GetTypes().Where(type => !HasHideInIntellisenseAttributes(type)).ToArray(); + var publicApi = browsableTypes.GeneratePublicApi(ApiGeneratorOptions); + + // we will have a slightly different public API for net4x vs netcore + var attribute = (TargetFrameworkAttribute)_assembly.GetCustomAttribute(typeof(TargetFrameworkAttribute)); + + // remove the differences between the lines + publicApi = publicApi.Replace( + $@"[assembly: System.Runtime.Versioning.TargetFramework(""{attribute.FrameworkName}"", FrameworkDisplayName=""{attribute.FrameworkDisplayName}"")]", + string.Empty); + + var expected = GetExpected(publicApi); + + publicApi.Should().Be(expected, "Public API should match the verified API. Update verified snapshot when the public API changes as appropriate"); + } + + [Theory] + [InlineData(typeof(Hidden), true)] + [InlineData(typeof(NotHidden1), false)] + [InlineData(typeof(NotHidden2), false)] + [InlineData(typeof(NotHidden3), false)] + [InlineData(typeof(NotHidden4), false)] + [InlineData(typeof(NotHidden5), false)] + [InlineData(typeof(NotHidden6), false)] + public void CalculatesHiddenCorrectly(Type type, bool isHidden) + { + var actual = HasHideInIntellisenseAttributes(type); + actual.Should().Be(isHidden); + } + + private static bool HasHideInIntellisenseAttributes(Type type) + { + var browsable = type.GetCustomAttribute(); + if (browsable is null || browsable.Browsable) + { + return false; + } + + var editorBrowsable = type.GetCustomAttribute(); + if (editorBrowsable is null || editorBrowsable.State != EditorBrowsableState.Never) + { + return false; + } + + return true; + } + + private string GetExpected(string publicApi, [CallerMemberName] string methodName = null) + { + // poor-man's VerifyTests.Verify, because Verify has incompatible dependencies with ASP.NET Core + var snapshotDirectory = Path.Combine(Directory.GetParent(_filePath).FullName, "Snapshots"); + var receivedPath = Path.Combine(snapshotDirectory, $"PublicApiTests.{methodName}.received.txt"); + var verifiedPath = Path.Combine(snapshotDirectory, $"PublicApiTests.{methodName}.verified.txt"); + + File.WriteAllText(receivedPath, publicApi); + return File.Exists(verifiedPath) ? File.ReadAllText(verifiedPath) : string.Empty; + } + + [Browsable(false)] + [EditorBrowsable(EditorBrowsableState.Never)] + public class Hidden + { + } + + [Browsable(true)] + [EditorBrowsable(EditorBrowsableState.Never)] + public class NotHidden1 + { + } + + [Browsable(false)] + [EditorBrowsable(EditorBrowsableState.Advanced)] + public class NotHidden2 + { + } + + [Browsable(false)] + [EditorBrowsable(EditorBrowsableState.Always)] + public class NotHidden3 + { + } + + [Browsable(false)] + public class NotHidden4 + { + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public class NotHidden5 + { + } + + public class NotHidden6 + { + } + } +} diff --git a/tracer/test/Datadog.Trace.TestHelpers/TestHelper.cs b/tracer/test/Datadog.Trace.TestHelpers/TestHelper.cs index 00bcb7a9a..86598c6cb 100644 --- a/tracer/test/Datadog.Trace.TestHelpers/TestHelper.cs +++ b/tracer/test/Datadog.Trace.TestHelpers/TestHelper.cs @@ -79,7 +79,7 @@ public Process StartDotnetTestSample(int traceAgentPort, string arguments, strin traceAgentPort: traceAgentPort, statsdPort: statsdPort, aspNetCorePort: aspNetCorePort, - processToProfile: exec); + processToProfile: exec + ";testhost.exe"); } public ProcessResult RunDotnetTestSampleAndWaitForExit(int traceAgentPort, int? statsdPort = null, string arguments = null, string packageVersion = "", string framework = "") diff --git a/tracer/test/Datadog.Trace.TestHelpers/TestRunners.cs b/tracer/test/Datadog.Trace.TestHelpers/TestRunners.cs index f704e3993..819c2c69c 100644 --- a/tracer/test/Datadog.Trace.TestHelpers/TestRunners.cs +++ b/tracer/test/Datadog.Trace.TestHelpers/TestRunners.cs @@ -17,6 +17,7 @@ public class TestRunners "vstest.console", "xunit.console.x86", "xunit.console.x64", + "ReSharperTestRunner", "ReSharperTestRunner64", "ReSharperTestRunner64c" }; diff --git a/tracer/test/Datadog.Trace.TestHelpers/TracerRestorerAttribute.cs b/tracer/test/Datadog.Trace.TestHelpers/TracerRestorerAttribute.cs index 22148f8ad..a35f574d7 100644 --- a/tracer/test/Datadog.Trace.TestHelpers/TracerRestorerAttribute.cs +++ b/tracer/test/Datadog.Trace.TestHelpers/TracerRestorerAttribute.cs @@ -5,6 +5,7 @@ using System; using System.Reflection; +using Datadog.Trace.ClrProfiler; using Xunit.Sdk; namespace Datadog.Trace.TestHelpers @@ -14,17 +15,20 @@ public class TracerRestorerAttribute : BeforeAfterTestAttribute { private Tracer _tracer; private TracerManager _tracerManager; + private IDistributedTracer _distributedTracer; public override void Before(MethodInfo methodUnderTest) { _tracer = Tracer.Instance; _tracerManager = _tracer.TracerManager; + _distributedTracer = ClrProfiler.DistributedTracer.Instance; base.Before(methodUnderTest); } public override void After(MethodInfo methodUnderTest) { SetTracer(_tracer, _tracerManager); + ClrProfiler.DistributedTracer.SetInstanceOnlyForTests(_distributedTracer); base.After(methodUnderTest); } diff --git a/tracer/test/Datadog.Trace.Tests/Configuration/ConfigurationSourceTests.cs b/tracer/test/Datadog.Trace.Tests/Configuration/ConfigurationSourceTests.cs index 5cc7459dc..700c71a40 100644 --- a/tracer/test/Datadog.Trace.Tests/Configuration/ConfigurationSourceTests.cs +++ b/tracer/test/Datadog.Trace.Tests/Configuration/ConfigurationSourceTests.cs @@ -54,7 +54,7 @@ public static IEnumerable GetGlobalTestData() public static IEnumerable GetDefaultTestData() { yield return new object[] { CreateFunc(s => s.TraceEnabled), true }; - yield return new object[] { CreateFunc(s => s.AgentUri), new Uri("http://127.0.0.1:9411/api/v2/spans") }; + yield return new object[] { CreateFunc(s => s.ExporterSettings.AgentUri), new Uri("http://127.0.0.1:9411/api/v2/spans") }; yield return new object[] { CreateFunc(s => s.Environment), null }; yield return new object[] { CreateFunc(s => s.ServiceName), null }; yield return new object[] { CreateFunc(s => s.SignalFxAccessToken), null }; @@ -67,7 +67,7 @@ public static IEnumerable GetDefaultTestData() yield return new object[] { CreateFunc(s => s.CustomSamplingRules), null }; yield return new object[] { CreateFunc(s => s.MaxTracesSubmittedPerSecond), 100 }; yield return new object[] { CreateFunc(s => s.TracerMetricsEnabled), false }; - yield return new object[] { CreateFunc(s => s.DogStatsdPort), 8125 }; + yield return new object[] { CreateFunc(s => s.ExporterSettings.DogStatsdPort), 8125 }; yield return new object[] { CreateFunc(s => s.RecordedValueMaxLength), 12000 }; } @@ -76,11 +76,11 @@ public static IEnumerable GetTestData() yield return new object[] { ConfigurationKeys.TraceEnabled, "true", CreateFunc(s => s.TraceEnabled), true }; yield return new object[] { ConfigurationKeys.TraceEnabled, "false", CreateFunc(s => s.TraceEnabled), false }; - yield return new object[] { ConfigurationKeys.AgentHost, "test-host", CreateFunc(s => s.AgentUri), new Uri("http://test-host:9411/api/v2/spans") }; - yield return new object[] { ConfigurationKeys.AgentPort, "9000", CreateFunc(s => s.AgentUri), new Uri("http://127.0.0.1:9000/api/v2/spans") }; + yield return new object[] { ConfigurationKeys.AgentHost, "test-host", CreateFunc(s => s.ExporterSettings.AgentUri), new Uri("http://test-host:9411/api/v2/spans") }; + yield return new object[] { ConfigurationKeys.AgentPort, "9000", CreateFunc(s => s.ExporterSettings.AgentUri), new Uri("http://127.0.0.1:9000/api/v2/spans") }; - yield return new object[] { ConfigurationKeys.EndpointUrl, "http://localhost:9411/api/v2/spans", CreateFunc(s => s.AgentUri), new Uri("http://127.0.0.1:9411/api/v2/spans") }; - yield return new object[] { ConfigurationKeys.EndpointUrl, "https://ingest.realm.sfx.com/v2/trace", CreateFunc(s => s.AgentUri), new Uri("https://ingest.realm.sfx.com/v2/trace") }; + yield return new object[] { ConfigurationKeys.EndpointUrl, "http://localhost:9411/api/v2/spans", CreateFunc(s => s.ExporterSettings.AgentUri), new Uri("http://127.0.0.1:9411/api/v2/spans") }; + yield return new object[] { ConfigurationKeys.EndpointUrl, "https://ingest.realm.sfx.com/v2/trace", CreateFunc(s => s.ExporterSettings.AgentUri), new Uri("https://ingest.realm.sfx.com/v2/trace") }; yield return new object[] { ConfigurationKeys.Environment, "staging", CreateFunc(s => s.Environment), "staging" }; diff --git a/tracer/test/Datadog.Trace.Tests/Configuration/ImmutableExporterSettingsTests.cs b/tracer/test/Datadog.Trace.Tests/Configuration/ImmutableExporterSettingsTests.cs new file mode 100644 index 000000000..446b67a6c --- /dev/null +++ b/tracer/test/Datadog.Trace.Tests/Configuration/ImmutableExporterSettingsTests.cs @@ -0,0 +1,103 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using Datadog.Trace.Configuration; +using FluentAssertions; +using FluentAssertions.Execution; +using Xunit; + +namespace Datadog.Trace.Tests.Configuration +{ + public class ImmutableExporterSettingsTests + { + private const BindingFlags Flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy; + + // These properties are present on ExporterSettings, but not on ImmutableExporterSettings + private static readonly string[] ExcludedProperties = + { + // No exclusions yet + }; + + [Fact] + public void OnlyHasReadOnlyProperties() + { + var type = typeof(ImmutableExporterSettings); + + using var scope = new AssertionScope(); + + var properties = type.GetProperties(Flags); + foreach (var propertyInfo in properties) + { + propertyInfo.CanWrite.Should().BeFalse($"{propertyInfo.Name} should be read only"); + } + + var fields = type.GetFields(Flags); + foreach (var field in fields) + { + field.IsInitOnly.Should().BeTrue($"{field.Name} should be read only"); + } + } + + [Fact] + public void HasSamePropertiesAsExporterSettings() + { + var mutableProperties = typeof(ExporterSettings) + .GetProperties(Flags) + .Select(x => x.Name) + .Where(x => !ExcludedProperties.Contains(x)); + + var immutableProperties = typeof(ImmutableExporterSettings) + .GetProperties(Flags) + .Select(x => x.Name); + + immutableProperties.Should().Contain(mutableProperties); + } + + [Fact] + public void AllPropertyValuesMatch() + { + var equalityCheckers = new List>() + { + (e, i) => e.MetricsPipeName == i.MetricsPipeName, + (e, i) => e.TracesPipeName == i.TracesPipeName, + (e, i) => e.DogStatsdPort == i.DogStatsdPort, + (e, i) => e.MetricsTransport == i.MetricsTransport, + (e, i) => e.MetricsEndpointUrl == i.MetricsEndpointUrl, + (e, i) => e.TracesTransport == i.TracesTransport, + (e, i) => e.TracesPipeTimeoutMs == i.TracesPipeTimeoutMs, + (e, i) => e.AgentUri == i.AgentUri, + (e, i) => e.PartialFlushEnabled == i.PartialFlushEnabled, + (e, i) => e.PartialFlushMinSpans == i.PartialFlushMinSpans, + }; + + var mutableProperties = typeof(ExporterSettings) + .GetProperties(Flags); + + // Ensure that all properties are represented + Assert.Equal(mutableProperties.Count(), equalityCheckers.Count); + + var exporterSettings = new ExporterSettings(); + + exporterSettings.MetricsPipeName = "metricspipe"; + exporterSettings.TracesPipeName = "tracespipe"; + exporterSettings.DogStatsdPort = 1234; + exporterSettings.MetricsTransport = Vendors.StatsdClient.Transport.TransportType.NamedPipe; + exporterSettings.TracesTransport = TracesTransportType.WindowsNamedPipe; + exporterSettings.TracesPipeTimeoutMs = 5556; + exporterSettings.AgentUri = new Uri("http://localhost:8282"); + + var immutableSettings = new ImmutableExporterSettings(exporterSettings); + + foreach (var equalityCheck in equalityCheckers) + { + Assert.True(equalityCheck(exporterSettings, immutableSettings)); + } + } + } +} diff --git a/tracer/test/Datadog.Trace.Tests/Datadog.Trace.Tests.csproj b/tracer/test/Datadog.Trace.Tests/Datadog.Trace.Tests.csproj index 4baef089e..6f9c89757 100644 --- a/tracer/test/Datadog.Trace.Tests/Datadog.Trace.Tests.csproj +++ b/tracer/test/Datadog.Trace.Tests/Datadog.Trace.Tests.csproj @@ -41,8 +41,4 @@ - - - - diff --git a/tracer/test/Datadog.Trace.Tests/DistributedTraceTests.cs b/tracer/test/Datadog.Trace.Tests/DistributedTraceTests.cs index c7213b110..90f42b37f 100644 --- a/tracer/test/Datadog.Trace.Tests/DistributedTraceTests.cs +++ b/tracer/test/Datadog.Trace.Tests/DistributedTraceTests.cs @@ -34,8 +34,9 @@ public void ManuallyDistributedTrace_CarriesExpectedValues() var distributedTraceContext = new SpanContext(traceId, parentSpanId); var secondTracer = TracerHelper.Create(); + var spanCreationSettings = new SpanCreationSettings() { Parent = distributedTraceContext }; - using (var scope = secondTracer.StartActive("manual.trace", parent: distributedTraceContext)) + using (var scope = secondTracer.StartActive("manual.trace", spanCreationSettings)) { scope.Span.SetTag(Tags.SamplingPriority, samplingPriorityText); Assert.True(scope.Span.TraceId == traceId, "Trace ID must match the parent trace."); diff --git a/tracer/test/Datadog.Trace.Tests/DistributedTracer/AutomaticTracerTests.cs b/tracer/test/Datadog.Trace.Tests/DistributedTracer/AutomaticTracerTests.cs new file mode 100644 index 000000000..92b1339f7 --- /dev/null +++ b/tracer/test/Datadog.Trace.Tests/DistributedTracer/AutomaticTracerTests.cs @@ -0,0 +1,125 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +// Modified by Splunk Inc. + +using System; +using Datadog.Trace.ClrProfiler; +using Datadog.Trace.TestHelpers; +using FluentAssertions; +using Moq; +using Xunit; + +namespace Datadog.Trace.Tests.DistributedTracer +{ + [Collection(nameof(TracerInstanceTestCollection))] + [TracerRestorer] + public class AutomaticTracerTests + { + [Fact] + public void GetSpanContext_NoChild() + { + var automaticTracer = new AutomaticTracer(); + + automaticTracer.GetDistributedTrace().Should().BeNull(); + + automaticTracer.SetDistributedTrace(new SpanContext(TraceId.CreateFromInt(1), 2)); + + ((IDistributedTracer)automaticTracer).GetSpanContext().Should().BeNull("automatic tracer shouldn't read the distributed trace unless there is a child tracer"); + } + + [Fact] + public void GetSpanContext() + { + var automaticTracer = new AutomaticTracer(); + automaticTracer.Register(Mock.Of()); + + automaticTracer.GetDistributedTrace().Should().BeNull(); + + var expectedSpanContext = new SpanContext(TraceId.CreateFromInt(1), 2, SamplingPriority.UserKeep, "Service", "Origin"); + + automaticTracer.SetDistributedTrace(expectedSpanContext); + + var actualSpanContext = ((IDistributedTracer)automaticTracer).GetSpanContext(); + + actualSpanContext.Should().BeEquivalentTo(expectedSpanContext); + } + + [Fact] + public void SetSpanContext() + { + var automaticTracer = new AutomaticTracer(); + automaticTracer.Register(Mock.Of()); + + var distributedTracer = (IDistributedTracer)automaticTracer; + var expectedSpanContext = new SpanContext(TraceId.CreateFromInt(1), 2); + + distributedTracer.SetSpanContext(expectedSpanContext); + distributedTracer.GetSpanContext().Should().BeEquivalentTo(expectedSpanContext); + } + + [Fact] + public void SetSamplingPriority_NoChild() + { + var automaticTracer = new AutomaticTracer(); + + ((IDistributedTracer)automaticTracer).SetSamplingPriority(SamplingPriority.UserKeep); + } + + [Fact] + public void SetSamplingPriority() + { + var manualTracer = new Mock(); + + var automaticTracer = new AutomaticTracer(); + automaticTracer.Register(manualTracer.Object); + + ((IDistributedTracer)automaticTracer).SetSamplingPriority(SamplingPriority.UserKeep); + + manualTracer.Verify(t => t.SetSamplingPriority((int?)SamplingPriority.UserKeep), Times.Once); + } + + [Fact] + public void GetDistributedTrace() + { + var automaticTracer = new AutomaticTracer(); + + automaticTracer.GetDistributedTrace().Should().BeNull(); + + var tracer = Tracer.Instance; + using (var scope = tracer.StartActive("Test")) + { + var traceId = automaticTracer.GetDistributedTrace()["trace-id"]; + var spanId = automaticTracer.GetDistributedTrace()["parent-id"]; + + traceId.Should().Be(scope.Span.TraceId.ToString()); + spanId.Should().Be(scope.Span.SpanId.ToString()); + } + + automaticTracer.GetDistributedTrace().Should().BeNull(); + } + + [Fact] + public void RuntimeId() + { + var automaticTracer = new AutomaticTracer(); + + var runtimeId = automaticTracer.GetAutomaticRuntimeId(); + + Guid.TryParse(runtimeId, out _).Should().BeTrue(); + + automaticTracer.GetAutomaticRuntimeId().Should().Be(runtimeId, "runtime id should remain the same"); + + ((IDistributedTracer)automaticTracer).GetRuntimeId().Should().Be(runtimeId, "distributed tracer API should return the same runtime id"); + } + + [Fact] + public void IsChildTracer() + { + var automaticTracer = new AutomaticTracer(); + ((IDistributedTracer)automaticTracer).IsChildTracer.Should().BeFalse(); + } + } +} diff --git a/tracer/test/Datadog.Trace.Tests/DistributedTracer/CommonTracerTests.cs b/tracer/test/Datadog.Trace.Tests/DistributedTracer/CommonTracerTests.cs new file mode 100644 index 000000000..fc636154f --- /dev/null +++ b/tracer/test/Datadog.Trace.Tests/DistributedTracer/CommonTracerTests.cs @@ -0,0 +1,35 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using Datadog.Trace.ClrProfiler; +using Datadog.Trace.TestHelpers; +using FluentAssertions; +using Xunit; + +namespace Datadog.Trace.Tests.DistributedTracer +{ + [Collection(nameof(TracerInstanceTestCollection))] + [TracerRestorer] + public class CommonTracerTests + { + [Fact] + public void SetSamplingPriority() + { + var commonTracer = new CommonTracerImpl(); + + var expectedSamplingPriority = SamplingPriority.UserKeep; + + using var scope = (Scope)Tracer.Instance.StartActive("Test"); + + commonTracer.SetSamplingPriority((int?)expectedSamplingPriority); + + scope.Span.Context.TraceContext.SamplingPriority.Should().Be(expectedSamplingPriority, "SetSamplingPriority should have successfully set the active trace sampling priority"); + } + + private class CommonTracerImpl : CommonTracer + { + } + } +} diff --git a/tracer/test/Datadog.Trace.Tests/DistributedTracer/DistributedTracerRestorerAttribute.cs b/tracer/test/Datadog.Trace.Tests/DistributedTracer/DistributedTracerRestorerAttribute.cs new file mode 100644 index 000000000..833d3c709 --- /dev/null +++ b/tracer/test/Datadog.Trace.Tests/DistributedTracer/DistributedTracerRestorerAttribute.cs @@ -0,0 +1,30 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using System; +using System.Reflection; +using Datadog.Trace.ClrProfiler; +using Xunit.Sdk; + +namespace Datadog.Trace.Tests.DistributedTracer +{ + [AttributeUsage(AttributeTargets.Class, Inherited = true)] + internal class DistributedTracerRestorerAttribute : BeforeAfterTestAttribute + { + private IDistributedTracer _distributedTracer; + + public override void Before(MethodInfo methodUnderTest) + { + _distributedTracer = ClrProfiler.DistributedTracer.Instance; + base.Before(methodUnderTest); + } + + public override void After(MethodInfo methodUnderTest) + { + ClrProfiler.DistributedTracer.SetInstanceOnlyForTests(_distributedTracer); + base.After(methodUnderTest); + } + } +} diff --git a/tracer/test/Datadog.Trace.Tests/DistributedTracer/DistributedTracerTests.cs b/tracer/test/Datadog.Trace.Tests/DistributedTracer/DistributedTracerTests.cs new file mode 100644 index 000000000..ee3b2eb46 --- /dev/null +++ b/tracer/test/Datadog.Trace.Tests/DistributedTracer/DistributedTracerTests.cs @@ -0,0 +1,57 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +// Modified by Splunk Inc. + +using Datadog.Trace.ClrProfiler; +using Datadog.Trace.TestHelpers; +using FluentAssertions; +using Moq; +using Xunit; + +namespace Datadog.Trace.Tests.DistributedTracer +{ + [Collection(nameof(TracerInstanceTestCollection))] + [DistributedTracerRestorer] + [TracerRestorer] + public class DistributedTracerTests + { + [Fact] + public void GetSpanContext() + { + var distributedTracer = new Mock(); + + var spanContext = new SpanContext(TraceId.CreateFromInt(1), 2, SamplingPriority.UserKeep); + + distributedTracer.Setup(t => t.GetSpanContext()).Returns(spanContext); + + ClrProfiler.DistributedTracer.SetInstanceOnlyForTests(distributedTracer.Object); + + using var parentScope = Tracer.Instance.StartActive("Parent"); + + using var scope = (Scope)Tracer.Instance.StartActive("Test"); + + distributedTracer.Verify(t => t.GetSpanContext(), Times.Exactly(2)); + scope.Span.TraceId.Should().Be(spanContext.TraceId); + scope.Span.Context.TraceContext.SamplingPriority.Should().Be(spanContext.SamplingPriority); + } + + [Fact] + public void SetSpanContext() + { + var distributedTracer = new Mock(); + + ClrProfiler.DistributedTracer.SetInstanceOnlyForTests(distributedTracer.Object); + + using (var scope = (Scope)Tracer.Instance.StartActive("Test")) + { + distributedTracer.Verify(t => t.SetSpanContext(scope.Span.Context), Times.Once); + } + + distributedTracer.Verify(t => t.SetSpanContext(null), Times.Once); + distributedTracer.Verify(t => t.SetSpanContext(It.IsAny()), Times.Exactly(2)); + } + } +} diff --git a/tracer/test/Datadog.Trace.Tests/DistributedTracer/ManualTracerTests.cs b/tracer/test/Datadog.Trace.Tests/DistributedTracer/ManualTracerTests.cs new file mode 100644 index 000000000..16078f179 --- /dev/null +++ b/tracer/test/Datadog.Trace.Tests/DistributedTracer/ManualTracerTests.cs @@ -0,0 +1,78 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +// Modified by Splunk Inc. + +using System; +using Datadog.Trace.ClrProfiler; +using FluentAssertions; +using Moq; +using Xunit; + +namespace Datadog.Trace.Tests.DistributedTracer +{ + public class ManualTracerTests + { + [Fact] + public void GetSpanContext() + { + var expectedSpanContext = new SpanContext(TraceId.CreateFromInt(1), 2, SamplingPriority.UserKeep, "Service", "Origin"); + + var automaticTracer = new Mock(); + automaticTracer.Setup(t => t.GetDistributedTrace()).Returns(expectedSpanContext); + + var manualTracer = new ManualTracer(automaticTracer.Object); + + var actualSpanContext = ((IDistributedTracer)manualTracer).GetSpanContext(); + + actualSpanContext.Should().BeEquivalentTo(expectedSpanContext); + } + + [Fact] + public void SetSpanContext() + { + var automaticTracer = new Mock(); + var manualTracer = new ManualTracer(automaticTracer.Object); + + var expectedSpanContext = new SpanContext(TraceId.CreateFromInt(1), 2, SamplingPriority.UserKeep, "Service", "Origin"); + + ((IDistributedTracer)manualTracer).SetSpanContext(expectedSpanContext); + + automaticTracer.Verify(t => t.SetDistributedTrace(expectedSpanContext), Times.Once()); + } + + [Fact] + public void SetSamplingPriority() + { + var automaticTracer = new Mock(); + + var manualTracer = new ManualTracer(automaticTracer.Object); + + ((IDistributedTracer)manualTracer).SetSamplingPriority(SamplingPriority.UserKeep); + + automaticTracer.Verify(t => t.SetSamplingPriority((int?)SamplingPriority.UserKeep), Times.Once()); + } + + [Fact] + public void RuntimeId() + { + var expectedRuntimeId = Guid.NewGuid().ToString(); + + var automaticTracer = new Mock(); + automaticTracer.Setup(t => t.GetAutomaticRuntimeId()).Returns(expectedRuntimeId); + + var manualTracer = new ManualTracer(automaticTracer.Object); + + ((IDistributedTracer)manualTracer).GetRuntimeId().Should().Be(expectedRuntimeId); + } + + [Fact] + public void IsChildTracer() + { + var manualTracer = new ManualTracer(Mock.Of()); + ((IDistributedTracer)manualTracer).IsChildTracer.Should().BeTrue(); + } + } +} diff --git a/tracer/test/Datadog.Trace.Tests/DogStatsDTests.cs b/tracer/test/Datadog.Trace.Tests/DogStatsDTests.cs index f1d50bbaa..d36bcb0f8 100644 --- a/tracer/test/Datadog.Trace.Tests/DogStatsDTests.cs +++ b/tracer/test/Datadog.Trace.Tests/DogStatsDTests.cs @@ -108,7 +108,10 @@ public void Send_metrics_when_enabled() { var settings = new TracerSettings { - AgentUri = new Uri($"http://127.0.0.1:{agent.Port}"), + ExporterSettings = new ExporterSettings() + { + AgentUri = new Uri($"http://127.0.0.1:{agent.Port}"), + }, TracerMetricsEnabled = tracerMetricsEnabled, StartupDiagnosticLogEnabled = false, Exporter = ExporterType.DatadogAgent diff --git a/tracer/test/Datadog.Trace.Tests/ExtensionMethods/SpanExtensionsTests.cs b/tracer/test/Datadog.Trace.Tests/ExtensionMethods/SpanExtensionsTests.cs index 466871f01..e32a41e8e 100644 --- a/tracer/test/Datadog.Trace.Tests/ExtensionMethods/SpanExtensionsTests.cs +++ b/tracer/test/Datadog.Trace.Tests/ExtensionMethods/SpanExtensionsTests.cs @@ -18,7 +18,7 @@ public class SpanExtensionsTests public SpanExtensionsTests() { // Reset the cache - DbCommandCache.Cache = new ConcurrentDictionary[]>(); + DbCommandCache.Cache = new(); } [Theory] @@ -34,26 +34,10 @@ public void ExtractProperTagsFromConnectionString( var spanContext = new SpanContext(Mock.Of(), Mock.Of(), "test"); var span = new Span(spanContext, null); - span.AddTagsFromDbCommand(CreateDbCommand(connectionString)); - - Assert.Equal(expectedDbName, span.GetTag(Tags.DbName)); - Assert.Equal(expectedUserId, span.GetTag(Tags.DbUser)); - Assert.Equal(expectedHost, span.GetTag(Tags.OutHost)); - } - - [Fact] - public void SetSpanTypeToSql() - { - const string connectionString = "Server=myServerName;Database=myDataBase;User Id=myUsername;Password=myPassword;"; - const string commandText = "SELECT * FROM Table ORDER BY id"; - - var spanContext = new SpanContext(Mock.Of(), Mock.Of(), "test"); - var span = new Span(spanContext, null); - - span.AddTagsFromDbCommand(CreateDbCommand(connectionString, commandText)); - - Assert.Equal(SpanTypes.Sql, span.Type); - Assert.Equal(commandText, span.ResourceName); + var commandTags = DbCommandCache.GetTagsFromDbCommand(CreateDbCommand(connectionString)); + Assert.Equal(expectedDbName, commandTags.DbName); + Assert.Equal(expectedUserId, commandTags.DbUser); + Assert.Equal(expectedHost, commandTags.OutHost); } [Fact] @@ -83,10 +67,10 @@ public void ShouldDisableCacheIfTooManyConnectionStrings() { var connectionString = string.Format(connectionStringTemplate, i); - span.AddTagsFromDbCommand(CreateDbCommand(connectionString)); + var commandTags = DbCommandCache.GetTagsFromDbCommand(CreateDbCommand(connectionString)); Assert.NotNull(DbCommandCache.Cache); - Assert.Equal("myServerName" + i, span.GetTag(Tags.OutHost)); + Assert.Equal("myServerName" + i, commandTags.OutHost); } // Test the logic with cache disabled @@ -94,10 +78,10 @@ public void ShouldDisableCacheIfTooManyConnectionStrings() { var connectionString = string.Format(connectionStringTemplate, "NoCache" + i); - span.AddTagsFromDbCommand(CreateDbCommand(connectionString)); + var commandTags = DbCommandCache.GetTagsFromDbCommand(CreateDbCommand(connectionString)); Assert.Null(DbCommandCache.Cache); - Assert.Equal("myServerName" + "NoCache" + i, span.GetTag(Tags.OutHost)); + Assert.Equal("myServerName" + "NoCache" + i, commandTags.OutHost); } } diff --git a/tracer/test/Datadog.Trace.Tests/Headers/DDHeadersCollectionTests.cs b/tracer/test/Datadog.Trace.Tests/Headers/DDHeadersCollectionTests.cs index a9719d648..fd2d412f0 100644 --- a/tracer/test/Datadog.Trace.Tests/Headers/DDHeadersCollectionTests.cs +++ b/tracer/test/Datadog.Trace.Tests/Headers/DDHeadersCollectionTests.cs @@ -3,6 +3,8 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // +// Modified by Splunk Inc. + using System.Collections.Generic; using System.Globalization; using Datadog.Trace.Conventions; diff --git a/tracer/test/Datadog.Trace.Tests/Logging/LoggingProviderTestHelpers.cs b/tracer/test/Datadog.Trace.Tests/Logging/LoggingProviderTestHelpers.cs index 6104b2b64..c4aa5d0d0 100644 --- a/tracer/test/Datadog.Trace.Tests/Logging/LoggingProviderTestHelpers.cs +++ b/tracer/test/Datadog.Trace.Tests/Logging/LoggingProviderTestHelpers.cs @@ -31,10 +31,11 @@ internal static Tracer InitializeTracer(bool enableLogsInjection) return new Tracer(settings, writerMock.Object, samplerMock.Object, scopeManager: null, statsd: null); } - internal static void LogInSpanWithServiceName(Tracer tracer, ILog logger, Func openMappedContext, string service, out Scope scope) + internal static void LogInSpanWithServiceName(Tracer tracer, ILog logger, Func openMappedContext, string service, out IScope scope) { - using (scope = tracer.StartActive("span", serviceName: service)) + using (scope = tracer.StartActive("span")) { + scope.Span.ServiceName = service; using (var mappedContext = openMappedContext(CustomPropertyName, CustomPropertyValue, false)) { logger.Log(LogLevel.Info, () => $"{LogPrefix}Entered single scope with a different service name."); @@ -42,7 +43,7 @@ internal static void LogInSpanWithServiceName(Tracer tracer, ILog logger, Func openMappedContext, out Scope parentScope, out Scope childScope) + internal static void LogInParentSpan(Tracer tracer, ILog logger, Func openMappedContext, out IScope parentScope, out IScope childScope) { using (parentScope = tracer.StartActive("parent")) { @@ -60,7 +61,7 @@ internal static void LogInParentSpan(Tracer tracer, ILog logger, Func openMappedContext, out Scope parentScope, out Scope childScope) + internal static void LogInChildSpan(Tracer tracer, ILog logger, Func openMappedContext, out IScope parentScope, out IScope childScope) { using (parentScope = tracer.StartActive("parent")) { @@ -74,7 +75,7 @@ internal static void LogInChildSpan(Tracer tracer, ILog logger, Func openMappedContext, out Scope parentScope, out Scope childScope) + internal static void LogOutsideSpans(Tracer tracer, ILog logger, Func openMappedContext, out IScope parentScope, out IScope childScope) { logger.Log(LogLevel.Info, () => $"{LogPrefix}Logged before starting/activating a scope"); @@ -92,7 +93,7 @@ internal static void LogOutsideSpans(Tracer tracer, ILog logger, Func $"{LogPrefix}Closed child scope so there is no active scope."); } - internal static void LogEverywhere(Tracer tracer, ILog logger, Func openMappedContext, out Scope parentScope, out Scope childScope) + internal static void LogEverywhere(Tracer tracer, ILog logger, Func openMappedContext, out IScope parentScope, out IScope childScope) { logger.Log(LogLevel.Info, () => $"{LogPrefix}Logged before starting/activating a scope"); diff --git a/tracer/test/Datadog.Trace.Tests/Logging/NLogLogProviderTests.cs b/tracer/test/Datadog.Trace.Tests/Logging/NLogLogProviderTests.cs index 0612a2ab7..a97f298f0 100644 --- a/tracer/test/Datadog.Trace.Tests/Logging/NLogLogProviderTests.cs +++ b/tracer/test/Datadog.Trace.Tests/Logging/NLogLogProviderTests.cs @@ -20,7 +20,7 @@ public class NLogLogProviderTests { private const string NLogExpectedStringFormat = "\"{0}\": \"{1}\""; - private readonly CustomNLogLogProvider _logProvider; + private readonly ILogProvider _logProvider; private readonly ILog _logger; private readonly MemoryTarget _target; @@ -42,100 +42,29 @@ public NLogLogProviderTests() LogManager.Configuration = config; SimpleConfigurator.ConfigureForTargetLogging(_target, NLog.LogLevel.Trace); - _logProvider = new CustomNLogLogProvider(); + _logProvider = new NoOpNLogLogProvider(); LogProvider.SetCurrentLogProvider(_logProvider); _logger = new LoggerExecutionWrapper(_logProvider.GetLogger("test")); } - [Fact] - public void LogsInjectionEnabledAddsParentCorrelationIdentifiers() + [Theory] + [InlineData(false)] + [InlineData(true)] + public void DoesNotAddCorrelationIdentifiers(bool enableLogsInjection) { // Assert that the NLog log provider is correctly being used - Assert.IsType(LogProvider.CurrentLogProvider); + Assert.IsType(LogProvider.CurrentLogProvider); - // Instantiate a tracer for this test with default settings and set LogsInjectionEnabled to TRUE - var tracer = LoggingProviderTestHelpers.InitializeTracer(enableLogsInjection: true); - LoggingProviderTestHelpers.LogInParentSpan(tracer, _logger, _logProvider.OpenMappedContext, out var parentScope, out var childScope); - - // Filter the logs - List filteredLogs = new List(_target.Logs); - filteredLogs.RemoveAll(log => !log.Contains(LoggingProviderTestHelpers.LogPrefix)); - Assert.All(filteredLogs, e => LogEventContains(e, tracer.DefaultServiceName, tracer.Settings.ServiceVersion, tracer.Settings.Environment, parentScope)); - } - - [Fact] - public void LogsInjectionEnabledAddsChildCorrelationIdentifiers() - { - // Assert that the NLog log provider is correctly being used - Assert.IsType(LogProvider.CurrentLogProvider); - - // Instantiate a tracer for this test with default settings and set LogsInjectionEnabled to TRUE - var tracer = LoggingProviderTestHelpers.InitializeTracer(enableLogsInjection: true); - LoggingProviderTestHelpers.LogInChildSpan(tracer, _logger, _logProvider.OpenMappedContext, out var parentScope, out var childScope); - - // Filter the logs - List filteredLogs = new List(_target.Logs); - filteredLogs.RemoveAll(log => !log.Contains(LoggingProviderTestHelpers.LogPrefix)); - Assert.All(filteredLogs, e => LogEventContains(e, tracer.DefaultServiceName, tracer.Settings.ServiceVersion, tracer.Settings.Environment, childScope)); - } - - [Fact] - public void LogsInjectionEnabledDoesNotAddCorrelationIdentifiersOutsideSpans() - { - // Assert that the NLog log provider is correctly being used - Assert.IsType(LogProvider.CurrentLogProvider); - - // Instantiate a tracer for this test with default settings and set LogsInjectionEnabled to TRUE - var tracer = LoggingProviderTestHelpers.InitializeTracer(enableLogsInjection: true); - LoggingProviderTestHelpers.LogOutsideSpans(tracer, _logger, _logProvider.OpenMappedContext, out var parentScope, out var childScope); - - // Filter the logs - List filteredLogs = new List(_target.Logs); - filteredLogs.RemoveAll(log => !log.Contains(LoggingProviderTestHelpers.LogPrefix)); - Assert.All(filteredLogs, e => LogEventDoesNotContainCorrelationIdentifiers(e)); - } - - [Fact] - public void LogsInjectionEnabledUsesTracerServiceName() - { - // Assert that the NLog log provider is correctly being used - Assert.IsType(LogProvider.CurrentLogProvider); - - // Instantiate a tracer for this test with default settings and set LogsInjectionEnabled to TRUE - var tracer = LoggingProviderTestHelpers.InitializeTracer(enableLogsInjection: true); - LoggingProviderTestHelpers.LogInSpanWithServiceName(tracer, _logger, _logProvider.OpenMappedContext, "custom-service", out var scope); - - // Filter the logs - List filteredLogs = new List(_target.Logs); - filteredLogs.RemoveAll(log => !log.Contains(LoggingProviderTestHelpers.LogPrefix)); - Assert.All(filteredLogs, e => LogEventContains(e, tracer.DefaultServiceName, tracer.Settings.ServiceVersion, tracer.Settings.Environment, scope)); - } - - [Fact] - public void DisabledLibLogSubscriberDoesNotAddCorrelationIdentifiers() - { - // Assert that the NLog log provider is correctly being used - Assert.IsType(LogProvider.CurrentLogProvider); - - // Instantiate a tracer for this test with default settings and set LogsInjectionEnabled to TRUE - var tracer = LoggingProviderTestHelpers.InitializeTracer(enableLogsInjection: false); + // Instantiate a tracer for this test with default settings and set LogsInjectionEnabled to the test case value + var tracer = LoggingProviderTestHelpers.InitializeTracer(enableLogsInjection); LoggingProviderTestHelpers.LogEverywhere(tracer, _logger, _logProvider.OpenMappedContext, out var parentScope, out var childScope); // Filter the logs List filteredLogs = new List(_target.Logs); - filteredLogs.RemoveAll(log => !log.Contains(LoggingProviderTestHelpers.LogPrefix)); + filteredLogs.RemoveAll(log => !log.ToString().Contains(LoggingProviderTestHelpers.LogPrefix)); Assert.All(filteredLogs, e => LogEventDoesNotContainCorrelationIdentifiers(e)); } - internal static void LogEventContains(string nLogString, string service, string version, string env, Scope scope) - { - Assert.Contains(string.Format(NLogExpectedStringFormat, CorrelationIdentifier.ServiceKey, service), nLogString); - Assert.Contains(string.Format(NLogExpectedStringFormat, CorrelationIdentifier.EnvKey, env), nLogString); - Assert.Contains(string.Format(NLogExpectedStringFormat, CorrelationIdentifier.VersionKey, version), nLogString); - Assert.Contains(string.Format(NLogExpectedStringFormat, CorrelationIdentifier.SpanIdKey, scope.Span.SpanId), nLogString); - Assert.Contains(string.Format(NLogExpectedStringFormat, CorrelationIdentifier.TraceIdKey, scope.Span.TraceId), nLogString); - } - internal static void LogEventDoesNotContainCorrelationIdentifiers(string nLogString) { // Do not assert on the service property diff --git a/tracer/test/Datadog.Trace.Tests/Logging/SerilogDuckTypeTests.cs b/tracer/test/Datadog.Trace.Tests/Logging/SerilogDuckTypeTests.cs new file mode 100644 index 000000000..0c03d4e4a --- /dev/null +++ b/tracer/test/Datadog.Trace.Tests/Logging/SerilogDuckTypeTests.cs @@ -0,0 +1,55 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using System; +using System.Collections.Generic; +using System.Linq; +using Datadog.Trace.ClrProfiler.AutoInstrumentation.Logging.Serilog.LogsInjection; +using Datadog.Trace.DuckTyping; +using FluentAssertions; +using Serilog.Events; +using Xunit; + +namespace Datadog.Trace.Tests.Logging +{ + public class SerilogDuckTypeTests + { + [Fact] + public void CanCreateLogPropertyValueWithHelper() + { + var value = "test_value"; + var logPropertyValue = SerilogLogPropertyHelper.CreateScalarValue(value); + + logPropertyValue.Should() + .NotBeNull() + .And.BeOfType() + .Subject.Value.Should() + .BeOfType() + .And + .Be(value); + } + + [Fact] + public void CanDuckTypeLogEvent() + { + var logEvent = new LogEvent( + DateTimeOffset.Now, + LogEventLevel.Error, + exception: null, + MessageTemplate.Empty, + properties: Enumerable.Empty()); + var proxy = logEvent.DuckCast(); + + proxy.Properties.Should().NotBeNull(); + proxy.Properties.Should().BeEmpty(); + + logEvent.AddPropertyIfAbsent(new LogEventProperty("key", new ScalarValue("value"))); + + // String values are rendered with quotes unless the ':l formatter is used. + // Since we can't enforce a format with object.ToString(), assert the result with surrounding quotes + proxy.Properties["key"].ToString().Should().BeEquivalentTo("\"value\""); + } + } +} diff --git a/tracer/test/Datadog.Trace.Tests/Logging/SerilogLogProviderTests.cs b/tracer/test/Datadog.Trace.Tests/Logging/SerilogLogProviderTests.cs index 1bacdee42..1bc6bae9f 100644 --- a/tracer/test/Datadog.Trace.Tests/Logging/SerilogLogProviderTests.cs +++ b/tracer/test/Datadog.Trace.Tests/Logging/SerilogLogProviderTests.cs @@ -7,7 +7,6 @@ using System; using System.Collections.Generic; -using System.Threading; using System.Threading.Tasks; using Datadog.Trace.Logging; using Serilog; @@ -31,79 +30,21 @@ public SerilogLogProviderTests() .CreateLogger(); _logEvents = new List(); - _logProvider = new CustomSerilogLogProvider(); + _logProvider = new NoOpSerilogLogProvider(); LogProvider.SetCurrentLogProvider(_logProvider); _logger = new LoggerExecutionWrapper(_logProvider.GetLogger("Test")); } - [Fact] - public void LogsInjectionEnabledAddsParentCorrelationIdentifiers() + [Theory] + [InlineData(false)] + [InlineData(true)] + public void DoesNotAddCorrelationIdentifiers(bool enableLogsInjection) { // Assert that the Serilog log provider is correctly being used - Assert.IsType(LogProvider.CurrentLogProvider); + Assert.IsType(LogProvider.CurrentLogProvider); // Instantiate a tracer for this test with default settings and set LogsInjectionEnabled to TRUE - var tracer = LoggingProviderTestHelpers.InitializeTracer(enableLogsInjection: true); - LoggingProviderTestHelpers.LogInParentSpan(tracer, _logger, _logProvider.OpenMappedContext, out var parentScope, out var childScope); - - // Filter the logs - _logEvents.RemoveAll(log => !log.MessageTemplate.ToString().Contains(LoggingProviderTestHelpers.LogPrefix)); - Assert.All(_logEvents, e => LogEventContains(e, tracer.DefaultServiceName, tracer.Settings.ServiceVersion, tracer.Settings.Environment, parentScope)); - } - - [Fact] - public void LogsInjectionEnabledAddsChildCorrelationIdentifiers() - { - // Assert that the Serilog log provider is correctly being used - Assert.IsType(LogProvider.CurrentLogProvider); - - // Instantiate a tracer for this test with default settings and set LogsInjectionEnabled to TRUE - var tracer = LoggingProviderTestHelpers.InitializeTracer(enableLogsInjection: true); - LoggingProviderTestHelpers.LogInChildSpan(tracer, _logger, _logProvider.OpenMappedContext, out var parentScope, out var childScope); - - // Filter the logs - _logEvents.RemoveAll(log => !log.MessageTemplate.ToString().Contains(LoggingProviderTestHelpers.LogPrefix)); - Assert.All(_logEvents, e => LogEventContains(e, tracer.DefaultServiceName, tracer.Settings.ServiceVersion, tracer.Settings.Environment, childScope)); - } - - [Fact] - public void LogsInjectionEnabledDoesNotAddCorrelationIdentifiersOutsideSpans() - { - // Assert that the Serilog log provider is correctly being used - Assert.IsType(LogProvider.CurrentLogProvider); - - // Instantiate a tracer for this test with default settings and set LogsInjectionEnabled to TRUE - var tracer = LoggingProviderTestHelpers.InitializeTracer(enableLogsInjection: true); - LoggingProviderTestHelpers.LogOutsideSpans(tracer, _logger, _logProvider.OpenMappedContext, out var parentScope, out var childScope); - - // Filter the logs - _logEvents.RemoveAll(log => !log.MessageTemplate.ToString().Contains(LoggingProviderTestHelpers.LogPrefix)); - Assert.All(_logEvents, e => LogEventDoesNotContainCorrelationIdentifiers(e)); - } - - [Fact] - public void LogsInjectionEnabledUsesTracerServiceName() - { - // Assert that the Serilog log provider is correctly being used - Assert.IsType(LogProvider.CurrentLogProvider); - - // Instantiate a tracer for this test with default settings and set LogsInjectionEnabled to TRUE - var tracer = LoggingProviderTestHelpers.InitializeTracer(enableLogsInjection: true); - LoggingProviderTestHelpers.LogInSpanWithServiceName(tracer, _logger, _logProvider.OpenMappedContext, "custom-service", out var scope); - - // Filter the logs - _logEvents.RemoveAll(log => !log.MessageTemplate.ToString().Contains(LoggingProviderTestHelpers.LogPrefix)); - Assert.All(_logEvents, e => LogEventContains(e, tracer.DefaultServiceName, tracer.Settings.ServiceVersion, tracer.Settings.Environment, scope)); - } - - [Fact] - public void DisabledLibLogSubscriberDoesNotAddCorrelationIdentifiers() - { - // Assert that the Serilog log provider is correctly being used - Assert.IsType(LogProvider.CurrentLogProvider); - - // Instantiate a tracer for this test with default settings and set LogsInjectionEnabled to FALSE - var tracer = LoggingProviderTestHelpers.InitializeTracer(enableLogsInjection: false); + var tracer = LoggingProviderTestHelpers.InitializeTracer(enableLogsInjection); LoggingProviderTestHelpers.LogEverywhere(tracer, _logger, _logProvider.OpenMappedContext, out var parentScope, out var childScope); // Filter the logs @@ -111,61 +52,6 @@ public void DisabledLibLogSubscriberDoesNotAddCorrelationIdentifiers() Assert.All(_logEvents, e => LogEventDoesNotContainCorrelationIdentifiers(e)); } - [Fact] - public void LogTheRightSpan() - { - // Assert that the Serilog log provider is correctly being used - Assert.IsType(LogProvider.CurrentLogProvider); - - // Instantiate a tracer for this test with default settings and set LogsInjectionEnabled to TRUE - var tracer = LoggingProviderTestHelpers.InitializeTracer(enableLogsInjection: true); - - var barrier1 = new Barrier(2); - var barrier2 = new Barrier(2); - - var task1 = Task.Run(() => Thread1(barrier1, tracer)); - barrier1.SignalAndWait(); // Wait until thread1 has created both scopes - - var task2 = Task.Run(() => Thread2(barrier2, tracer)); - barrier2.SignalAndWait(); // Wait until thread2 has created both scopes - - // Both threads have created a span - - barrier1.SignalAndWait(); // Release thread1 - barrier1.SignalAndWait(); // Wait until thread1 has disposed the inner scope - - // Thread1 has disposed the inner span, outer span is still open - - barrier2.SignalAndWait(); // Release thread2 - // Thread2 closes the inner span. If the interleaved operations had no wrong effect, - // the first log should have a span and the second log shouldn't - task2.Wait(); - - // Unblock the first thread - barrier1.SignalAndWait(); - task1.Wait(); - - Assert.Equal(2, _logEvents.Count); - - var spanLog = _logEvents[0]; - - Assert.StartsWith("Span", spanLog.MessageTemplate.Text); - Assert.Equal(5, spanLog.Properties.Count); - - var expectedSpanId = spanLog.MessageTemplate.Text.Split('-')[1]; - var spanProperty = spanLog.Properties[CorrelationIdentifier.SpanIdKey]; - Assert.Equal(expectedSpanId, spanProperty.ToString().Trim('\"')); - - var noSpanLog = _logEvents[1]; - Assert.StartsWith("NoSpan", noSpanLog.MessageTemplate.ToString()); - Assert.Empty(noSpanLog.Properties); - } - - internal static void LogEventContains(Serilog.Events.LogEvent logEvent, string service, string version, string env, Scope scope) - { - Contains(logEvent, service, version, env, scope.Span.TraceId, scope.Span.SpanId); - } - internal static void Contains(Serilog.Events.LogEvent logEvent, string service, string version, string env, TraceId traceId, ulong spanId) { Assert.True(logEvent.Properties.ContainsKey(CorrelationIdentifier.SerilogServiceKey)); @@ -191,36 +77,5 @@ internal static void LogEventDoesNotContainCorrelationIdentifiers(Serilog.Events Assert.False(logEvent.Properties.ContainsKey(CorrelationIdentifier.SpanIdKey)); Assert.False(logEvent.Properties.ContainsKey(CorrelationIdentifier.TraceIdKey)); } - - private static void Thread1(Barrier barrier, Tracer tracer) - { - using (tracer.StartActive("Outer")) - { - using (tracer.StartActive("Inner")) - { - barrier.SignalAndWait(); - barrier.SignalAndWait(); - } - - barrier.SignalAndWait(); - barrier.SignalAndWait(); - } - } - - private static void Thread2(Barrier barrier, Tracer tracer) - { - using (var outerScope = tracer.StartActive("Outer")) - { - using (tracer.StartActive("Inner")) - { - barrier.SignalAndWait(); - barrier.SignalAndWait(); - } - - Log.Information("Span-" + outerScope.Span.SpanId); - } - - Log.Information("NoSpan"); - } } } diff --git a/tracer/test/Datadog.Trace.Tests/PlatformHelpers/AzureAppServicesMetadataTests.cs b/tracer/test/Datadog.Trace.Tests/PlatformHelpers/AzureAppServicesMetadataTests.cs index bd65608d0..29be47189 100644 --- a/tracer/test/Datadog.Trace.Tests/PlatformHelpers/AzureAppServicesMetadataTests.cs +++ b/tracer/test/Datadog.Trace.Tests/PlatformHelpers/AzureAppServicesMetadataTests.cs @@ -18,9 +18,12 @@ namespace Datadog.Trace.Tests.PlatformHelpers { [CollectionDefinition(nameof(AzureAppServicesMetadataTests), DisableParallelization = true)] + [Collection(nameof(AzureAppServicesMetadataTests))] [AzureAppServicesRestorer] public class AzureAppServicesMetadataTests { + internal static readonly string DeploymentId = "AzureExampleSiteName"; + private const string AppServiceKind = "app"; private const string AppServiceType = "app"; private const string FunctionKind = "functionapp"; @@ -36,7 +39,6 @@ public class AzureAppServicesMetadataTests private static readonly string SubscriptionId = "8c500027-5f00-400e-8f00-60000000000f"; private static readonly string PlanResourceGroup = "apm-dotnet"; - private static readonly string DeploymentId = "AzureExampleSiteName"; private static readonly string SiteResourceGroup = "apm-dotnet-site-resource-group"; private static readonly string ExpectedResourceId = $"/subscriptions/{SubscriptionId}/resourcegroups/{SiteResourceGroup}/providers/microsoft.web/sites/{DeploymentId}".ToLowerInvariant(); @@ -151,8 +153,8 @@ public void PopulatesOnlyRootSpans() var vars = GetMockVariables(SubscriptionId, DeploymentId, PlanResourceGroup, SiteResourceGroup); AzureAppServices.Metadata = new AzureAppServices(vars); var tracer = TracerHelper.Create(); - var rootSpans = new List(); - var nonRootSpans = new List(); + var rootSpans = new List(); + var nonRootSpans = new List(); var iterations = 5; var remaining = iterations; diff --git a/tracer/test/Datadog.Trace.Tests/PublicApiTests.cs b/tracer/test/Datadog.Trace.Tests/PublicApiTests.cs index 3f620c0a3..627072f06 100644 --- a/tracer/test/Datadog.Trace.Tests/PublicApiTests.cs +++ b/tracer/test/Datadog.Trace.Tests/PublicApiTests.cs @@ -3,123 +3,12 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // -using System; -using System.ComponentModel; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.Versioning; -using FluentAssertions; -using PublicApiGenerator; -using Xunit; - namespace Datadog.Trace.Tests { - public class PublicApiTests + public class PublicApiTests : PublicApiTestsBase { - private static readonly ApiGeneratorOptions ApiGeneratorOptions = new ApiGeneratorOptions - { - ExcludeAttributes = new[] { typeof(InternalsVisibleToAttribute).FullName, }, - }; - - [Fact(Skip = "OTel doesn't have a published public API")] - public void PublicApiHasNotChanged() - { - var assembly = typeof(Tracer).Assembly; - var browsableTypes = assembly.GetTypes().Where(type => !HasHideInIntellisenseAttributes(type)).ToArray(); - var publicApi = browsableTypes.GeneratePublicApi(ApiGeneratorOptions); - - // we will have a slightly different public API for net4x vs netcore - var attribute = (TargetFrameworkAttribute)assembly.GetCustomAttribute(typeof(TargetFrameworkAttribute)); - - // remove the differences between the lines - publicApi = publicApi.Replace( - $@"[assembly: System.Runtime.Versioning.TargetFramework(""{attribute.FrameworkName}"", FrameworkDisplayName=""{attribute.FrameworkDisplayName}"")]", - string.Empty); - - var expected = GetExpected(publicApi); - - publicApi.Should().Be(expected, "Public API should match the verified API. Update verified snapshot when the public API changes as appropriate"); - } - - [Theory] - [InlineData(typeof(Hidden), true)] - [InlineData(typeof(NotHidden1), false)] - [InlineData(typeof(NotHidden2), false)] - [InlineData(typeof(NotHidden3), false)] - [InlineData(typeof(NotHidden4), false)] - [InlineData(typeof(NotHidden5), false)] - [InlineData(typeof(NotHidden6), false)] - public void CalculatesHiddenCorrectly(Type type, bool isHidden) - { - var actual = HasHideInIntellisenseAttributes(type); - actual.Should().Be(isHidden); - } - - private static bool HasHideInIntellisenseAttributes(Type type) - { - var browsable = type.GetCustomAttribute(); - if (browsable is null || browsable.Browsable) - { - return false; - } - - var editorBrowsable = type.GetCustomAttribute(); - if (editorBrowsable is null || editorBrowsable.State != EditorBrowsableState.Never) - { - return false; - } - - return true; - } - - private static string GetExpected(string publicApi, [CallerMemberName] string methodName = null, [CallerFilePath] string filePath = null) - { - // poor-man's VerifyTests.Verify, because Verify has incompatible dependencies with ASP.NET Core - var snapshotDirectory = Path.Combine(Directory.GetParent(filePath).FullName, "Snapshots"); - var receivedPath = Path.Combine(snapshotDirectory, $"PublicApiTests.{methodName}.received.txt"); - var verifiedPath = Path.Combine(snapshotDirectory, $"PublicApiTests.{methodName}.verified.txt"); - - File.WriteAllText(receivedPath, publicApi); - return File.Exists(verifiedPath) ? File.ReadAllText(verifiedPath) : string.Empty; - } - - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public class Hidden - { - } - - [Browsable(true)] - [EditorBrowsable(EditorBrowsableState.Never)] - public class NotHidden1 - { - } - - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Advanced)] - public class NotHidden2 - { - } - - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Always)] - public class NotHidden3 - { - } - - [Browsable(false)] - public class NotHidden4 - { - } - - [EditorBrowsable(EditorBrowsableState.Never)] - public class NotHidden5 - { - } - - public class NotHidden6 + public PublicApiTests() + : base(typeof(Tracer).Assembly) { } } diff --git a/tracer/test/Datadog.Trace.Tests/Snapshots/PublicApiTests.PublicApiHasNotChanged.verified.txt b/tracer/test/Datadog.Trace.Tests/Snapshots/PublicApiTests.PublicApiHasNotChanged.verified.txt index c0e6c6a6d..49ed154b2 100644 --- a/tracer/test/Datadog.Trace.Tests/Snapshots/PublicApiTests.PublicApiHasNotChanged.verified.txt +++ b/tracer/test/Datadog.Trace.Tests/Snapshots/PublicApiTests.PublicApiHasNotChanged.verified.txt @@ -1,4 +1,4 @@ -[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/DataDog/dd-trace-dotnet.git")] +[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/signalfx/signalfx-dotnet-tracing.git")] namespace Datadog.Trace.Configuration { @@ -14,80 +14,43 @@ namespace Datadog.Trace.Configuration public string GetString(string key) { } public void Insert(int index, Datadog.Trace.Configuration.IConfigurationSource item) { } } - public static class ConfigurationKeys - { - public const string AgentHost = "SIGNALFX_AGENT_HOST"; - public const string AgentPort = "SIGNALFX_TRACE_AGENT_PORT"; - public const string AgentUri = "SIGNALFX_TRACE_AGENT_URL"; - public const string AppSecBlockingEnabled = "SIGNALFX_APPSEC_BLOCKING_ENABLED"; - public const string AppSecCustomIpHeader = "SIGNALFX_APPSEC_IPHEADER"; - public const string AppSecEnabled = "SIGNALFX_APPSEC_ENABLED"; - public const string AppSecExtraHeaders = "SIGNALFX_APPSEC_EXTRA_HEADERS"; - public const string AppSecRules = "SIGNALFX_APPSEC_RULES"; - public const string BufferSize = "SIGNALFX_TRACE_BUFFER_SIZE"; - public const string CIVisibilityEnabled = "SIGNALFX_CIVISIBILITY_ENABLED"; - public const string ConfigurationFileName = "SIGNALFX_TRACE_CONFIG_FILE"; - public const string CustomSamplingRules = "SIGNALFX_TRACE_SAMPLING_RULES"; - public const string DebugEnabled = "SIGNALFX_TRACE_DEBUG"; - public const string DiagnosticSourceEnabled = "SIGNALFX_DIAGNOSTIC_SOURCE_ENABLED"; - public const string DisabledIntegrations = "SIGNALFX_DISABLED_INTEGRATIONS"; - public const string DogStatsDArgs = "SIGNALFX_DOGSTATSD_ARGS"; - public const string DogStatsDPath = "SIGNALFX_DOGSTATSD_PATH"; - public const string DogStatsdPort = "SIGNALFX_DOGSTATSD_PORT"; - public const string Environment = "SIGNALFX_ENV"; - [System.Obsolete("App Analytics has been replaced by Tracing without Limits. For more information s" + - "ee https://docs.datadoghq.com/tracing/legacy_app_analytics/")] - public const string GlobalAnalyticsEnabled = "SIGNALFX_TRACE_ANALYTICS_ENABLED"; - public const string GlobalSamplingRate = "SIGNALFX_TRACE_SAMPLE_RATE"; - public const string GlobalTags = "SIGNALFX_TAGS"; - public const string HeaderTags = "SIGNALFX_TRACE_HEADER_TAGS"; - public const string HttpClientErrorStatusCodes = "SIGNALFX_HTTP_CLIENT_ERROR_STATUSES"; - public const string HttpClientExcludedUrlSubstrings = "SIGNALFX_TRACE_HTTP_CLIENT_EXCLUDED_URL_SUBSTRINGS"; - public const string HttpServerErrorStatusCodes = "SIGNALFX_HTTP_SERVER_ERROR_STATUSES"; - public const string KafkaCreateConsumerScopeEnabled = "SIGNALFX_TRACE_KAFKA_CREATE_CONSUMER_SCOPE_ENABLED"; - public const string LogDirectory = "SIGNALFX_TRACE_LOG_DIRECTORY"; - public const string LogRateLimit = "SIGNALFX_TRACE_LOGGING_RATE"; - public const string LogsInjectionEnabled = "SIGNALFX_LOGS_INJECTION"; - public const string MaxLogFileSize = "SIGNALFX_MAX_LOGFILE_SIZE"; - public const string MaxTracesSubmittedPerSecond = "SIGNALFX_MAX_TRACES_PER_SECOND"; - public const string MetricsPipeName = "SIGNALFX_DOGSTATSD_PIPE_NAME"; - public const string PartialFlushEnabled = "SIGNALFX_TRACE_PARTIAL_FLUSH_ENABLED"; - public const string PartialFlushMinSpans = "SIGNALFX_TRACE_PARTIAL_FLUSH_MIN_SPANS"; - [System.Obsolete("SIGNALFX_TRACE_LOG_PATH is deprecated. Use SIGNALFX_TRACE_LOG_DIRECTORY instead")] - public const string ProfilerLogPath = "SIGNALFX_TRACE_LOG_PATH"; - public const string RuntimeMetricsEnabled = "SIGNALFX_RUNTIME_METRICS_ENABLED"; - public const string SerializationBatchInterval = "SIGNALFX_TRACE_BATCH_INTERVAL"; - public const string ServiceName = "SIGNALFX_SERVICE_NAME"; - public const string ServiceNameMappings = "SIGNALFX_TRACE_SERVICE_MAPPING"; - public const string ServiceVersion = "SIGNALFX_VERSION"; - public const string StartupDiagnosticLogEnabled = "SIGNALFX_TRACE_STARTUP_LOGS"; - public const string TraceAgentArgs = "SIGNALFX_TRACE_AGENT_ARGS"; - public const string TraceAgentPath = "SIGNALFX_TRACE_AGENT_PATH"; - public const string TraceAgentPortKey = "SIGNALFX_APM_RECEIVER_PORT"; - public const string TraceEnabled = "SIGNALFX_TRACE_ENABLED"; - public const string TracerMetricsEnabled = "SIGNALFX_TRACE_METRICS_ENABLED"; - public const string TracesPipeName = "SIGNALFX_TRACE_PIPE_NAME"; - public const string TracesPipeTimeoutMs = "SIGNALFX_TRACE_PIPE_TIMEOUT_MS"; - public const string TracesTransport = "SIGNALFX_TRACE_TRANSPORT"; - public static class Integrations - { - [System.Obsolete("App Analytics has been replaced by Tracing without Limits. For more information s" + - "ee https://docs.datadoghq.com/tracing/legacy_app_analytics/")] - public const string AnalyticsEnabled = "SIGNALFX_TRACE_{0}_ANALYTICS_ENABLED"; - [System.Obsolete("App Analytics has been replaced by Tracing without Limits. For more information s" + - "ee https://docs.datadoghq.com/tracing/legacy_app_analytics/")] - public const string AnalyticsSampleRate = "SIGNALFX_TRACE_{0}_ANALYTICS_SAMPLE_RATE"; - public const string Enabled = "SIGNALFX_TRACE_{0}_ENABLED"; - } + public enum ConventionType + { + Default = 0, + OpenTelemetry = 1, + Datadog = 2, } public class EnvironmentConfigurationSource : Datadog.Trace.Configuration.StringConfigurationSource { public EnvironmentConfigurationSource() { } public override string GetString(string key) { } } + public class ExporterSettings + { + public const string DefaultAgentHost = "localhost"; + public const int DefaultAgentPort = 9411; + public ExporterSettings() { } + public ExporterSettings(Datadog.Trace.Configuration.IConfigurationSource source) { } + public System.Uri AgentUri { get; set; } + public int DogStatsdPort { get; set; } + public System.Uri MetricsEndpointUrl { get; set; } + public string MetricsPipeName { get; set; } + public bool PartialFlushEnabled { get; set; } + public int PartialFlushMinSpans { get; set; } + public string TracesPipeName { get; set; } + public int TracesPipeTimeoutMs { get; set; } + } + public enum ExporterType + { + Default = 0, + DatadogAgent = 1, + Zipkin = 0, + } public class GlobalSettings { public bool DebugEnabled { get; } + public bool FileLogEnabled { get; } + public bool StdoutLogEnabled { get; } public static Datadog.Trace.Configuration.GlobalSettings FromDefaultSources() { } public static void Reload() { } public static void SetDebugEnabled(bool enabled) { } @@ -101,6 +64,19 @@ namespace Datadog.Trace.Configuration int? GetInt32(string key); string GetString(string key); } + public class ImmutableExporterSettings + { + public ImmutableExporterSettings(Datadog.Trace.Configuration.ExporterSettings settings) { } + public ImmutableExporterSettings(Datadog.Trace.Configuration.IConfigurationSource source) { } + public System.Uri AgentUri { get; } + public int DogStatsdPort { get; } + public System.Uri MetricsEndpointUrl { get; } + public string MetricsPipeName { get; } + public bool PartialFlushEnabled { get; } + public int PartialFlushMinSpans { get; } + public string TracesPipeName { get; } + public int TracesPipeTimeoutMs { get; } + } public class ImmutableIntegrationSettings { public bool? AnalyticsEnabled { get; } @@ -116,13 +92,14 @@ namespace Datadog.Trace.Configuration { public ImmutableTracerSettings(Datadog.Trace.Configuration.IConfigurationSource source) { } public ImmutableTracerSettings(Datadog.Trace.Configuration.TracerSettings settings) { } - public System.Uri AgentUri { get; } [System.Obsolete("App Analytics has been replaced by Tracing without Limits. For more information s" + "ee https://docs.datadoghq.com/tracing/legacy_app_analytics/")] public bool AnalyticsEnabled { get; } + public Datadog.Trace.Configuration.ConventionType Convention { get; } public string CustomSamplingRules { get; } - public int DogStatsdPort { get; } public string Environment { get; } + public Datadog.Trace.Configuration.ExporterType Exporter { get; } + public Datadog.Trace.Configuration.ImmutableExporterSettings ExporterSettings { get; } public double? GlobalSamplingRate { get; } public System.Collections.Generic.IReadOnlyDictionary GlobalTags { get; } public System.Collections.Generic.IReadOnlyDictionary HeaderTags { get; } @@ -130,17 +107,18 @@ namespace Datadog.Trace.Configuration public bool KafkaCreateConsumerScopeEnabled { get; } public bool LogsInjectionEnabled { get; } public int MaxTracesSubmittedPerSecond { get; } - public string MetricsPipeName { get; } - public bool PartialFlushEnabled { get; } - public int PartialFlushMinSpans { get; } - public bool RuntimeMetricsEnabled { get; } + public Datadog.Trace.SignalFx.Metrics.MetricsExporterType MetricsExporter { get; } + public System.Collections.Generic.HashSet Propagators { get; } + public int RecordedValueMaxLength { get; } public string ServiceName { get; } public string ServiceVersion { get; } public bool StartupDiagnosticLogEnabled { get; } + public bool TagElasticsearchQueries { get; } + public bool TagRedisCommands { get; } + public bool ThreadSamplingEnabled { get; } + public System.TimeSpan ThreadSamplingPeriod { get; } public bool TraceEnabled { get; } public bool TracerMetricsEnabled { get; } - public string TracesPipeName { get; } - public int TracesPipeTimeoutMs { get; } public string TracesTransport { get; } public static Datadog.Trace.Configuration.ImmutableTracerSettings FromDefaultSources() { } } @@ -163,6 +141,7 @@ namespace Datadog.Trace.Configuration public System.Collections.Generic.IDictionary GetDictionary(string key) { } public System.Collections.Generic.IDictionary GetDictionary(string key, bool allowOptionalMappings) { } public T GetValue(string key) { } + public override string ToString() { } public static Datadog.Trace.Configuration.JsonConfigurationSource FromFile(string filename) { } } public class NameValueConfigurationSource : Datadog.Trace.Configuration.StringConfigurationSource @@ -184,19 +163,18 @@ namespace Datadog.Trace.Configuration } public class TracerSettings { - public const string DefaultAgentHost = "localhost"; - public const int DefaultAgentPort = 8126; public TracerSettings() { } public TracerSettings(Datadog.Trace.Configuration.IConfigurationSource source) { } - public System.Uri AgentUri { get; set; } [System.Obsolete("App Analytics has been replaced by Tracing without Limits. For more information s" + "ee https://docs.datadoghq.com/tracing/legacy_app_analytics/")] public bool AnalyticsEnabled { get; set; } + public Datadog.Trace.Configuration.ConventionType Convention { get; set; } public string CustomSamplingRules { get; set; } public bool DiagnosticSourceEnabled { get; set; } public System.Collections.Generic.HashSet DisabledIntegrationNames { get; set; } - public int DogStatsdPort { get; set; } public string Environment { get; set; } + public Datadog.Trace.Configuration.ExporterType Exporter { get; set; } + public Datadog.Trace.Configuration.ExporterSettings ExporterSettings { get; set; } public double? GlobalSamplingRate { get; set; } public System.Collections.Generic.IDictionary GlobalTags { get; set; } public System.Collections.Generic.IDictionary HeaderTags { get; set; } @@ -204,17 +182,20 @@ namespace Datadog.Trace.Configuration public bool KafkaCreateConsumerScopeEnabled { get; set; } public bool LogsInjectionEnabled { get; set; } public int MaxTracesSubmittedPerSecond { get; set; } - public string MetricsPipeName { get; set; } - public bool PartialFlushEnabled { get; set; } - public int PartialFlushMinSpans { get; set; } + public Datadog.Trace.SignalFx.Metrics.MetricsExporterType MetricsExporter { get; set; } + public System.Collections.Generic.HashSet Propagators { get; set; } + public int RecordedValueMaxLength { get; set; } public bool RuntimeMetricsEnabled { get; set; } public string ServiceName { get; set; } public string ServiceVersion { get; set; } + public string SignalFxAccessToken { get; set; } public bool StartupDiagnosticLogEnabled { get; set; } + public bool TagElasticsearchQueries { get; set; } + public bool TagMongoCommands { get; set; } + public bool TagRedisCommands { get; set; } public bool TraceEnabled { get; set; } + public bool TraceResponseHeaderEnabled { get; set; } public bool TracerMetricsEnabled { get; set; } - public string TracesPipeName { get; set; } - public int TracesPipeTimeoutMs { get; set; } public string TracesTransport { get; set; } public Datadog.Trace.Configuration.ImmutableTracerSettings Build() { } public void SetHttpClientErrorStatusCodes(System.Collections.Generic.IEnumerable statusCodes) { } @@ -224,6 +205,23 @@ namespace Datadog.Trace.Configuration public static Datadog.Trace.Configuration.TracerSettings FromDefaultSources() { } } } +namespace Datadog.Trace.Configuration.Types +{ + public static class PropagatorTypes + { + public const string B3 = "B3"; + public const string Datadog = "Datadog"; + public const string W3C = "W3C"; + } +} +namespace Datadog.Trace.Conventions +{ + public interface ITraceIdConvention + { + Datadog.Trace.TraceId CreateFromString(string id); + Datadog.Trace.TraceId GenerateNewTraceId(); + } +} namespace Datadog.Trace { public static class CorrelationIdentifier @@ -231,22 +229,44 @@ namespace Datadog.Trace public static string Env { get; } public static string Service { get; } public static ulong SpanId { get; } - public static ulong TraceId { get; } + public static Datadog.Trace.TraceId TraceId { get; } public static string Version { get; } } - public static class HttpHeaderNames + public interface IScope : System.IDisposable { - public const string Origin = "x-datadog-origin"; - public const string ParentId = "x-datadog-parent-id"; - public const string SamplingPriority = "x-datadog-sampling-priority"; - public const string TraceId = "x-datadog-trace-id"; - public const string TracingEnabled = "x-datadog-tracing-enabled"; + Datadog.Trace.ISpan Span { get; } + void Close(); + } + public interface ISpan : System.IDisposable + { + Datadog.Trace.ISpanContext Context { get; } + bool Error { get; set; } + string LogicScope { get; set; } + string OperationName { get; set; } + string ResourceName { get; set; } + string ServiceName { get; set; } + ulong SpanId { get; } + Datadog.Trace.SpanStatus Status { get; set; } + Datadog.Trace.TraceId TraceId { get; } + string Type { get; set; } + void Finish(); + void Finish(System.DateTimeOffset finishTimestamp); + string GetTag(string key); + void SetException(System.Exception exception); + Datadog.Trace.ISpan SetTag(string key, string value); } public interface ISpanContext { string ServiceName { get; } ulong SpanId { get; } - ulong TraceId { get; } + Datadog.Trace.TraceId TraceId { get; } + } + public interface ITracer + { + Datadog.Trace.IScope ActiveScope { get; } + Datadog.Trace.Configuration.ImmutableTracerSettings Settings { get; } + Datadog.Trace.IScope StartActive(string operationName); + Datadog.Trace.IScope StartActive(string operationName, Datadog.Trace.SpanCreationSettings settings); } public enum SamplingPriority { @@ -255,37 +275,26 @@ namespace Datadog.Trace AutoKeep = 1, UserKeep = 2, } - public class Scope : System.IDisposable + public static class ServerTimingHeader { - public Datadog.Trace.Span Span { get; } - public void Close() { } - public void Dispose() { } + public const string Key = "Server-Timing"; + public static void SetHeaders(Datadog.Trace.SpanContext context, T carrier, System.Action setter) { } } - public class Span : System.IDisposable + public class SpanContext : Datadog.Trace.ISpanContext, System.Collections.Generic.IEnumerable>, System.Collections.Generic.IReadOnlyCollection>, System.Collections.Generic.IReadOnlyDictionary, System.Collections.IEnumerable { - public bool Error { get; set; } - public string OperationName { get; set; } - public string ResourceName { get; set; } - public string ServiceName { get; set; } - public ulong SpanId { get; } - public ulong TraceId { get; } - public string Type { get; set; } - public void Dispose() { } - public void Finish() { } - public void Finish(System.DateTimeOffset finishTimestamp) { } - public string GetTag(string key) { } - public void SetException(System.Exception exception) { } - public Datadog.Trace.Span SetTag(string key, string value) { } - public override string ToString() { } - } - public class SpanContext : Datadog.Trace.ISpanContext - { - public SpanContext(ulong? traceId, ulong spanId, Datadog.Trace.SamplingPriority? samplingPriority = default, string serviceName = null) { } + public SpanContext(Datadog.Trace.TraceId? traceId, ulong spanId, string traceState) { } + public SpanContext(Datadog.Trace.TraceId? traceId, ulong spanId, Datadog.Trace.SamplingPriority? samplingPriority = default, string serviceName = null) { } public Datadog.Trace.ISpanContext Parent { get; } public ulong? ParentId { get; } public string ServiceName { get; set; } public ulong SpanId { get; } - public ulong TraceId { get; } + public Datadog.Trace.TraceId TraceId { get; } + } + public struct SpanCreationSettings + { + public bool? FinishOnClose { get; set; } + public Datadog.Trace.ISpanContext Parent { get; set; } + public System.DateTimeOffset? StartTime { get; set; } } public static class SpanKinds { @@ -294,6 +303,19 @@ namespace Datadog.Trace public const string Producer = "producer"; public const string Server = "server"; } + public readonly struct SpanStatus : System.IEquatable + { + public static readonly Datadog.Trace.SpanStatus Error; + public static readonly Datadog.Trace.SpanStatus Ok; + public static readonly Datadog.Trace.SpanStatus Unset; + public Datadog.Trace.StatusCode StatusCode { get; } + public bool Equals(Datadog.Trace.SpanStatus other) { } + public override bool Equals(object obj) { } + public override int GetHashCode() { } + public override string ToString() { } + public static bool operator !=(Datadog.Trace.SpanStatus status1, Datadog.Trace.SpanStatus status2) { } + public static bool operator ==(Datadog.Trace.SpanStatus status1, Datadog.Trace.SpanStatus status2) { } + } public static class SpanTypes { public const string Benchmark = "benchmark"; @@ -305,19 +327,29 @@ namespace Datadog.Trace public const string Serverless = "serverless"; public const string Sql = "sql"; public const string Test = "test"; + public const string Topic = "topic"; public const string Web = "web"; } + public enum StatusCode + { + Unset = 0, + Ok = 1, + Error = 2, + } public static class Tags { public const string DbName = "db.name"; + public const string DbOperation = "db.operation"; + public const string DbStatement = "db.statement"; public const string DbType = "db.system"; public const string DbUser = "db.user"; public const string Env = "deployment.environment"; - public const string ErrorMsg = "error.msg"; - public const string ErrorStack = "error.stack"; - public const string ErrorType = "error.type"; + public const string Error = "error"; + public const string ErrorMsg = "sfx.error.message"; + public const string ErrorStack = "sfx.error.stack"; + public const string ErrorType = "sfx.error.kind"; public const string HttpMethod = "http.method"; - public const string HttpRequestHeadersHost = "http.request.headers.host"; + public const string HttpRequestHeadersHost = "http.host"; public const string HttpStatusCode = "http.status_code"; public const string HttpUrl = "http.url"; public const string InstrumentationName = "component"; @@ -326,31 +358,76 @@ namespace Datadog.Trace public const string ManualDrop = "manual.drop"; public const string ManualKeep = "manual.keep"; public const string MessageSize = "message.size"; - public const string OutHost = "out.host"; - public const string OutPort = "out.port"; + public const string OutHost = "net.peer.name"; + public const string OutPort = "net.peer.port"; public const string SamplingPriority = "sampling.priority"; + public const string SignalFxLibrary = "signalfx.tracing.library"; + public const string SignalFxVersion = "signalfx.tracing.version"; public const string SpanKind = "span.kind"; public const string SqlQuery = "sql.query"; public const string SqlRows = "sql.rows"; public const string Version = "version"; + public static class Messaging + { + public const string ConsumerId = "messaging.consumer_id\t"; + public const string ConversationId = "messaging.conversation_id"; + public const string Destination = "messaging.destination"; + public const string DestinationKind = "messaging.destination_kind"; + public const string MessageId = "messaging.message_id"; + public const string MessageSize = "messaging.message_payload_size_bytes"; + public const string MessageSizeCompressed = "messaging.message_payload_compressed_size_bytes"; + public const string Operation = "messaging.operation"; + public const string Protocol = "messaging.protocol"; + public const string ProtocolVersion = "messaging.protocol_version"; + public const string System = "messaging.system"; + public const string TempDestination = "messaging.temp_destination"; + public const string Url = "messaging.url"; + } + public static class Net + { + public const string PeerIP = "net.peer.ip"; + public const string PeerName = "net.peer.name"; + public const string PeerPort = "net.peer.port"; + } + public static class RabbitMq + { + public const string RoutingKey = "messaging.rabbitmq.routing_key"; + } + } + public readonly struct TraceId : System.IEquatable + { + public ulong Higher { get; } + public ulong Lower { get; } + public static Datadog.Trace.TraceId Zero { get; } + public bool Equals(Datadog.Trace.TraceId other) { } + public override bool Equals(object obj) { } + public override int GetHashCode() { } + public override string ToString() { } + public static Datadog.Trace.TraceId CreateDataDogCompatibleFromDecimalString(string id) { } + public static Datadog.Trace.TraceId CreateFromInt(int id) { } + public static Datadog.Trace.TraceId CreateFromString(string id) { } + public static Datadog.Trace.TraceId CreateFromUlong(ulong id) { } + public static Datadog.Trace.TraceId CreateRandom() { } + public static Datadog.Trace.TraceId CreateRandomDataDogCompatible() { } + public static bool operator !=(Datadog.Trace.TraceId traceId1, Datadog.Trace.TraceId traceId2) { } + public static bool operator ==(Datadog.Trace.TraceId traceId1, Datadog.Trace.TraceId traceId2) { } } - public class Tracer + public class Tracer : Datadog.Trace.ITracer { [System.Obsolete("This API is deprecated. Use Tracer.Instance to obtain a Tracer instance to create" + " spans.")] public Tracer() { } [System.Obsolete(@"This API is deprecated, as it replaces the global settings for all Tracer instances in the application. If you were using this API to configure the global Tracer.Instance in code, use the static Tracer.Configure() to replace the global Tracer settings for the application")] public Tracer(Datadog.Trace.Configuration.TracerSettings settings) { } - public Datadog.Trace.Scope ActiveScope { get; } + public Datadog.Trace.IScope ActiveScope { get; } public string DefaultServiceName { get; } public Datadog.Trace.Configuration.ImmutableTracerSettings Settings { get; } [set: System.Obsolete("Use Tracer.Configure to configure the global Tracer instance in code.")] public static Datadog.Trace.Tracer Instance { get; set; } - public Datadog.Trace.Scope ActivateSpan(Datadog.Trace.Span span, bool finishOnClose = true) { } protected override void Finalize() { } public System.Threading.Tasks.Task ForceFlushAsync() { } - public Datadog.Trace.Scope StartActive(string operationName, Datadog.Trace.ISpanContext parent = null, string serviceName = null, System.DateTimeOffset? startTime = default, bool ignoreActiveScope = false, bool finishOnClose = true) { } - public Datadog.Trace.Span StartSpan(string operationName, Datadog.Trace.ISpanContext parent = null, string serviceName = null, System.DateTimeOffset? startTime = default, bool ignoreActiveScope = false) { } + public Datadog.Trace.IScope StartActive(string operationName) { } + public Datadog.Trace.IScope StartActive(string operationName, Datadog.Trace.SpanCreationSettings settings) { } public static void Configure(Datadog.Trace.Configuration.TracerSettings settings) { } } } @@ -358,8 +435,8 @@ namespace Datadog.Trace.ExtensionMethods { public static class SpanExtensions { - public static void AddTagsFromDbCommand(this Datadog.Trace.Span span, System.Data.IDbCommand command) { } - public static void SetTraceSamplingPriority(this Datadog.Trace.Span span, Datadog.Trace.SamplingPriority samplingPriority) { } + public static void AddTagsFromDbCommand(this Datadog.Trace.ISpan span, System.Data.IDbCommand command) { } + public static void SetTraceSamplingPriority(this Datadog.Trace.ISpan span, Datadog.Trace.SamplingPriority samplingPriority) { } } } namespace Datadog.Trace.Logging @@ -393,4 +470,432 @@ namespace Datadog.Trace.Logging.LogProviders public LibLogException(string message) { } public LibLogException(string message, System.Exception inner) { } } +} +namespace Datadog.Trace.Propagation +{ + public static class B3HttpHeaderNames + { + public const string B3Flags = "x-b3-flags"; + public const string B3ParentId = "x-b3-parentspanid"; + public const string B3Sampled = "x-b3-sampled"; + public const string B3SpanId = "x-b3-spanid"; + public const string B3TraceId = "x-b3-traceid"; + } + public class B3SpanContextPropagator : Datadog.Trace.Propagation.IPropagator + { + public B3SpanContextPropagator(Datadog.Trace.Conventions.ITraceIdConvention traceIdConvention) { } + public virtual Datadog.Trace.SpanContext Extract(T carrier, System.Func> getter) { } + public virtual void Inject(Datadog.Trace.SpanContext context, T carrier, System.Action setter) { } + } + public class CommonHttpHeaderNames + { + public const string TracingEnabled = "x-datadog-tracing-enabled"; + public const string UserAgent = "User-Agent"; + public CommonHttpHeaderNames() { } + } + public static class DDHttpHeaderNames + { + public const string Origin = "x-datadog-origin"; + public const string ParentId = "x-datadog-parent-id"; + public const string SamplingPriority = "x-datadog-sampling-priority"; + public const string TraceId = "x-datadog-trace-id"; + public const string TracingEnabled = "x-datadog-tracing-enabled"; + } + public interface IPropagator + { + Datadog.Trace.SpanContext Extract(T carrier, System.Func> getter); + void Inject(Datadog.Trace.SpanContext context, T carrier, System.Action setter); + } + public interface IPropagatorsProvider + { + bool CanProvide(string propagatorId, Datadog.Trace.Conventions.ITraceIdConvention traceIdConvention); + Datadog.Trace.Propagation.IPropagator GetPropagator(string propagatorId, Datadog.Trace.Conventions.ITraceIdConvention traceIdConvention); + } + public static class W3CHeaderNames + { + public const string TraceParent = "traceparent"; + public const string TraceState = "tracestate"; + } + public class W3CSpanContextPropagator : Datadog.Trace.Propagation.IPropagator + { + public W3CSpanContextPropagator(Datadog.Trace.Conventions.ITraceIdConvention traceIdConvention) { } + public virtual Datadog.Trace.SpanContext Extract(T carrier, System.Func> getter) { } + public virtual void Inject(Datadog.Trace.SpanContext context, T carrier, System.Action setter) { } + public static string GetFormattedTraceParent(Datadog.Trace.SpanContext context) { } + } +} +namespace Datadog.Trace.SignalFx.Metrics +{ + public enum MetricsExporterType + { + Default = 0, + StatsD = 1, + SignalFx = 0, + } +} +namespace Datadog.Trace.ThreadSampling +{ + public static class ThreadSampler + { + public static void Initialize(System.TimeSpan threadSamplingPeriod) { } + } +} +namespace Datadog.Trace.Vendors.ProtoBuf +{ + public readonly struct DiscriminatedUnion128 + { + public readonly bool Boolean; + public readonly System.DateTime DateTime; + public readonly double Double; + public readonly System.Guid Guid; + public readonly int Int32; + public readonly long Int64; + public readonly float Single; + public readonly System.TimeSpan TimeSpan; + public readonly uint UInt32; + public readonly ulong UInt64; + public DiscriminatedUnion128(int discriminator, bool value) { } + public DiscriminatedUnion128(int discriminator, System.DateTime? value) { } + public DiscriminatedUnion128(int discriminator, double value) { } + public DiscriminatedUnion128(int discriminator, System.Guid? value) { } + public DiscriminatedUnion128(int discriminator, int value) { } + public DiscriminatedUnion128(int discriminator, long value) { } + public DiscriminatedUnion128(int discriminator, float value) { } + public DiscriminatedUnion128(int discriminator, System.TimeSpan? value) { } + public DiscriminatedUnion128(int discriminator, uint value) { } + public DiscriminatedUnion128(int discriminator, ulong value) { } + public int Discriminator { get; } + public bool Is(int discriminator) { } + public static void Reset(ref Datadog.Trace.Vendors.ProtoBuf.DiscriminatedUnion128 value, int discriminator) { } + } + public readonly struct DiscriminatedUnion128Object + { + public readonly bool Boolean; + public readonly System.DateTime DateTime; + public readonly double Double; + public readonly System.Guid Guid; + public readonly int Int32; + public readonly long Int64; + public readonly object Object; + public readonly float Single; + public readonly System.TimeSpan TimeSpan; + public readonly uint UInt32; + public readonly ulong UInt64; + public DiscriminatedUnion128Object(int discriminator, bool value) { } + public DiscriminatedUnion128Object(int discriminator, System.DateTime? value) { } + public DiscriminatedUnion128Object(int discriminator, double value) { } + public DiscriminatedUnion128Object(int discriminator, System.Guid? value) { } + public DiscriminatedUnion128Object(int discriminator, int value) { } + public DiscriminatedUnion128Object(int discriminator, long value) { } + public DiscriminatedUnion128Object(int discriminator, object value) { } + public DiscriminatedUnion128Object(int discriminator, float value) { } + public DiscriminatedUnion128Object(int discriminator, System.TimeSpan? value) { } + public DiscriminatedUnion128Object(int discriminator, uint value) { } + public DiscriminatedUnion128Object(int discriminator, ulong value) { } + public int Discriminator { get; } + public bool Is(int discriminator) { } + public static void Reset(ref Datadog.Trace.Vendors.ProtoBuf.DiscriminatedUnion128Object value, int discriminator) { } + } + public readonly struct DiscriminatedUnion32 + { + public readonly bool Boolean; + public readonly int Int32; + public readonly float Single; + public readonly uint UInt32; + public DiscriminatedUnion32(int discriminator, bool value) { } + public DiscriminatedUnion32(int discriminator, int value) { } + public DiscriminatedUnion32(int discriminator, float value) { } + public DiscriminatedUnion32(int discriminator, uint value) { } + public int Discriminator { get; } + public bool Is(int discriminator) { } + public static void Reset(ref Datadog.Trace.Vendors.ProtoBuf.DiscriminatedUnion32 value, int discriminator) { } + } + public readonly struct DiscriminatedUnion32Object + { + public readonly bool Boolean; + public readonly int Int32; + public readonly object Object; + public readonly float Single; + public readonly uint UInt32; + public DiscriminatedUnion32Object(int discriminator, bool value) { } + public DiscriminatedUnion32Object(int discriminator, int value) { } + public DiscriminatedUnion32Object(int discriminator, object value) { } + public DiscriminatedUnion32Object(int discriminator, float value) { } + public DiscriminatedUnion32Object(int discriminator, uint value) { } + public int Discriminator { get; } + public bool Is(int discriminator) { } + public static void Reset(ref Datadog.Trace.Vendors.ProtoBuf.DiscriminatedUnion32Object value, int discriminator) { } + } + public readonly struct DiscriminatedUnion64 + { + public readonly bool Boolean; + public readonly System.DateTime DateTime; + public readonly double Double; + public readonly int Int32; + public readonly long Int64; + public readonly float Single; + public readonly System.TimeSpan TimeSpan; + public readonly uint UInt32; + public readonly ulong UInt64; + public DiscriminatedUnion64(int discriminator, bool value) { } + public DiscriminatedUnion64(int discriminator, System.DateTime? value) { } + public DiscriminatedUnion64(int discriminator, double value) { } + public DiscriminatedUnion64(int discriminator, int value) { } + public DiscriminatedUnion64(int discriminator, long value) { } + public DiscriminatedUnion64(int discriminator, float value) { } + public DiscriminatedUnion64(int discriminator, System.TimeSpan? value) { } + public DiscriminatedUnion64(int discriminator, uint value) { } + public DiscriminatedUnion64(int discriminator, ulong value) { } + public int Discriminator { get; } + public bool Is(int discriminator) { } + public static void Reset(ref Datadog.Trace.Vendors.ProtoBuf.DiscriminatedUnion64 value, int discriminator) { } + } + public readonly struct DiscriminatedUnion64Object + { + public readonly bool Boolean; + public readonly System.DateTime DateTime; + public readonly double Double; + public readonly int Int32; + public readonly long Int64; + public readonly object Object; + public readonly float Single; + public readonly System.TimeSpan TimeSpan; + public readonly uint UInt32; + public readonly ulong UInt64; + public DiscriminatedUnion64Object(int discriminator, bool value) { } + public DiscriminatedUnion64Object(int discriminator, System.DateTime? value) { } + public DiscriminatedUnion64Object(int discriminator, double value) { } + public DiscriminatedUnion64Object(int discriminator, int value) { } + public DiscriminatedUnion64Object(int discriminator, long value) { } + public DiscriminatedUnion64Object(int discriminator, object value) { } + public DiscriminatedUnion64Object(int discriminator, float value) { } + public DiscriminatedUnion64Object(int discriminator, System.TimeSpan? value) { } + public DiscriminatedUnion64Object(int discriminator, uint value) { } + public DiscriminatedUnion64Object(int discriminator, ulong value) { } + public int Discriminator { get; } + public bool Is(int discriminator) { } + public static void Reset(ref Datadog.Trace.Vendors.ProtoBuf.DiscriminatedUnion64Object value, int discriminator) { } + } + public readonly struct DiscriminatedUnionObject + { + public readonly object Object; + public DiscriminatedUnionObject(int discriminator, object value) { } + public int Discriminator { get; } + public bool Is(int discriminator) { } + public static void Reset(ref Datadog.Trace.Vendors.ProtoBuf.DiscriminatedUnionObject value, int discriminator) { } + } +} +namespace Datadog.Tracer.OpenTelemetry.Proto.Common.V1 +{ + public class AnyValue + { + public AnyValue() { } + public Datadog.Tracer.OpenTelemetry.Proto.Common.V1.ArrayValue ArrayValue { get; set; } + public bool BoolValue { get; set; } + public byte[] BytesValue { get; set; } + public double DoubleValue { get; set; } + public long IntValue { get; set; } + public Datadog.Tracer.OpenTelemetry.Proto.Common.V1.KeyValueList KvlistValue { get; set; } + [System.ComponentModel.DefaultValue("")] + public string StringValue { get; set; } + public void ResetArrayValue() { } + public void ResetBoolValue() { } + public void ResetBytesValue() { } + public void ResetDoubleValue() { } + public void ResetIntValue() { } + public void ResetKvlistValue() { } + public void ResetStringValue() { } + public bool ShouldSerializeArrayValue() { } + public bool ShouldSerializeBoolValue() { } + public bool ShouldSerializeBytesValue() { } + public bool ShouldSerializeDoubleValue() { } + public bool ShouldSerializeIntValue() { } + public bool ShouldSerializeKvlistValue() { } + public bool ShouldSerializeStringValue() { } + } + public class ArrayValue + { + public ArrayValue() { } + public System.Collections.Generic.List Values { get; } + } + public class InstrumentationLibrary + { + public InstrumentationLibrary() { } + [System.ComponentModel.DefaultValue("")] + public string Name { get; set; } + [System.ComponentModel.DefaultValue("")] + public string Version { get; set; } + } + public class KeyValue + { + public KeyValue() { } + [System.ComponentModel.DefaultValue("")] + public string Key { get; set; } + public Datadog.Tracer.OpenTelemetry.Proto.Common.V1.AnyValue Value { get; set; } + } + public class KeyValueList + { + public KeyValueList() { } + public System.Collections.Generic.List Values { get; } + } + [System.Obsolete] + public class StringKeyValue + { + public StringKeyValue() { } + [System.ComponentModel.DefaultValue("")] + public string Key { get; set; } + [System.ComponentModel.DefaultValue("")] + public string Value { get; set; } + } +} +namespace Datadog.Tracer.OpenTelemetry.Proto.Logs.V1 +{ + public class InstrumentationLibraryLogs + { + public InstrumentationLibraryLogs() { } + public Datadog.Tracer.OpenTelemetry.Proto.Common.V1.InstrumentationLibrary InstrumentationLibrary { get; set; } + public System.Collections.Generic.List Logs { get; } + [System.ComponentModel.DefaultValue("")] + public string SchemaUrl { get; set; } + } + public class LogRecord + { + public LogRecord() { } + public System.Collections.Generic.List Attributes { get; } + public Datadog.Tracer.OpenTelemetry.Proto.Common.V1.AnyValue Body { get; set; } + public uint DroppedAttributesCount { get; set; } + public uint Flags { get; set; } + [System.ComponentModel.DefaultValue("")] + public string Name { get; set; } + public Datadog.Tracer.OpenTelemetry.Proto.Logs.V1.SeverityNumber SeverityNumber { get; set; } + [System.ComponentModel.DefaultValue("")] + public string SeverityText { get; set; } + public byte[] SpanId { get; set; } + public ulong TimeUnixNano { get; set; } + public byte[] TraceId { get; set; } + } + public enum LogRecordFlags + { + LogRecordFlagUnspecified = 0, + LogRecordFlagTraceFlagsMask = 255, + } + public class LogsData + { + public LogsData() { } + public System.Collections.Generic.List ResourceLogs { get; } + } + public class ResourceLogs + { + public ResourceLogs() { } + public System.Collections.Generic.List InstrumentationLibraryLogs { get; } + public Datadog.Tracer.OpenTelemetry.Proto.Resource.V1.Resource Resource { get; set; } + [System.ComponentModel.DefaultValue("")] + public string SchemaUrl { get; set; } + } + public enum SeverityNumber + { + SeverityNumberUnspecified = 0, + SeverityNumberTrace = 1, + SeverityNumberTrace2 = 2, + SeverityNumberTrace3 = 3, + SeverityNumberTrace4 = 4, + SeverityNumberDebug = 5, + SeverityNumberDebug2 = 6, + SeverityNumberDebug3 = 7, + SeverityNumberDebug4 = 8, + SeverityNumberInfo = 9, + SeverityNumberInfo2 = 10, + SeverityNumberInfo3 = 11, + SeverityNumberInfo4 = 12, + SeverityNumberWarn = 13, + SeverityNumberWarn2 = 14, + SeverityNumberWarn3 = 15, + SeverityNumberWarn4 = 16, + SeverityNumberError = 17, + SeverityNumberError2 = 18, + SeverityNumberError3 = 19, + SeverityNumberError4 = 20, + SeverityNumberFatal = 21, + SeverityNumberFatal2 = 22, + SeverityNumberFatal3 = 23, + SeverityNumberFatal4 = 24, + } +} +namespace Datadog.Tracer.OpenTelemetry.Proto.Resource.V1 +{ + public class Resource + { + public Resource() { } + public System.Collections.Generic.List Attributes { get; } + public uint DroppedAttributesCount { get; set; } + } +} +namespace Datadog.Tracer.SignalFx.Metrics.Protobuf +{ + public class DataPoint + { + public DataPoint() { } + public System.Collections.Generic.List dimensions { get; } + [System.ComponentModel.DefaultValue("")] + public string metric { get; set; } + public Datadog.Tracer.SignalFx.Metrics.Protobuf.MetricType metricType { get; set; } + [System.ComponentModel.DefaultValue("")] + public string source { get; set; } + public long timestamp { get; set; } + public Datadog.Tracer.SignalFx.Metrics.Protobuf.Datum value { get; set; } + public void Resetmetric() { } + public void ResetmetricType() { } + public void Resetsource() { } + public void Resettimestamp() { } + public bool ShouldSerializemetric() { } + public bool ShouldSerializemetricType() { } + public bool ShouldSerializesource() { } + public bool ShouldSerializetimestamp() { } + } + public class DataPointUploadMessage + { + public DataPointUploadMessage() { } + public System.Collections.Generic.List datapoints { get; } + } + public class Datum + { + public Datum() { } + public double doubleValue { get; set; } + public long intValue { get; set; } + [System.ComponentModel.DefaultValue("")] + public string strValue { get; set; } + public void ResetdoubleValue() { } + public void ResetintValue() { } + public void ResetstrValue() { } + public bool ShouldSerializedoubleValue() { } + public bool ShouldSerializeintValue() { } + public bool ShouldSerializestrValue() { } + } + public class Dimension + { + public Dimension() { } + [System.ComponentModel.DefaultValue("")] + public string key { get; set; } + [System.ComponentModel.DefaultValue("")] + public string value { get; set; } + public void Resetkey() { } + public void Resetvalue() { } + public bool ShouldSerializekey() { } + public bool ShouldSerializevalue() { } + } + public enum MetricType + { + GAUGE = 0, + COUNTER = 1, + ENUM = 2, + CUMULATIVE_COUNTER = 3, + } + public class PointValue + { + public PointValue() { } + public long timestamp { get; set; } + public Datadog.Tracer.SignalFx.Metrics.Protobuf.Datum value { get; set; } + public void Resettimestamp() { } + public bool ShouldSerializetimestamp() { } + } } \ No newline at end of file diff --git a/tracer/test/Datadog.Trace.Tests/SpanTests.cs b/tracer/test/Datadog.Trace.Tests/SpanTests.cs index 707a3e5c6..5cd09e51c 100644 --- a/tracer/test/Datadog.Trace.Tests/SpanTests.cs +++ b/tracer/test/Datadog.Trace.Tests/SpanTests.cs @@ -149,11 +149,11 @@ public void TopLevelSpans() { var spans = new List<(Scope Scope, bool IsTopLevel)>(); - spans.Add((_tracer.StartActive("Root", serviceName: "root"), true)); - spans.Add((_tracer.StartActive("Child1", serviceName: "root"), false)); - spans.Add((_tracer.StartActive("Child2", serviceName: "child"), true)); - spans.Add((_tracer.StartActive("Child3", serviceName: "child"), false)); - spans.Add((_tracer.StartActive("Child4", serviceName: "root"), true)); + spans.Add(((Scope)_tracer.StartActive("Root", serviceName: "root"), true)); + spans.Add(((Scope)_tracer.StartActive("Child1", serviceName: "root"), false)); + spans.Add(((Scope)_tracer.StartActive("Child2", serviceName: "child"), true)); + spans.Add(((Scope)_tracer.StartActive("Child3", serviceName: "child"), false)); + spans.Add(((Scope)_tracer.StartActive("Child4", serviceName: "root"), true)); foreach (var (scope, expectedResult) in spans) { @@ -175,11 +175,12 @@ public void SpanIds_SingleSpanIsRoot() [Fact] public void SpanIds_SingleScopeIsRoot() { - Scope scope = _tracer.StartActive("Operation Galactic Storm"); + Scope scope = (Scope)_tracer.StartActive("Operation Galactic Storm"); + var span = scope.Span; using (scope) { - scope.Span.SpanId.Should().NotBe(0); - scope.Span.RootSpanId.Should().Be(scope.Span.SpanId); + span.SpanId.Should().NotBe(0); + span.RootSpanId.Should().Be(scope.Span.SpanId); } } @@ -188,7 +189,7 @@ public void SpanIds_RemoteParentOfSpanIsNotLocalRoot() { const ulong remoteParentSpanId = 1234567890123456789; SpanContext remoteParentSpanCtx = new SpanContext(traceId: null, spanId: remoteParentSpanId); - Span span = _tracer.StartSpan(operationName: "Operation Galactic Storm", parent: remoteParentSpanCtx); + var span = _tracer.StartSpan(operationName: "Operation Galactic Storm", parent: remoteParentSpanCtx); using (span) { span.SpanId.Should().NotBe(0); @@ -202,12 +203,14 @@ public void SpanIds_RemoteParentOfScopeIsNotLocalRoot() { const ulong remoteParentSpanId = 1234567890123456789; SpanContext remoteParentSpanCtx = new SpanContext(traceId: null, spanId: remoteParentSpanId); - Scope scope = _tracer.StartActive(operationName: "Operation Galactic Storm", parent: remoteParentSpanCtx); + var spanCreationSettings = new SpanCreationSettings() { Parent = remoteParentSpanCtx }; + Scope scope = (Scope)_tracer.StartActive(operationName: "Operation Galactic Storm", spanCreationSettings); + var span = scope.Span; using (scope) { - scope.Span.SpanId.Should().NotBe(0); - scope.Span.SpanId.Should().NotBe(remoteParentSpanId); // There is an expected 1 in 2^64 chance of this line failing - scope.Span.RootSpanId.Should().Be(scope.Span.SpanId); + span.SpanId.Should().NotBe(0); + span.SpanId.Should().NotBe(remoteParentSpanId); // There is an expected 1 in 2^64 chance of this line failing + span.RootSpanId.Should().Be(scope.Span.SpanId); } } @@ -238,17 +241,21 @@ public void SpanIds_RootOfSpanHierarchy() [Fact] public void SpanIds_RootOfScopeHierarchy() { - using (Scope scope1 = _tracer.StartActive(operationName: "Operation Root")) - using (Scope scope2 = _tracer.StartActive(operationName: "Operation Middle")) - using (Scope scope3 = _tracer.StartActive(operationName: "Operation Leaf")) + using (Scope scope1 = (Scope)_tracer.StartActive(operationName: "Operation Root")) + using (Scope scope2 = (Scope)_tracer.StartActive(operationName: "Operation Middle")) + using (Scope scope3 = (Scope)_tracer.StartActive(operationName: "Operation Leaf")) { scope1.Span.SpanId.Should().NotBe(0); scope2.Span.SpanId.Should().NotBe(0); scope3.Span.SpanId.Should().NotBe(0); - scope1.Span.RootSpanId.Should().Be(scope1.Span.SpanId); - scope2.Span.RootSpanId.Should().Be(scope1.Span.SpanId); - scope3.Span.RootSpanId.Should().Be(scope1.Span.SpanId); + var span1 = scope1.Span; + var span2 = scope2.Span; + var span3 = scope3.Span; + + span1.RootSpanId.Should().Be(scope1.Span.SpanId); + span2.RootSpanId.Should().Be(scope1.Span.SpanId); + span3.RootSpanId.Should().Be(scope1.Span.SpanId); } } @@ -257,30 +264,34 @@ public void SpanIds_RootOfScopeSpanMixedHierarchy() { const ulong remoteParentSpanId = 1234567890123456789; SpanContext remoteParentSpanCtx = new SpanContext(traceId: null, spanId: remoteParentSpanId); + var spanCreationSettings = new SpanCreationSettings() { Parent = remoteParentSpanCtx }; - using (Scope scope1 = _tracer.StartActive(operationName: "Operation Root", parent: remoteParentSpanCtx)) + using (Scope scope1 = (Scope)_tracer.StartActive(operationName: "Operation Root", spanCreationSettings)) using (Span span2 = _tracer.StartSpan(operationName: "Operation Middle 1")) - using (Scope scope3 = _tracer.StartActive(operationName: "Operation Middle 2")) + using (Scope scope3 = (Scope)_tracer.StartActive(operationName: "Operation Middle 2")) using (Span span4 = _tracer.StartSpan(operationName: "Operation Leaf")) { - scope1.Span.SpanId.Should().NotBe(0); + var span1 = scope1.Span; + var span3 = scope3.Span; + + span1.SpanId.Should().NotBe(0); span2.SpanId.Should().NotBe(0); - scope3.Span.SpanId.Should().NotBe(0); + span3.SpanId.Should().NotBe(0); span4.SpanId.Should().NotBe(0); - scope1.Span.SpanId.Should().NotBe(remoteParentSpanId); // There is an expected 1 in 2^64 chance of this line failing + span1.SpanId.Should().NotBe(remoteParentSpanId); // There is an expected 1 in 2^64 chance of this line failing span2.SpanId.Should().NotBe(remoteParentSpanId); // There is an expected 1 in 2^64 chance of this line failing - scope3.Span.SpanId.Should().NotBe(remoteParentSpanId); // There is an expected 1 in 2^64 chance of this line failing + span3.SpanId.Should().NotBe(remoteParentSpanId); // There is an expected 1 in 2^64 chance of this line failing span4.SpanId.Should().NotBe(remoteParentSpanId); // There is an expected 1 in 2^64 chance of this line failing - scope1.Span.Context.ParentId.Should().Be(remoteParentSpanId); // Parent (not root) of S1 is remote + span1.Context.ParentId.Should().Be(remoteParentSpanId); // Parent (not root) of S1 is remote span2.Context.ParentId.Should().Be(scope1.Span.SpanId); // Parent of S2 is S1: it was created in an active S1-scope - scope3.Span.Context.ParentId.Should().Be(scope1.Span.SpanId); // Parent of S3 is also S1: it was created in an active S1 scope, S2 is not a scope + span3.Context.ParentId.Should().Be(scope1.Span.SpanId); // Parent of S3 is also S1: it was created in an active S1 scope, S2 is not a scope span4.Context.ParentId.Should().Be(scope3.Span.SpanId); // Parent of S4 is S3: it was created in an active S3-scope - scope1.Span.RootSpanId.Should().Be(scope1.Span.SpanId); + span1.RootSpanId.Should().Be(scope1.Span.SpanId); span2.RootSpanId.Should().Be(scope1.Span.SpanId); - scope3.Span.RootSpanId.Should().Be(scope1.Span.SpanId); + span3.RootSpanId.Should().Be(scope1.Span.SpanId); span4.RootSpanId.Should().Be(scope1.Span.SpanId); } } diff --git a/tracer/test/Datadog.Trace.Tests/TraceContextTests.cs b/tracer/test/Datadog.Trace.Tests/TraceContextTests.cs index 6064cb1c1..dbf99d0d3 100644 --- a/tracer/test/Datadog.Trace.Tests/TraceContextTests.cs +++ b/tracer/test/Datadog.Trace.Tests/TraceContextTests.cs @@ -3,6 +3,8 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // +// Modified by Splunk Inc. + using System; using Datadog.Trace.Util; using FluentAssertions; @@ -46,8 +48,11 @@ public void FlushPartialTraces(bool partialFlush) tracer.Setup(t => t.Settings).Returns(new Trace.Configuration.TracerSettings { - PartialFlushEnabled = partialFlush, - PartialFlushMinSpans = 5 + ExporterSettings = new Trace.Configuration.ExporterSettings() + { + PartialFlushEnabled = partialFlush, + PartialFlushMinSpans = 5 + } }.Build()); var traceContext = new TraceContext(tracer.Object); @@ -123,8 +128,11 @@ public void FullFlushShouldNotPropagateSamplingPriority() tracer.Setup(t => t.Settings).Returns(new Trace.Configuration.TracerSettings { - PartialFlushEnabled = true, - PartialFlushMinSpans = partialFlushThreshold + ExporterSettings = new Trace.Configuration.ExporterSettings() + { + PartialFlushEnabled = true, + PartialFlushMinSpans = partialFlushThreshold + } }.Build()); ArraySegment? spans = null; @@ -173,8 +181,11 @@ public void PartialFlushShouldPropagateSamplingPriority() tracer.Setup(t => t.Settings).Returns(new Trace.Configuration.TracerSettings { - PartialFlushEnabled = true, - PartialFlushMinSpans = partialFlushThreshold + ExporterSettings = new Trace.Configuration.ExporterSettings() + { + PartialFlushEnabled = true, + PartialFlushMinSpans = partialFlushThreshold + } }.Build()); ArraySegment? spans = null; diff --git a/tracer/test/Datadog.Trace.Tests/TracerInstanceTest.cs b/tracer/test/Datadog.Trace.Tests/TracerInstanceTest.cs index 23bd41a8a..135e594e4 100644 --- a/tracer/test/Datadog.Trace.Tests/TracerInstanceTest.cs +++ b/tracer/test/Datadog.Trace.Tests/TracerInstanceTest.cs @@ -15,7 +15,7 @@ namespace Datadog.Trace.Tests { - [CollectionDefinition(nameof(TracerInstanceTest), DisableParallelization = true)] + [Collection(nameof(TracerInstanceTestCollection))] [TracerRestorer] public class TracerInstanceTest { @@ -75,7 +75,10 @@ public void ReplacingGlobalTracerManagerMidTraceWritesTheTrace() var oldSettings = new TracerSettings { Exporter = ExporterType.DatadogAgent, - AgentUri = new Uri($"http://127.0.0.1:{agent.Port}"), + ExporterSettings = new ExporterSettings() + { + AgentUri = new Uri($"http://127.0.0.1:{agent.Port}"), + }, TracerMetricsEnabled = false, StartupDiagnosticLogEnabled = false, GlobalTags = new Dictionary { { "test-tag", "original-value" } }, @@ -87,7 +90,10 @@ public void ReplacingGlobalTracerManagerMidTraceWritesTheTrace() var newSettings = new TracerSettings { Exporter = ExporterType.DatadogAgent, - AgentUri = new Uri($"http://127.0.0.1:{agent.Port}"), + ExporterSettings = new ExporterSettings() + { + AgentUri = new Uri($"http://127.0.0.1:{agent.Port}"), + }, TracerMetricsEnabled = false, StartupDiagnosticLogEnabled = false, GlobalTags = new Dictionary { { "test-tag", "new-value" } }, diff --git a/tracer/test/Datadog.Trace.Tests/TracerSettingsTests.cs b/tracer/test/Datadog.Trace.Tests/TracerSettingsTests.cs index 117c0f1b9..af273c715 100644 --- a/tracer/test/Datadog.Trace.Tests/TracerSettingsTests.cs +++ b/tracer/test/Datadog.Trace.Tests/TracerSettingsTests.cs @@ -3,6 +3,8 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // +// Modified by Splunk Inc. + using System; using System.Collections.Generic; using System.Collections.Specialized; @@ -101,7 +103,7 @@ public void ReplaceLocalhost(string original, string expected) var tracerSettings = new TracerSettings(new NameValueConfigurationSource(settings)); - Assert.Equal(expected, tracerSettings.AgentUri.ToString()); + Assert.Equal(expected, tracerSettings.ExporterSettings.AgentUri.ToString()); } [Theory] diff --git a/tracer/test/Datadog.Trace.Tests/TracerTests.cs b/tracer/test/Datadog.Trace.Tests/TracerTests.cs index 8706cb3af..edf181118 100644 --- a/tracer/test/Datadog.Trace.Tests/TracerTests.cs +++ b/tracer/test/Datadog.Trace.Tests/TracerTests.cs @@ -15,6 +15,7 @@ using Datadog.Trace.Propagation; using Datadog.Trace.Sampling; using Datadog.Trace.TestHelpers; +using Datadog.Trace.Tests.PlatformHelpers; using Datadog.Trace.Vendors.StatsdClient; using FluentAssertions; using Moq; @@ -38,7 +39,7 @@ public TracerTests() [Fact] public void StartActive_SetOperationName_OperationNameIsSet() { - var scope = _tracer.StartActive("Operation", null); + var scope = _tracer.StartActive("Operation"); Assert.Equal("Operation", scope.Span.OperationName); } @@ -46,7 +47,7 @@ public void StartActive_SetOperationName_OperationNameIsSet() [Fact] public void StartActive_SetOperationName_ActiveScopeIsSet() { - var scope = _tracer.StartActive("Operation", null); + var scope = _tracer.StartActive("Operation"); var activeScope = _tracer.ActiveScope; Assert.Equal(scope, activeScope); @@ -55,38 +56,44 @@ public void StartActive_SetOperationName_ActiveScopeIsSet() [Fact] public void StartActive_NoActiveScope_RootSpan() { - var scope = _tracer.StartActive("Operation", null); + var scope = (Scope)_tracer.StartActive("Operation"); + var span = scope.Span; - Assert.True(scope.Span.IsRootSpan); + Assert.True(span.IsRootSpan); } [Fact] public void StartActive_ActiveScope_UseCurrentScopeAsParent() { - var parentScope = _tracer.StartActive("Parent"); - var childScope = _tracer.StartActive("Child"); + var parentScope = (Scope)_tracer.StartActive("Parent"); + var childScope = (Scope)_tracer.StartActive("Child"); - Assert.Equal(parentScope.Span.Context, childScope.Span.Context.Parent); + var parentSpan = parentScope.Span; + var childSpan = childScope.Span; + + Assert.Equal(parentSpan.Context, childSpan.Context.Parent); } [Fact] public void StartActive_IgnoreActiveScope_RootSpan() { var firstScope = _tracer.StartActive("First"); - var secondScope = _tracer.StartActive("Second", ignoreActiveScope: true); + var secondScope = (Scope)_tracer.StartActive("Second", ignoreActiveScope: true); + var secondSpan = secondScope.Span; - Assert.True(secondScope.Span.IsRootSpan); + Assert.True(secondSpan.IsRootSpan); } [Fact] public void StartActive_FinishOnClose_SpanIsFinishedWhenScopeIsClosed() { - var scope = _tracer.StartActive("Operation"); - Assert.False(scope.Span.IsFinished); + var scope = (Scope)_tracer.StartActive("Operation"); + var span = scope.Span; + Assert.False(span.IsFinished); scope.Close(); - Assert.True(scope.Span.IsFinished); + Assert.True(span.IsFinished); Assert.Null(_tracer.ActiveScope); } @@ -94,24 +101,28 @@ public void StartActive_FinishOnClose_SpanIsFinishedWhenScopeIsClosed() public void StartActive_FinishOnClose_SpanIsFinishedWhenScopeIsDisposed() { Scope scope; - using (scope = _tracer.StartActive("Operation")) + Span span; + using (scope = (Scope)_tracer.StartActive("Operation")) { - Assert.False(scope.Span.IsFinished); + span = scope.Span; + Assert.False(span.IsFinished); } - Assert.True(scope.Span.IsFinished); + Assert.True(span.IsFinished); Assert.Null(_tracer.ActiveScope); } [Fact] public void StartActive_NoFinishOnClose_SpanIsNotFinishedWhenScopeIsClosed() { - var scope = _tracer.StartActive("Operation", finishOnClose: false); - Assert.False(scope.Span.IsFinished); + var spanCreationSettings = new SpanCreationSettings() { FinishOnClose = false }; + var scope = (Scope)_tracer.StartActive("Operation", spanCreationSettings); + var span = scope.Span; + Assert.False(span.IsFinished); scope.Dispose(); - Assert.False(scope.Span.IsFinished); + Assert.False(span.IsFinished); Assert.Null(_tracer.ActiveScope); } @@ -119,9 +130,12 @@ public void StartActive_NoFinishOnClose_SpanIsNotFinishedWhenScopeIsClosed() public void StartActive_SetParentManually_ParentIsSet() { var parent = _tracer.StartSpan("Parent"); - var child = _tracer.StartActive("Child", parent.Context); - Assert.Equal(parent.Context, child.Span.Context.Parent); + var spanCreationSettings = new SpanCreationSettings() { Parent = parent.Context }; + var childScope = (Scope)_tracer.StartActive("Child", spanCreationSettings); + var childSpan = childScope.Span; + + Assert.Equal(parent.Context, childSpan.Context.Parent); } [Fact] @@ -132,16 +146,18 @@ public void StartActive_SetParentManuallyFromExternalContext_ParentIsSet() const SamplingPriority samplingPriority = SamplingPriority.UserKeep; var parent = new SpanContext(traceId, parentId, samplingPriority); - var child = _tracer.StartActive("Child", parent); + var spanCreationSettings = new SpanCreationSettings() { Parent = parent }; + var child = (Scope)_tracer.StartActive("Child", spanCreationSettings); + var childSpan = child.Span; - Assert.True(child.Span.IsRootSpan); + Assert.True(childSpan.IsRootSpan); Assert.Equal(traceId, parent.TraceId); Assert.Equal(parentId, parent.SpanId); Assert.Null(parent.TraceContext); - Assert.Equal(parent, child.Span.Context.Parent); - Assert.Equal(parentId, child.Span.Context.ParentId); - Assert.NotNull(child.Span.Context.TraceContext); - Assert.Equal(samplingPriority, child.Span.Context.TraceContext.SamplingPriority); + Assert.Equal(parent, childSpan.Context.Parent); + Assert.Equal(parentId, childSpan.Context.ParentId); + Assert.NotNull(childSpan.Context.TraceContext); + Assert.Equal(samplingPriority, childSpan.Context.TraceContext.SamplingPriority); } [Fact] @@ -155,27 +171,32 @@ public void StartActive_NoServiceName_DefaultServiceName() [Fact] public void StartActive_SetServiceName_ServiceNameIsSet() { - var scope = _tracer.StartActive("Operation", serviceName: "MyAwesomeService"); + var scope = _tracer.StartActive("Operation"); + scope.Span.ServiceName = "MyAwesomeService"; Assert.Equal("MyAwesomeService", scope.Span.ServiceName); } [Fact] - public void StartActive_SetParentServiceName_ChildServiceNameIsSet() + public void StartActive_SetParentServiceName_ChildServiceNameIsDefaultServiceName() { - var parent = _tracer.StartActive("Parent", serviceName: "MyAwesomeService"); + var parent = _tracer.StartActive("Parent"); + parent.Span.ServiceName = "MyAwesomeService"; var child = _tracer.StartActive("Child"); - Assert.Equal("MyAwesomeService", child.Span.ServiceName); + Assert.NotEqual("MyAwesomeService", child.Span.ServiceName); + Assert.Equal(_tracer.DefaultServiceName, child.Span.ServiceName); } [Fact] public void StartActive_SetStartTime_StartTimeIsProperlySet() { var startTime = new DateTimeOffset(2017, 01, 01, 0, 0, 0, TimeSpan.Zero); - var scope = _tracer.StartActive("Operation", startTime: startTime); + var spanCreationSettings = new SpanCreationSettings() { StartTime = startTime }; + var scope = _tracer.StartActive("Operation", spanCreationSettings); + var span = (Span)scope.Span; - Assert.Equal(startTime, scope.Span.StartTime); + Assert.Equal(startTime, span.StartTime); } [Fact] @@ -198,8 +219,9 @@ public void StartManual_SetOperationName_ActiveScopeIsNotSet() public void StartManual_NoActiveScope_RootSpan() { var scope = _tracer.StartActive("Operation"); + var span = (Span)scope.Span; - Assert.True(scope.Span.IsRootSpan); + Assert.True(span.IsRootSpan); } [Fact] @@ -225,28 +247,37 @@ public void StartManual_IgnoreActiveScope_RootSpan() [Fact] public void StartActive_2ChildrenOfRoot_ChildrenParentProperlySet() { - var root = _tracer.StartActive("Root"); - var child1 = _tracer.StartActive("Child1"); + var root = (Scope)_tracer.StartActive("Root"); + var rootSpan = root.Span; + + var child1 = (Scope)_tracer.StartActive("Child1"); + var child1Span = child1.Span; child1.Dispose(); - var child2 = _tracer.StartActive("Child2"); - Assert.Equal(root.Span.Context.TraceContext, (ITraceContext)child1.Span.Context.TraceContext); - Assert.Equal(root.Span.Context.SpanId, child1.Span.Context.ParentId); - Assert.Equal(root.Span.Context.TraceContext, (ITraceContext)child2.Span.Context.TraceContext); - Assert.Equal(root.Span.Context.SpanId, child2.Span.Context.ParentId); + var child2 = (Scope)_tracer.StartActive("Child2"); + var child2Span = child2.Span; + + Assert.Equal(rootSpan.Context.TraceContext, child1Span.Context.TraceContext); + Assert.Equal(rootSpan.Context.SpanId, child1Span.Context.ParentId); + Assert.Equal(rootSpan.Context.TraceContext, child2Span.Context.TraceContext); + Assert.Equal(rootSpan.Context.SpanId, child2Span.Context.ParentId); } [Fact] public void StartActive_2LevelChildren_ChildrenParentProperlySet() { - var root = _tracer.StartActive("Root"); - var child1 = _tracer.StartActive("Child1"); - var child2 = _tracer.StartActive("Child2"); - - Assert.Equal(root.Span.Context.TraceContext, (ITraceContext)child1.Span.Context.TraceContext); - Assert.Equal(root.Span.Context.SpanId, child1.Span.Context.ParentId); - Assert.Equal(root.Span.Context.TraceContext, (ITraceContext)child2.Span.Context.TraceContext); - Assert.Equal(child1.Span.Context.SpanId, child2.Span.Context.ParentId); + var root = (Scope)_tracer.StartActive("Root"); + var child1 = (Scope)_tracer.StartActive("Child1"); + var child2 = (Scope)_tracer.StartActive("Child2"); + + var rootSpan = root.Span; + var child1Span = child1.Span; + var child2Span = child2.Span; + + Assert.Equal(rootSpan.Context.TraceContext, child1Span.Context.TraceContext); + Assert.Equal(rootSpan.Context.SpanId, child1Span.Context.ParentId); + Assert.Equal(rootSpan.Context.TraceContext, child2Span.Context.TraceContext); + Assert.Equal(child1Span.Context.SpanId, child2Span.Context.ParentId); } [Fact] @@ -254,25 +285,29 @@ public async Task StartActive_AsyncChildrenCreation_ChildrenParentProperlySet() { var tcs = new TaskCompletionSource(); - var root = _tracer.StartActive("Root"); + var root = (Scope)_tracer.StartActive("Root"); + var rootSpan = root.Span; - Func> createSpanAsync = async (t) => + Func> createSpanAsync = async (t) => { await tcs.Task; return t.StartActive("AsyncChild"); }; var tasks = Enumerable.Range(0, 10).Select(x => createSpanAsync(_tracer)).ToArray(); - var syncChild = _tracer.StartActive("SyncChild"); + var syncChild = (Scope)_tracer.StartActive("SyncChild"); + var syncChildSpan = syncChild.Span; tcs.SetResult(true); - Assert.Equal(root.Span.Context.TraceContext, (ITraceContext)syncChild.Span.Context.TraceContext); - Assert.Equal(root.Span.Context.SpanId, syncChild.Span.Context.ParentId); + Assert.Equal(rootSpan.Context.TraceContext, syncChildSpan.Context.TraceContext); + Assert.Equal(rootSpan.Context.SpanId, syncChildSpan.Context.ParentId); foreach (var task in tasks) { - var span = await task; - Assert.Equal(root.Span.Context.TraceContext, (ITraceContext)span.Span.Context.TraceContext); - Assert.Equal(root.Span.Context.SpanId, span.Span.Context.ParentId); + var scope = (Scope)await task; + var span = scope.Span; + + Assert.Equal(rootSpan.Context.TraceContext, span.Context.TraceContext); + Assert.Equal(rootSpan.Context.SpanId, span.Context.ParentId); } } @@ -287,7 +322,7 @@ public void SetEnv(string env) }; var tracer = TracerHelper.Create(settings); - Span span = tracer.StartSpan("operation"); + ISpan span = tracer.StartSpan("operation"); Assert.Equal(env, span.GetTag(Tags.Env)); } @@ -308,11 +343,14 @@ public void SetServiceName(string tracerServiceName, string spanServiceName, str }; var tracer = TracerHelper.Create(settings); - Span span = tracer.StartSpan("operationName", serviceName: spanServiceName); + ISpan span = tracer.StartSpan("operationName", serviceName: spanServiceName); if (expectedServiceName == null) { - Assert.Contains(span.ServiceName, TestRunners.ValidNames); + // due to the service name fallback, if this runs at the same time as AzureAppServicesMetadataTests, + // then AzureAppServices.IsRelevant returns true, and we may pull the service name from the AAS env vars + var expectedServiceNames = TestRunners.ValidNames.Concat(new[] { AzureAppServicesMetadataTests.DeploymentId }); + Assert.Contains(span.ServiceName, expectedServiceNames); } else { @@ -331,15 +369,21 @@ public void OriginHeader_RootSpanTag() var propagatedContext = new SpanContext(traceId, spanId, samplingPriority, null, origin); Assert.Equal(origin, propagatedContext.Origin); - using var firstSpan = _tracer.StartActive("First Span", propagatedContext); - Assert.True(firstSpan.Span.IsRootSpan); - Assert.Equal(origin, firstSpan.Span.Context.Origin); - Assert.Equal(origin, firstSpan.Span.GetTag(Tags.Origin)); + var spanCreationSettings = new SpanCreationSettings() { Parent = propagatedContext }; + using var firstScope = (Scope)_tracer.StartActive("First Span", spanCreationSettings); + var firstSpan = (Span)firstScope.Span; - using var secondSpan = _tracer.StartActive("Child", firstSpan.Span.Context); - Assert.False(secondSpan.Span.IsRootSpan); - Assert.Equal(origin, secondSpan.Span.Context.Origin); - Assert.Equal(origin, secondSpan.Span.GetTag(Tags.Origin)); + Assert.True(firstSpan.IsRootSpan); + Assert.Equal(origin, firstSpan.Context.Origin); + Assert.Equal(origin, firstSpan.GetTag(Tags.Origin)); + + var spanCreationSettings2 = new SpanCreationSettings() { Parent = firstSpan.Context }; + using var secondScope = (Scope)_tracer.StartActive("Child", spanCreationSettings2); + var secondSpan = (Span)secondScope.Span; + + Assert.False(secondSpan.IsRootSpan); + Assert.Equal(origin, secondSpan.Context.Origin); + Assert.Equal(origin, secondSpan.GetTag(Tags.Origin)); } [Fact] @@ -353,17 +397,22 @@ public void OriginHeader_InjectFromChildSpan() var propagatedContext = new SpanContext(traceId, spanId, samplingPriority, null, origin); var propagator = new DDSpanContextPropagator(new DatadogTraceIdConvention()); - using var firstSpan = _tracer.StartActive("First Span", propagatedContext); - using var secondSpan = _tracer.StartActive("Child", firstSpan.Span.Context); + var spanCreationSettings = new SpanCreationSettings() { Parent = propagatedContext }; + using var firstScope = (Scope)_tracer.StartActive("First Span", spanCreationSettings); + var firstSpan = firstScope.Span; + + var spanCreationSettings2 = new SpanCreationSettings() { Parent = firstSpan.Context }; + using var secondScope = (Scope)_tracer.StartActive("Child", spanCreationSettings2); + var secondSpan = secondScope.Span; IHeadersCollection headers = WebRequest.CreateHttp("http://localhost").Headers.Wrap(); - propagator.Inject(secondSpan.Span.Context, headers); + propagator.Inject(secondSpan.Context, headers); var resultContext = propagator.Extract(headers); Assert.NotNull(resultContext); - Assert.Equal(firstSpan.Span.Context.Origin, resultContext.Origin); - Assert.Equal(secondSpan.Span.Context.Origin, resultContext.Origin); + Assert.Equal(firstSpan.Context.Origin, resultContext.Origin); + Assert.Equal(secondSpan.Context.Origin, resultContext.Origin); Assert.Equal(origin, resultContext.Origin); } diff --git a/tracer/test/benchmarks/Benchmarks.Trace/AgentWriterBenchmark.cs b/tracer/test/benchmarks/Benchmarks.Trace/AgentWriterBenchmark.cs index 3b339e066..099b80f2d 100644 --- a/tracer/test/benchmarks/Benchmarks.Trace/AgentWriterBenchmark.cs +++ b/tracer/test/benchmarks/Benchmarks.Trace/AgentWriterBenchmark.cs @@ -28,7 +28,7 @@ static AgentWriterBenchmark() settings.StartupDiagnosticLogEnabled = false; settings.TraceEnabled = false; - var api = new Api(settings.AgentUri, new FakeApiRequestFactory(), statsd: null, updateSampleRates: null, isPartialFlushEnabled: false); + var api = new Api(settings.ExporterSettings.AgentUri, new FakeApiRequestFactory(), statsd: null, updateSampleRates: null, isPartialFlushEnabled: false); AgentWriter = new AgentWriter(api, new NullMetrics(), automaticFlush: false); diff --git a/tracer/test/benchmarks/Benchmarks.Trace/NLogBenchmark.cs b/tracer/test/benchmarks/Benchmarks.Trace/NLogBenchmark.cs index cfb088fba..8115f84fa 100644 --- a/tracer/test/benchmarks/Benchmarks.Trace/NLogBenchmark.cs +++ b/tracer/test/benchmarks/Benchmarks.Trace/NLogBenchmark.cs @@ -1,6 +1,9 @@ +using System; using System.IO; using BenchmarkDotNet.Attributes; +using BenchmarkDotNet.Engines; using Datadog.Trace; +using Datadog.Trace.ClrProfiler.AutoInstrumentation.Logging.NLog.LogsInjection; using Datadog.Trace.Configuration; using Datadog.Trace.Logging; using NLog; @@ -17,7 +20,7 @@ public class NLogBenchmark static NLogBenchmark() { - LogProvider.SetCurrentLogProvider(new CustomNLogLogProvider()); + LogProvider.SetCurrentLogProvider(new NoOpNLogLogProvider()); var logInjectionSettings = new TracerSettings { @@ -47,6 +50,9 @@ static NLogBenchmark() LogManager.Configuration = config; Logger = LogManager.GetCurrentClassLogger(); + + // Run the automatic instrumentation initialization code once outside of the microbenchmark + _ = DiagnosticContextHelper.Cache.Mdlc; } [Benchmark] @@ -56,7 +62,27 @@ public void EnrichedLog() { using (LogInjectionTracer.StartActive("Child")) { + object state = null; + + if (DiagnosticContextHelper.Cache.Mdlc is { } mdlc) + { + state = DiagnosticContextHelper.SetMdlcState(mdlc, LogInjectionTracer); + } + else if (DiagnosticContextHelper.Cache.Mdc is { } mdc) + { + state = DiagnosticContextHelper.SetMdcState(mdc, LogInjectionTracer); + } + Logger.Info("Hello"); + + if (state is IDisposable disposable) + { + disposable.Dispose(); + } + else if (state is bool removeTraceIds && DiagnosticContextHelper.Cache.Mdc is { } mdc2) + { + DiagnosticContextHelper.RemoveMdcState(mdc2, removeTraceIds); + } } } } diff --git a/tracer/test/benchmarks/Benchmarks.Trace/SerilogBenchmark.cs b/tracer/test/benchmarks/Benchmarks.Trace/SerilogBenchmark.cs index d2e3cc536..c56fdeb54 100644 --- a/tracer/test/benchmarks/Benchmarks.Trace/SerilogBenchmark.cs +++ b/tracer/test/benchmarks/Benchmarks.Trace/SerilogBenchmark.cs @@ -1,11 +1,17 @@ +using System; +using System.Collections; +using System.Linq; using BenchmarkDotNet.Attributes; using Datadog.Trace; +using Datadog.Trace.ClrProfiler.AutoInstrumentation.Logging.Serilog.LogsInjection; using Datadog.Trace.Configuration; +using Datadog.Trace.DuckTyping; using Datadog.Trace.Logging; using Serilog; using Serilog.Core; using Serilog.Events; using Serilog.Formatting.Display; +using Serilog.Parsing; using Logger = Serilog.Core.Logger; namespace Benchmarks.Trace @@ -16,9 +22,12 @@ public class SerilogBenchmark private static readonly Logger Logger; private static readonly Tracer LogInjectionTracer; + [Params(1, 10, 100)] + public static int N { get; set; } + static SerilogBenchmark() { - LogProvider.SetCurrentLogProvider(new CustomSerilogLogProvider()); + LogProvider.SetCurrentLogProvider(new NoOpSerilogLogProvider()); var logInjectionSettings = new TracerSettings { @@ -47,7 +56,40 @@ public void EnrichedLog() { using (LogInjectionTracer.StartActive("Child")) { - Logger.Information("Hello"); + for (int i = 0; i < N; i++) + { + var logEvent = new LogEvent( + DateTimeOffset.Now, + LogEventLevel.Information, + exception: null, + new MessageTemplate("Hello", Enumerable.Empty()), + properties: Enumerable.Empty()); + + // equivalent of auto-instrumentation + var tracer = LogInjectionTracer; + var dict = logEvent.DuckCast().Properties; + AddPropertyIfAbsent(dict, CorrelationIdentifier.SerilogServiceKey, tracer.DefaultServiceName); + AddPropertyIfAbsent(dict, CorrelationIdentifier.SerilogVersionKey, tracer.Settings.ServiceVersion); + AddPropertyIfAbsent(dict, CorrelationIdentifier.SerilogEnvKey, tracer.Settings.Environment); + + var span = tracer.ActiveScope?.Span; + if (span is not null) + { + AddPropertyIfAbsent(dict, CorrelationIdentifier.SerilogTraceIdKey, span.TraceId.ToString()); + AddPropertyIfAbsent(dict, CorrelationIdentifier.SerilogSpanIdKey, span.SpanId.ToString()); + } + + Logger.Write(logEvent); + } + } + } + + static void AddPropertyIfAbsent(IDictionary dict, string key, string value) + { + if (!dict.Contains(key)) + { + var property = SerilogLogPropertyHelper.CreateScalarValue(value ?? string.Empty); + dict.Add(key, property); } } } diff --git a/tracer/test/benchmarks/Benchmarks.Trace/SpanBenchmark.cs b/tracer/test/benchmarks/Benchmarks.Trace/SpanBenchmark.cs index 7269c7cb0..243ea0625 100644 --- a/tracer/test/benchmarks/Benchmarks.Trace/SpanBenchmark.cs +++ b/tracer/test/benchmarks/Benchmarks.Trace/SpanBenchmark.cs @@ -31,7 +31,7 @@ static SpanBenchmark() [Benchmark] public void StartFinishSpan() { - Span span = Tracer.StartSpan("operation"); + var span = Tracer.StartSpan("operation"); span.SetTraceSamplingPriority(SamplingPriority.UserReject); span.Finish(); } @@ -42,7 +42,7 @@ public void StartFinishSpan() [Benchmark] public void StartFinishScope() { - using (Scope scope = Tracer.StartActive("operation")) + using (Scope scope = Tracer.StartActiveInternal("operation")) { scope.Span.SetTraceSamplingPriority(SamplingPriority.UserReject); } diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Admin_Home_Index_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Admin_Home_Index_statusCode=200.verified.txt index 2420813f4..3ee8ed361 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Admin_Home_Index_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Admin_Home_Index_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /admin/home/index, + Name: GET home.index, LogicScope: aspnet-mvc.request, - Resource: GET /admin/home/index, + Resource: GET home.index, Service: sample, Type: web, ParentId: Id_3, @@ -27,9 +27,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /admin/home/index, + Name: GET home.index, LogicScope: aspnet.request, - Resource: GET /admin/home/index, + Resource: GET home.index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Admin_Home_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Admin_Home_statusCode=200.verified.txt index 70706f612..8794225f3 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Admin_Home_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Admin_Home_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /admin/home/index, + Name: GET home.index, LogicScope: aspnet-mvc.request, - Resource: GET /admin/home/index, + Resource: GET home.index, Service: sample, Type: web, ParentId: Id_3, @@ -27,9 +27,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /admin/home/index, + Name: GET home.index, LogicScope: aspnet.request, - Resource: GET /admin/home/index, + Resource: GET home.index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Admin_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Admin_statusCode=200.verified.txt index e5423b0c3..aa5461421 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Admin_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Admin_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /admin/home/index, + Name: GET home.index, LogicScope: aspnet-mvc.request, - Resource: GET /admin/home/index, + Resource: GET home.index, Service: sample, Type: web, ParentId: Id_3, @@ -27,9 +27,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /admin/home/index, + Name: GET home.index, LogicScope: aspnet.request, - Resource: GET /admin/home/index, + Resource: GET home.index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_BadRequest_statusCode=500.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_BadRequest_statusCode=500.verified.txt index 4246ad062..ea74e3f13 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_BadRequest_statusCode=500.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_BadRequest_statusCode=500.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/badrequest, + Name: GET home.badrequest, LogicScope: aspnet.request, - Resource: GET /home/badrequest, + Resource: GET home.badrequest, Service: sample, Type: web, Error: 1, @@ -36,9 +36,9 @@ at Samples.AspNetMvc4.Controllers.HomeController.BadRequest(), { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/badrequest, + Name: GET home.badrequest, LogicScope: aspnet-mvc.request, - Resource: GET /home/badrequest, + Resource: GET home.badrequest, Service: sample, Type: web, ParentId: Id_2, diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_Index_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_Index_statusCode=200.verified.txt index 2a8b7df1c..1c077c55a 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_Index_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_Index_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/index, + Name: GET home.index, LogicScope: aspnet-mvc.request, - Resource: GET /home/index, + Resource: GET home.index, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/index, + Name: GET home.index, LogicScope: aspnet.request, - Resource: GET /home/index, + Resource: GET home.index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_OptionalIdentifier_123_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_OptionalIdentifier_123_statusCode=200.verified.txt index 586a9c78d..fdefe33da 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_OptionalIdentifier_123_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_OptionalIdentifier_123_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/optionalidentifier/{id}, + Name: GET home.optionalidentifier, LogicScope: aspnet-mvc.request, - Resource: GET /home/optionalidentifier/{id}, + Resource: GET home.optionalidentifier, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/optionalidentifier/{id}, + Name: GET home.optionalidentifier, LogicScope: aspnet.request, - Resource: GET /home/optionalidentifier/{id}, + Resource: GET home.optionalidentifier, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_OptionalIdentifier_BadValue_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_OptionalIdentifier_BadValue_statusCode=200.verified.txt index d86f4ee0c..3bba14288 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_OptionalIdentifier_BadValue_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_OptionalIdentifier_BadValue_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/optionalidentifier/{id}, + Name: GET home.optionalidentifier, LogicScope: aspnet-mvc.request, - Resource: GET /home/optionalidentifier/{id}, + Resource: GET home.optionalidentifier, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/optionalidentifier/{id}, + Name: GET home.optionalidentifier, LogicScope: aspnet.request, - Resource: GET /home/optionalidentifier/{id}, + Resource: GET home.optionalidentifier, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_OptionalIdentifier_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_OptionalIdentifier_statusCode=200.verified.txt index 0e1cf3283..0d5fd14b3 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_OptionalIdentifier_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_OptionalIdentifier_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/optionalidentifier, + Name: GET home.optionalidentifier, LogicScope: aspnet-mvc.request, - Resource: GET /home/optionalidentifier, + Resource: GET home.optionalidentifier, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/optionalidentifier, + Name: GET home.optionalidentifier, LogicScope: aspnet.request, - Resource: GET /home/optionalidentifier, + Resource: GET home.optionalidentifier, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_StatusCode-value=201_statusCode=201.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_StatusCode-value=201_statusCode=201.verified.txt index faf21a8cc..36d78d882 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_StatusCode-value=201_statusCode=201.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_StatusCode-value=201_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/statuscode, + Name: GET home.statuscode, LogicScope: aspnet-mvc.request, - Resource: GET /home/statuscode, + Resource: GET home.statuscode, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/statuscode, + Name: GET home.statuscode, LogicScope: aspnet.request, - Resource: GET /home/statuscode, + Resource: GET home.statuscode, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_StatusCode-value=503_statusCode=503.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_StatusCode-value=503_statusCode=503.verified.txt index e909cb962..a4f8e97b2 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_StatusCode-value=503_statusCode=503.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_StatusCode-value=503_statusCode=503.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/statuscode, + Name: GET home.statuscode, LogicScope: aspnet-mvc.request, - Resource: GET /home/statuscode, + Resource: GET home.statuscode, Service: sample, Type: web, ParentId: Id_3, @@ -28,9 +28,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/statuscode, + Name: GET home.statuscode, LogicScope: aspnet.request, - Resource: GET /home/statuscode, + Resource: GET home.statuscode, Service: sample, Type: web, Error: 1, diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_identifier_123_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_identifier_123_statusCode=200.verified.txt index bdb4feae8..6a07996c9 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_identifier_123_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_identifier_123_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/identifier/{id}, + Name: GET home.identifier, LogicScope: aspnet-mvc.request, - Resource: GET /home/identifier/{id}, + Resource: GET home.identifier, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/identifier/{id}, + Name: GET home.identifier, LogicScope: aspnet.request, - Resource: GET /home/identifier/{id}, + Resource: GET home.identifier, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_identifier_BadValue_statusCode=500.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_identifier_BadValue_statusCode=500.verified.txt index 4678195e5..b891befca 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_identifier_BadValue_statusCode=500.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_identifier_BadValue_statusCode=500.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/identifier/{id}, + Name: GET home.identifier, LogicScope: aspnet.request, - Resource: GET /home/identifier/{id}, + Resource: GET home.identifier, Service: sample, Type: web, Error: 1, @@ -39,9 +39,9 @@ at System.Web.Mvc.ActionDescriptor.ExtractParameterFromDictionary(ParameterInfo { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/identifier/{id}, + Name: GET home.identifier, LogicScope: aspnet-mvc.request, - Resource: GET /home/identifier/{id}, + Resource: GET home.identifier, Service: sample, Type: web, ParentId: Id_2, diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_identifier_statusCode=500.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_identifier_statusCode=500.verified.txt index e92f1e09b..678888da2 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_identifier_statusCode=500.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_identifier_statusCode=500.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/identifier, + Name: GET home.identifier, LogicScope: aspnet.request, - Resource: GET /home/identifier, + Resource: GET home.identifier, Service: sample, Type: web, Error: 1, @@ -39,9 +39,9 @@ at System.Web.Mvc.ActionDescriptor.ExtractParameterFromDictionary(ParameterInfo { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/identifier, + Name: GET home.identifier, LogicScope: aspnet-mvc.request, - Resource: GET /home/identifier, + Resource: GET home.identifier, Service: sample, Type: web, ParentId: Id_2, diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_statusCode=200.verified.txt index 66f4ba70f..f8d2b75ec 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=_Home_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/index, + Name: GET home.index, LogicScope: aspnet-mvc.request, - Resource: GET /home/index, + Resource: GET home.index, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/index, + Name: GET home.index, LogicScope: aspnet.request, - Resource: GET /home/index, + Resource: GET home.index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=__statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=__statusCode=200.verified.txt index 8601313cb..ac4c48172 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=__statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.NoFF.__path=__statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/index, + Name: GET home.index, LogicScope: aspnet-mvc.request, - Resource: GET /home/index, + Resource: GET home.index, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/index, + Name: GET home.index, LogicScope: aspnet.request, - Resource: GET /home/index, + Resource: GET home.index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Admin_Home_Index_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Admin_Home_Index_statusCode=200.verified.txt index 3ee8ed361..2420813f4 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Admin_Home_Index_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Admin_Home_Index_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.index, + Name: GET /admin/home/index, LogicScope: aspnet-mvc.request, - Resource: GET home.index, + Resource: GET /admin/home/index, Service: sample, Type: web, ParentId: Id_3, @@ -27,9 +27,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.index, + Name: GET /admin/home/index, LogicScope: aspnet.request, - Resource: GET home.index, + Resource: GET /admin/home/index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Admin_Home_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Admin_Home_statusCode=200.verified.txt index 8794225f3..70706f612 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Admin_Home_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Admin_Home_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.index, + Name: GET /admin/home/index, LogicScope: aspnet-mvc.request, - Resource: GET home.index, + Resource: GET /admin/home/index, Service: sample, Type: web, ParentId: Id_3, @@ -27,9 +27,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.index, + Name: GET /admin/home/index, LogicScope: aspnet.request, - Resource: GET home.index, + Resource: GET /admin/home/index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Admin_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Admin_statusCode=200.verified.txt index aa5461421..e5423b0c3 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Admin_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Admin_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.index, + Name: GET /admin/home/index, LogicScope: aspnet-mvc.request, - Resource: GET home.index, + Resource: GET /admin/home/index, Service: sample, Type: web, ParentId: Id_3, @@ -27,9 +27,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.index, + Name: GET /admin/home/index, LogicScope: aspnet.request, - Resource: GET home.index, + Resource: GET /admin/home/index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_BadRequest_statusCode=500.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_BadRequest_statusCode=500.verified.txt index ea74e3f13..4246ad062 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_BadRequest_statusCode=500.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_BadRequest_statusCode=500.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.badrequest, + Name: GET /home/badrequest, LogicScope: aspnet.request, - Resource: GET home.badrequest, + Resource: GET /home/badrequest, Service: sample, Type: web, Error: 1, @@ -36,9 +36,9 @@ at Samples.AspNetMvc4.Controllers.HomeController.BadRequest(), { TraceId: Id_1, SpanId: Id_3, - Name: GET home.badrequest, + Name: GET /home/badrequest, LogicScope: aspnet-mvc.request, - Resource: GET home.badrequest, + Resource: GET /home/badrequest, Service: sample, Type: web, ParentId: Id_2, diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_Index_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_Index_statusCode=200.verified.txt index 1c077c55a..2a8b7df1c 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_Index_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_Index_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.index, + Name: GET /home/index, LogicScope: aspnet-mvc.request, - Resource: GET home.index, + Resource: GET /home/index, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.index, + Name: GET /home/index, LogicScope: aspnet.request, - Resource: GET home.index, + Resource: GET /home/index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_OptionalIdentifier_123_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_OptionalIdentifier_123_statusCode=200.verified.txt index fdefe33da..586a9c78d 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_OptionalIdentifier_123_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_OptionalIdentifier_123_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.optionalidentifier, + Name: GET /home/optionalidentifier/{id}, LogicScope: aspnet-mvc.request, - Resource: GET home.optionalidentifier, + Resource: GET /home/optionalidentifier/{id}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.optionalidentifier, + Name: GET /home/optionalidentifier/{id}, LogicScope: aspnet.request, - Resource: GET home.optionalidentifier, + Resource: GET /home/optionalidentifier/{id}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_OptionalIdentifier_BadValue_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_OptionalIdentifier_BadValue_statusCode=200.verified.txt index 3bba14288..d86f4ee0c 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_OptionalIdentifier_BadValue_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_OptionalIdentifier_BadValue_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.optionalidentifier, + Name: GET /home/optionalidentifier/{id}, LogicScope: aspnet-mvc.request, - Resource: GET home.optionalidentifier, + Resource: GET /home/optionalidentifier/{id}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.optionalidentifier, + Name: GET /home/optionalidentifier/{id}, LogicScope: aspnet.request, - Resource: GET home.optionalidentifier, + Resource: GET /home/optionalidentifier/{id}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_OptionalIdentifier_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_OptionalIdentifier_statusCode=200.verified.txt index 0d5fd14b3..0e1cf3283 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_OptionalIdentifier_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_OptionalIdentifier_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.optionalidentifier, + Name: GET /home/optionalidentifier, LogicScope: aspnet-mvc.request, - Resource: GET home.optionalidentifier, + Resource: GET /home/optionalidentifier, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.optionalidentifier, + Name: GET /home/optionalidentifier, LogicScope: aspnet.request, - Resource: GET home.optionalidentifier, + Resource: GET /home/optionalidentifier, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_StatusCode-value=201_statusCode=201.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_StatusCode-value=201_statusCode=201.verified.txt index 36d78d882..faf21a8cc 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_StatusCode-value=201_statusCode=201.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_StatusCode-value=201_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.statuscode, + Name: GET /home/statuscode, LogicScope: aspnet-mvc.request, - Resource: GET home.statuscode, + Resource: GET /home/statuscode, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.statuscode, + Name: GET /home/statuscode, LogicScope: aspnet.request, - Resource: GET home.statuscode, + Resource: GET /home/statuscode, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_StatusCode-value=503_statusCode=503.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_StatusCode-value=503_statusCode=503.verified.txt index a4f8e97b2..e909cb962 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_StatusCode-value=503_statusCode=503.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_StatusCode-value=503_statusCode=503.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.statuscode, + Name: GET /home/statuscode, LogicScope: aspnet-mvc.request, - Resource: GET home.statuscode, + Resource: GET /home/statuscode, Service: sample, Type: web, ParentId: Id_3, @@ -28,9 +28,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.statuscode, + Name: GET /home/statuscode, LogicScope: aspnet.request, - Resource: GET home.statuscode, + Resource: GET /home/statuscode, Service: sample, Type: web, Error: 1, diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_identifier_123_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_identifier_123_statusCode=200.verified.txt index 6a07996c9..bdb4feae8 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_identifier_123_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_identifier_123_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.identifier, + Name: GET /home/identifier/{id}, LogicScope: aspnet-mvc.request, - Resource: GET home.identifier, + Resource: GET /home/identifier/{id}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.identifier, + Name: GET /home/identifier/{id}, LogicScope: aspnet.request, - Resource: GET home.identifier, + Resource: GET /home/identifier/{id}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_identifier_BadValue_statusCode=500.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_identifier_BadValue_statusCode=500.verified.txt index b891befca..4678195e5 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_identifier_BadValue_statusCode=500.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_identifier_BadValue_statusCode=500.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.identifier, + Name: GET /home/identifier/{id}, LogicScope: aspnet.request, - Resource: GET home.identifier, + Resource: GET /home/identifier/{id}, Service: sample, Type: web, Error: 1, @@ -39,9 +39,9 @@ at System.Web.Mvc.ActionDescriptor.ExtractParameterFromDictionary(ParameterInfo { TraceId: Id_1, SpanId: Id_3, - Name: GET home.identifier, + Name: GET /home/identifier/{id}, LogicScope: aspnet-mvc.request, - Resource: GET home.identifier, + Resource: GET /home/identifier/{id}, Service: sample, Type: web, ParentId: Id_2, diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_identifier_statusCode=500.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_identifier_statusCode=500.verified.txt index 678888da2..e92f1e09b 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_identifier_statusCode=500.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_identifier_statusCode=500.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.identifier, + Name: GET /home/identifier, LogicScope: aspnet.request, - Resource: GET home.identifier, + Resource: GET /home/identifier, Service: sample, Type: web, Error: 1, @@ -39,9 +39,9 @@ at System.Web.Mvc.ActionDescriptor.ExtractParameterFromDictionary(ParameterInfo { TraceId: Id_1, SpanId: Id_3, - Name: GET home.identifier, + Name: GET /home/identifier, LogicScope: aspnet-mvc.request, - Resource: GET home.identifier, + Resource: GET /home/identifier, Service: sample, Type: web, ParentId: Id_2, diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_statusCode=200.verified.txt index f8d2b75ec..66f4ba70f 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=_Home_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.index, + Name: GET /home/index, LogicScope: aspnet-mvc.request, - Resource: GET home.index, + Resource: GET /home/index, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.index, + Name: GET /home/index, LogicScope: aspnet.request, - Resource: GET home.index, + Resource: GET /home/index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=__statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=__statusCode=200.verified.txt index ac4c48172..8601313cb 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=__statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Classic.WithFF.__path=__statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.index, + Name: GET /home/index, LogicScope: aspnet-mvc.request, - Resource: GET home.index, + Resource: GET /home/index, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.index, + Name: GET /home/index, LogicScope: aspnet.request, - Resource: GET home.index, + Resource: GET /home/index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Admin_Home_Index_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Admin_Home_Index_statusCode=200.verified.txt index 2420813f4..3ee8ed361 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Admin_Home_Index_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Admin_Home_Index_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /admin/home/index, + Name: GET home.index, LogicScope: aspnet-mvc.request, - Resource: GET /admin/home/index, + Resource: GET home.index, Service: sample, Type: web, ParentId: Id_3, @@ -27,9 +27,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /admin/home/index, + Name: GET home.index, LogicScope: aspnet.request, - Resource: GET /admin/home/index, + Resource: GET home.index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Admin_Home_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Admin_Home_statusCode=200.verified.txt index 70706f612..8794225f3 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Admin_Home_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Admin_Home_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /admin/home/index, + Name: GET home.index, LogicScope: aspnet-mvc.request, - Resource: GET /admin/home/index, + Resource: GET home.index, Service: sample, Type: web, ParentId: Id_3, @@ -27,9 +27,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /admin/home/index, + Name: GET home.index, LogicScope: aspnet.request, - Resource: GET /admin/home/index, + Resource: GET home.index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Admin_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Admin_statusCode=200.verified.txt index e5423b0c3..aa5461421 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Admin_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Admin_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /admin/home/index, + Name: GET home.index, LogicScope: aspnet-mvc.request, - Resource: GET /admin/home/index, + Resource: GET home.index, Service: sample, Type: web, ParentId: Id_3, @@ -27,9 +27,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /admin/home/index, + Name: GET home.index, LogicScope: aspnet.request, - Resource: GET /admin/home/index, + Resource: GET home.index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_BadRequest_statusCode=500.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_BadRequest_statusCode=500.verified.txt index f0db39f3a..3679b0388 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_BadRequest_statusCode=500.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_BadRequest_statusCode=500.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/badrequest, + Name: GET home.badrequest, LogicScope: aspnet.request, - Resource: GET /home/badrequest, + Resource: GET home.badrequest, Service: sample, Type: web, Error: 1, @@ -36,9 +36,9 @@ at Samples.AspNetMvc4.Controllers.HomeController.BadRequest(), { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/badrequest, + Name: GET home.badrequest, LogicScope: aspnet-mvc.request, - Resource: GET /home/badrequest, + Resource: GET home.badrequest, Service: sample, Type: web, ParentId: Id_2, diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_Index_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_Index_statusCode=200.verified.txt index 2a8b7df1c..1c077c55a 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_Index_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_Index_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/index, + Name: GET home.index, LogicScope: aspnet-mvc.request, - Resource: GET /home/index, + Resource: GET home.index, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/index, + Name: GET home.index, LogicScope: aspnet.request, - Resource: GET /home/index, + Resource: GET home.index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_OptionalIdentifier_123_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_OptionalIdentifier_123_statusCode=200.verified.txt index 586a9c78d..fdefe33da 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_OptionalIdentifier_123_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_OptionalIdentifier_123_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/optionalidentifier/{id}, + Name: GET home.optionalidentifier, LogicScope: aspnet-mvc.request, - Resource: GET /home/optionalidentifier/{id}, + Resource: GET home.optionalidentifier, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/optionalidentifier/{id}, + Name: GET home.optionalidentifier, LogicScope: aspnet.request, - Resource: GET /home/optionalidentifier/{id}, + Resource: GET home.optionalidentifier, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_OptionalIdentifier_BadValue_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_OptionalIdentifier_BadValue_statusCode=200.verified.txt index d86f4ee0c..3bba14288 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_OptionalIdentifier_BadValue_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_OptionalIdentifier_BadValue_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/optionalidentifier/{id}, + Name: GET home.optionalidentifier, LogicScope: aspnet-mvc.request, - Resource: GET /home/optionalidentifier/{id}, + Resource: GET home.optionalidentifier, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/optionalidentifier/{id}, + Name: GET home.optionalidentifier, LogicScope: aspnet.request, - Resource: GET /home/optionalidentifier/{id}, + Resource: GET home.optionalidentifier, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_OptionalIdentifier_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_OptionalIdentifier_statusCode=200.verified.txt index 0e1cf3283..0d5fd14b3 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_OptionalIdentifier_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_OptionalIdentifier_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/optionalidentifier, + Name: GET home.optionalidentifier, LogicScope: aspnet-mvc.request, - Resource: GET /home/optionalidentifier, + Resource: GET home.optionalidentifier, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/optionalidentifier, + Name: GET home.optionalidentifier, LogicScope: aspnet.request, - Resource: GET /home/optionalidentifier, + Resource: GET home.optionalidentifier, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_StatusCode-value=201_statusCode=201.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_StatusCode-value=201_statusCode=201.verified.txt index faf21a8cc..36d78d882 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_StatusCode-value=201_statusCode=201.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_StatusCode-value=201_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/statuscode, + Name: GET home.statuscode, LogicScope: aspnet-mvc.request, - Resource: GET /home/statuscode, + Resource: GET home.statuscode, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/statuscode, + Name: GET home.statuscode, LogicScope: aspnet.request, - Resource: GET /home/statuscode, + Resource: GET home.statuscode, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_StatusCode-value=503_statusCode=503.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_StatusCode-value=503_statusCode=503.verified.txt index e909cb962..a4f8e97b2 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_StatusCode-value=503_statusCode=503.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_StatusCode-value=503_statusCode=503.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/statuscode, + Name: GET home.statuscode, LogicScope: aspnet-mvc.request, - Resource: GET /home/statuscode, + Resource: GET home.statuscode, Service: sample, Type: web, ParentId: Id_3, @@ -28,9 +28,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/statuscode, + Name: GET home.statuscode, LogicScope: aspnet.request, - Resource: GET /home/statuscode, + Resource: GET home.statuscode, Service: sample, Type: web, Error: 1, diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_identifier_123_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_identifier_123_statusCode=200.verified.txt index bdb4feae8..6a07996c9 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_identifier_123_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_identifier_123_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/identifier/{id}, + Name: GET home.identifier, LogicScope: aspnet-mvc.request, - Resource: GET /home/identifier/{id}, + Resource: GET home.identifier, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/identifier/{id}, + Name: GET home.identifier, LogicScope: aspnet.request, - Resource: GET /home/identifier/{id}, + Resource: GET home.identifier, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_identifier_BadValue_statusCode=500.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_identifier_BadValue_statusCode=500.verified.txt index 0b00db3ba..c02dd5e38 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_identifier_BadValue_statusCode=500.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_identifier_BadValue_statusCode=500.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/identifier/{id}, + Name: GET home.identifier, LogicScope: aspnet.request, - Resource: GET /home/identifier/{id}, + Resource: GET home.identifier, Service: sample, Type: web, Error: 1, @@ -39,9 +39,9 @@ at System.Web.Mvc.ActionDescriptor.ExtractParameterFromDictionary(ParameterInfo { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/identifier/{id}, + Name: GET home.identifier, LogicScope: aspnet-mvc.request, - Resource: GET /home/identifier/{id}, + Resource: GET home.identifier, Service: sample, Type: web, ParentId: Id_2, diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_identifier_statusCode=500.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_identifier_statusCode=500.verified.txt index 2637299c8..fdcc01ad3 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_identifier_statusCode=500.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_identifier_statusCode=500.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/identifier, + Name: GET home.identifier, LogicScope: aspnet.request, - Resource: GET /home/identifier, + Resource: GET home.identifier, Service: sample, Type: web, Error: 1, @@ -39,9 +39,9 @@ at System.Web.Mvc.ActionDescriptor.ExtractParameterFromDictionary(ParameterInfo { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/identifier, + Name: GET home.identifier, LogicScope: aspnet-mvc.request, - Resource: GET /home/identifier, + Resource: GET home.identifier, Service: sample, Type: web, ParentId: Id_2, diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_statusCode=200.verified.txt index 66f4ba70f..f8d2b75ec 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=_Home_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/index, + Name: GET home.index, LogicScope: aspnet-mvc.request, - Resource: GET /home/index, + Resource: GET home.index, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/index, + Name: GET home.index, LogicScope: aspnet.request, - Resource: GET /home/index, + Resource: GET home.index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=__statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=__statusCode=200.verified.txt index 8601313cb..ac4c48172 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=__statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.NoFF.__path=__statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/index, + Name: GET home.index, LogicScope: aspnet-mvc.request, - Resource: GET /home/index, + Resource: GET home.index, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/index, + Name: GET home.index, LogicScope: aspnet.request, - Resource: GET /home/index, + Resource: GET home.index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Admin_Home_Index_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Admin_Home_Index_statusCode=200.verified.txt index 3ee8ed361..2420813f4 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Admin_Home_Index_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Admin_Home_Index_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.index, + Name: GET /admin/home/index, LogicScope: aspnet-mvc.request, - Resource: GET home.index, + Resource: GET /admin/home/index, Service: sample, Type: web, ParentId: Id_3, @@ -27,9 +27,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.index, + Name: GET /admin/home/index, LogicScope: aspnet.request, - Resource: GET home.index, + Resource: GET /admin/home/index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Admin_Home_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Admin_Home_statusCode=200.verified.txt index 8794225f3..70706f612 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Admin_Home_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Admin_Home_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.index, + Name: GET /admin/home/index, LogicScope: aspnet-mvc.request, - Resource: GET home.index, + Resource: GET /admin/home/index, Service: sample, Type: web, ParentId: Id_3, @@ -27,9 +27,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.index, + Name: GET /admin/home/index, LogicScope: aspnet.request, - Resource: GET home.index, + Resource: GET /admin/home/index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Admin_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Admin_statusCode=200.verified.txt index aa5461421..e5423b0c3 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Admin_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Admin_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.index, + Name: GET /admin/home/index, LogicScope: aspnet-mvc.request, - Resource: GET home.index, + Resource: GET /admin/home/index, Service: sample, Type: web, ParentId: Id_3, @@ -27,9 +27,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.index, + Name: GET /admin/home/index, LogicScope: aspnet.request, - Resource: GET home.index, + Resource: GET /admin/home/index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_BadRequest_statusCode=500.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_BadRequest_statusCode=500.verified.txt index 3679b0388..f0db39f3a 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_BadRequest_statusCode=500.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_BadRequest_statusCode=500.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.badrequest, + Name: GET /home/badrequest, LogicScope: aspnet.request, - Resource: GET home.badrequest, + Resource: GET /home/badrequest, Service: sample, Type: web, Error: 1, @@ -36,9 +36,9 @@ at Samples.AspNetMvc4.Controllers.HomeController.BadRequest(), { TraceId: Id_1, SpanId: Id_3, - Name: GET home.badrequest, + Name: GET /home/badrequest, LogicScope: aspnet-mvc.request, - Resource: GET home.badrequest, + Resource: GET /home/badrequest, Service: sample, Type: web, ParentId: Id_2, diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_Index_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_Index_statusCode=200.verified.txt index 1c077c55a..2a8b7df1c 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_Index_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_Index_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.index, + Name: GET /home/index, LogicScope: aspnet-mvc.request, - Resource: GET home.index, + Resource: GET /home/index, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.index, + Name: GET /home/index, LogicScope: aspnet.request, - Resource: GET home.index, + Resource: GET /home/index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_OptionalIdentifier_123_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_OptionalIdentifier_123_statusCode=200.verified.txt index fdefe33da..586a9c78d 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_OptionalIdentifier_123_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_OptionalIdentifier_123_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.optionalidentifier, + Name: GET /home/optionalidentifier/{id}, LogicScope: aspnet-mvc.request, - Resource: GET home.optionalidentifier, + Resource: GET /home/optionalidentifier/{id}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.optionalidentifier, + Name: GET /home/optionalidentifier/{id}, LogicScope: aspnet.request, - Resource: GET home.optionalidentifier, + Resource: GET /home/optionalidentifier/{id}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_OptionalIdentifier_BadValue_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_OptionalIdentifier_BadValue_statusCode=200.verified.txt index 3bba14288..d86f4ee0c 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_OptionalIdentifier_BadValue_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_OptionalIdentifier_BadValue_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.optionalidentifier, + Name: GET /home/optionalidentifier/{id}, LogicScope: aspnet-mvc.request, - Resource: GET home.optionalidentifier, + Resource: GET /home/optionalidentifier/{id}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.optionalidentifier, + Name: GET /home/optionalidentifier/{id}, LogicScope: aspnet.request, - Resource: GET home.optionalidentifier, + Resource: GET /home/optionalidentifier/{id}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_OptionalIdentifier_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_OptionalIdentifier_statusCode=200.verified.txt index 0d5fd14b3..0e1cf3283 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_OptionalIdentifier_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_OptionalIdentifier_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.optionalidentifier, + Name: GET /home/optionalidentifier, LogicScope: aspnet-mvc.request, - Resource: GET home.optionalidentifier, + Resource: GET /home/optionalidentifier, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.optionalidentifier, + Name: GET /home/optionalidentifier, LogicScope: aspnet.request, - Resource: GET home.optionalidentifier, + Resource: GET /home/optionalidentifier, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_StatusCode-value=201_statusCode=201.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_StatusCode-value=201_statusCode=201.verified.txt index 36d78d882..faf21a8cc 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_StatusCode-value=201_statusCode=201.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_StatusCode-value=201_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.statuscode, + Name: GET /home/statuscode, LogicScope: aspnet-mvc.request, - Resource: GET home.statuscode, + Resource: GET /home/statuscode, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.statuscode, + Name: GET /home/statuscode, LogicScope: aspnet.request, - Resource: GET home.statuscode, + Resource: GET /home/statuscode, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_StatusCode-value=503_statusCode=503.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_StatusCode-value=503_statusCode=503.verified.txt index a4f8e97b2..e909cb962 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_StatusCode-value=503_statusCode=503.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_StatusCode-value=503_statusCode=503.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.statuscode, + Name: GET /home/statuscode, LogicScope: aspnet-mvc.request, - Resource: GET home.statuscode, + Resource: GET /home/statuscode, Service: sample, Type: web, ParentId: Id_3, @@ -28,9 +28,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.statuscode, + Name: GET /home/statuscode, LogicScope: aspnet.request, - Resource: GET home.statuscode, + Resource: GET /home/statuscode, Service: sample, Type: web, Error: 1, diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_identifier_123_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_identifier_123_statusCode=200.verified.txt index 6a07996c9..bdb4feae8 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_identifier_123_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_identifier_123_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.identifier, + Name: GET /home/identifier/{id}, LogicScope: aspnet-mvc.request, - Resource: GET home.identifier, + Resource: GET /home/identifier/{id}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.identifier, + Name: GET /home/identifier/{id}, LogicScope: aspnet.request, - Resource: GET home.identifier, + Resource: GET /home/identifier/{id}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_identifier_BadValue_statusCode=500.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_identifier_BadValue_statusCode=500.verified.txt index c02dd5e38..0b00db3ba 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_identifier_BadValue_statusCode=500.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_identifier_BadValue_statusCode=500.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.identifier, + Name: GET /home/identifier/{id}, LogicScope: aspnet.request, - Resource: GET home.identifier, + Resource: GET /home/identifier/{id}, Service: sample, Type: web, Error: 1, @@ -39,9 +39,9 @@ at System.Web.Mvc.ActionDescriptor.ExtractParameterFromDictionary(ParameterInfo { TraceId: Id_1, SpanId: Id_3, - Name: GET home.identifier, + Name: GET /home/identifier/{id}, LogicScope: aspnet-mvc.request, - Resource: GET home.identifier, + Resource: GET /home/identifier/{id}, Service: sample, Type: web, ParentId: Id_2, diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_identifier_statusCode=500.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_identifier_statusCode=500.verified.txt index fdcc01ad3..2637299c8 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_identifier_statusCode=500.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_identifier_statusCode=500.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.identifier, + Name: GET /home/identifier, LogicScope: aspnet.request, - Resource: GET home.identifier, + Resource: GET /home/identifier, Service: sample, Type: web, Error: 1, @@ -39,9 +39,9 @@ at System.Web.Mvc.ActionDescriptor.ExtractParameterFromDictionary(ParameterInfo { TraceId: Id_1, SpanId: Id_3, - Name: GET home.identifier, + Name: GET /home/identifier, LogicScope: aspnet-mvc.request, - Resource: GET home.identifier, + Resource: GET /home/identifier, Service: sample, Type: web, ParentId: Id_2, diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_statusCode=200.verified.txt index f8d2b75ec..66f4ba70f 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=_Home_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.index, + Name: GET /home/index, LogicScope: aspnet-mvc.request, - Resource: GET home.index, + Resource: GET /home/index, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.index, + Name: GET /home/index, LogicScope: aspnet.request, - Resource: GET home.index, + Resource: GET /home/index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=__statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=__statusCode=200.verified.txt index ac4c48172..8601313cb 100644 --- a/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=__statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc4Tests.Integrated.WithFF.__path=__statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.index, + Name: GET /home/index, LogicScope: aspnet-mvc.request, - Resource: GET home.index, + Resource: GET /home/index, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.index, + Name: GET /home/index, LogicScope: aspnet.request, - Resource: GET home.index, + Resource: GET /home/index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_DataDog_DogHouse_Woof_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_DataDog_DogHouse_Woof_statusCode=200.verified.txt index 5d3414f87..3dd2504f9 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_DataDog_DogHouse_Woof_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_DataDog_DogHouse_Woof_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /datadog/doghouse/woof, + Name: GET doghouse.woof, LogicScope: aspnet-mvc.request, - Resource: GET /datadog/doghouse/woof, + Resource: GET doghouse.woof, Service: sample, Type: web, ParentId: Id_3, @@ -27,9 +27,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /datadog/doghouse/woof, + Name: GET doghouse.woof, LogicScope: aspnet.request, - Resource: GET /datadog/doghouse/woof, + Resource: GET doghouse.woof, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_DataDog_DogHouse_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_DataDog_DogHouse_statusCode=200.verified.txt index 105ce577a..bcb514c11 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_DataDog_DogHouse_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_DataDog_DogHouse_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /datadog/doghouse/index, + Name: GET doghouse.index, LogicScope: aspnet-mvc.request, - Resource: GET /datadog/doghouse/index, + Resource: GET doghouse.index, Service: sample, Type: web, ParentId: Id_3, @@ -27,9 +27,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /datadog/doghouse/index, + Name: GET doghouse.index, LogicScope: aspnet.request, - Resource: GET /datadog/doghouse/index, + Resource: GET doghouse.index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_DataDog_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_DataDog_statusCode=200.verified.txt index 6e07a0124..df898497e 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_DataDog_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_DataDog_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /datadog/doghouse/index, + Name: GET doghouse.index, LogicScope: aspnet-mvc.request, - Resource: GET /datadog/doghouse/index, + Resource: GET doghouse.index, Service: sample, Type: web, ParentId: Id_3, @@ -27,9 +27,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /datadog/doghouse/index, + Name: GET doghouse.index, LogicScope: aspnet.request, - Resource: GET /datadog/doghouse/index, + Resource: GET doghouse.index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_Home_Get_3_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_Home_Get_3_statusCode=200.verified.txt index ea217c94d..248bb20ff 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_Home_Get_3_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_Home_Get_3_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/get/{id}, + Name: GET home.get, LogicScope: aspnet-mvc.request, - Resource: GET /home/get/{id}, + Resource: GET home.get, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/get/{id}, + Name: GET home.get, LogicScope: aspnet.request, - Resource: GET /home/get/{id}, + Resource: GET home.get, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_Home_Get_statusCode=500.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_Home_Get_statusCode=500.verified.txt index 1ef5dd436..5c106a782 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_Home_Get_statusCode=500.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_Home_Get_statusCode=500.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/get, + Name: GET home.get, LogicScope: aspnet.request, - Resource: GET /home/get, + Resource: GET home.get, Service: sample, Type: web, Error: 1, @@ -39,9 +39,9 @@ at System.Web.Mvc.ActionDescriptor.ExtractParameterFromDictionary(ParameterInfo { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/get, + Name: GET home.get, LogicScope: aspnet-mvc.request, - Resource: GET /home/get, + Resource: GET home.get, Service: sample, Type: web, ParentId: Id_2, diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_Home_Index_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_Home_Index_statusCode=200.verified.txt index 2a8b7df1c..1c077c55a 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_Home_Index_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_Home_Index_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/index, + Name: GET home.index, LogicScope: aspnet-mvc.request, - Resource: GET /home/index, + Resource: GET home.index, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/index, + Name: GET home.index, LogicScope: aspnet.request, - Resource: GET /home/index, + Resource: GET home.index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_Home_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_Home_statusCode=200.verified.txt index 66f4ba70f..f8d2b75ec 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_Home_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=_Home_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/index, + Name: GET home.index, LogicScope: aspnet-mvc.request, - Resource: GET /home/index, + Resource: GET home.index, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/index, + Name: GET home.index, LogicScope: aspnet.request, - Resource: GET /home/index, + Resource: GET home.index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=__statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=__statusCode=200.verified.txt index 8601313cb..ac4c48172 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=__statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Classic.NoFF.__path=__statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/index, + Name: GET home.index, LogicScope: aspnet-mvc.request, - Resource: GET /home/index, + Resource: GET home.index, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/index, + Name: GET home.index, LogicScope: aspnet.request, - Resource: GET /home/index, + Resource: GET home.index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_DataDog_DogHouse_Woof_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_DataDog_DogHouse_Woof_statusCode=200.verified.txt index 3dd2504f9..5d3414f87 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_DataDog_DogHouse_Woof_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_DataDog_DogHouse_Woof_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET doghouse.woof, + Name: GET /datadog/doghouse/woof, LogicScope: aspnet-mvc.request, - Resource: GET doghouse.woof, + Resource: GET /datadog/doghouse/woof, Service: sample, Type: web, ParentId: Id_3, @@ -27,9 +27,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET doghouse.woof, + Name: GET /datadog/doghouse/woof, LogicScope: aspnet.request, - Resource: GET doghouse.woof, + Resource: GET /datadog/doghouse/woof, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_DataDog_DogHouse_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_DataDog_DogHouse_statusCode=200.verified.txt index bcb514c11..105ce577a 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_DataDog_DogHouse_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_DataDog_DogHouse_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET doghouse.index, + Name: GET /datadog/doghouse/index, LogicScope: aspnet-mvc.request, - Resource: GET doghouse.index, + Resource: GET /datadog/doghouse/index, Service: sample, Type: web, ParentId: Id_3, @@ -27,9 +27,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET doghouse.index, + Name: GET /datadog/doghouse/index, LogicScope: aspnet.request, - Resource: GET doghouse.index, + Resource: GET /datadog/doghouse/index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_DataDog_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_DataDog_statusCode=200.verified.txt index df898497e..6e07a0124 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_DataDog_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_DataDog_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET doghouse.index, + Name: GET /datadog/doghouse/index, LogicScope: aspnet-mvc.request, - Resource: GET doghouse.index, + Resource: GET /datadog/doghouse/index, Service: sample, Type: web, ParentId: Id_3, @@ -27,9 +27,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET doghouse.index, + Name: GET /datadog/doghouse/index, LogicScope: aspnet.request, - Resource: GET doghouse.index, + Resource: GET /datadog/doghouse/index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_Home_Get_3_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_Home_Get_3_statusCode=200.verified.txt index 248bb20ff..ea217c94d 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_Home_Get_3_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_Home_Get_3_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.get, + Name: GET /home/get/{id}, LogicScope: aspnet-mvc.request, - Resource: GET home.get, + Resource: GET /home/get/{id}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.get, + Name: GET /home/get/{id}, LogicScope: aspnet.request, - Resource: GET home.get, + Resource: GET /home/get/{id}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_Home_Get_statusCode=500.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_Home_Get_statusCode=500.verified.txt index 5c106a782..1ef5dd436 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_Home_Get_statusCode=500.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_Home_Get_statusCode=500.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.get, + Name: GET /home/get, LogicScope: aspnet.request, - Resource: GET home.get, + Resource: GET /home/get, Service: sample, Type: web, Error: 1, @@ -39,9 +39,9 @@ at System.Web.Mvc.ActionDescriptor.ExtractParameterFromDictionary(ParameterInfo { TraceId: Id_1, SpanId: Id_3, - Name: GET home.get, + Name: GET /home/get, LogicScope: aspnet-mvc.request, - Resource: GET home.get, + Resource: GET /home/get, Service: sample, Type: web, ParentId: Id_2, diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_Home_Index_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_Home_Index_statusCode=200.verified.txt index 1c077c55a..2a8b7df1c 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_Home_Index_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_Home_Index_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.index, + Name: GET /home/index, LogicScope: aspnet-mvc.request, - Resource: GET home.index, + Resource: GET /home/index, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.index, + Name: GET /home/index, LogicScope: aspnet.request, - Resource: GET home.index, + Resource: GET /home/index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_Home_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_Home_statusCode=200.verified.txt index f8d2b75ec..66f4ba70f 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_Home_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=_Home_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.index, + Name: GET /home/index, LogicScope: aspnet-mvc.request, - Resource: GET home.index, + Resource: GET /home/index, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.index, + Name: GET /home/index, LogicScope: aspnet.request, - Resource: GET home.index, + Resource: GET /home/index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=__statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=__statusCode=200.verified.txt index ac4c48172..8601313cb 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=__statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Classic.WithFF.__path=__statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.index, + Name: GET /home/index, LogicScope: aspnet-mvc.request, - Resource: GET home.index, + Resource: GET /home/index, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.index, + Name: GET /home/index, LogicScope: aspnet.request, - Resource: GET home.index, + Resource: GET /home/index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_DataDog_DogHouse_Woof_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_DataDog_DogHouse_Woof_statusCode=200.verified.txt index 5d3414f87..3dd2504f9 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_DataDog_DogHouse_Woof_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_DataDog_DogHouse_Woof_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /datadog/doghouse/woof, + Name: GET doghouse.woof, LogicScope: aspnet-mvc.request, - Resource: GET /datadog/doghouse/woof, + Resource: GET doghouse.woof, Service: sample, Type: web, ParentId: Id_3, @@ -27,9 +27,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /datadog/doghouse/woof, + Name: GET doghouse.woof, LogicScope: aspnet.request, - Resource: GET /datadog/doghouse/woof, + Resource: GET doghouse.woof, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_DataDog_DogHouse_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_DataDog_DogHouse_statusCode=200.verified.txt index 105ce577a..bcb514c11 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_DataDog_DogHouse_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_DataDog_DogHouse_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /datadog/doghouse/index, + Name: GET doghouse.index, LogicScope: aspnet-mvc.request, - Resource: GET /datadog/doghouse/index, + Resource: GET doghouse.index, Service: sample, Type: web, ParentId: Id_3, @@ -27,9 +27,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /datadog/doghouse/index, + Name: GET doghouse.index, LogicScope: aspnet.request, - Resource: GET /datadog/doghouse/index, + Resource: GET doghouse.index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_DataDog_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_DataDog_statusCode=200.verified.txt index 6e07a0124..df898497e 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_DataDog_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_DataDog_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /datadog/doghouse/index, + Name: GET doghouse.index, LogicScope: aspnet-mvc.request, - Resource: GET /datadog/doghouse/index, + Resource: GET doghouse.index, Service: sample, Type: web, ParentId: Id_3, @@ -27,9 +27,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /datadog/doghouse/index, + Name: GET doghouse.index, LogicScope: aspnet.request, - Resource: GET /datadog/doghouse/index, + Resource: GET doghouse.index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_Home_Get_3_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_Home_Get_3_statusCode=200.verified.txt index ea217c94d..248bb20ff 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_Home_Get_3_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_Home_Get_3_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/get/{id}, + Name: GET home.get, LogicScope: aspnet-mvc.request, - Resource: GET /home/get/{id}, + Resource: GET home.get, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/get/{id}, + Name: GET home.get, LogicScope: aspnet.request, - Resource: GET /home/get/{id}, + Resource: GET home.get, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_Home_Get_statusCode=500.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_Home_Get_statusCode=500.verified.txt index 99845be6e..066602479 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_Home_Get_statusCode=500.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_Home_Get_statusCode=500.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/get, + Name: GET home.get, LogicScope: aspnet.request, - Resource: GET /home/get, + Resource: GET home.get, Service: sample, Type: web, Error: 1, @@ -39,9 +39,9 @@ at System.Web.Mvc.ActionDescriptor.ExtractParameterFromDictionary(ParameterInfo { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/get, + Name: GET home.get, LogicScope: aspnet-mvc.request, - Resource: GET /home/get, + Resource: GET home.get, Service: sample, Type: web, ParentId: Id_2, diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_Home_Index_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_Home_Index_statusCode=200.verified.txt index 2a8b7df1c..1c077c55a 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_Home_Index_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_Home_Index_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/index, + Name: GET home.index, LogicScope: aspnet-mvc.request, - Resource: GET /home/index, + Resource: GET home.index, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/index, + Name: GET home.index, LogicScope: aspnet.request, - Resource: GET /home/index, + Resource: GET home.index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_Home_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_Home_statusCode=200.verified.txt index 66f4ba70f..f8d2b75ec 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_Home_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=_Home_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/index, + Name: GET home.index, LogicScope: aspnet-mvc.request, - Resource: GET /home/index, + Resource: GET home.index, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/index, + Name: GET home.index, LogicScope: aspnet.request, - Resource: GET /home/index, + Resource: GET home.index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=__statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=__statusCode=200.verified.txt index 8601313cb..ac4c48172 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=__statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.NoFF.__path=__statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /home/index, + Name: GET home.index, LogicScope: aspnet-mvc.request, - Resource: GET /home/index, + Resource: GET home.index, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /home/index, + Name: GET home.index, LogicScope: aspnet.request, - Resource: GET /home/index, + Resource: GET home.index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_DataDog_DogHouse_Woof_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_DataDog_DogHouse_Woof_statusCode=200.verified.txt index 3dd2504f9..5d3414f87 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_DataDog_DogHouse_Woof_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_DataDog_DogHouse_Woof_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET doghouse.woof, + Name: GET /datadog/doghouse/woof, LogicScope: aspnet-mvc.request, - Resource: GET doghouse.woof, + Resource: GET /datadog/doghouse/woof, Service: sample, Type: web, ParentId: Id_3, @@ -27,9 +27,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET doghouse.woof, + Name: GET /datadog/doghouse/woof, LogicScope: aspnet.request, - Resource: GET doghouse.woof, + Resource: GET /datadog/doghouse/woof, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_DataDog_DogHouse_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_DataDog_DogHouse_statusCode=200.verified.txt index bcb514c11..105ce577a 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_DataDog_DogHouse_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_DataDog_DogHouse_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET doghouse.index, + Name: GET /datadog/doghouse/index, LogicScope: aspnet-mvc.request, - Resource: GET doghouse.index, + Resource: GET /datadog/doghouse/index, Service: sample, Type: web, ParentId: Id_3, @@ -27,9 +27,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET doghouse.index, + Name: GET /datadog/doghouse/index, LogicScope: aspnet.request, - Resource: GET doghouse.index, + Resource: GET /datadog/doghouse/index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_DataDog_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_DataDog_statusCode=200.verified.txt index df898497e..6e07a0124 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_DataDog_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_DataDog_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET doghouse.index, + Name: GET /datadog/doghouse/index, LogicScope: aspnet-mvc.request, - Resource: GET doghouse.index, + Resource: GET /datadog/doghouse/index, Service: sample, Type: web, ParentId: Id_3, @@ -27,9 +27,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET doghouse.index, + Name: GET /datadog/doghouse/index, LogicScope: aspnet.request, - Resource: GET doghouse.index, + Resource: GET /datadog/doghouse/index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_Home_Get_3_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_Home_Get_3_statusCode=200.verified.txt index 248bb20ff..ea217c94d 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_Home_Get_3_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_Home_Get_3_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.get, + Name: GET /home/get/{id}, LogicScope: aspnet-mvc.request, - Resource: GET home.get, + Resource: GET /home/get/{id}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.get, + Name: GET /home/get/{id}, LogicScope: aspnet.request, - Resource: GET home.get, + Resource: GET /home/get/{id}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_Home_Get_statusCode=500.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_Home_Get_statusCode=500.verified.txt index 066602479..99845be6e 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_Home_Get_statusCode=500.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_Home_Get_statusCode=500.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.get, + Name: GET /home/get, LogicScope: aspnet.request, - Resource: GET home.get, + Resource: GET /home/get, Service: sample, Type: web, Error: 1, @@ -39,9 +39,9 @@ at System.Web.Mvc.ActionDescriptor.ExtractParameterFromDictionary(ParameterInfo { TraceId: Id_1, SpanId: Id_3, - Name: GET home.get, + Name: GET /home/get, LogicScope: aspnet-mvc.request, - Resource: GET home.get, + Resource: GET /home/get, Service: sample, Type: web, ParentId: Id_2, diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_Home_Index_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_Home_Index_statusCode=200.verified.txt index 1c077c55a..2a8b7df1c 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_Home_Index_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_Home_Index_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.index, + Name: GET /home/index, LogicScope: aspnet-mvc.request, - Resource: GET home.index, + Resource: GET /home/index, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.index, + Name: GET /home/index, LogicScope: aspnet.request, - Resource: GET home.index, + Resource: GET /home/index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_Home_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_Home_statusCode=200.verified.txt index f8d2b75ec..66f4ba70f 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_Home_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=_Home_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.index, + Name: GET /home/index, LogicScope: aspnet-mvc.request, - Resource: GET home.index, + Resource: GET /home/index, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.index, + Name: GET /home/index, LogicScope: aspnet.request, - Resource: GET home.index, + Resource: GET /home/index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=__statusCode=200.verified.txt b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=__statusCode=200.verified.txt index ac4c48172..8601313cb 100644 --- a/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=__statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetMvc5Tests.Integrated.WithFF.__path=__statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET home.index, + Name: GET /home/index, LogicScope: aspnet-mvc.request, - Resource: GET home.index, + Resource: GET /home/index, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET home.index, + Name: GET /home/index, LogicScope: aspnet.request, - Resource: GET home.index, + Resource: GET /home/index, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_delayAsync_0_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_delayAsync_0_statusCode=200.verified.txt index 70b6d31bb..01bb9cb12 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_delayAsync_0_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_delayAsync_0_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/delayasync/{value}, + Name: GET api2/delayasync/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/delayasync/{value}, + Resource: GET api2/delayasync/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api2/delayasync/{value}, + Name: GET api2/delayasync/{value}, LogicScope: aspnet.request, - Resource: GET /api2/delayasync/{value}, + Resource: GET api2/delayasync/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_delay_0_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_delay_0_statusCode=200.verified.txt index a2b7fb554..1f88266f2 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_delay_0_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_delay_0_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/delay/{value}, + Name: GET api2/delay/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/delay/{value}, + Resource: GET api2/delay/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api2/delay/{value}, + Name: GET api2/delay/{value}, LogicScope: aspnet.request, - Resource: GET /api2/delay/{value}, + Resource: GET api2/delay/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_optional_1_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_optional_1_statusCode=200.verified.txt index 8a53db2ff..163297512 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_optional_1_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_optional_1_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/optional/{value}, + Name: GET api2/optional/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/optional/{value}, + Resource: GET api2/optional/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api2/optional/{value}, + Name: GET api2/optional/{value}, LogicScope: aspnet.request, - Resource: GET /api2/optional/{value}, + Resource: GET api2/optional/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_optional_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_optional_statusCode=200.verified.txt index 34d2e66ba..6c5b8f2ee 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_optional_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_optional_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/optional/{value}, + Name: GET api2/optional/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/optional/{value}, + Resource: GET api2/optional/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api2/optional/{value}, + Name: GET api2/optional/{value}, LogicScope: aspnet.request, - Resource: GET /api2/optional/{value}, + Resource: GET api2/optional/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_statuscode_201-ps=true&ts=false_statusCode=201.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_statuscode_201-ps=true&ts=false_statusCode=201.verified.txt index 4cfca6f64..300bd2b2b 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_statuscode_201-ps=true&ts=false_statusCode=201.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_statuscode_201-ps=true&ts=false_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/statuscode/{value}, + Name: GET api2/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/statuscode/{value}, + Resource: GET api2/statuscode/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api2/statuscode/{value}, + Name: GET api2/statuscode/{value}, LogicScope: aspnet.request, - Resource: GET /api2/statuscode/{value}, + Resource: GET api2/statuscode/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_statuscode_201-ps=true&ts=true_statusCode=201.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_statuscode_201-ps=true&ts=true_statusCode=201.verified.txt index 6816df4e8..f93704002 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_statuscode_201-ps=true&ts=true_statusCode=201.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_statuscode_201-ps=true&ts=true_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/statuscode/{value}, + Name: GET api2/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/statuscode/{value}, + Resource: GET api2/statuscode/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api2/statuscode/{value}, + Name: GET api2/statuscode/{value}, LogicScope: aspnet.request, - Resource: GET /api2/statuscode/{value}, + Resource: GET api2/statuscode/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_statuscode_201_statusCode=201.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_statuscode_201_statusCode=201.verified.txt index c0282f1c2..b12ad5ad9 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_statuscode_201_statusCode=201.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_statuscode_201_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/statuscode/{value}, + Name: GET api2/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/statuscode/{value}, + Resource: GET api2/statuscode/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api2/statuscode/{value}, + Name: GET api2/statuscode/{value}, LogicScope: aspnet.request, - Resource: GET /api2/statuscode/{value}, + Resource: GET api2/statuscode/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_statuscode_503_statusCode=503.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_statuscode_503_statusCode=503.verified.txt index 297f3fb2f..b331c1f5a 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_statuscode_503_statusCode=503.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_statuscode_503_statusCode=503.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/statuscode/{value}, + Name: GET api2/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/statuscode/{value}, + Resource: GET api2/statuscode/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -28,9 +28,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api2/statuscode/{value}, + Name: GET api2/statuscode/{value}, LogicScope: aspnet.request, - Resource: GET /api2/statuscode/{value}, + Resource: GET api2/statuscode/{value}, Service: sample, Type: web, Error: 1, diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_transientfailure_false_statusCode=500.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_transientfailure_false_statusCode=500.verified.txt index 7d8864109..2384e13fe 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_transientfailure_false_statusCode=500.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_transientfailure_false_statusCode=500.verified.txt @@ -15,9 +15,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api2/transientfailure/{value}, + Name: GET api2/transientfailure/{value}, LogicScope: aspnet.request, - Resource: GET /api2/transientfailure/{value}, + Resource: GET api2/transientfailure/{value}, Service: sample, Type: web, Error: 1, @@ -49,9 +49,9 @@ at Samples.AspNetMvc5.Controllers.ConventionsController.TransientFailure(String { TraceId: Id_1, SpanId: Id_4, - Name: GET /api2/transientfailure/{value}, + Name: GET api2/transientfailure/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/transientfailure/{value}, + Resource: GET api2/transientfailure/{value}, Service: sample, Type: web, ParentId: Id_3, diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_transientfailure_true_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_transientfailure_true_statusCode=200.verified.txt index 1335c6607..8b92f71a6 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_transientfailure_true_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api2_transientfailure_true_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/transientfailure/{value}, + Name: GET api2/transientfailure/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/transientfailure/{value}, + Resource: GET api2/transientfailure/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api2/transientfailure/{value}, + Name: GET api2/transientfailure/{value}, LogicScope: aspnet.request, - Resource: GET /api2/transientfailure/{value}, + Resource: GET api2/transientfailure/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_absolute-route_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_absolute-route_statusCode=200.verified.txt index cb43e6aff..c4c16382d 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_absolute-route_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_absolute-route_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/absolute-route, + Name: GET api/absolute-route, LogicScope: aspnet-webapi.request, - Resource: GET /api/absolute-route, + Resource: GET api/absolute-route, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api/absolute-route, + Name: GET api/absolute-route, LogicScope: aspnet.request, - Resource: GET /api/absolute-route, + Resource: GET api/absolute-route, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_delay-async_0_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_delay-async_0_statusCode=200.verified.txt index d01c468b8..a720b6712 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_delay-async_0_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_delay-async_0_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/delay-async/{seconds}, + Name: GET api/delay-async/{seconds}, LogicScope: aspnet-webapi.request, - Resource: GET /api/delay-async/{seconds}, + Resource: GET api/delay-async/{seconds}, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api/delay-async/{seconds}, + Name: GET api/delay-async/{seconds}, LogicScope: aspnet.request, - Resource: GET /api/delay-async/{seconds}, + Resource: GET api/delay-async/{seconds}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_delay-optional_1_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_delay-optional_1_statusCode=200.verified.txt index 3560930b6..acac2d245 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_delay-optional_1_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_delay-optional_1_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/delay-optional/{seconds}, + Name: GET api/delay-optional/{seconds}, LogicScope: aspnet-webapi.request, - Resource: GET /api/delay-optional/{seconds}, + Resource: GET api/delay-optional/{seconds}, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api/delay-optional/{seconds}, + Name: GET api/delay-optional/{seconds}, LogicScope: aspnet.request, - Resource: GET /api/delay-optional/{seconds}, + Resource: GET api/delay-optional/{seconds}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_delay-optional_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_delay-optional_statusCode=200.verified.txt index f6b603ba7..0dde13b30 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_delay-optional_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_delay-optional_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/delay-optional/{seconds}, + Name: GET api/delay-optional/{seconds}, LogicScope: aspnet-webapi.request, - Resource: GET /api/delay-optional/{seconds}, + Resource: GET api/delay-optional/{seconds}, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api/delay-optional/{seconds}, + Name: GET api/delay-optional/{seconds}, LogicScope: aspnet.request, - Resource: GET /api/delay-optional/{seconds}, + Resource: GET api/delay-optional/{seconds}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_delay_0_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_delay_0_statusCode=200.verified.txt index fb5e18235..4282597e1 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_delay_0_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_delay_0_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/delay/{seconds}, + Name: GET api/delay/{seconds}, LogicScope: aspnet-webapi.request, - Resource: GET /api/delay/{seconds}, + Resource: GET api/delay/{seconds}, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api/delay/{seconds}, + Name: GET api/delay/{seconds}, LogicScope: aspnet.request, - Resource: GET /api/delay/{seconds}, + Resource: GET api/delay/{seconds}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_environment_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_environment_statusCode=200.verified.txt index 94b85dcc8..19515f598 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_environment_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_environment_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/environment, + Name: GET api/environment, LogicScope: aspnet-webapi.request, - Resource: GET /api/environment, + Resource: GET api/environment, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api/environment, + Name: GET api/environment, LogicScope: aspnet.request, - Resource: GET /api/environment, + Resource: GET api/environment, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_statuscode_201_statusCode=201.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_statuscode_201_statusCode=201.verified.txt index 140c16cb6..ade17caa4 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_statuscode_201_statusCode=201.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_statuscode_201_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/statuscode/{value}, + Name: GET api/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api/statuscode/{value}, + Resource: GET api/statuscode/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api/statuscode/{value}, + Name: GET api/statuscode/{value}, LogicScope: aspnet.request, - Resource: GET /api/statuscode/{value}, + Resource: GET api/statuscode/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_statuscode_503_statusCode=503.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_statuscode_503_statusCode=503.verified.txt index da8091077..7f9d58585 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_statuscode_503_statusCode=503.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_statuscode_503_statusCode=503.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/statuscode/{value}, + Name: GET api/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api/statuscode/{value}, + Resource: GET api/statuscode/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api/statuscode/{value}, + Name: GET api/statuscode/{value}, LogicScope: aspnet.request, - Resource: GET /api/statuscode/{value}, + Resource: GET api/statuscode/{value}, Service: sample, Type: web, Error: 1, diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_transient-failure_false_statusCode=500.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_transient-failure_false_statusCode=500.verified.txt index 5884e14eb..ff56d4921 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_transient-failure_false_statusCode=500.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_transient-failure_false_statusCode=500.verified.txt @@ -15,9 +15,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api/transient-failure/{value}, + Name: GET api/transient-failure/{value}, LogicScope: aspnet.request, - Resource: GET /api/transient-failure/{value}, + Resource: GET api/transient-failure/{value}, Service: sample, Type: web, Error: 1, @@ -49,9 +49,9 @@ at Samples.AspNetMvc5.Controllers.ApiController.TransientFailure(String value), { TraceId: Id_1, SpanId: Id_4, - Name: GET /api/transient-failure/{value}, + Name: GET api/transient-failure/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api/transient-failure/{value}, + Resource: GET api/transient-failure/{value}, Service: sample, Type: web, ParentId: Id_3, diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_transient-failure_true_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_transient-failure_true_statusCode=200.verified.txt index d0dfe307c..b7177d833 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_transient-failure_true_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.NoFF.__path=_api_transient-failure_true_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/transient-failure/{value}, + Name: GET api/transient-failure/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api/transient-failure/{value}, + Resource: GET api/transient-failure/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api/transient-failure/{value}, + Name: GET api/transient-failure/{value}, LogicScope: aspnet.request, - Resource: GET /api/transient-failure/{value}, + Resource: GET api/transient-failure/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_delayAsync_0_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_delayAsync_0_statusCode=200.verified.txt index 01bb9cb12..70b6d31bb 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_delayAsync_0_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_delayAsync_0_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/delayasync/{value}, + Name: GET /api2/delayasync/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/delayasync/{value}, + Resource: GET /api2/delayasync/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api2/delayasync/{value}, + Name: GET /api2/delayasync/{value}, LogicScope: aspnet.request, - Resource: GET api2/delayasync/{value}, + Resource: GET /api2/delayasync/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_delay_0_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_delay_0_statusCode=200.verified.txt index 1f88266f2..a2b7fb554 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_delay_0_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_delay_0_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/delay/{value}, + Name: GET /api2/delay/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/delay/{value}, + Resource: GET /api2/delay/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api2/delay/{value}, + Name: GET /api2/delay/{value}, LogicScope: aspnet.request, - Resource: GET api2/delay/{value}, + Resource: GET /api2/delay/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_optional_1_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_optional_1_statusCode=200.verified.txt index 163297512..8a53db2ff 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_optional_1_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_optional_1_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/optional/{value}, + Name: GET /api2/optional/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/optional/{value}, + Resource: GET /api2/optional/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api2/optional/{value}, + Name: GET /api2/optional/{value}, LogicScope: aspnet.request, - Resource: GET api2/optional/{value}, + Resource: GET /api2/optional/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_optional_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_optional_statusCode=200.verified.txt index 6c5b8f2ee..34d2e66ba 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_optional_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_optional_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/optional/{value}, + Name: GET /api2/optional/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/optional/{value}, + Resource: GET /api2/optional/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api2/optional/{value}, + Name: GET /api2/optional/{value}, LogicScope: aspnet.request, - Resource: GET api2/optional/{value}, + Resource: GET /api2/optional/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_statuscode_201-ps=true&ts=false_statusCode=201.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_statuscode_201-ps=true&ts=false_statusCode=201.verified.txt index 300bd2b2b..4cfca6f64 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_statuscode_201-ps=true&ts=false_statusCode=201.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_statuscode_201-ps=true&ts=false_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/statuscode/{value}, + Name: GET /api2/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/statuscode/{value}, + Resource: GET /api2/statuscode/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api2/statuscode/{value}, + Name: GET /api2/statuscode/{value}, LogicScope: aspnet.request, - Resource: GET api2/statuscode/{value}, + Resource: GET /api2/statuscode/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_statuscode_201-ps=true&ts=true_statusCode=201.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_statuscode_201-ps=true&ts=true_statusCode=201.verified.txt index f93704002..6816df4e8 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_statuscode_201-ps=true&ts=true_statusCode=201.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_statuscode_201-ps=true&ts=true_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/statuscode/{value}, + Name: GET /api2/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/statuscode/{value}, + Resource: GET /api2/statuscode/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api2/statuscode/{value}, + Name: GET /api2/statuscode/{value}, LogicScope: aspnet.request, - Resource: GET api2/statuscode/{value}, + Resource: GET /api2/statuscode/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_statuscode_201_statusCode=201.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_statuscode_201_statusCode=201.verified.txt index b12ad5ad9..c0282f1c2 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_statuscode_201_statusCode=201.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_statuscode_201_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/statuscode/{value}, + Name: GET /api2/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/statuscode/{value}, + Resource: GET /api2/statuscode/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api2/statuscode/{value}, + Name: GET /api2/statuscode/{value}, LogicScope: aspnet.request, - Resource: GET api2/statuscode/{value}, + Resource: GET /api2/statuscode/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_statuscode_503_statusCode=503.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_statuscode_503_statusCode=503.verified.txt index b331c1f5a..297f3fb2f 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_statuscode_503_statusCode=503.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_statuscode_503_statusCode=503.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/statuscode/{value}, + Name: GET /api2/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/statuscode/{value}, + Resource: GET /api2/statuscode/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -28,9 +28,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api2/statuscode/{value}, + Name: GET /api2/statuscode/{value}, LogicScope: aspnet.request, - Resource: GET api2/statuscode/{value}, + Resource: GET /api2/statuscode/{value}, Service: sample, Type: web, Error: 1, diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_transientfailure_false_statusCode=500.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_transientfailure_false_statusCode=500.verified.txt index 2384e13fe..7d8864109 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_transientfailure_false_statusCode=500.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_transientfailure_false_statusCode=500.verified.txt @@ -15,9 +15,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api2/transientfailure/{value}, + Name: GET /api2/transientfailure/{value}, LogicScope: aspnet.request, - Resource: GET api2/transientfailure/{value}, + Resource: GET /api2/transientfailure/{value}, Service: sample, Type: web, Error: 1, @@ -49,9 +49,9 @@ at Samples.AspNetMvc5.Controllers.ConventionsController.TransientFailure(String { TraceId: Id_1, SpanId: Id_4, - Name: GET api2/transientfailure/{value}, + Name: GET /api2/transientfailure/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/transientfailure/{value}, + Resource: GET /api2/transientfailure/{value}, Service: sample, Type: web, ParentId: Id_3, diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_transientfailure_true_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_transientfailure_true_statusCode=200.verified.txt index 8b92f71a6..1335c6607 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_transientfailure_true_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api2_transientfailure_true_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/transientfailure/{value}, + Name: GET /api2/transientfailure/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/transientfailure/{value}, + Resource: GET /api2/transientfailure/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api2/transientfailure/{value}, + Name: GET /api2/transientfailure/{value}, LogicScope: aspnet.request, - Resource: GET api2/transientfailure/{value}, + Resource: GET /api2/transientfailure/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_absolute-route_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_absolute-route_statusCode=200.verified.txt index c4c16382d..cb43e6aff 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_absolute-route_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_absolute-route_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/absolute-route, + Name: GET /api/absolute-route, LogicScope: aspnet-webapi.request, - Resource: GET api/absolute-route, + Resource: GET /api/absolute-route, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api/absolute-route, + Name: GET /api/absolute-route, LogicScope: aspnet.request, - Resource: GET api/absolute-route, + Resource: GET /api/absolute-route, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_delay-async_0_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_delay-async_0_statusCode=200.verified.txt index a720b6712..d01c468b8 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_delay-async_0_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_delay-async_0_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/delay-async/{seconds}, + Name: GET /api/delay-async/{seconds}, LogicScope: aspnet-webapi.request, - Resource: GET api/delay-async/{seconds}, + Resource: GET /api/delay-async/{seconds}, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api/delay-async/{seconds}, + Name: GET /api/delay-async/{seconds}, LogicScope: aspnet.request, - Resource: GET api/delay-async/{seconds}, + Resource: GET /api/delay-async/{seconds}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_delay-optional_1_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_delay-optional_1_statusCode=200.verified.txt index acac2d245..3560930b6 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_delay-optional_1_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_delay-optional_1_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/delay-optional/{seconds}, + Name: GET /api/delay-optional/{seconds}, LogicScope: aspnet-webapi.request, - Resource: GET api/delay-optional/{seconds}, + Resource: GET /api/delay-optional/{seconds}, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api/delay-optional/{seconds}, + Name: GET /api/delay-optional/{seconds}, LogicScope: aspnet.request, - Resource: GET api/delay-optional/{seconds}, + Resource: GET /api/delay-optional/{seconds}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_delay-optional_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_delay-optional_statusCode=200.verified.txt index 0dde13b30..f6b603ba7 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_delay-optional_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_delay-optional_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/delay-optional/{seconds}, + Name: GET /api/delay-optional/{seconds}, LogicScope: aspnet-webapi.request, - Resource: GET api/delay-optional/{seconds}, + Resource: GET /api/delay-optional/{seconds}, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api/delay-optional/{seconds}, + Name: GET /api/delay-optional/{seconds}, LogicScope: aspnet.request, - Resource: GET api/delay-optional/{seconds}, + Resource: GET /api/delay-optional/{seconds}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_delay_0_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_delay_0_statusCode=200.verified.txt index 4282597e1..fb5e18235 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_delay_0_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_delay_0_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/delay/{seconds}, + Name: GET /api/delay/{seconds}, LogicScope: aspnet-webapi.request, - Resource: GET api/delay/{seconds}, + Resource: GET /api/delay/{seconds}, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api/delay/{seconds}, + Name: GET /api/delay/{seconds}, LogicScope: aspnet.request, - Resource: GET api/delay/{seconds}, + Resource: GET /api/delay/{seconds}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_environment_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_environment_statusCode=200.verified.txt index 19515f598..94b85dcc8 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_environment_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_environment_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/environment, + Name: GET /api/environment, LogicScope: aspnet-webapi.request, - Resource: GET api/environment, + Resource: GET /api/environment, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api/environment, + Name: GET /api/environment, LogicScope: aspnet.request, - Resource: GET api/environment, + Resource: GET /api/environment, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_statuscode_201_statusCode=201.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_statuscode_201_statusCode=201.verified.txt index ade17caa4..140c16cb6 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_statuscode_201_statusCode=201.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_statuscode_201_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/statuscode/{value}, + Name: GET /api/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api/statuscode/{value}, + Resource: GET /api/statuscode/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api/statuscode/{value}, + Name: GET /api/statuscode/{value}, LogicScope: aspnet.request, - Resource: GET api/statuscode/{value}, + Resource: GET /api/statuscode/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_statuscode_503_statusCode=503.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_statuscode_503_statusCode=503.verified.txt index 7f9d58585..da8091077 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_statuscode_503_statusCode=503.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_statuscode_503_statusCode=503.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/statuscode/{value}, + Name: GET /api/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api/statuscode/{value}, + Resource: GET /api/statuscode/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api/statuscode/{value}, + Name: GET /api/statuscode/{value}, LogicScope: aspnet.request, - Resource: GET api/statuscode/{value}, + Resource: GET /api/statuscode/{value}, Service: sample, Type: web, Error: 1, diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_transient-failure_false_statusCode=500.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_transient-failure_false_statusCode=500.verified.txt index ff56d4921..5884e14eb 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_transient-failure_false_statusCode=500.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_transient-failure_false_statusCode=500.verified.txt @@ -15,9 +15,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api/transient-failure/{value}, + Name: GET /api/transient-failure/{value}, LogicScope: aspnet.request, - Resource: GET api/transient-failure/{value}, + Resource: GET /api/transient-failure/{value}, Service: sample, Type: web, Error: 1, @@ -49,9 +49,9 @@ at Samples.AspNetMvc5.Controllers.ApiController.TransientFailure(String value), { TraceId: Id_1, SpanId: Id_4, - Name: GET api/transient-failure/{value}, + Name: GET /api/transient-failure/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api/transient-failure/{value}, + Resource: GET /api/transient-failure/{value}, Service: sample, Type: web, ParentId: Id_3, diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_transient-failure_true_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_transient-failure_true_statusCode=200.verified.txt index b7177d833..d0dfe307c 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_transient-failure_true_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Classic.WithFF.__path=_api_transient-failure_true_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/transient-failure/{value}, + Name: GET /api/transient-failure/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api/transient-failure/{value}, + Resource: GET /api/transient-failure/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api/transient-failure/{value}, + Name: GET /api/transient-failure/{value}, LogicScope: aspnet.request, - Resource: GET api/transient-failure/{value}, + Resource: GET /api/transient-failure/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_delayAsync_0_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_delayAsync_0_statusCode=200.verified.txt index 70b6d31bb..01bb9cb12 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_delayAsync_0_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_delayAsync_0_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/delayasync/{value}, + Name: GET api2/delayasync/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/delayasync/{value}, + Resource: GET api2/delayasync/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api2/delayasync/{value}, + Name: GET api2/delayasync/{value}, LogicScope: aspnet.request, - Resource: GET /api2/delayasync/{value}, + Resource: GET api2/delayasync/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_delay_0_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_delay_0_statusCode=200.verified.txt index a2b7fb554..1f88266f2 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_delay_0_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_delay_0_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/delay/{value}, + Name: GET api2/delay/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/delay/{value}, + Resource: GET api2/delay/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api2/delay/{value}, + Name: GET api2/delay/{value}, LogicScope: aspnet.request, - Resource: GET /api2/delay/{value}, + Resource: GET api2/delay/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_optional_1_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_optional_1_statusCode=200.verified.txt index 8a53db2ff..163297512 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_optional_1_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_optional_1_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/optional/{value}, + Name: GET api2/optional/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/optional/{value}, + Resource: GET api2/optional/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api2/optional/{value}, + Name: GET api2/optional/{value}, LogicScope: aspnet.request, - Resource: GET /api2/optional/{value}, + Resource: GET api2/optional/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_optional_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_optional_statusCode=200.verified.txt index 34d2e66ba..6c5b8f2ee 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_optional_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_optional_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/optional/{value}, + Name: GET api2/optional/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/optional/{value}, + Resource: GET api2/optional/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api2/optional/{value}, + Name: GET api2/optional/{value}, LogicScope: aspnet.request, - Resource: GET /api2/optional/{value}, + Resource: GET api2/optional/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_statuscode_201-ps=true&ts=false_statusCode=201.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_statuscode_201-ps=true&ts=false_statusCode=201.verified.txt index 4cfca6f64..300bd2b2b 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_statuscode_201-ps=true&ts=false_statusCode=201.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_statuscode_201-ps=true&ts=false_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/statuscode/{value}, + Name: GET api2/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/statuscode/{value}, + Resource: GET api2/statuscode/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api2/statuscode/{value}, + Name: GET api2/statuscode/{value}, LogicScope: aspnet.request, - Resource: GET /api2/statuscode/{value}, + Resource: GET api2/statuscode/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_statuscode_201-ps=true&ts=true_statusCode=201.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_statuscode_201-ps=true&ts=true_statusCode=201.verified.txt index 6816df4e8..f93704002 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_statuscode_201-ps=true&ts=true_statusCode=201.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_statuscode_201-ps=true&ts=true_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/statuscode/{value}, + Name: GET api2/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/statuscode/{value}, + Resource: GET api2/statuscode/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api2/statuscode/{value}, + Name: GET api2/statuscode/{value}, LogicScope: aspnet.request, - Resource: GET /api2/statuscode/{value}, + Resource: GET api2/statuscode/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_statuscode_201_statusCode=201.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_statuscode_201_statusCode=201.verified.txt index c0282f1c2..b12ad5ad9 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_statuscode_201_statusCode=201.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_statuscode_201_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/statuscode/{value}, + Name: GET api2/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/statuscode/{value}, + Resource: GET api2/statuscode/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api2/statuscode/{value}, + Name: GET api2/statuscode/{value}, LogicScope: aspnet.request, - Resource: GET /api2/statuscode/{value}, + Resource: GET api2/statuscode/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_statuscode_503_statusCode=503.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_statuscode_503_statusCode=503.verified.txt index 297f3fb2f..b331c1f5a 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_statuscode_503_statusCode=503.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_statuscode_503_statusCode=503.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/statuscode/{value}, + Name: GET api2/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/statuscode/{value}, + Resource: GET api2/statuscode/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -28,9 +28,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api2/statuscode/{value}, + Name: GET api2/statuscode/{value}, LogicScope: aspnet.request, - Resource: GET /api2/statuscode/{value}, + Resource: GET api2/statuscode/{value}, Service: sample, Type: web, Error: 1, diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_transientfailure_false_statusCode=500.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_transientfailure_false_statusCode=500.verified.txt index 7d8864109..2384e13fe 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_transientfailure_false_statusCode=500.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_transientfailure_false_statusCode=500.verified.txt @@ -15,9 +15,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api2/transientfailure/{value}, + Name: GET api2/transientfailure/{value}, LogicScope: aspnet.request, - Resource: GET /api2/transientfailure/{value}, + Resource: GET api2/transientfailure/{value}, Service: sample, Type: web, Error: 1, @@ -49,9 +49,9 @@ at Samples.AspNetMvc5.Controllers.ConventionsController.TransientFailure(String { TraceId: Id_1, SpanId: Id_4, - Name: GET /api2/transientfailure/{value}, + Name: GET api2/transientfailure/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/transientfailure/{value}, + Resource: GET api2/transientfailure/{value}, Service: sample, Type: web, ParentId: Id_3, diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_transientfailure_true_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_transientfailure_true_statusCode=200.verified.txt index 1335c6607..8b92f71a6 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_transientfailure_true_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api2_transientfailure_true_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/transientfailure/{value}, + Name: GET api2/transientfailure/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/transientfailure/{value}, + Resource: GET api2/transientfailure/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api2/transientfailure/{value}, + Name: GET api2/transientfailure/{value}, LogicScope: aspnet.request, - Resource: GET /api2/transientfailure/{value}, + Resource: GET api2/transientfailure/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_absolute-route_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_absolute-route_statusCode=200.verified.txt index cb43e6aff..c4c16382d 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_absolute-route_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_absolute-route_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/absolute-route, + Name: GET api/absolute-route, LogicScope: aspnet-webapi.request, - Resource: GET /api/absolute-route, + Resource: GET api/absolute-route, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api/absolute-route, + Name: GET api/absolute-route, LogicScope: aspnet.request, - Resource: GET /api/absolute-route, + Resource: GET api/absolute-route, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_delay-async_0_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_delay-async_0_statusCode=200.verified.txt index d01c468b8..a720b6712 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_delay-async_0_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_delay-async_0_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/delay-async/{seconds}, + Name: GET api/delay-async/{seconds}, LogicScope: aspnet-webapi.request, - Resource: GET /api/delay-async/{seconds}, + Resource: GET api/delay-async/{seconds}, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api/delay-async/{seconds}, + Name: GET api/delay-async/{seconds}, LogicScope: aspnet.request, - Resource: GET /api/delay-async/{seconds}, + Resource: GET api/delay-async/{seconds}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_delay-optional_1_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_delay-optional_1_statusCode=200.verified.txt index 3560930b6..acac2d245 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_delay-optional_1_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_delay-optional_1_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/delay-optional/{seconds}, + Name: GET api/delay-optional/{seconds}, LogicScope: aspnet-webapi.request, - Resource: GET /api/delay-optional/{seconds}, + Resource: GET api/delay-optional/{seconds}, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api/delay-optional/{seconds}, + Name: GET api/delay-optional/{seconds}, LogicScope: aspnet.request, - Resource: GET /api/delay-optional/{seconds}, + Resource: GET api/delay-optional/{seconds}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_delay-optional_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_delay-optional_statusCode=200.verified.txt index f6b603ba7..0dde13b30 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_delay-optional_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_delay-optional_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/delay-optional/{seconds}, + Name: GET api/delay-optional/{seconds}, LogicScope: aspnet-webapi.request, - Resource: GET /api/delay-optional/{seconds}, + Resource: GET api/delay-optional/{seconds}, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api/delay-optional/{seconds}, + Name: GET api/delay-optional/{seconds}, LogicScope: aspnet.request, - Resource: GET /api/delay-optional/{seconds}, + Resource: GET api/delay-optional/{seconds}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_delay_0_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_delay_0_statusCode=200.verified.txt index fb5e18235..4282597e1 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_delay_0_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_delay_0_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/delay/{seconds}, + Name: GET api/delay/{seconds}, LogicScope: aspnet-webapi.request, - Resource: GET /api/delay/{seconds}, + Resource: GET api/delay/{seconds}, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api/delay/{seconds}, + Name: GET api/delay/{seconds}, LogicScope: aspnet.request, - Resource: GET /api/delay/{seconds}, + Resource: GET api/delay/{seconds}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_environment_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_environment_statusCode=200.verified.txt index 94b85dcc8..19515f598 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_environment_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_environment_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/environment, + Name: GET api/environment, LogicScope: aspnet-webapi.request, - Resource: GET /api/environment, + Resource: GET api/environment, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api/environment, + Name: GET api/environment, LogicScope: aspnet.request, - Resource: GET /api/environment, + Resource: GET api/environment, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_statuscode_201_statusCode=201.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_statuscode_201_statusCode=201.verified.txt index 140c16cb6..ade17caa4 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_statuscode_201_statusCode=201.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_statuscode_201_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/statuscode/{value}, + Name: GET api/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api/statuscode/{value}, + Resource: GET api/statuscode/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api/statuscode/{value}, + Name: GET api/statuscode/{value}, LogicScope: aspnet.request, - Resource: GET /api/statuscode/{value}, + Resource: GET api/statuscode/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_statuscode_503_statusCode=503.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_statuscode_503_statusCode=503.verified.txt index da8091077..7f9d58585 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_statuscode_503_statusCode=503.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_statuscode_503_statusCode=503.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/statuscode/{value}, + Name: GET api/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api/statuscode/{value}, + Resource: GET api/statuscode/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api/statuscode/{value}, + Name: GET api/statuscode/{value}, LogicScope: aspnet.request, - Resource: GET /api/statuscode/{value}, + Resource: GET api/statuscode/{value}, Service: sample, Type: web, Error: 1, diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_transient-failure_false_statusCode=500.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_transient-failure_false_statusCode=500.verified.txt index 5884e14eb..ff56d4921 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_transient-failure_false_statusCode=500.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_transient-failure_false_statusCode=500.verified.txt @@ -15,9 +15,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api/transient-failure/{value}, + Name: GET api/transient-failure/{value}, LogicScope: aspnet.request, - Resource: GET /api/transient-failure/{value}, + Resource: GET api/transient-failure/{value}, Service: sample, Type: web, Error: 1, @@ -49,9 +49,9 @@ at Samples.AspNetMvc5.Controllers.ApiController.TransientFailure(String value), { TraceId: Id_1, SpanId: Id_4, - Name: GET /api/transient-failure/{value}, + Name: GET api/transient-failure/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api/transient-failure/{value}, + Resource: GET api/transient-failure/{value}, Service: sample, Type: web, ParentId: Id_3, diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_transient-failure_true_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_transient-failure_true_statusCode=200.verified.txt index d0dfe307c..b7177d833 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_transient-failure_true_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.NoFF.__path=_api_transient-failure_true_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/transient-failure/{value}, + Name: GET api/transient-failure/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api/transient-failure/{value}, + Resource: GET api/transient-failure/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET /api/transient-failure/{value}, + Name: GET api/transient-failure/{value}, LogicScope: aspnet.request, - Resource: GET /api/transient-failure/{value}, + Resource: GET api/transient-failure/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_delayAsync_0_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_delayAsync_0_statusCode=200.verified.txt index 01bb9cb12..70b6d31bb 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_delayAsync_0_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_delayAsync_0_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/delayasync/{value}, + Name: GET /api2/delayasync/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/delayasync/{value}, + Resource: GET /api2/delayasync/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api2/delayasync/{value}, + Name: GET /api2/delayasync/{value}, LogicScope: aspnet.request, - Resource: GET api2/delayasync/{value}, + Resource: GET /api2/delayasync/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_delay_0_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_delay_0_statusCode=200.verified.txt index 1f88266f2..a2b7fb554 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_delay_0_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_delay_0_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/delay/{value}, + Name: GET /api2/delay/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/delay/{value}, + Resource: GET /api2/delay/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api2/delay/{value}, + Name: GET /api2/delay/{value}, LogicScope: aspnet.request, - Resource: GET api2/delay/{value}, + Resource: GET /api2/delay/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_optional_1_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_optional_1_statusCode=200.verified.txt index 163297512..8a53db2ff 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_optional_1_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_optional_1_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/optional/{value}, + Name: GET /api2/optional/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/optional/{value}, + Resource: GET /api2/optional/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api2/optional/{value}, + Name: GET /api2/optional/{value}, LogicScope: aspnet.request, - Resource: GET api2/optional/{value}, + Resource: GET /api2/optional/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_optional_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_optional_statusCode=200.verified.txt index 6c5b8f2ee..34d2e66ba 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_optional_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_optional_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/optional/{value}, + Name: GET /api2/optional/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/optional/{value}, + Resource: GET /api2/optional/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api2/optional/{value}, + Name: GET /api2/optional/{value}, LogicScope: aspnet.request, - Resource: GET api2/optional/{value}, + Resource: GET /api2/optional/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_statuscode_201-ps=true&ts=false_statusCode=201.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_statuscode_201-ps=true&ts=false_statusCode=201.verified.txt index 300bd2b2b..4cfca6f64 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_statuscode_201-ps=true&ts=false_statusCode=201.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_statuscode_201-ps=true&ts=false_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/statuscode/{value}, + Name: GET /api2/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/statuscode/{value}, + Resource: GET /api2/statuscode/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api2/statuscode/{value}, + Name: GET /api2/statuscode/{value}, LogicScope: aspnet.request, - Resource: GET api2/statuscode/{value}, + Resource: GET /api2/statuscode/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_statuscode_201-ps=true&ts=true_statusCode=201.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_statuscode_201-ps=true&ts=true_statusCode=201.verified.txt index f93704002..6816df4e8 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_statuscode_201-ps=true&ts=true_statusCode=201.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_statuscode_201-ps=true&ts=true_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/statuscode/{value}, + Name: GET /api2/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/statuscode/{value}, + Resource: GET /api2/statuscode/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api2/statuscode/{value}, + Name: GET /api2/statuscode/{value}, LogicScope: aspnet.request, - Resource: GET api2/statuscode/{value}, + Resource: GET /api2/statuscode/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_statuscode_201_statusCode=201.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_statuscode_201_statusCode=201.verified.txt index b12ad5ad9..c0282f1c2 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_statuscode_201_statusCode=201.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_statuscode_201_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/statuscode/{value}, + Name: GET /api2/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/statuscode/{value}, + Resource: GET /api2/statuscode/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api2/statuscode/{value}, + Name: GET /api2/statuscode/{value}, LogicScope: aspnet.request, - Resource: GET api2/statuscode/{value}, + Resource: GET /api2/statuscode/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_statuscode_503_statusCode=503.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_statuscode_503_statusCode=503.verified.txt index b331c1f5a..297f3fb2f 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_statuscode_503_statusCode=503.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_statuscode_503_statusCode=503.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/statuscode/{value}, + Name: GET /api2/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/statuscode/{value}, + Resource: GET /api2/statuscode/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -28,9 +28,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api2/statuscode/{value}, + Name: GET /api2/statuscode/{value}, LogicScope: aspnet.request, - Resource: GET api2/statuscode/{value}, + Resource: GET /api2/statuscode/{value}, Service: sample, Type: web, Error: 1, diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_transientfailure_false_statusCode=500.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_transientfailure_false_statusCode=500.verified.txt index 2384e13fe..7d8864109 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_transientfailure_false_statusCode=500.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_transientfailure_false_statusCode=500.verified.txt @@ -15,9 +15,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api2/transientfailure/{value}, + Name: GET /api2/transientfailure/{value}, LogicScope: aspnet.request, - Resource: GET api2/transientfailure/{value}, + Resource: GET /api2/transientfailure/{value}, Service: sample, Type: web, Error: 1, @@ -49,9 +49,9 @@ at Samples.AspNetMvc5.Controllers.ConventionsController.TransientFailure(String { TraceId: Id_1, SpanId: Id_4, - Name: GET api2/transientfailure/{value}, + Name: GET /api2/transientfailure/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/transientfailure/{value}, + Resource: GET /api2/transientfailure/{value}, Service: sample, Type: web, ParentId: Id_3, diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_transientfailure_true_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_transientfailure_true_statusCode=200.verified.txt index 8b92f71a6..1335c6607 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_transientfailure_true_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api2_transientfailure_true_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/transientfailure/{value}, + Name: GET /api2/transientfailure/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/transientfailure/{value}, + Resource: GET /api2/transientfailure/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api2/transientfailure/{value}, + Name: GET /api2/transientfailure/{value}, LogicScope: aspnet.request, - Resource: GET api2/transientfailure/{value}, + Resource: GET /api2/transientfailure/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_absolute-route_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_absolute-route_statusCode=200.verified.txt index c4c16382d..cb43e6aff 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_absolute-route_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_absolute-route_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/absolute-route, + Name: GET /api/absolute-route, LogicScope: aspnet-webapi.request, - Resource: GET api/absolute-route, + Resource: GET /api/absolute-route, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api/absolute-route, + Name: GET /api/absolute-route, LogicScope: aspnet.request, - Resource: GET api/absolute-route, + Resource: GET /api/absolute-route, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_delay-async_0_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_delay-async_0_statusCode=200.verified.txt index a720b6712..d01c468b8 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_delay-async_0_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_delay-async_0_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/delay-async/{seconds}, + Name: GET /api/delay-async/{seconds}, LogicScope: aspnet-webapi.request, - Resource: GET api/delay-async/{seconds}, + Resource: GET /api/delay-async/{seconds}, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api/delay-async/{seconds}, + Name: GET /api/delay-async/{seconds}, LogicScope: aspnet.request, - Resource: GET api/delay-async/{seconds}, + Resource: GET /api/delay-async/{seconds}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_delay-optional_1_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_delay-optional_1_statusCode=200.verified.txt index acac2d245..3560930b6 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_delay-optional_1_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_delay-optional_1_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/delay-optional/{seconds}, + Name: GET /api/delay-optional/{seconds}, LogicScope: aspnet-webapi.request, - Resource: GET api/delay-optional/{seconds}, + Resource: GET /api/delay-optional/{seconds}, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api/delay-optional/{seconds}, + Name: GET /api/delay-optional/{seconds}, LogicScope: aspnet.request, - Resource: GET api/delay-optional/{seconds}, + Resource: GET /api/delay-optional/{seconds}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_delay-optional_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_delay-optional_statusCode=200.verified.txt index 0dde13b30..f6b603ba7 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_delay-optional_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_delay-optional_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/delay-optional/{seconds}, + Name: GET /api/delay-optional/{seconds}, LogicScope: aspnet-webapi.request, - Resource: GET api/delay-optional/{seconds}, + Resource: GET /api/delay-optional/{seconds}, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api/delay-optional/{seconds}, + Name: GET /api/delay-optional/{seconds}, LogicScope: aspnet.request, - Resource: GET api/delay-optional/{seconds}, + Resource: GET /api/delay-optional/{seconds}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_delay_0_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_delay_0_statusCode=200.verified.txt index 4282597e1..fb5e18235 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_delay_0_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_delay_0_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/delay/{seconds}, + Name: GET /api/delay/{seconds}, LogicScope: aspnet-webapi.request, - Resource: GET api/delay/{seconds}, + Resource: GET /api/delay/{seconds}, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api/delay/{seconds}, + Name: GET /api/delay/{seconds}, LogicScope: aspnet.request, - Resource: GET api/delay/{seconds}, + Resource: GET /api/delay/{seconds}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_environment_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_environment_statusCode=200.verified.txt index 19515f598..94b85dcc8 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_environment_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_environment_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/environment, + Name: GET /api/environment, LogicScope: aspnet-webapi.request, - Resource: GET api/environment, + Resource: GET /api/environment, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api/environment, + Name: GET /api/environment, LogicScope: aspnet.request, - Resource: GET api/environment, + Resource: GET /api/environment, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_statuscode_201_statusCode=201.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_statuscode_201_statusCode=201.verified.txt index ade17caa4..140c16cb6 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_statuscode_201_statusCode=201.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_statuscode_201_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/statuscode/{value}, + Name: GET /api/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api/statuscode/{value}, + Resource: GET /api/statuscode/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api/statuscode/{value}, + Name: GET /api/statuscode/{value}, LogicScope: aspnet.request, - Resource: GET api/statuscode/{value}, + Resource: GET /api/statuscode/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_statuscode_503_statusCode=503.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_statuscode_503_statusCode=503.verified.txt index 7f9d58585..da8091077 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_statuscode_503_statusCode=503.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_statuscode_503_statusCode=503.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/statuscode/{value}, + Name: GET /api/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api/statuscode/{value}, + Resource: GET /api/statuscode/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -26,9 +26,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api/statuscode/{value}, + Name: GET /api/statuscode/{value}, LogicScope: aspnet.request, - Resource: GET api/statuscode/{value}, + Resource: GET /api/statuscode/{value}, Service: sample, Type: web, Error: 1, diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_transient-failure_false_statusCode=500.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_transient-failure_false_statusCode=500.verified.txt index ff56d4921..5884e14eb 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_transient-failure_false_statusCode=500.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_transient-failure_false_statusCode=500.verified.txt @@ -15,9 +15,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api/transient-failure/{value}, + Name: GET /api/transient-failure/{value}, LogicScope: aspnet.request, - Resource: GET api/transient-failure/{value}, + Resource: GET /api/transient-failure/{value}, Service: sample, Type: web, Error: 1, @@ -49,9 +49,9 @@ at Samples.AspNetMvc5.Controllers.ApiController.TransientFailure(String value), { TraceId: Id_1, SpanId: Id_4, - Name: GET api/transient-failure/{value}, + Name: GET /api/transient-failure/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api/transient-failure/{value}, + Resource: GET /api/transient-failure/{value}, Service: sample, Type: web, ParentId: Id_3, diff --git a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_transient-failure_true_statusCode=200.verified.txt b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_transient-failure_true_statusCode=200.verified.txt index b7177d833..d0dfe307c 100644 --- a/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_transient-failure_true_statusCode=200.verified.txt +++ b/tracer/test/snapshots/AspNetWebApi2Tests.Integrated.WithFF.__path=_api_transient-failure_true_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/transient-failure/{value}, + Name: GET /api/transient-failure/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api/transient-failure/{value}, + Resource: GET /api/transient-failure/{value}, Service: sample, Type: web, ParentId: Id_3, @@ -24,9 +24,9 @@ { TraceId: Id_1, SpanId: Id_3, - Name: GET api/transient-failure/{value}, + Name: GET /api/transient-failure/{value}, LogicScope: aspnet.request, - Resource: GET api/transient-failure/{value}, + Resource: GET /api/transient-failure/{value}, Service: sample, Type: web, Tags: { diff --git a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_delayAsync_0_statusCode=200.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_delayAsync_0_statusCode=200.verified.txt index 79aadd92e..2c20089e9 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_delayAsync_0_statusCode=200.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_delayAsync_0_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/delayasync/{value}, + Name: GET api2/delayasync/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/delayasync/{value}, + Resource: GET api2/delayasync/{value}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -16,6 +16,7 @@ http.request.headers.host: localhost:00000, http.status_code: 200, http.url: http://localhost:00000/api2/delayAsync/0, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_delay_0_statusCode=200.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_delay_0_statusCode=200.verified.txt index 546347e58..120a40ca0 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_delay_0_statusCode=200.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_delay_0_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/delay/{value}, + Name: GET api2/delay/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/delay/{value}, + Resource: GET api2/delay/{value}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -16,6 +16,7 @@ http.request.headers.host: localhost:00000, http.status_code: 200, http.url: http://localhost:00000/api2/delay/0, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_optional_1_statusCode=200.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_optional_1_statusCode=200.verified.txt index 588950065..c60d47420 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_optional_1_statusCode=200.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_optional_1_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/optional/{value}, + Name: GET api2/optional/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/optional/{value}, + Resource: GET api2/optional/{value}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -16,6 +16,7 @@ http.request.headers.host: localhost:00000, http.status_code: 200, http.url: http://localhost:00000/api2/optional/1, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_optional_statusCode=200.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_optional_statusCode=200.verified.txt index f32e2a746..fc08849de 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_optional_statusCode=200.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_optional_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/optional/{value}, + Name: GET api2/optional/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/optional/{value}, + Resource: GET api2/optional/{value}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -16,6 +16,7 @@ http.request.headers.host: localhost:00000, http.status_code: 200, http.url: http://localhost:00000/api2/optional, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_statuscode_201-ps=true&ts=false_statusCode=201.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_statuscode_201-ps=true&ts=false_statusCode=201.verified.txt index edb91986c..b8b183f84 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_statuscode_201-ps=true&ts=false_statusCode=201.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_statuscode_201-ps=true&ts=false_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/statuscode/{value}, + Name: GET api2/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/statuscode/{value}, + Resource: GET api2/statuscode/{value}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -16,6 +16,7 @@ http.request.headers.host: localhost:00000, http.status_code: 201, http.url: http://localhost:00000/api2/statuscode/201?ps=true&ts=false, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_statuscode_201-ps=true&ts=true_statusCode=201.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_statuscode_201-ps=true&ts=true_statusCode=201.verified.txt index 12d0be1bf..32cd3a0ed 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_statuscode_201-ps=true&ts=true_statusCode=201.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_statuscode_201-ps=true&ts=true_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/statuscode/{value}, + Name: GET api2/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/statuscode/{value}, + Resource: GET api2/statuscode/{value}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -16,6 +16,7 @@ http.request.headers.host: localhost:00000, http.status_code: 201, http.url: http://localhost:00000/api2/statuscode/201?ps=true&ts=true, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_statuscode_201_statusCode=201.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_statuscode_201_statusCode=201.verified.txt index ffba678f1..6690e3c94 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_statuscode_201_statusCode=201.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_statuscode_201_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/statuscode/{value}, + Name: GET api2/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/statuscode/{value}, + Resource: GET api2/statuscode/{value}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -16,6 +16,7 @@ http.request.headers.host: localhost:00000, http.status_code: 201, http.url: http://localhost:00000/api2/statuscode/201, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_statuscode_503_statusCode=503.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_statuscode_503_statusCode=503.verified.txt index 7323a5abb..adbc4ed3e 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_statuscode_503_statusCode=503.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_statuscode_503_statusCode=503.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/statuscode/{value}, + Name: GET api2/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/statuscode/{value}, + Resource: GET api2/statuscode/{value}, Service: Samples.Owin.WebApi2, Type: web, Error: 1, @@ -17,6 +17,7 @@ http.request.headers.host: localhost:00000, http.status_code: 503, http.url: http://localhost:00000/api2/statuscode/503, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, sfx.error.message: The HTTP response has status code 503., diff --git a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_transientfailure_false_statusCode=500.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_transientfailure_false_statusCode=500.verified.txt index 61a60b96b..74b342507 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_transientfailure_false_statusCode=500.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_transientfailure_false_statusCode=500.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/transientfailure/{value}, + Name: GET api2/transientfailure/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/transientfailure/{value}, + Resource: GET api2/transientfailure/{value}, Service: Samples.Owin.WebApi2, Type: web, Error: 1, @@ -16,6 +16,7 @@ http.method: GET, http.request.headers.host: localhost:00000, http.url: http://localhost:00000/api2/transientfailure/false, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, sfx.error.kind: System.ArgumentException, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_transientfailure_true_statusCode=200.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_transientfailure_true_statusCode=200.verified.txt index 6d04a26aa..cbc413886 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_transientfailure_true_statusCode=200.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api2_transientfailure_true_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api2/transientfailure/{value}, + Name: GET api2/transientfailure/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api2/transientfailure/{value}, + Resource: GET api2/transientfailure/{value}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -16,6 +16,7 @@ http.request.headers.host: localhost:00000, http.status_code: 200, http.url: http://localhost:00000/api2/transientfailure/true, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_absolute-route_statusCode=200.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_absolute-route_statusCode=200.verified.txt index e258c68f0..e081f5733 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_absolute-route_statusCode=200.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_absolute-route_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/absolute-route, + Name: GET api/absolute-route, LogicScope: aspnet-webapi.request, - Resource: GET /api/absolute-route, + Resource: GET api/absolute-route, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -14,6 +14,7 @@ http.request.headers.host: localhost:00000, http.status_code: 200, http.url: http://localhost:00000/api/absolute-route, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_delay-async_0_statusCode=200.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_delay-async_0_statusCode=200.verified.txt index 09e6088d0..a9efb84a6 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_delay-async_0_statusCode=200.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_delay-async_0_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/delay-async/{seconds}, + Name: GET api/delay-async/{seconds}, LogicScope: aspnet-webapi.request, - Resource: GET /api/delay-async/{seconds}, + Resource: GET api/delay-async/{seconds}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -14,6 +14,7 @@ http.request.headers.host: localhost:00000, http.status_code: 200, http.url: http://localhost:00000/api/delay-async/0, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_delay-optional_1_statusCode=200.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_delay-optional_1_statusCode=200.verified.txt index ed75d645a..d7d9b2ff2 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_delay-optional_1_statusCode=200.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_delay-optional_1_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/delay-optional/{seconds}, + Name: GET api/delay-optional/{seconds}, LogicScope: aspnet-webapi.request, - Resource: GET /api/delay-optional/{seconds}, + Resource: GET api/delay-optional/{seconds}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -14,6 +14,7 @@ http.request.headers.host: localhost:00000, http.status_code: 200, http.url: http://localhost:00000/api/delay-optional/1, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_delay-optional_statusCode=200.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_delay-optional_statusCode=200.verified.txt index 830acbf94..6af5ccaa8 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_delay-optional_statusCode=200.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_delay-optional_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/delay-optional/{seconds}, + Name: GET api/delay-optional/{seconds}, LogicScope: aspnet-webapi.request, - Resource: GET /api/delay-optional/{seconds}, + Resource: GET api/delay-optional/{seconds}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -14,6 +14,7 @@ http.request.headers.host: localhost:00000, http.status_code: 200, http.url: http://localhost:00000/api/delay-optional, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_delay_0_statusCode=200.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_delay_0_statusCode=200.verified.txt index 745237798..8cc178d1a 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_delay_0_statusCode=200.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_delay_0_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/delay/{seconds}, + Name: GET api/delay/{seconds}, LogicScope: aspnet-webapi.request, - Resource: GET /api/delay/{seconds}, + Resource: GET api/delay/{seconds}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -14,6 +14,7 @@ http.request.headers.host: localhost:00000, http.status_code: 200, http.url: http://localhost:00000/api/delay/0, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_environment_statusCode=200.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_environment_statusCode=200.verified.txt index d8f320973..492ecae5d 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_environment_statusCode=200.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_environment_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/environment, + Name: GET api/environment, LogicScope: aspnet-webapi.request, - Resource: GET /api/environment, + Resource: GET api/environment, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -14,6 +14,7 @@ http.request.headers.host: localhost:00000, http.status_code: 200, http.url: http://localhost:00000/api/environment, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_statuscode_201_statusCode=201.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_statuscode_201_statusCode=201.verified.txt index 7ddc77ae7..49bdeee94 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_statuscode_201_statusCode=201.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_statuscode_201_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/statuscode/{value}, + Name: GET api/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api/statuscode/{value}, + Resource: GET api/statuscode/{value}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -14,6 +14,7 @@ http.request.headers.host: localhost:00000, http.status_code: 201, http.url: http://localhost:00000/api/statuscode/201, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_statuscode_503_statusCode=503.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_statuscode_503_statusCode=503.verified.txt index 4e939f807..98a9c35d9 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_statuscode_503_statusCode=503.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_statuscode_503_statusCode=503.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/statuscode/{value}, + Name: GET api/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api/statuscode/{value}, + Resource: GET api/statuscode/{value}, Service: Samples.Owin.WebApi2, Type: web, Error: 1, @@ -15,6 +15,7 @@ http.request.headers.host: localhost:00000, http.status_code: 503, http.url: http://localhost:00000/api/statuscode/503, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, sfx.error.message: The HTTP response has status code 503., diff --git a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_transient-failure_false_statusCode=500.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_transient-failure_false_statusCode=500.verified.txt index 8b8a08492..c5d53dab4 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_transient-failure_false_statusCode=500.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_transient-failure_false_statusCode=500.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/transient-failure/{value}, + Name: GET api/transient-failure/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api/transient-failure/{value}, + Resource: GET api/transient-failure/{value}, Service: Samples.Owin.WebApi2, Type: web, Error: 1, @@ -14,6 +14,7 @@ http.method: GET, http.request.headers.host: localhost:00000, http.url: http://localhost:00000/api/transient-failure/false, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, sfx.error.kind: System.ArgumentException, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_transient-failure_true_statusCode=200.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_transient-failure_true_statusCode=200.verified.txt index e22d7e0eb..e683003f2 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_transient-failure_true_statusCode=200.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.NoFF.__path=_api_transient-failure_true_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET /api/transient-failure/{value}, + Name: GET api/transient-failure/{value}, LogicScope: aspnet-webapi.request, - Resource: GET /api/transient-failure/{value}, + Resource: GET api/transient-failure/{value}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -14,6 +14,7 @@ http.request.headers.host: localhost:00000, http.status_code: 200, http.url: http://localhost:00000/api/transient-failure/true, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_delayAsync_0_statusCode=200.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_delayAsync_0_statusCode=200.verified.txt index 3fa321ac6..b45a946b1 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_delayAsync_0_statusCode=200.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_delayAsync_0_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/delayasync/{value}, + Name: GET /api2/delayasync/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/delayasync/{value}, + Resource: GET /api2/delayasync/{value}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -16,6 +16,7 @@ http.request.headers.host: localhost:00000, http.status_code: 200, http.url: http://localhost:00000/api2/delayAsync/0, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_delay_0_statusCode=200.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_delay_0_statusCode=200.verified.txt index c5c13153c..50d596f9a 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_delay_0_statusCode=200.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_delay_0_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/delay/{value}, + Name: GET /api2/delay/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/delay/{value}, + Resource: GET /api2/delay/{value}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -16,6 +16,7 @@ http.request.headers.host: localhost:00000, http.status_code: 200, http.url: http://localhost:00000/api2/delay/0, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_optional_1_statusCode=200.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_optional_1_statusCode=200.verified.txt index a0f7eea82..3a430c233 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_optional_1_statusCode=200.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_optional_1_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/optional/{value}, + Name: GET /api2/optional/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/optional/{value}, + Resource: GET /api2/optional/{value}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -16,6 +16,7 @@ http.request.headers.host: localhost:00000, http.status_code: 200, http.url: http://localhost:00000/api2/optional/1, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_optional_statusCode=200.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_optional_statusCode=200.verified.txt index e0700e168..8584ea6f4 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_optional_statusCode=200.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_optional_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/optional/{value}, + Name: GET /api2/optional/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/optional/{value}, + Resource: GET /api2/optional/{value}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -16,6 +16,7 @@ http.request.headers.host: localhost:00000, http.status_code: 200, http.url: http://localhost:00000/api2/optional, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_statuscode_201-ps=true&ts=false_statusCode=201.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_statuscode_201-ps=true&ts=false_statusCode=201.verified.txt index 1f6d62212..93de2176a 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_statuscode_201-ps=true&ts=false_statusCode=201.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_statuscode_201-ps=true&ts=false_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/statuscode/{value}, + Name: GET /api2/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/statuscode/{value}, + Resource: GET /api2/statuscode/{value}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -16,6 +16,7 @@ http.request.headers.host: localhost:00000, http.status_code: 201, http.url: http://localhost:00000/api2/statuscode/201?ps=true&ts=false, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_statuscode_201-ps=true&ts=true_statusCode=201.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_statuscode_201-ps=true&ts=true_statusCode=201.verified.txt index 1e72783a4..7e935994e 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_statuscode_201-ps=true&ts=true_statusCode=201.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_statuscode_201-ps=true&ts=true_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/statuscode/{value}, + Name: GET /api2/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/statuscode/{value}, + Resource: GET /api2/statuscode/{value}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -16,6 +16,7 @@ http.request.headers.host: localhost:00000, http.status_code: 201, http.url: http://localhost:00000/api2/statuscode/201?ps=true&ts=true, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_statuscode_201_statusCode=201.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_statuscode_201_statusCode=201.verified.txt index 66eddd8c2..ec41f5f82 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_statuscode_201_statusCode=201.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_statuscode_201_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/statuscode/{value}, + Name: GET /api2/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/statuscode/{value}, + Resource: GET /api2/statuscode/{value}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -16,6 +16,7 @@ http.request.headers.host: localhost:00000, http.status_code: 201, http.url: http://localhost:00000/api2/statuscode/201, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_statuscode_503_statusCode=503.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_statuscode_503_statusCode=503.verified.txt index 26cfb0770..6502a282d 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_statuscode_503_statusCode=503.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_statuscode_503_statusCode=503.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/statuscode/{value}, + Name: GET /api2/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/statuscode/{value}, + Resource: GET /api2/statuscode/{value}, Service: Samples.Owin.WebApi2, Type: web, Error: 1, @@ -17,6 +17,7 @@ http.request.headers.host: localhost:00000, http.status_code: 503, http.url: http://localhost:00000/api2/statuscode/503, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, sfx.error.message: The HTTP response has status code 503., diff --git a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_transientfailure_false_statusCode=500.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_transientfailure_false_statusCode=500.verified.txt index a9095a0e0..680cd2d3f 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_transientfailure_false_statusCode=500.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_transientfailure_false_statusCode=500.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/transientfailure/{value}, + Name: GET /api2/transientfailure/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/transientfailure/{value}, + Resource: GET /api2/transientfailure/{value}, Service: Samples.Owin.WebApi2, Type: web, Error: 1, @@ -16,6 +16,7 @@ http.method: GET, http.request.headers.host: localhost:00000, http.url: http://localhost:00000/api2/transientfailure/false, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, sfx.error.kind: System.ArgumentException, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_transientfailure_true_statusCode=200.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_transientfailure_true_statusCode=200.verified.txt index 616afe210..d147040f8 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_transientfailure_true_statusCode=200.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api2_transientfailure_true_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api2/transientfailure/{value}, + Name: GET /api2/transientfailure/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api2/transientfailure/{value}, + Resource: GET /api2/transientfailure/{value}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -16,6 +16,7 @@ http.request.headers.host: localhost:00000, http.status_code: 200, http.url: http://localhost:00000/api2/transientfailure/true, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_absolute-route_statusCode=200.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_absolute-route_statusCode=200.verified.txt index ade93fd97..bb6b67800 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_absolute-route_statusCode=200.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_absolute-route_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/absolute-route, + Name: GET /api/absolute-route, LogicScope: aspnet-webapi.request, - Resource: GET api/absolute-route, + Resource: GET /api/absolute-route, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -14,6 +14,7 @@ http.request.headers.host: localhost:00000, http.status_code: 200, http.url: http://localhost:00000/api/absolute-route, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_delay-async_0_statusCode=200.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_delay-async_0_statusCode=200.verified.txt index 7901f8ce3..b7c4d97f7 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_delay-async_0_statusCode=200.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_delay-async_0_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/delay-async/{seconds}, + Name: GET /api/delay-async/{seconds}, LogicScope: aspnet-webapi.request, - Resource: GET api/delay-async/{seconds}, + Resource: GET /api/delay-async/{seconds}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -14,6 +14,7 @@ http.request.headers.host: localhost:00000, http.status_code: 200, http.url: http://localhost:00000/api/delay-async/0, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_delay-optional_1_statusCode=200.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_delay-optional_1_statusCode=200.verified.txt index ba00c5e9f..25ec546a5 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_delay-optional_1_statusCode=200.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_delay-optional_1_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/delay-optional/{seconds}, + Name: GET /api/delay-optional/{seconds}, LogicScope: aspnet-webapi.request, - Resource: GET api/delay-optional/{seconds}, + Resource: GET /api/delay-optional/{seconds}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -14,6 +14,7 @@ http.request.headers.host: localhost:00000, http.status_code: 200, http.url: http://localhost:00000/api/delay-optional/1, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_delay-optional_statusCode=200.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_delay-optional_statusCode=200.verified.txt index bec9a070b..093450262 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_delay-optional_statusCode=200.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_delay-optional_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/delay-optional/{seconds}, + Name: GET /api/delay-optional/{seconds}, LogicScope: aspnet-webapi.request, - Resource: GET api/delay-optional/{seconds}, + Resource: GET /api/delay-optional/{seconds}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -14,6 +14,7 @@ http.request.headers.host: localhost:00000, http.status_code: 200, http.url: http://localhost:00000/api/delay-optional, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_delay_0_statusCode=200.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_delay_0_statusCode=200.verified.txt index 3faec8ab5..542465bf8 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_delay_0_statusCode=200.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_delay_0_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/delay/{seconds}, + Name: GET /api/delay/{seconds}, LogicScope: aspnet-webapi.request, - Resource: GET api/delay/{seconds}, + Resource: GET /api/delay/{seconds}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -14,6 +14,7 @@ http.request.headers.host: localhost:00000, http.status_code: 200, http.url: http://localhost:00000/api/delay/0, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_environment_statusCode=200.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_environment_statusCode=200.verified.txt index b0f3d630f..280092068 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_environment_statusCode=200.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_environment_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/environment, + Name: GET /api/environment, LogicScope: aspnet-webapi.request, - Resource: GET api/environment, + Resource: GET /api/environment, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -14,6 +14,7 @@ http.request.headers.host: localhost:00000, http.status_code: 200, http.url: http://localhost:00000/api/environment, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_statuscode_201_statusCode=201.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_statuscode_201_statusCode=201.verified.txt index b26758437..7ba61f8b1 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_statuscode_201_statusCode=201.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_statuscode_201_statusCode=201.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/statuscode/{value}, + Name: GET /api/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api/statuscode/{value}, + Resource: GET /api/statuscode/{value}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -14,6 +14,7 @@ http.request.headers.host: localhost:00000, http.status_code: 201, http.url: http://localhost:00000/api/statuscode/201, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_statuscode_503_statusCode=503.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_statuscode_503_statusCode=503.verified.txt index b1dc55d1a..83253abd5 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_statuscode_503_statusCode=503.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_statuscode_503_statusCode=503.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/statuscode/{value}, + Name: GET /api/statuscode/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api/statuscode/{value}, + Resource: GET /api/statuscode/{value}, Service: Samples.Owin.WebApi2, Type: web, Error: 1, @@ -15,6 +15,7 @@ http.request.headers.host: localhost:00000, http.status_code: 503, http.url: http://localhost:00000/api/statuscode/503, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, sfx.error.message: The HTTP response has status code 503., diff --git a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_transient-failure_false_statusCode=500.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_transient-failure_false_statusCode=500.verified.txt index e6f8ee975..4c04d65c4 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_transient-failure_false_statusCode=500.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_transient-failure_false_statusCode=500.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/transient-failure/{value}, + Name: GET /api/transient-failure/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api/transient-failure/{value}, + Resource: GET /api/transient-failure/{value}, Service: Samples.Owin.WebApi2, Type: web, Error: 1, @@ -14,6 +14,7 @@ http.method: GET, http.request.headers.host: localhost:00000, http.url: http://localhost:00000/api/transient-failure/false, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, sfx.error.kind: System.ArgumentException, diff --git a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_transient-failure_true_statusCode=200.verified.txt b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_transient-failure_true_statusCode=200.verified.txt index 381ac0360..b458be276 100644 --- a/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_transient-failure_true_statusCode=200.verified.txt +++ b/tracer/test/snapshots/OwinWebApi2Tests.WithFF.__path=_api_transient-failure_true_statusCode=200.verified.txt @@ -2,9 +2,9 @@ { TraceId: Id_1, SpanId: Id_2, - Name: GET api/transient-failure/{value}, + Name: GET /api/transient-failure/{value}, LogicScope: aspnet-webapi.request, - Resource: GET api/transient-failure/{value}, + Resource: GET /api/transient-failure/{value}, Service: Samples.Owin.WebApi2, Type: web, Tags: { @@ -14,6 +14,7 @@ http.request.headers.host: localhost:00000, http.status_code: 200, http.url: http://localhost:00000/api/transient-failure/true, + http_useragent: Mozilla/5.0, language: dotnet, runtime-id: Guid_1, signalfx.tracing.library: dotnet-tracing, diff --git a/tracer/test/test-applications/Samples.Shared/SampleHelpers.cs b/tracer/test/test-applications/Samples.Shared/SampleHelpers.cs index a56198005..7c26ac318 100644 --- a/tracer/test/test-applications/Samples.Shared/SampleHelpers.cs +++ b/tracer/test/test-applications/Samples.Shared/SampleHelpers.cs @@ -39,7 +39,7 @@ public static string GetTracerAssemblyLocation() public static void RunShutDownTasks(object caller) { - var assemblies = AppDomain.CurrentDomain.GetAssemblies(); + var assemblies = System.AppDomain.CurrentDomain.GetAssemblies(); foreach (var assembly in assemblies) { diff --git a/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/App_Start/RouteConfig.cs b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/App_Start/RouteConfig.cs new file mode 100644 index 000000000..8d203e485 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/App_Start/RouteConfig.cs @@ -0,0 +1,25 @@ +using System.Web.Mvc; +using System.Web.Routing; + +namespace Samples.AspNet.VersionConflict +{ + public class RouteConfig + { + public static void RegisterRoutes(RouteCollection routes) + { + routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); + + routes.MapMvcAttributeRoutes(); + + routes.MapRoute( + name: "Default", + url: "{controller}/{action}/{id}", + defaults: new + { + controller = "Home", + action = "Index", + id = UrlParameter.Optional + }); + } + } +} diff --git a/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Controllers/HomeController.cs b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Controllers/HomeController.cs new file mode 100644 index 000000000..7112c8995 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Controllers/HomeController.cs @@ -0,0 +1,145 @@ +using System; +using System.Linq; +using System.Net.Http; +using System.Threading; +using System.Reflection; +using System.Web.Mvc; +using Datadog.Trace; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Samples.AspNet.VersionConflict.Controllers +{ + public class HomeController : Controller + { + private static readonly Version _manualTracingVersion = new Version("2.255.0.0"); + + public ActionResult Index() + { + var envVars = SampleHelpers.GetDatadogEnvironmentVariables(); + + return View(envVars.ToList()); + } + + public ActionResult Shutdown() + { + SampleHelpers.RunShutDownTasks(this); + + return RedirectToAction("Index"); + } + + public ActionResult ParentScope() + { + var scope = Tracer.Instance.ActiveScope; + + if (scope == null) + { + throw new Exception("Tracer.Instance.ActiveScope is null"); + } + + scope.Span.SetTag("Test", "OK"); + + var tagValue = scope.Span.GetTag("Test"); + + if (tagValue != "OK") + { + throw new Exception("Roundtrip tag test failed: " + (tagValue ?? "{null}")); + } + + scope.Span.SetTag(Tags.SamplingPriority, "UserKeep"); + + return Content(JsonConvert.SerializeObject(scope.Span, typeof(ISpan), new JsonSerializerSettings())); + } + + public ActionResult SendRequest() + { + int result; + + using (Tracer.Instance.StartActive("Manual")) + { + using (var innerScope = Tracer.Instance.StartActive("Manual-Inner")) + { + // Create two nested automatic spans to make sure the parent-child relationship is maintained + using (StartAutomaticTrace("Automatic-Outer")) + { + using (var client = new HttpClient()) + { + var target = Url.Action("Index", "Home", null, "http"); + var content = client.GetStringAsync(target).Result; + result = content.Length; + } + } + } + } + + return View(result); + } + + public ActionResult Sampling(bool parentTrace = true) + { + if (parentTrace) + { + CreateTraces(); + } + else + { + // Same test but without a parent automatic trace + var mutex = new ManualResetEventSlim(); + + ThreadPool.UnsafeQueueUserWorkItem(_ => + { + try + { + CreateTraces(); + } + finally + { + mutex.Set(); + } + + }, null); + + mutex.Wait(); + } + + return View(); + } + + private void CreateTraces() + { + using (var scope = Tracer.Instance.StartActive("Manual")) + { + scope.Span.SetTag(Tags.SamplingPriority, "UserKeep"); + + using (var client = new HttpClient()) + { + var target = Url.Action("Index", "Home", null, "http"); + + _ = client.GetStringAsync(target).Result; + + // This should be ignored because the sampling priority has been locked + scope.Span.SetTag(Tags.SamplingPriority, "UserReject"); + + _ = client.GetStringAsync(target).Result; + + Tracer.Instance.StartActive("Child").Dispose(); + } + } + } + + private static IDisposable StartAutomaticTrace(string operationName) + { + // Get the Datadog.Trace.Tracer type from the automatic instrumentation assembly + Assembly automaticAssembly = AppDomain.CurrentDomain.GetAssemblies().Single(asm => asm.GetName().Name.Equals("Datadog.Trace") && asm.GetName().Version < _manualTracingVersion); + Type tracerType = automaticAssembly.GetType("Datadog.Trace.Tracer"); + + // Invoke 'Tracer.Instance' + var instanceGetMethod = tracerType.GetProperty("Instance", BindingFlags.Static | BindingFlags.Public).GetGetMethod(); + object instance = instanceGetMethod.Invoke(null, new object[] {}); + + // Invoke 'public Scope StartActive(string operationName, ISpanContext parent = null, string serviceName = null, DateTimeOffset? startTime = null, bool ignoreActiveScope = false, bool finishOnClose = true)' + var startActive = tracerType.GetMethod("StartActive", new Type[] { typeof(string) }); + return (IDisposable)startActive.Invoke(instance, new[] { operationName }); + } + } +} diff --git a/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Global.asax b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Global.asax new file mode 100644 index 000000000..b52d6d3ac --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Global.asax @@ -0,0 +1 @@ +<%@ Application Codebehind="Global.asax.cs" Inherits="Samples.AspNet.VersionConflict.MvcApplication" Language="C#" %> diff --git a/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Global.asax.cs b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Global.asax.cs new file mode 100644 index 000000000..f36261028 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Global.asax.cs @@ -0,0 +1,16 @@ +using System.Web; +using System.Web.Http; +using System.Web.Mvc; +using System.Web.Routing; + +namespace Samples.AspNet.VersionConflict +{ + public class MvcApplication : HttpApplication + { + protected void Application_Start() + { + AreaRegistration.RegisterAllAreas(); + RouteConfig.RegisterRoutes(RouteTable.Routes); + } + } +} diff --git a/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Properties/AssemblyInfo.cs b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..b4bb96c53 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Samples.AspNet.VersionConflict")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Samples.AspNet.VersionConflict")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("3c6dd42e-9214-4747-92ba-78de29aace59")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Samples.AspNet.VersionConflict.csproj b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Samples.AspNet.VersionConflict.csproj new file mode 100644 index 000000000..a704a2c9e --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Samples.AspNet.VersionConflict.csproj @@ -0,0 +1,225 @@ + + + + + + Debug + x64 + + + 2.0 + {FAB2B108-E5BE-4647-869B-1DC5D362252E} + {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + Samples.AspNet.VersionConflict + Samples.AspNet.VersionConflict + v4.6.1 + true + true + + + + + + + + + + + + ..\..\..\..\..\packages\Datadog.Trace.2.255.246\lib\net461\Datadog.Trace.dll + + + ..\..\..\..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + + ..\..\..\..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + + ..\..\..\..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll + + + + ..\..\..\..\..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll + + + + + ..\..\..\..\..\packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll + + + + + + + + + + ..\..\..\..\..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.Helpers.dll + + + ..\..\..\..\..\packages\Microsoft.AspNet.WebApi.Core.5.1.2\lib\net45\System.Web.Http.dll + + + ..\..\..\..\..\packages\Microsoft.AspNet.WebApi.Tracing.5.1.2\lib\net45\System.Web.Http.Tracing.dll + + + ..\..\..\..\..\packages\Microsoft.AspNet.WebApi.WebHost.5.1.2\lib\net45\System.Web.Http.WebHost.dll + + + ..\..\..\..\..\packages\Microsoft.AspNet.Mvc.5.2.7\lib\net45\System.Web.Mvc.dll + + + ..\..\..\..\..\packages\Microsoft.AspNet.Razor.3.2.7\lib\net45\System.Web.Razor.dll + + + ..\..\..\..\..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.dll + + + ..\..\..\..\..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Deployment.dll + + + ..\..\..\..\..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Razor.dll + + + + + + + + + + + + ..\..\..\..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll + + + + + + + + + + + Global.asax + + + + + + + + + + + + + Web.config + + + Web.config + + + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + AnyCPU + bin\ + DEBUG;TRACE + prompt + full + true + MinimumRecommendedRules.ruleset + + + AnyCPU + bin\ + true + TRACE + prompt + pdbonly + true + MinimumRecommendedRules.ruleset + + + true + bin\ + DEBUG;TRACE + full + x64 + prompt + MinimumRecommendedRules.ruleset + + + true + bin\ + TRACE + true + pdbonly + x64 + prompt + MinimumRecommendedRules.ruleset + + + true + bin\ + DEBUG;TRACE + full + x86 + prompt + MinimumRecommendedRules.ruleset + + + true + bin\ + TRACE + true + pdbonly + x86 + prompt + MinimumRecommendedRules.ruleset + + + true + + + + + + + + + True + True + 50449 + / + http://localhost:50449/ + False + False + + + False + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Samples.AspNet.VersionConflict.csproj.DotSettings b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Samples.AspNet.VersionConflict.csproj.DotSettings new file mode 100644 index 000000000..b9fd6ee4f --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Samples.AspNet.VersionConflict.csproj.DotSettings @@ -0,0 +1,2 @@ + + CSharp80 \ No newline at end of file diff --git a/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Views/Home/Index.cshtml b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Views/Home/Index.cshtml new file mode 100644 index 000000000..c6f14b1eb --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Views/Home/Index.cshtml @@ -0,0 +1,63 @@ +@using Samples +@model List> + +@{ + ViewBag.Title = "Index"; +} + +
+ + + + + + + + + + + + + + + + + + + + + + + +
Application bitness@(Environment.Is64BitProcess ? "64-bit" : "32-bit")
Profiler attached@SampleHelpers.IsProfilerAttached()
Current directory@(Environment.CurrentDirectory)
MapPath("~")@(System.Web.Hosting.HostingEnvironment.IsHosted ? System.Web.Hosting.HostingEnvironment.MapPath("~") : null)
Datadog.Trace.dll path@SampleHelpers.GetTracerAssemblyLocation()
+
+ +
+
Environment Variables:
+ + + + + + + + + @if (Model.Any()) + { + foreach (var envVar in Model) + { + + + + + } + } + else + { + + + + } + +
NameValue
@envVar.Key@envVar.Value
(empty)
+
diff --git a/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Views/Home/Sampling.cshtml b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Views/Home/Sampling.cshtml new file mode 100644 index 000000000..c431ed0dd --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Views/Home/Sampling.cshtml @@ -0,0 +1,5 @@ +@{ + ViewBag.Title = "Sampling"; +} + +

Hello, world!

diff --git a/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Views/Home/SendRequest.cshtml b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Views/Home/SendRequest.cshtml new file mode 100644 index 000000000..0cc13b746 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Views/Home/SendRequest.cshtml @@ -0,0 +1,8 @@ +@model int + +@{ + ViewBag.Title = "Request"; +} + +

Hello, world!

+

Downloaded @Model bytes

\ No newline at end of file diff --git a/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Views/_Layout.cshtml b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Views/_Layout.cshtml new file mode 100644 index 000000000..ae9851976 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Views/_Layout.cshtml @@ -0,0 +1,15 @@ + + + + + + @ViewBag.Title - Samples.AspNet.VersionConflict + + + + +
+ @RenderBody() +
+ + diff --git a/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Views/_ViewStart.cshtml b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Views/_ViewStart.cshtml new file mode 100644 index 000000000..f2c8fb697 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Views/_ViewStart.cshtml @@ -0,0 +1,3 @@ +@{ + Layout = "~/Views/_Layout.cshtml"; +} \ No newline at end of file diff --git a/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Views/web.config b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Views/web.config new file mode 100644 index 000000000..32c3beea0 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Views/web.config @@ -0,0 +1,42 @@ + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Web.Debug.config b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Web.Debug.config new file mode 100644 index 000000000..fae9cfefa --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Web.Debug.config @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Web.Release.config b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Web.Release.config new file mode 100644 index 000000000..da6e960b8 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Web.Release.config @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Web.config b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Web.config new file mode 100644 index 000000000..8a2c918d8 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/Web.config @@ -0,0 +1,72 @@ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/packages.config b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/packages.config new file mode 100644 index 000000000..9f66fdbdf --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNet.VersionConflict/packages.config @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tracer/test/test-applications/integrations/LogsInjection.ILogger.VersionConflict.2x/LogHelper.cs b/tracer/test/test-applications/integrations/LogsInjection.ILogger.VersionConflict.2x/LogHelper.cs new file mode 100644 index 000000000..e62559cc2 --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.ILogger.VersionConflict.2x/LogHelper.cs @@ -0,0 +1,168 @@ +using System; +using System.Collections.Generic; +using System.IO; +#if NET6_0_OR_GREATER +using System.Text.Json.Serialization; +#endif +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Logging; + +namespace LogsInjection.ILogger.VersionConflict_2x +{ + public static class LogHelper + { + public const string ExcludeMessagePrefix = "[ExcludeMessage]"; + + public static void UninjectedLog(this Microsoft.Extensions.Logging.ILogger logger, string message) + { + logger.LogInformation($"{ExcludeMessagePrefix}{message}"); + } + + public static void ConditionalLog(this Microsoft.Extensions.Logging.ILogger logger, string message) + { +#if NETCOREAPP + logger.LogInformation(message); +#else + // We don't instrument on .NET Framework, so we don't expect this to be log injected + logger.UninjectedLog(message); +#endif + } + + public static void ConfigureCustomLogging(WebHostBuilderContext ctx, ILoggingBuilder logging) + { + // delete existing log file + var logFile = Path.Combine(ctx.HostingEnvironment.ContentRootPath, "simple.log"); + if (File.Exists(logFile)) + { + try + { + File.Delete(logFile); + } + catch + { + // Don't throw if something's amiss + } + } + + logging.AddProvider(new SimpleLogProvider(logFile)); + } + + public class SimpleLogProvider : ILoggerProvider, ISupportExternalScope + { + private readonly string _logPath; + + public SimpleLogProvider(string logPath) + { + _logPath = logPath; + } + + internal IExternalScopeProvider ScopeProvider { get; private set; } + + public Microsoft.Extensions.Logging.ILogger CreateLogger(string categoryName) => new SimpleLogger(this, categoryName, _logPath); + + public void Dispose() + { + } + + void ISupportExternalScope.SetScopeProvider(IExternalScopeProvider scopeProvider) + { + ScopeProvider = scopeProvider; + } + + public class SimpleLogger : Microsoft.Extensions.Logging.ILogger + { + private readonly SimpleLogProvider _provider; + private readonly string _logPath; + private readonly string _category; + + public SimpleLogger(SimpleLogProvider loggerProvider, string categoryName, string logPath) + { + _provider = loggerProvider; + _category = categoryName; + _logPath = logPath; + } + + public IDisposable BeginScope(TState state) + { + return _provider.ScopeProvider?.Push(state); + } + + public bool IsEnabled(LogLevel logLevel) + { + return true; + } + + public void Log(DateTimeOffset timestamp, LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter) + { + if (!IsEnabled(logLevel)) + { + return; + } + + var scopes = new Dictionary(); + var scopeProvider = _provider.ScopeProvider; + if (scopeProvider != null) + { + scopeProvider.ForEachScope( + (scope, builder) => + { + if (scope is IEnumerable> pairs) + { + foreach (var kvp in pairs) + { + builder[kvp.Key] = kvp.Value; + } + } + else + { + var temp = builder.TryGetValue("scopes", out var rawScope) + ? (List)rawScope + : new List(); + temp.Add(scope); + builder["scopes"] = temp; + } + }, + scopes); + } +#if NETCOREAPP2_1 || !NETCOREAPP + var log = Newtonsoft.Json.JsonConvert.SerializeObject( + new + { + timestamp = timestamp.ToString("yyyy-MM-dd HH:mm:ss.fff zzz"), + category = _category, + scopes = scopes, + message = formatter(state, exception), + exception = exception?.Message + }, Newtonsoft.Json.Formatting.None); +#else + var log = System.Text.Json.JsonSerializer.Serialize( + new + { + timestamp = timestamp.ToString("yyyy-MM-dd HH:mm:ss.fff zzz"), + category = _category, + scopes = scopes, + message = formatter(state, exception), + exception = exception?.Message + }, new System.Text.Json.JsonSerializerOptions() + { + WriteIndented = false, +#if NET6_0_OR_GREATER + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, +#else + IgnoreNullValues = true, +#endif + }); +#endif + + + File.AppendAllText(_logPath, log + Environment.NewLine); + } + + public void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter) + { + Log(DateTimeOffset.UtcNow, logLevel, eventId, state, exception, formatter); + } + } + } + } +} diff --git a/tracer/test/test-applications/integrations/LogsInjection.ILogger.VersionConflict.2x/LogsInjection.ILogger.VersionConflict.2x.csproj b/tracer/test/test-applications/integrations/LogsInjection.ILogger.VersionConflict.2x/LogsInjection.ILogger.VersionConflict.2x.csproj new file mode 100644 index 000000000..7ac1a0c96 --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.ILogger.VersionConflict.2x/LogsInjection.ILogger.VersionConflict.2x.csproj @@ -0,0 +1,28 @@ + + + + net461;netcoreapp2.1;netcoreapp3.0;netcoreapp3.1;net5.0;net6.0 + false + false + + + + + + + + + + + + + + + + + + + + + + diff --git a/tracer/test/test-applications/integrations/LogsInjection.ILogger.VersionConflict.2x/Program.cs b/tracer/test/test-applications/integrations/LogsInjection.ILogger.VersionConflict.2x/Program.cs new file mode 100644 index 000000000..e16e335c5 --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.ILogger.VersionConflict.2x/Program.cs @@ -0,0 +1,22 @@ +using System; +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Hosting; + +namespace LogsInjection.ILogger.VersionConflict_2x +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IWebHostBuilder CreateHostBuilder(string[] args) => + WebHost.CreateDefaultBuilder(args) + .UseContentRoot(AppContext.BaseDirectory) + .UseSetting(WebHostDefaults.SuppressStatusMessagesKey, "True") + .ConfigureLogging(LogHelper.ConfigureCustomLogging) + .UseStartup(); + + } +} diff --git a/tracer/test/test-applications/integrations/LogsInjection.ILogger.VersionConflict.2x/Properties/launchSettings.json b/tracer/test/test-applications/integrations/LogsInjection.ILogger.VersionConflict.2x/Properties/launchSettings.json new file mode 100644 index 000000000..debe25d3e --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.ILogger.VersionConflict.2x/Properties/launchSettings.json @@ -0,0 +1,24 @@ +{ + "profiles": { + "LogsInjection.ILogger.VersionConflict.2x": { + "commandName": "Project", + "dotnetRunMessages": "false", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_URLS": "http://127.0.0.1:0", + + "COR_ENABLE_PROFILING": "1", + "COR_PROFILER": "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}", + "COR_PROFILER_PATH": "$(SolutionDir)tracer\\bin\\tracer-home\\win-$(Platform)\\Datadog.Trace.ClrProfiler.Native.dll", + + "CORECLR_ENABLE_PROFILING": "1", + "CORECLR_PROFILER": "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}", + "CORECLR_PROFILER_PATH": "$(SolutionDir)tracer\\bin\\tracer-home\\win-$(Platform)\\Datadog.Trace.ClrProfiler.Native.dll", + + "SIGNALFX_DOTNET_TRACER_HOME": "$(SolutionDir)tracer\\bin\\tracer-home", + "SIGNALFX_VERSION": "1.0.0", + "SIGNALFX_LOGS_INJECTION": "1" + } + } + } +} \ No newline at end of file diff --git a/tracer/test/test-applications/integrations/LogsInjection.ILogger.VersionConflict.2x/Startup.cs b/tracer/test/test-applications/integrations/LogsInjection.ILogger.VersionConflict.2x/Startup.cs new file mode 100644 index 000000000..1eac89337 --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.ILogger.VersionConflict.2x/Startup.cs @@ -0,0 +1,56 @@ +using System.Linq; +using Datadog.Trace; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Hosting.Server.Features; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + +namespace LogsInjection.ILogger.VersionConflict_2x +{ + public class Startup + { + public static volatile bool AppListening = false; + public static volatile string ServerAddress = null; + public void ConfigureServices(IServiceCollection services) + { + services.AddHostedService(); + services.AddHttpClient(); + } + +#pragma warning disable 618 // ignore obsolete IApplicationLifetime + public void Configure(IApplicationBuilder app, IApplicationLifetime lifetime, ILogger logger) +#pragma warning restore 618 + { + // Not injected as we won't have a traceId + logger.UninjectedLog("Building pipeline"); + using (var scope = Tracer.Instance.StartActive("pipeline build")) + { + logger.LogInformation("Still building pipeline..."); + } + + // Register a callback to run after the app is fully configured + lifetime.ApplicationStarted.Register(() => + { + ServerAddress = app.ServerFeatures.Get().Addresses.First(); + AppListening = true; + }); + + app.Use((httpContext, next) => + { + logger.ConditionalLog($"Visited {httpContext.Request.Path}"); + return next(); + }); + + app.Run(context => + { + logger.ConditionalLog("Received request, echoing"); + + using var scope = Tracer.Instance.StartActive("middleware execution"); + logger.LogInformation("Sending response"); + return context.Response.WriteAsync("PONG"); + }); + } + } +} diff --git a/tracer/test/test-applications/integrations/LogsInjection.ILogger.VersionConflict.2x/Worker.cs b/tracer/test/test-applications/integrations/LogsInjection.ILogger.VersionConflict.2x/Worker.cs new file mode 100644 index 000000000..8bad2b2bc --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.ILogger.VersionConflict.2x/Worker.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; + +namespace LogsInjection.ILogger.VersionConflict_2x +{ + public class Worker : BackgroundService + { + private readonly ILogger _logger; + private readonly IServiceProvider _serviceProvider; +#pragma warning disable 618 // ignore obsolete IApplicationLifetime + private readonly IApplicationLifetime _lifetime; + + public Worker(ILogger logger, IApplicationLifetime lifetime, IServiceProvider serviceProvider) +#pragma warning restore 618 + { + _logger = logger; + _lifetime = lifetime; + _serviceProvider = serviceProvider; + } + + protected override async Task ExecuteAsync(CancellationToken stoppingToken) + { + while (!Startup.AppListening && !stoppingToken.IsCancellationRequested) + { + _logger.UninjectedLog("Waiting for app started handling requests"); + await Task.Delay(100, stoppingToken); + } + + if (stoppingToken.IsCancellationRequested) + { + _logger.UninjectedLog("Cancellation requested."); + return; + } + + using (var scope = Datadog.Trace.Tracer.Instance.StartActive("worker request")) + { + try + { + using var serviceScope = _serviceProvider.CreateScope(); + var httpClientFactory = serviceScope.ServiceProvider.GetRequiredService(); + var client = httpClientFactory.CreateClient(); + + _logger.LogInformation("Sending request to self"); + var response = await client.GetAsync(Startup.ServerAddress, stoppingToken); + + if (!response.IsSuccessStatusCode) + { + _logger.LogError("Error sending request, status code did not indicate success"); + response.EnsureSuccessStatusCode(); + } + + _logger.LogInformation("Request sent successfully"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error sending request"); + } + } + + _logger.UninjectedLog("Stopping application"); + + // trigger app shutdown + _lifetime.StopApplication(); + } + } +} diff --git a/tracer/test/test-applications/integrations/LogsInjection.ILogger.VersionConflict.2x/appsettings.json b/tracer/test/test-applications/integrations/LogsInjection.ILogger.VersionConflict.2x/appsettings.json new file mode 100644 index 000000000..8983e0fc1 --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.ILogger.VersionConflict.2x/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/tracer/test/test-applications/integrations/LogsInjection.Log4Net.VersionConflict.2x/AppDirFileAppender.cs b/tracer/test/test-applications/integrations/LogsInjection.Log4Net.VersionConflict.2x/AppDirFileAppender.cs new file mode 100644 index 000000000..443628a0c --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.Log4Net.VersionConflict.2x/AppDirFileAppender.cs @@ -0,0 +1,20 @@ +using System.IO; +using log4net.Appender; + +namespace LogsInjection.Log4Net.VersionConflict_2x +{ + /// + /// See the following StackOverflow link for overwriting built-in appenders: https://stackoverflow.com/questions/1922430/how-do-you-make-log4net-output-to-current-working-directory + /// + public class AppDirFileAppender : FileAppender + { + public override string File + { + set + { + var directory = Directory.GetParent(typeof(AppDirFileAppender).Assembly.Location).FullName; + base.File = Path.Combine(directory, value); + } + } + } +} diff --git a/tracer/test/test-applications/integrations/LogsInjection.Log4Net.VersionConflict.2x/LogsInjection.Log4Net.VersionConflict.2x.csproj b/tracer/test/test-applications/integrations/LogsInjection.Log4Net.VersionConflict.2x/LogsInjection.Log4Net.VersionConflict.2x.csproj new file mode 100644 index 000000000..259773d47 --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.Log4Net.VersionConflict.2x/LogsInjection.Log4Net.VersionConflict.2x.csproj @@ -0,0 +1,24 @@ + + + + + net461;netcoreapp3.0;netcoreapp3.1;net5.0;net6.0 + netcoreapp3.0;netcoreapp3.1;net5.0;net6.0 + + + + + + + + + + + + + + Always + + + + diff --git a/tracer/test/test-applications/integrations/LogsInjection.Log4Net.VersionConflict.2x/Program.cs b/tracer/test/test-applications/integrations/LogsInjection.Log4Net.VersionConflict.2x/Program.cs new file mode 100644 index 000000000..4400d310c --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.Log4Net.VersionConflict.2x/Program.cs @@ -0,0 +1,28 @@ +using System.IO; +using log4net; +using log4net.Config; +using LogsInjectionHelper.VersionConflict; + +namespace LogsInjection.Log4Net.VersionConflict_2x +{ + public class Program + { + private static readonly ILog log = LogManager.GetLogger(typeof(Program)); + + public static int Main(string[] args) + { + var appDirectory = Directory.GetParent(typeof(Program).Assembly.Location).FullName; + var textFilePath = Path.Combine(appDirectory, "log-textFile.log"); + var jsonFilePath = Path.Combine(appDirectory, "log-jsonFile.log"); + + File.Delete(textFilePath); + File.Delete(jsonFilePath); + + // Initialize log4net + var logRepository = LogManager.GetRepository(typeof(Program).Assembly); + XmlConfigurator.Configure(logRepository, new FileInfo(Path.Combine(appDirectory, "log4net.205.config"))); + + return LoggingMethods.RunLoggingProcedure(log.Info); + } + } +} diff --git a/tracer/test/test-applications/integrations/LogsInjection.Log4Net.VersionConflict.2x/Properties/launchSettings.json b/tracer/test/test-applications/integrations/LogsInjection.Log4Net.VersionConflict.2x/Properties/launchSettings.json new file mode 100644 index 000000000..5983c173e --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.Log4Net.VersionConflict.2x/Properties/launchSettings.json @@ -0,0 +1,22 @@ +{ + "profiles": { + "LogsInjection.Log4Net.VersionConflict.2x": { + "commandName": "Project", + "environmentVariables": { + "COR_ENABLE_PROFILING": "1", + "COR_PROFILER": "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}", + "COR_PROFILER_PATH": "$(SolutionDir)tracer\\bin\\tracer-home\\win-$(Platform)\\Datadog.Trace.ClrProfiler.Native.dll", + + "CORECLR_ENABLE_PROFILING": "1", + "CORECLR_PROFILER": "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}", + "CORECLR_PROFILER_PATH": "$(SolutionDir)tracer\\bin\\tracer-home\\win-$(Platform)\\Datadog.Trace.ClrProfiler.Native.dll", + + "SIGNALFX_DOTNET_TRACER_HOME": "$(SolutionDir)tracer\\bin\\tracer-home", + "SIGNALFX_VERSION": "1.0.0", + + "SIGNALFX_LOGS_INJECTION": "true" + }, + "nativeDebugging": true + } + } +} \ No newline at end of file diff --git a/tracer/test/test-applications/integrations/LogsInjection.Log4Net.VersionConflict.2x/log4net.205.config b/tracer/test/test-applications/integrations/LogsInjection.Log4Net.VersionConflict.2x/log4net.205.config new file mode 100644 index 000000000..597dd53b7 --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.Log4Net.VersionConflict.2x/log4net.205.config @@ -0,0 +1,47 @@ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tracer/test/test-applications/integrations/LogsInjection.NLog.VersionConflict.2x/LogsInjection.NLog.VersionConflict.2x.csproj b/tracer/test/test-applications/integrations/LogsInjection.NLog.VersionConflict.2x/LogsInjection.NLog.VersionConflict.2x.csproj new file mode 100644 index 000000000..7a7e5a2bb --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.NLog.VersionConflict.2x/LogsInjection.NLog.VersionConflict.2x.csproj @@ -0,0 +1,23 @@ + + + + + net461;netcoreapp3.0;netcoreapp3.1;net5.0;net6.0 + netcoreapp3.0;netcoreapp3.1;net5.0;net6.0 + + + + + + + + + + + + + Always + + + + diff --git a/tracer/test/test-applications/integrations/LogsInjection.NLog.VersionConflict.2x/NLog.46.config b/tracer/test/test-applications/integrations/LogsInjection.NLog.VersionConflict.2x/NLog.46.config new file mode 100644 index 000000000..9abf89a45 --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.NLog.VersionConflict.2x/NLog.46.config @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tracer/test/test-applications/integrations/LogsInjection.NLog.VersionConflict.2x/Program.cs b/tracer/test/test-applications/integrations/LogsInjection.NLog.VersionConflict.2x/Program.cs new file mode 100644 index 000000000..01df7835b --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.NLog.VersionConflict.2x/Program.cs @@ -0,0 +1,46 @@ +using System.IO; +using System.Runtime.InteropServices; +using LogsInjectionHelper.VersionConflict; +using NLog; +using NLog.Config; +using NLog.Targets; + +namespace LogsInjection.NLog.VersionConflict_2x +{ + public class Program + { + public static int Main(string[] args) + { + var appDirectory = Directory.GetParent(typeof(Program).Assembly.Location).FullName; + var textFilePath = Path.Combine(appDirectory, "log-textFile.log"); + var jsonFilePath = Path.Combine(appDirectory, "log-jsonFile.log"); + + File.Delete(textFilePath); + File.Delete(jsonFilePath); + + // Initialize NLog + LogManager.Configuration = new XmlLoggingConfiguration(Path.Combine(appDirectory, "NLog.46.config")); +#if NETCOREAPP + // Hacks for the fact the NLog on Linux just can't do anything right + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + var target = (FileTarget)LogManager.Configuration.FindTargetByName("textFile"); + if (target is not null) + { + target.FileName = Path.Combine(appDirectory, "log-textFile.log"); + } + + target = (FileTarget)LogManager.Configuration.FindTargetByName("jsonFile"); + if (target is not null) + { + target.FileName = Path.Combine(appDirectory, "log-jsonFile.log"); + } + LogManager.ReconfigExistingLoggers(); + } +#endif + + Logger logger = LogManager.GetCurrentClassLogger(); + return LoggingMethods.RunLoggingProcedure(logger.Info); + } + } +} diff --git a/tracer/test/test-applications/integrations/LogsInjection.NLog.VersionConflict.2x/Properties/launchSettings.json b/tracer/test/test-applications/integrations/LogsInjection.NLog.VersionConflict.2x/Properties/launchSettings.json new file mode 100644 index 000000000..70095ff44 --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.NLog.VersionConflict.2x/Properties/launchSettings.json @@ -0,0 +1,22 @@ +{ + "profiles": { + "LogsInjection.NLog.VersionConflict.2x": { + "commandName": "Project", + "environmentVariables": { + "COR_ENABLE_PROFILING": "1", + "COR_PROFILER": "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}", + "COR_PROFILER_PATH": "$(SolutionDir)tracer\\bin\\tracer-home\\win-$(Platform)\\Datadog.Trace.ClrProfiler.Native.dll", + + "CORECLR_ENABLE_PROFILING": "1", + "CORECLR_PROFILER": "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}", + "CORECLR_PROFILER_PATH": "$(SolutionDir)tracer\\bin\\tracer-home\\win-$(Platform)\\Datadog.Trace.ClrProfiler.Native.dll", + + "SIGNALFX_DOTNET_TRACER_HOME": "$(SolutionDir)tracer\\bin\\tracer-home", + "SIGNALFX_VERSION": "1.0.0", + + "SIGNALFX_LOGS_INJECTION": "true" + }, + "nativeDebugging": true + } + } +} \ No newline at end of file diff --git a/tracer/test/test-applications/integrations/LogsInjection.NLog/LogsInjection.NLog.csproj b/tracer/test/test-applications/integrations/LogsInjection.NLog/LogsInjection.NLog.csproj index e0ff5e6d0..b75469c40 100644 --- a/tracer/test/test-applications/integrations/LogsInjection.NLog/LogsInjection.NLog.csproj +++ b/tracer/test/test-applications/integrations/LogsInjection.NLog/LogsInjection.NLog.csproj @@ -1,7 +1,7 @@  - 4.1.2 + 1.0.0.505 4.5.0 $(DefineConstants);NLOG_4_0 $(DefineConstants);NLOG_4_6 diff --git a/tracer/test/test-applications/integrations/LogsInjection.NLog/Program.cs b/tracer/test/test-applications/integrations/LogsInjection.NLog/Program.cs index 2908e68e7..4f95bcb6c 100644 --- a/tracer/test/test-applications/integrations/LogsInjection.NLog/Program.cs +++ b/tracer/test/test-applications/integrations/LogsInjection.NLog/Program.cs @@ -1,7 +1,10 @@ - using System; +using System.Collections; +using System.Collections.Generic; using System.IO; using System.Runtime.InteropServices; +using System.Linq; +using System.Reflection; using NLog; using NLog.Config; using NLog.Targets; @@ -20,16 +23,36 @@ public static int Main(string[] args) // Disabling the startup log at the process level should prevent this. Environment.SetEnvironmentVariable("SIGNALFX_TRACE_STARTUP_LOGS", "0"); + var env = SampleHelpers.GetDatadogEnvironmentVariables(); + foreach(var kvp in env) + { + Console.WriteLine($"{kvp.Key}: {kvp.Value}"); + } + + bool isAttached = SampleHelpers.IsProfilerAttached(); + Console.WriteLine(" * Checking if the profiler is attached: {0}", isAttached); + LoggingMethods.DeleteExistingLogs(); // Initialize NLog var appDirectory = Directory.GetParent(typeof(Program).Assembly.Location).FullName; #if NLOG_4_6 LogManager.Configuration = new XmlLoggingConfiguration(Path.Combine(appDirectory, "NLog.46.config")); + Console.WriteLine("Using NLOG_4_6 configuration"); + + global::NLog.LogManager.ThrowExceptions = true; + global::NLog.Common.InternalLogger.LogToConsole = true; + global::NLog.Common.InternalLogger.LogLevel = LogLevel.Debug; #elif NLOG_4_0 LogManager.Configuration = new XmlLoggingConfiguration(Path.Combine(appDirectory, "NLog.40.config")); + Console.WriteLine("Using NLOG_4_0 configuration"); + + global::NLog.LogManager.ThrowExceptions = true; + global::NLog.Common.InternalLogger.LogToConsole = true; + global::NLog.Common.InternalLogger.LogLevel = LogLevel.Debug; #else LogManager.Configuration = new XmlLoggingConfiguration(Path.Combine(appDirectory, "NLog.Pre40.config")); + Console.WriteLine("Using pre NLOG_4_0 configuration"); #endif #if NETCOREAPP // Hacks for the fact the NLog on Linux just can't do anything right @@ -54,4 +77,66 @@ public static int Main(string[] args) return LoggingMethods.RunLoggingProcedure(Logger.Info); } } + + public class SampleHelpers + { + private static readonly Type NativeMethodsType = Type.GetType("Datadog.Trace.ClrProfiler.NativeMethods, Datadog.Trace"); + + public static bool IsProfilerAttached() + { + if(NativeMethodsType is null) + { + return false; + } + + try + { + MethodInfo profilerAttachedMethodInfo = NativeMethodsType.GetMethod("IsProfilerAttached"); + return (bool)profilerAttachedMethodInfo.Invoke(null, null); + } + catch (Exception ex) + { + Console.WriteLine(ex); + } + + return false; + } + + public static string GetTracerAssemblyLocation() + { + return NativeMethodsType?.Assembly.Location ?? "(none)"; + } + + public static void RunShutDownTasks(object caller) + { + var assemblies = AppDomain.CurrentDomain.GetAssemblies(); + + foreach (var assembly in assemblies) + { + foreach (var type in assembly.DefinedTypes) + { + if (type.Namespace == "Coverlet.Core.Instrumentation.Tracker") + { + var unloadModuleMethod = type.GetMethod("UnloadModule", BindingFlags.Public | BindingFlags.Static); + unloadModuleMethod.Invoke(null, new object[] { caller, EventArgs.Empty }); + } + } + } + } + + public static IEnumerable> GetDatadogEnvironmentVariables() + { + var prefixes = new[] { "COR_", "CORECLR_", "SIGNALFX_" }; + + var envVars = from envVar in Environment.GetEnvironmentVariables().Cast() + from prefix in prefixes + let key = (envVar.Key as string)?.ToUpperInvariant() + let value = envVar.Value as string + where key.StartsWith(prefix) + orderby key + select new KeyValuePair(key, value); + + return envVars.ToList(); + } + } } diff --git a/tracer/test/test-applications/integrations/LogsInjection.NLog/Properties/launchSettings.json b/tracer/test/test-applications/integrations/LogsInjection.NLog/Properties/launchSettings.json index 774ff1efe..d7025157c 100644 --- a/tracer/test/test-applications/integrations/LogsInjection.NLog/Properties/launchSettings.json +++ b/tracer/test/test-applications/integrations/LogsInjection.NLog/Properties/launchSettings.json @@ -3,7 +3,17 @@ "LogsInjection.NLog": { "commandName": "Project", "environmentVariables": { - "SIGNALFX_LOGS_INJECTION": "true" + "SIGNALFX_LOGS_INJECTION": "true", + "COR_ENABLE_PROFILING": "1", + "COR_PROFILER": "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}", + "COR_PROFILER_PATH": "$(SolutionDir)tracer\\bin\\tracer-home\\win-$(Platform)\\SignalFx.Trace.ClrProfiler.Native.dll", + + "CORECLR_ENABLE_PROFILING": "1", + "CORECLR_PROFILER": "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}", + "CORECLR_PROFILER_PATH": "$(SolutionDir)tracer\\bin\\tracer-home\\win-$(Platform)\\SignalFx.Trace.ClrProfiler.Native.dll", + + "SIGNALFX_DOTNET_TRACER_HOME": "$(SolutionDir)tracer\\bin\\tracer-home", + "SIGNALFX_VERSION": "1.0.0", } } } diff --git a/tracer/test/test-applications/integrations/LogsInjection.NLog10.VersionConflict.2x/LogsInjection.NLog10.VersionConflict.2x.csproj b/tracer/test/test-applications/integrations/LogsInjection.NLog10.VersionConflict.2x/LogsInjection.NLog10.VersionConflict.2x.csproj new file mode 100644 index 000000000..8e22a1f5d --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.NLog10.VersionConflict.2x/LogsInjection.NLog10.VersionConflict.2x.csproj @@ -0,0 +1,23 @@ + + + + + net461 + + + + + + + + + + + + + + Always + + + + diff --git a/tracer/test/test-applications/integrations/LogsInjection.NLog10.VersionConflict.2x/NLog.Pre40.config b/tracer/test/test-applications/integrations/LogsInjection.NLog10.VersionConflict.2x/NLog.Pre40.config new file mode 100644 index 000000000..92ae66afd --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.NLog10.VersionConflict.2x/NLog.Pre40.config @@ -0,0 +1,13 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/tracer/test/test-applications/integrations/LogsInjection.NLog10.VersionConflict.2x/Program.cs b/tracer/test/test-applications/integrations/LogsInjection.NLog10.VersionConflict.2x/Program.cs new file mode 100644 index 000000000..7da2e3321 --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.NLog10.VersionConflict.2x/Program.cs @@ -0,0 +1,24 @@ +using System.IO; +using LogsInjectionHelper.VersionConflict; +using NLog; +using NLog.Config; + +namespace LogsInjection.NLog10.VersionConflict_2x +{ + public class Program + { + public static int Main(string[] args) + { + var appDirectory = Directory.GetParent(typeof(Program).Assembly.Location).FullName; + var textFilePath = Path.Combine(appDirectory, "log-textFile.log"); + + File.Delete(textFilePath); + + // Initialize NLog + LogManager.Configuration = new XmlLoggingConfiguration(Path.Combine(appDirectory, "NLog.Pre40.config")); + Logger logger = LogManager.GetCurrentClassLogger(); + + return LoggingMethods.RunLoggingProcedure(logger.Info); + } + } +} diff --git a/tracer/test/test-applications/integrations/LogsInjection.NLog10.VersionConflict.2x/Properties/launchSettings.json b/tracer/test/test-applications/integrations/LogsInjection.NLog10.VersionConflict.2x/Properties/launchSettings.json new file mode 100644 index 000000000..0114501bf --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.NLog10.VersionConflict.2x/Properties/launchSettings.json @@ -0,0 +1,22 @@ +{ + "profiles": { + "LogsInjection.NLog10.VersionConflict.2x": { + "commandName": "Project", + "environmentVariables": { + "COR_ENABLE_PROFILING": "1", + "COR_PROFILER": "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}", + "COR_PROFILER_PATH": "$(SolutionDir)tracer\\bin\\tracer-home\\win-$(Platform)\\Datadog.Trace.ClrProfiler.Native.dll", + + "CORECLR_ENABLE_PROFILING": "1", + "CORECLR_PROFILER": "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}", + "CORECLR_PROFILER_PATH": "$(SolutionDir)tracer\\bin\\tracer-home\\win-$(Platform)\\Datadog.Trace.ClrProfiler.Native.dll", + + "SIGNALFX_DOTNET_TRACER_HOME": "$(SolutionDir)tracer\\bin\\tracer-home", + "SIGNALFX_VERSION": "1.0.0", + + "SIGNALFX_LOGS_INJECTION": "true" + }, + "nativeDebugging": true + } + } +} \ No newline at end of file diff --git a/tracer/test/test-applications/integrations/LogsInjection.NLog20.VersionConflict.2x/LogsInjection.NLog20.VersionConflict.2x.csproj b/tracer/test/test-applications/integrations/LogsInjection.NLog20.VersionConflict.2x/LogsInjection.NLog20.VersionConflict.2x.csproj new file mode 100644 index 000000000..f17ab687a --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.NLog20.VersionConflict.2x/LogsInjection.NLog20.VersionConflict.2x.csproj @@ -0,0 +1,23 @@ + + + + + net461 + + + + + + + + + + + + + + Always + + + + diff --git a/tracer/test/test-applications/integrations/LogsInjection.NLog20.VersionConflict.2x/NLog.Pre40.config b/tracer/test/test-applications/integrations/LogsInjection.NLog20.VersionConflict.2x/NLog.Pre40.config new file mode 100644 index 000000000..92ae66afd --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.NLog20.VersionConflict.2x/NLog.Pre40.config @@ -0,0 +1,13 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/tracer/test/test-applications/integrations/LogsInjection.NLog20.VersionConflict.2x/Program.cs b/tracer/test/test-applications/integrations/LogsInjection.NLog20.VersionConflict.2x/Program.cs new file mode 100644 index 000000000..df5f2b085 --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.NLog20.VersionConflict.2x/Program.cs @@ -0,0 +1,24 @@ +using System.IO; +using LogsInjectionHelper.VersionConflict; +using NLog; +using NLog.Config; + +namespace LogsInjection.NLog20.VersionConflict_2x +{ + public class Program + { + public static int Main(string[] args) + { + var appDirectory = Directory.GetParent(typeof(Program).Assembly.Location).FullName; + var textFilePath = Path.Combine(appDirectory, "log-textFile.log"); + + File.Delete(textFilePath); + + // Initialize NLog + LogManager.Configuration = new XmlLoggingConfiguration(Path.Combine(appDirectory, "NLog.Pre40.config")); + Logger logger = LogManager.GetCurrentClassLogger(); + + return LoggingMethods.RunLoggingProcedure(logger.Info); + } + } +} diff --git a/tracer/test/test-applications/integrations/LogsInjection.NLog20.VersionConflict.2x/Properties/launchSettings.json b/tracer/test/test-applications/integrations/LogsInjection.NLog20.VersionConflict.2x/Properties/launchSettings.json new file mode 100644 index 000000000..7e495a412 --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.NLog20.VersionConflict.2x/Properties/launchSettings.json @@ -0,0 +1,22 @@ +{ + "profiles": { + "LogsInjection.NLog20.VersionConflict.2x": { + "commandName": "Project", + "environmentVariables": { + "COR_ENABLE_PROFILING": "1", + "COR_PROFILER": "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}", + "COR_PROFILER_PATH": "$(SolutionDir)tracer\\bin\\tracer-home\\win-$(Platform)\\Datadog.Trace.ClrProfiler.Native.dll", + + "CORECLR_ENABLE_PROFILING": "1", + "CORECLR_PROFILER": "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}", + "CORECLR_PROFILER_PATH": "$(SolutionDir)tracer\\bin\\tracer-home\\win-$(Platform)\\Datadog.Trace.ClrProfiler.Native.dll", + + "SIGNALFX_DOTNET_TRACER_HOME": "$(SolutionDir)tracer\\bin\\tracer-home", + "SIGNALFX_VERSION": "1.0.0", + + "SIGNALFX_LOGS_INJECTION": "true" + }, + "nativeDebugging": true + } + } +} \ No newline at end of file diff --git a/tracer/test/test-applications/integrations/LogsInjection.Serilog.VersionConflict.2x/LogsInjection.Serilog.VersionConflict.2x.csproj b/tracer/test/test-applications/integrations/LogsInjection.Serilog.VersionConflict.2x/LogsInjection.Serilog.VersionConflict.2x.csproj new file mode 100644 index 000000000..040e07aac --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.Serilog.VersionConflict.2x/LogsInjection.Serilog.VersionConflict.2x.csproj @@ -0,0 +1,18 @@ + + + + + net461;netcoreapp3.0;netcoreapp3.1;net5.0;net6.0 + netcoreapp3.0;netcoreapp3.1;net5.0;net6.0 + + + + + + + + + + + + diff --git a/tracer/test/test-applications/integrations/LogsInjection.Serilog.VersionConflict.2x/Program.cs b/tracer/test/test-applications/integrations/LogsInjection.Serilog.VersionConflict.2x/Program.cs new file mode 100644 index 000000000..aa194c20c --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.Serilog.VersionConflict.2x/Program.cs @@ -0,0 +1,36 @@ + +using System.IO; +using LogsInjectionHelper.VersionConflict; +using Serilog; +using Serilog.Formatting.Json; +using LogEventLevel = Serilog.Events.LogEventLevel; + +namespace LogsInjection.Serilog.VersionConflict_2x +{ + public class Program + { + public static int Main(string[] args) + { + // Initialize Serilog + var appDirectory = Directory.GetParent(typeof(Program).Assembly.Location).FullName; + var textFilePath = Path.Combine(appDirectory, "log-textFile.log"); + var jsonFilePath = Path.Combine(appDirectory, "log-jsonFile.log"); + + File.Delete(textFilePath); + File.Delete(jsonFilePath); + + var log = new LoggerConfiguration() + .Enrich.FromLogContext() + .MinimumLevel.Is(LogEventLevel.Information) + .WriteTo.File( + textFilePath, + outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {{ dd_service: \"{dd_service}\", dd_version: \"{dd_version}\", dd_env: \"{dd_env}\", dd_trace_id: \"{dd_trace_id}\", dd_span_id: \"{dd_span_id}\" }} {Message:lj} {NewLine}{Exception}") + .WriteTo.File( + new JsonFormatter(), + jsonFilePath) + .CreateLogger(); + + return LoggingMethods.RunLoggingProcedure(log.Information); + } + } +} diff --git a/tracer/test/test-applications/integrations/LogsInjection.Serilog.VersionConflict.2x/Properties/launchSettings.json b/tracer/test/test-applications/integrations/LogsInjection.Serilog.VersionConflict.2x/Properties/launchSettings.json new file mode 100644 index 000000000..1b91701ed --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.Serilog.VersionConflict.2x/Properties/launchSettings.json @@ -0,0 +1,22 @@ +{ + "profiles": { + "LogsInjection.Serilog.VersionConflict.2x": { + "commandName": "Project", + "environmentVariables": { + "COR_ENABLE_PROFILING": "1", + "COR_PROFILER": "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}", + "COR_PROFILER_PATH": "$(SolutionDir)tracer\\bin\\tracer-home\\win-$(Platform)\\Datadog.Trace.ClrProfiler.Native.dll", + + "CORECLR_ENABLE_PROFILING": "1", + "CORECLR_PROFILER": "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}", + "CORECLR_PROFILER_PATH": "$(SolutionDir)tracer\\bin\\tracer-home\\win-$(Platform)\\Datadog.Trace.ClrProfiler.Native.dll", + + "SIGNALFX_DOTNET_TRACER_HOME": "$(SolutionDir)tracer\\bin\\tracer-home", + "SIGNALFX_VERSION": "1.0.0", + + "SIGNALFX_LOGS_INJECTION": "true" + }, + "nativeDebugging": true + } + } +} \ No newline at end of file diff --git a/tracer/test/test-applications/integrations/LogsInjection.Serilog/LogsInjection.Serilog.csproj b/tracer/test/test-applications/integrations/LogsInjection.Serilog/LogsInjection.Serilog.csproj index a7bc1a8ab..382c54335 100644 --- a/tracer/test/test-applications/integrations/LogsInjection.Serilog/LogsInjection.Serilog.csproj +++ b/tracer/test/test-applications/integrations/LogsInjection.Serilog/LogsInjection.Serilog.csproj @@ -1,7 +1,7 @@  - 1.5.14 + 1.4.16 2.0.0 $(DefineConstants);SERILOG_2_0 $(DefineConstants);SERILOG_LOG_OPTIN_CROSS_APPDOMAIN diff --git a/tracer/test/test-applications/integrations/LogsInjection.Serilog/Properties/launchSettings.json b/tracer/test/test-applications/integrations/LogsInjection.Serilog/Properties/launchSettings.json index 1d0379dcf..47ce0d034 100644 --- a/tracer/test/test-applications/integrations/LogsInjection.Serilog/Properties/launchSettings.json +++ b/tracer/test/test-applications/integrations/LogsInjection.Serilog/Properties/launchSettings.json @@ -3,7 +3,17 @@ "LogsInjection.Serilog": { "commandName": "Project", "environmentVariables": { - "SIGNALFX_LOGS_INJECTION": "true" + "SIGNALFX_LOGS_INJECTION": "true", + "COR_ENABLE_PROFILING": "1", + "COR_PROFILER": "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}", + "COR_PROFILER_PATH": "$(SolutionDir)tracer\\bin\\tracer-home\\win-$(Platform)\\SignalFx.Trace.ClrProfiler.Native.dll", + + "CORECLR_ENABLE_PROFILING": "1", + "CORECLR_PROFILER": "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}", + "CORECLR_PROFILER_PATH": "$(SolutionDir)tracer\\bin\\tracer-home\\win-$(Platform)\\SignalFx.Trace.ClrProfiler.Native.dll", + + "SIGNALFX_DOTNET_TRACER_HOME": "$(SolutionDir)tracer\\bin\\tracer-home", + "SIGNALFX_VERSION": "1.0.0" } } } diff --git a/tracer/test/test-applications/integrations/LogsInjection.Serilog14.VersionConflict.2x/LogsInjection.Serilog14.VersionConflict.2x.csproj b/tracer/test/test-applications/integrations/LogsInjection.Serilog14.VersionConflict.2x/LogsInjection.Serilog14.VersionConflict.2x.csproj new file mode 100644 index 000000000..5ffc7e625 --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.Serilog14.VersionConflict.2x/LogsInjection.Serilog14.VersionConflict.2x.csproj @@ -0,0 +1,17 @@ + + + + + net461 + + + + + + + + + + + + diff --git a/tracer/test/test-applications/integrations/LogsInjection.Serilog14.VersionConflict.2x/Program.cs b/tracer/test/test-applications/integrations/LogsInjection.Serilog14.VersionConflict.2x/Program.cs new file mode 100644 index 000000000..70ea3ad40 --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.Serilog14.VersionConflict.2x/Program.cs @@ -0,0 +1,38 @@ + +using System; +using System.IO; +using LogsInjectionHelper.VersionConflict; +using Serilog; +using LogEventLevel = Serilog.Events.LogEventLevel; + +namespace LogsInjection.Serilog14.VersionConflict_2x +{ + public class Program + { + public static int Main(string[] args) + { + // Initialize Serilog + var appDirectory = Directory.GetParent(typeof(Program).Assembly.Location).FullName; + var textFilePath = Path.Combine(appDirectory, "log-textFile.log"); + var jsonFilePath = Path.Combine(appDirectory, "log-jsonFile.log"); + + File.Delete(textFilePath); + File.Delete(jsonFilePath); + + var log = new LoggerConfiguration() + .Enrich.FromLogContext() + .MinimumLevel.Is(LogEventLevel.Information) + .WriteTo.File( + textFilePath, + outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {{ dd_service: \"{dd_service}\", dd_version: \"{dd_version}\", dd_env: \"{dd_env}\", dd_trace_id: \"{dd_trace_id}\", dd_span_id: \"{dd_span_id}\" }} {Message:lj} {NewLine}{Exception}") + .CreateLogger(); + + return LoggingMethods.RunLoggingProcedure(LogWrapper(log)); + } + + public static Action LogWrapper(ILogger log) + { + return (string message) => log.Information(message); + } + } +} diff --git a/tracer/test/test-applications/integrations/LogsInjection.Serilog14.VersionConflict.2x/Properties/launchSettings.json b/tracer/test/test-applications/integrations/LogsInjection.Serilog14.VersionConflict.2x/Properties/launchSettings.json new file mode 100644 index 000000000..1042eae43 --- /dev/null +++ b/tracer/test/test-applications/integrations/LogsInjection.Serilog14.VersionConflict.2x/Properties/launchSettings.json @@ -0,0 +1,22 @@ +{ + "profiles": { + "LogsInjection.Serilog14.VersionConflict.2x": { + "commandName": "Project", + "environmentVariables": { + "COR_ENABLE_PROFILING": "1", + "COR_PROFILER": "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}", + "COR_PROFILER_PATH": "$(SolutionDir)tracer\\bin\\tracer-home\\win-$(Platform)\\Datadog.Trace.ClrProfiler.Native.dll", + + "CORECLR_ENABLE_PROFILING": "1", + "CORECLR_PROFILER": "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}", + "CORECLR_PROFILER_PATH": "$(SolutionDir)tracer\\bin\\tracer-home\\win-$(Platform)\\Datadog.Trace.ClrProfiler.Native.dll", + + "SIGNALFX_DOTNET_TRACER_HOME": "$(SolutionDir)tracer\\bin\\tracer-home", + "SIGNALFX_VERSION": "1.0.0", + + "SIGNALFX_LOGS_INJECTION": "true" + }, + "nativeDebugging": true + } + } +} \ No newline at end of file diff --git a/tracer/test/test-applications/integrations/Samples.MSTestTests/Samples.MSTestTests.csproj b/tracer/test/test-applications/integrations/Samples.MSTestTests/Samples.MSTestTests.csproj index 098b9f060..fc3a76d78 100644 --- a/tracer/test/test-applications/integrations/Samples.MSTestTests/Samples.MSTestTests.csproj +++ b/tracer/test/test-applications/integrations/Samples.MSTestTests/Samples.MSTestTests.csproj @@ -3,7 +3,7 @@ false Library - 2.0.0 + 2.2.8 false @@ -18,3 +18,4 @@ + \ No newline at end of file diff --git a/tracer/test/test-applications/integrations/Samples.MSTestTests/TestSuite.cs b/tracer/test/test-applications/integrations/Samples.MSTestTests/TestSuite.cs index f87e06dac..428ff20ab 100644 --- a/tracer/test/test-applications/integrations/Samples.MSTestTests/TestSuite.cs +++ b/tracer/test/test-applications/integrations/Samples.MSTestTests/TestSuite.cs @@ -19,7 +19,7 @@ public static void AssemblyInit(TestContext context) } context.WriteLine(string.Empty); } - + [TestMethod] public void SimplePassTest() { diff --git a/tracer/test/test-applications/integrations/Samples.MongoDB/Program.cs b/tracer/test/test-applications/integrations/Samples.MongoDB/Program.cs index c55bfd80a..8a6543d5a 100644 --- a/tracer/test/test-applications/integrations/Samples.MongoDB/Program.cs +++ b/tracer/test/test-applications/integrations/Samples.MongoDB/Program.cs @@ -38,7 +38,7 @@ public static void Main(string[] args) }; - using (var mainScope = Tracer.Instance.StartActive("Main()", serviceName: "Samples.MongoDB")) + using (var mainScope = Tracer.Instance.StartActive("Main()")) { var connectionString = $"mongodb://{Host()}:27017"; var client = new MongoClient(connectionString); @@ -59,7 +59,7 @@ public static void Run(IMongoCollection collection, BsonDocument n { var allFilter = new BsonDocument(); - using (var syncScope = Tracer.Instance.StartActive("sync-calls", serviceName: "Samples.MongoDB")) + using (var syncScope = Tracer.Instance.StartActive("sync-calls")) { #if MONGODB_2_2 collection.DeleteMany(allFilter); @@ -100,7 +100,7 @@ public static async Task RunAsync(IMongoCollection collection, Bso { var allFilter = new BsonDocument(); - using (var asyncScope = Tracer.Instance.StartActive("async-calls", serviceName: "Samples.MongoDB")) + using (var asyncScope = Tracer.Instance.StartActive("async-calls")) { await collection.DeleteManyAsync(allFilter); await collection.InsertOneAsync(newDocument); @@ -122,14 +122,14 @@ public static async Task RunAsync(IMongoCollection collection, Bso public static void WireProtocolExecuteIntegrationTest(MongoClient client) { - using (var syncScope = Tracer.Instance.StartActive("sync-calls-execute", serviceName: "Samples.MongoDB")) + using (var syncScope = Tracer.Instance.StartActive("sync-calls-execute")) { var server = client.Cluster.SelectServer(new ServerSelector(), CancellationToken.None); var channel = server.GetChannel(CancellationToken.None); channel.KillCursors(new long[] { 0, 1, 2 }, new global::MongoDB.Driver.Core.WireProtocol.Messages.Encoders.MessageEncoderSettings(), CancellationToken.None); } - using (var asyncScope = Tracer.Instance.StartActive("async-calls-execute", serviceName: "Samples.MongoDB")) + using (var asyncScope = Tracer.Instance.StartActive("async-calls-execute")) { var server = client.Cluster.SelectServer(new ServerSelector(), CancellationToken.None); var channel = server.GetChannel(CancellationToken.None); diff --git a/tracer/test/test-applications/integrations/Samples.RabbitMQ/Program.cs b/tracer/test/test-applications/integrations/Samples.RabbitMQ/Program.cs index c10c000d3..62bf4e8ea 100644 --- a/tracer/test/test-applications/integrations/Samples.RabbitMQ/Program.cs +++ b/tracer/test/test-applications/integrations/Samples.RabbitMQ/Program.cs @@ -191,7 +191,7 @@ private static void Receive() var consumer = new EventingBasicConsumer(channel); consumer.Received += (model, ea) => { - using (Tracer.Instance.StartActive("consumer.Received event", serviceName: "Samples.RabbitMQ")) + using (Tracer.Instance.StartActive("consumer.Received event")) { #if RABBITMQ_6_0 var body = ea.Body.ToArray(); diff --git a/tracer/test/test-applications/integrations/Samples.RateLimiter/Program.cs b/tracer/test/test-applications/integrations/Samples.RateLimiter/Program.cs index e9a1914cb..fea6a7f6a 100644 --- a/tracer/test/test-applications/integrations/Samples.RateLimiter/Program.cs +++ b/tracer/test/test-applications/integrations/Samples.RateLimiter/Program.cs @@ -20,11 +20,15 @@ private static void Main() { var numberOfSeconds = 5; var maxMilliseconds = numberOfSeconds * 1000; - var configuredLimitPerSecond = int.Parse(Environment.GetEnvironmentVariables()[ConfigurationKeys.MaxTracesSubmittedPerSecond].ToString()); + var configuredLimitPerSecond = int.Parse(Environment.GetEnvironmentVariables()["SIGNALFX_MAX_TRACES_PER_SECOND"].ToString()); Console.WriteLine($"Ready to run for {numberOfSeconds} seconds."); Console.WriteLine($"Configured rate limit of {configuredLimitPerSecond}"); + var settings = TracerSettings.FromDefaultSources(); + settings.ServiceName = ServiceDogWalker; + Tracer.Configure(settings); + PrepKeys(ServiceDogWalker, RootWalkOperation, configuredLimitPerSecond * numberOfSeconds); var timer = new Stopwatch(); @@ -66,13 +70,13 @@ private static void RunStuff(string serviceName, string operationName) Counts[Key(serviceName, operationName)]++; - Scope root; + IScope root; - using (root = Tracer.Instance.StartActive(operationName: operationName, serviceName: serviceName)) + using (root = Tracer.Instance.StartActive(operationName: operationName)) { Thread.Sleep(3); - using (var sub = Tracer.Instance.StartActive(operationName: "sub", serviceName: serviceName)) + using (var sub = Tracer.Instance.StartActive(operationName: "sub")) { Thread.Sleep(2); } @@ -104,11 +108,11 @@ private static string Key(string service, string operation, double? priority = n return $"{service}_{operation}_{priority}"; } - private static ConcurrentDictionary GetMetrics(Scope root) + private static ConcurrentDictionary GetMetrics(IScope root) { ConcurrentDictionary metrics = null; - foreach (var property in typeof(Span) + foreach (var property in root.Span.GetType() .GetProperties( BindingFlags.Instance | BindingFlags.NonPublic)) diff --git a/tracer/test/test-applications/integrations/Samples.TracingWithoutLimits/Program.cs b/tracer/test/test-applications/integrations/Samples.TracingWithoutLimits/Program.cs index 2615c0337..318f08982 100644 --- a/tracer/test/test-applications/integrations/Samples.TracingWithoutLimits/Program.cs +++ b/tracer/test/test-applications/integrations/Samples.TracingWithoutLimits/Program.cs @@ -4,6 +4,7 @@ using System.Reflection; using System.Threading; using Datadog.Trace; +using Datadog.Trace.Configuration; namespace Samples.TracingWithoutLimits { @@ -102,24 +103,28 @@ private static string ConsoleTime() private static void RunStuff(string serviceName, string operationName) { + var settings = TracerSettings.FromDefaultSources(); + settings.ServiceName = serviceName; + Tracer.Configure(settings); + Counts[Key(serviceName, operationName)]++; - Scope root; + IScope root; - using (root = Tracer.Instance.StartActive(operationName: operationName, serviceName: serviceName)) + using (root = Tracer.Instance.StartActive(operationName: operationName)) { Thread.Sleep(3); - using (var sub = Tracer.Instance.StartActive(operationName: SubOperation, serviceName: serviceName)) + using (var sub = Tracer.Instance.StartActive(operationName: SubOperation)) { Thread.Sleep(2); - using (var open = Tracer.Instance.StartActive(operationName: OpenOperation, serviceName: serviceName)) + using (var open = Tracer.Instance.StartActive(operationName: OpenOperation)) { Thread.Sleep(2); } - using (var close = Tracer.Instance.StartActive(operationName: CloseOperation, serviceName: serviceName)) + using (var close = Tracer.Instance.StartActive(operationName: CloseOperation)) { Thread.Sleep(1); } @@ -166,11 +171,11 @@ private static string Key(string service, string operation, double? priority = n return $"{service}_{operation}_{priority}"; } - private static ConcurrentDictionary GetMetrics(Scope root) + private static ConcurrentDictionary GetMetrics(IScope root) { ConcurrentDictionary metrics = null; - foreach (var property in typeof(Span) + foreach (var property in root.Span.GetType() .GetProperties( BindingFlags.Instance | BindingFlags.NonPublic)) diff --git a/tracer/test/test-applications/integrations/Samples.VersionConflict.1x/Program.cs b/tracer/test/test-applications/integrations/Samples.VersionConflict.1x/Program.cs new file mode 100644 index 000000000..9361e3603 --- /dev/null +++ b/tracer/test/test-applications/integrations/Samples.VersionConflict.1x/Program.cs @@ -0,0 +1,35 @@ +using System; +using System.Net.Http; +using System.Threading.Tasks; +using Datadog.Trace; + +namespace Samples.VersionConflict_1x +{ + class Program + { + static async Task Main() + { + using (WebServer.Start(out var url)) + { + // Attempt to access the ActiveScope while the automatic ActiveScope is null + var activeScope = Tracer.Instance.ActiveScope; + if (activeScope is null) + { + Console.WriteLine("As expected, initial Tracer.Instance.ActiveScope == null"); + } + + using (var scope = Tracer.Instance.StartActive("Manual")) + { + scope.Span.SetTag(Tags.SamplingPriority, "UserKeep"); + + using (var client = new HttpClient()) + { + _ = await client.GetStringAsync(url); + + scope.Span.SetTag(Tags.SamplingPriority, "UserReject"); + } + } + } + } + } +} diff --git a/tracer/test/test-applications/integrations/Samples.VersionConflict.1x/Properties/launchSettings.json b/tracer/test/test-applications/integrations/Samples.VersionConflict.1x/Properties/launchSettings.json new file mode 100644 index 000000000..d3aff7773 --- /dev/null +++ b/tracer/test/test-applications/integrations/Samples.VersionConflict.1x/Properties/launchSettings.json @@ -0,0 +1,20 @@ +{ + "profiles": { + "Samples.VersionConflict.1x": { + "commandName": "Project", + "environmentVariables": { + "COR_ENABLE_PROFILING": "1", + "COR_PROFILER": "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}", + "COR_PROFILER_PATH": "$(SolutionDir)tracer\\bin\\tracer-home\\win-$(Platform)\\Datadog.Trace.ClrProfiler.Native.dll", + + "CORECLR_ENABLE_PROFILING": "1", + "CORECLR_PROFILER": "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}", + "CORECLR_PROFILER_PATH": "$(SolutionDir)tracer\\bin\\tracer-home\\win-$(Platform)\\Datadog.Trace.ClrProfiler.Native.dll", + + "SIGNALFX_DOTNET_TRACER_HOME": "$(SolutionDir)tracer\\bin\\tracer-home", + "SIGNALFX_VERSION": "1.0.0" + }, + "nativeDebugging": true + } + } + } \ No newline at end of file diff --git a/tracer/test/test-applications/integrations/Samples.VersionConflict.1x/Samples.VersionConflict.1x.csproj b/tracer/test/test-applications/integrations/Samples.VersionConflict.1x/Samples.VersionConflict.1x.csproj new file mode 100644 index 000000000..31dec7fee --- /dev/null +++ b/tracer/test/test-applications/integrations/Samples.VersionConflict.1x/Samples.VersionConflict.1x.csproj @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tracer/test/test-applications/integrations/Samples.VersionConflict.2x/Program.cs b/tracer/test/test-applications/integrations/Samples.VersionConflict.2x/Program.cs new file mode 100644 index 000000000..8c91d5d48 --- /dev/null +++ b/tracer/test/test-applications/integrations/Samples.VersionConflict.2x/Program.cs @@ -0,0 +1,53 @@ +using System; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; +using Datadog.Trace; + +namespace Samples.VersionConflict_2x +{ + class Program + { + static async Task Main() + { + using var server = WebServer.Start(out var url); + + server.RequestHandler = context => + { + var traceId = context.Request.Headers[HttpHeaderNames.TraceId]; + var spanId = context.Request.Headers[HttpHeaderNames.ParentId]; + var samplingPriority = context.Request.Headers[HttpHeaderNames.SamplingPriority]; + + Console.WriteLine($"{traceId}/{spanId}/{samplingPriority}"); + + var payload = Encoding.UTF8.GetBytes("OK"); + + context.Response.ContentEncoding = Encoding.UTF8; + context.Response.ContentLength64 = payload.Length; + context.Response.OutputStream.Write(payload, 0, payload.Length); + context.Response.Close(); + }; + + // Attempt to access the ActiveScope while the automatic ActiveScope is null + var activeScope = Tracer.Instance.ActiveScope; + if (activeScope is not null) + { + throw new InvalidOperationException("Tracer.Instance.ActiveScope should be null"); + } + + using (var scope = Tracer.Instance.StartActive("Manual")) + { + scope.Span.SetTag(Tags.SamplingPriority, "UserKeep"); + + using (var client = new HttpClient()) + { + _ = await client.GetStringAsync(url + "/a"); + + scope.Span.SetTag(Tags.SamplingPriority, "UserReject"); + + _ = await client.GetStringAsync(url + "/b"); + } + } + } + } +} diff --git a/tracer/test/test-applications/integrations/Samples.VersionConflict.2x/Properties/launchSettings.json b/tracer/test/test-applications/integrations/Samples.VersionConflict.2x/Properties/launchSettings.json new file mode 100644 index 000000000..3cf491dda --- /dev/null +++ b/tracer/test/test-applications/integrations/Samples.VersionConflict.2x/Properties/launchSettings.json @@ -0,0 +1,20 @@ +{ + "profiles": { + "Samples.VersionConflict.2x": { + "commandName": "Project", + "environmentVariables": { + "COR_ENABLE_PROFILING": "1", + "COR_PROFILER": "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}", + "COR_PROFILER_PATH": "$(SolutionDir)tracer\\bin\\tracer-home\\win-$(Platform)\\Datadog.Trace.ClrProfiler.Native.dll", + + "CORECLR_ENABLE_PROFILING": "1", + "CORECLR_PROFILER": "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}", + "CORECLR_PROFILER_PATH": "$(SolutionDir)tracer\\bin\\tracer-home\\win-$(Platform)\\Datadog.Trace.ClrProfiler.Native.dll", + + "SIGNALFX_DOTNET_TRACER_HOME": "$(SolutionDir)tracer\\bin\\tracer-home", + "SIGNALFX_VERSION": "1.0.0" + }, + "nativeDebugging": true + } + } + } \ No newline at end of file diff --git a/tracer/test/test-applications/integrations/Samples.VersionConflict.2x/Samples.VersionConflict.2x.csproj b/tracer/test/test-applications/integrations/Samples.VersionConflict.2x/Samples.VersionConflict.2x.csproj new file mode 100644 index 000000000..a0987a600 --- /dev/null +++ b/tracer/test/test-applications/integrations/Samples.VersionConflict.2x/Samples.VersionConflict.2x.csproj @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tracer/test/test-applications/integrations/dependency-libs/LogsInjectionHelper.VersionConflict/LoggingMethods.cs b/tracer/test/test-applications/integrations/dependency-libs/LogsInjectionHelper.VersionConflict/LoggingMethods.cs new file mode 100644 index 000000000..2dc0467b0 --- /dev/null +++ b/tracer/test/test-applications/integrations/dependency-libs/LogsInjectionHelper.VersionConflict/LoggingMethods.cs @@ -0,0 +1,90 @@ +using System; +using Datadog.Trace; + +namespace LogsInjectionHelper.VersionConflict +{ + public static class LoggingMethods + { + /// + /// Prepend a string to log lines that should not be validated for logs injection. + /// In other words, they're not written within a Datadog scope + /// + private static readonly string ExcludeMessagePrefix = "[ExcludeMessage]"; + + public static int RunLoggingProcedure(Action logAction) + { + try + { + logAction($"{ExcludeMessagePrefix}Starting manual1 Datadog scope."); + using (Tracer.Instance.StartActive("manual1")) + { + logAction($"Trace: manual1"); + using (TracerUtils.StartAutomaticTraceHigherAssemblyVersion("automatic2")) + { + logAction($"Trace: manual1-automatic2"); + using (Tracer.Instance.StartActive("manual3")) + { + logAction($"Trace: manual1-automatic2-manual3"); + using (Tracer.Instance.StartActive("manual4")) + { + logAction($"Trace: manual1-automatic2-manual3-manual4"); + + using (TracerUtils.StartAutomaticTraceHigherAssemblyVersion("automatic5")) + { + logAction($"Trace: manual1-automatic2-manual3-manual4-automatic5"); + } + + logAction($"Trace: manual1-automatic2-manual3-manual4"); + } + + logAction($"Trace: manual1-automatic2-manual3"); + + using (TracerUtils.StartAutomaticTraceHigherAssemblyVersion("automatic4")) + { + logAction($"Trace: manual1-automatic2-manual3-automatic4"); + using (TracerUtils.StartAutomaticTraceHigherAssemblyVersion("automatic5")) + { + logAction($"Trace: manual1-automatic2-manual3-automatic4-automatic5"); + using (Tracer.Instance.StartActive("manual6")) + { + logAction($"Trace: manual1-automatic2-manual3-automatic4-automatic5-manual6"); + } + + logAction($"Trace: manual1-automatic2-manual3-automatic4-automatic5"); + } + + logAction($"Trace: manual1-automatic2-manual3-automatic4"); + } + + logAction($"Trace: manual1-automatic2-manual3"); + } + logAction($"Trace: manual1-automatic2"); + } + + logAction($"Trace: manual1"); + } + + logAction($"{ExcludeMessagePrefix}Exited manual1 Datadog scope."); + } + catch (Exception ex) + { + Console.Error.WriteLine(ex); + return (int)ExitCode.UnknownError; + } + +#if NETCOREAPP2_1 + // Add a delay to avoid a race condition on shutdown: https://github.com/dotnet/coreclr/pull/22712 + // This would cause a segmentation fault on .net core 2.x + System.Threading.Thread.Sleep(5000); +#endif + + return (int)ExitCode.Success; + } + + enum ExitCode : int + { + Success = 0, + UnknownError = -10 + } + } +} diff --git a/tracer/test/test-applications/integrations/dependency-libs/LogsInjectionHelper.VersionConflict/LogsInjectionHelper.VersionConflict.csproj b/tracer/test/test-applications/integrations/dependency-libs/LogsInjectionHelper.VersionConflict/LogsInjectionHelper.VersionConflict.csproj new file mode 100644 index 000000000..deff166db --- /dev/null +++ b/tracer/test/test-applications/integrations/dependency-libs/LogsInjectionHelper.VersionConflict/LogsInjectionHelper.VersionConflict.csproj @@ -0,0 +1,12 @@ + + + + net461;netcoreapp2.1;netcoreapp3.0 + latest + + + + + + + diff --git a/tracer/test/test-applications/integrations/dependency-libs/LogsInjectionHelper.VersionConflict/TracerUtils.cs b/tracer/test/test-applications/integrations/dependency-libs/LogsInjectionHelper.VersionConflict/TracerUtils.cs new file mode 100644 index 000000000..503758133 --- /dev/null +++ b/tracer/test/test-applications/integrations/dependency-libs/LogsInjectionHelper.VersionConflict/TracerUtils.cs @@ -0,0 +1,68 @@ +using System; +using System.Linq; +using System.Reflection; +using Datadog.Trace; + +namespace LogsInjectionHelper.VersionConflict +{ + public class TracerUtils + { + private static readonly Version _manualTracingVersion = typeof(Tracer).Assembly.GetName().Version; + private static Assembly _automaticAssembly; + + private static bool VersionIsLowerThanManualTracingVersion(Version version) + { +#if NETFRAMEWORK + return version < _manualTracingVersion; +#else + return version == _manualTracingVersion; +#endif + } + + private static bool VersionIsHigherThanManualTracingVersion(Version version) + { + return version > _manualTracingVersion; + } + + + public static IDisposable StartAutomaticTraceLowerAssemblyVersion(string operationName) + { + return StartAutomaticTrace(operationName, VersionIsLowerThanManualTracingVersion); + } + + public static IDisposable StartAutomaticTraceHigherAssemblyVersion(string operationName) + { + return StartAutomaticTrace(operationName, VersionIsHigherThanManualTracingVersion); + } + + private static IDisposable StartAutomaticTrace(string operationName, Func versionComparisonFunc) + { + if (_automaticAssembly is null) + { + // Get the Datadog.Trace.Tracer type from the automatic instrumentation assembly +#if NETFRAMEWORK + _automaticAssembly = System.AppDomain.CurrentDomain.GetAssemblies().Single(asm => asm.GetName().Name.Equals("Datadog.Trace") && versionComparisonFunc(asm.GetName().Version)); +#elif !NETCOREAPP2_1 + foreach (var alc in System.Runtime.Loader.AssemblyLoadContext.All) + { + _automaticAssembly = alc.Assemblies.SingleOrDefault(asm => asm.GetName().Name.Equals("Datadog.Trace") && versionComparisonFunc(asm.GetName().Version)); + if (_automaticAssembly != null) + { + break; + } + } +#endif + } + + Type tracerType = _automaticAssembly.GetType("Datadog.Trace.Tracer"); + + // Invoke 'Tracer.Instance' + var instanceGetMethod = tracerType.GetProperty("Instance", BindingFlags.Static | BindingFlags.Public).GetGetMethod(); + object instance = instanceGetMethod.Invoke(null, new object[] {}); + + // Invoke 'public Scope StartActive(string operationName, ISpanContext parent = null, string serviceName = null, DateTimeOffset? startTime = null, bool ignoreActiveScope = false, bool finishOnClose = true)' + var startActive = tracerType.GetMethod("StartActive", new Type[] { typeof(string) }); + return (IDisposable)startActive.Invoke(instance, new[] { operationName }); + } + } +} diff --git a/tracer/test/test-applications/integrations/dependency-libs/LogsInjectionHelper/LoggingMethods.cs b/tracer/test/test-applications/integrations/dependency-libs/LogsInjectionHelper/LoggingMethods.cs index 2054fe2ef..42a224c72 100644 --- a/tracer/test/test-applications/integrations/dependency-libs/LogsInjectionHelper/LoggingMethods.cs +++ b/tracer/test/test-applications/integrations/dependency-libs/LogsInjectionHelper/LoggingMethods.cs @@ -55,7 +55,6 @@ public static int RunLoggingProcedure(Action logAction) #if NETFRAMEWORK logAction("Calling the PluginApplication.Program in a separate AppDomain"); AppDomainProxy.Call(applicationAppDomain, "PluginApplication", "PluginApplication.Program", "Invoke", null); - logAction("Returned from the PluginApplication.Program call"); #else logAction("Skipping the cross-AppDomain call on .NET Core"); #endif diff --git a/tracer/test/test-applications/regression/TraceContext.InvalidOperationException/InMemoryLog4NetLogger.cs b/tracer/test/test-applications/regression/TraceContext.InvalidOperationException/InMemoryLog4NetLogger.cs deleted file mode 100644 index ee8881bce..000000000 --- a/tracer/test/test-applications/regression/TraceContext.InvalidOperationException/InMemoryLog4NetLogger.cs +++ /dev/null @@ -1,29 +0,0 @@ -using log4net; -using log4net.Appender; -using log4net.Core; -using log4net.Layout; -using log4net.Repository.Hierarchy; - -namespace TraceContext.InvalidOperationException -{ - public class InMemoryLog4NetLogger - { - public static MemoryAppender InMemoryAppender; - - public static void Setup() - { - var hierarchy = (Hierarchy)LogManager.GetRepository(typeof(Logger).Assembly); - - var patternLayout = new PatternLayout(); - patternLayout.ConversionPattern = "%message"; - patternLayout.ActivateOptions(); - - InMemoryAppender = new MemoryAppender(); - InMemoryAppender.ActivateOptions(); - hierarchy.Root.AddAppender(InMemoryAppender); - - hierarchy.Root.Level = Level.Info; - hierarchy.Configured = true; - } - } -} diff --git a/tracer/test/test-applications/regression/TraceContext.InvalidOperationException/Program.cs b/tracer/test/test-applications/regression/TraceContext.InvalidOperationException/Program.cs deleted file mode 100644 index c90b98ffc..000000000 --- a/tracer/test/test-applications/regression/TraceContext.InvalidOperationException/Program.cs +++ /dev/null @@ -1,150 +0,0 @@ -using Datadog.Trace; -using Datadog.Trace.Configuration; -using log4net; -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Tracer = Datadog.Trace.Tracer; - -namespace TraceContext.InvalidOperationException -{ - class Program - { - internal static readonly string ThreadFinishedMessage = "The current thread has finished"; - - static int Main(string[] args) - { - try - { - InMemoryLog4NetLogger.Setup(); - var logger = LogManager.GetLogger(typeof(Program)); - - var ddTraceSettings = TracerSettings.FromDefaultSources(); - ddTraceSettings.LogsInjectionEnabled = true; - ddTraceSettings.TraceEnabled = true; - Tracer.Configure(ddTraceSettings); - var tracer = Tracer.Instance; - - var totalIterations = 400_000; - var threadRepresentation = Enumerable.Range(0, 5).ToArray(); - var threadCount = threadRepresentation.Length; - - // Two logs per thread iteration + 1 extra log at the end of each thread - var expectedLogCount = threadCount; - var exceptionBag = new ConcurrentBag(); - - Console.WriteLine($"Running {threadRepresentation.Length} threads with {totalIterations} iterations."); - - var threads = - threadRepresentation - .Select( - idx => new Thread( - thread => - { - try - { - Span firstSpan; - using (var outerScope = tracer.StartActive("outer-span")) - { - // Save the span so we can later re-use its TraceContext - firstSpan = outerScope.Span; - - // Initialize scopes/spans to aggressively open - var threadScopes = new Stack(); - var i = 0; - - while (i++ < totalIterations) - { - string spanString = $"inner-span-{i}"; - threadScopes.Push(tracer.StartActive(spanString)); - } - - i = 0; - while (threadScopes.Count > 0) - { - threadScopes.Pop().Dispose(); - } - } - - Thread.Sleep(500); - - // Now that the entire set of spans has been closed and queued - // to be written to the agent, re-open that same TraceContext - // Repeat the operation to trigger the exception - using (var outerScope = tracer.ActivateSpan(firstSpan)) - { - // Initialize scopes/spans to aggressively open - var threadScopes = new Stack(); - var i = 0; - - while (i++ < totalIterations) - { - string spanString = $"second inner-span-{i}"; - threadScopes.Push(tracer.StartActive(spanString)); - } - - i = 0; - while (threadScopes.Count > 0) - { - threadScopes.Pop().Dispose(); - } - } - - // Verify everything is cleaned up on this thread - logger.Info(ThreadFinishedMessage); - } - catch (Exception ex) - { - exceptionBag.Add(ex); - } - })) - .ToList(); - - foreach (var thread in threads) - { - thread.Start(); - } - - while (threads.Any(x => x.IsAlive)) - { - Thread.Sleep(1000); - } - - if (exceptionBag.Any()) - { - // No exceptions are acceptable - throw new AggregateException(exceptionBag.ToArray()); - } - - var loggingEvents = InMemoryLog4NetLogger.InMemoryAppender.GetEvents(); - var invalidOperationExceptionEvents = loggingEvents.Where(e => e.RenderedMessage.Contains("InvalidOperationException")); - int invalidOperationExceptionCount = invalidOperationExceptionEvents.Count(); - - Console.WriteLine($"Received {invalidOperationExceptionCount} log events containing 'InvalidOperationException'."); - - if (loggingEvents.Length != expectedLogCount && invalidOperationExceptionEvents.Count() > 0) - { - throw new Exception($"Expected log count: {expectedLogCount}, actual log count: {loggingEvents.Length}, logs containing 'InvalidOperationException': {invalidOperationExceptionCount}"); - } - - Console.WriteLine("All is well!"); - } - catch (Exception ex) - { - Console.Error.WriteLine(ex); - return (int)ExitCode.UnknownError; - } - - return (int)ExitCode.Success; - } - - enum ExitCode : int - { - Success = 0, - UnknownError = -10 - } - } -} diff --git a/tracer/test/test-applications/regression/TraceContext.InvalidOperationException/TraceContext.InvalidOperationException.csproj b/tracer/test/test-applications/regression/TraceContext.InvalidOperationException/TraceContext.InvalidOperationException.csproj deleted file mode 100644 index 083a4c824..000000000 --- a/tracer/test/test-applications/regression/TraceContext.InvalidOperationException/TraceContext.InvalidOperationException.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - -