Skip to content

Commit

Permalink
More logging adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
skjolber committed Jan 11, 2025
1 parent f38d5a7 commit 8f719c9
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ logging.level.io.grpc.netty=info
logging.level.root=debug

entur.jwt.mdc.enabled=true
entur.logging.grpc.trace.mdc.interceptor-order=50

entur.logging.request-response.grpc.server.interceptor-order=275
entur.logging.request-response.grpc.server.exception-handler.interceptor-order=280
entur.logging.grpc.trace.mdc.interceptor-order=50
entur.logging.request-response.grpc.server.interceptor-order=5170
entur.logging.request-response.grpc.server.exception-handler.interceptor-order=5175
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# gcp-grpc-ecosystem-without-test-artifacts-example
Simple GRPC service example without test dependencies from this project.

This emulates the deployed application (i.e. machine readable JSON).
This emulates the deployed application (i.e. machine-readable JSON).
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,8 @@ logging.level.io.grpc.netty=info
# override log level
logging.level.root=debug

logging.level.org.lognet.springboot.grpc.FailureHandlingSupport=ERROR



# normalize lognet interceptor order
# min is -2147483648
# 100
grpc.recovery.interceptor-order=100
# 200
grpc.security.auth.interceptor-order=200
# 300
grpc.validation.interceptor-order=300
# 400
grpc.metrics.interceptor-order=400

entur.jwt.mdc.enabled=true
entur.logging.grpc.trace.mdc.interceptor-order=50

entur.logging.request-response.grpc.server.interceptor-order=275
entur.logging.request-response.grpc.server.exception-handler.interceptor-order=280
entur.logging.grpc.trace.mdc.interceptor-order=50
entur.logging.request-response.grpc.server.interceptor-order=5170
entur.logging.request-response.grpc.server.exception-handler.interceptor-order=5175
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# gcp-grpc-lognet-without-test-artifacts-example
Simple GRPC service example without test dependencies from this project.

