Skip to content

Commit

Permalink
Make DiagnosticsClient.StartEventPipeSessionAsync public
Browse files Browse the repository at this point in the history
This allows user code to pass a cancellation token without wrapping the call to StartEventPipeSession() in Task.Run() or similar. Resolves dotnet#3727.
  • Loading branch information
loop-evgeny committed Nov 13, 2023
1 parent 0d24da0 commit 89cff6a
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ namespace Microsoft.Diagnostics.NETCore.Client
/// </summary>
public sealed class DiagnosticsClient
{
private const int DefaultCircularBufferMB = 256;

private readonly IpcEndpoint _endpoint;

public DiagnosticsClient(int processId) :
Expand Down Expand Up @@ -66,7 +68,7 @@ internal Task WaitForConnectionAsync(CancellationToken token)
/// <returns>
/// An EventPipeSession object representing the EventPipe session that just started.
/// </returns>
public EventPipeSession StartEventPipeSession(IEnumerable<EventPipeProvider> providers, bool requestRundown = true, int circularBufferMB = 256)
public EventPipeSession StartEventPipeSession(IEnumerable<EventPipeProvider> providers, bool requestRundown = true, int circularBufferMB = DefaultCircularBufferMB)
{
return EventPipeSession.Start(_endpoint, providers, requestRundown, circularBufferMB);
}
Expand All @@ -80,7 +82,7 @@ public EventPipeSession StartEventPipeSession(IEnumerable<EventPipeProvider> pro
/// <returns>
/// An EventPipeSession object representing the EventPipe session that just started.
/// </returns>
public EventPipeSession StartEventPipeSession(EventPipeProvider provider, bool requestRundown = true, int circularBufferMB = 256)
public EventPipeSession StartEventPipeSession(EventPipeProvider provider, bool requestRundown = true, int circularBufferMB = DefaultCircularBufferMB)
{
return EventPipeSession.Start(_endpoint, new[] { provider }, requestRundown, circularBufferMB);
}
Expand All @@ -95,7 +97,8 @@ public EventPipeSession StartEventPipeSession(EventPipeProvider provider, bool r
/// <returns>
/// An EventPipeSession object representing the EventPipe session that just started.
/// </returns>
internal Task<EventPipeSession> StartEventPipeSessionAsync(IEnumerable<EventPipeProvider> providers, bool requestRundown, int circularBufferMB, CancellationToken token)
public Task<EventPipeSession> StartEventPipeSessionAsync(IEnumerable<EventPipeProvider> providers, bool requestRundown,
int circularBufferMB = DefaultCircularBufferMB, CancellationToken token = default)
{
return EventPipeSession.StartAsync(_endpoint, providers, requestRundown, circularBufferMB, token);
}
Expand All @@ -110,7 +113,8 @@ internal Task<EventPipeSession> StartEventPipeSessionAsync(IEnumerable<EventPipe
/// <returns>
/// An EventPipeSession object representing the EventPipe session that just started.
/// </returns>
internal Task<EventPipeSession> StartEventPipeSessionAsync(EventPipeProvider provider, bool requestRundown, int circularBufferMB, CancellationToken token)
public Task<EventPipeSession> StartEventPipeSessionAsync(EventPipeProvider provider, bool requestRundown,
int circularBufferMB = DefaultCircularBufferMB, CancellationToken token = default)
{
return EventPipeSession.StartAsync(_endpoint, new[] { provider }, requestRundown, circularBufferMB, token);
}
Expand Down

0 comments on commit 89cff6a

Please sign in to comment.