Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lagt til logging av CallId i kall mot pensjon #3438

Merged
merged 3 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.List;
import java.util.Set;

import static no.nav.dolly.util.CallIdUtil.generateCallId;
import static no.nav.dolly.util.JacksonExchangeStrategyUtil.getJacksonStrategy;

@Slf4j
Expand All @@ -59,100 +60,111 @@ public PensjonforvalterConsumer(
.build();
}

@Timed(name = "providers", tags = {"operation", "pen_getMiljoer"})
@Timed(name = "providers", tags = { "operation", "pen_getMiljoer" })
public Mono<Set<String>> getMiljoer() {

return tokenService.exchange(serverProperties)
.flatMap(token -> new HentMiljoerCommand(webClient, token.getTokenValue()).call());
}

@Timed(name = "providers", tags = {"operation", "popp_lagreInntekt"})
@Timed(name = "providers", tags = { "operation", "popp_lagreInntekt" })
public Flux<PensjonforvalterResponse> lagreInntekter(PensjonPoppInntektRequest pensjonPoppInntektRequest) {

log.info("Popp lagre inntekt {}", pensjonPoppInntektRequest);
String callId = generateCallId();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nå når callId også skal logges kunne det være et alternativ å flytte loggingen inn i command-fil, istedet for å introdusere et parameter til. Det vil være enklere å lese og vedlikeholde, men dette er også OK.
(så lite kode som mulig bør være målet 😄 )

log.info("Popp lagre inntekt {}, callId: {}", pensjonPoppInntektRequest, callId);
return tokenService.exchange(serverProperties)
.flatMapMany(token -> new LagrePoppInntektCommand(webClient, token.getTokenValue(),
pensjonPoppInntektRequest).call());
pensjonPoppInntektRequest, callId).call());
}

@Timed(name = "providers", tags = {"operation", "pen_opprettPerson"})
@Timed(name = "providers", tags = { "operation", "pen_opprettPerson" })
public Flux<PensjonforvalterResponse> opprettPerson(PensjonPersonRequest pensjonPersonRequest,
Set<String> miljoer) {

pensjonPersonRequest.setMiljoer(miljoer);
log.info("Pensjon opprett person {}", pensjonPersonRequest);
String callId = generateCallId();
log.info("Pensjon opprett person {}, callId: {}", pensjonPersonRequest, callId);
return tokenService.exchange(serverProperties)
.flatMapMany(token -> new OpprettPersonCommand(webClient, pensjonPersonRequest, token.getTokenValue()).call());
.flatMapMany(token -> new OpprettPersonCommand(webClient, pensjonPersonRequest, token.getTokenValue(), callId).call());
}

@Timed(name = "providers", tags = {"operation", "pen_hentSamboer"})
@Timed(name = "providers", tags = { "operation", "pen_hentSamboer" })
public Flux<PensjonSamboerResponse> hentSamboer(String ident, String miljoe) {

return tokenService.exchange(serverProperties)
.flatMapMany(token -> new HentSamboerCommand(webClient, ident, miljoe, token.getTokenValue()).call())
.doOnNext(response -> log.info("Pensjon samboer for {} i {} hentet {}", ident, miljoe, response));
}

@Timed(name = "providers", tags = {"operation", "pen_opprettSamboer"})
@Timed(name = "providers", tags = { "operation", "pen_opprettSamboer" })
public Flux<PensjonforvalterResponse> lagreSamboer(PensjonSamboerRequest pensjonSamboerRequest,
String miljoe) {

log.info("Pensjon samboer opprett i {} {}", miljoe, pensjonSamboerRequest);
String callId = generateCallId();
log.info("Pensjon samboer opprett i {} {}, callId: {}", miljoe, pensjonSamboerRequest, callId);
return tokenService.exchange(serverProperties)
.flatMapMany(token -> new LagreSamboerCommand(webClient, pensjonSamboerRequest, miljoe, token.getTokenValue()).call());
.flatMapMany(token -> new LagreSamboerCommand(webClient, pensjonSamboerRequest, miljoe, token.getTokenValue(), callId).call());
}

