@@ -6,9 +6,9 @@ namespace Voxel.MiddyNet.Tracing.ApiGatewayMiddleware
6
6
{
7
7
public class ApiGatewayTracingMiddleware : ILambdaMiddleware < APIGatewayProxyRequest , APIGatewayProxyResponse >
8
8
{
9
+ private const string TraceContextKey = "TraceContext" ;
9
10
private const string TraceParentHeaderName = "traceparent" ;
10
11
private const string TraceStateHeaderName = "tracestate" ;
11
- private const string TraceIdHeaderName = "trace-id" ;
12
12
13
13
public Task Before ( APIGatewayProxyRequest apiGatewayEvent , MiddyNetContext context )
14
14
{
@@ -22,17 +22,17 @@ public Task Before(APIGatewayProxyRequest apiGatewayEvent, MiddyNetContext conte
22
22
23
23
var traceContext = TraceContext . Handle ( traceParentHeaderValue , traceStateHeaderValue ) ;
24
24
25
+ context . AdditionalContext . Add ( TraceContextKey , traceContext ) ;
26
+
25
27
context . Logger . EnrichWith ( new LogProperty ( TraceParentHeaderName , traceContext . TraceParent ) ) ;
26
28
context . Logger . EnrichWith ( new LogProperty ( TraceStateHeaderName , traceContext . TraceState ) ) ;
27
29
context . Logger . EnrichWith ( new LogProperty ( TraceIdHeaderName , traceContext . TraceId ) ) ;
28
-
29
- context . AdditionalContext . Add ( TraceParentHeaderName , traceContext . TraceParent ) ;
30
- context . AdditionalContext . Add ( TraceStateHeaderName , traceContext . TraceState ) ;
31
- context . AdditionalContext . Add ( TraceIdHeaderName , traceContext . TraceId ) ;
32
-
30
+
33
31
return Task . CompletedTask ;
34
32
}
35
33
34
+ private const string TraceIdHeaderName = "trace-id" ;
35
+
36
36
public Task < APIGatewayProxyResponse > After ( APIGatewayProxyResponse lambdaResponse , MiddyNetContext context )
37
37
{
38
38
return Task . FromResult ( lambdaResponse ) ;
0 commit comments