-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'introduce-log-event-ids' of github.com:nmshd/backbone i…
…nto introduce-log-event-ids
- Loading branch information
Showing
16 changed files
with
310 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Artifact Repo Publish | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
paths: [helm/artifacthub-repo.yml] | ||
|
||
jobs: | ||
upload-artifact-repo-config: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install oras | ||
run: | | ||
curl -L https://github.com/oras-project/oras/releases/download/v1.1.0/oras_1.1.0_linux_amd64.tar.gz -o oras.tar.gz | ||
tar -xzf oras.tar.gz oras | ||
sudo mv oras /usr/local/bin | ||
rm oras.tar.gz | ||
- name: Docker Login | ||
uses: docker/[email protected] | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: oras push | ||
working-directory: ./helm | ||
run: | | ||
oras push \ | ||
ghcr.io/nmshd/backbone-helm-chart:artifacthub.io \ | ||
--config /dev/null:application/vnd.cncf.artifacthub.config.v1+yaml \ | ||
artifacthub-repo.yml:application/vnd.cncf.artifacthub.repository-metadata.layer.v1.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using Microsoft.AspNetCore.Http; | ||
using Serilog; | ||
using Serilog.Events; | ||
|
||
namespace Backbone.Infrastructure.Logging; | ||
|
||
public static class LogHelper | ||
{ | ||
public static LogEventLevel GetLevel(HttpContext ctx, double _, Exception? ex) | ||
{ | ||
return ex != null | ||
? LogEventLevel.Error | ||
: ctx.Response.StatusCode > 499 | ||
? LogEventLevel.Error | ||
: IsHealthCheckEndpoint(ctx) // Not an error, check if it was a health check | ||
? LogEventLevel.Verbose // Was a health check, use Verbose | ||
: LogEventLevel.Information; | ||
} | ||
|
||
private static bool IsHealthCheckEndpoint(HttpContext ctx) | ||
{ | ||
var endpoint = ctx.GetEndpoint(); | ||
if (endpoint != null) | ||
{ | ||
return string.Equals( | ||
endpoint.DisplayName, | ||
"Health checks", | ||
StringComparison.Ordinal); | ||
} | ||
|
||
// No endpoint, so not a health check endpoint | ||
return false; | ||
} | ||
|
||
public static void EnrichFromRequest(IDiagnosticContext diagnosticContext, HttpContext httpContext) | ||
{ | ||
var request = httpContext.Request; | ||
|
||
diagnosticContext.Set("Host", request.Host); | ||
diagnosticContext.Set("Protocol", request.Protocol); | ||
diagnosticContext.Set("Scheme", request.Scheme); | ||
|
||
if (request.QueryString.HasValue) | ||
{ | ||
diagnosticContext.Set("QueryString", request.QueryString.Value); | ||
} | ||
|
||
diagnosticContext.Set("ContentType", httpContext.Response.ContentType); | ||
|
||
var endpoint = httpContext.GetEndpoint(); | ||
if (endpoint != null) | ||
{ | ||
diagnosticContext.Set("EndpointName", endpoint.DisplayName); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.