@Timed(name = "providers", tags = {"operation", "pen_opprettSamboer"})
@Timed(name = "providers", tags = { "operation", "pen_opprettSamboer" })
public Flux<PensjonforvalterResponse> annullerSamboer(String ident, String periodeId, String miljoe) {

log.info("Pensjon samboer annuller {} periodeId {}", ident, periodeId);
String callId = generateCallId();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bruk generelt var på venstre side av variabelnavn, lettere å lese og vedlikeholde. (Noen ganger er det gode grunner til å ha eksplisitt type dog.)

log.info("Pensjon samboer annuller {} periodeId {}, callId: {}", ident, periodeId, callId);
return tokenService.exchange(serverProperties)
.flatMapMany(token -> new AnnullerSamboerCommand(webClient, periodeId, miljoe, token.getTokenValue()).call());
.flatMapMany(token -> new AnnullerSamboerCommand(webClient, periodeId, miljoe, token.getTokenValue(), callId).call());
}

@Timed(name = "providers", tags = {"operation", "pen_lagreAlderspensjon"})
@Timed(name = "providers", tags = { "operation", "pen_lagreAlderspensjon" })
public Flux<PensjonforvalterResponse> lagreAlderspensjon(AlderspensjonRequest request) {

log.info("Pensjon lagre alderspensjon {}", request);
String callId = generateCallId();
log.info("Pensjon lagre alderspensjon {}, callId: {}", request, callId);
return tokenService.exchange(serverProperties)
.flatMapMany(token ->
new LagreAlderspensjonCommand(webClient, token.getTokenValue(), request).call());
new LagreAlderspensjonCommand(webClient, token.getTokenValue(), request, callId).call());
}

@Timed(name = "providers", tags = {"operation", "pen_lagreUforetrygd"})
@Timed(name = "providers", tags = { "operation", "pen_lagreUforetrygd" })
public Flux<PensjonforvalterResponse> lagreUforetrygd(PensjonUforetrygdRequest request) {

log.info("Pensjon lagre uforetrygd {}", request);
String callId = generateCallId();
log.info("Pensjon lagre uforetrygd {}, callId: {}", request, callId);
return tokenService.exchange(serverProperties)
.flatMapMany(token -> new LagreUforetrygdCommand(webClient, token.getTokenValue(), request).call());
.flatMapMany(token -> new LagreUforetrygdCommand(webClient, token.getTokenValue(), request, callId).call());
}

@Timed(name = "providers", tags = {"operation", "pen_lagreTpForhold"})
@Timed(name = "providers", tags = { "operation", "pen_lagreTpForhold" })
public Flux<PensjonforvalterResponse> lagreTpForhold(PensjonTpForholdRequest pensjonTpForholdRequest) {

log.info("Pensjon lagre TP-forhold {}", pensjonTpForholdRequest);
String callId = generateCallId();
log.info("Pensjon lagre TP-forhold {}, callId: {}", pensjonTpForholdRequest, callId);
return tokenService.exchange(serverProperties)
.flatMapMany(token -> new LagreTpForholdCommand(webClient, token.getTokenValue(), pensjonTpForholdRequest).call());
.flatMapMany(token -> new LagreTpForholdCommand(webClient, token.getTokenValue(), pensjonTpForholdRequest, callId).call());
}

@Timed(name = "providers", tags = {"operation", "pen_sletteTpForhold"})
@Timed(name = "providers", tags = { "operation", "pen_sletteTpForhold" })
public void sletteTpForhold(List<String> identer) {

String callId = generateCallId();
log.info("Pensjon slette TP-forhold callId: {}", callId);

tokenService.exchange(serverProperties)
.flatMapMany(token -> new HentMiljoerCommand(webClient, token.getTokenValue()).call()
.flatMapMany(miljoer -> Flux.range(0, identer.size())
.map(index -> new SletteTpForholdCommand(webClient, identer.get(index), miljoer, token.getTokenValue()).call())))
.map(index -> new SletteTpForholdCommand(webClient, identer.get(index), miljoer, token.getTokenValue(), callId).call())))
.flatMap((Flux::from))
.collectList()
.subscribe(response -> log.info("Slettet mot PESYS (tp) i alle miljoer"));
}

