Gitlab - Argos ALM by PALO IT

Added log for correlation id

parent 8be3a154
package com.example.http.reactive.handler;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebFilter;
import org.springframework.web.server.WebFilterChain;
import reactor.core.publisher.Mono;
@Slf4j
@Component
public class LogWebFilter implements WebFilter {
private static String correlationIdHeader = "X-Correlation-Id";
@Override
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
if (exchange.getRequest().getHeaders().containsKey(correlationIdHeader)) {
List<String> correlationId = exchange.getRequest().getHeaders().get(correlationIdHeader);
log.info("External Correlation Id:[{}]", correlationId);
exchange.getResponse().getHeaders().addAll(correlationIdHeader, correlationId);
}
return chain.filter(exchange);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment