Skip to content

Commit

Permalink
Added some extra logging for Unleash
Browse files Browse the repository at this point in the history
  • Loading branch information
flexable777 committed Dec 15, 2020
1 parent 8d8ce19 commit b2cdbf0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,18 @@ class FeatureToggleInterceptor(
return isEnabled
}

private fun isEnabled(feature: String): Boolean =
unleash.isEnabled(feature, contextMedInnloggetBruker())
private fun isEnabled(feature: String): Boolean {
logger.debug("Unleash: feature: {}", feature)
val contextMedInnloggetBruker = contextMedInnloggetBruker()
logger.debug("contextMedInnloggetBruker: {}", contextMedInnloggetBruker)
return unleash.isEnabled(feature, contextMedInnloggetBruker)
}

private fun contextMedInnloggetBruker(): UnleashContext? =
UnleashContext.builder().userId(getIdent()).build()
private fun contextMedInnloggetBruker(): UnleashContext? {
val ident = getIdent()
logger.debug("Unleash: getIdent(): {}", ident)
return UnleashContext.builder().userId(ident).build()
}

private fun getIdent() = innloggetSaksbehandlerRepository.getInnloggetIdent()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package no.nav.klage.oppgave.service.unleash

import no.finn.unleash.strategy.Strategy
import no.nav.klage.oppgave.util.getLogger
import org.springframework.beans.factory.annotation.Value
import org.springframework.core.env.Environment
import org.springframework.stereotype.Component

@Component
class ByClusterStrategy(@Value("\${nais.cluster.name}") val currentCluster: String) : Strategy {

companion object {
@Suppress("JAVA_CLASS_ON_COMPANION")
private val logger = getLogger(javaClass.enclosingClass)
const val PARAM = "cluster"
}

Expand All @@ -20,6 +22,8 @@ class ByClusterStrategy(@Value("\${nais.cluster.name}") val currentCluster: Stri
private fun getEnabledClusters(parameters: Map<String, String>?) =
parameters?.get(PARAM)?.split(',')

private fun isCurrentClusterEnabled(cluster: String): Boolean =
currentCluster == cluster
private fun isCurrentClusterEnabled(cluster: String): Boolean {
logger.debug("isCurrentClusterEnabled? cluster: {}, currentCluster: {}", cluster, currentCluster)
return currentCluster == cluster
}
}

0 comments on commit b2cdbf0

Please sign in to comment.