Skip to content

Commit e76bdb8

Browse files
authored
Make DiagnosticsClient.StartEventPipeSessionAsync public (#4394)
This allows user code to pass a cancellation token without wrapping the call to StartEventPipeSession() in Task.Run() or similar. Resolves #3727.
1 parent 6e81615 commit e76bdb8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ namespace Microsoft.Diagnostics.NETCore.Client
1919
/// </summary>
2020
public sealed class DiagnosticsClient
2121
{
22+
private const int DefaultCircularBufferMB = 256;
23+
2224
private readonly IpcEndpoint _endpoint;
2325

2426
public DiagnosticsClient(int processId) :
@@ -66,7 +68,7 @@ internal Task WaitForConnectionAsync(CancellationToken token)
6668
/// <returns>
6769
/// An EventPipeSession object representing the EventPipe session that just started.
6870
/// </returns>
69-
public EventPipeSession StartEventPipeSession(IEnumerable<EventPipeProvider> providers, bool requestRundown = true, int circularBufferMB = 256)
71+
public EventPipeSession StartEventPipeSession(IEnumerable<EventPipeProvider> providers, bool requestRundown = true, int circularBufferMB = DefaultCircularBufferMB)
7072
{
7173
return EventPipeSession.Start(_endpoint, providers, requestRundown, circularBufferMB);
7274
}
@@ -80,7 +82,7 @@ public EventPipeSession StartEventPipeSession(IEnumerable<EventPipeProvider> pro
8082
/// <returns>
8183
/// An EventPipeSession object representing the EventPipe session that just started.
8284
/// </returns>
83-
public EventPipeSession StartEventPipeSession(EventPipeProvider provider, bool requestRundown = true, int circularBufferMB = 256)
85+
public EventPipeSession StartEventPipeSession(EventPipeProvider provider, bool requestRundown = true, int circularBufferMB = DefaultCircularBufferMB)
8486
{
8587
return EventPipeSession.Start(_endpoint, new[] { provider }, requestRundown, circularBufferMB);
8688
}
@@ -95,7 +97,8 @@ public EventPipeSession StartEventPipeSession(EventPipeProvider provider, bool r
9597
/// <returns>
9698
/// An EventPipeSession object representing the EventPipe session that just started.
9799
/// </returns>
98-
internal Task<EventPipeSession> StartEventPipeSessionAsync(IEnumerable<EventPipeProvider> providers, bool requestRundown, int circularBufferMB, CancellationToken token)
100+
public Task<EventPipeSession> StartEventPipeSessionAsync(IEnumerable<EventPipeProvider> providers, bool requestRundown,
101+
int circularBufferMB = DefaultCircularBufferMB, CancellationToken token = default)
99102
{
100103
return EventPipeSession.StartAsync(_endpoint, providers, requestRundown, circularBufferMB, token);
101104
}
@@ -110,7 +113,8 @@ internal Task<EventPipeSession> StartEventPipeSessionAsync(IEnumerable<EventPipe
110113
/// <returns>
111114
/// An EventPipeSession object representing the EventPipe session that just started.
112115
/// </returns>
113-
internal Task<EventPipeSession> StartEventPipeSessionAsync(EventPipeProvider provider, bool requestRundown, int circularBufferMB, CancellationToken token)
116+
public Task<EventPipeSession> StartEventPipeSessionAsync(EventPipeProvider provider, bool requestRundown,
117+
int circularBufferMB = DefaultCircularBufferMB, CancellationToken token = default)
114118
{
115119
return EventPipeSession.StartAsync(_endpoint, new[] { provider }, requestRundown, circularBufferMB, token);
116120
}

0 commit comments

Comments
 (0)