-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(apps): export logs to open telemetry endpoint #1617
Open
arealmaas
wants to merge
6
commits into
main
Choose a base branch
from
feat/enable-otlp-loggin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+198
−43
Open
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3150b90
feat(apps): export logs to open telemetry endpoint
arealmaas e30f921
add readme and stuff
arealmaas 77b547a
Merge branch 'main' into feat/enable-otlp-loggin
arealmaas 107b443
Merge branch 'main' into feat/enable-otlp-loggin
arealmaas 4a4198d
rm unused test
arealmaas da9c869
fix tests
arealmaas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,45 @@ | ||
auth_enabled: false | ||
|
||
server: | ||
http_listen_port: 3100 | ||
|
||
common: | ||
path_prefix: /tmp/loki | ||
|
||
compactor: | ||
working_directory: /tmp/loki/compactor | ||
compaction_interval: 10m | ||
|
||
ingester: | ||
lifecycler: | ||
address: 127.0.0.1 | ||
ring: | ||
kvstore: | ||
store: inmemory | ||
replication_factor: 1 | ||
final_sleep: 0s | ||
chunk_idle_period: 5m | ||
chunk_retain_period: 30s | ||
|
||
schema_config: | ||
configs: | ||
- from: 2020-10-24 | ||
store: tsdb | ||
object_store: filesystem | ||
schema: v13 | ||
index: | ||
prefix: index_ | ||
period: 24h | ||
|
||
storage_config: | ||
tsdb_shipper: | ||
active_index_directory: /tmp/loki/tsdb-index | ||
cache_location: /tmp/loki/tsdb-cache | ||
cache_ttl: 24h | ||
filesystem: | ||
directory: /tmp/loki/chunks | ||
|
||
limits_config: | ||
reject_old_samples: true | ||
reject_old_samples_max_age: 168h | ||
allow_structured_metadata: true |
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
1 change: 1 addition & 0 deletions
1
...igdir.Domain.Dialogporten.WebApi.Tests/Common/Middleware/RequestLoggingMiddlewareTests.cs
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 @@ | ||
|
38 changes: 38 additions & 0 deletions
38
src/Digdir.Domain.Dialogporten.WebApi/Common/Middleware/RequestLoggingMiddleware.cs
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,38 @@ | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Digdir.Domain.Dialogporten.WebApi.Common.Middleware; | ||
|
||
public class RequestLoggingMiddleware | ||
{ | ||
private readonly RequestDelegate _next; | ||
private readonly ILogger<RequestLoggingMiddleware> _logger; | ||
|
||
public RequestLoggingMiddleware(RequestDelegate next, ILogger<RequestLoggingMiddleware> logger) | ||
{ | ||
_next = next; | ||
_logger = logger; | ||
} | ||
|
||
public async Task InvokeAsync(HttpContext context) | ||
{ | ||
try | ||
{ | ||
await _next(context); | ||
} | ||
finally | ||
{ | ||
_logger.LogInformation( | ||
"HTTP {RequestMethod} {RequestPath} responded {StatusCode}", | ||
context.Request.Method, | ||
context.Request.Path, | ||
context.Response.StatusCode); | ||
} | ||
} | ||
} | ||
|
||
public static class RequestLoggingMiddlewareExtensions | ||
{ | ||
public static IApplicationBuilder UseRequestLogging(this IApplicationBuilder app) | ||
=> app.UseMiddleware<RequestLoggingMiddleware>(); | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Enhance log data for better observability
The current logging implementation captures basic request details, but for effective monitoring and debugging in a distributed system, consider including additional telemetry data:
Here's a suggested implementation: