Skip to content

Commit

Permalink
fix: fix certain metrics that weren't firing
Browse files Browse the repository at this point in the history
  • Loading branch information
bgiori committed Sep 3, 2024
1 parent e0962e0 commit dbf2994
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions src/main/kotlin/LocalEvaluationClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ class LocalEvaluationClient internal constructor(
apiKey: String,
private val config: LocalEvaluationConfig = LocalEvaluationConfig(),
private val httpClient: OkHttpClient = OkHttpClient(),
cohortApi: CohortApi? = getCohortDownloadApi(config, httpClient)
private val metrics: LocalEvaluationMetrics = LocalEvaluationMetricsWrapper(config.metrics),
cohortApi: CohortApi? = getCohortDownloadApi(config, httpClient, metrics),
) {
private val assignmentService: AssignmentService? = createAssignmentService(apiKey)
private val serverUrl: HttpUrl = getServerUrl(config)
private val evaluation: EvaluationEngine = EvaluationEngineImpl()
private val metrics: LocalEvaluationMetrics = LocalEvaluationMetricsWrapper(config.metrics)
private val flagConfigApi = DynamicFlagConfigApi(apiKey, serverUrl, getProxyUrl(config), httpClient)
private val flagConfigApi = DynamicFlagConfigApi(apiKey, serverUrl, getProxyUrl(config), httpClient, metrics)
private val flagConfigStorage = InMemoryFlagConfigStorage()
private val cohortStorage = if (config.cohortSyncConfig == null) {
null
Expand Down Expand Up @@ -88,7 +88,8 @@ class LocalEvaluationClient internal constructor(
setOptions(Options().setMinIdLength(1))
setServerUrl(getEventServerUrl(config, config.assignmentConfiguration))
},
InMemoryAssignmentFilter(config.assignmentConfiguration.cacheCapacity)
InMemoryAssignmentFilter(config.assignmentConfiguration.cacheCapacity),
metrics = metrics,
)
}
@JvmOverloads
Expand Down Expand Up @@ -159,7 +160,11 @@ class LocalEvaluationClient internal constructor(
}
}

private fun getCohortDownloadApi(config: LocalEvaluationConfig, httpClient: OkHttpClient): CohortApi? {
private fun getCohortDownloadApi(
config: LocalEvaluationConfig,
httpClient: OkHttpClient,
metrics: LocalEvaluationMetrics
): CohortApi? {
return if (config.cohortSyncConfig != null) {
DynamicCohortApi(
apiKey = config.cohortSyncConfig.apiKey,
Expand All @@ -168,6 +173,7 @@ private fun getCohortDownloadApi(config: LocalEvaluationConfig, httpClient: OkHt
serverUrl = getCohortServerUrl(config),
proxyUrl = getProxyUrl(config),
httpClient = httpClient,
metrics = metrics
)
} else {
null
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/deployment/DeploymentRunner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal class DeploymentRunner(
private val lock = Once()
private val poller = Executors.newScheduledThreadPool(1, daemonFactory)
private val cohortLoader = if (cohortApi != null && cohortStorage != null) {
CohortLoader(cohortApi, cohortStorage)
CohortLoader(cohortApi, cohortStorage, metrics)
} else {
null
}
Expand Down

0 comments on commit dbf2994

Please sign in to comment.