Skip to content

Commit

Permalink
#325 - fix issue with tracing of catalog-service
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli committed Sep 10, 2023
1 parent 2b11c86 commit 0d724a1
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 39 deletions.
6 changes: 0 additions & 6 deletions catalog-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@
<artifactId>resilience4j-micrometer</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.github.loki4j</groupId>
<artifactId>loki-logback-appender</artifactId>
<scope>runtime</scope>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>net.ttddyy.observation</groupId>
<artifactId>datasource-micrometer-spring-boot</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/***
<p>
Licensed under MIT License Copyright (c) 2021-2023 Raja Kolli.
Licensed under MIT License Copyright (c) 2022-2023 Raja Kolli.
</p>
***/

Expand Down Expand Up @@ -28,8 +28,8 @@ ObservedAspect observedAspect(ObservationRegistry observationRegistry) {
}

@Bean
WebClient webClient() {
return WebClient.builder()
WebClient webClient(WebClient.Builder webClientBuilder) {
return webClientBuilder
.defaultHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)
.defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.baseUrl(applicationProperties.getInventoryServiceUrl())
Expand Down
2 changes: 0 additions & 2 deletions catalog-service/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ server.port=18080

spring.webflux.base-path=/${spring.application.name}

spring.config.import=optional:configserver:${CONFIG_SERVER:http://localhost:8888}/

# spring.kafka.bootstrap-servers=localhost:9092
spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer
spring.kafka.producer.value-serializer=org.springframework.kafka.support.serializer.JsonSerializer
Expand Down
31 changes: 6 additions & 25 deletions catalog-service/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,25 @@
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />

<springProperty scope="context" name="appName" source="spring.application.name"/>
<springProperty scope="context" name="lokiUri" source="loki.uri"/>

<springProfile name="default">
<root level="INFO">
<appender-ref ref="CONSOLE" />
</root>
</springProfile>
<springProfile name="dockerLoki">
<root level="INFO">
<appender-ref ref="LOKI"/>
<appender-ref ref="CONSOLE" />
</root>
</springProfile>
<springProfile name="!default,!dockerLoki">

<springProfile name="!default">
<property name="LOG_FILE" value="logs/${appName}.log"/>
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
<root level="INFO">
<appender-ref ref="FILE" />
<appender-ref ref="CONSOLE" />
</root>
</springProfile>

<appender name="LOKI" class="com.github.loki4j.logback.Loki4jAppender">
<batchTimeoutMs>2000</batchTimeoutMs>
<http>
<url>${lokiUri:-http://localhost:3100/loki/api/v1/push}</url>
</http>
<format>
<label>
<pattern>application=${appName},hostname=${HOSTNAME},level=%level</pattern>
</label>
<message>
<pattern>${FILE_LOG_PATTERN}</pattern>
</message>
<sortByTime>true</sortByTime>
</format>
<metricsEnabled>true</metricsEnabled>
</appender>

<logger name="com.example.catalogservice" level="DEBUG"/>
<logger name="org.springframework.transaction" level="DEBUG" />
<logger name="org.springframework.kafka.transaction" level="DEBUG" />
<logger name="org.apache.kafka.clients.Metadata" level="WARN" />

</configuration>
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
logging:
file:
name: logs/catalog-service.log
resilience4j:
bulkhead:
instances:
Expand Down

0 comments on commit 0d724a1

Please sign in to comment.