-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
le Plug-in contextual logging. With this change in place we now injec…
…t restateServiceMethod and restateInvocationId in log4j2 context. These two variables can then be used in the log pattern, in the json appender, etc.
- Loading branch information
1 parent
26105f1
commit 67096de
Showing
16 changed files
with
137 additions
and
11 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
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
32 changes: 32 additions & 0 deletions
32
sdk-core-impl/src/main/java/dev/restate/sdk/core/impl/GrpcContextDataProvider.java
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,32 @@ | ||
package dev.restate.sdk.core.impl; | ||
|
||
import dev.restate.sdk.core.InvocationId; | ||
import java.util.Map; | ||
import org.apache.logging.log4j.core.util.ContextDataProvider; | ||
|
||
/** | ||
* Log4j2 ContextDataProvider inferring context from the Grpc context. | ||
* | ||
* <p>This is used to propagate the context to the user code, such that log statements from the user | ||
* will contain the restate logging context variables. | ||
*/ | ||
public class GrpcContextDataProvider implements ContextDataProvider { | ||
@Override | ||
public Map<String, String> supplyContextData() { | ||
InvocationId invocationId = InvocationId.INVOCATION_ID_KEY.get(); | ||
String serviceMethod = RestateGrpcServer.SERVICE_METHOD.get(); | ||
|
||
// We use Map.of constructors to avoid allocating hashmaps | ||
if (invocationId == null && serviceMethod == null) { | ||
return Map.of(); | ||
} else if (invocationId == null) { | ||
return Map.of(RestateGrpcServer.LoggingContextSetter.SERVICE_METHOD_KEY, serviceMethod); | ||
} else { | ||
return Map.of( | ||
RestateGrpcServer.LoggingContextSetter.INVOCATION_ID_KEY, | ||
invocationId.toString(), | ||
RestateGrpcServer.LoggingContextSetter.SERVICE_METHOD_KEY, | ||
serviceMethod); | ||
} | ||
} | ||
} |
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
...c/main/resources/META-INF/services/org.apache.logging.log4j.core.util.ContextDataProvider
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 @@ | ||
dev.restate.sdk.core.impl.GrpcContextDataProvider |
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
1 change: 1 addition & 0 deletions
1
...c/main/resources/META-INF/services/org.apache.logging.log4j.core.util.ContextDataProvider
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 @@ | ||
io.reactiverse.contextual.logging.VertxContextDataProvider |
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