@Timed(name = "providers", tags = {"operation", "pen_lagreTpYtelse"})
@Timed(name = "providers", tags = { "operation", "pen_lagreTpYtelse" })
public Flux<PensjonforvalterResponse> lagreTpYtelse(PensjonTpYtelseRequest pensjonTpYtelseRequest) {

log.info("Pensjon lagre TP-ytelse {}", pensjonTpYtelseRequest);
String callId = generateCallId();
log.info("Pensjon lagre TP-ytelse {}, callId: {}", pensjonTpYtelseRequest, callId);
return tokenService.exchange(serverProperties)
.flatMapMany(token -> new LagreTpYtelseCommand(webClient, token.getTokenValue(), pensjonTpYtelseRequest).call());
.flatMapMany(token -> new LagreTpYtelseCommand(webClient, token.getTokenValue(), pensjonTpYtelseRequest, callId).call());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import static no.nav.dolly.domain.CommonKeysAndUtils.CONSUMER;
import static no.nav.dolly.domain.CommonKeysAndUtils.HEADER_NAV_CALL_ID;
import static no.nav.dolly.domain.CommonKeysAndUtils.HEADER_NAV_CONSUMER_ID;
import static no.nav.dolly.util.CallIdUtil.generateCallId;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;

@Slf4j
Expand All @@ -28,6 +27,7 @@ public class AnnullerSamboerCommand implements Callable<Mono<PensjonforvalterRes
private final String periodeId;
private final String miljoe;
private final String token;
private final String callId;

public Mono<PensjonforvalterResponse> call() {
return webClient
Expand All @@ -36,7 +36,7 @@ public Mono<PensjonforvalterResponse> call() {
.path(PEN_SAMBOER_URL)
.build(miljoe, periodeId))
.header(AUTHORIZATION, "Bearer " + token)
.header(HEADER_NAV_CALL_ID, generateCallId())
.header(HEADER_NAV_CALL_ID, callId)
.header(HEADER_NAV_CONSUMER_ID, CONSUMER)
.retrieve()
.toBodilessEntity()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import static no.nav.dolly.domain.CommonKeysAndUtils.CONSUMER;
import static no.nav.dolly.domain.CommonKeysAndUtils.HEADER_NAV_CALL_ID;
import static no.nav.dolly.domain.CommonKeysAndUtils.HEADER_NAV_CONSUMER_ID;
import static no.nav.dolly.util.CallIdUtil.generateCallId;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;

@Slf4j
Expand All @@ -29,6 +28,7 @@ public class HentPoppInntekterCommand implements Callable<Mono<JsonNode>> {
private final String token;
private final String ident;
private final String miljoe;
private final String callId;

public Mono<JsonNode> call() {
return webClient
Expand All @@ -38,7 +38,7 @@ public Mono<JsonNode> call() {
.queryParam(FNR_PARAM, ident)
.build())
.header(AUTHORIZATION, "Bearer " + token)
.header(HEADER_NAV_CALL_ID, generateCallId())
.header(HEADER_NAV_CALL_ID, callId)
.header(HEADER_NAV_CONSUMER_ID, CONSUMER)
.header(MILJO_HEADER, miljoe)
.retrieve()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static no.nav.dolly.domain.CommonKeysAndUtils.CONSUMER;
import static no.nav.dolly.domain.CommonKeysAndUtils.HEADER_NAV_CALL_ID;
import static no.nav.dolly.domain.CommonKeysAndUtils.HEADER_NAV_CONSUMER_ID;
import static no.nav.dolly.util.CallIdUtil.generateCallId;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;

@Slf4j
Expand All @@ -32,6 +31,7 @@ public class LagreAlderspensjonCommand implements Callable<Flux<Pensjonforvalter
private final String token;

private final AlderspensjonRequest alderspensjonRequest;
private final String callId;

public Flux<PensjonforvalterResponse> call() {
return webClient
Expand All @@ -41,7 +41,7 @@ public Flux<PensjonforvalterResponse> call() {
PENSJON_AP_VEDTAK_URL : PENSJON_AP_SOKNAD_URL)
.build())
.header(AUTHORIZATION, "Bearer " + token)
.header(HEADER_NAV_CALL_ID, generateCallId())
.header(HEADER_NAV_CALL_ID, callId)
.header(HEADER_NAV_CONSUMER_ID, CONSUMER)
.bodyValue(alderspensjonRequest)
.retrieve()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import static no.nav.dolly.domain.CommonKeysAndUtils.CONSUMER;
import static no.nav.dolly.domain.CommonKeysAndUtils.HEADER_NAV_CALL_ID;
import static no.nav.dolly.domain.CommonKeysAndUtils.HEADER_NAV_CONSUMER_ID;
import static no.nav.dolly.util.CallIdUtil.generateCallId;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;

@Slf4j
Expand All @@ -28,6 +27,7 @@ public class LagrePoppInntektCommand implements Callable<Flux<PensjonforvalterRe
private final WebClient webClient;
private final String token;
private final PensjonPoppInntektRequest pensjonPoppInntektRequest;
private final String callId;

public Flux<PensjonforvalterResponse> call() {
return webClient
Expand All @@ -36,7 +36,7 @@ public Flux<PensjonforvalterResponse> call() {
.path(POPP_INNTEKT_URL)
.build())
.header(AUTHORIZATION, "Bearer " + token)
.header(HEADER_NAV_CALL_ID, generateCallId())
.header(HEADER_NAV_CALL_ID, callId)
.header(HEADER_NAV_CONSUMER_ID, CONSUMER)
.bodyValue(pensjonPoppInntektRequest)
.retrieve()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import static no.nav.dolly.domain.CommonKeysAndUtils.CONSUMER;
import static no.nav.dolly.domain.CommonKeysAndUtils.HEADER_NAV_CALL_ID;
import static no.nav.dolly.domain.CommonKeysAndUtils.HEADER_NAV_CONSUMER_ID;
import static no.nav.dolly.util.CallIdUtil.generateCallId;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;

@Slf4j
Expand All @@ -27,6 +26,7 @@ public class LagreSamboerCommand implements Callable<Mono<PensjonforvalterRespon
private final PensjonSamboerRequest pensjonSamboerRequest;
private final String miljoe;
private final String token;
private final String callId;

public Mono<PensjonforvalterResponse> call() {
return webClient
Expand All @@ -35,7 +35,7 @@ public Mono<PensjonforvalterResponse> call() {
.path(PEN_SAMBOER_URL)
.build(miljoe))
.header(AUTHORIZATION, "Bearer " + token)
.header(HEADER_NAV_CALL_ID, generateCallId())
.header(HEADER_NAV_CALL_ID, callId)
.header(HEADER_NAV_CONSUMER_ID, CONSUMER)
.bodyValue(pensjonSamboerRequest)
.retrieve()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static no.nav.dolly.domain.CommonKeysAndUtils.CONSUMER;
import static no.nav.dolly.domain.CommonKeysAndUtils.HEADER_NAV_CALL_ID;
import static no.nav.dolly.domain.CommonKeysAndUtils.HEADER_NAV_CONSUMER_ID;
import static no.nav.dolly.util.CallIdUtil.generateCallId;
import static no.nav.dolly.util.TokenXUtil.getUserJwt;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;

Expand All @@ -32,6 +31,7 @@ public class LagreTpForholdCommand implements Callable<Flux<PensjonforvalterResp
private final String token;

private final PensjonTpForholdRequest lagreTpForholdRequest;
private final String callId;

public Flux<PensjonforvalterResponse> call() {
return webClient
Expand All @@ -41,7 +41,7 @@ public Flux<PensjonforvalterResponse> call() {
.build())
.header(AUTHORIZATION, "Bearer " + token)
.header(UserConstant.USER_HEADER_JWT, getUserJwt())
.header(HEADER_NAV_CALL_ID, generateCallId())
.header(HEADER_NAV_CALL_ID, callId)
.header(HEADER_NAV_CONSUMER_ID, CONSUMER)
.bodyValue(lagreTpForholdRequest)
.retrieve()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static no.nav.dolly.domain.CommonKeysAndUtils.CONSUMER;
import static no.nav.dolly.domain.CommonKeysAndUtils.HEADER_NAV_CALL_ID;
import static no.nav.dolly.domain.CommonKeysAndUtils.HEADER_NAV_CONSUMER_ID;
import static no.nav.dolly.util.CallIdUtil.generateCallId;
import static no.nav.dolly.util.TokenXUtil.getUserJwt;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;

Expand All @@ -31,6 +30,7 @@ public class LagreTpYtelseCommand implements Callable<Flux<PensjonforvalterRespo
private final String token;

private final PensjonTpYtelseRequest pensjonTpYtelseRequest;
private final String callId;

public Flux<PensjonforvalterResponse> call() {
return webClient
Expand All @@ -40,7 +40,7 @@ public Flux<PensjonforvalterResponse> call() {
.build())
.header(AUTHORIZATION, "Bearer " + token)
.header(UserConstant.USER_HEADER_JWT, getUserJwt())
.header(HEADER_NAV_CALL_ID, generateCallId())
.header(HEADER_NAV_CALL_ID, callId)
.header(HEADER_NAV_CONSUMER_ID, CONSUMER)
.bodyValue(pensjonTpYtelseRequest)
.retrieve()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import static no.nav.dolly.domain.CommonKeysAndUtils.CONSUMER;
import static no.nav.dolly.domain.CommonKeysAndUtils.HEADER_NAV_CALL_ID;
import static no.nav.dolly.domain.CommonKeysAndUtils.HEADER_NAV_CONSUMER_ID;
import static no.nav.dolly.util.CallIdUtil.generateCallId;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;

@Slf4j
Expand All @@ -30,6 +29,7 @@ public class LagreUforetrygdCommand implements Callable<Flux<PensjonforvalterRes
private final String token;

private final PensjonUforetrygdRequest uforetrygdRequest;
private final String callId;

public Flux<PensjonforvalterResponse> call() {
return webClient
Expand All @@ -38,7 +38,7 @@ public Flux<PensjonforvalterResponse> call() {
.path(PENSJON_UT_URL)
.build())
.header(AUTHORIZATION, "Bearer " + token)
.header(HEADER_NAV_CALL_ID, generateCallId())
.header(HEADER_NAV_CALL_ID, callId)
.header(HEADER_NAV_CONSUMER_ID, CONSUMER)
.bodyValue(uforetrygdRequest)
.retrieve()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static no.nav.dolly.domain.CommonKeysAndUtils.CONSUMER;
import static no.nav.dolly.domain.CommonKeysAndUtils.HEADER_NAV_CALL_ID;
import static no.nav.dolly.domain.CommonKeysAndUtils.HEADER_NAV_CONSUMER_ID;
import static no.nav.dolly.util.CallIdUtil.generateCallId;
import static no.nav.dolly.util.TokenXUtil.getUserJwt;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;

Expand All @@ -30,6 +29,7 @@ public class OpprettPersonCommand implements Callable<Flux<PensjonforvalterRespo
private final WebClient webClient;
private final PensjonPersonRequest pensjonPersonRequest;
private final String token;
private final String callId;

public Flux<PensjonforvalterResponse> call() {
return webClient
Expand All @@ -39,7 +39,7 @@ public Flux<PensjonforvalterResponse> call() {
.build())
.header(AUTHORIZATION, "Bearer " + token)
.header(UserConstant.USER_HEADER_JWT, getUserJwt())
.header(HEADER_NAV_CALL_ID, generateCallId())
.header(HEADER_NAV_CALL_ID, callId)
.header(HEADER_NAV_CONSUMER_ID, CONSUMER)
.bodyValue(pensjonPersonRequest)
.retrieve()
Expand Down
Loading
Loading