This emulates the deployed application (i.e. machine readable JSON).
This emulates the deployed application (i.e. machine-readable JSON).
20 changes: 10 additions & 10 deletions gcp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,24 +207,24 @@ and
```xml
<dependency>
<groupId>no.entur.logging.cloud</groupId>
<artifactId>spring-boot-starter-gcp-grpc</artifactId>
<artifactId>spring-boot-starter-gcp-grpc-ecosystem</artifactId>
<version>${cloud-logging.version}</version>
</dependency>
<dependency>
<groupId>no.entur.logging.cloud</groupId>
<artifactId>spring-boot-starter-gcp-grpc-test</artifactId>
<artifactId>spring-boot-starter-gcp-grpc-ecosystem-test</artifactId>
<version>${cloud-logging.version}</version>
<scope>test</scope>
</dependency>
<!-- request-response logging -->
<dependency>
<groupId>no.entur.logging.cloud</groupId>
<artifactId>request-response-spring-boot-starter-gcp-grpc</artifactId>
<artifactId>request-response-spring-boot-starter-gcp-grpc-ecosystem</artifactId>
<version>${cloud-logging.version}</version>
</dependency>
<dependency>
<groupId>no.entur.logging.cloud</groupId>
<artifactId>request-response-spring-boot-starter-gcp-grpc-test</artifactId>
<artifactId>request-response-spring-boot-starter-gcp-grpc-ecosystem-test</artifactId>
<version>${cloud-logging.version}</version>
<scope>test</scope>
</dependency>
Expand All @@ -247,13 +247,13 @@ and
<artifactId>api</artifactId>
<version>${cloud-logging.version}</version>
</dependency>
// MDC support
<!-- MDC support -->
<dependency>
<groupId>no.entur.logging.cloud</groupId>
<artifactId>mdc-context-grpc-netty</artifactId>
<version>${cloud-logging.version}</version>
</dependency>
// Correlation id + various interceptors
<!-- Correlation id + various interceptors -->
<dependency>
<groupId>no.entur.logging.cloud</groupId>
<artifactId>correlation-id-trace-grpc-netty</artifactId>
Expand Down Expand Up @@ -284,11 +284,11 @@ ext {
add

```groovy
implementation("no.entur.logging.cloud:spring-boot-starter-gcp-grpc:${cloudLoggingVersion}")
testImplementation("no.entur.logging.cloud:spring-boot-starter-gcp-grpc-test:${cloudLoggingVersion}")
implementation("no.entur.logging.cloud:spring-boot-starter-gcp-grpc-ecosystem:${cloudLoggingVersion}")
testImplementation("no.entur.logging.cloud:spring-boot-starter-gcp-grpc-ecosystem-test:${cloudLoggingVersion}")
// request-response logging
implementation("no.entur.logging.cloud:request-response-spring-boot-starter-gcp-grpc:${cloudLoggingVersion}")
testImplementation("no.entur.logging.cloud:request-response-spring-boot-starter-gcp-grpc-test:${cloudLoggingVersion}")
implementation("no.entur.logging.cloud:request-response-spring-boot-starter-gcp-grpc-ecosystem:${cloudLoggingVersion}")
testImplementation("no.entur.logging.cloud:request-response-spring-boot-starter-gcp-grpc-ecosystem-test:${cloudLoggingVersion}")
// on-demand logging support
implementation("no.entur.logging.cloud:on-demand-spring-boot-starter-grpc:${cloudLoggingVersion}")
// metrics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@
import net.devh.boot.grpc.server.advice.GrpcExceptionHandler;
import net.devh.boot.grpc.server.autoconfigure.GrpcAdviceAutoConfiguration;
import net.devh.boot.grpc.server.error.GrpcExceptionInterceptor;
import no.entur.logging.cloud.rr.grpc.GrpcSink;
import no.entur.logging.cloud.rr.grpc.filter.GrpcServerLoggingFilters;
import no.entur.logging.cloud.rr.grpc.mapper.GrpcMetadataJsonMapper;
import no.entur.logging.cloud.rr.grpc.mapper.GrpcPayloadJsonMapper;
import no.entur.logging.cloud.spring.rr.grpc.OrderedGrpcLoggingServerInterceptor;
import no.entur.logging.cloud.spring.rr.grpc.RequestResponseGrpcExceptionHandlerInterceptor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -29,6 +35,15 @@ public class RequestResponseGrpcEcosystemAutoConfiguration {
@Value("${entur.logging.request-response.grpc.server.exception-handler.interceptor-order:0}")
private int exceptionInterceptorOrder;

@Value("${entur.logging.request-response.grpc.server.interceptor-order:5175}")
private int serverInterceptorOrder;

@Bean
@ConditionalOnMissingBean(OrderedGrpcLoggingServerInterceptor.class)
public OrderedGrpcLoggingServerInterceptor orderedGrpcLoggingServerInterceptor(GrpcPayloadJsonMapper grpcPayloadJsonMapper, GrpcMetadataJsonMapper grpcMetadataJsonMapper, GrpcSink grpcSink, GrpcServerLoggingFilters grpcServerLoggingFilters) {
return new OrderedGrpcLoggingServerInterceptor(grpcSink, grpcServerLoggingFilters, grpcMetadataJsonMapper, grpcPayloadJsonMapper, serverInterceptorOrder);
}

@GrpcAdvice
@ConditionalOnProperty(name = {"entur.logging.request-response.grpc.server.exception-handler.enabled"}, havingValue = "true", matchIfMissing = true)
public static class StatusRuntimeExceptionGrpcServiceAdvice {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import no.entur.logging.cloud.rr.grpc.mapper.JsonPrinterFactory;
import no.entur.logging.cloud.rr.grpc.mapper.JsonPrinterStatusMapper;
import no.entur.logging.cloud.rr.grpc.mapper.TypeRegistryFactory;
import no.entur.logging.cloud.spring.rr.grpc.OrderedGrpcLoggingServerInterceptor;
import no.entur.logging.cloud.spring.rr.grpc.RequestResponseGrpcExceptionHandlerInterceptor;
import org.lognet.springboot.grpc.FailureHandlingSupport;
import org.lognet.springboot.grpc.autoconfigure.ConditionalOnMissingErrorHandler;
Expand All @@ -40,6 +41,15 @@ public class RequestResponseGrpcLognetAutoConfiguration {
@Value("${entur.logging.request-response.grpc.server.exception-handler.interceptor-order:0}")
private int exceptionInterceptorOrder;

@Value("${entur.logging.request-response.grpc.server.interceptor-order:0}")
private int serverInterceptorOrder;

@Bean
@ConditionalOnMissingBean(OrderedGrpcLoggingServerInterceptor.class)
public OrderedGrpcLoggingServerInterceptor orderedGrpcLoggingServerInterceptor(GrpcPayloadJsonMapper grpcPayloadJsonMapper, GrpcMetadataJsonMapper grpcMetadataJsonMapper, GrpcSink grpcSink, GrpcServerLoggingFilters grpcServerLoggingFilters) {
return new OrderedGrpcLoggingServerInterceptor(grpcSink, grpcServerLoggingFilters, grpcMetadataJsonMapper, grpcPayloadJsonMapper, serverInterceptorOrder);
}

@Bean
@ConditionalOnBean({FailureHandlingSupport.class, GRpcExceptionHandlerMethodResolver.class})
@ConditionalOnProperty(name = {"entur.logging.request-response.grpc.server.exception-handler.enabled"}, havingValue = "true", matchIfMissing = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,9 @@ public class RequestResponseGrpcAutoConfiguration extends AbstractRequestRespons
@Value("${entur.logging.request-response.max-body-size}")
protected int maxBodySize;

@Value("${entur.logging.request-response.grpc.server.interceptor-order:0}")
private int serverInterceptorOrder;

@Value("${entur.logging.request-response.grpc.client.interceptor-order:0}")
private int clientInterceptorOrder;

@Value("${entur.logging.request-response.grpc.server.exception-handler.interceptor-order:0}")
private int exceptionInterceptorOrder;

@Bean
@ConditionalOnMissingBean(JsonFormat.TypeRegistry.class)
public JsonFormat.TypeRegistry jsonFormatTypeRegistry() {
Expand Down Expand Up @@ -78,12 +72,6 @@ public GrpcServerLoggingFilters grpcServerLoggingFilters() {
return GrpcServerLoggingFilters.newBuilder().classicDefaultLogging().build();
}

@Bean
@ConditionalOnMissingBean(OrderedGrpcLoggingServerInterceptor.class)
public OrderedGrpcLoggingServerInterceptor orderedGrpcLoggingServerInterceptor(GrpcPayloadJsonMapper grpcPayloadJsonMapper, GrpcMetadataJsonMapper grpcMetadataJsonMapper, GrpcSink grpcSink, GrpcServerLoggingFilters grpcServerLoggingFilters) {
return new OrderedGrpcLoggingServerInterceptor(grpcSink, grpcServerLoggingFilters, grpcMetadataJsonMapper, grpcPayloadJsonMapper, serverInterceptorOrder);
}

@Bean
@ConditionalOnMissingBean(OrderedGrpcLoggingClientInterceptor.class)
public OrderedGrpcLoggingClientInterceptor orderedGrpcLoggingClientInterceptor(GrpcPayloadJsonMapper grpcPayloadJsonMapper, GrpcMetadataJsonMapper grpcMetadataJsonMapper, GrpcSink grpcSink, GrpcClientLoggingFilters grpcServiceLoggingFilters) {
Expand Down

0 comments on commit 8f719c9

Please sign in to comment.