Skip to content

Commit 7ab30d7

Browse files
authored
fix: The Profiler logger should be marked as "initialized" as soon as the file is created. (#3015)
1 parent 663ca40 commit 7ab30d7

File tree

5 files changed

+10
-8
lines changed

5 files changed

+10
-8
lines changed

.github/codeql/codeql-config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
paths:
2-
-'src' # this is the only path that needs to be scanned
2+
- src

.github/codeql/codql-config.yml

-2
This file was deleted.

.github/workflows/codeql.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ jobs:
5757
languages: csharp
5858
config-file: ./.github/codeql/codeql-config.yml
5959

60-
# build is not required for .NET projects
60+
- name: Build .NET Agent Solution
61+
run: |
62+
dotnet build ${{ env.fullagent_solution_path }}
63+
shell: powershell
6164

6265
- name: Perform CodeQL Analysis
6366
uses: github/codeql-action/analyze@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3.28.10

src/Agent/NewRelic/Home/Home.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</Target>
1414

1515
<ItemGroup>
16-
<PackageReference Include="NewRelic.Agent.Internal.Profiler" Version="10.37.0.7"/>
16+
<PackageReference Include="NewRelic.Agent.Internal.Profiler" Version="10.37.0.19"/>
1717
</ItemGroup>
1818

1919
</Project>

src/Agent/NewRelic/Profiler/Profiler/CorProfilerCallbackImpl.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,16 @@ namespace NewRelic { namespace Profiler {
222222
configFailed = true;
223223
}
224224

225-
// ...then we initialize the log
225+
// ...then we initialize the log file
226226
InitializeLogging();
227227

228228
// If we failed to load the config file, try again. Not because we expect it
229229
// to succeed, but because we want to log the error. We couldn't do that the
230230
// first time because the logger hadn't been initialized yet
231231
if (configFailed)
232232
{
233-
configuration = InitializeConfigAndSetLogLevel();
233+
nrlog::StdLog.SetInitalized(); // Ensure the logger is marked as initialized
234+
configuration = InitializeConfigAndSetLogLevel(); // this will throw an exception that we want to log
234235
}
235236

236237
LogTrace(_productName);
@@ -277,7 +278,7 @@ namespace NewRelic { namespace Profiler {
277278
return S_OK;
278279
}
279280
catch (...) {
280-
LogError(L"An exception was thrown while initializing the profiler.");
281+
LogError(L"An exception was thrown while initializing the profiler. The profiler will be detached now.");
281282
return CORPROF_E_PROFILER_CANCEL_ACTIVATION;
282283
}
283284
}

0 commit comments

Comments
 (0)