Skip to content

Commit b58beec

Browse files
committed
PR feedback
1 parent af75306 commit b58beec

File tree

10 files changed

+34
-34
lines changed

10 files changed

+34
-34
lines changed

documentation/schema.json

+8
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,14 @@
11231123
"$ref": "#/definitions/ExceptionsConfiguration"
11241124
}
11251125
]
1126+
},
1127+
"CollectOnStartup": {
1128+
"type": [
1129+
"boolean",
1130+
"null"
1131+
],
1132+
"description": "True if exception collection should begin immediately",
1133+
"default": true
11261134
}
11271135
}
11281136
},

src/Microsoft.Diagnostics.Monitoring.StartupHook/DiagnosticsBootstrapper.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ public DiagnosticsBootstrapper()
4040
new MessageDispatcher.ProfilerMessageSource(CommandSet.StartupHook));
4141
ToolIdentifiers.EnableEnvVar(InProcessFeaturesIdentifiers.EnvironmentVariables.AvailableInfrastructure.ManagedMessaging);
4242

43-
SharedInternals.MessageDispatcher.RegisterCallback<EmptyPayload>(StartupHookCommand.Stop, (IpcMessage) =>
43+
SharedInternals.MessageDispatcher.RegisterCallback<EmptyPayload>(StartupHookCommand.StopAllFeatures, (IpcMessage) =>
4444
{
4545
_exceptionProcessor.Stop();
4646
_parameterCapturingService?.RequestStopAll();
4747
});
4848

49-
SharedInternals.MessageDispatcher.RegisterCallback<EmptyPayload>(StartupHookCommand.Start, (IpcMessage) =>
49+
SharedInternals.MessageDispatcher.RegisterCallback<EmptyPayload>(StartupHookCommand.StartAllFeatures, (IpcMessage) =>
5050
{
5151
_exceptionProcessor.Start();
5252
});

src/Microsoft.Diagnostics.Monitoring.StartupHook/Exceptions/CurrentAppDomainFirstChanceExceptionSource.cs

-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ internal sealed class CurrentAppDomainFirstChanceExceptionSource :
1515
{
1616
private long _disposedState;
1717

18-
public CurrentAppDomainFirstChanceExceptionSource()
19-
{
20-
}
21-
2218
public override void Start()
2319
{
2420
AppDomain.CurrentDomain.FirstChanceException += CurrentDomain_FirstChanceException;

src/Microsoft.Diagnostics.Monitoring.StartupHook/Exceptions/CurrentAppDomainUnhandledExceptionSource.cs

-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ internal sealed class CurrentAppDomainUnhandledExceptionSource :
1414
{
1515
private long _disposedState;
1616

17-
public CurrentAppDomainUnhandledExceptionSource()
18-
{
19-
}
20-
2117
public override void Start()
2218
{
2319
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

src/Microsoft.Diagnostics.Monitoring.WebApi/ProfilerMessage.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ public enum ServerResponseCommand : ushort
2727
public enum ProfilerCommand : ushort
2828
{
2929
Callstack,
30-
Stop,
31-
Start,
30+
StopAllFeatures,
31+
StartAllFeatures,
3232
};
3333

3434
public enum StartupHookCommand : ushort
3535
{
3636
StartCapturingParameters,
3737
StopCapturingParameters,
38-
Stop,
39-
Start,
38+
StopAllFeatures,
39+
StartAllFeatures,
4040
};
4141

4242
public interface IProfilerMessage

src/Profilers/MonitorProfiler/Communication/CommandServer.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ void CommandServer::ProcessResetMessage(const IpcMessage& message, std::shared_p
151151

152152
_unmanagedOnlyQueue.Enqueue(nativeCallbackInfo);
153153

154-
hr = nativeCallbackInfo.Promise->get_future().get();
154+
hr = nativeCallbackInfo.CompletionPromise->get_future().get();
155155
}
156156
if (message.CommandSet == static_cast<unsigned short>(CommandSet::StartupHook))
157157
{
@@ -161,7 +161,7 @@ void CommandServer::ProcessResetMessage(const IpcMessage& message, std::shared_p
161161

162162
_clientQueue.Enqueue(managedCallbackInfo);
163163

164-
hr = managedCallbackInfo.Promise->get_future().get();
164+
hr = managedCallbackInfo.CompletionPromise->get_future().get();
165165
}
166166

167167
*reinterpret_cast<HRESULT*>(response.Payload.data()) = hr;
@@ -175,16 +175,16 @@ bool CommandServer::IsControlCommand(const IpcMessage& message)
175175
case static_cast<int>(CommandSet::Profiler):
176176
switch (message.Command)
177177
{
178-
case static_cast<int>(ProfilerCommand::Start):
179-
case static_cast<int>(ProfilerCommand::Stop):
178+
case static_cast<int>(ProfilerCommand::StartAllFeatures):
179+
case static_cast<int>(ProfilerCommand::StopAllFeatures):
180180
return true;
181181
default:
182182
return false;
183183
}
184184
case static_cast<int>(CommandSet::StartupHook):
185185
switch (message.Command) {
186-
case static_cast<int>(StartupHookCommand::Start):
187-
case static_cast<int>(StartupHookCommand::Stop):
186+
case static_cast<int>(StartupHookCommand::StartAllFeatures):
187+
case static_cast<int>(StartupHookCommand::StopAllFeatures):
188188
return true;
189189
default:
190190
return false;
@@ -250,9 +250,9 @@ void CommandServer::ProcessingThread(BlockingQueue<CallbackInfo>& queue)
250250
_logger->Log(LogLevel::Warning, _LS("IpcMessage callback failed: 0x%08x"), hr);
251251
}
252252

253-
if (info.Promise)
253+
if (info.CompletionPromise)
254254
{
255-
info.Promise->set_value(hr);
255+
info.CompletionPromise->set_value(hr);
256256
}
257257
}
258258
}

src/Profilers/MonitorProfiler/Communication/CommandServer.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class CommandServer final
3232
{
3333
public:
3434
IpcMessage Message;
35-
std::shared_ptr<std::promise<HRESULT>> Promise;
35+
std::shared_ptr<std::promise<HRESULT>> CompletionPromise;
3636
};
3737

3838
void ListeningThread();
@@ -48,7 +48,7 @@ class CommandServer final
4848
// Currently the managed payload always uses json deserialization
4949
// The native payload ignores this
5050
info.Message.Payload = std::vector<BYTE>({ (BYTE)'{', (BYTE)'}' });
51-
info.Promise = std::make_shared<std::promise<HRESULT>>();
51+
info.CompletionPromise = std::make_shared<std::promise<HRESULT>>();
5252
}
5353

5454
// Wrapper methods for sending and logging

src/Profilers/MonitorProfiler/Communication/Messages.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ enum class ProfilerCommand : unsigned short
1111

1212
// Indicate that any outstanding collection should be stopped and all data should be flushed
1313
// Currently a no-op
14-
Stop,
14+
StopAllFeatures,
1515

1616
// Indicate that collection should resume again
1717
// Currently a no-op
18-
Start,
18+
StartAllFeatures,
1919
};
2020

2121
enum class StartupHookCommand : unsigned short
@@ -26,11 +26,11 @@ enum class StartupHookCommand : unsigned short
2626
// Indicates that all collection should stop
2727
// Request cancellation on all outstanding ParameterCapture requests
2828
// Unhooks from exception handling events, drains all the exception state, and resets the pipelines
29-
Stop,
29+
StopAllFeatures,
3030

3131
// Indicates that all collection should start
3232
// Reconnects exception handler events
33-
Start,
33+
StartAllFeatures,
3434
};
3535

3636
enum class ServerResponseCommand : unsigned short

src/Profilers/MonitorProfiler/MainProfiler/MainProfiler.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,8 @@ HRESULT MainProfiler::ProfilerCommandSetCallback(const IpcMessage& message)
283283
{
284284
case ProfilerCommand::Callstack:
285285
return ProcessCallstackMessage();
286-
case ProfilerCommand::Start:
287-
case ProfilerCommand::Stop:
286+
case ProfilerCommand::StartAllFeatures:
287+
case ProfilerCommand::StopAllFeatures:
288288
// TODO We don't do anything here now, but we could interrupt the current stack walk with CORPROF_E_STACKSNAPSHOT_ABORT in the snapshot callback.
289289
return S_OK;
290290
default:

src/Tools/dotnet-monitor/Profiler/ProfilerService.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -84,25 +84,25 @@ public async Task ApplyProfilersAsync(IEndpointInfo endpointInfo, CancellationTo
8484

8585
// Currently this is a no-op but ideally will interrupt all callstack collections
8686
await _profilerChannel.SendMessage(endpointInfo,
87-
new JsonProfilerMessage((ushort)CommandSet.Profiler, (ushort)ProfilerCommand.Stop, new EmptyPayload()),
87+
new JsonProfilerMessage((ushort)CommandSet.Profiler, (ushort)ProfilerCommand.StopAllFeatures, new EmptyPayload()),
8888
cancellationToken, ResetTimeout);
8989
await _profilerChannel.SendMessage(endpointInfo,
90-
new JsonProfilerMessage((ushort)CommandSet.Profiler, (ushort)ProfilerCommand.Start, new EmptyPayload()),
90+
new JsonProfilerMessage((ushort)CommandSet.Profiler, (ushort)ProfilerCommand.StartAllFeatures, new EmptyPayload()),
9191
cancellationToken, ResetTimeout);
9292

9393
if (_inProcessFeatures.IsStartupHookRequired)
9494
{
9595
// This will stop all exception pipelines from collecting data and request all parameter captures to be uninstrumented
9696
await _profilerChannel.SendMessage(endpointInfo,
97-
new JsonProfilerMessage((ushort)CommandSet.StartupHook, (ushort)StartupHookCommand.Stop, new EmptyPayload()),
97+
new JsonProfilerMessage((ushort)CommandSet.StartupHook, (ushort)StartupHookCommand.StopAllFeatures, new EmptyPayload()),
9898
cancellationToken, ResetTimeout);
9999

100100
//CONSIDER Currently this is granular enough because only exceptions really need starts. If that changes, we will need to be more verbose about
101101
// which features need to be started rather than 1 stop/start for the entire command set.
102102
if (_inProcessFeatures.CollectExceptionsOnStartup)
103103
{
104104
await _profilerChannel.SendMessage(endpointInfo,
105-
new JsonProfilerMessage((ushort)CommandSet.StartupHook, (ushort)StartupHookCommand.Start, new EmptyPayload()),
105+
new JsonProfilerMessage((ushort)CommandSet.StartupHook, (ushort)StartupHookCommand.StartAllFeatures, new EmptyPayload()),
106106
cancellationToken, ResetTimeout);
107107
}
108108
}

0 commit comments

Comments
 (0)