-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: or-2013 add initiator to otel tracing via middleware
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
src/AssociationRegistry.Admin.Api/Infrastructure/Middleware/InitiatorActivityMiddleware.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,28 @@ | ||
namespace AssociationRegistry.Admin.Api.Infrastructure.Middleware; | ||
|
||
using Microsoft.AspNetCore.Http; | ||
using System.Diagnostics; | ||
using System.Threading.Tasks; | ||
|
||
public class InitiatorActivityMiddleware | ||
{ | ||
private readonly RequestDelegate _next; | ||
|
||
public InitiatorActivityMiddleware(RequestDelegate next) | ||
{ | ||
_next = next; | ||
} | ||
|
||
public async Task InvokeAsync(HttpContext context) | ||
{ | ||
if (context.Request.Headers.TryGetValue(WellknownHeaderNames.Initiator, out var headerValue)) | ||
{ | ||
var currentActivity = Activity.Current; | ||
if (currentActivity != null) | ||
{ | ||
currentActivity.SetTag("vr.initiator", headerValue.ToString()); | ||
} | ||
} | ||
await _next(context); | ||
} | ||
} |
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