PoC: minimizing the code: only calling the loader (#172)

* PoC: minimizing the code: only calling the loader

* Remove tests not being used

* Clean solution

* Remove some tools and fix solution

* Remove Az Pipelines

* Lean CI: remove Az and simplify GH workflows

* Fix env var on GH workflow for Windows

* Delete samples.sln and unused samples on the branch

* Remove extra solutions
This commit is contained in:
Paulo Janotti 2021-05-21 11:32:17 -07:00 committed by GitHub
parent a0425a0c41
commit 87959cc830
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2216 changed files with 18 additions and 324342 deletions

View File

@ -1,75 +0,0 @@
trigger:
branches:
include:
- main
- refs/tags/*
schedules:
- cron: "0 3 * * *"
displayName: Daily 3am (UTC) build
branches:
include:
- main
- benchmarks/*
always: true
variables:
buildConfiguration: release
publishOutput: $(Build.SourcesDirectory)/src/bin/managed-publish
stages:
- stage: build
jobs:
#### Windows
- job: Windows
pool: Benchmarks
workspace:
clean: all
variables:
tracerHomeName: windows-tracer-home
tracerHome: $(System.DefaultWorkingDirectory)/src/bin/$(tracerHomeName)
msiHome: $(System.DefaultWorkingDirectory)/src/bin/msi
nuget_packages: $(Pipeline.Workspace)/.nuget/packages
steps:
- task: UseDotNet@2
displayName: install dotnet core sdk
inputs:
packageType: sdk
version: 5.0.x
- task: NuGetToolInstaller@1
displayName: install nuget
- task: DotNetCoreCLI@2
displayName: dotnet restore
inputs:
command: restore
projects: src/**/*.csproj
# native projects must be restored with nuget.exe
- task: NuGetCommand@2
displayName: nuget restore native
inputs:
restoreSolution: Datadog.Trace.Native.sln
verbosityRestore: Normal
- task: DotNetCoreCLI@2
displayName: Benchmarks
inputs:
command: 'run'
projects: '$(System.DefaultWorkingDirectory)/test/benchmarks/Benchmarks.Trace/Benchmarks.Trace.csproj'
arguments: '-c Release -f netcoreapp3.1 -- -r net472 netcoreapp3.1 -m -f * --iterationTime 1500'
env:
OTEL_ENV: CI
OTEL_SERVICE: dd-trace-dotnet
- task: PowerShell@2
inputs:
targetType: 'inline'
script: 'Start-Sleep -s 120'

View File

@ -1,156 +0,0 @@
trigger:
branches:
include:
- main
paths:
exclude:
- docs/*
- .github/*
pr:
branches:
include:
- main
- release/*
paths:
exclude:
- docs/*
- .github/*
schedules:
- cron: "0 4 * * *"
displayName: Daily 4am (UTC) build
branches:
include:
- main
- benchmarks/*
always: true
jobs:
- job: windows_profiler
pool:
vmImage: windows-2019
steps:
- task: UseDotNet@2
displayName: install dotnet core runtime 3.1
inputs:
packageType: runtime
version: 3.1.x
- task: UseDotNet@2
displayName: install dotnet core sdk 5.0.103
inputs:
packageType: sdk
version: 5.0.103
- task: DotNetCoreCLI@2
displayName: dotnet build
inputs:
command: build
configuration: Release
arguments: /nowarn:netsdk1138
projects: |
src/Datadog.Trace.ClrProfiler.Managed.Loader/Datadog.Trace.ClrProfiler.Managed.Loader.csproj
sample-libs/**/Samples.ExampleLibrary*.csproj
- task: NuGetToolInstaller@1
displayName: install nuget
- task: NuGetCommand@2
displayName: nuget restore
inputs:
restoreSolution: Datadog.Trace.Native.sln
verbosityRestore: Normal
- task: MSBuild@1
displayName: msbuild
inputs:
solution: Datadog.Trace.proj
platform: x64
configuration: Release
msbuildArguments: /t:BuildCpp
maximumCpuCount: true
- publish: $(System.DefaultWorkingDirectory)/src/Datadog.Trace.ClrProfiler.Native/bin/Release/x64
artifact: windows-native
- job: linux_profiler
pool:
vmImage: ubuntu-20.04
steps:
- task: UseDotNet@2
displayName: install dotnet core runtime 3.1
inputs:
packageType: runtime
version: 3.1.x
- task: UseDotNet@2
displayName: install dotnet core sdk 5.0
inputs:
packageType: sdk
version: 5.0.x
- task: DotNetCoreCLI@2
displayName: dotnet build
inputs:
command: build
configuration: Release
arguments: /nowarn:netsdk1138
projects: |
src/Datadog.Trace.ClrProfiler.Managed.Loader/Datadog.Trace.ClrProfiler.Managed.Loader.csproj
- script: |
sudo apt-get update
sudo apt-get install -y llvm clang
sudo apt-get remove -y cmake
curl -L -o /tmp/cmake.sh https://github.com/Kitware/CMake/releases/download/v3.19.8/cmake-3.19.8-Linux-x86_64.sh
sudo sh /tmp/cmake.sh --prefix=/usr/local --exclude-subdir --skip-license
displayName: install_dependencies
- script: |
cd ./src/Datadog.Trace.ClrProfiler.Native
CXX=clang++ CC=clang cmake . -DCMAKE_BUILD_TYPE=Release
make
displayName: build_profiler
- publish: $(System.DefaultWorkingDirectory)/src/Datadog.Trace.ClrProfiler.Native/bin
artifact: linux-native
- job: crank
pool: Throughput
workspace:
clean: all
dependsOn:
- linux_profiler
- windows_profiler
condition: succeeded()
steps:
- download: current
artifact: linux-native
- task: CopyFiles@2
inputs:
sourceFolder: $(Pipeline.Workspace)/linux-native
targetFolder: $(System.DefaultWorkingDirectory)/
- download: current
artifact: windows-native
- task: CopyFiles@2
inputs:
sourceFolder: $(Pipeline.Workspace)/windows-native
targetFolder: $(System.DefaultWorkingDirectory)/
- script: |
cd ./build/crank
chmod +x ./run.sh
./run.sh
env:
OTEL_SERVICE: dd-trace-dotnet

View File

@ -1,495 +0,0 @@
trigger:
branches:
include:
- main
paths:
exclude:
- docs/*
- .github/*
pr:
branches:
include:
- main
- release/*
paths:
exclude:
- docs/*
- .github/*
pool:
vmImage: ubuntu-18.04
variables:
buildConfiguration: Release
publishOutput: $(System.DefaultWorkingDirectory)/src/bin/managed-publish
jobs:
- job: build_linux_profiler
steps:
- task: UseDotNet@2
displayName: install dotnet core runtime 3.1
inputs:
packageType: runtime
version: 3.1.x
- task: UseDotNet@2
displayName: install dotnet core sdk 5
inputs:
packageType: sdk
version: 5.0.x
- task: DotNetCoreCLI@2
displayName: dotnet build Datadog.Trace.ClrProfiler.Managed.Loader
inputs:
command: build
projects: src/Datadog.Trace.ClrProfiler.Managed.Loader/Datadog.Trace.ClrProfiler.Managed.Loader.csproj
arguments: --configuration $(buildConfiguration) /nowarn:netsdk1138
- task: DotNetCoreCLI@2
displayName: dotnet publish Datadog.Trace.ClrProfiler.Managed 2.0
inputs:
command: publish
publishWebProjects: false
modifyOutputPath: false
zipAfterPublish: false
projects: src/Datadog.Trace.ClrProfiler.Managed/Datadog.Trace.ClrProfiler.Managed.csproj
arguments: --configuration $(buildConfiguration) --framework netstandard2.0 --output $(publishOutput)/netstandard2.0
- task: DotNetCoreCLI@2
displayName: dotnet publish Datadog.Trace.ClrProfiler.Managed 3.1
inputs:
command: publish
publishWebProjects: false
modifyOutputPath: false
zipAfterPublish: false
projects: src/Datadog.Trace.ClrProfiler.Managed/Datadog.Trace.ClrProfiler.Managed.csproj
arguments: --configuration $(buildConfiguration) --framework netcoreapp3.1 --output $(publishOutput)/netcoreapp3.1
- task: DockerCompose@0
displayName: docker-compose run Profiler
inputs:
containerregistrytype: Container Registry
dockerComposeCommand: run -e buildConfiguration=$(buildConfiguration) Profiler
- publish: $(System.DefaultWorkingDirectory)/src/Datadog.Trace.ClrProfiler.Native/bin/$(buildConfiguration)/x64
artifact: linux-tracer-home
- job: Linux
dependsOn: build_linux_profiler
condition: succeeded()
strategy:
matrix:
netcoreapp2_1:
publishTargetFramework: netcoreapp2.1
netcoreapp3_0:
publishTargetFramework: netcoreapp3.0
netcoreapp3_1:
publishTargetFramework: netcoreapp3.1
net5_0:
publishTargetFramework: net5.0
variables:
TestAllPackageVersions: true
steps:
- download: current
artifact: linux-tracer-home
- task: CopyFiles@2
inputs:
sourceFolder: $(Pipeline.Workspace)/linux-tracer-home
targetFolder: $(System.DefaultWorkingDirectory)/src/Datadog.Trace.ClrProfiler.Native/bin/$(buildConfiguration)/x64
- task: DockerCompose@0
displayName: docker-compose run build
inputs:
containerregistrytype: Container Registry
dockerComposeCommand: run -e TestAllPackageVersions=true -e buildConfiguration=$(buildConfiguration) -e publishTargetFramework=$(publishTargetFramework) build
- task: DockerCompose@0
displayName: docker-compose run IntegrationTests
inputs:
containerregistrytype: Container Registry
dockerComposeCommand: run -e TestAllPackageVersions=true -e buildConfiguration=$(buildConfiguration) -e publishTargetFramework=$(publishTargetFramework) IntegrationTests
- publish: build_data
artifact: $(Agent.JobName)_profiler-logs-$(System.JobAttempt)
condition: succeededOrFailed()
- task: PublishTestResults@2
displayName: publish test results
inputs:
testResultsFormat: VSTest
testResultsFiles: test/**/*.trx
condition: succeededOrFailed()
- job: build_alpine_linux_profiler
steps:
- task: UseDotNet@2
displayName: install dotnet core runtime 3.1
inputs:
packageType: runtime
version: 3.1.x
- task: UseDotNet@2
displayName: install dotnet core sdk 5
inputs:
packageType: sdk
version: 5.0.x
- task: DotNetCoreCLI@2
displayName: dotnet build Datadog.Trace.ClrProfiler.Managed.Loader
inputs:
command: build
projects: src/Datadog.Trace.ClrProfiler.Managed.Loader/Datadog.Trace.ClrProfiler.Managed.Loader.csproj
arguments: --configuration $(buildConfiguration) /nowarn:netsdk1138
- task: DotNetCoreCLI@2
displayName: dotnet publish Datadog.Trace.ClrProfiler.Managed 2.0
inputs:
command: publish
publishWebProjects: false
modifyOutputPath: false
zipAfterPublish: false
projects: src/Datadog.Trace.ClrProfiler.Managed/Datadog.Trace.ClrProfiler.Managed.csproj
arguments: --configuration $(buildConfiguration) --framework netstandard2.0 --output $(publishOutput)/netstandard2.0
- task: DotNetCoreCLI@2
displayName: dotnet publish Datadog.Trace.ClrProfiler.Managed 3.1
inputs:
command: publish
publishWebProjects: false
modifyOutputPath: false
zipAfterPublish: false
projects: src/Datadog.Trace.ClrProfiler.Managed/Datadog.Trace.ClrProfiler.Managed.csproj
arguments: --configuration $(buildConfiguration) --framework netcoreapp3.1 --output $(publishOutput)/netcoreapp3.1
- task: DockerCompose@0
displayName: docker-compose run Profiler.Alpine
inputs:
containerregistrytype: Container Registry
dockerComposeCommand: run -e buildConfiguration=$(buildConfiguration) Profiler.Alpine
- publish: $(System.DefaultWorkingDirectory)/src/Datadog.Trace.ClrProfiler.Native/bin/$(buildConfiguration)/x64
artifact: alpine-linux-tracer-home
- job: Alpine_Linux
dependsOn: build_alpine_linux_profiler
condition: succeeded()
strategy:
matrix:
netcoreapp2_1:
publishTargetFramework: netcoreapp2.1
netcoreapp3_0:
publishTargetFramework: netcoreapp3.0
netcoreapp3_1:
publishTargetFramework: netcoreapp3.1
net5_0:
publishTargetFramework: net5.0
variables:
TestAllPackageVersions: true
steps:
- download: current
artifact: alpine-linux-tracer-home
- task: CopyFiles@2
inputs:
sourceFolder: $(Pipeline.Workspace)/alpine-linux-tracer-home
targetFolder: $(System.DefaultWorkingDirectory)/src/Datadog.Trace.ClrProfiler.Native/bin/$(buildConfiguration)/x64
- task: DockerCompose@0
displayName: docker-compose run build
inputs:
containerregistrytype: Container Registry
dockerComposeCommand: run -e TestAllPackageVersions=true -e buildConfiguration=$(buildConfiguration) -e publishTargetFramework=$(publishTargetFramework) build
- task: DockerCompose@0
displayName: docker-compose run IntegrationTests.Alpine.Core21
condition: eq(variables['publishTargetFramework'], 'netcoreapp2.1')
inputs:
containerregistrytype: Container Registry
dockerComposeCommand: run -e TestAllPackageVersions=true -e buildConfiguration=$(buildConfiguration) IntegrationTests.Alpine.Core21
- task: DockerCompose@0
displayName: docker-compose run IntegrationTests.Alpine.Core30
condition: eq(variables['publishTargetFramework'], 'netcoreapp3.0')
inputs:
containerregistrytype: Container Registry
dockerComposeCommand: run -e TestAllPackageVersions=true -e buildConfiguration=$(buildConfiguration) IntegrationTests.Alpine.Core30
- task: DockerCompose@0
displayName: docker-compose run IntegrationTests.Alpine.Core31
condition: eq(variables['publishTargetFramework'], 'netcoreapp3.1')
inputs:
containerregistrytype: Container Registry
dockerComposeCommand: run -e TestAllPackageVersions=true -e buildConfiguration=$(buildConfiguration) IntegrationTests.Alpine.Core31
- task: DockerCompose@0
displayName: docker-compose run IntegrationTests.Alpine.Core50
condition: eq(variables['publishTargetFramework'], 'net5.0')
inputs:
containerregistrytype: Container Registry
dockerComposeCommand: run -e TestAllPackageVersions=true -e buildConfiguration=$(buildConfiguration) IntegrationTests.Alpine.Core50
- publish: build_data
artifact: $(Agent.JobName)_profiler-logs-$(System.JobAttempt)
condition: succeededOrFailed()
- task: PublishTestResults@2
displayName: publish test results
inputs:
testResultsFormat: VSTest
testResultsFiles: test/**/*.trx
condition: succeededOrFailed()
- job: Windows
timeoutInMinutes: 100
strategy:
matrix:
x64:
buildPlatform: x64
enable32bit: false
x86:
buildPlatform: x86
enable32bit: true
pool:
vmImage: windows-2019
variables:
msiOutputDirectory: src/WindowsInstaller/bin/$(buildConfiguration)/$(buildPlatform)/en-us
steps:
- task: UseDotNet@2
displayName: install dotnet core sdk 2.1
inputs:
packageType: sdk
version: 2.1.x
- task: UseDotNet@2
displayName: install dotnet core sdk 3.0
inputs:
packageType: sdk
version: 3.0.x
- task: UseDotNet@2
displayName: install dotnet core sdk 3.1
inputs:
packageType: sdk
version: 3.1.x
- task: UseDotNet@2
displayName: install dotnet core sdk 5
inputs:
packageType: sdk
version: 5.0.x
- task: NuGetToolInstaller@1
displayName: install nuget
- task: NuGetCommand@2
displayName: nuget restore
inputs:
restoreSolution: Datadog.Trace.sln
verbosityRestore: Normal
# this triggers a dependency chain that builds all the managed and native dlls
- task: MSBuild@1
displayName: msbuild tracer-home
inputs:
solution: Datadog.Trace.proj
platform: $(buildPlatform)
configuration: $(buildConfiguration)
msbuildArguments: /t:msi /p:RunWixToolsOutOfProc=true /p:TracerHomeDirectory=$(publishOutput)
maximumCpuCount: true
- task: MSBuild@1
displayName: Build .NET Framework projects (not SDK-based projects)
inputs:
solution: Datadog.Trace.proj
platform: $(buildPlatform)
configuration: $(buildConfiguration)
msbuildArguments: /t:BuildFrameworkReproductions
maximumCpuCount: true
- task: DotNetCoreCLI@2
displayName: dotnet build integration tests
inputs:
command: build
projects: |
test/test-applications/regression/**/*.csproj
test/*.IntegrationTests/*.IntegrationTests.csproj
!test/test-applications/regression/**/ExpenseItDemo*.csproj
!test/test-applications/regression/**/EntityFramework6x*.csproj
!test/test-applications/regression/**/StackExchange.Redis.AssemblyConflict.LegacyProject.csproj
arguments: --configuration $(buildConfiguration) -p:Platform=$(buildPlatform) -p:ManagedProfilerOutputDirectory=$(publishOutput) /nowarn:netsdk1138
- task: DotNetCoreCLI@2
displayName: dotnet build samples
inputs:
command: build
projects: |
test/test-applications/integrations/**/*.csproj
!test/test-applications/integrations/dependency-libs/**/*.csproj
arguments: --configuration $(buildConfiguration) -p:Platform=$(buildPlatform) -p:ManagedProfilerOutputDirectory=$(publishOutput) -p:BuildInParallel=false /nowarn:netsdk1138 -p:ExcludeManagedProfiler=true -p:ExcludeNativeProfiler=true -p:LoadManagedProfilerFromProfilerDirectory=false
- task: DotNetCoreCLI@2
displayName: dotnet test
inputs:
command: test
projects: |
test/Datadog.Trace.IntegrationTests/Datadog.Trace.IntegrationTests.csproj
test/Datadog.Trace.OpenTracing.IntegrationTests/Datadog.Trace.OpenTracing.IntegrationTests.csproj
arguments: -c $(buildConfiguration) -p:Platform=$(buildPlatform)
- task: DotNetCoreCLI@2
displayName: dotnet test
inputs:
command: test
projects: test/Datadog.Trace.ClrProfiler.IntegrationTests/Datadog.Trace.ClrProfiler.IntegrationTests.csproj
arguments: -c $(buildConfiguration) --filter "(RunOnWindows=True|Category=Smoke)&LoadFromGAC!=True&IIS!=True" -p:Platform=$(buildPlatform)
- task: DockerCompose@0
displayName: docker-compose stop services
inputs:
containerregistrytype: Container Registry
dockerComposeCommand: down
condition: succeededOrFailed()
- job: Windows_IIS
timeoutInMinutes: 100
strategy:
matrix:
x64:
buildPlatform: x64
enable32bit: false
x86:
buildPlatform: x86
enable32bit: true
pool:
vmImage: windows-2019
variables:
msiOutputDirectory: src/WindowsInstaller/bin/$(buildConfiguration)/$(buildPlatform)/en-us
steps:
- task: UseDotNet@2
displayName: install dotnet core runtime 2.1
inputs:
packageType: runtime
version: 2.1.x
- task: UseDotNet@2
displayName: install dotnet core runtime 3.0
inputs:
packageType: runtime
version: 3.0.x
- task: UseDotNet@2
displayName: install dotnet core runtime 3.1
inputs:
packageType: runtime
version: 3.1.x
- task: UseDotNet@2
displayName: install dotnet core sdk 5
inputs:
packageType: sdk
version: 5.0.x
- task: NuGetToolInstaller@1
displayName: install nuget
- task: NuGetCommand@2
displayName: nuget restore
inputs:
restoreSolution: Datadog.Trace.sln
verbosityRestore: Normal
# this triggers a dependency chain that builds all the managed and native dlls
- task: MSBuild@1
displayName: msbuild tracer-home
inputs:
solution: Datadog.Trace.proj
platform: $(buildPlatform)
configuration: $(buildConfiguration)
msbuildArguments: /t:msi /p:RunWixToolsOutOfProc=true /p:TracerHomeDirectory=$(publishOutput)
maximumCpuCount: true
- task: MSBuild@1
displayName: Build .NET Framework projects (not SDK-based projects)
inputs:
solution: Datadog.Trace.proj
platform: $(buildPlatform)
configuration: $(buildConfiguration)
msbuildArguments: /t:BuildFrameworkReproductions
maximumCpuCount: true
- task: DotNetCoreCLI@2
displayName: dotnet build integration tests
inputs:
command: build
projects: |
test/test-applications/regression/**/*.csproj
test/*.IntegrationTests/*.IntegrationTests.csproj
!test/test-applications/regression/**/ExpenseItDemo*.csproj
!test/test-applications/regression/**/EntityFramework6x*.csproj
!test/test-applications/regression/**/StackExchange.Redis.AssemblyConflict.LegacyProject.csproj
arguments: --configuration $(buildConfiguration) -p:Platform=$(buildPlatform) -p:ManagedProfilerOutputDirectory=$(publishOutput) /nowarn:netsdk1138
- task: DotNetCoreCLI@2
displayName: dotnet build samples
inputs:
command: build
projects: |
test/test-applications/integrations/**/*.csproj
!test/test-applications/integrations/dependency-libs/**/*.csproj
arguments: --configuration $(buildConfiguration) -p:Platform=$(buildPlatform) -p:ManagedProfilerOutputDirectory=$(publishOutput) -p:BuildInParallel=false /nowarn:netsdk1138 -p:ExcludeManagedProfiler=true -p:ExcludeNativeProfiler=true -p:LoadManagedProfilerFromProfilerDirectory=false
- task: NuGetCommand@2
displayName: nuget restore IIS samples
inputs:
restoreSolution: test/test-applications/aspnet/samples-iis.sln
verbosityRestore: Normal
- task: MSBuild@1
displayName: Publish IIS samples
inputs:
solution: test/test-applications/aspnet/samples-iis.sln
configuration: '$(buildConfiguration)'
msbuildArguments: '/p:DeployOnBuild=true /p:PublishProfile=$(System.DefaultWorkingDirectory)/test/test-applications/aspnet/PublishProfiles/FolderProfile.pubxml'
maximumCpuCount: true
- task: DockerCompose@0
displayName: docker-compose build IIS containers
inputs:
containerregistrytype: Container Registry
dockerComposeCommand: build --build-arg DOTNET_TRACER_MSI=$(msiOutputDirectory)/*.msi --build-arg ENABLE_32_BIT=$(enable32bit) IntegrationTests.IIS.LoaderOptimizationRegKey
- task: DockerCompose@0
displayName: docker-compose start IIS containers
inputs:
containerregistrytype: Container Registry
dockerComposeCommand: up -d IntegrationTests.IIS.LoaderOptimizationRegKey
- powershell: |
[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
$publish = New-Object System.EnterpriseServices.Internal.Publish
Get-ChildItem $(publishOutput)/net45 -Filter *.dll | Foreach-Object { $publish.GacInstall($_.FullName) }
displayName: Add net45 OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed assets to the GAC
- task: DotNetCoreCLI@2
displayName: dotnet test --filter LoadFromGAC=True
inputs:
command: test
projects: test/Datadog.Trace.ClrProfiler.IntegrationTests/Datadog.Trace.ClrProfiler.IntegrationTests.csproj
arguments: -c $(buildConfiguration) --filter "(RunOnWindows=True|Category=Smoke)&LoadFromGAC=True" -p:Platform=$(buildPlatform)
- task: DockerCompose@0
displayName: docker-compose stop services
inputs:
containerregistrytype: Container Registry
dockerComposeCommand: down
condition: succeededOrFailed()

View File

@ -1,271 +0,0 @@
trigger:
branches:
include:
- main
- refs/tags/*
pr: none
variables:
buildConfiguration: release
publishOutput: $(Build.SourcesDirectory)/src/bin/managed-publish
stages:
- stage: build
jobs:
#### Windows and NuGet packages
- job: windows_packages_and_nuget
pool:
vmImage: windows-2019
variables:
tracerHomeName: windows-tracer-home
tracerHome: $(System.DefaultWorkingDirectory)/src/bin/$(tracerHomeName)
msiHome: $(System.DefaultWorkingDirectory)/src/bin/msi
nuget_packages: $(Pipeline.Workspace)/.nuget/packages
steps:
- task: UseDotNet@2
displayName: install dotnet core sdk 5.0
inputs:
packageType: sdk
version: 5.0.x
- task: NuGetToolInstaller@1
displayName: install nuget
- task: DotNetCoreCLI@2
displayName: dotnet restore
inputs:
command: restore
projects: src/**/*.csproj
# native projects must be restored with nuget.exe
- task: NuGetCommand@2
displayName: nuget restore native
inputs:
restoreSolution: Datadog.Trace.Native.sln
verbosityRestore: Normal
# this triggers a dependency chain that builds all the managed, x64, and x86 dlls, and the zip and msi files
- task: MSBuild@1
displayName: build both msi
inputs:
solution: Datadog.Trace.proj
configuration: $(buildConfiguration)
msbuildArguments: /t:msi /p:Platform=All;ZipHomeDirectory=true;TracerHomeDirectory=$(tracerHome);RunWixToolsOutOfProc=true;MsiOutputPath=$(msiHome)
maximumCpuCount: true
- publish: $(msiHome)/en-us
artifact: windows-msi
- publish: $(tracerHome).zip
artifact: $(tracerHomeName)
- task: DotNetCoreCLI@2
displayName: dotnet pack
inputs:
command: pack
packagesToPack: src/Datadog.Trace/Datadog.Trace.csproj;src/Datadog.Trace.OpenTracing/Datadog.Trace.OpenTracing.csproj
packDirectory: $(System.DefaultWorkingDirectory)/nuget-output
configuration: $(buildConfiguration)
- publish: $(System.DefaultWorkingDirectory)/nuget-output
artifact: nuget-packages
#### Linux packages
- job: linux_packages
pool:
vmImage: ubuntu-18.04
variables:
tracerHome: $(System.DefaultWorkingDirectory)/src/bin/managed-publish
steps:
- task: UseDotNet@2
displayName: install dotnet core sdk
inputs:
version: 5.0.x
- task: DotNetCoreCLI@2
displayName: dotnet build Datadog.Trace.ClrProfiler.Managed.Loader
inputs:
command: build
projects: src/Datadog.Trace.ClrProfiler.Managed.Loader/Datadog.Trace.ClrProfiler.Managed.Loader.csproj
arguments: --configuration $(buildConfiguration)
- task: DotNetCoreCLI@2
displayName: dotnet publish Datadog.Trace.ClrProfiler.Managed netstandard 2.0
inputs:
command: publish
publishWebProjects: false
modifyOutputPath: false
zipAfterPublish: false
projects: src/Datadog.Trace.ClrProfiler.Managed/Datadog.Trace.ClrProfiler.Managed.csproj
arguments: --configuration $(buildConfiguration) --framework netstandard2.0 --output $(tracerHome)/netstandard2.0
- task: DotNetCoreCLI@2
displayName: dotnet publish Datadog.Trace.ClrProfiler.Managed netcoreapp 3.1
inputs:
command: publish
publishWebProjects: false
modifyOutputPath: false
zipAfterPublish: false
projects: src/Datadog.Trace.ClrProfiler.Managed/Datadog.Trace.ClrProfiler.Managed.csproj
arguments: --configuration $(buildConfiguration) --framework netcoreapp3.1 --output $(tracerHome)/netcoreapp3.1
- task: DockerCompose@0
displayName: docker-compose run Profiler
inputs:
containerregistrytype: Container Registry
dockerComposeCommand: run -e buildConfiguration=$(buildConfiguration) Profiler
- task: DockerCompose@0
displayName: docker-compose run package
inputs:
containerregistrytype: Container Registry
dockerComposeCommand: run -e buildConfiguration=$(buildConfiguration) package
- publish: deploy/linux
artifact: linux-packages
- job: linux_alpine_packages
pool:
vmImage: ubuntu-18.04
variables:
tracerHome: $(System.DefaultWorkingDirectory)/src/bin/managed-publish
steps:
- task: UseDotNet@2
displayName: install dotnet core sdk
inputs:
version: 5.0.x
- task: DotNetCoreCLI@2
displayName: dotnet build Datadog.Trace.ClrProfiler.Managed.Loader
inputs:
command: build
projects: src/Datadog.Trace.ClrProfiler.Managed.Loader/Datadog.Trace.ClrProfiler.Managed.Loader.csproj
arguments: --configuration $(buildConfiguration)
- task: DotNetCoreCLI@2
displayName: dotnet publish Datadog.Trace.ClrProfiler.Managed 2.0
inputs:
command: publish
publishWebProjects: false
modifyOutputPath: false
zipAfterPublish: false
projects: src/Datadog.Trace.ClrProfiler.Managed/Datadog.Trace.ClrProfiler.Managed.csproj
arguments: --configuration $(buildConfiguration) --framework netstandard2.0 --output $(tracerHome)/netstandard2.0
- task: DotNetCoreCLI@2
displayName: dotnet publish Datadog.Trace.ClrProfiler.Managed 3.1
inputs:
command: publish
publishWebProjects: false
modifyOutputPath: false
zipAfterPublish: false
projects: src/Datadog.Trace.ClrProfiler.Managed/Datadog.Trace.ClrProfiler.Managed.csproj
arguments: --configuration $(buildConfiguration) --framework netcoreapp3.1 --output $(tracerHome)/netcoreapp3.1
- task: DockerCompose@0
displayName: docker-compose run Profiler.Alpine
inputs:
containerregistrytype: Container Registry
dockerComposeCommand: run -e buildConfiguration=$(buildConfiguration) Profiler.Alpine
- task: DockerCompose@0
displayName: docker-compose run package.alpine
inputs:
containerregistrytype: Container Registry
dockerComposeCommand: run -e buildConfiguration=$(buildConfiguration) package.alpine
- publish: deploy/linux
artifact: linux-alpine-packages
#### Upload artifacts to S3
- stage: upload
jobs:
- job: s3_upload
pool:
vmImage: ubuntu-18.04
steps:
- download: current
artifact: windows-msi
patterns: '**/*x64.msi'
- download: current
artifact: linux-packages
patterns: '**/*amd64.deb'
- script: |
mkdir s3_upload
mv $(Pipeline.Workspace)/windows-msi/*.msi s3_upload/
mv $(Pipeline.Workspace)/linux-packages/*.deb s3_upload/
displayName: Move deb package and MSI to s3_upload folder
# for prerelease versions, rename datadog-dotnet-apm-{version}-amd64.deb
# to datadog-dotnet-apm-{version}-{tag}-amd64.deb (i.e. add the prerelease tag)
# by copying most of the filename from datadog-dotnet-apm-{version}-{tag}-x64.msi
- script: |
MSI_NAME=$(ls s3_upload/*.msi)
PACKAGE_NAME=${MSI_NAME::-8}
echo Renaming deb package to $PACKAGE_NAME-amd64.deb
mv s3_upload/*.deb $PACKAGE_NAME-amd64.deb
displayName: Rename deb package name to match MSI name
# Create index.txt file with the following format:
# BRANCH_NAME
# SHA
# ARTIFACT WILDCARD (datadog-dotnet-apm-vX.X.X-*)
# COMMIT AUTHOR
# Note: For the branch name, normalize 'refs/heads/<branch>' to '<branch>' and 'refs/tags/<tag_name>' to 'tags/<tag_name>'
- script: |
INDEX_FILE=$(pwd)/s3_upload/index.txt
echo $(Build.SourceBranch) | sed 's/refs\/heads\///g' | sed 's/refs\/tags\//tags\//g' >> $INDEX_FILE
git rev-parse HEAD >> $INDEX_FILE
pushd s3_upload && name=$(ls *.deb) && echo "${name::-9}*" >> $INDEX_FILE && popd
git show -s --format='%ae' HEAD >> $INDEX_FILE
echo Generated index.txt file:
cat $INDEX_FILE
displayName: Write index.txt
- script: |
sudo apt-get install -y unzip python3-setuptools
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
unzip awscli-bundle.zip
sudo python3 ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
aws --version
displayName: Install AWS CLI
- script: aws configure set aws_access_key_id $SECRET
displayName: Authenticate aws_access_key_id
env:
SECRET: $(AWS_ACCESS_KEY_ID)
- script: aws configure set aws_secret_access_key $SECRET
displayName: Authenticate aws_secret_access_key
env:
SECRET: $(AWS_SECRET_ACCESS_KEY)
# by default, run this step on main branch only.
# use "push_artifacts_to_s3" to override:
# "true": run this step
# "false": do NOT run this step
# else: run this stage if branch is main
- script: aws s3 cp s3_upload s3://datadog-reliability-env/dotnet/ --recursive
displayName: Upload deb, MSI, index.txt to s3
condition: >
and(
succeeded(),
ne(variables['push_artifacts_to_s3'], 'false'),
or(
eq(variables['push_artifacts_to_s3'], 'true'),
eq(variables['Build.SourceBranch'], 'refs/heads/main')
)
)

View File

@ -1,232 +0,0 @@
trigger:
branches:
include:
- main
- refs/tags/*
exclude:
- refs/pull/*/head
paths:
exclude:
- docs/*
- .github/*
variables:
publishOutput: $(System.DefaultWorkingDirectory)/src/bin/managed-publish
jobs:
- job: build_linux_profiler
steps:
- task: UseDotNet@2
displayName: install dotnet core sdk 5.0
inputs:
packageType: sdk
version: 5.0.x
includePreviewVersions: true
- task: DotNetCoreCLI@2
displayName: dotnet build Datadog.Trace.ClrProfiler.Managed.Loader
inputs:
command: build
projects: src/Datadog.Trace.ClrProfiler.Managed.Loader/Datadog.Trace.ClrProfiler.Managed.Loader.csproj
arguments: --configuration Release
- task: DotNetCoreCLI@2
displayName: dotnet publish Datadog.Trace.ClrProfiler.Managed 2.0
inputs:
command: publish
publishWebProjects: false
modifyOutputPath: false
zipAfterPublish: false
projects: src/Datadog.Trace.ClrProfiler.Managed/Datadog.Trace.ClrProfiler.Managed.csproj
arguments: --configuration Release --framework netstandard2.0 --output $(publishOutput)/netstandard2.0
- task: DotNetCoreCLI@2
displayName: dotnet publish Datadog.Trace.ClrProfiler.Managed 3.1
inputs:
command: publish
publishWebProjects: false
modifyOutputPath: false
zipAfterPublish: false
projects: src/Datadog.Trace.ClrProfiler.Managed/Datadog.Trace.ClrProfiler.Managed.csproj
arguments: --configuration Release --framework netcoreapp3.1 --output $(publishOutput)/netcoreapp3.1
- task: DockerCompose@0
displayName: docker-compose run Profiler
inputs:
containerregistrytype: Container Registry
dockerComposeCommand: run -e buildConfiguration=Release Profiler
- publish: $(System.DefaultWorkingDirectory)/src/Datadog.Trace.ClrProfiler.Native/bin/Release/x64
displayName: Uploading linux tracer home artifact
artifact: linux-tracer-home
- job: macos_profiler
pool:
vmImage: macOS-10.15
steps:
- task: UseDotNet@2
displayName: install dotnet core runtime 3.1
inputs:
packageType: runtime
version: 3.1.x
- task: UseDotNet@2
displayName: install dotnet core sdk 5.0
inputs:
packageType: sdk
version: 5.0.x
- task: DotNetCoreCLI@2
displayName: dotnet build
inputs:
command: build
configuration: Release
arguments: /nowarn:netsdk1138
projects: |
src/Datadog.Trace.ClrProfiler.Managed.Loader/Datadog.Trace.ClrProfiler.Managed.Loader.csproj
- script: |
cd ./src/Datadog.Trace.ClrProfiler.Native
cmake . -DCMAKE_BUILD_TYPE=Release
make
displayName: build_profiler
- publish: $(System.DefaultWorkingDirectory)/src/Datadog.Trace.ClrProfiler.Native/bin
displayName: Uploading macos profiler artifact
artifact: macos-profiler
- job: build_runner_tool_and_standalone
dependsOn:
- build_linux_profiler
- macos_profiler
condition: succeeded()
pool:
vmImage: windows-2019
steps:
- download: current
artifact: linux-tracer-home
patterns: '**/*.so'
- task: CopyFiles@2
displayName: Copying native linux binary from previous job
inputs:
sourceFolder: $(Pipeline.Workspace)/linux-tracer-home
targetFolder: $(System.DefaultWorkingDirectory)/src/Datadog.Trace.Tools.Runner/home/linux-x64
- download: current
artifact: macos-profiler
patterns: '**/*.dylib'
- task: CopyFiles@2
displayName: Copying native macos binary from previous job
inputs:
sourceFolder: $(Pipeline.Workspace)/macos-profiler
targetFolder: $(System.DefaultWorkingDirectory)/src/Datadog.Trace.Tools.Runner/home/osx-x64
# Install the tracer latest stable release to attach the profiler to the build and test steps.
# The script exposes the required environment variables to the following steps
- task: PowerShell@2
displayName: Install profiler latest release
inputs:
filePath: ./.azure-pipelines/setup_tracer.ps1
- task: UseDotNet@2
displayName: install dotnet core runtime 2.1
inputs:
packageType: runtime
version: 2.1.x
- task: UseDotNet@2
displayName: install dotnet core runtime 3.0
inputs:
packageType: runtime
version: 3.0.x
- task: UseDotNet@2
displayName: install dotnet core runtime 3.1
inputs:
packageType: runtime
version: 3.1.x
- task: UseDotNet@2
displayName: install dotnet core sdk 5.0
inputs:
packageType: sdk
version: 5.0.x
includePreviewVersions: true
- task: DotNetCoreCLI@2
displayName: dotnet build
inputs:
command: build
configuration: $(buildConfiguration)
arguments: -l:DatadogLogger,"$(OTEL_DOTNET_TRACER_MSBUILD)"
projects: |
src/**/*.csproj
test/**/*.Tests.csproj
benchmarks/**/*.csproj
!src/Datadog.Trace.Tools.Runner/*.csproj
env:
OTEL_SERVICE_NAME: dd-tracer-dotnet
- task: NuGetToolInstaller@1
displayName: install nuget
- task: NuGetCommand@2
displayName: nuget restore
inputs:
restoreSolution: Datadog.Trace.Native.sln
verbosityRestore: Normal
- task: MSBuild@1
displayName: tool build
inputs:
solution: src/Datadog.Trace.Tools.Runner/Datadog.Trace.Tools.Runner.proj
msbuildArguments: /t:BuildTool /l:DatadogLogger,"$(OTEL_DOTNET_TRACER_MSBUILD)"
maximumCpuCount: true
env:
OTEL_SERVICE_NAME: dd-tracer-dotnet-runner-tool
- task: MSBuild@1
displayName: standalone build
inputs:
solution: src/Datadog.Trace.Tools.Runner/Datadog.Trace.Tools.Runner.proj
msbuildArguments: /t:BuildStandalone /l:DatadogLogger,"$(OTEL_DOTNET_TRACER_MSBUILD)"
maximumCpuCount: true
env:
OTEL_SERVICE_NAME: dd-tracer-dotnet-runner-tool
- task: DeleteFiles@1
displayName: 'Remove unneeded files'
inputs:
Contents: |
$(System.DefaultWorkingDirectory)/src/Datadog.Trace.Tools.Runner/bin/Release/Tool/!(*.nupkg)
$(System.DefaultWorkingDirectory)/src/Datadog.Trace.Tools.Runner/bin/Release/Console/publish/win-x64/home*
$(System.DefaultWorkingDirectory)/src/Datadog.Trace.Tools.Runner/bin/Release/Console/publish/win-x86/home*
$(System.DefaultWorkingDirectory)/src/Datadog.Trace.Tools.Runner/bin/Release/Console/publish/linux-x64/home*
$(System.DefaultWorkingDirectory)/src/Datadog.Trace.Tools.Runner/bin/Release/Console/publish/osx-x64/home*
- publish: $(System.DefaultWorkingDirectory)/src/Datadog.Trace.Tools.Runner/bin/Release/Tool
displayName: Uploading runner dotnet tool artifact
artifact: runner-dotnet-tool
- publish: $(System.DefaultWorkingDirectory)/src/Datadog.Trace.Tools.Runner/bin/Release/Console/publish/win-x64
displayName: Uploading runner standalone win-x64 artifact
artifact: runner-standalone-win-x64
- publish: $(System.DefaultWorkingDirectory)/src/Datadog.Trace.Tools.Runner/bin/Release/Console/publish/win-x86
displayName: Uploading runner standalone win-x86 artifact
artifact: runner-standalone-win-x86
- publish: $(System.DefaultWorkingDirectory)/src/Datadog.Trace.Tools.Runner/bin/Release/Console/publish/linux-x64
displayName: Uploading runner standalone linux-x64 artifact
artifact: runner-standalone-linux-x64
- publish: $(System.DefaultWorkingDirectory)/src/Datadog.Trace.Tools.Runner/bin/Release/Console/publish/osx-x64
displayName: Uploading runner standalone osx-x64 artifact
artifact: runner-standalone-osx-x64

View File

@ -1,82 +0,0 @@
$ProgressPreference = 'SilentlyContinue'
echo "Getting latest release version"
# Get the latest release tag from the github release page
$release_version = (Invoke-WebRequest https://api.github.com/repos/datadog/dd-trace-dotnet/releases | ConvertFrom-Json)[0].tag_name.SubString(1)
$otel_tracer_workingfolder = $env:OTEL_TRACER_WORKINGFOLDER
$otel_tracer_home = ""
$otel_tracer_msbuild = ""
$otel_tracer_integrations = ""
$otel_tracer_profiler_32 = ""
$otel_tracer_profiler_64 = ""
# Download the binary file depending of the current operating system and extract the content to the "release" folder
echo "Downloading tracer v$release_version"
if ($env:os -eq "Windows_NT")
{
$url = "https://github.com/DataDog/dd-trace-dotnet/releases/download/v$($release_version)/windows-tracer-home.zip"
Invoke-WebRequest -Uri $url -OutFile windows.zip
echo "Extracting windows.zip"
Expand-Archive windows.zip -DestinationPath .\release
Remove-Item windows.zip
if ([string]::IsNullOrEmpty($otel_tracer_workingfolder)) {
$otel_tracer_home = "$(pwd)\release"
} else {
$otel_tracer_home = "$otel_tracer_workingfolder\release"
}
$otel_tracer_msbuild = "$otel_tracer_home\netstandard2.0\OpenTelemetry.AutoInstrumentation.MSBuild.dll"
$otel_tracer_integrations = "$otel_tracer_home\integrations.json"
$otel_tracer_profiler_32 = "$otel_tracer_home\win-x86\OpenTelemetry.AutoInstrumentation.ClrProfiler.Native.dll"
$otel_tracer_profiler_64 = "$otel_tracer_home\win-x64\OpenTelemetry.AutoInstrumentation.ClrProfiler.Native.dll"
}
else
{
# File version is the same as the release version without the prerelease suffix.
$file_version = $release_version.replace("-prerelease", "")
$url = "https://github.com/DataDog/dd-trace-dotnet/releases/download/v$($release_version)/datadog-dotnet-apm-$($file_version).tar.gz"
Invoke-WebRequest -Uri $url -OutFile linux.tar.gz
mkdir release
echo "Extracting linux.tar.gz"
tar -xvzf linux.tar.gz -C ./release
Remove-Item linux.tar.gz
# Ensure the profiler can write the native log profiler
sudo mkdir -p /var/log/opentelemetry/dotnet
sudo chmod -R 777 /var/log/opentelemetry/dotnet
if ([string]::IsNullOrEmpty($otel_tracer_workingfolder)) {
$otel_tracer_home = "$(pwd)/release"
} else {
$otel_tracer_home = "$otel_tracer_workingfolder/release"
}
$otel_tracer_msbuild = "$otel_tracer_home/netstandard2.0/OpenTelemetry.AutoInstrumentation.MSBuild.dll"
$otel_tracer_integrations = "$otel_tracer_home/integrations.json"
$otel_tracer_profiler_64 = "$otel_tracer_home/OpenTelemetry.AutoInstrumentation.ClrProfiler.Native.so"
}
# Set all environment variables to attach the profiler to the following pipeline steps
echo "Setting environment variables..."
echo "##vso[task.setvariable variable=OTEL_ENV]CI"
echo "##vso[task.setvariable variable=OTEL_DOTNET_TRACER_HOME]$otel_tracer_home"
echo "##vso[task.setvariable variable=OTEL_DOTNET_TRACER_MSBUILD]$otel_tracer_msbuild"
echo "##vso[task.setvariable variable=OTEL_INTEGRATIONS]$otel_tracer_integrations"
echo "##vso[task.setvariable variable=CORECLR_ENABLE_PROFILING]1"
echo "##vso[task.setvariable variable=CORECLR_PROFILER]{918728DD-259F-4A6A-AC2B-B85E1B658318}"
echo "##vso[task.setvariable variable=CORECLR_PROFILER_PATH_32]$otel_tracer_profiler_32"
echo "##vso[task.setvariable variable=CORECLR_PROFILER_PATH_64]$otel_tracer_profiler_64"
echo "##vso[task.setvariable variable=COR_ENABLE_PROFILING]1"
echo "##vso[task.setvariable variable=COR_PROFILER]{918728DD-259F-4A6A-AC2B-B85E1B658318}"
echo "##vso[task.setvariable variable=COR_PROFILER_PATH_32]$otel_tracer_profiler_32"
echo "##vso[task.setvariable variable=COR_PROFILER_PATH_64]$otel_tracer_profiler_64"
echo "Done."

View File

@ -1,25 +0,0 @@
steps:
- task: UseDotNet@2
displayName: install dotnet core sdk 2.1
inputs:
packageType: sdk
version: 2.1.x
- task: UseDotNet@2
displayName: install dotnet core sdk 3.0
inputs:
packageType: sdk
version: 3.0.x
- task: UseDotNet@2
displayName: install dotnet core sdk 3.1
inputs:
packageType: sdk
version: 3.1.x
- task: UseDotNet@2
displayName: install dotnet core sdk 5
inputs:
packageType: sdk
version: $(dotnetCoreSdk5Version)
includePreviewVersions: true

View File

@ -1,24 +0,0 @@
steps:
- task: UseDotNet@2
displayName: install dotnet core runtime 2.1
inputs:
packageType: runtime
version: 2.1.x
- task: UseDotNet@2
displayName: install dotnet core runtime 3.0
inputs:
packageType: runtime
version: 3.0.x
- task: UseDotNet@2
displayName: install dotnet core runtime 3.1
inputs:
packageType: runtime
version: 3.1.x
- task: UseDotNet@2
displayName: install dotnet core sdk 5.0
inputs:
packageType: sdk
version: $(dotnetCoreSdk5Version)

File diff suppressed because it is too large Load Diff

View File

@ -1,275 +0,0 @@
trigger:
branches:
include:
- main
- refs/tags/*
exclude:
- refs/pull/*/head
paths:
exclude:
- docs/*
- .github/*
variables:
buildConfiguration: Debug
OTEL_DOTNET_TRACER_MSBUILD:
jobs:
- job: managed
strategy:
matrix:
windows:
imageName: windows-2019
linux:
imageName: ubuntu-18.04
pool:
vmImage: $(imageName)
steps:
# Install the tracer latest stable release to attach the profiler to the build and test steps.
# The script exposes the required environment variables to the following steps
#- task: PowerShell@2
# displayName: Install profiler latest release
# inputs:
# filePath: ./.azure-pipelines/setup_tracer.ps1
- task: UseDotNet@2
displayName: install dotnet core runtime 2.1
inputs:
packageType: runtime
version: 2.1.x
- task: UseDotNet@2
displayName: install dotnet core runtime 3.0
inputs:
packageType: runtime
version: 3.0.x
- task: UseDotNet@2
displayName: install dotnet core runtime 3.1
inputs:
packageType: runtime
version: 3.1.x
- task: UseDotNet@2
displayName: install dotnet core sdk 5.0
inputs:
packageType: sdk
version: 5.0.x
- task: DotNetCoreCLI@2
displayName: dotnet build
inputs:
command: build
configuration: $(buildConfiguration)
arguments: /nowarn:netsdk1138 #-l:DatadogLogger,"$(OTEL_DOTNET_TRACER_MSBUILD)"
projects: |
src/**/*.csproj
test/**/*.Tests.csproj
test/benchmarks/**/*.csproj
!src/Datadog.Trace.Tools.Runner/*.csproj
env:
OTEL_SERVICE_NAME: dd-trace-dotnet
- task: DotNetCoreCLI@2
displayName: dotnet test
inputs:
command: test
configuration: $(buildConfiguration)
projects: |
test/**/*.Tests.csproj
env:
OTEL_SERVICE_NAME: dd-tracer-dotnet
- job: managed_macos
pool:
vmImage: macOS-10.15
steps:
- task: UseDotNet@2
displayName: install dotnet core runtime 2.1
inputs:
packageType: runtime
version: 2.1.x
- task: UseDotNet@2
displayName: install dotnet core runtime 3.0
inputs:
packageType: runtime
version: 3.0.x
- task: UseDotNet@2
displayName: install dotnet core runtime 3.1
inputs:
packageType: runtime
version: 3.1.x
- task: UseDotNet@2
displayName: install dotnet core sdk 5.0
inputs:
packageType: sdk
version: 5.0.x
- task: DotNetCoreCLI@2
displayName: dotnet build
inputs:
command: build
configuration: $(buildConfiguration)
arguments: /nowarn:netsdk1138
projects: |
src/**/*.csproj
test/**/*.Tests.csproj
benchmarks/**/*.csproj
!src/Datadog.Trace.Tools.Runner/*.csproj
- task: DotNetCoreCLI@2
displayName: dotnet test
inputs:
command: test
configuration: $(buildConfiguration)
projects: test/**/*.Tests.csproj
env:
OTEL_SERVICE: dd-trace-dotnet
- job: windows_profiler
strategy:
matrix:
x64:
buildPlatform: x64
x86:
buildPlatform: x86
pool:
vmImage: windows-2019
steps:
- task: UseDotNet@2
displayName: install dotnet core runtime 3.1
inputs:
packageType: runtime
version: 3.1.x
- task: UseDotNet@2
displayName: install dotnet core sdk 5.0
inputs:
packageType: sdk
version: 5.0.x
- task: DotNetCoreCLI@2
displayName: dotnet build
inputs:
command: build
configuration: $(buildConfiguration)
arguments: /nowarn:netsdk1138
projects: |
src/Datadog.Trace.ClrProfiler.Managed.Loader/Datadog.Trace.ClrProfiler.Managed.Loader.csproj
sample-libs/**/Samples.ExampleLibrary*.csproj
- task: NuGetToolInstaller@1
displayName: install nuget
- task: NuGetCommand@2
displayName: nuget restore
inputs:
restoreSolution: Datadog.Trace.Native.sln
verbosityRestore: Normal
- task: MSBuild@1
displayName: msbuild
inputs:
solution: Datadog.Trace.proj
platform: $(buildPlatform)
configuration: $(buildConfiguration)
msbuildArguments: /t:BuildCpp;BuildCppTests
maximumCpuCount: true
- script: Datadog.Trace.ClrProfiler.Native.Tests.exe --gtest_output=xml
displayName: run tests
workingDirectory: $(System.DefaultWorkingDirectory)/test/Datadog.Trace.ClrProfiler.Native.Tests/bin/$(buildConfiguration)/$(buildPlatform)
- task: PublishTestResults@2
displayName: publish test results
inputs:
testResultsFiles: test/**/test*.xml
buildPlatform: $(buildPlatform)
buildConfiguration: $(buildConfiguration)
condition: succeededOrFailed()
- job: linux_profiler
pool:
vmImage: ubuntu-20.04
steps:
- task: UseDotNet@2
displayName: install dotnet core runtime 3.1
inputs:
packageType: runtime
version: 3.1.x
- task: UseDotNet@2
displayName: install dotnet core sdk 5.0
inputs:
packageType: sdk
version: 5.0.x
- task: DotNetCoreCLI@2
displayName: dotnet build
inputs:
command: build
configuration: $(buildConfiguration)
arguments: /nowarn:netsdk1138
projects: |
src/Datadog.Trace.ClrProfiler.Managed.Loader/Datadog.Trace.ClrProfiler.Managed.Loader.csproj
- script: |
sudo apt-get update
sudo apt-get install -y llvm clang
displayName: install_dependencies
- script: |
cd ./src/Datadog.Trace.ClrProfiler.Native
CXX=clang++ CC=clang cmake .
make
displayName: build_profiler
- script: |
cd ./src/Datadog.Trace.ClrProfiler.Native
CXX=clang++ CC=clang cmake .
make
displayName: build_profiler
- job: macos_profiler
pool:
vmImage: macOS-10.15
steps:
- task: UseDotNet@2
displayName: install dotnet core runtime 3.1
inputs:
packageType: runtime
version: 3.1.x
- task: UseDotNet@2
displayName: install dotnet core sdk 5.0
inputs:
packageType: sdk
version: 5.0.x
- task: DotNetCoreCLI@2
displayName: dotnet build
inputs:
command: build
configuration: $(buildConfiguration)
arguments: /nowarn:netsdk1138
projects: |
src/Datadog.Trace.ClrProfiler.Managed.Loader/Datadog.Trace.ClrProfiler.Managed.Loader.csproj
- script: |
cd ./src/Datadog.Trace.ClrProfiler.Native
cmake .
make
displayName: build_profiler

View File

@ -1,51 +1,26 @@
name: Build artifacts
on:
push:
branches: [ main ]
branches: [ poc-otel-sdk ]
tags:
- 'v*.*.*'
pull_request:
branches: [ main ]
branches: [ poc-otel-sdk ]
workflow_dispatch:
jobs:
alpine_build:
name: Alpine Build
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- run: docker-compose run build
env:
buildConfiguration: Release
- run: docker-compose run Profiler.Alpine
env:
buildConfiguration: Release
- run: docker-compose run package.alpine
env:
buildConfiguration: Release
- uses: actions/upload-artifact@v2
with:
name: artifacts
path: deploy/linux
linux_build:
name: Linux Build
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- run: docker-compose run build
- run: ./build/docker/build.sh
env:
buildConfiguration: Release
- run: docker-compose run Profiler
- run: ./build/docker/Datadog.Trace.ClrProfiler.Native.sh
env:
buildConfiguration: Release
- run: docker-compose run package
env:
buildConfiguration: Release
- uses: actions/upload-artifact@v2
with:
name: artifacts
path: deploy/linux
windows_build:
name: Windows Build
@ -53,52 +28,13 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: microsoft/setup-msbuild@v1.0.2
- run: dotnet --list-sdks
- run: dotnet build -c %buildConfiguration% src/Datadog.Trace.ClrProfiler.Managed.Loader/Datadog.Trace.ClrProfiler.Managed.Loader.csproj
shell: cmd
- run: choco install wixtoolset
shell: cmd
- run: .\build\build.cmd
env:
buildConfiguration: Release
- run: nuget restore src\Datadog.Trace.ClrProfiler.Native\Datadog.Trace.ClrProfiler.Native.vcxproj -SolutionDirectory .
shell: cmd
- run: msbuild.exe Datadog.Trace.proj -t:BuildCpp -p:Configuration=%buildConfiguration% -p:Platform=x64
shell: cmd
- uses: actions/upload-artifact@v2
with:
name: artifacts
path: src/WindowsInstaller/bin/Release/*/en-us
macos_build:
name: MacOS Build
runs-on: macos-10.15
steps:
- uses: actions/checkout@v2
- run: brew install make
- run: ./build/build_mac.sh
env:
buildConfiguration: Release
- run: tar --create --verbose --file=otel-dotnet-autoinstrumentation-macos.tar deploy/macos
- uses: actions/upload-artifact@v2
with:
name: artifacts
path: otel-dotnet-autoinstrumentation-macos.tar
create_release:
runs-on: ubuntu-20.04
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') # only trigger if the current event is for a tag push
needs: [alpine_build, linux_build, windows_build, macos_build]
permissions:
contents: write
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
path: .
- name: Extract tag name
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v}
- name: Extract release notes
run: awk '/## \[${{ steps.get_version.outputs.VERSION }}\]/,0' docs/CHANGELOG.md >> notes.md
- run: gh release create v${{ steps.get_version.outputs.VERSION }} -F notes.md artifacts/otel* artifacts/x64/en-us/opentelemetry* artifacts/x86/en-us/opentelemetry*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -1,311 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.452
MinimumVisualStudioVersion = 15.0.26124.0
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Datadog.Trace.ClrProfiler.Native", "src\Datadog.Trace.ClrProfiler.Native\Datadog.Trace.ClrProfiler.Native.vcxproj", "{91B6272F-5780-4C94-8071-DBBA7B4F67F3}"
ProjectSection(ProjectDependencies) = postProject
{AB8596C1-CFDA-4A5E-9E9C-74A3DF9AED77} = {AB8596C1-CFDA-4A5E-9E9C-74A3DF9AED77}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Datadog.Trace.ClrProfiler.Native.DLL", "src\Datadog.Trace.ClrProfiler.Native\Datadog.Trace.ClrProfiler.Native.DLL.vcxproj", "{C0C8D381-D6B9-4C76-9428-F40F2FA93A9A}"
ProjectSection(ProjectDependencies) = postProject
{AB8596C1-CFDA-4A5E-9E9C-74A3DF9AED77} = {AB8596C1-CFDA-4A5E-9E9C-74A3DF9AED77}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Datadog.Trace", "src\Datadog.Trace\Datadog.Trace.csproj", "{5DFDF781-F24C-45B1-82EF-9125875A80A4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Datadog.Trace.Tests", "test\Datadog.Trace.Tests\Datadog.Trace.Tests.csproj", "{73A1BE1C-9C8A-43FA-86A8-BF2744B4C1BB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Datadog.Trace.OpenTracing", "src\Datadog.Trace.OpenTracing\Datadog.Trace.OpenTracing.csproj", "{188219D1-D123-46C9-B905-A9ED30E6AAA7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Datadog.Trace.OpenTracing.Tests", "test\Datadog.Trace.OpenTracing.Tests\Datadog.Trace.OpenTracing.Tests.csproj", "{3BCE5D99-147B-4305-9970-AB0F683A6E8D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Datadog.Trace.TestHelpers", "test\Datadog.Trace.TestHelpers\Datadog.Trace.TestHelpers.csproj", "{237A1C92-DE9E-4649-961B-BBB7CF0DFE01}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{9E5F0022-0A50-40BF-AC6A-C3078585ECAB}"
ProjectSection(SolutionItems) = preProject
src\Directory.Build.props = src\Directory.Build.props
src\GlobalSuppressions.cs = src\GlobalSuppressions.cs
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{8CEC2042-F11C-49F5-A674-2355793B600A}"
ProjectSection(SolutionItems) = preProject
test\Directory.Build.props = test\Directory.Build.props
test\GlobalSuppressions.cs = test\GlobalSuppressions.cs
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Datadog.Trace.ClrProfiler.Managed", "src\Datadog.Trace.ClrProfiler.Managed\Datadog.Trace.ClrProfiler.Managed.csproj", "{85F35AAF-D102-4960-8B41-3BD9CBD0E77F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{5D8E1F81-B820-4736-B797-271B0FE787EE}"
ProjectSection(SolutionItems) = preProject
tools\Directory.Build.props = tools\Directory.Build.props
tools\GlobalSuppressions.cs = tools\GlobalSuppressions.cs
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Datadog.Trace.ClrProfiler.Managed.Tests", "test\Datadog.Trace.ClrProfiler.Managed.Tests\Datadog.Trace.ClrProfiler.Managed.Tests.csproj", "{5B52C0C0-A554-4E53-9D17-B121E78FF919}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Datadog.Trace.ClrProfiler.Managed.Loader", "src\Datadog.Trace.ClrProfiler.Managed.Loader\Datadog.Trace.ClrProfiler.Managed.Loader.csproj", "{AB8596C1-CFDA-4A5E-9E9C-74A3DF9AED77}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Datadog.Core.Tools", "tools\Datadog.Core.Tools\Datadog.Core.Tools.csproj", "{3BEACB10-89FE-4F74-8022-1A52F223CE82}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Datadog.Trace.AspNet", "src\Datadog.Trace.AspNet\Datadog.Trace.AspNet.csproj", "{B34EDBC7-C5FB-409D-8472-BC7469D6F2BD}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Datadog.Trace.Ci.Shared", "src\Datadog.Trace.Ci.Shared\Datadog.Trace.Ci.Shared.shproj", "{A1D7653A-C409-414A-B9B0-7879953EBCDD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Datadog.Trace.MSBuild", "src\Datadog.Trace.MSBuild\Datadog.Trace.MSBuild.csproj", "{ADE25B77-2608-4E3E-96B0-6144A6466F84}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Datadog.Trace.BenchmarkDotNet", "src\Datadog.Trace.BenchmarkDotNet\Datadog.Trace.BenchmarkDotNet.csproj", "{B40276C5-764C-48AB-91A4-72F3D2A66611}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Datadog.Trace.ClrProfiler.Managed.Core", "src\Datadog.Trace.ClrProfiler.Managed.Core\Datadog.Trace.ClrProfiler.Managed.Core.csproj", "{934FE26D-885D-4FAD-9AFC-BFA975DFCBB5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Benchmarks.Trace", "test\benchmarks\Benchmarks.Trace\Benchmarks.Trace.csproj", "{C68D858A-BAE7-4365-8A0B-CBFDDE3257E7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks", "{64FBB8EE-5430-4BD8-95B3-DC69AD2E3D9D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Datadog.Trace.DuckTyping.Tests", "test\Datadog.Trace.DuckTyping.Tests\Datadog.Trace.DuckTyping.Tests.csproj", "{6E635156-2BF9-471B-94A3-3BFE3D40169F}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\Datadog.Trace.Ci.Shared\Datadog.Trace.Ci.Shared.projitems*{85f35aaf-d102-4960-8b41-3bd9cbd0e77f}*SharedItemsImports = 5
src\Datadog.Trace.Ci.Shared\Datadog.Trace.Ci.Shared.projitems*{a1d7653a-c409-414a-b9b0-7879953ebcdd}*SharedItemsImports = 13
src\Datadog.Trace.Ci.Shared\Datadog.Trace.Ci.Shared.projitems*{ade25b77-2608-4e3e-96b0-6144a6466f84}*SharedItemsImports = 5
src\Datadog.Trace.Ci.Shared\Datadog.Trace.Ci.Shared.projitems*{b40276c5-764c-48ab-91a4-72f3d2a66611}*SharedItemsImports = 5
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{91B6272F-5780-4C94-8071-DBBA7B4F67F3}.Debug|Any CPU.ActiveCfg = Debug|Win32
{91B6272F-5780-4C94-8071-DBBA7B4F67F3}.Debug|x64.ActiveCfg = Debug|x64
{91B6272F-5780-4C94-8071-DBBA7B4F67F3}.Debug|x64.Build.0 = Debug|x64
{91B6272F-5780-4C94-8071-DBBA7B4F67F3}.Debug|x86.ActiveCfg = Debug|Win32
{91B6272F-5780-4C94-8071-DBBA7B4F67F3}.Debug|x86.Build.0 = Debug|Win32
{91B6272F-5780-4C94-8071-DBBA7B4F67F3}.Release|Any CPU.ActiveCfg = Release|Win32
{91B6272F-5780-4C94-8071-DBBA7B4F67F3}.Release|x64.ActiveCfg = Release|x64
{91B6272F-5780-4C94-8071-DBBA7B4F67F3}.Release|x64.Build.0 = Release|x64
{91B6272F-5780-4C94-8071-DBBA7B4F67F3}.Release|x86.ActiveCfg = Release|Win32
{91B6272F-5780-4C94-8071-DBBA7B4F67F3}.Release|x86.Build.0 = Release|Win32
{C0C8D381-D6B9-4C76-9428-F40F2FA93A9A}.Debug|Any CPU.ActiveCfg = Debug|Win32
{C0C8D381-D6B9-4C76-9428-F40F2FA93A9A}.Debug|x64.ActiveCfg = Debug|x64
{C0C8D381-D6B9-4C76-9428-F40F2FA93A9A}.Debug|x64.Build.0 = Debug|x64
{C0C8D381-D6B9-4C76-9428-F40F2FA93A9A}.Debug|x86.ActiveCfg = Debug|Win32
{C0C8D381-D6B9-4C76-9428-F40F2FA93A9A}.Debug|x86.Build.0 = Debug|Win32
{C0C8D381-D6B9-4C76-9428-F40F2FA93A9A}.Release|Any CPU.ActiveCfg = Release|Win32
{C0C8D381-D6B9-4C76-9428-F40F2FA93A9A}.Release|x64.ActiveCfg = Release|x64
{C0C8D381-D6B9-4C76-9428-F40F2FA93A9A}.Release|x64.Build.0 = Release|x64
{C0C8D381-D6B9-4C76-9428-F40F2FA93A9A}.Release|x86.ActiveCfg = Release|Win32
{C0C8D381-D6B9-4C76-9428-F40F2FA93A9A}.Release|x86.Build.0 = Release|Win32
{5DFDF781-F24C-45B1-82EF-9125875A80A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5DFDF781-F24C-45B1-82EF-9125875A80A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5DFDF781-F24C-45B1-82EF-9125875A80A4}.Debug|x64.ActiveCfg = Debug|Any CPU
{5DFDF781-F24C-45B1-82EF-9125875A80A4}.Debug|x64.Build.0 = Debug|Any CPU
{5DFDF781-F24C-45B1-82EF-9125875A80A4}.Debug|x86.ActiveCfg = Debug|Any CPU
{5DFDF781-F24C-45B1-82EF-9125875A80A4}.Debug|x86.Build.0 = Debug|Any CPU
{5DFDF781-F24C-45B1-82EF-9125875A80A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5DFDF781-F24C-45B1-82EF-9125875A80A4}.Release|Any CPU.Build.0 = Release|Any CPU
{5DFDF781-F24C-45B1-82EF-9125875A80A4}.Release|x64.ActiveCfg = Release|Any CPU
{5DFDF781-F24C-45B1-82EF-9125875A80A4}.Release|x64.Build.0 = Release|Any CPU
{5DFDF781-F24C-45B1-82EF-9125875A80A4}.Release|x86.ActiveCfg = Release|Any CPU
{5DFDF781-F24C-45B1-82EF-9125875A80A4}.Release|x86.Build.0 = Release|Any CPU
{73A1BE1C-9C8A-43FA-86A8-BF2744B4C1BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{73A1BE1C-9C8A-43FA-86A8-BF2744B4C1BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{73A1BE1C-9C8A-43FA-86A8-BF2744B4C1BB}.Debug|x64.ActiveCfg = Debug|Any CPU
{73A1BE1C-9C8A-43FA-86A8-BF2744B4C1BB}.Debug|x64.Build.0 = Debug|Any CPU
{73A1BE1C-9C8A-43FA-86A8-BF2744B4C1BB}.Debug|x86.ActiveCfg = Debug|Any CPU
{73A1BE1C-9C8A-43FA-86A8-BF2744B4C1BB}.Debug|x86.Build.0 = Debug|Any CPU
{73A1BE1C-9C8A-43FA-86A8-BF2744B4C1BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{73A1BE1C-9C8A-43FA-86A8-BF2744B4C1BB}.Release|Any CPU.Build.0 = Release|Any CPU
{73A1BE1C-9C8A-43FA-86A8-BF2744B4C1BB}.Release|x64.ActiveCfg = Release|Any CPU
{73A1BE1C-9C8A-43FA-86A8-BF2744B4C1BB}.Release|x64.Build.0 = Release|Any CPU
{73A1BE1C-9C8A-43FA-86A8-BF2744B4C1BB}.Release|x86.ActiveCfg = Release|Any CPU
{73A1BE1C-9C8A-43FA-86A8-BF2744B4C1BB}.Release|x86.Build.0 = Release|Any CPU
{188219D1-D123-46C9-B905-A9ED30E6AAA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{188219D1-D123-46C9-B905-A9ED30E6AAA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{188219D1-D123-46C9-B905-A9ED30E6AAA7}.Debug|x64.ActiveCfg = Debug|Any CPU
{188219D1-D123-46C9-B905-A9ED30E6AAA7}.Debug|x64.Build.0 = Debug|Any CPU
{188219D1-D123-46C9-B905-A9ED30E6AAA7}.Debug|x86.ActiveCfg = Debug|Any CPU
{188219D1-D123-46C9-B905-A9ED30E6AAA7}.Debug|x86.Build.0 = Debug|Any CPU
{188219D1-D123-46C9-B905-A9ED30E6AAA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{188219D1-D123-46C9-B905-A9ED30E6AAA7}.Release|Any CPU.Build.0 = Release|Any CPU
{188219D1-D123-46C9-B905-A9ED30E6AAA7}.Release|x64.ActiveCfg = Release|Any CPU
{188219D1-D123-46C9-B905-A9ED30E6AAA7}.Release|x64.Build.0 = Release|Any CPU
{188219D1-D123-46C9-B905-A9ED30E6AAA7}.Release|x86.ActiveCfg = Release|Any CPU
{188219D1-D123-46C9-B905-A9ED30E6AAA7}.Release|x86.Build.0 = Release|Any CPU
{3BCE5D99-147B-4305-9970-AB0F683A6E8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3BCE5D99-147B-4305-9970-AB0F683A6E8D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3BCE5D99-147B-4305-9970-AB0F683A6E8D}.Debug|x64.ActiveCfg = Debug|Any CPU
{3BCE5D99-147B-4305-9970-AB0F683A6E8D}.Debug|x64.Build.0 = Debug|Any CPU
{3BCE5D99-147B-4305-9970-AB0F683A6E8D}.Debug|x86.ActiveCfg = Debug|Any CPU
{3BCE5D99-147B-4305-9970-AB0F683A6E8D}.Debug|x86.Build.0 = Debug|Any CPU
{3BCE5D99-147B-4305-9970-AB0F683A6E8D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3BCE5D99-147B-4305-9970-AB0F683A6E8D}.Release|Any CPU.Build.0 = Release|Any CPU
{3BCE5D99-147B-4305-9970-AB0F683A6E8D}.Release|x64.ActiveCfg = Release|Any CPU
{3BCE5D99-147B-4305-9970-AB0F683A6E8D}.Release|x64.Build.0 = Release|Any CPU
{3BCE5D99-147B-4305-9970-AB0F683A6E8D}.Release|x86.ActiveCfg = Release|Any CPU
{3BCE5D99-147B-4305-9970-AB0F683A6E8D}.Release|x86.Build.0 = Release|Any CPU
{237A1C92-DE9E-4649-961B-BBB7CF0DFE01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{237A1C92-DE9E-4649-961B-BBB7CF0DFE01}.Debug|Any CPU.Build.0 = Debug|Any CPU
{237A1C92-DE9E-4649-961B-BBB7CF0DFE01}.Debug|x64.ActiveCfg = Debug|Any CPU
{237A1C92-DE9E-4649-961B-BBB7CF0DFE01}.Debug|x64.Build.0 = Debug|Any CPU
{237A1C92-DE9E-4649-961B-BBB7CF0DFE01}.Debug|x86.ActiveCfg = Debug|Any CPU
{237A1C92-DE9E-4649-961B-BBB7CF0DFE01}.Debug|x86.Build.0 = Debug|Any CPU
{237A1C92-DE9E-4649-961B-BBB7CF0DFE01}.Release|Any CPU.ActiveCfg = Release|Any CPU
{237A1C92-DE9E-4649-961B-BBB7CF0DFE01}.Release|Any CPU.Build.0 = Release|Any CPU
{237A1C92-DE9E-4649-961B-BBB7CF0DFE01}.Release|x64.ActiveCfg = Release|Any CPU
{237A1C92-DE9E-4649-961B-BBB7CF0DFE01}.Release|x64.Build.0 = Release|Any CPU
{237A1C92-DE9E-4649-961B-BBB7CF0DFE01}.Release|x86.ActiveCfg = Release|Any CPU
{237A1C92-DE9E-4649-961B-BBB7CF0DFE01}.Release|x86.Build.0 = Release|Any CPU
{85F35AAF-D102-4960-8B41-3BD9CBD0E77F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{85F35AAF-D102-4960-8B41-3BD9CBD0E77F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{85F35AAF-D102-4960-8B41-3BD9CBD0E77F}.Debug|x64.ActiveCfg = Debug|Any CPU
{85F35AAF-D102-4960-8B41-3BD9CBD0E77F}.Debug|x64.Build.0 = Debug|Any CPU
{85F35AAF-D102-4960-8B41-3BD9CBD0E77F}.Debug|x86.ActiveCfg = Debug|Any CPU
{85F35AAF-D102-4960-8B41-3BD9CBD0E77F}.Debug|x86.Build.0 = Debug|Any CPU
{85F35AAF-D102-4960-8B41-3BD9CBD0E77F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{85F35AAF-D102-4960-8B41-3BD9CBD0E77F}.Release|Any CPU.Build.0 = Release|Any CPU
{85F35AAF-D102-4960-8B41-3BD9CBD0E77F}.Release|x64.ActiveCfg = Release|Any CPU
{85F35AAF-D102-4960-8B41-3BD9CBD0E77F}.Release|x64.Build.0 = Release|Any CPU
{85F35AAF-D102-4960-8B41-3BD9CBD0E77F}.Release|x86.ActiveCfg = Release|Any CPU
{85F35AAF-D102-4960-8B41-3BD9CBD0E77F}.Release|x86.Build.0 = Release|Any CPU
{5B52C0C0-A554-4E53-9D17-B121E78FF919}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5B52C0C0-A554-4E53-9D17-B121E78FF919}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5B52C0C0-A554-4E53-9D17-B121E78FF919}.Debug|x64.ActiveCfg = Debug|Any CPU
{5B52C0C0-A554-4E53-9D17-B121E78FF919}.Debug|x64.Build.0 = Debug|Any CPU
{5B52C0C0-A554-4E53-9D17-B121E78FF919}.Debug|x86.ActiveCfg = Debug|Any CPU
{5B52C0C0-A554-4E53-9D17-B121E78FF919}.Debug|x86.Build.0 = Debug|Any CPU
{5B52C0C0-A554-4E53-9D17-B121E78FF919}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5B52C0C0-A554-4E53-9D17-B121E78FF919}.Release|Any CPU.Build.0 = Release|Any CPU
{5B52C0C0-A554-4E53-9D17-B121E78FF919}.Release|x64.ActiveCfg = Release|Any CPU
{5B52C0C0-A554-4E53-9D17-B121E78FF919}.Release|x64.Build.0 = Release|Any CPU
{5B52C0C0-A554-4E53-9D17-B121E78FF919}.Release|x86.ActiveCfg = Release|Any CPU
{5B52C0C0-A554-4E53-9D17-B121E78FF919}.Release|x86.Build.0 = Release|Any CPU
{AB8596C1-CFDA-4A5E-9E9C-74A3DF9AED77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AB8596C1-CFDA-4A5E-9E9C-74A3DF9AED77}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AB8596C1-CFDA-4A5E-9E9C-74A3DF9AED77}.Debug|x64.ActiveCfg = Debug|Any CPU
{AB8596C1-CFDA-4A5E-9E9C-74A3DF9AED77}.Debug|x64.Build.0 = Debug|Any CPU
{AB8596C1-CFDA-4A5E-9E9C-74A3DF9AED77}.Debug|x86.ActiveCfg = Debug|Any CPU
{AB8596C1-CFDA-4A5E-9E9C-74A3DF9AED77}.Debug|x86.Build.0 = Debug|Any CPU
{AB8596C1-CFDA-4A5E-9E9C-74A3DF9AED77}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AB8596C1-CFDA-4A5E-9E9C-74A3DF9AED77}.Release|Any CPU.Build.0 = Release|Any CPU
{AB8596C1-CFDA-4A5E-9E9C-74A3DF9AED77}.Release|x64.ActiveCfg = Release|Any CPU
{AB8596C1-CFDA-4A5E-9E9C-74A3DF9AED77}.Release|x64.Build.0 = Release|Any CPU
{AB8596C1-CFDA-4A5E-9E9C-74A3DF9AED77}.Release|x86.ActiveCfg = Release|Any CPU
{AB8596C1-CFDA-4A5E-9E9C-74A3DF9AED77}.Release|x86.Build.0 = Release|Any CPU
{3BEACB10-89FE-4F74-8022-1A52F223CE82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3BEACB10-89FE-4F74-8022-1A52F223CE82}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3BEACB10-89FE-4F74-8022-1A52F223CE82}.Debug|x64.ActiveCfg = Debug|Any CPU
{3BEACB10-89FE-4F74-8022-1A52F223CE82}.Debug|x64.Build.0 = Debug|Any CPU
{3BEACB10-89FE-4F74-8022-1A52F223CE82}.Debug|x86.ActiveCfg = Debug|Any CPU
{3BEACB10-89FE-4F74-8022-1A52F223CE82}.Debug|x86.Build.0 = Debug|Any CPU
{3BEACB10-89FE-4F74-8022-1A52F223CE82}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3BEACB10-89FE-4F74-8022-1A52F223CE82}.Release|Any CPU.Build.0 = Release|Any CPU
{3BEACB10-89FE-4F74-8022-1A52F223CE82}.Release|x64.ActiveCfg = Release|Any CPU
{3BEACB10-89FE-4F74-8022-1A52F223CE82}.Release|x64.Build.0 = Release|Any CPU
{3BEACB10-89FE-4F74-8022-1A52F223CE82}.Release|x86.ActiveCfg = Release|Any CPU
{3BEACB10-89FE-4F74-8022-1A52F223CE82}.Release|x86.Build.0 = Release|Any CPU
{B34EDBC7-C5FB-409D-8472-BC7469D6F2BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B34EDBC7-C5FB-409D-8472-BC7469D6F2BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B34EDBC7-C5FB-409D-8472-BC7469D6F2BD}.Debug|x64.ActiveCfg = Debug|Any CPU
{B34EDBC7-C5FB-409D-8472-BC7469D6F2BD}.Debug|x64.Build.0 = Debug|Any CPU
{B34EDBC7-C5FB-409D-8472-BC7469D6F2BD}.Debug|x86.ActiveCfg = Debug|Any CPU
{B34EDBC7-C5FB-409D-8472-BC7469D6F2BD}.Debug|x86.Build.0 = Debug|Any CPU
{B34EDBC7-C5FB-409D-8472-BC7469D6F2BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B34EDBC7-C5FB-409D-8472-BC7469D6F2BD}.Release|Any CPU.Build.0 = Release|Any CPU
{B34EDBC7-C5FB-409D-8472-BC7469D6F2BD}.Release|x64.ActiveCfg = Release|Any CPU
{B34EDBC7-C5FB-409D-8472-BC7469D6F2BD}.Release|x64.Build.0 = Release|Any CPU
{B34EDBC7-C5FB-409D-8472-BC7469D6F2BD}.Release|x86.ActiveCfg = Release|Any CPU
{B34EDBC7-C5FB-409D-8472-BC7469D6F2BD}.Release|x86.Build.0 = Release|Any CPU
{ADE25B77-2608-4E3E-96B0-6144A6466F84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ADE25B77-2608-4E3E-96B0-6144A6466F84}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ADE25B77-2608-4E3E-96B0-6144A6466F84}.Debug|x64.ActiveCfg = Debug|Any CPU
{ADE25B77-2608-4E3E-96B0-6144A6466F84}.Debug|x64.Build.0 = Debug|Any CPU
{ADE25B77-2608-4E3E-96B0-6144A6466F84}.Debug|x86.ActiveCfg = Debug|Any CPU
{ADE25B77-2608-4E3E-96B0-6144A6466F84}.Debug|x86.Build.0 = Debug|Any CPU
{ADE25B77-2608-4E3E-96B0-6144A6466F84}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ADE25B77-2608-4E3E-96B0-6144A6466F84}.Release|Any CPU.Build.0 = Release|Any CPU
{ADE25B77-2608-4E3E-96B0-6144A6466F84}.Release|x64.ActiveCfg = Release|Any CPU
{ADE25B77-2608-4E3E-96B0-6144A6466F84}.Release|x64.Build.0 = Release|Any CPU
{ADE25B77-2608-4E3E-96B0-6144A6466F84}.Release|x86.ActiveCfg = Release|Any CPU
{ADE25B77-2608-4E3E-96B0-6144A6466F84}.Release|x86.Build.0 = Release|Any CPU
{B40276C5-764C-48AB-91A4-72F3D2A66611}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B40276C5-764C-48AB-91A4-72F3D2A66611}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B40276C5-764C-48AB-91A4-72F3D2A66611}.Debug|x64.ActiveCfg = Debug|Any CPU
{B40276C5-764C-48AB-91A4-72F3D2A66611}.Debug|x64.Build.0 = Debug|Any CPU
{B40276C5-764C-48AB-91A4-72F3D2A66611}.Debug|x86.ActiveCfg = Debug|Any CPU
{B40276C5-764C-48AB-91A4-72F3D2A66611}.Debug|x86.Build.0 = Debug|Any CPU
{B40276C5-764C-48AB-91A4-72F3D2A66611}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B40276C5-764C-48AB-91A4-72F3D2A66611}.Release|Any CPU.Build.0 = Release|Any CPU
{B40276C5-764C-48AB-91A4-72F3D2A66611}.Release|x64.ActiveCfg = Release|Any CPU
{B40276C5-764C-48AB-91A4-72F3D2A66611}.Release|x64.Build.0 = Release|Any CPU
{B40276C5-764C-48AB-91A4-72F3D2A66611}.Release|x86.ActiveCfg = Release|Any CPU
{B40276C5-764C-48AB-91A4-72F3D2A66611}.Release|x86.Build.0 = Release|Any CPU
{934FE26D-885D-4FAD-9AFC-BFA975DFCBB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{934FE26D-885D-4FAD-9AFC-BFA975DFCBB5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{934FE26D-885D-4FAD-9AFC-BFA975DFCBB5}.Debug|x64.ActiveCfg = Debug|Any CPU
{934FE26D-885D-4FAD-9AFC-BFA975DFCBB5}.Debug|x64.Build.0 = Debug|Any CPU
{934FE26D-885D-4FAD-9AFC-BFA975DFCBB5}.Debug|x86.ActiveCfg = Debug|Any CPU
{934FE26D-885D-4FAD-9AFC-BFA975DFCBB5}.Debug|x86.Build.0 = Debug|Any CPU
{934FE26D-885D-4FAD-9AFC-BFA975DFCBB5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{934FE26D-885D-4FAD-9AFC-BFA975DFCBB5}.Release|Any CPU.Build.0 = Release|Any CPU
{934FE26D-885D-4FAD-9AFC-BFA975DFCBB5}.Release|x64.ActiveCfg = Release|Any CPU
{934FE26D-885D-4FAD-9AFC-BFA975DFCBB5}.Release|x64.Build.0 = Release|Any CPU
{934FE26D-885D-4FAD-9AFC-BFA975DFCBB5}.Release|x86.ActiveCfg = Release|Any CPU
{934FE26D-885D-4FAD-9AFC-BFA975DFCBB5}.Release|x86.Build.0 = Release|Any CPU
{C68D858A-BAE7-4365-8A0B-CBFDDE3257E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C68D858A-BAE7-4365-8A0B-CBFDDE3257E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C68D858A-BAE7-4365-8A0B-CBFDDE3257E7}.Debug|x64.ActiveCfg = Debug|Any CPU
{C68D858A-BAE7-4365-8A0B-CBFDDE3257E7}.Debug|x64.Build.0 = Debug|Any CPU
{C68D858A-BAE7-4365-8A0B-CBFDDE3257E7}.Debug|x86.ActiveCfg = Debug|Any CPU
{C68D858A-BAE7-4365-8A0B-CBFDDE3257E7}.Debug|x86.Build.0 = Debug|Any CPU
{C68D858A-BAE7-4365-8A0B-CBFDDE3257E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C68D858A-BAE7-4365-8A0B-CBFDDE3257E7}.Release|Any CPU.Build.0 = Release|Any CPU
{C68D858A-BAE7-4365-8A0B-CBFDDE3257E7}.Release|x64.ActiveCfg = Release|Any CPU
{C68D858A-BAE7-4365-8A0B-CBFDDE3257E7}.Release|x64.Build.0 = Release|Any CPU
{C68D858A-BAE7-4365-8A0B-CBFDDE3257E7}.Release|x86.ActiveCfg = Release|Any CPU
{C68D858A-BAE7-4365-8A0B-CBFDDE3257E7}.Release|x86.Build.0 = Release|Any CPU
{6E635156-2BF9-471B-94A3-3BFE3D40169F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6E635156-2BF9-471B-94A3-3BFE3D40169F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6E635156-2BF9-471B-94A3-3BFE3D40169F}.Debug|x64.ActiveCfg = Debug|Any CPU
{6E635156-2BF9-471B-94A3-3BFE3D40169F}.Debug|x64.Build.0 = Debug|Any CPU
{6E635156-2BF9-471B-94A3-3BFE3D40169F}.Debug|x86.ActiveCfg = Debug|Any CPU
{6E635156-2BF9-471B-94A3-3BFE3D40169F}.Debug|x86.Build.0 = Debug|Any CPU
{6E635156-2BF9-471B-94A3-3BFE3D40169F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6E635156-2BF9-471B-94A3-3BFE3D40169F}.Release|Any CPU.Build.0 = Release|Any CPU
{6E635156-2BF9-471B-94A3-3BFE3D40169F}.Release|x64.ActiveCfg = Release|Any CPU
{6E635156-2BF9-471B-94A3-3BFE3D40169F}.Release|x64.Build.0 = Release|Any CPU
{6E635156-2BF9-471B-94A3-3BFE3D40169F}.Release|x86.ActiveCfg = Release|Any CPU
{6E635156-2BF9-471B-94A3-3BFE3D40169F}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{91B6272F-5780-4C94-8071-DBBA7B4F67F3} = {9E5F0022-0A50-40BF-AC6A-C3078585ECAB}
{C0C8D381-D6B9-4C76-9428-F40F2FA93A9A} = {9E5F0022-0A50-40BF-AC6A-C3078585ECAB}
{5DFDF781-F24C-45B1-82EF-9125875A80A4} = {9E5F0022-0A50-40BF-AC6A-C3078585ECAB}
{73A1BE1C-9C8A-43FA-86A8-BF2744B4C1BB} = {8CEC2042-F11C-49F5-A674-2355793B600A}
{188219D1-D123-46C9-B905-A9ED30E6AAA7} = {9E5F0022-0A50-40BF-AC6A-C3078585ECAB}
{3BCE5D99-147B-4305-9970-AB0F683A6E8D} = {8CEC2042-F11C-49F5-A674-2355793B600A}
{237A1C92-DE9E-4649-961B-BBB7CF0DFE01} = {8CEC2042-F11C-49F5-A674-2355793B600A}
{85F35AAF-D102-4960-8B41-3BD9CBD0E77F} = {9E5F0022-0A50-40BF-AC6A-C3078585ECAB}
{5B52C0C0-A554-4E53-9D17-B121E78FF919} = {8CEC2042-F11C-49F5-A674-2355793B600A}
{AB8596C1-CFDA-4A5E-9E9C-74A3DF9AED77} = {9E5F0022-0A50-40BF-AC6A-C3078585ECAB}
{3BEACB10-89FE-4F74-8022-1A52F223CE82} = {5D8E1F81-B820-4736-B797-271B0FE787EE}
{B34EDBC7-C5FB-409D-8472-BC7469D6F2BD} = {9E5F0022-0A50-40BF-AC6A-C3078585ECAB}
{A1D7653A-C409-414A-B9B0-7879953EBCDD} = {9E5F0022-0A50-40BF-AC6A-C3078585ECAB}
{ADE25B77-2608-4E3E-96B0-6144A6466F84} = {9E5F0022-0A50-40BF-AC6A-C3078585ECAB}
{B40276C5-764C-48AB-91A4-72F3D2A66611} = {9E5F0022-0A50-40BF-AC6A-C3078585ECAB}
{934FE26D-885D-4FAD-9AFC-BFA975DFCBB5} = {9E5F0022-0A50-40BF-AC6A-C3078585ECAB}
{C68D858A-BAE7-4365-8A0B-CBFDDE3257E7} = {64FBB8EE-5430-4BD8-95B3-DC69AD2E3D9D}
{64FBB8EE-5430-4BD8-95B3-DC69AD2E3D9D} = {8CEC2042-F11C-49F5-A674-2355793B600A}
{6E635156-2BF9-471B-94A3-3BFE3D40169F} = {8CEC2042-F11C-49F5-A674-2355793B600A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {160A1D00-1F5B-40F8-A155-621B4459D78F}
EndGlobalSection
EndGlobal

View File

@ -1,120 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.329
MinimumVisualStudioVersion = 15.0.26124.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{9E5F0022-0A50-40BF-AC6A-C3078585ECAB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{8CEC2042-F11C-49F5-A674-2355793B600A}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Datadog.Trace.ClrProfiler.Native.Tests", "test\Datadog.Trace.ClrProfiler.Native.Tests\Datadog.Trace.ClrProfiler.Native.Tests.vcxproj", "{5728056A-51AA-4FF5-AD0C-E86E44E36102}"
ProjectSection(ProjectDependencies) = postProject
{6CE95C50-9533-4650-8F11-BCE30908DCDF} = {6CE95C50-9533-4650-8F11-BCE30908DCDF}
{901F02A8-8776-4D18-80C9-05C58262C1C7} = {901F02A8-8776-4D18-80C9-05C58262C1C7}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Datadog.Trace.ClrProfiler.Native", "src\Datadog.Trace.ClrProfiler.Native\Datadog.Trace.ClrProfiler.Native.vcxproj", "{91B6272F-5780-4C94-8071-DBBA7B4F67F3}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Datadog.Trace.ClrProfiler.Native.DLL", "src\Datadog.Trace.ClrProfiler.Native\Datadog.Trace.ClrProfiler.Native.DLL.vcxproj", "{C0C8D381-D6B9-4C76-9428-F40F2FA93A9A}"
ProjectSection(ProjectDependencies) = postProject
{0686E907-996A-4D6D-A685-D9C0F932C405} = {0686E907-996A-4D6D-A685-D9C0F932C405}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sample-libs", "sample-libs", "{B9AA20A4-0F9A-47FB-B3BE-A5BDEA42EFF0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.ExampleLibrary", "test\test-applications\integrations\dependency-libs\Samples.ExampleLibrary\Samples.ExampleLibrary.csproj", "{901F02A8-8776-4D18-80C9-05C58262C1C7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.ExampleLibraryTracer", "test\test-applications\integrations\dependency-libs\Samples.ExampleLibraryTracer\Samples.ExampleLibraryTracer.csproj", "{6CE95C50-9533-4650-8F11-BCE30908DCDF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Datadog.Trace.ClrProfiler.Managed.Loader", "src\Datadog.Trace.ClrProfiler.Managed.Loader\Datadog.Trace.ClrProfiler.Managed.Loader.csproj", "{0686E907-996A-4D6D-A685-D9C0F932C405}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5728056A-51AA-4FF5-AD0C-E86E44E36102}.Debug|Any CPU.ActiveCfg = Debug|Win32
{5728056A-51AA-4FF5-AD0C-E86E44E36102}.Debug|x64.ActiveCfg = Debug|x64
{5728056A-51AA-4FF5-AD0C-E86E44E36102}.Debug|x64.Build.0 = Debug|x64
{5728056A-51AA-4FF5-AD0C-E86E44E36102}.Debug|x86.ActiveCfg = Debug|Win32
{5728056A-51AA-4FF5-AD0C-E86E44E36102}.Release|Any CPU.ActiveCfg = Release|Win32
{5728056A-51AA-4FF5-AD0C-E86E44E36102}.Release|x64.ActiveCfg = Release|x64
{5728056A-51AA-4FF5-AD0C-E86E44E36102}.Release|x64.Build.0 = Release|x64
{5728056A-51AA-4FF5-AD0C-E86E44E36102}.Release|x86.ActiveCfg = Release|Win32
{5728056A-51AA-4FF5-AD0C-E86E44E36102}.Release|x86.Build.0 = Release|Win32
{91B6272F-5780-4C94-8071-DBBA7B4F67F3}.Debug|Any CPU.ActiveCfg = Debug|Win32
{91B6272F-5780-4C94-8071-DBBA7B4F67F3}.Debug|x64.ActiveCfg = Debug|x64
{91B6272F-5780-4C94-8071-DBBA7B4F67F3}.Debug|x64.Build.0 = Debug|x64
{91B6272F-5780-4C94-8071-DBBA7B4F67F3}.Debug|x86.ActiveCfg = Debug|Win32
{91B6272F-5780-4C94-8071-DBBA7B4F67F3}.Debug|x86.Build.0 = Debug|Win32
{91B6272F-5780-4C94-8071-DBBA7B4F67F3}.Release|Any CPU.ActiveCfg = Release|Win32
{91B6272F-5780-4C94-8071-DBBA7B4F67F3}.Release|x64.ActiveCfg = Release|x64
{91B6272F-5780-4C94-8071-DBBA7B4F67F3}.Release|x64.Build.0 = Release|x64
{91B6272F-5780-4C94-8071-DBBA7B4F67F3}.Release|x86.ActiveCfg = Release|Win32
{91B6272F-5780-4C94-8071-DBBA7B4F67F3}.Release|x86.Build.0 = Release|Win32
{C0C8D381-D6B9-4C76-9428-F40F2FA93A9A}.Debug|Any CPU.ActiveCfg = Debug|Win32
{C0C8D381-D6B9-4C76-9428-F40F2FA93A9A}.Debug|x64.ActiveCfg = Debug|x64
{C0C8D381-D6B9-4C76-9428-F40F2FA93A9A}.Debug|x64.Build.0 = Debug|x64
{C0C8D381-D6B9-4C76-9428-F40F2FA93A9A}.Debug|x86.ActiveCfg = Debug|Win32
{C0C8D381-D6B9-4C76-9428-F40F2FA93A9A}.Debug|x86.Build.0 = Debug|Win32
{C0C8D381-D6B9-4C76-9428-F40F2FA93A9A}.Release|Any CPU.ActiveCfg = Release|Win32
{C0C8D381-D6B9-4C76-9428-F40F2FA93A9A}.Release|x64.ActiveCfg = Release|x64
{C0C8D381-D6B9-4C76-9428-F40F2FA93A9A}.Release|x64.Build.0 = Release|x64
{C0C8D381-D6B9-4C76-9428-F40F2FA93A9A}.Release|x86.ActiveCfg = Release|Win32
{C0C8D381-D6B9-4C76-9428-F40F2FA93A9A}.Release|x86.Build.0 = Release|Win32
{901F02A8-8776-4D18-80C9-05C58262C1C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{901F02A8-8776-4D18-80C9-05C58262C1C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{901F02A8-8776-4D18-80C9-05C58262C1C7}.Debug|x64.ActiveCfg = Debug|Any CPU
{901F02A8-8776-4D18-80C9-05C58262C1C7}.Debug|x64.Build.0 = Debug|Any CPU
{901F02A8-8776-4D18-80C9-05C58262C1C7}.Debug|x86.ActiveCfg = Debug|Any CPU
{901F02A8-8776-4D18-80C9-05C58262C1C7}.Debug|x86.Build.0 = Debug|Any CPU
{901F02A8-8776-4D18-80C9-05C58262C1C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{901F02A8-8776-4D18-80C9-05C58262C1C7}.Release|Any CPU.Build.0 = Release|Any CPU
{901F02A8-8776-4D18-80C9-05C58262C1C7}.Release|x64.ActiveCfg = Release|Any CPU
{901F02A8-8776-4D18-80C9-05C58262C1C7}.Release|x64.Build.0 = Release|Any CPU
{901F02A8-8776-4D18-80C9-05C58262C1C7}.Release|x86.ActiveCfg = Release|Any CPU
{901F02A8-8776-4D18-80C9-05C58262C1C7}.Release|x86.Build.0 = Release|Any CPU
{6CE95C50-9533-4650-8F11-BCE30908DCDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6CE95C50-9533-4650-8F11-BCE30908DCDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6CE95C50-9533-4650-8F11-BCE30908DCDF}.Debug|x64.ActiveCfg = Debug|Any CPU
{6CE95C50-9533-4650-8F11-BCE30908DCDF}.Debug|x64.Build.0 = Debug|Any CPU
{6CE95C50-9533-4650-8F11-BCE30908DCDF}.Debug|x86.ActiveCfg = Debug|Any CPU
{6CE95C50-9533-4650-8F11-BCE30908DCDF}.Debug|x86.Build.0 = Debug|Any CPU
{6CE95C50-9533-4650-8F11-BCE30908DCDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6CE95C50-9533-4650-8F11-BCE30908DCDF}.Release|Any CPU.Build.0 = Release|Any CPU
{6CE95C50-9533-4650-8F11-BCE30908DCDF}.Release|x64.ActiveCfg = Release|Any CPU
{6CE95C50-9533-4650-8F11-BCE30908DCDF}.Release|x64.Build.0 = Release|Any CPU
{6CE95C50-9533-4650-8F11-BCE30908DCDF}.Release|x86.ActiveCfg = Release|Any CPU
{6CE95C50-9533-4650-8F11-BCE30908DCDF}.Release|x86.Build.0 = Release|Any CPU
{0686E907-996A-4D6D-A685-D9C0F932C405}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0686E907-996A-4D6D-A685-D9C0F932C405}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0686E907-996A-4D6D-A685-D9C0F932C405}.Debug|x64.ActiveCfg = Debug|Any CPU
{0686E907-996A-4D6D-A685-D9C0F932C405}.Debug|x64.Build.0 = Debug|Any CPU
{0686E907-996A-4D6D-A685-D9C0F932C405}.Debug|x86.ActiveCfg = Debug|Any CPU
{0686E907-996A-4D6D-A685-D9C0F932C405}.Debug|x86.Build.0 = Debug|Any CPU
{0686E907-996A-4D6D-A685-D9C0F932C405}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0686E907-996A-4D6D-A685-D9C0F932C405}.Release|Any CPU.Build.0 = Release|Any CPU
{0686E907-996A-4D6D-A685-D9C0F932C405}.Release|x64.ActiveCfg = Release|Any CPU
{0686E907-996A-4D6D-A685-D9C0F932C405}.Release|x64.Build.0 = Release|Any CPU
{0686E907-996A-4D6D-A685-D9C0F932C405}.Release|x86.ActiveCfg = Release|Any CPU
{0686E907-996A-4D6D-A685-D9C0F932C405}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{5728056A-51AA-4FF5-AD0C-E86E44E36102} = {8CEC2042-F11C-49F5-A674-2355793B600A}
{91B6272F-5780-4C94-8071-DBBA7B4F67F3} = {9E5F0022-0A50-40BF-AC6A-C3078585ECAB}
{C0C8D381-D6B9-4C76-9428-F40F2FA93A9A} = {9E5F0022-0A50-40BF-AC6A-C3078585ECAB}
{901F02A8-8776-4D18-80C9-05C58262C1C7} = {B9AA20A4-0F9A-47FB-B3BE-A5BDEA42EFF0}
{6CE95C50-9533-4650-8F11-BCE30908DCDF} = {B9AA20A4-0F9A-47FB-B3BE-A5BDEA42EFF0}
{0686E907-996A-4D6D-A685-D9C0F932C405} = {9E5F0022-0A50-40BF-AC6A-C3078585ECAB}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {160A1D00-1F5B-40F8-A155-621B4459D78F}
EndGlobalSection
EndGlobal

File diff suppressed because it is too large Load Diff

View File

@ -27,18 +27,11 @@ cd "$DIR/../.."
BUILD_TYPE=${buildConfiguration:-Debug}
OUTDIR="$( pwd )/src/Datadog.Trace.ClrProfiler.Native/bin/${BUILD_TYPE}/x64"
# If running the unified pipeline, do not copy managed assets yet. Do so during the package build step
if [ -z "${UNIFIED_PIPELINE-}" ]; then
PUBLISH_OUTPUT_MANAGED="$( pwd )/src/bin/managed-publish"
mkdir -p ${OUTDIR}/
cp -fr ${PUBLISH_OUTPUT_MANAGED}/* ${OUTDIR}/
fi
os=$(uname_os)
case "$os" in
windows*)
msbuild.exe Datadog.Trace.proj -t:BuildCpp -p:TracerHomeDirectory=${OUTDIR} -p:Configuration=${BUILD_TYPE} -p:Platform=x64
nuget restore "src\Datadog.Trace.ClrProfiler.Native\Datadog.Trace.ClrProfiler.Native.vcxproj" -SolutionDirectory .
msbuild.exe Datadog.Trace.proj -t:BuildCpp -p:Configuration=${BUILD_TYPE} -p:Platform=x64
;;
*)

View File

@ -16,74 +16,5 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
cd "$DIR/../.."
buildConfiguration=${buildConfiguration:-Debug}
publishTargetFramework=${publishTargetFramework:-netcoreapp3.1}
PUBLISH_OUTPUT="$( pwd )/src/bin/managed-publish"
os=$(uname_os)
mkdir -p "$PUBLISH_OUTPUT/netstandard2.0"
mkdir -p "$PUBLISH_OUTPUT/netcoreapp3.1"
if [ "$os" == "windows" ]
then
mkdir -p "$PUBLISH_OUTPUT/net45"
mkdir -p "$PUBLISH_OUTPUT/net461"
fi
dotnet build -c $buildConfiguration src/Datadog.Trace.ClrProfiler.Managed.Loader/Datadog.Trace.ClrProfiler.Managed.Loader.csproj
for proj in Datadog.Trace Datadog.Trace.OpenTracing ; do
dotnet publish -f netstandard2.0 -c $buildConfiguration src/$proj/$proj.csproj
dotnet publish -f netcoreapp3.1 -c $buildConfiguration src/$proj/$proj.csproj
if [ "$os" == "windows" ]
then
dotnet publish -f net45 -c $buildConfiguration src/$proj/$proj.csproj
dotnet publish -f net461 -c $buildConfiguration src/$proj/$proj.csproj
fi
done
dotnet publish -f netstandard2.0 -c $buildConfiguration src/Datadog.Trace.ClrProfiler.Managed/Datadog.Trace.ClrProfiler.Managed.csproj -o "$PUBLISH_OUTPUT/netstandard2.0"
dotnet publish -f netcoreapp3.1 -c $buildConfiguration src/Datadog.Trace.ClrProfiler.Managed/Datadog.Trace.ClrProfiler.Managed.csproj -o "$PUBLISH_OUTPUT/netcoreapp3.1"
if [ "$os" == "windows" ]
then
dotnet publish -f net45 -c $buildConfiguration src/Datadog.Trace.ClrProfiler.Managed/Datadog.Trace.ClrProfiler.Managed.csproj -o "$PUBLISH_OUTPUT/net45"
dotnet publish -f net461 -c $buildConfiguration src/Datadog.Trace.ClrProfiler.Managed/Datadog.Trace.ClrProfiler.Managed.csproj -o "$PUBLISH_OUTPUT/net461"
fi
# Exit if QUICK_BUILD env var is not empty
if [ -n "${QUICK_BUILD-}" ]
then
exit
fi
# Only build Samples.AspNetCoreMvc21 for netcoreapp2.1
if [ "$publishTargetFramework" == "netcoreapp2.1" ]
then
dotnet publish -f $publishTargetFramework -c $buildConfiguration test/test-applications/integrations/Samples.AspNetCoreMvc21/Samples.AspNetCoreMvc21.csproj -p:Configuration=$buildConfiguration -p:ManagedProfilerOutputDirectory="$PUBLISH_OUTPUT"
fi
# Only build Samples.AspNetCoreMvc30 for netcoreapp3.0
if [ "$publishTargetFramework" == "netcoreapp3.0" ]
then
dotnet publish -f $publishTargetFramework -c $buildConfiguration test/test-applications/integrations/Samples.AspNetCoreMvc30/Samples.AspNetCoreMvc30.csproj -p:Configuration=$buildConfiguration -p:ManagedProfilerOutputDirectory="$PUBLISH_OUTPUT"
fi
# Only build Samples.AspNetCoreMvc31 for netcoreapp3.1
if [ "$publishTargetFramework" == "netcoreapp3.1" ]
then
dotnet publish -f $publishTargetFramework -c $buildConfiguration test/test-applications/integrations/Samples.AspNetCoreMvc31/Samples.AspNetCoreMvc31.csproj -p:Configuration=$buildConfiguration -p:ManagedProfilerOutputDirectory="$PUBLISH_OUTPUT"
fi
dotnet publish -f $publishTargetFramework -c $buildConfiguration test/test-applications/instrumentation/CallTargetNativeTest/CallTargetNativeTest.csproj -p:Configuration=$buildConfiguration -p:ManagedProfilerOutputDirectory="$PUBLISH_OUTPUT"
for sample in Samples.Elasticsearch Samples.Elasticsearch.V5 Samples.ServiceStack.Redis Samples.StackExchange.Redis Samples.SqlServer Samples.Microsoft.Data.SqlClient Samples.MongoDB Samples.HttpMessageHandler Samples.WebRequest Samples.Npgsql Samples.MySql Samples.GraphQL Samples.Dapper Samples.NoMultiLoader Samples.RabbitMQ Samples.RuntimeMetrics Samples.FakeDbCommand Samples.Microsoft.Data.Sqlite Samples.SQLite.Core Samples.OracleMDA Samples.OracleMDA.Core ; do
dotnet publish -f $publishTargetFramework -c $buildConfiguration test/test-applications/integrations/$sample/$sample.csproj -p:Configuration=$buildConfiguration -p:ManagedProfilerOutputDirectory="$PUBLISH_OUTPUT"
done
for sample in DataDogThreadTest HttpMessageHandler.StackOverflowException StackExchange.Redis.StackOverflowException AspNetMvcCorePerformance AssemblyLoad.FileNotFoundException TraceContext.InvalidOperationException AssemblyResolveMscorlibResources.InfiniteRecursionCrash StackExchange.Redis.AssemblyConflict.SdkProject NetCoreAssemblyLoadFailureOlderNuGet DuplicateTypeProxy ; do
dotnet publish -f $publishTargetFramework -c $buildConfiguration test/test-applications/regression/$sample/$sample.csproj -p:Configuration=$buildConfiguration -p:ManagedProfilerOutputDirectory="$PUBLISH_OUTPUT"
done
dotnet msbuild Datadog.Trace.proj -t:RestoreAndBuildSamplesForPackageVersions -p:Configuration=$buildConfiguration -p:ManagedProfilerOutputDirectory="$PUBLISH_OUTPUT" -p:TargetFramework=$publishTargetFramework
for proj in Datadog.Trace.IntegrationTests Datadog.Trace.OpenTracing.IntegrationTests Datadog.Trace.ClrProfiler.IntegrationTests ; do
dotnet publish -f $publishTargetFramework -c $buildConfiguration test/$proj/$proj.csproj
done

View File

@ -1,246 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Text;
using Datadog.Trace.ClrProfiler;
using Newtonsoft.Json;
namespace PrepareRelease
{
public static class GenerateIntegrationDefinitions
{
public static void Run(params string[] outputDirectories)
{
Console.WriteLine("Updating the integrations definitions");
var assemblies = new List<Assembly>();
assemblies.Add(typeof(Instrumentation).Assembly);
// Extract all InstrumentMethodAttribute at assembly scope level
var assemblyInstrumentMethodAttributes = from assembly in assemblies
let attributes = assembly.GetCustomAttributes(inherit: false)
.Select(a => a as InstrumentMethodAttribute)
.Where(a => a != null).ToList()
from attribute in attributes
let callTargetClassCheck = attribute.CallTargetType
?? throw new NullReferenceException($"The usage of InstrumentMethodAttribute[Type={attribute.TypeName}, Method={attribute.MethodName}] in assembly scope must define the CallTargetType property.")
select attribute;
// Extract all InstrumentMethodAttribute from the classes
var classesInstrumentMethodAttributes = from assembly in assemblies
from wrapperType in assembly.GetTypes()
let attributes = wrapperType.GetCustomAttributes(inherit: false)
.Select(a => a as InstrumentMethodAttribute)
.Where(a => a != null)
.Select(a =>
{
a.CallTargetType = wrapperType;
return a;
}).ToList()
from attribute in attributes
select attribute;
// combine all InstrumentMethodAttributes
// and create objects that will generate correct JSON schema
var callTargetIntegrations = from attribute in assemblyInstrumentMethodAttributes.Concat(classesInstrumentMethodAttributes)
let integrationName = attribute.IntegrationName
let assembly = attribute.CallTargetType.Assembly
let wrapperType = attribute.CallTargetType
orderby integrationName
group new
{
assembly,
wrapperType,
attribute
}
by integrationName into g
select new
{
name = g.Key,
method_replacements = from item in g
from assembly in item.attribute.AssemblyNames
select new
{
caller = new
{
assembly = (string)null,
type = (string)null,
method = (string)null
},
target = new
{
assembly = assembly,
type = item.attribute.TypeName,
method = item.attribute.MethodName,
signature = (string)null,
signature_types = new string[] { item.attribute.ReturnTypeName }.Concat(item.attribute.ParameterTypeNames ?? Enumerable.Empty<string>()).ToArray(),
minimum_major = item.attribute.VersionRange.MinimumMajor,
minimum_minor = item.attribute.VersionRange.MinimumMinor,
minimum_patch = item.attribute.VersionRange.MinimumPatch,
maximum_major = item.attribute.VersionRange.MaximumMajor,
maximum_minor = item.attribute.VersionRange.MaximumMinor,
maximum_patch = item.attribute.VersionRange.MaximumPatch
},
wrapper = new
{
assembly = item.assembly.FullName,
type = item.wrapperType.FullName,
method = (string)null,
signature = (string)null,
action = MethodReplacementActionType.CallTargetModification.ToString()
}
}
};
// find all methods in OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed.dll with [InterceptMethod]
// and create objects that will generate correct JSON schema
var integrations = from assembly in assemblies
from wrapperType in assembly.GetTypes()
from wrapperMethod in wrapperType.GetRuntimeMethods()
let attributes = wrapperMethod.GetCustomAttributes<InterceptMethodAttribute>(inherit: false)
where attributes.Any()
from attribute in attributes
let integrationName = attribute.Integration ?? GetIntegrationName(wrapperType)
orderby integrationName
group new
{
assembly,
wrapperType,
wrapperMethod,
attribute
}
by integrationName into g
select new
{
name = g.Key,
method_replacements = from item in g
from targetAssembly in item.attribute.TargetAssemblies
select new
{
caller = new
{
assembly = item.attribute.CallerAssembly,
type = item.attribute.CallerType,
method = item.attribute.CallerMethod
},
target = new
{
assembly = targetAssembly,
type = item.attribute.TargetType,
method = item.attribute.TargetMethod ?? item.wrapperMethod.Name,
signature = item.attribute.TargetSignature,
signature_types = item.attribute.TargetSignatureTypes,
minimum_major = item.attribute.TargetVersionRange.MinimumMajor,
minimum_minor = item.attribute.TargetVersionRange.MinimumMinor,
minimum_patch = item.attribute.TargetVersionRange.MinimumPatch,
maximum_major = item.attribute.TargetVersionRange.MaximumMajor,
maximum_minor = item.attribute.TargetVersionRange.MaximumMinor,
maximum_patch = item.attribute.TargetVersionRange.MaximumPatch
},
wrapper = new
{
assembly = item.assembly.FullName,
type = item.wrapperType.FullName,
method = item.wrapperMethod.Name,
signature = GetMethodSignature(item.wrapperMethod, item.attribute),
action = item.attribute.MethodReplacementAction.ToString()
}
}
};
var serializerSettings = new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
Formatting = Formatting.Indented
};
var json = JsonConvert.SerializeObject(callTargetIntegrations.Concat(integrations), serializerSettings);
Console.WriteLine(json);
foreach (var outputDirectory in outputDirectories)
{
var filename = Path.Combine(outputDirectory, "integrations.json");
var utf8NoBom = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false);
File.WriteAllText(filename, json, utf8NoBom);
}
}
private static string GetIntegrationName(Type wrapperType)
{
const string integrations = "Integration";
var typeName = wrapperType.Name;
if (typeName.EndsWith(integrations, StringComparison.OrdinalIgnoreCase))
{
return typeName.Substring(startIndex: 0, length: typeName.Length - integrations.Length);
}
return typeName;
}
private static string GetMethodSignature(MethodInfo method, InterceptMethodAttribute attribute)
{
var returnType = method.ReturnType;
var parameters = method.GetParameters().Select(p => p.ParameterType).ToArray();
var requiredParameterTypes = new[] { typeof(int), typeof(int), typeof(long) };
var lastParameterTypes = parameters.Skip(parameters.Length - requiredParameterTypes.Length);
if (attribute.MethodReplacementAction == MethodReplacementActionType.ReplaceTargetMethod)
{
if (!lastParameterTypes.SequenceEqual(requiredParameterTypes))
{
throw new Exception(
$"Method {method.DeclaringType.FullName}.{method.Name}() does not meet parameter requirements. " +
"Wrapper methods must have at least 3 parameters and the last 3 must be of types Int32 (opCode), Int32 (mdToken), and Int64 (moduleVersionPtr).");
}
}
else if (attribute.MethodReplacementAction == MethodReplacementActionType.InsertFirst)
{
if (attribute.CallerAssembly == null || attribute.CallerType == null || attribute.CallerMethod == null)
{
throw new Exception(
$"Method {method.DeclaringType.FullName}.{method.Name}() does not meet InterceptMethodAttribute requirements. " +
"Currently, InsertFirst methods must have CallerAssembly, CallerType, and CallerMethod defined. " +
$"Current values: CallerAssembly=\"{attribute.CallerAssembly}\", CallerType=\"{attribute.CallerType}\", CallerMethod=\"{attribute.CallerMethod}\"");
}
else if (parameters.Any())
{
throw new Exception(
$"Method {method.DeclaringType.FullName}.{method.Name}() does not meet parameter requirements. " +
"Currently, InsertFirst methods must have zero parameters.");
}
else if (returnType != typeof(void))
{
throw new Exception(
$"Method {method.DeclaringType.FullName}.{method.Name}() does not meet return type requirements. " +
"Currently, InsertFirst methods must have a void return type.");
}
}
var signatureHelper = SignatureHelper.GetMethodSigHelper(method.CallingConvention, returnType);
signatureHelper.AddArguments(parameters, requiredCustomModifiers: null, optionalCustomModifiers: null);
var signatureBytes = signatureHelper.GetSignature();
if (method.IsGenericMethod)
{
// if method is generic, fix first byte (calling convention)
// and insert a second byte with generic parameter count
const byte IMAGE_CEE_CS_CALLCONV_GENERIC = 0x10;
var genericArguments = method.GetGenericArguments();
var newSignatureBytes = new byte[signatureBytes.Length + 1];
newSignatureBytes[0] = (byte)(signatureBytes[0] | IMAGE_CEE_CS_CALLCONV_GENERIC);
newSignatureBytes[1] = (byte)genericArguments.Length;
Array.Copy(signatureBytes, 1, newSignatureBytes, 2, signatureBytes.Length - 1);
signatureBytes = newSignatureBytes;
}
return string.Join(" ", signatureBytes.Select(b => b.ToString("X2")));
}
}
}

View File

@ -1,14 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework Condition="'$(OS)' == 'Windows_NT'">net461</TargetFramework>
<TargetFramework Condition="'$(OS)' != 'Windows_NT'">netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\src\Datadog.Trace.ClrProfiler.Managed\Datadog.Trace.ClrProfiler.Managed.csproj" />
<ProjectReference Include="..\..\..\tools\Datadog.Core.Tools\Datadog.Core.Tools.csproj" />
</ItemGroup>
</Project>

View File

@ -1,68 +0,0 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Datadog.Core.Tools;
namespace PrepareRelease
{
public class Program
{
public const string Versions = "versions";
public const string Integrations = "integrations";
public const string Msi = "msi";
public static void Main(string[] args)
{
if (args.Length == 0)
{
throw new ArgumentException($@"You must specify at least one job name from [""{Versions}"", ""{Integrations}, ""{Msi}""].");
}
var solutionDir = EnvironmentTools.GetSolutionDirectory();
if (JobShouldRun(Integrations, args))
{
Console.WriteLine("--------------- Integrations Job Started ---------------");
GenerateIntegrationDefinitions.Run(solutionDir);
Console.WriteLine("--------------- Integrations Job Complete ---------------");
}
if (JobShouldRun(Versions, args))
{
Console.WriteLine("--------------- Versions Job Started ---------------");
SetAllVersions.Run();
Console.WriteLine("--------------- Versions Job Complete ---------------");
}
if (JobShouldRun(Msi, args))
{
Environment.SetEnvironmentVariable("SOLUTION_DIR", solutionDir);
var outputDir = Path.Combine(solutionDir, "src", "bin", "windows-tracer-home");
Environment.SetEnvironmentVariable("OUTPUT_DIR", outputDir);
var publishBatch = Path.Combine(solutionDir, "build", "tools", "PrepareRelease", "publish-all.bat");
ExecuteCommand(publishBatch);
Console.WriteLine("--------------- MSI Job Started ---------------");
SyncMsiContent.Run(solutionDir, outputDir);
Console.WriteLine("--------------- MSI Job Complete ---------------");
}
}
private static bool JobShouldRun(string jobName, string[] args)
{
return args.Any(a => string.Equals(a, jobName, StringComparison.OrdinalIgnoreCase));
}
private static void ExecuteCommand(string command)
{
var processInfo = new ProcessStartInfo("cmd.exe", "/c " + command) { CreateNoWindow = true, UseShellExecute = true };
var process = Process.Start(processInfo);
process.WaitForExit(120_000);
Console.WriteLine("Publish ExitCode: " + process.ExitCode, "ExecuteCommand");
process?.Close();
}
}
}

View File

@ -1,8 +0,0 @@
{
"profiles": {
"PrepareRelease": {
"commandName": "Project",
"commandLineArgs": "versions integrations msi"
}
}
}

View File

@ -1,266 +0,0 @@
using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using Datadog.Core.Tools;
namespace PrepareRelease
{
public static class SetAllVersions
{
public static void Run()
{
Console.WriteLine($"Updating version instances to {VersionString()}");
// Sample application package updates
SynchronizeVersion(
"samples/AutomaticTraceIdInjection/Log4NetExample/Log4NetExample.csproj",
DatadogTraceNugetDependencyVersionReplace);
SynchronizeVersion(
"samples/AutomaticTraceIdInjection/NLog40Example/NLog40Example.csproj",
DatadogTraceNugetDependencyVersionReplace);
SynchronizeVersion(
"samples/AutomaticTraceIdInjection/NLog45Example/NLog45Example.csproj",
DatadogTraceNugetDependencyVersionReplace);
SynchronizeVersion(
"samples/AutomaticTraceIdInjection/NLog46Example/NLog46Example.csproj",
DatadogTraceNugetDependencyVersionReplace);
SynchronizeVersion(
"samples/AutomaticTraceIdInjection/SerilogExample/SerilogExample.csproj",
DatadogTraceNugetDependencyVersionReplace);
// Dockerfile updates
SynchronizeVersion(
"samples/ConsoleApp/Alpine3.9.dockerfile",
text => Regex.Replace(text, $"ARG TRACER_VERSION={VersionPattern()}", $"ARG TRACER_VERSION={VersionString()}"));
SynchronizeVersion(
"samples/ConsoleApp/Alpine3.10.dockerfile",
text => Regex.Replace(text, $"ARG TRACER_VERSION={VersionPattern()}", $"ARG TRACER_VERSION={VersionString()}"));
SynchronizeVersion(
"samples/ConsoleApp/Debian.dockerfile",
text => Regex.Replace(text, $"ARG TRACER_VERSION={VersionPattern()}", $"ARG TRACER_VERSION={VersionString()}"));
SynchronizeVersion(
"test/test-applications/regression/AutomapperTest/Dockerfile",
text => Regex.Replace(text, $"ARG TRACER_VERSION={VersionPattern()}", $"ARG TRACER_VERSION={VersionString()}"));
// Managed project / NuGet package updates
SynchronizeVersion(
"src/Datadog.Trace/Datadog.Trace.csproj",
NugetVersionReplace);
SynchronizeVersion(
"src/Datadog.Trace.AspNet/Datadog.Trace.AspNet.csproj",
NugetVersionReplace);
SynchronizeVersion(
"src/Datadog.Trace.ClrProfiler.Managed/Datadog.Trace.ClrProfiler.Managed.csproj",
NugetVersionReplace);
SynchronizeVersion(
"src/Datadog.Trace.ClrProfiler.Managed.Core/Datadog.Trace.ClrProfiler.Managed.Core.csproj",
NugetVersionReplace);
SynchronizeVersion(
"src/Datadog.Trace.ClrProfiler.Managed.Loader/Datadog.Trace.ClrProfiler.Managed.Loader.csproj",
NugetVersionReplace);
SynchronizeVersion(
"src/Datadog.Trace.OpenTracing/Datadog.Trace.OpenTracing.csproj",
NugetVersionReplace);
SynchronizeVersion(
"src/Datadog.Trace.MSBuild/Datadog.Trace.MSBuild.csproj",
NugetVersionReplace);
SynchronizeVersion(
"src/Datadog.Trace.Tools.Runner/Datadog.Trace.Tools.Runner.Standalone.csproj",
NugetVersionReplace);
SynchronizeVersion(
"src/Datadog.Trace.Tools.Runner/Datadog.Trace.Tools.Runner.Tool.csproj",
NugetVersionReplace);
// Fully qualified name updates
SynchronizeVersion(
"src/Datadog.Trace.ClrProfiler.Managed.Loader/Startup.cs",
FullAssemblyNameReplace);
SynchronizeVersion(
"src/Datadog.Trace.ClrProfiler.Native/dd_profiler_constants.h",
FullAssemblyNameReplace);
// Four-part AssemblyVersion update
SynchronizeVersion(
"src/Datadog.Trace/TracerConstants.cs",
FourPartVersionReplace);
// Locked AssemblyVersion #.0.0.0 updates
SynchronizeVersion(
"src/Datadog.Trace.AspNet/AssemblyInfo.cs",
text => MajorAssemblyVersionReplace(text, "."));
SynchronizeVersion(
"src/Datadog.Trace.ClrProfiler.Managed.Core/AssemblyInfo.cs",
text => MajorAssemblyVersionReplace(text, "."));
// Native profiler updates
SynchronizeVersion(
"src/Datadog.Trace.ClrProfiler.Native/CMakeLists.txt",
text => FullVersionReplace(text, ".", prefix: "VERSION "));
SynchronizeVersion(
"src/Datadog.Trace.ClrProfiler.Native/Resource.rc",
text =>
{
text = FullVersionReplace(text, ",");
text = FullVersionReplace(text, ".");
return text;
});
SynchronizeVersion(
"src/Datadog.Trace.ClrProfiler.Native/version.h",
text => FullVersionReplace(text, "."));
// Deployment updates
SynchronizeVersion(
"integrations.json",
FullAssemblyNameReplace);
SynchronizeVersion(
"build/docker/package.sh",
text => Regex.Replace(text, $"VERSION={VersionPattern()}", $"VERSION={VersionString()}"));
SynchronizeVersion(
"src/WindowsInstaller/WindowsInstaller.wixproj",
WixProjReplace);
Console.WriteLine($"Completed synchronizing versions to {VersionString()}");
}
private static string FourPartVersionReplace(string text)
{
return Regex.Replace(text, VersionPattern(fourPartVersion: true), FourPartVersionString(), RegexOptions.Singleline);
}
private static string FullVersionReplace(string text, string split, string prefix = "")
{
return Regex.Replace(text, prefix + VersionPattern(split), prefix + VersionString(split), RegexOptions.Singleline);
}
private static string FullAssemblyNameReplace(string text)
{
return Regex.Replace(text, AssemblyString(VersionPattern()), AssemblyString(VersionString()), RegexOptions.Singleline);
}
private static string MajorAssemblyVersionReplace(string text, string split)
{
return Regex.Replace(text, VersionPattern(fourPartVersion: true), MajorVersionString(split), RegexOptions.Singleline);
}
private static string DatadogTraceNugetDependencyVersionReplace(string text)
{
return Regex.Replace(text, $"<PackageReference Include=\"Datadog.Trace\" Version=\"{VersionPattern(withPrereleasePostfix: true)}\" />", $"<PackageReference Include=\"Datadog.Trace\" Version=\"{VersionString(withPrereleasePostfix: true)}\" />", RegexOptions.Singleline);
}
private static string NugetVersionReplace(string text)
{
return Regex.Replace(text, $"<Version>{VersionPattern(withPrereleasePostfix: true)}</Version>", $"<Version>{VersionString(withPrereleasePostfix: true)}</Version>", RegexOptions.Singleline);
}
private static string NuspecVersionReplace(string text)
{
return Regex.Replace(text, $"<version>{VersionPattern(withPrereleasePostfix: true)}</version>", $"<version>{VersionString(withPrereleasePostfix: true)}</version>", RegexOptions.Singleline);
}
private static string WixProjReplace(string text)
{
text = Regex.Replace(
text,
$"<OutputName>opentelemetry-dotnet-autoinstrumentation-{VersionPattern(withPrereleasePostfix: true)}-\\$\\(Platform\\)</OutputName>",
$"<OutputName>opentelemetry-dotnet-autoinstrumentation-{VersionString(withPrereleasePostfix: true)}-$(Platform)</OutputName>",
RegexOptions.Singleline);
text = Regex.Replace(
text,
$"InstallerVersion={VersionPattern()}",
$"InstallerVersion={VersionString()}",
RegexOptions.Singleline);
return text;
}
private static void SynchronizeVersion(string path, Func<string, string> transform)
{
var solutionDirectory = EnvironmentTools.GetSolutionDirectory();
var fullPath = Path.Combine(solutionDirectory, path);
Console.WriteLine($"Updating version instances for {path}");
if (!File.Exists(fullPath))
{
throw new Exception($"File not found to version: {path}");
}
var fileContent = File.ReadAllText(fullPath);
var newFileContent = transform(fileContent);
File.WriteAllText(fullPath, newFileContent, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false));
}
private static string FourPartVersionString(string split = ".")
{
return $"{TracerVersion.Major}{split}{TracerVersion.Minor}{split}{TracerVersion.Patch}{split}0";
}
private static string MajorVersionString(string split = ".")
{
return $"{TracerVersion.Major}{split}0{split}0{split}0";
}
private static string VersionString(string split = ".", bool withPrereleasePostfix = false)
{
var newVersion = $"{TracerVersion.Major}{split}{TracerVersion.Minor}{split}{TracerVersion.Patch}";
// this gets around a compiler warning about unreachable code below
var isPreRelease = TracerVersion.IsPreRelease;
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
if (withPrereleasePostfix && isPreRelease)
{
newVersion = newVersion + "-prerelease";
}
return newVersion;
}
private static string VersionPattern(string split = ".", bool withPrereleasePostfix = false, bool fourPartVersion = false)
{
if (split == ".")
{
split = @"\.";
}
var pattern = $@"\d+{split}\d+{split}\d+";
if (fourPartVersion)
{
pattern = pattern + $@"{split}\d+";
}
if (withPrereleasePostfix)
{
pattern = pattern + "(\\-prerelease)?";
}
return pattern;
}
private static string AssemblyString(string versionText)
{
return $"OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed, Version={versionText}.0, Culture=neutral, PublicKeyToken=34b8972644a12429";
}
}
}

View File

@ -1,166 +0,0 @@
using System;
using System.IO;
using System.Linq;
using System.Text;
namespace PrepareRelease
{
public class SyncMsiContent
{
private const string FileNameTemplate = @"{{file_name}}";
private const string ComponentListTemplate = @"{{component_list}}";
private const string ComponentGroupIdTemplate = @"{{component_group_id}}";
private const string ComponentGroupDirectoryTemplate = @"{{component_group_directory}}";
private const string FileIdPrefixTemplate = @"{{file_id_prefix}}";
private const string FrameworkMonikerTemplate = @"{{framework_moniker}}";
private const string Net461Property = "WIX_IS_NETFRAMEWORK_461_OR_LATER_INSTALLED";
private const string Net461Condition = @"
<Condition>" + Net461Property + "</Condition>";
private static readonly string ItemTemplate = $@"
<Component Win64=""$(var.Win64)"">{Net461Condition}
<File Id=""{FileIdPrefixTemplate}{FileNameTemplate}""
Source=""$(var.TracerHomeDirectory)\{FrameworkMonikerTemplate}\{FileNameTemplate}""
KeyPath=""yes"" Checksum=""yes"" Assembly="".net""/>
</Component>";
private static readonly string FileTemplate = $@"<?xml version=""1.0"" encoding=""UTF-8""?>
<Wix xmlns=""http://schemas.microsoft.com/wix/2006/wi""
xmlns:util=""http://schemas.microsoft.com/wix/UtilExtension"">
<?include $(sys.CURRENTDIR)\Config.wxi?>
<Fragment>
<ComponentGroup Id=""{ComponentGroupIdTemplate}"" Directory=""{ComponentGroupDirectoryTemplate}"">{ComponentListTemplate}
</ComponentGroup>
</Fragment>
</Wix>
";
private enum GacStatus
{
NotInGac = 0,
Net45 = 1,
Net461 = 2
}
public static void Run(string solutionDirectory, string outputDirectory)
{
CreateWixFile(
solutionDirectory,
outputDirectory,
groupId: "Files.Managed.Net45.GAC",
frameworkMoniker: "net45",
groupDirectory: "net45.GAC",
filePrefix: "net45_GAC_",
GacStatus.Net45);
CreateWixFile(
solutionDirectory,
outputDirectory,
groupId: "Files.Managed.Net461.GAC",
frameworkMoniker: "net461",
groupDirectory: "net461.GAC",
filePrefix: "net461_GAC_",
GacStatus.Net461);
CreateWixFile(
solutionDirectory,
outputDirectory,
groupId: "Files.Managed.Net45",
frameworkMoniker: "net45");
CreateWixFile(
solutionDirectory,
outputDirectory,
groupId: "Files.Managed.Net461",
frameworkMoniker: "net461");
CreateWixFile(
solutionDirectory,
outputDirectory,
groupId: "Files.Managed.NetStandard20",
frameworkMoniker: "netstandard2.0");
CreateWixFile(
solutionDirectory,
outputDirectory,
groupId: "Files.Managed.Netcoreapp31",
frameworkMoniker: "netcoreapp3.1");
}
private static void CreateWixFile(
string solutionDirectory,
string outputDirectory,
string groupId,
string frameworkMoniker,
string groupDirectory = null,
string filePrefix = null,
GacStatus gac = GacStatus.NotInGac)
{
Console.WriteLine($"Creating the {groupId} Group");
groupDirectory ??= $"{frameworkMoniker}";
filePrefix ??= $"{frameworkMoniker.Replace(".", string.Empty)}_";
var wixProjectRoot =
Path.Combine(
solutionDirectory,
"src",
"WindowsInstaller");
var extensions = gac == GacStatus.NotInGac ? new[] { ".dll", ".pdb" } : new[] { ".dll" };
var filePaths = GetTracerBinContent(outputDirectory, frameworkMoniker, extensions);
var components = string.Empty;
foreach (var filePath in filePaths)
{
var fileName = Path.GetFileName(filePath);
var component =
ItemTemplate
.Replace(FileIdPrefixTemplate, filePrefix)
.Replace(FrameworkMonikerTemplate, frameworkMoniker)
.Replace(FileNameTemplate, fileName);
if (gac == GacStatus.NotInGac)
{
component = component.Replace(@" Assembly="".net""", string.Empty);
component = component.Replace(Net461Condition, string.Empty);
}
else if (gac == GacStatus.Net45)
{
component = component.Replace(Net461Property, $"NOT {Net461Property}");
}
components += component;
}
var wixFileContent =
FileTemplate
.Replace(ComponentGroupDirectoryTemplate, groupDirectory)
.Replace(ComponentGroupIdTemplate, groupId)
.Replace(ComponentListTemplate, components);
var wixFilePath = Path.Combine(wixProjectRoot, groupId + ".wxs");
File.WriteAllText(wixFilePath, wixFileContent, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false));
Console.WriteLine($"{groupId} Group successfully created.");
}
private static string[] GetTracerBinContent(string outputDirectory, string frameworkMoniker, string[] extensions)
{
var outputFolder = Path.Combine(outputDirectory, frameworkMoniker);
var filePaths = Directory.EnumerateFiles(
outputFolder,
"*.*",
SearchOption.AllDirectories)
.Where(f => extensions.Contains(Path.GetExtension(f)))
.ToArray();
if (filePaths.Length == 0)
{
throw new Exception("Be sure to build in release mode before running this tool.");
}
return filePaths;
}
}
}

View File

@ -1,8 +0,0 @@
REM SET SOLUTION_DIR=C:\Github\otel-trace-dotnet
SET TOOL_BUILD_CONFIG=Release
SET INTEGRATIONS_PROJ=%SOLUTION_DIR%\src\Datadog.Trace.ClrProfiler.Managed\Datadog.Trace.ClrProfiler.Managed.csproj
SET OUTPUT_DIR=%SOLUTION_DIR%\build\tools\PrepareRelease\bin\tracer-home
RMDIR "%OUTPUT_DIR%" /S /Q
dotnet msbuild "%SOLUTION_DIR%\Datadog.Trace.proj" /t:PublishManagedProfilerOnDisk /p:Configuration=Release;TracerHomeDirectory=%OUTPUT_DIR%

2
poc.sh
View File

@ -11,7 +11,7 @@ function finish {
trap finish EXIT
# build projects
QUICK_BUILD=1 ./build/docker/build.sh
./build/docker/build.sh
./build/docker/Datadog.Trace.ClrProfiler.Native.sh # probably this can be commented out if we do not touch it
# start Jaeger

View File

@ -1,20 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Datadog.Trace" Version="0.0.1" />
<PackageReference Include="log4net" Version="2.0.12" />
<PackageReference Include="log4net.Ext.Json" Version="2.0.8.3" />
</ItemGroup>
<ItemGroup>
<None Update="log4net.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@ -1,34 +0,0 @@
using System.IO;
using Datadog.Trace;
using log4net;
using log4net.Config;
namespace Log4NetExample
{
class Program
{
private static readonly ILog log = LogManager.GetLogger(typeof(Program));
static void Main(string[] args)
{
var logRepository = LogManager.GetRepository(typeof(Program).Assembly);
XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));
try
{
LogicalThreadContext.Properties["order-number"] = 1024;
log.Info("Message before a trace.");
using (var scope = Tracer.Instance.StartActive("Log4NetExample - Main()"))
{
log.Info("Message during a trace.");
}
}
finally
{
LogicalThreadContext.Properties.Remove("order-number");
}
log.Info("Message after a trace.");
}
}
}

View File

@ -1,13 +0,0 @@
{
"profiles": {
"Log4NetExample": {
"commandName": "Project",
"environmentVariables": {
"OTEL_LOGS_INJECTION": "true",
"OTEL_ENV": "dev",
"OTEL_SERVICE": "Log4NetExample",
"OTEL_VERSION": "1.0.0"
}
}
}
}

View File

@ -1,84 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<!-- For the SerializedLayout from the log4net.Ext.Json NuGet package, you can extract the 'properties' value to automatically extract all of the Datadog properties (see: https://github.com/BrightOpen/log4net.Ext.Json#json-stuff) -->
<!--
Additions to layout:
- <member value='properties'/>
-->
<appender name="jsonFileAllPropertiesAppender" type="log4net.Appender.FileAppender" >
<file value="log-log4net-jsonFile-allProperties.log" />
<!-- Set up SerializedLayout as defined here: https://github.com/BrightOpen/log4net.Ext.Json#json-stuff -->
<layout type='log4net.Layout.SerializedLayout, log4net.Ext.Json'>
<decorator type='log4net.Layout.Decorators.StandardTypesDecorator, log4net.Ext.Json' />
<default />
<!--explicit default members-->
<remove value='message' />
<!--remove the default preformatted message member-->
<member value='message:messageobject' />
<!--add raw message-->
<!-- Manual changes: start -->
<member value='properties'/>
<!-- Manual changes: end -->
</layout>
</appender>
<!-- For the SerializedLayout from the log4net.Ext.Json NuGet package, you can also extract the Datadog properties individually by adding <member> nodes (see: https://github.com/BrightOpen/log4net.Ext.Json#json-stuff) -->
<!--
Additions to layout:
- <member value='dd.env' />
- <member value='dd.service' />
- <member value='dd.version' />
- <member value='dd.trace_id' />
- <member value='dd.span_id' />
-->
<appender name="jsonFileExplicitPropertiesAppender" type="log4net.Appender.FileAppender" >
<file value="log-log4net-jsonFile-explicitProperties.log" />
<layout type='log4net.Layout.SerializedLayout, log4net.Ext.Json'>
<decorator type='log4net.Layout.Decorators.StandardTypesDecorator, log4net.Ext.Json' />
<default />
<!--explicit default members-->
<remove value='message' />
<!--remove the default preformatted message member-->
<member value='message:messageobject' />
<!--add raw message-->
<member value='order-number' />
<!-- Manual changes: start -->
<member value='dd.env' />
<member value='dd.service' />
<member value='dd.version' />
<member value='dd.trace_id' />
<member value='dd.span_id' />
<!-- Manual changes: end -->
</layout>
</appender>
<!-- For the default PatternLayout, you must extract the Datadog properties individually by using the %property{name} syntax (see: https://logging.apache.org/log4net/release/manual/contexts.html) -->
<!--
- Additions to layout: {dd.env=&quot;%property{dd.env}&quot;, dd.service=&quot;%property{dd.service}&quot;, dd.version=&quot;%property{dd.version}&quot;, dd.trace_id=&quot;%property{dd.trace_id}&quot;, dd.span_id=&quot;%property{dd.span_id}&quot;}
- -->
<!--
Parsing this log line with a custom Pipeline that adds Trace/Log correlation can be done with the following Processors:
1. Grok Parser: Set the parsing rules to `log_parser %{date("yyyy-MM-dd HH:mm:ss,SSS"):date} \[%{integer:thread}\] %{word:level} %{notSpace:logger} \{%{data::keyvalue}} - %{data:message}`
-->
<appender name="textFileAppender" type="log4net.Appender.FileAppender">
<file value="log-log4net-textFile.log" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %level %logger {dd.env=&quot;%property{dd.env}&quot;, dd.service=&quot;%property{dd.service}&quot;, dd.version=&quot;%property{dd.version}&quot;, dd.trace_id=&quot;%property{dd.trace_id}&quot;, dd.span_id=&quot;%property{dd.span_id}&quot;} - %message%newline" />
</layout>
</appender>
<root>
<level value="INFO" />
<appender-ref ref="jsonFileExplicitPropertiesAppender" />
<appender-ref ref="jsonFileAllPropertiesAppender" />
<appender-ref ref="textFileAppender" />
</root>
</log4net>
</configuration>

View File

@ -1,47 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<!-- For JsonLayout, you must extract the Datadog properties individually by adding <attribute> nodes (see: https://github.com/NLog/NLog/wiki/JsonLayout) -->
<!--
Additions to layout:
- <attribute name="dd.env" layout="${mdc:item=dd.env}"/>
- <attribute name="dd.service" layout="${mdc:item=dd.service}"/>
- <attribute name="dd.version" layout="${mdc:item=dd.version}"/>
- <attribute name="dd.trace_id" layout="${mdc:item=dd.trace_id}"/>
- <attribute name="dd.span_id" layout="${mdc:item=dd.span_id}"/>
-->
<target name="jsonFile" xsi:type="File" fileName="log-NLog40-jsonFile.log">
<layout xsi:type="JsonLayout">
<attribute name="time" layout="${longdate}" />
<attribute name="level" layout="${level:upperCase=true}"/>
<attribute name="message" layout="${message}" />
<attribute name="exception" layout="${exception:format=ToString}" />
<!-- Manual changes: start -->
<attribute name="dd.env" layout="${mdc:item=dd.env}"/>
<attribute name="dd.service" layout="${mdc:item=dd.service}"/>
<attribute name="dd.version" layout="${mdc:item=dd.version}"/>
<attribute name="dd.trace_id" layout="${mdc:item=dd.trace_id}"/>
<attribute name="dd.span_id" layout="${mdc:item=dd.span_id}"/>
<!-- Manual changes: end -->
</layout>
</target>
<!-- For a custom layout, you must extract the Datadog properties individually by using the ${mdc:item=String} syntax (see: https://github.com/NLog/NLog/wiki/MDC-Layout-Renderer) -->
<!--
Additions to layout: {dd.env=&quot;${mdc:item=dd.env}&quot;,dd.service=&quot;${mdc:item=dd.service}&quot;,dd.version=&quot;${mdc:item=dd.version}&quot;,dd.trace_id=&quot;${mdc:item=dd.trace_id}&quot;,dd.span_id=&quot;${mdc:item=dd.span_id}&quot;}
-->
<!--
Parsing this log line with a custom Pipeline that adds Trace/Log correlation can be done with the following Processors:
1. Grok Parser: Set the parsing rules to `log_parser %{date("yyyy-MM-dd HH:mm:ss.SSSS"):time}\|%{word:level}\|%{notSpace:logger}\|\{%{data::keyvalue}}\|%{data:message}`
-->
<target name="textFile" xsi:type="File" fileName="log-NLog40-textFile.log"
layout="${longdate}|${uppercase:${level}}|${logger}|{dd.env=&quot;${mdc:item=dd.env}&quot;,dd.service=&quot;${mdc:item=dd.service}&quot;,dd.version=&quot;${mdc:item=dd.version}&quot;,dd.trace_id=&quot;${mdc:item=dd.trace_id}&quot;,dd.span_id=&quot;${mdc:item=dd.span_id}&quot;}|${message}" />
</targets>
<!-- rules to map from logger name to target -->
<rules>
<logger name="*" minlevel="Trace" writeTo="jsonFile,textFile" />
</rules>
</nlog>

View File

@ -1,19 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net45</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Datadog.Trace" Version="0.0.1" />
<PackageReference Include="NLog" Version="4.0.0" />
</ItemGroup>
<ItemGroup>
<None Update="NLog.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@ -1,24 +0,0 @@
using Datadog.Trace;
using NLog;
namespace NLog40Example
{
class Program
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
static void Main(string[] args)
{
MappedDiagnosticsContext.Set("order-number", 1024.ToString());
Logger.Info("Message before a trace.");
using (var scope = Tracer.Instance.StartActive("NLog45Example - Main()"))
{
Logger.Info("Message during a trace.");
}
Logger.Info("Message after a trace.");
MappedDiagnosticsContext.Remove("order-number");
}
}
}

View File

@ -1,13 +0,0 @@
{
"profiles": {
"NLog40Example": {
"commandName": "Project",
"environmentVariables": {
"OTEL_LOGS_INJECTION": "true",
"OTEL_ENV": "dev",
"OTEL_SERVICE": "NLog40Example",
"OTEL_VERSION": "1.0.0"
}
}
}
}

View File

@ -1,60 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<!-- For JsonLayout, you can set includeMdc=true to automatically extract all of the Datadog properties (see: https://github.com/NLog/NLog/wiki/JsonLayout) -->
<!--
Additions to layout: none
-->
<target name="jsonFile-includeMdc-true" xsi:type="File" fileName="log-NLog45-jsonFile-includeMdc-true.log">
<layout xsi:type="JsonLayout" includeMdc="true"> <!-- includeMdc property available in NLog 4.4.10+ -->
<attribute name="time" layout="${longdate}" />
<attribute name="level" layout="${level:upperCase=true}"/>
<attribute name="message" layout="${message}" />
<attribute name="exception" layout="${exception:format=ToString}" />
</layout>
</target>
<!-- For JsonLayout, if includeMdc=false or if not set, you must extract the Datadog properties individually by adding <attribute> nodes (see: https://github.com/NLog/NLog/wiki/JsonLayout) -->
<!--
Additions to layout:
- <attribute name="dd.env" layout="${mdc:item=dd.env}"/>
- <attribute name="dd.service" layout="${mdc:item=dd.service}"/>
- <attribute name="dd.version" layout="${mdc:item=dd.version}"/>
- <attribute name="dd.trace_id" layout="${mdc:item=dd.trace_id}"/>
- <attribute name="dd.span_id" layout="${mdc:item=dd.span_id}"/>
-->
<target name="jsonFile-includeMdc-false" xsi:type="File" fileName="log-NLog45-jsonFile-includeMdc-false.log">
<layout xsi:type="JsonLayout">
<attribute name="time" layout="${longdate}" />
<attribute name="level" layout="${level:upperCase=true}"/>
<attribute name="message" layout="${message}" />
<attribute name="exception" layout="${exception:format=ToString}" />
<!-- Manual changes: start -->
<attribute name="dd.env" layout="${mdc:item=dd.env}"/>
<attribute name="dd.service" layout="${mdc:item=dd.service}"/>
<attribute name="dd.version" layout="${mdc:item=dd.version}"/>
<attribute name="dd.trace_id" layout="${mdc:item=dd.trace_id}"/>
<attribute name="dd.span_id" layout="${mdc:item=dd.span_id}"/>
<!-- Manual changes: end -->
</layout>
</target>
<!-- For a custom layout, you must extract the Datadog properties individually by using the ${mdc:item=String} syntax (see: https://github.com/NLog/NLog/wiki/MDC-Layout-Renderer) -->
<!--
Additions to layout: {dd.env=&quot;${mdc:item=dd.env}&quot;,dd.service=&quot;${mdc:item=dd.service}&quot;,dd.version=&quot;${mdc:item=dd.version}&quot;,dd.trace_id=&quot;${mdc:item=dd.trace_id}&quot;,dd.span_id=&quot;${mdc:item=dd.span_id}&quot;}
-->
<!--
Parsing this log line with a custom Pipeline that adds Trace/Log correlation can be done with the following Processors:
1. Grok Parser: Set the parsing rules to `log_parser %{date("yyyy-MM-dd HH:mm:ss.SSSS"):time}\|%{word:level}\|%{notSpace:logger}\|\{%{data::keyvalue}}\|%{data:message}`
-->
<target name="textFile" xsi:type="File" fileName="log-NLog45-textFile.log"
layout="${longdate}|${uppercase:${level}}|${logger}|{dd.env=&quot;${mdc:item=dd.env}&quot;,dd.service=&quot;${mdc:item=dd.service}&quot;,dd.version=&quot;${mdc:item=dd.version}&quot;,dd.trace_id=&quot;${mdc:item=dd.trace_id}&quot;,dd.span_id=&quot;${mdc:item=dd.span_id}&quot;}|${message}" />
</targets>
<!-- rules to map from logger name to target -->
<rules>
<logger name="*" minlevel="Trace" writeTo="jsonFile-includeMdc-true,jsonFile-includeMdc-false,textFile" />
</rules>
</nlog>

View File

@ -1,19 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Datadog.Trace" Version="0.0.1" />
<PackageReference Include="NLog" Version="4.5.11" />
</ItemGroup>
<ItemGroup>
<None Update="NLog.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@ -1,25 +0,0 @@
using Datadog.Trace;
using NLog;
namespace NLog45Example
{
class Program
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
static void Main(string[] args)
{
using (MappedDiagnosticsContext.SetScoped("order-number", 1024))
{
Logger.Info("Message before a trace.");
using (var scope = Tracer.Instance.StartActive("NLog45Example - Main()"))
{
Logger.Info("Message during a trace.");
}
Logger.Info("Message after a trace.");
}
}
}
}

View File

@ -1,13 +0,0 @@
{
"profiles": {
"NLog45Example": {
"commandName": "Project",
"environmentVariables": {
"OTEL_LOGS_INJECTION": "true",
"OTEL_ENV": "dev",
"OTEL_SERVICE": "NLog45Example",
"OTEL_VERSION": "1.0.0"
}
}
}
}

View File

@ -1,60 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<!-- For JsonLayout, you can set includeMdlc=true to automatically extract all of the Datadog properties (see: https://github.com/NLog/NLog/wiki/JsonLayout) -->
<!--
Additions to layout: none
-->
<target name="jsonFile-includeMdlc-true" xsi:type="File" fileName="log-NLog46-jsonFile-includeMdlc-true.log">
<layout xsi:type="JsonLayout" includeMdlc="true"> <!-- includeMdlc property available in NLog 4.4.10+ -->
<attribute name="time" layout="${longdate}" />
<attribute name="level" layout="${level:upperCase=true}"/>
<attribute name="message" layout="${message}" />
<attribute name="exception" layout="${exception:format=ToString}" />
</layout>
</target>
<!-- For JsonLayout, if includeMdlc=false or if not set, you must extract the Datadog properties individually by adding <attribute> nodes (see: https://github.com/NLog/NLog/wiki/JsonLayout) -->
<!--
Additions to layout:
- <attribute name="dd.env" layout="${mdlc:item=dd.env}"/>
- <attribute name="dd.service" layout="${mdlc:item=dd.service}"/>
- <attribute name="dd.version" layout="${mdlc:item=dd.version}"/>
- <attribute name="dd.trace_id" layout="${mdlc:item=dd.trace_id}"/>
- <attribute name="dd.span_id" layout="${mdlc:item=dd.span_id}"/>
-->
<target name="jsonFile-includeMdlc-false" xsi:type="File" fileName="log-NLog46-jsonFile-includeMdlc-false.log">
<layout xsi:type="JsonLayout">
<attribute name="time" layout="${longdate}" />
<attribute name="level" layout="${level:upperCase=true}"/>
<attribute name="message" layout="${message}" />
<attribute name="exception" layout="${exception:format=ToString}" />
<!-- Manual changes: start -->
<attribute name="dd.env" layout="${mdlc:item=dd.env}"/>
<attribute name="dd.service" layout="${mdlc:item=dd.service}"/>
<attribute name="dd.version" layout="${mdlc:item=dd.version}"/>
<attribute name="dd.trace_id" layout="${mdlc:item=dd.trace_id}"/>
<attribute name="dd.span_id" layout="${mdlc:item=dd.span_id}"/>
<!-- Manual changes: end -->
</layout>
</target>
<!-- For a custom layout, you must extract the Datadog properties individually by using the ${mdlc:item=String} syntax (see: https://github.com/NLog/NLog/wiki/MDLC-Layout-Renderer) -->
<!--
Additions to layout: {dd.env=&quot;${mdlc:item=dd.env}&quot;,dd.service=&quot;${mdlc:item=dd.service}&quot;,dd.version=&quot;${mdlc:item=dd.version}&quot;,dd.trace_id=&quot;${mdlc:item=dd.trace_id}&quot;,dd.span_id=&quot;${mdlc:item=dd.span_id}&quot;}
-->
<!--
Parsing this log line with a custom Pipeline that adds Trace/Log correlation can be done with the following Processors:
1. Grok Parser: Set the parsing rules to `log_parser %{date("yyyy-MM-dd HH:mm:ss.SSSS"):time}\|%{word:level}\|%{notSpace:logger}\|\{%{data::keyvalue}}\|%{data:message}`
-->
<target name="textFile" xsi:type="File" fileName="log-NLog46-textFile.log"
layout="${longdate}|${uppercase:${level}}|${logger}|{dd.env=&quot;${mdlc:item=dd.env}&quot;,dd.service=&quot;${mdlc:item=dd.service}&quot;,dd.version=&quot;${mdlc:item=dd.version}&quot;,dd.trace_id=&quot;${mdlc:item=dd.trace_id}&quot;,dd.span_id=&quot;${mdlc:item=dd.span_id}&quot;}|${message}" />
</targets>
<!-- rules to map from logger name to target -->
<rules>
<logger name="*" minlevel="Trace" writeTo="jsonFile-includeMdlc-true,jsonFile-includeMdlc-false,textFile" />
</rules>
</nlog>

View File

@ -1,19 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Datadog.Trace" Version="0.0.1" />
<PackageReference Include="NLog" Version="4.6.7" />
</ItemGroup>
<ItemGroup>
<None Update="NLog.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@ -1,25 +0,0 @@
using Datadog.Trace;
using NLog;
namespace NLog46Example
{
class Program
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
static void Main(string[] args)
{
using (MappedDiagnosticsLogicalContext.SetScoped("order-number", 1024))
{
Logger.Info("Message before a trace.");
using (var scope = Tracer.Instance.StartActive("NLog46Example - Main()"))
{
Logger.Info("Message during a trace.");
}
Logger.Info("Message after a trace.");
}
}
}
}

View File

@ -1,13 +0,0 @@
{
"profiles": {
"NLog46Example": {
"commandName": "Project",
"environmentVariables": {
"OTEL_LOGS_INJECTION": "true",
"OTEL_ENV": "dev",
"OTEL_SERVICE": "NLog46Example",
"OTEL_VERSION": "1.0.0"
}
}
}
}

View File

@ -1,21 +0,0 @@
# Automatic Trace ID injection
Follow the official documentation steps to set up [C# log collection](https://docs.datadoghq.com/logs/log_collection/csharp/) and [automatic trace ID injection](https://docs.datadoghq.com/tracing/connect_logs_and_traces/?tab=net), then run these samples to see the feature in action!
If there is a logging layout that you would like to see documented here, please feel free to reach out with an issue or contribution!
## Supported Logging Frameworks
### Log4Net
Layouts configured in the sample:
- JSON format: `SerializedLayout` (from the `log4net.Ext.Json` NuGet package)
- Raw format: `PatternLayout` (requires a custom Datadog Log Pipeline for processing)
### NLog
Layouts configured in the sample:
- JSON format: `JsonLayout`
- Raw format: Custom layout (requires a custom Datadog Log Pipeline for processing)
### Serilog
Layouts configured in the sample:
- JSON format: `JsonFormatter`
- JSON format: `CompactJsonFormatter` (from the `Serilog.Formatting.Compact` NuGet package)
- Raw format: output template (requires a custom Datadog Log Pipeline for processing)

View File

@ -1,69 +0,0 @@
using System.IO;
using Datadog.Trace;
using Serilog;
using Serilog.Context;
using Serilog.Formatting.Compact;
using Serilog.Formatting.Json;
namespace SerilogExample
{
class Program
{
static void Main(string[] args)
{
// Regardless of the output layout, your LoggerConfiguration must be
// enriched from the LogContext to extract the Datadog
// properties that are automatically injected by the .NET tracer
//
// Additions to LoggerConfiguration:
// - .Enrich.FromLogContext()
var loggerConfiguration = new LoggerConfiguration()
.Enrich.FromLogContext()
.MinimumLevel.Is(Serilog.Events.LogEventLevel.Information);
// When using a message template, you must emit all properties using the {Properties} syntax in order to emit the Datadog properties (see: https://github.com/serilog/serilog/wiki/Formatting-Output#formatting-plain-text)
// This is because Serilog cannot look up these individual keys by name due to the '.' in the Datadog property names (see https://github.com/serilog/serilog/wiki/Writing-Log-Events#message-template-syntax)
// Additionally, Datadog will only parse log properties if they are in a JSON-like map, and the values for the Datadog properties must be surrounded by quotation marks
//
// Additions to layout:
// - {Properties}
//
loggerConfiguration = loggerConfiguration
.WriteTo.File(
"log-Serilog-textFile.log",
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Properties} {Message:lj} {NewLine}{Exception}");
// The built-in JsonFormatter will display all properties by default, so no extra work is needed to emit the Datadog properties
//
// Additions to layout: none
//
loggerConfiguration = loggerConfiguration
.WriteTo.File(
new JsonFormatter(),
"log-Serilog-jsonFile-allProperties.log");
// The CompactJsonFormatter from the Serilog.Formatting.Compact NuGet package will display all properties by default, so no extra work is needed to emit the Datadog properties
//
// Additions to layout: none
//
loggerConfiguration = loggerConfiguration
.WriteTo.File(
new CompactJsonFormatter(),
"log-Serilog-compactJsonFile-allProperties.log");
// Main procedure
var log = loggerConfiguration.CreateLogger();
using (LogContext.PushProperty("order-number", 1024))
{
log.Information("Message before a trace.");
using (var scope = Tracer.Instance.StartActive("SerilogExample - Main()"))
{
log.Information("Message during a trace.");
}
log.Information("Message after a trace.");
}
}
}
}

View File

@ -1,13 +0,0 @@
{
"profiles": {
"SerilogExample": {
"commandName": "Project",
"environmentVariables": {
"OTEL_LOGS_INJECTION": "true",
"OTEL_ENV": "dev",
"OTEL_SERVICE": "SerilogExample",
"OTEL_VERSION": "1.0.0"
}
}
}
}

View File

@ -1,15 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Datadog.Trace" Version="0.0.1" />
<PackageReference Include="Serilog" Version="2.9.0" />
<PackageReference Include="Serilog.Formatting.Compact" Version="1.1.0" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
</ItemGroup>
</Project>

View File

@ -1,36 +0,0 @@
# RabbitMQ Instrumentation
Currently, the .NET Tracer does not have out-of-the-box automatic instrumentation for the RabbitMQ .NET SDK. This means if your .NET application publishes/consumes a RabbitMQ message and you would like to propagate/consume the Datadog trace context, you must do so manually by adding/removing the Datadog headers. This sample follows the ["Hello World" C# tutorial](https://www.rabbitmq.com/tutorials/tutorial-one-dotnet.html) provided by RabbitMQ and modifies it in the following ways:
1. The sender begins a Datadog trace before publishing a message
1. The sender injects the trace context into the published message before sending
1. The receiver extracts the trace context from the consumed message
1. The receiver starts a new Datadog trace that is now properly connected to the original trace
## Setup
### Application setup
This sample contains two .NET Core applications: `Send` and `Receive`. Open two terminals. First, run the consumer:
```
cd Receive
dotnet run
```
Then run the producer:
```
cd Send
dotnet run
```
For further tutorial instructions, see the official RabbitMQ docs at https://www.rabbitmq.com/tutorials/tutorial-one-dotnet.html
### RabbitMQ setup
Ensure RabbitMQ is running on localhost. If you have docker installed, you may get it up and running quickly on your workstation via the community Docker image:
```
docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3-management
```
For further setup instructions, see the official RabbitMQ docs at https://www.rabbitmq.com/download.html
## Results
![Datadog UI with one RabbitMQ producer span and one RabbitMQ consumer span](https://user-images.githubusercontent.com/13769665/94503633-be690d80-01bb-11eb-8a4c-ccb4a5ee5b82.png)

View File

@ -1,99 +0,0 @@
using Datadog.Trace;
using RabbitMQ.Client;
using RabbitMQ.Client.Events;
using System;
using System.Globalization;
using System.Text;
using System.Threading;
namespace Receive
{
class Receive
{
// This small application follows the RabbitMQ tutorial at https://www.rabbitmq.com/tutorials/tutorial-one-dotnet.html
public static void Main()
{
var factory = new ConnectionFactory() { HostName = "localhost" };
using (var connection = factory.CreateConnection())
{
using (var channel = connection.CreateModel())
{
channel.QueueDeclare(queue: "hello",
durable: false,
exclusive: false,
autoDelete: false,
arguments: null);
var consumer = new EventingBasicConsumer(channel);
consumer.Received += (model, ea) =>
{
// Receive message
var body = ea.Body.ToArray();
var message = Encoding.UTF8.GetString(body);
// Read the basic property headers and extract the Datadog properties
var headers = ea.BasicProperties.Headers;
ulong? parentSpanId = null;
ulong? traceId = null;
SamplingPriority? samplingPriority = null;
// Parse parentId header
if (headers?[HttpHeaderNames.ParentId] is byte[] parentSpanIdBytes)
{
parentSpanId = BitConverter.ToUInt64(parentSpanIdBytes, 0);
}
// Parse traceId header
if (headers?[HttpHeaderNames.TraceId] is byte[] traceIdBytes)
{
traceId = BitConverter.ToUInt64(traceIdBytes, 0);
}
// Parse samplingPriority header
if (headers?[HttpHeaderNames.SamplingPriority] is byte[] samplingPriorityBytes)
{
var samplingPriorityString = Encoding.UTF8.GetString(samplingPriorityBytes);
if (Enum.TryParse<SamplingPriority>(samplingPriorityString, out var result))
{
samplingPriority = result;
}
}
// Create a new SpanContext to represent the distributed tracing information
SpanContext propagatedContext = null;
if (parentSpanId.HasValue && traceId.HasValue)
{
propagatedContext = new SpanContext(traceId, parentSpanId.Value, samplingPriority);
}
// Start a new Datadog span
using (var scope = Tracer.Instance.StartActive("rabbitmq.consume", propagatedContext))
{
// Log message and properties to screen
Console.WriteLine(" [x] Received.");
Console.WriteLine(" Message: {0}", message);
Console.WriteLine(" Active TraceId: {0}", scope.Span.TraceId);
Console.WriteLine(" Active SpanId: {0}", scope.Span.SpanId);
Console.WriteLine(" Active SamplingPriority: {0}", scope.Span.GetTag(Tags.SamplingPriority));
// Set Datadog tags
var span = scope.Span;
span.SetTag(Tags.SpanKind, SpanKinds.Consumer);
span.SetTag("amqp.exchange", ea.Exchange);
span.SetTag("amqp.routing_key", ea.RoutingKey);
// Do work inside the Datadog trace
Thread.Sleep(1000);
}
};
channel.BasicConsume(queue: "hello",
autoAck: true,
consumer: consumer);
Console.WriteLine(" Press [enter] to exit.");
Console.ReadLine();
}
}
}
}
}

View File

@ -1,13 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Datadog.Trace" Version="1.19.3" />
<PackageReference Include="RabbitMQ.Client" Version="6.2.1" />
</ItemGroup>
</Project>

View File

@ -1,75 +0,0 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using Datadog.Trace;
using RabbitMQ.Client;
namespace Send
{
class Send
{
// This small application follows the RabbitMQ tutorial at https://www.rabbitmq.com/tutorials/tutorial-one-dotnet.html
public static void Main(string[] args)
{
var factory = new ConnectionFactory() { HostName = "localhost" };
using (var connection = factory.CreateConnection())
{
using (var channel = connection.CreateModel())
{
channel.QueueDeclare(queue: "hello",
durable: false,
exclusive: false,
autoDelete: false,
arguments: null);
// Start a new Datadog span
using (var scope = Tracer.Instance.StartActive("rabbitmq.publish"))
{
string message = "Hello World!";
var body = Encoding.UTF8.GetBytes(message);
// Create BasicProperties and a Headers dictionary to store header information
var properties = channel.CreateBasicProperties();
properties.Headers = new Dictionary<string, object>();
// Get properties for the active Datadog span
ulong traceId = scope.Span.TraceId;
ulong spanId = scope.Span.SpanId;
string samplingPriority = scope.Span.GetTag(Tags.SamplingPriority);
// Add properties to the Headers dictionary in the following way:
// - "x-datadog-trace-id": "<trace_id>"
// - "x-datadog-parent-id": "<span_id>"
// - "x-datadog-sampling-priority": "<sampling_priority>"
properties.Headers.Add(HttpHeaderNames.TraceId, BitConverter.GetBytes(traceId));
properties.Headers.Add(HttpHeaderNames.ParentId, BitConverter.GetBytes(spanId));
properties.Headers.Add(HttpHeaderNames.SamplingPriority, Encoding.UTF8.GetBytes(samplingPriority));
// Publish message
channel.BasicPublish(exchange: "",
routingKey: "hello",
basicProperties: properties, // Pass the properties with the message
body: body);
// Log message and properties to screen
Console.WriteLine(" [x] Sent {0}", message);
Console.WriteLine(" {0}:{1}", HttpHeaderNames.TraceId, traceId);
Console.WriteLine(" {0}:{1}", HttpHeaderNames.ParentId, spanId);
Console.WriteLine(" {0}:{1}", HttpHeaderNames.SamplingPriority, samplingPriority);
// Set Datadog tags
var span = scope.Span;
span.ResourceName = "basic.publish";
span.SetTag(Tags.SpanKind, SpanKinds.Producer);
span.SetTag("amqp.exchange", "");
span.SetTag("amqp.routing_key", "hello");
}
}
Console.WriteLine(" Press [enter] to exit.");
Console.ReadLine();
}
}
}
}

View File

@ -1,13 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Datadog.Trace" Version="1.19.3" />
<PackageReference Include="RabbitMQ.Client" Version="6.2.1" />
</ItemGroup>
</Project>

View File

@ -1,3 +0,0 @@
REM This is a required entry point for PowerShell scripts in Azure Service Fabric
powershell.exe -ExecutionPolicy Bypass -Command ".\DatadogInstall.ps1" > %SvcFabDir%\datadog-powershell-log.txt 2> %SvcFabDir%\datadog-powershell-error.txt

View File

@ -1,50 +0,0 @@
# allow overriding defaults using environment variables
if (Test-Path env:SvcFabDir) { $SvcFabDir = $env:SvcFabDir } else { $SvcFabDir = 'D:\SvcFab' }
if (Test-Path env:OTEL_TRACER_VERSION) { $OTEL_TRACER_VERSION = $env:OTEL_TRACER_VERSION } else { $OTEL_TRACER_VERSION = '0.0.1' }
if (Test-Path env:OTEL_TRACER_URL) { $OTEL_TRACER_URL = $env:OTEL_TRACER_URL } else { $OTEL_TRACER_URL = "https://github.com/DataDog/dd-trace-dotnet/releases/download/v$OTEL_TRACER_VERSION/windows-tracer-home.zip" }
if (Test-Path env:OTEL_DOTNET_TRACER_HOME) { $OTEL_DOTNET_TRACER_HOME = $env:OTEL_DOTNET_TRACER_HOME } else { $OTEL_DOTNET_TRACER_HOME = "$SvcFabDir\datadog-dotnet-tracer\v$OTEL_TRACER_VERSION" }
Write-Host "[DatadogInstall.ps1] Installing Datadog .NET Tracer v$OTEL_TRACER_VERSION"
# download, extract, and delete the archive
$ArchivePath = "$SvcFabDir\windows-tracer-home.zip"
Write-Host "[DatadogInstall.ps1] Downloading $OTEL_TRACER_URL to $ArchivePath"
Invoke-WebRequest $OTEL_TRACER_URL -OutFile $ArchivePath
Write-Host "[DatadogInstall.ps1] Extracting to $OTEL_DOTNET_TRACER_HOME"
Expand-Archive -Force -Path "$SvcFabDir\windows-tracer-home.zip" -DestinationPath $OTEL_DOTNET_TRACER_HOME
Write-Host "[DatadogInstall.ps1] Deleting $ArchivePath"
Remove-Item $ArchivePath
# create a folder for log files
$LOGS_PATH = "$SvcFabDir\datadog-dotnet-tracer-logs"
if (-not (Test-Path -Path $LOGS_PATH -PathType Container)) {
Write-Host "[DatadogInstall.ps1] Creating logs folder $LOGS_PATH"
New-Item -ItemType Directory -Force -Path $LOGS_PATH
}
function Set-MachineEnvironmentVariable {
param(
[string]$name,
[string]$value
)
Write-Host "[DatadogInstall.ps1] Setting environment variable $name=$value"
[System.Environment]::SetEnvironmentVariable($name, $value, [System.EnvironmentVariableTarget]::Machine)
}
Set-MachineEnvironmentVariable 'OTEL_DOTNET_TRACER_HOME' $OTEL_DOTNET_TRACER_HOME
Set-MachineEnvironmentVariable 'OTEL_INTEGRATIONS' "$OTEL_DOTNET_TRACER_HOME\integrations.json"
Set-MachineEnvironmentVariable 'OTEL_TRACE_LOG_DIRECTORY' "$LOGS_PATH"
# Set-MachineEnvironmentVariable'COR_ENABLE_PROFILING' '0' # Enable per app
Set-MachineEnvironmentVariable 'COR_PROFILER' '{918728DD-259F-4A6A-AC2B-B85E1B658318}'
Set-MachineEnvironmentVariable 'COR_PROFILER_PATH_32' "$OTEL_DOTNET_TRACER_HOME\win-x86\OpenTelemetry.AutoInstrumentation.ClrProfiler.Native.dll"
Set-MachineEnvironmentVariable 'COR_PROFILER_PATH_64' "$OTEL_DOTNET_TRACER_HOME\win-x64\OpenTelemetry.AutoInstrumentation.ClrProfiler.Native.dll"
# Set-MachineEnvironmentVariable 'CORECLR_ENABLE_PROFILING' '0' # Enable per app
Set-MachineEnvironmentVariable 'CORECLR_PROFILER' '{918728DD-259F-4A6A-AC2B-B85E1B658318}'
Set-MachineEnvironmentVariable 'CORECLR_PROFILER_PATH_32' "$OTEL_DOTNET_TRACER_HOME\win-x86\OpenTelemetry.AutoInstrumentation.ClrProfiler.Native.dll"
Set-MachineEnvironmentVariable 'CORECLR_PROFILER_PATH_64' "$OTEL_DOTNET_TRACER_HOME\win-x64\OpenTelemetry.AutoInstrumentation.ClrProfiler.Native.dll"

View File

@ -1,67 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ApplicationManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ApplicationTypeName="ServiceFabricApplicationType" ApplicationTypeVersion="1.0.0" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<Parameters>
<Parameter Name="WeatherService_NetFx461_InstanceCount" DefaultValue="-1" />
<Parameter Name="WeatherService_NetCore31_InstanceCount" DefaultValue="-1" />
<Parameter Name="WebApp_ASPNETCORE_ENVIRONMENT" DefaultValue="" />
<Parameter Name="WebApp_InstanceCount" DefaultValue="-1" />
</Parameters>
<!-- Import the ServiceManifest from the ServicePackage. The ServiceManifestName and ServiceManifestVersion
should match the Name and Version attributes of the ServiceManifest element defined in the
ServiceManifest.xml file. -->
<ServiceManifestImport>
<ServiceManifestRef ServiceManifestName="WeatherService_NetFx461" ServiceManifestVersion="1.0.0" />
<ConfigOverrides />
</ServiceManifestImport>
<ServiceManifestImport>
<ServiceManifestRef ServiceManifestName="WeatherService_NetCore31" ServiceManifestVersion="1.0.0" />
<ConfigOverrides />
<Policies>
<!-- Use admin user to install Datadog .NET Tracer -->
<RunAsPolicy CodePackageRef="Code" UserRef="SetupAdminUser" EntryPointType="Setup" />
</Policies>
</ServiceManifestImport>
<ServiceManifestImport>
<ServiceManifestRef ServiceManifestName="WebApp" ServiceManifestVersion="1.0.0" />
<ConfigOverrides />
<EnvironmentOverrides CodePackageRef="code">
<EnvironmentVariable Name="ASPNETCORE_ENVIRONMENT" Value="[WebApp_ASPNETCORE_ENVIRONMENT]" />
</EnvironmentOverrides>
<Policies>
<!-- Use admin user to install Datadog .NET Tracer -->
<RunAsPolicy CodePackageRef="Code" UserRef="SetupAdminUser" EntryPointType="Setup" />
</Policies>
</ServiceManifestImport>
<DefaultServices>
<!-- The section below creates instances of service types, when an instance of this
application type is created. You can also create one or more instances of service type using the
ServiceFabric PowerShell module.
The attribute ServiceTypeName below must match the name defined in the imported ServiceManifest.xml file. -->
<Service Name="WeatherService_NetFx461" ServicePackageActivationMode="ExclusiveProcess">
<StatelessService ServiceTypeName="WeatherService_NetFx461" InstanceCount="[WeatherService_NetFx461_InstanceCount]">
<SingletonPartition />
</StatelessService>
</Service>
<Service Name="WeatherService_NetCore31" ServicePackageActivationMode="ExclusiveProcess">
<StatelessService ServiceTypeName="WeatherService_NetCore31" InstanceCount="[WeatherService_NetCore31_InstanceCount]">
<SingletonPartition />
</StatelessService>
</Service>
<Service Name="WebApp" ServicePackageActivationMode="ExclusiveProcess">
<StatelessService ServiceTypeName="WebApp" InstanceCount="[WebApp_InstanceCount]">
<SingletonPartition />
</StatelessService>
</Service>
</DefaultServices>
<!-- Add admin user to install Datadog .NET Tracer -->
<Principals>
<Users>
<User Name="SetupAdminUser">
<MemberOf>
<SystemGroup Name="Administrators" />
</MemberOf>
</User>
</Users>
</Principals>
</ApplicationManifest>

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Application xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="fabric:/ServiceFabricApplication" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<Parameters>
<Parameter Name="WeatherService_NetFx461_InstanceCount" Value="-1" />
<Parameter Name="WeatherService_NetCore31_InstanceCount" Value="-1" />
<Parameter Name="WebApp_InstanceCount" Value="-1" />
</Parameters>
</Application>

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Application xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="fabric:/ServiceFabricApplication" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<Parameters>
<Parameter Name="WeatherService_NetFx461_InstanceCount" Value="1" />
<Parameter Name="WeatherService_NetCore31_InstanceCount" Value="1" />
<Parameter Name="WebApp_ASPNETCORE_ENVIRONMENT" Value="Development" />
<Parameter Name="WebApp_InstanceCount" Value="1" />
</Parameters>
</Application>

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Application xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="fabric:/ServiceFabricApplication" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<Parameters>
<Parameter Name="WeatherService_NetFx461_InstanceCount" Value="1" />
<Parameter Name="WeatherService_NetCore31_InstanceCount" Value="1" />
<Parameter Name="WebApp_ASPNETCORE_ENVIRONMENT" Value="Development" />
<Parameter Name="WebApp_InstanceCount" Value="1" />
</Parameters>
</Application>

View File

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools">
<!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster.
Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet.
For a remote cluster, you would need to specify the appropriate parameters for that specific cluster.
For example: <ClusterConnectionParameters ConnectionEndpoint="mycluster.westus.cloudapp.azure.com:19000" />
Example showing parameters for a cluster that uses certificate security:
<ClusterConnectionParameters ConnectionEndpoint="mycluster.westus.cloudapp.azure.com:19000"
X509Credential="true"
ServerCertThumbprint="0123456789012345678901234567890123456789"
FindType="FindByThumbprint"
FindValue="9876543210987654321098765432109876543210"
StoreLocation="CurrentUser"
StoreName="My" />
Example showing parameters for a cluster that uses Azure Active Directory (AAD) security:
<ClusterConnectionParameters ConnectionEndpoint="mycluster.westus.cloudapp.azure.com:19000"
AzureActiveDirectory="true"
ServerCertThumbprint="0123456789012345678901234567890123456789" />
-->
<ClusterConnectionParameters ConnectionEndpoint="" />
<ApplicationParameterFile Path="..\ApplicationParameters\Cloud.xml" />
<CopyPackageParameters CompressPackage="true" />
</PublishProfile>

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools">
<!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster.
Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet.
For a local cluster, you would typically not use any parameters.
For example: <ClusterConnectionParameters />
-->
<ClusterConnectionParameters />
<ApplicationParameterFile Path="..\ApplicationParameters\Local.1Node.xml" />
<UpgradeDeployment Mode="UnmonitoredAuto" Enabled="false">
<Parameters UpgradeReplicaSetCheckTimeoutSec="1" Force="True" />
</UpgradeDeployment>
</PublishProfile>

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools">
<!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster.
Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet.
For a local cluster, you would typically not use any parameters.
For example: <ClusterConnectionParameters />
-->
<ClusterConnectionParameters />
<ApplicationParameterFile Path="..\ApplicationParameters\Local.5Node.xml" />
</PublishProfile>

View File

@ -1,273 +0,0 @@
<#
.SYNOPSIS
Deploys a Service Fabric application type to a cluster.
.DESCRIPTION
This script deploys a Service Fabric application type to a cluster. It is invoked by Visual Studio when deploying a Service Fabric Application project.
.NOTES
WARNING: This script file is invoked by Visual Studio. Its parameters must not be altered but its logic can be customized as necessary.
.PARAMETER PublishProfileFile
Path to the file containing the publish profile.
.PARAMETER ApplicationPackagePath
Path to the folder of the packaged Service Fabric application.
.PARAMETER DeployOnly
Indicates that the Service Fabric application should not be created or upgraded after registering the application type.
.PARAMETER ApplicationParameter
Hashtable of the Service Fabric application parameters to be used for the application.
.PARAMETER UnregisterUnusedApplicationVersionsAfterUpgrade
Indicates whether to unregister any unused application versions that exist after an upgrade is finished.
.PARAMETER OverrideUpgradeBehavior
Indicates the behavior used to override the upgrade settings specified by the publish profile.
'None' indicates that the upgrade settings will not be overridden.
'ForceUpgrade' indicates that an upgrade will occur with default settings, regardless of what is specified in the publish profile.
'VetoUpgrade' indicates that an upgrade will not occur, regardless of what is specified in the publish profile.
.PARAMETER UseExistingClusterConnection
Indicates that the script should make use of an existing cluster connection that has already been established in the PowerShell session. The cluster connection parameters configured in the publish profile are ignored.
.PARAMETER OverwriteBehavior
Overwrite Behavior if an application exists in the cluster with the same name. Available Options are Never, Always, SameAppTypeAndVersion. This setting is not applicable when upgrading an application.
'Never' will not remove the existing application. This is the default behavior.
'Always' will remove the existing application even if its Application type and Version is different from the application being created.
'SameAppTypeAndVersion' will remove the existing application only if its Application type and Version is same as the application being created.
.PARAMETER SkipPackageValidation
Switch signaling whether the package should be validated or not before deployment.
.PARAMETER SecurityToken
A security token for authentication to cluster management endpoints. Used for silent authentication to clusters that are protected by Azure Active Directory.
.PARAMETER CopyPackageTimeoutSec
Timeout in seconds for copying application package to image store.
.EXAMPLE
. Scripts\Deploy-FabricApplication.ps1 -ApplicationPackagePath 'pkg\Debug'
Deploy the application using the default package location for a Debug build.
.EXAMPLE
. Scripts\Deploy-FabricApplication.ps1 -ApplicationPackagePath 'pkg\Debug' -DoNotCreateApplication
Deploy the application but do not create the application instance.
.EXAMPLE
. Scripts\Deploy-FabricApplication.ps1 -ApplicationPackagePath 'pkg\Debug' -ApplicationParameter @{CustomParameter1='MyValue'; CustomParameter2='MyValue'}
Deploy the application by providing values for parameters that are defined in the application manifest.
#>
Param
(
[String]
$PublishProfileFile,
[String]
$ApplicationPackagePath,
[Switch]
$DeployOnly,
[Hashtable]
$ApplicationParameter,
[Boolean]
$UnregisterUnusedApplicationVersionsAfterUpgrade,
[String]
[ValidateSet('None', 'ForceUpgrade', 'VetoUpgrade')]
$OverrideUpgradeBehavior = 'None',
[Switch]
$UseExistingClusterConnection,
[String]
[ValidateSet('Never','Always','SameAppTypeAndVersion')]
$OverwriteBehavior = 'Never',
[Switch]
$SkipPackageValidation,
[String]
$SecurityToken,
[int]
$CopyPackageTimeoutSec,
[int]
$RegisterApplicationTypeTimeoutSec
)
function Read-XmlElementAsHashtable
{
Param (
[System.Xml.XmlElement]
$Element
)
$hashtable = @{}
if ($Element.Attributes)
{
$Element.Attributes |
ForEach-Object {
$boolVal = $null
if ([bool]::TryParse($_.Value, [ref]$boolVal)) {
$hashtable[$_.Name] = $boolVal
}
else {
$hashtable[$_.Name] = $_.Value
}
}
}
return $hashtable
}
function Read-PublishProfile
{
Param (
[ValidateScript({Test-Path $_ -PathType Leaf})]
[String]
$PublishProfileFile
)
$publishProfileXml = [Xml] (Get-Content $PublishProfileFile -Encoding UTF8)
$publishProfile = @{}
$publishProfile.ClusterConnectionParameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("ClusterConnectionParameters")
$publishProfile.UpgradeDeployment = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("UpgradeDeployment")
$publishProfile.CopyPackageParameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("CopyPackageParameters")
$publishProfile.RegisterApplicationParameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("RegisterApplicationParameters")
if ($publishProfileXml.PublishProfile.Item("UpgradeDeployment"))
{
$publishProfile.UpgradeDeployment.Parameters = Read-XmlElementAsHashtable $publishProfileXml.PublishProfile.Item("UpgradeDeployment").Item("Parameters")
if ($publishProfile.UpgradeDeployment["Mode"])
{
$publishProfile.UpgradeDeployment.Parameters[$publishProfile.UpgradeDeployment["Mode"]] = $true
}
}
$publishProfileFolder = (Split-Path $PublishProfileFile)
$publishProfile.ApplicationParameterFile = [System.IO.Path]::Combine($PublishProfileFolder, $publishProfileXml.PublishProfile.ApplicationParameterFile.Path)
return $publishProfile
}
$LocalFolder = (Split-Path $MyInvocation.MyCommand.Path)
if (!$PublishProfileFile)
{
$PublishProfileFile = "$LocalFolder\..\PublishProfiles\Local.xml"
}
if (!$ApplicationPackagePath)
{
$ApplicationPackagePath = "$LocalFolder\..\pkg\Release"
}
$ApplicationPackagePath = Resolve-Path $ApplicationPackagePath
$publishProfile = Read-PublishProfile $PublishProfileFile
if (-not $UseExistingClusterConnection)
{
$ClusterConnectionParameters = $publishProfile.ClusterConnectionParameters
if ($SecurityToken)
{
$ClusterConnectionParameters["SecurityToken"] = $SecurityToken
}
try
{
[void](Connect-ServiceFabricCluster @ClusterConnectionParameters)
}
catch [System.Fabric.FabricObjectClosedException]
{
Write-Warning "Service Fabric cluster may not be connected."
throw
}
}
$RegKey = "HKLM:\SOFTWARE\Microsoft\Service Fabric SDK"
$ModuleFolderPath = (Get-ItemProperty -Path $RegKey -Name FabricSDKPSModulePath).FabricSDKPSModulePath
Import-Module "$ModuleFolderPath\ServiceFabricSDK.psm1"
$IsUpgrade = ($publishProfile.UpgradeDeployment -and $publishProfile.UpgradeDeployment.Enabled -and $OverrideUpgradeBehavior -ne 'VetoUpgrade') -or $OverrideUpgradeBehavior -eq 'ForceUpgrade'
$PublishParameters = @{
'ApplicationPackagePath' = $ApplicationPackagePath
'ApplicationParameterFilePath' = $publishProfile.ApplicationParameterFile
'ApplicationParameter' = $ApplicationParameter
'ErrorAction' = 'Stop'
}
if ($publishProfile.CopyPackageParameters.CopyPackageTimeoutSec)
{
$PublishParameters['CopyPackageTimeoutSec'] = $publishProfile.CopyPackageParameters.CopyPackageTimeoutSec
}
if ($publishProfile.CopyPackageParameters.CompressPackage)
{
$PublishParameters['CompressPackage'] = $publishProfile.CopyPackageParameters.CompressPackage
}
if ($publishProfile.RegisterApplicationParameters.RegisterApplicationTypeTimeoutSec)
{
$PublishParameters['RegisterApplicationTypeTimeoutSec'] = $publishProfile.RegisterApplicationParameters.RegisterApplicationTypeTimeoutSec
}
# CopyPackageTimeoutSec parameter overrides the value from the publish profile
if ($CopyPackageTimeoutSec)
{
$PublishParameters['CopyPackageTimeoutSec'] = $CopyPackageTimeoutSec
}
# RegisterApplicationTypeTimeoutSec parameter overrides the value from the publish profile
if ($RegisterApplicationTypeTimeoutSec)
{
$PublishParameters['RegisterApplicationTypeTimeoutSec'] = $RegisterApplicationTypeTimeoutSec
}
if ($IsUpgrade)
{
$Action = "RegisterAndUpgrade"
if ($DeployOnly)
{
$Action = "Register"
}
$UpgradeParameters = $publishProfile.UpgradeDeployment.Parameters
if ($OverrideUpgradeBehavior -eq 'ForceUpgrade')
{
# Warning: Do not alter these upgrade parameters. It will create an inconsistency with Visual Studio's behavior.
$UpgradeParameters = @{ UnmonitoredAuto = $true; Force = $true }
}
$PublishParameters['Action'] = $Action
$PublishParameters['UpgradeParameters'] = $UpgradeParameters
$PublishParameters['UnregisterUnusedVersions'] = $UnregisterUnusedApplicationVersionsAfterUpgrade
Publish-UpgradedServiceFabricApplication @PublishParameters
}
else
{
$Action = "RegisterAndCreate"
if ($DeployOnly)
{
$Action = "Register"
}
$PublishParameters['Action'] = $Action
$PublishParameters['OverwriteBehavior'] = $OverwriteBehavior
$PublishParameters['SkipPackageValidation'] = $SkipPackageValidation
Publish-NewServiceFabricApplication @PublishParameters
}

View File

@ -1,51 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.10\build\Microsoft.VisualStudio.Azure.Fabric.Application.props" Condition="Exists('..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.10\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" />
<PropertyGroup Label="Globals">
<ProjectGuid>013da2cd-0fda-4747-b3fc-1726bde4fd00</ProjectGuid>
<ProjectVersion>2.5</ProjectVersion>
<MinToolsVersion>1.5</MinToolsVersion>
<SupportedMSBuildNuGetPackageVersion>1.6.10</SupportedMSBuildNuGetPackageVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<None Include="ApplicationPackageRoot\ApplicationManifest.xml" />
<None Include="ApplicationParameters\Cloud.xml" />
<None Include="ApplicationParameters\Local.1Node.xml" />
<None Include="ApplicationParameters\Local.5Node.xml" />
<None Include="PublishProfiles\Cloud.xml" />
<None Include="PublishProfiles\Local.1Node.xml" />
<None Include="PublishProfiles\Local.5Node.xml" />
<None Include="Scripts\Deploy-FabricApplication.ps1" />
</ItemGroup>
<ItemGroup>
<Content Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WeatherService.NetCore31\WeatherService.NetCore31.csproj" />
<ProjectReference Include="..\WeatherService.NetFx461\WeatherService.NetFx461.csproj" />
<ProjectReference Include="..\WebApp\WebApp.csproj">
<ServiceLaunchUrl>http://{MachineName}:{ServicePort}/weatherforecast</ServiceLaunchUrl>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
<PropertyGroup>
<ApplicationProjectTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Service Fabric Tools\Microsoft.VisualStudio.Azure.Fabric.ApplicationProject.targets</ApplicationProjectTargetsPath>
</PropertyGroup>
<Import Project="$(ApplicationProjectTargetsPath)" Condition="Exists('$(ApplicationProjectTargetsPath)')" />
<Import Project="..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.10\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets" Condition="Exists('..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.10\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" />
<Target Name="ValidateMSBuildFiles" BeforeTargets="PrepareForBuild">
<Error Condition="!Exists('..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.10\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" Text="Unable to find the '..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.10\build\Microsoft.VisualStudio.Azure.Fabric.Application.props' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package." />
<Error Condition="!Exists('..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.10\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" Text="Unable to find the '..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.10\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package." />
</Target>
</Project>

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.VisualStudio.Azure.Fabric.MSBuild" version="1.6.10" targetFramework="net461" />
</packages>

View File

@ -1,57 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30225.117
MinimumVisualStudioVersion = 10.0.40219.1
Project("{A07B5EB6-E848-4116-A8D0-A826331D98C6}") = "ServiceFabricApplication", "ServiceFabricApplication\ServiceFabricApplication.sfproj", "{013DA2CD-0FDA-4747-B3FC-1726BDE4FD00}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebApp", "WebApp\WebApp.csproj", "{35D2DD19-F76D-490D-9DF6-0B8CCB97018E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WeatherService.NetCore31", "WeatherService.NetCore31\WeatherService.NetCore31.csproj", "{62A2C141-DD29-44BA-88BA-99CE709D1F6C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WeatherService.Abstractions", "WeatherService.Abstractions\WeatherService.Abstractions.csproj", "{5B19C92B-70F3-4944-82E2-778F6DA25D37}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{10D3D75A-E5B7-43B4-9937-C7AE7723E34F}"
ProjectSection(SolutionItems) = preProject
DatadogInstall.bat = DatadogInstall.bat
DatadogInstall.ps1 = DatadogInstall.ps1
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WeatherService.NetFx461", "WeatherService.NetFx461\WeatherService.NetFx461.csproj", "{4C032F2D-7A58-44B1-AF96-8EB655E49668}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{013DA2CD-0FDA-4747-B3FC-1726BDE4FD00}.Debug|x64.ActiveCfg = Debug|x64
{013DA2CD-0FDA-4747-B3FC-1726BDE4FD00}.Debug|x64.Build.0 = Debug|x64
{013DA2CD-0FDA-4747-B3FC-1726BDE4FD00}.Debug|x64.Deploy.0 = Debug|x64
{013DA2CD-0FDA-4747-B3FC-1726BDE4FD00}.Release|x64.ActiveCfg = Release|x64
{013DA2CD-0FDA-4747-B3FC-1726BDE4FD00}.Release|x64.Build.0 = Release|x64
{013DA2CD-0FDA-4747-B3FC-1726BDE4FD00}.Release|x64.Deploy.0 = Release|x64
{35D2DD19-F76D-490D-9DF6-0B8CCB97018E}.Debug|x64.ActiveCfg = Debug|x64
{35D2DD19-F76D-490D-9DF6-0B8CCB97018E}.Debug|x64.Build.0 = Debug|x64
{35D2DD19-F76D-490D-9DF6-0B8CCB97018E}.Release|x64.ActiveCfg = Release|x64
{35D2DD19-F76D-490D-9DF6-0B8CCB97018E}.Release|x64.Build.0 = Release|x64
{62A2C141-DD29-44BA-88BA-99CE709D1F6C}.Debug|x64.ActiveCfg = Debug|x64
{62A2C141-DD29-44BA-88BA-99CE709D1F6C}.Debug|x64.Build.0 = Debug|x64
{62A2C141-DD29-44BA-88BA-99CE709D1F6C}.Release|x64.ActiveCfg = Release|x64
{62A2C141-DD29-44BA-88BA-99CE709D1F6C}.Release|x64.Build.0 = Release|x64
{5B19C92B-70F3-4944-82E2-778F6DA25D37}.Debug|x64.ActiveCfg = Debug|x64
{5B19C92B-70F3-4944-82E2-778F6DA25D37}.Debug|x64.Build.0 = Debug|x64
{5B19C92B-70F3-4944-82E2-778F6DA25D37}.Release|x64.ActiveCfg = Release|x64
{5B19C92B-70F3-4944-82E2-778F6DA25D37}.Release|x64.Build.0 = Release|x64
{4C032F2D-7A58-44B1-AF96-8EB655E49668}.Debug|x64.ActiveCfg = Debug|x64
{4C032F2D-7A58-44B1-AF96-8EB655E49668}.Debug|x64.Build.0 = Debug|x64
{4C032F2D-7A58-44B1-AF96-8EB655E49668}.Release|x64.ActiveCfg = Release|x64
{4C032F2D-7A58-44B1-AF96-8EB655E49668}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {92BAE943-75F4-4682-8E29-F801A89BAEC0}
EndGlobalSection
EndGlobal

View File

@ -1,13 +0,0 @@
using System.Threading.Tasks;
using Microsoft.ServiceFabric.Services.Remoting;
using Microsoft.ServiceFabric.Services.Remoting.FabricTransport;
[assembly: FabricTransportServiceRemotingProvider(RemotingListenerVersion = RemotingListenerVersion.V2_1, RemotingClientVersion = RemotingClientVersion.V2_1)]
namespace WeatherService.Abstractions
{
public interface IWeatherService : IService
{
Task<WeatherForecast> GetWeather(string message);
}
}

View File

@ -1,15 +0,0 @@
using System;
namespace WeatherService.Abstractions
{
public class WeatherForecast
{
public DateTime Date { get; set; }
public int Temperature { get; set; }
public string Message { get; set; }
public string Service { get; set; }
}
}

View File

@ -1,13 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Platforms>x64</Platforms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ServiceFabric.Services.Remoting" Version="4.0.470" />
</ItemGroup>
</Project>

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<Settings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<!-- Add your custom configuration sections and parameters here -->
<!--
<Section Name="MyConfigSection">
<Parameter Name="MyParameter" Value="Value1" />
</Section>
-->
</Settings>

View File

@ -1,46 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="WeatherService_NetCore31"
Version="1.0.0"
xmlns="http://schemas.microsoft.com/2011/01/fabric"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ServiceTypes>
<!-- This is the name of your ServiceType.
This name must match the string used in the RegisterServiceAsync call in Program.cs. -->
<StatelessServiceType ServiceTypeName="WeatherService_NetCore31" />
</ServiceTypes>
<!-- Code package is your service executable. -->
<CodePackage Name="Code" Version="1.0.0">
<!-- Install Datadog .NET Tracer -->
<SetupEntryPoint>
<ExeHost>
<Program>DatadogInstall.bat</Program>
<WorkingFolder>CodePackage</WorkingFolder>
</ExeHost>
</SetupEntryPoint>
<EntryPoint>
<ExeHost>
<Program>WeatherService.NetFx461.exe</Program>
</ExeHost>
</EntryPoint>
<EnvironmentVariables>
<!-- Enable Datadog .NET Tracer -->
<EnvironmentVariable Name="CORECLR_ENABLE_PROFILING" Value="1" />
<EnvironmentVariable Name="COR_ENABLE_PROFILING" Value="1" />
</EnvironmentVariables>
</CodePackage>
<!-- Config package is the contents of the Config directoy under PackageRoot that contains an
independently-updateable and versioned set of custom configuration settings for your service. -->
<ConfigPackage Name="Config" Version="1.0.0" />
<Resources>
<Endpoints>
<!-- This endpoint is used by the communication listener to obtain the port on which to
listen. Please note that if your service is partitioned, this port is shared with
replicas of different partitions that are placed in your code. -->
<Endpoint Name="ServiceEndpointV2_1" />
</Endpoints>
</Resources>
</ServiceManifest>

View File

@ -1,24 +0,0 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.ServiceFabric.Services.Runtime;
namespace WeatherService.NetCore31
{
internal static class Program
{
/// <summary>
/// This is the entry point of the service host process.
/// </summary>
private static async Task Main()
{
// The ServiceManifest.XML file defines one or more service type names.
// Registering a service maps a service type name to a .NET type.
// When Service Fabric creates an instance of this service type,
// an instance of the class is created in this host process.
await ServiceRuntime.RegisterServiceAsync("WeatherService_NetCore31", context => new WeatherService(context));
// Prevents this host process from terminating so services keep running.
await Task.Delay(Timeout.Infinite);
}
}
}

View File

@ -1,25 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsServiceFabricServiceProject>True</IsServiceFabricServiceProject>
<ServerGarbageCollection>True</ServerGarbageCollection>
<Platforms>x64</Platforms>
</PropertyGroup>
<ItemGroup>
<None Include="..\DatadogInstall.bat" Link="DatadogInstall.bat">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\DatadogInstall.ps1" Link="DatadogInstall.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ServiceFabric.Services" Version="4.0.470" />
<ProjectReference Include="..\WeatherService.Abstractions\WeatherService.Abstractions.csproj" />
</ItemGroup>
</Project>

View File

@ -1,46 +0,0 @@
using System;
using System.Collections.Generic;
using System.Fabric;
using System.Threading.Tasks;
using Microsoft.ServiceFabric.Services.Communication.Runtime;
using Microsoft.ServiceFabric.Services.Remoting.Runtime;
using Microsoft.ServiceFabric.Services.Runtime;
using WeatherService.Abstractions;
namespace WeatherService.NetCore31
{
/// <summary>
/// An instance of this class is created for each service instance by the Service Fabric runtime.
/// </summary>
internal sealed class WeatherService : StatelessService, IWeatherService
{
public WeatherService(StatelessServiceContext context)
: base(context)
{
}
/// <summary>
/// Optional override to create listeners (e.g., TCP, HTTP) for this service replica to handle client or user requests.
/// </summary>
/// <returns>A collection of listeners.</returns>
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
return this.CreateServiceRemotingInstanceListeners();
}
public Task<WeatherForecast> GetWeather(string message)
{
var rng = new Random();
var forecast = new WeatherForecast
{
Date = DateTime.Now,
Temperature = rng.Next(-100, 100),
Message = message,
Service = typeof(WeatherService).FullName
};
return Task.FromResult(forecast);
}
}
}

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<Settings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<!-- Add your custom configuration sections and parameters here -->
<!--
<Section Name="MyConfigSection">
<Parameter Name="MyParameter" Value="Value1" />
</Section>
-->
</Settings>

View File

@ -1,46 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="WeatherService_NetFx461"
Version="1.0.0"
xmlns="http://schemas.microsoft.com/2011/01/fabric"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ServiceTypes>
<!-- This is the name of your ServiceType.
This name must match the string used in the RegisterServiceAsync call in Program.cs. -->
<StatelessServiceType ServiceTypeName="WeatherService_NetFx461" />
</ServiceTypes>
<!-- Code package is your service executable. -->
<CodePackage Name="Code" Version="1.0.0">
<!-- Install Datadog .NET Tracer -->
<SetupEntryPoint>
<ExeHost>
<Program>DatadogInstall.bat</Program>
<WorkingFolder>CodePackage</WorkingFolder>
</ExeHost>
</SetupEntryPoint>
<EntryPoint>
<ExeHost>
<Program>WeatherService.NetFx461.exe</Program>
</ExeHost>
</EntryPoint>
<EnvironmentVariables>
<!-- Enable Datadog .NET Tracer -->
<EnvironmentVariable Name="CORECLR_ENABLE_PROFILING" Value="1" />
<EnvironmentVariable Name="COR_ENABLE_PROFILING" Value="1" />
</EnvironmentVariables>
</CodePackage>
<!-- Config package is the contents of the Config directoy under PackageRoot that contains an
independently-updateable and versioned set of custom configuration settings for your service. -->
<ConfigPackage Name="Config" Version="1.0.0" />
<Resources>
<Endpoints>
<!-- This endpoint is used by the communication listener to obtain the port on which to
listen. Please note that if your service is partitioned, this port is shared with
replicas of different partitions that are placed in your code. -->
<Endpoint Name="ServiceEndpointV2_1" />
</Endpoints>
</Resources>
</ServiceManifest>

View File

@ -1,24 +0,0 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.ServiceFabric.Services.Runtime;
namespace WeatherService.NetFx461
{
internal static class Program
{
/// <summary>
/// This is the entry point of the service host process.
/// </summary>
private static async Task Main()
{
// The ServiceManifest.XML file defines one or more service type names.
// Registering a service maps a service type name to a .NET type.
// When Service Fabric creates an instance of this service type,
// an instance of the class is created in this host process.
await ServiceRuntime.RegisterServiceAsync("WeatherService_NetFx461", context => new WeatherService(context));
// Prevents this host process from terminating so services keep running.
await Task.Delay(Timeout.Infinite);
}
}
}

View File

@ -1,25 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net461</TargetFramework>
<IsServiceFabricServiceProject>True</IsServiceFabricServiceProject>
<ServerGarbageCollection>True</ServerGarbageCollection>
<Platforms>x64</Platforms>
</PropertyGroup>
<ItemGroup>
<None Include="..\DatadogInstall.bat" Link="DatadogInstall.bat">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\DatadogInstall.ps1" Link="DatadogInstall.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ServiceFabric.Services" Version="4.0.470" />
<ProjectReference Include="..\WeatherService.Abstractions\WeatherService.Abstractions.csproj" />
</ItemGroup>
</Project>

View File

@ -1,46 +0,0 @@
using System;
using System.Collections.Generic;
using System.Fabric;
using System.Threading.Tasks;
using Microsoft.ServiceFabric.Services.Communication.Runtime;
using Microsoft.ServiceFabric.Services.Remoting.Runtime;
using Microsoft.ServiceFabric.Services.Runtime;
using WeatherService.Abstractions;
namespace WeatherService.NetFx461
{
/// <summary>
/// An instance of this class is created for each service instance by the Service Fabric runtime.
/// </summary>
internal sealed class WeatherService : StatelessService, IWeatherService
{
public WeatherService(StatelessServiceContext context)
: base(context)
{
}
/// <summary>
/// Optional override to create listeners (e.g., TCP, HTTP) for this service replica to handle client or user requests.
/// </summary>
/// <returns>A collection of listeners.</returns>
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
return this.CreateServiceRemotingInstanceListeners();
}
public Task<WeatherForecast> GetWeather(string message)
{
var rng = new Random();
var forecast = new WeatherForecast
{
Date = DateTime.Now,
Temperature = rng.Next(-100, 100),
Message = message,
Service = typeof(WeatherService).FullName
};
return Task.FromResult(forecast);
}
}
}

View File

@ -1,35 +0,0 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.ServiceFabric.Services.Remoting.Client;
using WeatherService.Abstractions;
namespace WebApp.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly IWeatherService WeatherServiceNetCore31 = ServiceProxy.Create<IWeatherService>(new Uri("fabric:/ServiceFabricApplication/WeatherService_NetCore31"));
private static readonly IWeatherService WeatherServiceNetFx461 = ServiceProxy.Create<IWeatherService>(new Uri("fabric:/ServiceFabricApplication/WeatherService_NetFx461"));
[HttpGet]
public string Get()
{
return "Hello, world!";
}
[HttpGet("netcore31")]
public async Task<WeatherForecast> GetNetCore31()
{
return await WeatherServiceNetCore31.GetWeather("Hello, world!");
}
[HttpGet("netfx461")]
public async Task<WeatherForecast> GetNetFx461()
{
return await WeatherServiceNetFx461.GetWeather("Hello, world!");
}
}
}

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<Settings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<!-- Add your custom configuration sections and parameters here -->
<!--
<Section Name="MyConfigSection">
<Parameter Name="MyParameter" Value="Value1" />
</Section>
-->
</Settings>

View File

@ -1,48 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="WebApp"
Version="1.0.0"
xmlns="http://schemas.microsoft.com/2011/01/fabric"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ServiceTypes>
<!-- This is the name of your ServiceType.
This name must match the string used in RegisterServiceType call in Program.cs. -->
<StatelessServiceType ServiceTypeName="WebApp" />
</ServiceTypes>
<!-- Code package is your service executable. -->
<CodePackage Name="Code" Version="1.0.0">
<!-- Install Datadog .NET Tracer -->
<SetupEntryPoint>
<ExeHost>
<Program>DatadogInstall.bat</Program>
<WorkingFolder>CodePackage</WorkingFolder>
</ExeHost>
</SetupEntryPoint>
<EntryPoint>
<ExeHost>
<Program>WebApp.exe</Program>
<WorkingFolder>CodePackage</WorkingFolder>
</ExeHost>
</EntryPoint>
<EnvironmentVariables>
<EnvironmentVariable Name="ASPNETCORE_ENVIRONMENT" Value=""/>
<!-- Enable Datadog .NET Tracer -->
<EnvironmentVariable Name="CORECLR_ENABLE_PROFILING" Value="1" />
<EnvironmentVariable Name="COR_ENABLE_PROFILING" Value="1" />
</EnvironmentVariables>
</CodePackage>
<!-- Config package is the contents of the Config directoy under PackageRoot that contains an
independently-updateable and versioned set of custom configuration settings for your service. -->
<ConfigPackage Name="Config" Version="1.0.0" />
<Resources>
<Endpoints>
<!-- This endpoint is used by the communication listener to obtain the port on which to
listen. Please note that if your service is partitioned, this port is shared with
replicas of different partitions that are placed in your code. -->
<Endpoint Protocol="http" Name="ServiceEndpoint" Type="Input" Port="8742" />
</Endpoints>
</Resources>
</ServiceManifest>

View File

@ -1,42 +0,0 @@
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.ServiceFabric.Services.Runtime;
namespace WebApp
{
internal static class Program
{
/// <summary>
/// This is the entry point of the service host process.
/// </summary>
private static async Task Main(string[] args)
{
if (args?.Length > 0 && args.Contains("standalone", StringComparer.OrdinalIgnoreCase))
{
await CreateHostBuilder(args).Build().RunAsync();
}
else
{
// The ServiceManifest.XML file defines one or more service type names.
// Registering a service maps a service type name to a .NET type.
// When Service Fabric creates an instance of this service type,
// an instance of the class is created in this host process.
await ServiceRuntime.RegisterServiceAsync("WebApp", context => new WebApp(context));
// Prevents this host process from terminating so services keeps running.
await Task.Delay(Timeout.Infinite);
}
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}

View File

@ -1,31 +0,0 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:54096",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "weatherforecast",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"WebApp": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "weatherforecast",
"applicationUrl": "http://localhost:54095",
"commandLineArgs": "standalone",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -1,39 +0,0 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace WebApp
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints => endpoints.MapControllers());
}
}
}

View File

@ -1,45 +0,0 @@
using System.Collections.Generic;
using System.Fabric;
using System.IO;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.ServiceFabric.Services.Communication.AspNetCore;
using Microsoft.ServiceFabric.Services.Communication.Runtime;
using Microsoft.ServiceFabric.Services.Runtime;
namespace WebApp
{
/// <summary>
/// The FabricRuntime creates an instance of this class for each service type instance.
/// </summary>
internal sealed class WebApp : StatelessService
{
public WebApp(StatelessServiceContext context)
: base(context)
{
}
/// <summary>
/// Optional override to create listeners (like tcp, http) for this service instance.
/// </summary>
/// <returns>The collection of listeners.</returns>
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
yield return new ServiceInstanceListener(
serviceContext =>
new KestrelCommunicationListener(serviceContext,
"ServiceEndpoint",
(url, listener) =>
{
return new WebHostBuilder()
.UseKestrel()
.ConfigureServices(services => services.AddSingleton(serviceContext))
.UseContentRoot(Directory.GetCurrentDirectory())
.UseStartup<Startup>()
.UseServiceFabricIntegration(listener, ServiceFabricIntegrationOptions.None)
.UseUrls(url)
.Build();
}));
}
}
}

View File

@ -1,28 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsServiceFabricServiceProject>True</IsServiceFabricServiceProject>
<ServerGarbageCollection>True</ServerGarbageCollection>
<Platforms>x64</Platforms>
</PropertyGroup>
<ItemGroup>
<None Include="..\DatadogInstall.bat" Link="DatadogInstall.bat">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\DatadogInstall.ps1" Link="DatadogInstall.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ServiceFabric.AspNetCore.Kestrel" Version="4.0.470" />
<PackageReference Include="Microsoft.ServiceFabric.Services" Version="4.0.470" />
<PackageReference Include="Microsoft.ServiceFabric.Services.Remoting" Version="4.0.470" />
<ProjectReference Include="..\WeatherService.Abstractions\WeatherService.Abstractions.csproj" />
</ItemGroup>
</Project>

View File

@ -1,10 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}

View File

@ -1,66 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29324.140
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AutomaticTraceIdInjection", "AutomaticTraceIdInjection", "{8AD58831-2198-4661-AC87-EFA754EDC4E9}"
ProjectSection(SolutionItems) = preProject
AutomaticTraceIdInjection\README.md = AutomaticTraceIdInjection\README.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Log4NetExample", "AutomaticTraceIdInjection\Log4NetExample\Log4NetExample.csproj", "{1115F7F9-B6A6-4E4C-8731-E3E875616DF7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SerilogExample", "AutomaticTraceIdInjection\SerilogExample\SerilogExample.csproj", "{51F8B356-6F95-460A-9549-52534B85042D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F901F53D-6A53-421C-91F6-B6E32A65826A}"
ProjectSection(SolutionItems) = preProject
Directory.Build.props = Directory.Build.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NLog45Example", "AutomaticTraceIdInjection\NLog45Example\NLog45Example.csproj", "{B987A36C-111D-41B7-9DA0-35DF790DD450}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NLog46Example", "AutomaticTraceIdInjection\NLog46Example\NLog46Example.csproj", "{82DD704F-20C9-4F77-B3ED-7E555E8077C8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NLog40Example", "AutomaticTraceIdInjection\NLog40Example\NLog40Example.csproj", "{13CA2EF4-EF35-4473-BA59-F0F6C35ED147}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1115F7F9-B6A6-4E4C-8731-E3E875616DF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1115F7F9-B6A6-4E4C-8731-E3E875616DF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1115F7F9-B6A6-4E4C-8731-E3E875616DF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1115F7F9-B6A6-4E4C-8731-E3E875616DF7}.Release|Any CPU.Build.0 = Release|Any CPU
{51F8B356-6F95-460A-9549-52534B85042D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{51F8B356-6F95-460A-9549-52534B85042D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{51F8B356-6F95-460A-9549-52534B85042D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{51F8B356-6F95-460A-9549-52534B85042D}.Release|Any CPU.Build.0 = Release|Any CPU
{B987A36C-111D-41B7-9DA0-35DF790DD450}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B987A36C-111D-41B7-9DA0-35DF790DD450}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B987A36C-111D-41B7-9DA0-35DF790DD450}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B987A36C-111D-41B7-9DA0-35DF790DD450}.Release|Any CPU.Build.0 = Release|Any CPU
{82DD704F-20C9-4F77-B3ED-7E555E8077C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{82DD704F-20C9-4F77-B3ED-7E555E8077C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{82DD704F-20C9-4F77-B3ED-7E555E8077C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{82DD704F-20C9-4F77-B3ED-7E555E8077C8}.Release|Any CPU.Build.0 = Release|Any CPU
{13CA2EF4-EF35-4473-BA59-F0F6C35ED147}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{13CA2EF4-EF35-4473-BA59-F0F6C35ED147}.Debug|Any CPU.Build.0 = Debug|Any CPU
{13CA2EF4-EF35-4473-BA59-F0F6C35ED147}.Release|Any CPU.ActiveCfg = Release|Any CPU
{13CA2EF4-EF35-4473-BA59-F0F6C35ED147}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{1115F7F9-B6A6-4E4C-8731-E3E875616DF7} = {8AD58831-2198-4661-AC87-EFA754EDC4E9}
{51F8B356-6F95-460A-9549-52534B85042D} = {8AD58831-2198-4661-AC87-EFA754EDC4E9}
{B987A36C-111D-41B7-9DA0-35DF790DD450} = {8AD58831-2198-4661-AC87-EFA754EDC4E9}
{82DD704F-20C9-4F77-B3ED-7E555E8077C8} = {8AD58831-2198-4661-AC87-EFA754EDC4E9}
{13CA2EF4-EF35-4473-BA59-F0F6C35ED147} = {8AD58831-2198-4661-AC87-EFA754EDC4E9}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1C64C3C7-7F87-46D4-88F8-1DB81303FBAC}
EndGlobalSection
EndGlobal

View File

@ -1,4 +0,0 @@
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyVersionAttribute("0.0.0.0")]

View File

@ -1,35 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net45</TargetFrameworks>
<!-- NuGet -->
<Version>0.0.1</Version>
<Title>OpenTelemetry AutoInstrumentation for ASP.NET</Title>
<AssemblyName>OpenTelemetry.AutoInstrumentation.AspNet</AssemblyName>
<PackageDescription>
DEPRECATED. This package exists only for backwards compatibility. If your project references this package ("OpenTelemetry.AutoInstrumentation.AspNet") or "OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed", you can remove them both.
.NET Core applications no longer require any NuGet package to enable automatic instrumentation.
Automatic instrumentation for both ASP.NET and ASP.NET Core is now automatically enabled.
Users who need manual instrumentation should reference the "OpenTelemetry.AutoInstrumentation" package.
</PackageDescription>
<!-- Allow the GenerateAssemblyInfo task in the .NET SDK to generate all
assembly attributes except for the AssemblyVersionAttribute. This will
be locked at Major.0.0.0 and is defined in AssemblyInfo.cs -->
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<!-- Remove the OpenTelemetry.AutoInstrumentation.AspNet.dll assembly from the output and hide inapplicable warning (https://docs.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu5128) -->
<IncludeBuildOutput>false</IncludeBuildOutput>
<NoWarn>$(NoWarn);NU5128</NoWarn>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Datadog.Trace\Datadog.Trace.csproj" />
<Reference Include="System.Web" />
</ItemGroup>
</Project>

View File

@ -1,7 +0,0 @@
namespace Datadog.Trace.AspNet
{
internal static class SharedConstants
{
public const string HttpContextPropagatedResourceNameKey = "__Datadog.Trace.ClrProfiler.Managed.AspNetMvcIntegration-aspnet.resourcename";
}
}

View File

@ -1,225 +0,0 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Datadog.Trace.Configuration;
using Datadog.Trace.ExtensionMethods;
using Datadog.Trace.Headers;
using Datadog.Trace.Logging;
using Datadog.Trace.Propagation;
using Datadog.Trace.Tagging;
using Datadog.Trace.Util;
namespace Datadog.Trace.AspNet
{
/// <summary>
/// IHttpModule used to trace within an ASP.NET HttpApplication request
/// </summary>
public class TracingHttpModule : IHttpModule
{
internal static readonly IntegrationInfo IntegrationId = IntegrationRegistry.GetIntegrationInfo(nameof(IntegrationIds.AspNet));
private static readonly IDatadogLogger Log = DatadogLogging.GetLoggerFor(typeof(TracingHttpModule));
// there is no ConcurrentHashSet, so use a ConcurrentDictionary
// where we only care about the key, not the value
private static ConcurrentDictionary<HttpApplication, byte> registeredEventHandlers = new ConcurrentDictionary<HttpApplication, byte>();
private readonly string _httpContextScopeKey;
private readonly string _requestOperationName;
private HttpApplication _httpApplication;
/// <summary>
/// Initializes a new instance of the <see cref="TracingHttpModule" /> class.
/// </summary>
public TracingHttpModule()
: this("aspnet.request")
{
}
/// <summary>
/// Initializes a new instance of the <see cref="TracingHttpModule" /> class.
/// </summary>
/// <param name="operationName">The operation name to be used for the trace/span data generated</param>
public TracingHttpModule(string operationName)
{
_requestOperationName = operationName ?? throw new ArgumentNullException(nameof(operationName));
_httpContextScopeKey = string.Concat("__Datadog.Trace.AspNet.TracingHttpModule-", _requestOperationName);
}
/// <inheritdoc />
public void Init(HttpApplication httpApplication)
{
// Intent: The first HttpModule to run Init for this HttpApplication will register for events
// Actual: Each HttpApplication that comes through here is potentially a new .NET object, even
// if it refers to the same web application. Based on my reading, it appears that initialization
// is done for several types of resources. Read more in this SO article -- look at Sunday Ironfoot's
// (yes, reliable sounding name of course) response toward the end of this article:
// https://stackoverflow.com/a/2416546/24231.
// I've discovered that not letting each of these unique application objects be added, and thus
// the event handlers be registered within each HttpApplication object, leads to the runtime
// weirdness: at one point it crashed consistently for me, and later, I saw no spans at all.
if (registeredEventHandlers.TryAdd(httpApplication, 1))
{
_httpApplication = httpApplication;
httpApplication.BeginRequest += OnBeginRequest;
httpApplication.EndRequest += OnEndRequest;
httpApplication.Error += OnError;
}
}
/// <inheritdoc />
public void Dispose()
{
// defend against multiple calls to Dispose()
if (_httpApplication != null)
{
// Remove the HttpApplication mapping so we don't keep the object alive
registeredEventHandlers.TryRemove(_httpApplication, out var _);
_httpApplication = null;
}
}
private void OnBeginRequest(object sender, EventArgs eventArgs)
{
Scope scope = null;
try
{
var tracer = Tracer.Instance;
if (!tracer.Settings.IsIntegrationEnabled(IntegrationId))
{
// integration disabled
return;
}
var httpContext = (sender as HttpApplication)?.Context;
if (httpContext == null)
{
return;
}
HttpRequest httpRequest = httpContext.Request;
SpanContext propagatedContext = null;
var tagsFromHeaders = Enumerable.Empty<KeyValuePair<string, string>>();
var propagator = tracer.Propagator;
if (tracer.ActiveScope == null)
{
try
{
// extract propagated http headers
var headers = httpRequest.Headers.Wrap();
propagatedContext = propagator.Extract(headers);
tagsFromHeaders = headers.ExtractHeaderTags(tracer.Settings.HeaderTags, PropagationExtensions.HttpRequestHeadersTagPrefix);
}
catch (Exception ex)
{
Log.Error(ex, "Error extracting propagated HTTP headers.");
}
}
string host = httpRequest.Headers.Get("Host");
string httpMethod = httpRequest.HttpMethod.ToUpperInvariant();
string url = httpRequest.RawUrl.ToLowerInvariant();
var tags = new WebTags();
scope = tracer.StartActiveWithTags(_requestOperationName, propagatedContext, tags: tags);
// Leave resourceName blank for now - we'll update it in OnEndRequest
scope.Span.DecorateWebServerSpan(resourceName: null, httpMethod, host, url, tags, tagsFromHeaders);
tags.SetAnalyticsSampleRate(IntegrationId, tracer.Settings, enabledWithGlobalSetting: true);
httpContext.Items[_httpContextScopeKey] = scope;
// Decorate the incoming HTTP Request with distributed tracing headers
// in case the next processor cannot access the stored Scope
// (e.g. WCF being hosted in IIS)
if (HttpRuntime.UsingIntegratedPipeline)
{
propagator.Inject(scope.Span.Context, httpRequest.Headers.Wrap());
}
}
catch (Exception ex)
{
// Dispose here, as the scope won't be in context items and won't get disposed on request end in that case...
scope?.Dispose();
Log.Error(ex, "Datadog ASP.NET HttpModule instrumentation error");
}
}
private void OnEndRequest(object sender, EventArgs eventArgs)
{
try
{
if (!Tracer.Instance.Settings.IsIntegrationEnabled(IntegrationId))
{
// integration disabled
return;
}
if (sender is HttpApplication app &&
app.Context.Items[_httpContextScopeKey] is Scope scope)
{
if (HttpRuntime.UsingIntegratedPipeline)
{
scope.Span.SetHeaderTags<IHeadersCollection>(app.Context.Response.Headers.Wrap(), Tracer.Instance.Settings.HeaderTags, defaultTagPrefix: PropagationExtensions.HttpResponseHeadersTagPrefix);
}
scope.Span.SetHttpStatusCode(app.Context.Response.StatusCode, isServer: true);
if (app.Context.Items[SharedConstants.HttpContextPropagatedResourceNameKey] is string resourceName
&& !string.IsNullOrEmpty(resourceName))
{
scope.Span.ResourceName = resourceName;
}
else
{
string path = UriHelpers.GetCleanUriPath(app.Request.Url);
scope.Span.ResourceName = $"{app.Request.HttpMethod.ToUpperInvariant()} {path.ToLowerInvariant()}";
}
scope.Dispose();
}
}
catch (Exception ex)
{
Log.Error(ex, "Datadog ASP.NET HttpModule instrumentation error");
}
}
private void OnError(object sender, EventArgs eventArgs)
{
try
{
var httpContext = (sender as HttpApplication)?.Context;
var exception = httpContext?.Error;
// We want to ignore 404 exceptions here, as they are not errors
var httpException = exception as HttpException;
var is404 = httpException?.GetHttpCode() == 404;
if (httpContext.Items[_httpContextScopeKey] is Scope scope)
{
if (HttpRuntime.UsingIntegratedPipeline)
{
scope.Span.SetHeaderTags<IHeadersCollection>(httpContext.Response.Headers.Wrap(), Tracer.Instance.Settings.HeaderTags, defaultTagPrefix: PropagationExtensions.HttpResponseHeadersTagPrefix);
}
if (exception != null && !is404)
{
scope.Span.SetException(exception);
}
}
}
catch (Exception ex)
{
Log.Error(ex, "Datadog ASP.NET HttpModule instrumentation error");
}
}
}
}

View File

@ -1,25 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net461;netstandard2.0;netcoreapp3.1</TargetFrameworks>
<!-- NuGet -->
<Version>1.18.4-prerelease</Version>
<Title>Datadog APM</Title>
<Description>BenchmarkDotNet exporter for Datadog APM</Description>
</PropertyGroup>
<!-- For VS testing purposes only, copy all implementation assemblies to the
to test the loading of managed profiler assemblies from disk -->
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)'=='true' and ('$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'netcoreapp3.1')">
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Datadog.Trace\Datadog.Trace.csproj" />
</ItemGroup>
<Import Project="..\Datadog.Trace.Ci.Shared\Datadog.Trace.Ci.Shared.projitems" Label="Shared" />
</Project>

View File

@ -1,182 +0,0 @@
using System;
using System.Collections.Generic;
using System.Threading;
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.Exporters;
using BenchmarkDotNet.Loggers;
using BenchmarkDotNet.Reports;
using Datadog.Trace.Ci;
using Datadog.Trace.ExtensionMethods;
using Datadog.Trace.Logging;
namespace Datadog.Trace.BenchmarkDotNet
{
/// <summary>
/// Datadog BenchmarkDotNet Exporter
/// </summary>
public class DatadogExporter : IExporter
{
/// <summary>
/// Default DatadogExporter instance
/// </summary>
public static readonly IExporter Default = new DatadogExporter();
private static readonly IDatadogLogger Log = DatadogLogging.GetLoggerFor(typeof(DatadogExporter));
static DatadogExporter()
{
// Preload environment variables.
CIEnvironmentValues.DecorateSpan(null);
}
/// <inheritdoc />
public string Name => nameof(DatadogExporter);
/// <inheritdoc />
public void ExportToLog(Summary summary, ILogger logger)
{
}
/// <inheritdoc />
public IEnumerable<string> ExportToFiles(Summary summary, ILogger consoleLogger)
{
DateTimeOffset startTime = DateTimeOffset.UtcNow;
Exception exception = null;
try
{
Tracer tracer = new Tracer();
foreach (var report in summary.Reports)
{
Span span = tracer.StartSpan("benchmarkdotnet.test", startTime: startTime);
double durationNanoseconds = 0;
span.SetTraceSamplingPriority(SamplingPriority.AutoKeep);
span.Type = SpanTypes.Test;
span.ResourceName = $"{report.BenchmarkCase.Descriptor.Type.FullName}.{report.BenchmarkCase.Descriptor.WorkloadMethod.Name}";
CIEnvironmentValues.DecorateSpan(span);
span.SetTag(TestTags.Name, report.BenchmarkCase.Descriptor.WorkloadMethodDisplayInfo);
span.SetTag(TestTags.Type, TestTags.TypeBenchmark);
span.SetTag(TestTags.Suite, report.BenchmarkCase.Descriptor.Type.FullName);
span.SetTag(TestTags.Framework, $"BenchmarkDotNet {summary.HostEnvironmentInfo.BenchmarkDotNetVersion}");
span.SetTag(TestTags.Status, report.Success ? TestTags.StatusPass : TestTags.StatusFail);
if (summary.HostEnvironmentInfo != null)
{
span.SetTag("benchmark.host.processor.name", ProcessorBrandStringHelper.Prettify(summary.HostEnvironmentInfo.CpuInfo.Value));
span.SetMetric("benchmark.host.processor.physical_processor_count", summary.HostEnvironmentInfo.CpuInfo.Value.PhysicalProcessorCount);
span.SetMetric("benchmark.host.processor.physical_core_count", summary.HostEnvironmentInfo.CpuInfo.Value.PhysicalCoreCount);
span.SetMetric("benchmark.host.processor.logical_core_count", summary.HostEnvironmentInfo.CpuInfo.Value.LogicalCoreCount);
span.SetMetric("benchmark.host.processor.max_frequency_hertz", summary.HostEnvironmentInfo.CpuInfo.Value.MaxFrequency?.Hertz);
span.SetTag("benchmark.host.os_version", summary.HostEnvironmentInfo.OsVersion.Value);
span.SetTag("benchmark.host.runtime_version", summary.HostEnvironmentInfo.RuntimeVersion);
span.SetMetric("benchmark.host.chronometer.frequency_hertz", summary.HostEnvironmentInfo.ChronometerFrequency.Hertz);
span.SetMetric("benchmark.host.chronometer.resolution", summary.HostEnvironmentInfo.ChronometerResolution.Nanoseconds);
}
if (report.BenchmarkCase.Job != null)
{
var job = report.BenchmarkCase.Job;
span.SetTag("benchmark.job.description", job.DisplayInfo);
if (job.Environment != null)
{
var jobEnv = job.Environment;
span.SetTag("benchmark.job.environment.platform", jobEnv.Platform.ToString());
if (jobEnv.Runtime != null)
{
span.SetTag("benchmark.job.runtime.name", jobEnv.Runtime.Name);
span.SetTag("benchmark.job.runtime.moniker", jobEnv.Runtime.MsBuildMoniker);
}
}
}
if (report.ResultStatistics != null)
{
var stats = report.ResultStatistics;
span.SetMetric("benchmark.runs", stats.N);
span.SetMetric("benchmark.duration.mean", stats.Mean);
span.SetMetric("benchmark.statistics.n", stats.N);
span.SetMetric("benchmark.statistics.max", stats.Max);
span.SetMetric("benchmark.statistics.min", stats.Min);
span.SetMetric("benchmark.statistics.mean", stats.Mean);
span.SetMetric("benchmark.statistics.median", stats.Median);
span.SetMetric("benchmark.statistics.std_dev", stats.StandardDeviation);
span.SetMetric("benchmark.statistics.std_err", stats.StandardError);
span.SetMetric("benchmark.statistics.kurtosis", stats.Kurtosis);
span.SetMetric("benchmark.statistics.skewness", stats.Skewness);
if (stats.Percentiles != null)
{
span.SetMetric("benchmark.statistics.p90", stats.Percentiles.P90);
span.SetMetric("benchmark.statistics.p95", stats.Percentiles.P95);
span.SetMetric("benchmark.statistics.p99", stats.Percentiles.Percentile(99));
}
durationNanoseconds = stats.Mean;
}
if (report.Metrics != null)
{
foreach (var keyValue in report.Metrics)
{
if (keyValue.Value is null || keyValue.Value.Descriptor is null)
{
continue;
}
span.SetTag($"benchmark.metrics.{keyValue.Key}.displayName", keyValue.Value.Descriptor.DisplayName);
span.SetTag($"benchmark.metrics.{keyValue.Key}.legend", keyValue.Value.Descriptor.Legend);
span.SetTag($"benchmark.metrics.{keyValue.Key}.unit", keyValue.Value.Descriptor.Unit);
span.SetMetric($"benchmark.metrics.{keyValue.Key}.value", keyValue.Value.Value);
}
}
if (report.BenchmarkCase.Config?.HasMemoryDiagnoser() == true)
{
span.SetMetric("benchmark.memory.gen0Collections", report.GcStats.Gen0Collections);
span.SetMetric("benchmark.memory.gen1Collections", report.GcStats.Gen1Collections);
span.SetMetric("benchmark.memory.gen2Collections", report.GcStats.Gen2Collections);
span.SetMetric("benchmark.memory.total_operations", report.GcStats.TotalOperations);
span.SetMetric("benchmark.memory.mean_bytes_allocations", report.GcStats.BytesAllocatedPerOperation);
span.SetMetric("benchmark.memory.total_bytes_allocations", report.GcStats.GetTotalAllocatedBytes(false));
}
var duration = TimeSpan.FromTicks((long)(durationNanoseconds / TimeConstants.NanoSecondsPerTick));
span.Finish(startTime.Add(duration));
}
// Ensure all the spans gets flushed before we report the success.
// In some cases the process finishes without sending the traces in the buffer.
SynchronizationContext context = SynchronizationContext.Current;
try
{
SynchronizationContext.SetSynchronizationContext(null);
tracer.FlushAsync().GetAwaiter().GetResult();
}
finally
{
SynchronizationContext.SetSynchronizationContext(context);
}
}
catch (Exception ex)
{
exception = ex;
consoleLogger.WriteLine(LogKind.Error, ex.ToString());
}
if (exception is null)
{
return new string[] { "Datadog Exporter ran successfully." };
}
else
{
return new string[] { "Datadog Exporter error: " + exception.ToString() };
}
}
}
}

View File

@ -1,18 +0,0 @@
using BenchmarkDotNet.Attributes;
namespace Datadog.Trace.BenchmarkDotNet
{
/// <summary>
/// Datadog BenchmarkDotNet exporter
/// </summary>
public class DatadogExporterAttribute : ExporterConfigBaseAttribute
{
/// <summary>
/// Initializes a new instance of the <see cref="DatadogExporterAttribute"/> class.
/// </summary>
public DatadogExporterAttribute()
: base(DatadogExporter.Default)
{
}
}
}

View File

@ -1,138 +0,0 @@
namespace Datadog.Trace.Ci
{
/// <summary>
/// Span tags for build data model
/// </summary>
internal static class BuildTags
{
/// <summary>
/// Build operation name
/// </summary>
public const string BuildOperationName = "msbuild.build";
/// <summary>
/// Build name
/// </summary>
public const string BuildName = "build.name";
/// <summary>
/// Build command
/// </summary>
public const string BuildCommand = "build.command";
/// <summary>
/// Build working folder
/// </summary>
public const string BuildWorkingFolder = "build.working_folder";
/// <summary>
/// Build environment
/// </summary>
public const string BuildEnvironment = "build.environment";
/// <summary>
/// Build start message
/// </summary>
public const string BuildStartMessage = "build.start_message";
/// <summary>
/// Build start message
/// </summary>
public const string BuildEndMessage = "build.end_message";
/// <summary>
/// Build status
/// </summary>
public const string BuildStatus = "build.status";
/// <summary>
/// Build succeeded status
/// </summary>
public const string BuildSucceededStatus = "SUCCEEDED";
/// <summary>
/// Build failed status
/// </summary>
public const string BuildFailedStatus = "FAILED";
/// <summary>
/// Project properties
/// </summary>
public const string ProjectProperties = "project.properties";
/// <summary>
/// Project filename
/// </summary>
public const string ProjectFile = "project.file";
/// <summary>
/// Project sender entity
/// </summary>
public const string ProjectSenderName = "project.sender_name";
/// <summary>
/// Project target names
/// </summary>
public const string ProjectTargetNames = "project.target_names";
/// <summary>
/// Project tools version
/// </summary>
public const string ProjectToolsVersion = "project.tools_version";
/// <summary>
/// Error message
/// </summary>
public const string ErrorMessage = "error.msg";
/// <summary>
/// Error type
/// </summary>
public const string ErrorType = "error.type";
/// <summary>
/// Error code
/// </summary>
public const string ErrorCode = "error.code";
/// <summary>
/// Error file
/// </summary>
public const string ErrorFile = "error.file";
/// <summary>
/// Error start line
/// </summary>
public const string ErrorStartLine = "error.start_location.line";
/// <summary>
/// Error start column
/// </summary>
public const string ErrorStartColumn = "error.start_location.column";
/// <summary>
/// Error end line
/// </summary>
public const string ErrorEndLine = "error.end_location.line";
/// <summary>
/// Error end column
/// </summary>
public const string ErrorEndColumn = "error.end_location.column";
/// <summary>
/// Error project file
/// </summary>
public const string ErrorProjectFile = "error.project_file";
/// <summary>
/// Error sub category
/// </summary>
public const string ErrorSubCategory = "error.sub_category";
/// <summary>
/// Error stack
/// </summary>
public const string ErrorStack = "error.stack";
}
}

View File

@ -1,612 +0,0 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using Datadog.Trace.Logging;
using Datadog.Trace.Util;
namespace Datadog.Trace.Ci
{
internal static class CIEnvironmentValues
{
private static readonly IDatadogLogger Logger = DatadogLogging.GetLoggerFor(typeof(CIEnvironmentValues));
static CIEnvironmentValues()
{
ReloadEnvironmentData();
}
public static bool IsCI { get; private set; }
public static string Provider { get; private set; }
public static string Repository { get; private set; }
public static string Commit { get; private set; }
public static string Branch { get; private set; }
public static string Tag { get; private set; }
public static string AuthorName { get; private set; }
public static string AuthorEmail { get; private set; }
public static DateTimeOffset? AuthorDate { get; private set; }
public static string CommitterName { get; private set; }
public static string CommitterEmail { get; private set; }
public static DateTimeOffset? CommitterDate { get; private set; }
public static string Message { get; private set; }
public static string SourceRoot { get; private set; }
public static string PipelineId { get; private set; }
public static string PipelineName { get; private set; }
public static string PipelineNumber { get; private set; }
public static string PipelineUrl { get; private set; }
public static string JobUrl { get; private set; }
public static string JobName { get; private set; }
public static string StageName { get; private set; }
public static string WorkspacePath { get; private set; }
public static void DecorateSpan(Span span)
{
if (span == null)
{
return;
}
span.SetTagIfNotNullOrEmpty(CommonTags.CIProvider, Provider);
span.SetTagIfNotNullOrEmpty(CommonTags.CIPipelineId, PipelineId);
span.SetTagIfNotNullOrEmpty(CommonTags.CIPipelineName, PipelineName);
span.SetTagIfNotNullOrEmpty(CommonTags.CIPipelineNumber, PipelineNumber);
span.SetTagIfNotNullOrEmpty(CommonTags.CIPipelineUrl, PipelineUrl);
span.SetTagIfNotNullOrEmpty(CommonTags.CIJobUrl, JobUrl);
span.SetTagIfNotNullOrEmpty(CommonTags.CIJobName, JobName);
span.SetTagIfNotNullOrEmpty(CommonTags.StageName, StageName);
span.SetTagIfNotNullOrEmpty(CommonTags.CIWorkspacePath, WorkspacePath);
span.SetTagIfNotNullOrEmpty(CommonTags.GitRepository, Repository);
span.SetTagIfNotNullOrEmpty(CommonTags.GitCommit, Commit);
span.SetTagIfNotNullOrEmpty(CommonTags.GitBranch, Branch);
span.SetTagIfNotNullOrEmpty(CommonTags.GitTag, Tag);
span.SetTagIfNotNullOrEmpty(CommonTags.GitCommitAuthorName, AuthorName);
span.SetTagIfNotNullOrEmpty(CommonTags.GitCommitAuthorEmail, AuthorEmail);
span.SetTagIfNotNullOrEmpty(CommonTags.GitCommitAuthorDate, AuthorDate?.ToString("yyyy-MM-dd'T'HH:mm:ss.fffK", CultureInfo.InvariantCulture));
span.SetTagIfNotNullOrEmpty(CommonTags.GitCommitCommitterName, CommitterName);
span.SetTagIfNotNullOrEmpty(CommonTags.GitCommitCommitterEmail, CommitterEmail);
span.SetTagIfNotNullOrEmpty(CommonTags.GitCommitCommitterDate, CommitterDate?.ToString("yyyy-MM-dd'T'HH:mm:ss.fffK", CultureInfo.InvariantCulture));
span.SetTagIfNotNullOrEmpty(CommonTags.GitCommitMessage, Message);
span.SetTagIfNotNullOrEmpty(CommonTags.BuildSourceRoot, SourceRoot);
}
internal static void ReloadEnvironmentData()
{
// **********
// Setup variables
// **********
Provider = null;
PipelineId = null;
PipelineName = null;
PipelineNumber = null;
PipelineUrl = null;
JobUrl = null;
JobName = null;
StageName = null;
WorkspacePath = null;
Repository = null;
Commit = null;
Branch = null;
Tag = null;
AuthorName = null;
AuthorEmail = null;
AuthorDate = null;
CommitterName = null;
CommitterEmail = null;
CommitterDate = null;
Message = null;
SourceRoot = null;
GitInfo gitInfo = GitInfo.GetCurrent();
if (EnvironmentHelpers.GetEnvironmentVariable("TRAVIS") != null)
{
SetupTravisEnvironment();
}
else if (EnvironmentHelpers.GetEnvironmentVariable("CIRCLECI") != null)
{
SetupCircleCiEnvironment();
}
else if (EnvironmentHelpers.GetEnvironmentVariable("JENKINS_URL") != null)
{
SetupJenkinsEnvironment();
}
else if (EnvironmentHelpers.GetEnvironmentVariable("GITLAB_CI") != null)
{
SetupGitlabEnvironment();
}
else if (EnvironmentHelpers.GetEnvironmentVariable("APPVEYOR") != null)
{
SetupAppveyorEnvironment();
}
else if (EnvironmentHelpers.GetEnvironmentVariable("TF_BUILD") != null)
{
SetupAzurePipelinesEnvironment();
}
else if (EnvironmentHelpers.GetEnvironmentVariable("BITBUCKET_COMMIT") != null)
{
SetupBitbucketEnvironment();
}
else if (EnvironmentHelpers.GetEnvironmentVariable("GITHUB_SHA") != null)
{
SetupGithubActionsEnvironment();
}
else if (EnvironmentHelpers.GetEnvironmentVariable("TEAMCITY_VERSION") != null)
{
SetupTeamcityEnvironment();
}
else if (EnvironmentHelpers.GetEnvironmentVariable("BUILDKITE") != null)
{
SetupBuildkiteEnvironment();
}
else if (EnvironmentHelpers.GetEnvironmentVariable("BITRISE_BUILD_SLUG") != null)
{
SetupBitriseEnvironment();
}
else
{
Branch = gitInfo.Branch;
Commit = gitInfo.Commit;
Repository = gitInfo.Repository;
SourceRoot = gitInfo.SourceRoot;
WorkspacePath = gitInfo.SourceRoot;
}
// **********
// Add Author, Committer and Message from git
// **********
// Merge commits have a different commit hash from the one reported by the CI.
if (gitInfo.Commit == Commit)
{
AuthorName = gitInfo.AuthorName;
AuthorEmail = gitInfo.AuthorEmail;
AuthorDate = gitInfo.AuthorDate;
CommitterName = gitInfo.CommitterName;
CommitterEmail = gitInfo.CommitterEmail;
CommitterDate = gitInfo.CommitterDate;
Message = gitInfo.Message;
}
// **********
// Remove sensitive info from repository url
// **********
if (Uri.TryCreate(Repository, UriKind.Absolute, out Uri repository))
{
if (!string.IsNullOrEmpty(repository.UserInfo))
{
Repository = repository.GetComponents(UriComponents.Fragment | UriComponents.Query | UriComponents.Path | UriComponents.Port | UriComponents.Host | UriComponents.Scheme, UriFormat.SafeUnescaped);
}
}
// **********
// Expand ~ in Paths
// **********
SourceRoot = ExpandPath(SourceRoot);
WorkspacePath = ExpandPath(WorkspacePath);
// **********
// Clean Refs
// **********
CleanBranchAndTag();
}
private static void SetupTravisEnvironment()
{
IsCI = true;
Provider = "travisci";
string prSlug = EnvironmentHelpers.GetEnvironmentVariable("TRAVIS_PULL_REQUEST_SLUG");
string repoSlug = !string.IsNullOrEmpty(prSlug) ? prSlug : EnvironmentHelpers.GetEnvironmentVariable("TRAVIS_REPO_SLUG");
Repository = string.Format("https://github.com/{0}.git", repoSlug);
Commit = EnvironmentHelpers.GetEnvironmentVariable("TRAVIS_COMMIT");
Tag = EnvironmentHelpers.GetEnvironmentVariable("TRAVIS_TAG");
if (string.IsNullOrEmpty(Tag))
{
Branch = EnvironmentHelpers.GetEnvironmentVariable("TRAVIS_PULL_REQUEST_BRANCH");
if (string.IsNullOrWhiteSpace(Branch))
{
Branch = EnvironmentHelpers.GetEnvironmentVariable("TRAVIS_BRANCH");
}
}
SourceRoot = EnvironmentHelpers.GetEnvironmentVariable("TRAVIS_BUILD_DIR");
WorkspacePath = EnvironmentHelpers.GetEnvironmentVariable("TRAVIS_BUILD_DIR");
PipelineId = EnvironmentHelpers.GetEnvironmentVariable("TRAVIS_BUILD_ID");
PipelineNumber = EnvironmentHelpers.GetEnvironmentVariable("TRAVIS_BUILD_NUMBER");
PipelineName = repoSlug;
PipelineUrl = EnvironmentHelpers.GetEnvironmentVariable("TRAVIS_BUILD_WEB_URL");
JobUrl = EnvironmentHelpers.GetEnvironmentVariable("TRAVIS_JOB_WEB_URL");
}
private static void SetupCircleCiEnvironment()
{
IsCI = true;
Provider = "circleci";
Repository = EnvironmentHelpers.GetEnvironmentVariable("CIRCLE_REPOSITORY_URL");
Commit = EnvironmentHelpers.GetEnvironmentVariable("CIRCLE_SHA1");
Tag = EnvironmentHelpers.GetEnvironmentVariable("CIRCLE_TAG");
if (string.IsNullOrEmpty(Tag))
{
Branch = EnvironmentHelpers.GetEnvironmentVariable("CIRCLE_BRANCH");
}
SourceRoot = EnvironmentHelpers.GetEnvironmentVariable("CIRCLE_WORKING_DIRECTORY");
WorkspacePath = EnvironmentHelpers.GetEnvironmentVariable("CIRCLE_WORKING_DIRECTORY");
PipelineId = EnvironmentHelpers.GetEnvironmentVariable("CIRCLE_WORKFLOW_ID");
PipelineNumber = EnvironmentHelpers.GetEnvironmentVariable("CIRCLE_BUILD_NUM");
PipelineName = EnvironmentHelpers.GetEnvironmentVariable("CIRCLE_PROJECT_REPONAME");
PipelineUrl = EnvironmentHelpers.GetEnvironmentVariable("CIRCLE_BUILD_URL");
JobUrl = EnvironmentHelpers.GetEnvironmentVariable("CIRCLE_BUILD_URL");
}
private static void SetupJenkinsEnvironment()
{
IsCI = true;
Provider = "jenkins";
Repository = EnvironmentHelpers.GetEnvironmentVariable("GIT_URL");
Commit = EnvironmentHelpers.GetEnvironmentVariable("GIT_COMMIT");
string gitBranch = EnvironmentHelpers.GetEnvironmentVariable("GIT_BRANCH");
if (gitBranch?.Contains("tags") == true)
{
Tag = gitBranch;
}
else
{
Branch = gitBranch;
}
SourceRoot = EnvironmentHelpers.GetEnvironmentVariable("WORKSPACE");
WorkspacePath = EnvironmentHelpers.GetEnvironmentVariable("WORKSPACE");
PipelineId = EnvironmentHelpers.GetEnvironmentVariable("BUILD_TAG");
PipelineNumber = EnvironmentHelpers.GetEnvironmentVariable("BUILD_NUMBER");
PipelineUrl = EnvironmentHelpers.GetEnvironmentVariable("BUILD_URL");
// Pipeline Name algorithm from: https://github.com/DataDog/dd-trace-java/blob/master/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/ci/JenkinsInfo.java
string pipelineName = EnvironmentHelpers.GetEnvironmentVariable("JOB_NAME");
if (pipelineName != null)
{
CleanBranchAndTag();
// First, the git branch is removed from the raw jobName
string jobNameNoBranch = Branch != null ? pipelineName.Trim().Replace("/" + Branch, string.Empty) : pipelineName;
// Once the branch has been removed, we try to extract
// the configurations from the job name.
// The configurations have the form like "key1=value1,key2=value2"
Dictionary<string, string> configurations = new Dictionary<string, string>();
string[] jobNameParts = jobNameNoBranch.Split('/');
if (jobNameParts.Length > 1 && jobNameParts[1].Contains("="))
{
string configsStr = jobNameParts[1].ToLowerInvariant().Trim();
string[] configsKeyValue = configsStr.Split(',');
foreach (string configKeyValue in configsKeyValue)
{
string[] keyValue = configKeyValue.Trim().Split('=');
configurations[keyValue[0]] = keyValue[1];
}
}
if (configurations.Count == 0)
{
// If there is no configurations,
// the jobName is the original one without branch.
PipelineName = jobNameNoBranch;
}
else
{
// If there are configurations,
// the jobName is the first part of the splited raw jobName.
PipelineName = jobNameParts[0];
}
}
}
private static void SetupGitlabEnvironment()
{
IsCI = true;
Provider = "gitlab";
Repository = EnvironmentHelpers.GetEnvironmentVariable("CI_REPOSITORY_URL");
Commit = EnvironmentHelpers.GetEnvironmentVariable("CI_COMMIT_SHA");
Branch = EnvironmentHelpers.GetEnvironmentVariable("CI_COMMIT_BRANCH");
Tag = EnvironmentHelpers.GetEnvironmentVariable("CI_COMMIT_TAG");
if (string.IsNullOrWhiteSpace(Branch))
{
Branch = EnvironmentHelpers.GetEnvironmentVariable("CI_COMMIT_REF_NAME");
}
SourceRoot = EnvironmentHelpers.GetEnvironmentVariable("CI_PROJECT_DIR");
WorkspacePath = EnvironmentHelpers.GetEnvironmentVariable("CI_PROJECT_DIR");
PipelineId = EnvironmentHelpers.GetEnvironmentVariable("CI_PIPELINE_ID");
PipelineName = EnvironmentHelpers.GetEnvironmentVariable("CI_PROJECT_PATH");
PipelineNumber = EnvironmentHelpers.GetEnvironmentVariable("CI_PIPELINE_IID");
PipelineUrl = EnvironmentHelpers.GetEnvironmentVariable("CI_PIPELINE_URL");
JobUrl = EnvironmentHelpers.GetEnvironmentVariable("CI_JOB_URL");
JobName = EnvironmentHelpers.GetEnvironmentVariable("CI_JOB_NAME");
StageName = EnvironmentHelpers.GetEnvironmentVariable("CI_JOB_STAGE");
// Clean pipeline url
PipelineUrl = PipelineUrl?.Replace("/-/pipelines/", "/pipelines/");
}
private static void SetupAppveyorEnvironment()
{
IsCI = true;
Provider = "appveyor";
string repoProvider = EnvironmentHelpers.GetEnvironmentVariable("APPVEYOR_REPO_PROVIDER");
if (repoProvider == "github")
{
Repository = string.Format("https://github.com/{0}.git", EnvironmentHelpers.GetEnvironmentVariable("APPVEYOR_REPO_NAME"));
}
else
{
Repository = EnvironmentHelpers.GetEnvironmentVariable("APPVEYOR_REPO_NAME");
}
Commit = EnvironmentHelpers.GetEnvironmentVariable("APPVEYOR_REPO_COMMIT");
SourceRoot = EnvironmentHelpers.GetEnvironmentVariable("APPVEYOR_BUILD_FOLDER");
WorkspacePath = EnvironmentHelpers.GetEnvironmentVariable("APPVEYOR_BUILD_FOLDER");
PipelineId = EnvironmentHelpers.GetEnvironmentVariable("APPVEYOR_BUILD_ID");
PipelineName = EnvironmentHelpers.GetEnvironmentVariable("APPVEYOR_REPO_NAME");
PipelineNumber = EnvironmentHelpers.GetEnvironmentVariable("APPVEYOR_BUILD_NUMBER");
PipelineUrl = string.Format("https://ci.appveyor.com/project/{0}/builds/{1}", EnvironmentHelpers.GetEnvironmentVariable("APPVEYOR_REPO_NAME"), EnvironmentHelpers.GetEnvironmentVariable("APPVEYOR_BUILD_ID"));
JobUrl = PipelineUrl;
Branch = EnvironmentHelpers.GetEnvironmentVariable("APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH");
Tag = EnvironmentHelpers.GetEnvironmentVariable("APPVEYOR_REPO_TAG_NAME");
if (string.IsNullOrWhiteSpace(Branch))
{
Branch = EnvironmentHelpers.GetEnvironmentVariable("APPVEYOR_REPO_BRANCH");
}
}
private static void SetupAzurePipelinesEnvironment()
{
IsCI = true;
Provider = "azurepipelines";
SourceRoot = EnvironmentHelpers.GetEnvironmentVariable("BUILD_SOURCESDIRECTORY");
WorkspacePath = EnvironmentHelpers.GetEnvironmentVariable("BUILD_SOURCESDIRECTORY");
PipelineId = EnvironmentHelpers.GetEnvironmentVariable("BUILD_BUILDID");
PipelineName = EnvironmentHelpers.GetEnvironmentVariable("BUILD_DEFINITIONNAME");
PipelineNumber = EnvironmentHelpers.GetEnvironmentVariable("BUILD_BUILDID");
PipelineUrl = string.Format(
"{0}{1}/_build/results?buildId={2}",
EnvironmentHelpers.GetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONSERVERURI"),
EnvironmentHelpers.GetEnvironmentVariable("SYSTEM_TEAMPROJECTID"),
EnvironmentHelpers.GetEnvironmentVariable("BUILD_BUILDID"));
JobUrl = string.Format(
"{0}{1}/_build/results?buildId={2}&view=logs&j={3}&t={4}",
EnvironmentHelpers.GetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONSERVERURI"),
EnvironmentHelpers.GetEnvironmentVariable("SYSTEM_TEAMPROJECTID"),
EnvironmentHelpers.GetEnvironmentVariable("BUILD_BUILDID"),
EnvironmentHelpers.GetEnvironmentVariable("SYSTEM_JOBID"),
EnvironmentHelpers.GetEnvironmentVariable("SYSTEM_TASKINSTANCEID"));
string prRepo = EnvironmentHelpers.GetEnvironmentVariable("SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI");
Repository = !string.IsNullOrWhiteSpace(prRepo) ? prRepo : EnvironmentHelpers.GetEnvironmentVariable("BUILD_REPOSITORY_URI");
string prCommit = EnvironmentHelpers.GetEnvironmentVariable("SYSTEM_PULLREQUEST_SOURCECOMMITID");
Commit = !string.IsNullOrWhiteSpace(prCommit) ? prCommit : EnvironmentHelpers.GetEnvironmentVariable("BUILD_SOURCEVERSION");
string prBranch = EnvironmentHelpers.GetEnvironmentVariable("SYSTEM_PULLREQUEST_SOURCEBRANCH");
Branch = !string.IsNullOrWhiteSpace(prBranch) ? prBranch : EnvironmentHelpers.GetEnvironmentVariable("BUILD_SOURCEBRANCH");
if (string.IsNullOrWhiteSpace(Branch))
{
Branch = EnvironmentHelpers.GetEnvironmentVariable("BUILD_SOURCEBRANCHNAME");
}
}
private static void SetupBitbucketEnvironment()
{
IsCI = true;
Provider = "bitbucket";
Repository = EnvironmentHelpers.GetEnvironmentVariable("BITBUCKET_GIT_SSH_ORIGIN");
Commit = EnvironmentHelpers.GetEnvironmentVariable("BITBUCKET_COMMIT");
Branch = EnvironmentHelpers.GetEnvironmentVariable("BITBUCKET_BRANCH");
Tag = EnvironmentHelpers.GetEnvironmentVariable("BITBUCKET_TAG");
SourceRoot = EnvironmentHelpers.GetEnvironmentVariable("BITBUCKET_CLONE_DIR");
WorkspacePath = EnvironmentHelpers.GetEnvironmentVariable("BITBUCKET_CLONE_DIR");
PipelineId = EnvironmentHelpers.GetEnvironmentVariable("BITBUCKET_PIPELINE_UUID")?.Replace("}", string.Empty).Replace("{", string.Empty);
PipelineNumber = EnvironmentHelpers.GetEnvironmentVariable("BITBUCKET_BUILD_NUMBER");
PipelineName = EnvironmentHelpers.GetEnvironmentVariable("BITBUCKET_REPO_FULL_NAME");
PipelineUrl = string.Format(
"https://bitbucket.org/{0}/addon/pipelines/home#!/results/{1}",
EnvironmentHelpers.GetEnvironmentVariable("BITBUCKET_REPO_FULL_NAME"),
EnvironmentHelpers.GetEnvironmentVariable("BITBUCKET_BUILD_NUMBER"));
JobUrl = PipelineUrl;
}
private static void SetupGithubActionsEnvironment()
{
IsCI = true;
Provider = "github";
Repository = string.Format("https://github.com/{0}.git", EnvironmentHelpers.GetEnvironmentVariable("GITHUB_REPOSITORY"));
Commit = EnvironmentHelpers.GetEnvironmentVariable("GITHUB_SHA");
string headRef = EnvironmentHelpers.GetEnvironmentVariable("GITHUB_HEAD_REF");
string ghRef = !string.IsNullOrEmpty(headRef) ? headRef : EnvironmentHelpers.GetEnvironmentVariable("GITHUB_REF");
if (ghRef.Contains("tags"))
{
Tag = ghRef;
}
else
{
Branch = ghRef;
}
SourceRoot = EnvironmentHelpers.GetEnvironmentVariable("GITHUB_WORKSPACE");
WorkspacePath = EnvironmentHelpers.GetEnvironmentVariable("GITHUB_WORKSPACE");
PipelineId = EnvironmentHelpers.GetEnvironmentVariable("GITHUB_RUN_ID");
PipelineNumber = EnvironmentHelpers.GetEnvironmentVariable("GITHUB_RUN_NUMBER");
PipelineName = EnvironmentHelpers.GetEnvironmentVariable("GITHUB_WORKFLOW");
PipelineUrl = $"https://github.com/{EnvironmentHelpers.GetEnvironmentVariable("GITHUB_REPOSITORY")}/commit/{Commit}/checks";
JobUrl = PipelineUrl;
}
private static void SetupTeamcityEnvironment()
{
IsCI = true;
Provider = "teamcity";
Repository = EnvironmentHelpers.GetEnvironmentVariable("BUILD_VCS_URL");
WorkspacePath = EnvironmentHelpers.GetEnvironmentVariable("BUILD_VCS_URL");
Commit = EnvironmentHelpers.GetEnvironmentVariable("BUILD_VCS_NUMBER");
SourceRoot = EnvironmentHelpers.GetEnvironmentVariable("BUILD_CHECKOUTDIR");
PipelineId = EnvironmentHelpers.GetEnvironmentVariable("BUILD_ID");
PipelineNumber = EnvironmentHelpers.GetEnvironmentVariable("BUILD_NUMBER");
string serverUrl = EnvironmentHelpers.GetEnvironmentVariable("SERVER_URL");
if (PipelineId != null && serverUrl != null)
{
PipelineUrl = $"{serverUrl}/viewLog.html?buildId={PipelineId}";
}
else
{
PipelineUrl = null;
}
}
private static void SetupBuildkiteEnvironment()
{
IsCI = true;
Provider = "buildkite";
Repository = EnvironmentHelpers.GetEnvironmentVariable("BUILDKITE_REPO");
Commit = EnvironmentHelpers.GetEnvironmentVariable("BUILDKITE_COMMIT");
Branch = EnvironmentHelpers.GetEnvironmentVariable("BUILDKITE_BRANCH");
Tag = EnvironmentHelpers.GetEnvironmentVariable("BUILDKITE_TAG");
SourceRoot = EnvironmentHelpers.GetEnvironmentVariable("BUILDKITE_BUILD_CHECKOUT_PATH");
WorkspacePath = EnvironmentHelpers.GetEnvironmentVariable("BUILDKITE_BUILD_CHECKOUT_PATH");
PipelineId = EnvironmentHelpers.GetEnvironmentVariable("BUILDKITE_BUILD_ID");
PipelineNumber = EnvironmentHelpers.GetEnvironmentVariable("BUILDKITE_BUILD_NUMBER");
PipelineName = EnvironmentHelpers.GetEnvironmentVariable("BUILDKITE_PIPELINE_SLUG");
PipelineUrl = EnvironmentHelpers.GetEnvironmentVariable("BUILDKITE_BUILD_URL");
JobUrl = string.Format("{0}#{1}", EnvironmentHelpers.GetEnvironmentVariable("BUILDKITE_BUILD_URL"), EnvironmentHelpers.GetEnvironmentVariable("BUILDKITE_JOB_ID"));
}
private static void SetupBitriseEnvironment()
{
IsCI = true;
Provider = "bitrise";
Repository = EnvironmentHelpers.GetEnvironmentVariable("GIT_REPOSITORY_URL");
string prCommit = EnvironmentHelpers.GetEnvironmentVariable("BITRISE_GIT_COMMIT");
Commit = !string.IsNullOrWhiteSpace(prCommit) ? prCommit : EnvironmentHelpers.GetEnvironmentVariable("GIT_CLONE_COMMIT_HASH");
string prBranch = EnvironmentHelpers.GetEnvironmentVariable("BITRISEIO_GIT_BRANCH_DEST");
Branch = !string.IsNullOrWhiteSpace(prBranch) ? prBranch : EnvironmentHelpers.GetEnvironmentVariable("BITRISE_GIT_BRANCH");
Tag = EnvironmentHelpers.GetEnvironmentVariable("BITRISE_GIT_TAG");
SourceRoot = EnvironmentHelpers.GetEnvironmentVariable("BITRISE_SOURCE_DIR");
WorkspacePath = EnvironmentHelpers.GetEnvironmentVariable("BITRISE_SOURCE_DIR");
PipelineId = EnvironmentHelpers.GetEnvironmentVariable("BITRISE_BUILD_SLUG");
PipelineNumber = EnvironmentHelpers.GetEnvironmentVariable("BITRISE_BUILD_NUMBER");
PipelineName = EnvironmentHelpers.GetEnvironmentVariable("BITRISE_APP_TITLE");
PipelineUrl = EnvironmentHelpers.GetEnvironmentVariable("BITRISE_BUILD_URL");
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static string ExpandPath(string path)
{
if (path == "~" || path?.StartsWith("~/") == true)
{
string homePath = (Environment.OSVersion.Platform == PlatformID.Unix ||
Environment.OSVersion.Platform == PlatformID.MacOSX)
? Environment.GetEnvironmentVariable("HOME")
: Environment.GetEnvironmentVariable("USERPROFILE");
path = homePath + path.Substring(1);
}
return path;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void SetTagIfNotNullOrEmpty(this Span span, string key, string value)
{
if (!string.IsNullOrEmpty(value))
{
span.SetTag(key, value);
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void CleanBranchAndTag()
{
var regex = new Regex(@"^refs\/heads\/tags\/(.*)|refs\/heads\/(.*)|refs\/tags\/(.*)|refs\/(.*)|origin\/tags\/(.*)|origin\/(.*)$");
try
{
// Clean tag name
if (!string.IsNullOrEmpty(Tag))
{
var match = regex.Match(Tag);
if (match.Success && match.Groups.Count == 7)
{
Tag =
!string.IsNullOrWhiteSpace(match.Groups[1].Value) ? match.Groups[1].Value :
!string.IsNullOrWhiteSpace(match.Groups[3].Value) ? match.Groups[3].Value :
!string.IsNullOrWhiteSpace(match.Groups[5].Value) ? match.Groups[5].Value :
!string.IsNullOrWhiteSpace(match.Groups[2].Value) ? match.Groups[2].Value :
match.Groups[4].Value;
}
}
}
catch (Exception ex)
{
Logger.Warning(ex, "Error fixing tag name: {TagName}", Tag);
}
try
{
// Clean branch name
if (!string.IsNullOrEmpty(Branch))
{
var match = regex.Match(Branch);
if (match.Success && match.Groups.Count == 7)
{
Branch =
!string.IsNullOrWhiteSpace(match.Groups[2].Value) ? match.Groups[2].Value :
!string.IsNullOrWhiteSpace(match.Groups[4].Value) ? match.Groups[4].Value :
match.Groups[6].Value;
if (string.IsNullOrEmpty(Tag))
{
Tag =
!string.IsNullOrWhiteSpace(match.Groups[1].Value) ? match.Groups[1].Value :
!string.IsNullOrWhiteSpace(match.Groups[3].Value) ? match.Groups[3].Value :
match.Groups[5].Value;
}
}
}
}
catch (Exception ex)
{
Logger.Warning(ex, "Error fixing branch name: {BranchName}", Branch);
}
}
}
}

View File

@ -1,170 +0,0 @@
namespace Datadog.Trace.Ci
{
/// <summary>
/// Common Span tags for test/build data model
/// </summary>
internal static class CommonTags
{
/// <summary>
/// GIT Repository
/// </summary>
[FeatureTracking]
public const string GitRepository = "git.repository_url";
/// <summary>
/// GIT Commit hash
/// </summary>
[FeatureTracking]
public const string GitCommit = "git.commit.sha";
/// <summary>
/// GIT Branch name
/// </summary>
[FeatureTracking]
public const string GitBranch = "git.branch";
/// <summary>
/// GIT Tag name
/// </summary>
[FeatureTracking]
public const string GitTag = "git.tag";
/// <summary>
/// GIT Commit Author name
/// </summary>
[FeatureTracking]
public const string GitCommitAuthorName = "git.commit.author.name";
/// <summary>
/// GIT Commit Author email
/// </summary>
[FeatureTracking]
public const string GitCommitAuthorEmail = "git.commit.author.email";
/// <summary>
/// GIT Commit Author date
/// </summary>
[FeatureTracking]
public const string GitCommitAuthorDate = "git.commit.author.date";
/// <summary>
/// GIT Commit Committer name
/// </summary>
[FeatureTracking]
public const string GitCommitCommitterName = "git.commit.committer.name";
/// <summary>
/// GIT Commit Committer email
/// </summary>
[FeatureTracking]
public const string GitCommitCommitterEmail = "git.commit.committer.email";
/// <summary>
/// GIT Commit Committer date
/// </summary>
[FeatureTracking]
public const string GitCommitCommitterDate = "git.commit.committer.date";
/// <summary>
/// GIT Commit message
/// </summary>
[FeatureTracking]
public const string GitCommitMessage = "git.commit.message";
/// <summary>
/// Build Source root
/// </summary>
[FeatureTracking]
public const string BuildSourceRoot = "build.source_root";
/// <summary>
/// CI Provider
/// </summary>
[FeatureTracking]
public const string CIProvider = "ci.provider.name";
/// <summary>
/// CI Pipeline id
/// </summary>
[FeatureTracking]
public const string CIPipelineId = "ci.pipeline.id";
/// <summary>
/// CI Pipeline name
/// </summary>
[FeatureTracking]
public const string CIPipelineName = "ci.pipeline.name";
/// <summary>
/// CI Pipeline number
/// </summary>
[FeatureTracking]
public const string CIPipelineNumber = "ci.pipeline.number";
/// <summary>
/// CI Pipeline url
/// </summary>
[FeatureTracking]
public const string CIPipelineUrl = "ci.pipeline.url";
/// <summary>
/// CI Job url
/// </summary>
[FeatureTracking]
public const string CIJobUrl = "ci.job.url";
/// <summary>
/// CI Job Name
/// </summary>
[FeatureTracking]
public const string CIJobName = "ci.job.name";
/// <summary>
/// CI Stage Name
/// </summary>
[FeatureTracking]
public const string StageName = "ci.stage.name";
/// <summary>
/// CI Job url
/// </summary>
[FeatureTracking]
public const string CIWorkspacePath = "ci.workspace_path";
/// <summary>
/// Runtime name
/// </summary>
[FeatureTracking]
public const string RuntimeName = "runtime.name";
/// <summary>
/// OS architecture
/// </summary>
[FeatureTracking]
public const string OSArchitecture = "os.architecture";
/// <summary>
/// OS platform
/// </summary>
[FeatureTracking]
public const string OSPlatform = "os.platform";
/// <summary>
/// OS version
/// </summary>
[FeatureTracking]
public const string OSVersion = "os.version";
/// <summary>
/// Runtime architecture
/// </summary>
[FeatureTracking]
public const string RuntimeArchitecture = "runtime.architecture";
/// <summary>
/// Runtime version
/// </summary>
[FeatureTracking]
public const string RuntimeVersion = "runtime.version";
}
}

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>a1d7653a-c409-414a-b9b0-7879953ebcdd</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>Datadog.Trace.Ci</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)BuildTags.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CIEnvironmentValues.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CommonTags.cs" />
<Compile Include="$(MSBuildThisFileDirectory)FeatureTrackingAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GitInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)TestParameters.cs" />
<Compile Include="$(MSBuildThisFileDirectory)TestTags.cs" />
</ItemGroup>
</Project>

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>a1d7653a-c409-414a-b9b0-7879953ebcdd</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="Datadog.Trace.Ci.Shared.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>

View File

@ -1,12 +0,0 @@
using System;
namespace Datadog.Trace.Ci
{
/// <summary>
/// Expose a constant as a feature tracking value
/// </summary>
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
internal class FeatureTrackingAttribute : Attribute
{
}
}

View File

@ -1,683 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Datadog.Trace.Logging;
namespace Datadog.Trace.Ci
{
/// <summary>
/// Git information class
/// </summary>
internal class GitInfo
{
private static readonly IDatadogLogger Log = DatadogLogging.GetLoggerFor(typeof(GitInfo));
private GitInfo()
{
}
/// <summary>
/// Gets Source root
/// </summary>
public string SourceRoot { get; private set; }
/// <summary>
/// Gets Repository
/// </summary>
public string Repository { get; private set; }
/// <summary>
/// Gets Branch
/// </summary>
public string Branch { get; private set; }
/// <summary>
/// Gets Commit
/// </summary>
public string Commit { get; private set; }
/// <summary>
/// Gets Author Name
/// </summary>
public string AuthorName { get; private set; }
/// <summary>
/// Gets Author Email
/// </summary>
public string AuthorEmail { get; private set; }
/// <summary>
/// Gets Author Date
/// </summary>
public DateTimeOffset? AuthorDate { get; private set; }
/// <summary>
/// Gets Committer Name
/// </summary>
public string CommitterName { get; private set; }
/// <summary>
/// Gets Committer Email
/// </summary>
public string CommitterEmail { get; private set; }
/// <summary>
/// Gets Committer Date
/// </summary>
public DateTimeOffset? CommitterDate { get; private set; }
/// <summary>
/// Gets PGP Signature
/// </summary>
public string PgpSignature { get; private set; }
/// <summary>
/// Gets Commit Message
/// </summary>
public string Message { get; private set; }
/// <summary>
/// Gets a GitInfo from a folder
/// </summary>
/// <param name="folder">Target folder to retrieve the git info</param>
/// <returns>Git info</returns>
public static GitInfo GetFrom(string folder)
{
return GetFrom(new DirectoryInfo(folder));
}
/// <summary>
/// Gets a GitInfo from the current folder or assembly attribute
/// </summary>
/// <returns>Git info</returns>
public static GitInfo GetCurrent()
{
string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
DirectoryInfo gitDirectory = GetParentGitFolder(baseDirectory) ?? GetParentGitFolder(Environment.CurrentDirectory);
return GetFrom(gitDirectory);
}
private static GitInfo GetFrom(DirectoryInfo gitDirectory)
{
if (gitDirectory == null)
{
return new GitInfo();
}
GitInfo gitInfo = new GitInfo();
try
{
gitInfo.SourceRoot = gitDirectory.Parent?.FullName;
// Get Git commit
string headPath = Path.Combine(gitDirectory.FullName, "HEAD");
if (File.Exists(headPath))
{
string head = File.ReadAllText(headPath).Trim();
// Symbolic Reference
if (head.StartsWith("ref:"))
{
gitInfo.Branch = head.Substring(4).Trim();
string refPath = Path.Combine(gitDirectory.FullName, gitInfo.Branch);
string infoRefPath = Path.Combine(gitDirectory.FullName, "info", "refs");
if (File.Exists(refPath))
{
// Get the commit from the .git/{refPath} file.
gitInfo.Commit = File.ReadAllText(refPath).Trim();
}
else if (File.Exists(infoRefPath))
{
// Get the commit from the .git/info/refs file.
string[] lines = File.ReadAllLines(infoRefPath);
foreach (string line in lines)
{
string[] hashRef = line.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
if (hashRef[1] == gitInfo.Branch)
{
gitInfo.Commit = hashRef[0];
}
}
}
}
else
{
// Hash reference
gitInfo.Commit = head;
}
}
// Process Git Config
string configPath = Path.Combine(gitDirectory.FullName, "config");
List<ConfigItem> lstConfigs = GetConfigItems(configPath);
if (lstConfigs != null && lstConfigs.Count > 0)
{
var remote = "origin";
var branchItem = lstConfigs.Find(i => i.Type == "branch" && i.Merge == gitInfo.Branch);
if (branchItem != null)
{
gitInfo.Branch = branchItem.Name;
remote = branchItem.Remote;
}
var remoteItem = lstConfigs.Find(i => i.Type == "remote" && i.Name == remote);
if (remoteItem != null)
{
gitInfo.Repository = remoteItem.Url;
}
}
// Get author and committer data
if (!string.IsNullOrEmpty(gitInfo.Commit))
{
string folder = gitInfo.Commit.Substring(0, 2);
string file = gitInfo.Commit.Substring(2);
string objectFilePath = Path.Combine(gitDirectory.FullName, "objects", folder, file);
if (File.Exists(objectFilePath))
{
// Load and parse object file
if (GitCommitObject.TryGetFromObjectFile(objectFilePath, out var commitObject))
{
gitInfo.AuthorDate = commitObject.AuthorDate;
gitInfo.AuthorEmail = commitObject.AuthorEmail;
gitInfo.AuthorName = commitObject.AuthorName;
gitInfo.CommitterDate = commitObject.CommitterDate;
gitInfo.CommitterEmail = commitObject.CommitterEmail;
gitInfo.CommitterName = commitObject.CommitterName;
gitInfo.Message = commitObject.Message;
gitInfo.PgpSignature = commitObject.PgpSignature;
}
}
else
{
// Search git object file from the pack files
string packFolder = Path.Combine(gitDirectory.FullName, "objects", "pack");
string[] files = Directory.GetFiles(packFolder, "*.idx", SearchOption.TopDirectoryOnly);
foreach (string idxFile in files)
{
if (GitPackageOffset.TryGetPackageOffset(idxFile, gitInfo.Commit, out var packageOffset))
{
if (GitCommitObject.TryGetFromPackageOffset(packageOffset, out var commitObject))
{
gitInfo.AuthorDate = commitObject.AuthorDate;
gitInfo.AuthorEmail = commitObject.AuthorEmail;
gitInfo.AuthorName = commitObject.AuthorName;
gitInfo.CommitterDate = commitObject.CommitterDate;
gitInfo.CommitterEmail = commitObject.CommitterEmail;
gitInfo.CommitterName = commitObject.CommitterName;
gitInfo.Message = commitObject.Message;
gitInfo.PgpSignature = commitObject.PgpSignature;
break;
}
}
}
}
}
}
catch (Exception ex)
{
Log.Error(ex, "Error loading git information from directory");
}
return gitInfo;
}
private static DirectoryInfo GetParentGitFolder(string innerFolder)
{
DirectoryInfo dirInfo = new DirectoryInfo(innerFolder);
while (dirInfo != null)
{
DirectoryInfo[] gitDirectories = dirInfo.GetDirectories(".git");
if (gitDirectories.Length > 0)
{
foreach (var gitDir in gitDirectories)
{
if (gitDir.Name == ".git")
{
return gitDir;
}
}
}
dirInfo = dirInfo.Parent;
}
return null;
}
private static List<ConfigItem> GetConfigItems(string configFile)
{
if (!File.Exists(configFile))
{
return null;
}
var lstConfig = new List<ConfigItem>();
ConfigItem currentItem = null;
var regex = new Regex("^\\[(.*) \\\"(.*)\\\"\\]");
string[] lines = File.ReadAllLines(configFile);
foreach (string line in lines)
{
if (line[0] == '\t')
{
if (currentItem != null)
{
string[] keyValue = line.Substring(1).Split(new string[] { " = " }, StringSplitOptions.RemoveEmptyEntries);
switch (keyValue[0])
{
case "url":
currentItem.Url = keyValue[1];
break;
case "remote":
currentItem.Remote = keyValue[1];
break;
case "merge":
currentItem.Merge = keyValue[1];
break;
}
}
continue;
}
var match = regex.Match(line);
if (match.Success)
{
if (currentItem != null)
{
lstConfig.Add(currentItem);
}
currentItem = new ConfigItem
{
Type = match.Groups[1].Value,
Name = match.Groups[2].Value
};
}
}
return lstConfig;
}
internal readonly struct GitCommitObject
{
public readonly string Tree;
public readonly string Parent;
public readonly string AuthorName;
public readonly string AuthorEmail;
public readonly DateTimeOffset? AuthorDate;
public readonly string CommitterName;
public readonly string CommitterEmail;
public readonly DateTimeOffset? CommitterDate;
public readonly string PgpSignature;
public readonly string Message;
private const string TreePrefix = "tree ";
private const string ParentPrefix = "parent ";
private const string AuthorPrefix = "author ";
private const string CommitterPrefix = "committer ";
private const string GpgSigPrefix = "gpgsig ";
private const long UnixEpochTicks = TimeSpan.TicksPerDay * 719162; // 621,355,968,000,000,000
private static readonly byte[] _commitByteArray = Encoding.UTF8.GetBytes("commit");
private GitCommitObject(string content)
{
Tree = null;
Parent = null;
AuthorName = null;
AuthorEmail = null;
AuthorDate = null;
CommitterName = null;
CommitterEmail = null;
CommitterDate = null;
PgpSignature = null;
Message = null;
string[] lines = content.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
List<string> msgLines = new List<string>();
for (var i = 0; i < lines.Length; i++)
{
string line = lines[i];
if (line.StartsWith(TreePrefix))
{
Tree = line.Substring(TreePrefix.Length);
continue;
}
if (line.StartsWith(ParentPrefix))
{
Parent = line.Substring(ParentPrefix.Length);
continue;
}
if (line.StartsWith(AuthorPrefix))
{
string authorContent = line.Substring(AuthorPrefix.Length);
string[] authorArray = authorContent.Split('<', '>');
AuthorName = authorArray[0].Trim();
AuthorEmail = authorArray[1].Trim();
string authorDate = authorArray[2].Trim();
string[] authorDateArray = authorDate.Split(' ');
if (long.TryParse(authorDateArray[0], out long unixSeconds))
{
AuthorDate = new DateTimeOffset((unixSeconds * TimeSpan.TicksPerSecond) + UnixEpochTicks, TimeSpan.Zero);
}
continue;
}
if (line.StartsWith(CommitterPrefix))
{
string committerContent = line.Substring(CommitterPrefix.Length);
string[] committerArray = committerContent.Split('<', '>');
CommitterName = committerArray[0].Trim();
CommitterEmail = committerArray[1].Trim();
string committerDate = committerArray[2].Trim();
string[] committerDateArray = committerDate.Split(' ');
if (long.TryParse(committerDateArray[0], out long unixSeconds))
{
CommitterDate = new DateTimeOffset((unixSeconds * TimeSpan.TicksPerSecond) + UnixEpochTicks, TimeSpan.Zero);
}
continue;
}
if (line.StartsWith(GpgSigPrefix))
{
string pgpLine = line.Substring(GpgSigPrefix.Length) + Environment.NewLine;
PgpSignature = pgpLine;
while (!pgpLine.Contains("END PGP SIGNATURE"))
{
i++;
pgpLine = lines[i];
PgpSignature += pgpLine + Environment.NewLine;
}
i++;
continue;
}
msgLines.Add(line);
}
Message += string.Join(Environment.NewLine, msgLines);
}
public static bool TryGetFromObjectFile(string filePath, out GitCommitObject commitObject)
{
commitObject = default;
try
{
using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
{
// We skip the 2 bytes zlib header magic number.
fs.Seek(2, SeekOrigin.Begin);
using (var defStream = new DeflateStream(fs, CompressionMode.Decompress))
{
byte[] buffer = new byte[8192];
int readBytes = defStream.Read(buffer, 0, buffer.Length);
defStream.Close();
if (_commitByteArray.SequenceEqual(buffer.Take(_commitByteArray.Length)))
{
string strContent = Encoding.UTF8.GetString(buffer, 0, readBytes);
string dataContent = strContent.Substring(strContent.IndexOf('\0') + 1);
commitObject = new GitCommitObject(dataContent);
return true;
}
}
}
}
catch (Exception ex)
{
Log.Error(ex, "Error getting commit object from object file");
}
return false;
}
public static bool TryGetFromPackageOffset(GitPackageOffset packageOffset, out GitCommitObject commitObject)
{
commitObject = default;
try
{
string packFile = Path.ChangeExtension(packageOffset.FilePath, ".pack");
if (File.Exists(packFile))
{
// packfile format explanation:
// https://codewords.recurse.com/issues/three/unpacking-git-packfiles#:~:text=idx%20file%20contains%20the%20index,pack%20file.&text=Objects%20in%20a%20packfile%20can,of%20storing%20the%20whole%20object.
using (var fs = new FileStream(packFile, FileMode.Open, FileAccess.Read, FileShare.Read))
using (var br = new BigEndianBinaryReader(fs))
{
// Move to the offset of the object
fs.Seek(packageOffset.Offset, SeekOrigin.Begin);
byte[] packData = br.ReadBytes(2);
// Extract the object size (https://codewords.recurse.com/images/three/varint.svg)
int objectSize = (int)(packData[0] & 0x0F);
if (packData[0] >= 128)
{
int shift = 4;
objectSize += (packData[1] & 0x7F) << shift;
if (packData[1] >= 128)
{
byte pData;
do
{
shift += 7;
pData = br.ReadByte();
objectSize += (pData & 0x7F) << shift;
}
while (pData >= 128);
}
}
// Check if the object size is in the aceptable range
if (objectSize > 0 && objectSize < ushort.MaxValue)
{
// Advance 2 bytes to skip the zlib magic number
uint zlibMagicNumber = br.ReadUInt16();
if ((byte)zlibMagicNumber == 0x78)
{
// Read the git commit object
using (var defStream = new DeflateStream(br.BaseStream, CompressionMode.Decompress))
{
byte[] buffer = new byte[objectSize];
int readBytes = defStream.Read(buffer, 0, buffer.Length);
defStream.Close();
string strContent = Encoding.UTF8.GetString(buffer, 0, readBytes);
commitObject = new GitCommitObject(strContent);
return true;
}
}
else
{
Log.Warning("The commit data doesn't have a valid zlib header magic number.");
}
}
else
{
Log.Warning<int>("The object size is outside of an acceptable range: {objectSize}", objectSize);
}
}
}
}
catch (Exception ex)
{
Log.Error(ex, "Error loading commit information from package offset");
}
return false;
}
}
internal readonly struct GitPackageOffset
{
public readonly string FilePath;
public readonly long Offset;
internal GitPackageOffset(string filePath, long offset)
{
FilePath = filePath;
Offset = offset;
}
public static bool TryGetPackageOffset(string idxFilePath, string commitSha, out GitPackageOffset packageOffset)
{
packageOffset = default;
// packfile format explanation:
// https://codewords.recurse.com/issues/three/unpacking-git-packfiles#:~:text=idx%20file%20contains%20the%20index,pack%20file.&text=Objects%20in%20a%20packfile%20can,of%20storing%20the%20whole%20object.
string index = commitSha.Substring(0, 2);
int folderIndex = int.Parse(index, System.Globalization.NumberStyles.HexNumber);
int previousIndex = folderIndex > 0 ? folderIndex - 1 : folderIndex;
try
{
using (var fs = new FileStream(idxFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
using (var br = new BigEndianBinaryReader(fs))
{
// Skip header and version
fs.Seek(8, SeekOrigin.Begin);
// First layer: 256 4-byte elements, with number of elements per folder
uint numberOfObjectsInPreviousIndex = 0;
if (previousIndex > -1)
{
// Seek to previous index position and read the number of objects
fs.Seek(previousIndex * 4, SeekOrigin.Current);
numberOfObjectsInPreviousIndex = br.ReadUInt32();
}
// In the fanout table, every index has its objects + the previous ones.
// We need to subtract the previous index objects to know the correct
// actual number of objects for this specific index.
uint numberOfObjectsInIndex = br.ReadUInt32() - numberOfObjectsInPreviousIndex;
// Seek to last position. The last position contains the number of all objects.
fs.Seek((255 - (folderIndex + 1)) * 4, SeekOrigin.Current);
uint totalNumberOfObjects = br.ReadUInt32();
// Second layer: 20-byte elements with the names in order
// Search the sha index in the second layer: the SHA listing.
uint? indexOfCommit = null;
fs.Seek(20 * (int)numberOfObjectsInPreviousIndex, SeekOrigin.Current);
for (uint i = 0; i < numberOfObjectsInIndex; i++)
{
string str = BitConverter.ToString(br.ReadBytes(20)).Replace("-", string.Empty);
if (str.Equals(commitSha, StringComparison.OrdinalIgnoreCase))
{
indexOfCommit = numberOfObjectsInPreviousIndex + i;
// If we find the SHA, we skip all SHA listing table.
fs.Seek(20 * (totalNumberOfObjects - (indexOfCommit.Value + 1)), SeekOrigin.Current);
break;
}
}
if (indexOfCommit.HasValue)
{
// Third layer: 4 byte CRC for each object. We skip it
fs.Seek(4 * totalNumberOfObjects, SeekOrigin.Current);
uint indexOfCommitValue = indexOfCommit.Value;
// Fourth layer: 4 byte per object of offset in pack file
fs.Seek(4 * indexOfCommitValue, SeekOrigin.Current);
uint offset = br.ReadUInt32();
ulong packOffset;
if (((offset >> 31) & 1) == 0)
{
// offset is in the layer
packOffset = (ulong)offset;
}
else
{
// offset is not in this layer, clear first bit and look at it at the 5th layer
offset &= 0x7FFFFFFF;
// Skip complete fourth layer.
fs.Seek(4 * (totalNumberOfObjects - (indexOfCommitValue + 1)), SeekOrigin.Current);
// Use the offset from fourth layer, to find the actual pack file offset in the fifth layer.
// In this case, the offset is 8 bytes long.
fs.Seek(8 * offset, SeekOrigin.Current);
packOffset = br.ReadUInt64();
}
packageOffset = new GitPackageOffset(idxFilePath, (long)packOffset);
return true;
}
}
}
catch (Exception ex)
{
Log.Error(ex, "Error getting package offset");
}
return false;
}
}
internal class ConfigItem
{
public string Type { get; set; }
public string Name { get; set; }
public string Url { get; set; }
public string Remote { get; set; }
public string Merge { get; set; }
}
internal class BigEndianBinaryReader : BinaryReader
{
public BigEndianBinaryReader(Stream stream)
: base(stream)
{
}
public override int ReadInt32()
{
var data = ReadBytes(4);
Array.Reverse(data);
return BitConverter.ToInt32(data, 0);
}
public override short ReadInt16()
{
var data = ReadBytes(2);
Array.Reverse(data);
return BitConverter.ToInt16(data, 0);
}
public override long ReadInt64()
{
var data = ReadBytes(8);
Array.Reverse(data);
return BitConverter.ToInt64(data, 0);
}
public override uint ReadUInt32()
{
var data = ReadBytes(4);
Array.Reverse(data);
return BitConverter.ToUInt32(data, 0);
}
}
}
}

View File

@ -1,19 +0,0 @@
using System.Collections.Generic;
using Datadog.Trace.Vendors.Newtonsoft.Json;
namespace Datadog.Trace.Ci
{
internal class TestParameters
{
[JsonProperty("metadata")]
public Dictionary<string, object> Metadata { get; set; }
[JsonProperty("arguments")]
public Dictionary<string, object> Arguments { get; set; }
internal string ToJSON()
{
return JsonConvert.SerializeObject(this);
}
}
}

Some files were not shown because too many files have changed in this diff Show More