Skip to content

Commit

Permalink
chore: Temp debugging, log Slack Webhook URL (#553)
Browse files Browse the repository at this point in the history
The Slack notifier function throws "invalid URI" once in a while,
attempting to figure out what/why
  • Loading branch information
oskogstad authored Mar 13, 2024
1 parent c5c426e commit 1f27886
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,19 @@ internal sealed class SlackClient : ISlackClient

public SlackClient(HttpClient httpClient, IOptions<SlackOptions> slackOptions)
{
_httpClient = httpClient;
_slackOptions = slackOptions;
_httpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
_slackOptions = slackOptions ?? throw new ArgumentNullException(nameof(slackOptions));
}

public Task SendAsync(SlackRequestDto message, CancellationToken cancellationToken) =>
_httpClient.PostAsJsonAsync(_slackOptions.Value.WebhookUrl, message, cancellationToken);
public async Task SendAsync(SlackRequestDto message, CancellationToken cancellationToken)
{
// TEMP DEBUG
Console.WriteLine($"Slack WebhookURL: {_slackOptions.Value.WebhookUrl}");
if (!Uri.TryCreate(_slackOptions.Value.WebhookUrl, UriKind.Absolute, out var uri))
{
return;
}

await _httpClient.PostAsJsonAsync(uri, message, cancellationToken);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ await _slack.SendAsync(new SlackRequestDto
ExceptionReport = appInsightsResponses.ToAsciiTableExceptionReport(),
Link = azureAlertRequest.ToQueryLink()
}, cancellationToken);

return req.CreateResponse(HttpStatusCode.OK);
}
}

0 comments on commit 1f27886

Please sign in to comment.