Skip to content

Commit 47871c7

Browse files
Add .NET Core support to msi installer (#173)
* remove extra slash from path * fix environment variables for .NET Core * rename product * add env variable that can disable logging, use separate path from Agent, add process id to filename * add NuGet package description
1 parent 550b18e commit 47871c7

File tree

4 files changed

+32
-18
lines changed

4 files changed

+32
-18
lines changed

deploy/Datadog.Trace.ClrProfiler.WindowsInstaller/Config.wxi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22

33
<Include>
4-
<?define BaseProductName = ".NET Tracing" ?>
4+
<?define BaseProductName = ".NET Tracer" ?>
55
<?define ArpManufacturer = "Datadog, Inc." ?>
66
<?define Company = "Datadog" ?>
77
<?define ManagedDllPath = "$(sys.CURRENTDIR)..\..\src\Datadog.Trace.ClrProfiler.Managed\bin\$(var.Configuration)\net45" ?>

deploy/Datadog.Trace.ClrProfiler.WindowsInstaller/Product.wxs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
<ComponentGroup Id="EnvironmentVariables.Machine" Directory="INSTALLFOLDER">
106106
<Component Id="EnvironmentVariablesShared" Guid="{C314A305-9C24-4E46-9ECF-E5EEA703BDEA}" Win64="$(var.Win64)">
107107
<CreateFolder/>
108-
<Environment Id="DD_INTEGRATIONS" Name="DD_INTEGRATIONS" Action="set" Permanent="no" System="yes" Value="[INSTALLFOLDER]\integrations.json" Part="all" />
108+
<Environment Id="DD_INTEGRATIONS" Name="DD_INTEGRATIONS" Action="set" Permanent="no" System="yes" Value="[INSTALLFOLDER]integrations.json" Part="all" />
109109
</Component>
110110
</ComponentGroup>
111111

@@ -114,14 +114,14 @@
114114
<CreateFolder/>
115115
<RegistryKey Root="HKLM"
116116
Key="System\CurrentControlSet\Services\W3SVC">
117-
<RegistryValue Type="multiString" Name="Environment" Value="COR_ENABLE_PROFILING=1[~]COR_PROFILER=$(var.ProfilerCLSID)[~]DD_PROFILER_PROCESSES=w3wp.exe" Action="append"/>
117+
<RegistryValue Type="multiString" Name="Environment" Value="COR_ENABLE_PROFILING=1[~]COR_PROFILER=$(var.ProfilerCLSID)[~]CORECLR_ENABLE_PROFILING=1[~]CORECLR_PROFILER=$(var.ProfilerCLSID)" Action="append"/>
118118
</RegistryKey>
119119
</Component>
120120

121121
<Component Id="Registry.EnvironmentVariables.WAS" Guid="{6CF8AB88-240E-4A0A-B630-43119C064AD4}" Win64="$(var.Win64)">
122122
<RegistryKey Root="HKLM"
123123
Key="System\CurrentControlSet\Services\WAS">
124-
<RegistryValue Type="multiString" Name="Environment" Value="COR_ENABLE_PROFILING=1[~]COR_PROFILER=$(var.ProfilerCLSID)[~]DD_PROFILER_PROCESSES=w3wp.exe" Action="append"/>
124+
<RegistryValue Type="multiString" Name="Environment" Value="COR_ENABLE_PROFILING=1[~]COR_PROFILER=$(var.ProfilerCLSID)[~]CORECLR_ENABLE_PROFILING=1[~]CORECLR_PROFILER=$(var.ProfilerCLSID)" Action="append"/>
125125
</RegistryKey>
126126
</Component>
127127
</ComponentGroup>

src/Datadog.Trace.ClrProfiler.Managed/Datadog.Trace.ClrProfiler.Managed.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
<Version>0.4.0-beta</Version>
66
<RootNamespace>Datadog.Trace.ClrProfiler</RootNamespace>
77
<LangVersion>7.3</LangVersion>
8+
<Description>
9+
Instrumentation code used by .NET Tracer for Datadog APM.
10+
Requires separate native library that implements the CLR Profiling API.
11+
</Description>
812
</PropertyGroup>
913

1014
<PropertyGroup Condition="'$(OS)' != 'Windows_NT'">

src/Datadog.Trace.ClrProfiler.Native/logging.cpp

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#include <spdlog/sinks/rotating_file_sink.h>
21
#include <spdlog/sinks/null_sink.h>
2+
#include <spdlog/sinks/rotating_file_sink.h>
33
#include <filesystem>
44

55
#include "logging.h"
@@ -14,21 +14,31 @@ std::shared_ptr<spdlog::logger> GetLogger() {
1414
std::unique_lock<std::mutex> lck(mtx);
1515

1616
try {
17-
auto programdata = GetEnvironmentValue(L"PROGRAMDATA");
18-
if (programdata.empty()) {
19-
programdata = L"C:\\ProgramData";
20-
}
21-
auto path = std::filesystem::path(programdata)
22-
.append("Datadog")
23-
.append("logs")
24-
.append("dotnet-profiler.log");
17+
const auto logger_enabled =
18+
GetEnvironmentValue(L"DD_DOTNET_TRACER_LOG_ENABLED");
2519

26-
if (!std::filesystem::exists(path.parent_path())) {
27-
std::filesystem::create_directories(path.parent_path());
28-
}
29-
logger = spdlog::rotating_logger_mt("dotnet-profiler", path.string(),
30-
1024 * 1024 * 5, 3);
20+
if (logger_enabled == L"0") {
21+
// disable logging, useful if the logger itself is crashing
22+
logger = spdlog::create<spdlog::sinks::null_sink_st>("dotnet-profiler");
23+
} else {
24+
auto programdata = GetEnvironmentValue(L"PROGRAMDATA");
25+
if (programdata.empty()) {
26+
programdata = L"C:\\ProgramData";
27+
}
3128

29+
DWORD process_id = GetCurrentProcessId();
30+
31+
auto path = std::filesystem::path(programdata)
32+
.append("Datadog .NET Tracer")
33+
.append("logs")
34+
.append("dotnet-profiler-" + std::to_string(process_id) + ".log");
35+
36+
if (!std::filesystem::exists(path.parent_path())) {
37+
std::filesystem::create_directories(path.parent_path());
38+
}
39+
logger = spdlog::rotating_logger_mt("dotnet-profiler", path.string(),
40+
1024 * 1024 * 5, 3);
41+
}
3242
} catch (...) {
3343
logger = spdlog::create<spdlog::sinks::null_sink_st>("dotnet-profiler");
3444
}

0 commit comments

Comments
 (0)