Skip to content

Commit

Permalink
Add tracing to observe taskhub operations (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianburckhardt authored Oct 14, 2021
1 parent 4a9ffbe commit cb07152
Showing 1 changed file with 82 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ async Task<TaskhubParameters> TryLoadExistingTaskhubAsync()
}
}

async Task<bool> ITaskHub.ExistsAsync()
async Task<bool> ExistsAsync()
{
var parameters = await this.TryLoadExistingTaskhubAsync().ConfigureAwait(false);
return (parameters != null && parameters.TaskhubName == this.settings.HubName);
}

async Task<bool> ITaskHub.CreateIfNotExistsAsync()
async Task<bool> CreateIfNotExistsAsync()
{
await this.cloudBlobContainer.CreateIfNotExistsAsync().ConfigureAwait(false);

Expand Down Expand Up @@ -153,7 +153,7 @@ async Task<bool> ITaskHub.CreateIfNotExistsAsync()
return true;
}

async Task ITaskHub.DeleteAsync()
async Task DeleteAsync()
{
if (await this.taskhubParameters.ExistsAsync().ConfigureAwait(false))
{
Expand All @@ -164,7 +164,7 @@ async Task ITaskHub.DeleteAsync()
await this.host.StorageProvider.DeleteAllPartitionStatesAsync().ConfigureAwait(false);
}

async Task ITaskHub.StartAsync()
async Task StartAsync()
{
this.shutdownSource = new CancellationTokenSource();

Expand Down Expand Up @@ -351,7 +351,7 @@ public IEventProcessor CreateEventProcessor(PartitionContext context)
}
}

async Task ITaskHub.StopAsync()
async Task StopAsync()
{
this.traceHelper.LogInformation("Shutting down EventHubsBackend");
this.shutdownSource.Cancel(); // initiates shutdown of client and of all partitions
Expand Down Expand Up @@ -454,5 +454,82 @@ async Task ClientProcessLoopAsync(ChannelReader<ClientEvent> channelReader)
this.client.Process(clientEvent);
}
}

async Task<bool> ITaskHub.ExistsAsync()
{
try
{
this.traceHelper.LogDebug("ITaskHub.ExistsAsync called");
bool result = await this.ExistsAsync();
this.traceHelper.LogDebug("ITaskHub.ExistsAsync returned {result}", result);
return result;
}
catch (Exception e)
{
this.traceHelper.LogError("ITaskHub.ExistsAsync failed with exception: {exception}", e);
throw;
}
}

async Task<bool> ITaskHub.CreateIfNotExistsAsync()
{
try
{
this.traceHelper.LogDebug("ITaskHub.CreateIfNotExistsAsync called");
bool result = await this.CreateIfNotExistsAsync();
this.traceHelper.LogDebug("ITaskHub.CreateIfNotExistsAsync returned {result}", result);
return result;
}
catch (Exception e)
{
this.traceHelper.LogError("ITaskHub.CreateIfNotExistsAsync failed with exception: {exception}", e);
throw;
}
}

async Task ITaskHub.DeleteAsync()
{
try
{
this.traceHelper.LogDebug("ITaskHub.DeleteAsync called");
await this.DeleteAsync();
this.traceHelper.LogDebug("ITaskHub.DeleteAsync returned");
}
catch (Exception e)
{
this.traceHelper.LogError("ITaskHub.DeleteAsync failed with exception: {exception}", e);
throw;
}
}

async Task ITaskHub.StartAsync()
{
try
{
this.traceHelper.LogDebug("ITaskHub.StartAsync called");
await this.StartAsync();
this.traceHelper.LogDebug("ITaskHub.StartAsync returned");
}
catch (Exception e)
{
this.traceHelper.LogError("ITaskHub.StartAsync failed with exception: {exception}", e);
throw;
}
}

async Task ITaskHub.StopAsync()
{
try
{
this.traceHelper.LogDebug("ITaskHub.StopAsync called");
await this.StopAsync();
this.traceHelper.LogDebug("ITaskHub.StopAsync returned");
}
catch (Exception e)
{
this.traceHelper.LogError("ITaskHub.StopAsync failed with exception: {exception}", e);
throw;
}
}
}
}

0 comments on commit cb07152

Please sign in to comment.