diff --git a/span-normalizer/span-normalizer/build.gradle.kts b/span-normalizer/span-normalizer/build.gradle.kts index b8f495c53..d13e31298 100644 --- a/span-normalizer/span-normalizer/build.gradle.kts +++ b/span-normalizer/span-normalizer/build.gradle.kts @@ -39,8 +39,8 @@ dependencies { implementation("org.hypertrace.core.serviceframework:platform-metrics:0.1.33") implementation("org.hypertrace.core.kafkastreams.framework:kafka-streams-framework:0.1.23") implementation("org.hypertrace.config.service:span-processing-config-service-api:0.1.27") - implementation("org.hypertrace.core.grpcutils:grpc-client-utils:0.6.2") - implementation("org.hypertrace.core.grpcutils:grpc-context-utils:0.6.2") + implementation("org.hypertrace.core.grpcutils:grpc-client-utils:0.7.1") + implementation("org.hypertrace.core.grpcutils:grpc-context-utils:0.7.1") // Required for the GRPC clients. runtimeOnly("io.grpc:grpc-netty:1.42.0") diff --git a/span-normalizer/span-normalizer/src/main/java/org/hypertrace/core/spannormalizer/jaeger/ExcludeSpanRulesCache.java b/span-normalizer/span-normalizer/src/main/java/org/hypertrace/core/spannormalizer/jaeger/ExcludeSpanRulesCache.java index 605240011..cb7e07ec4 100644 --- a/span-normalizer/span-normalizer/src/main/java/org/hypertrace/core/spannormalizer/jaeger/ExcludeSpanRulesCache.java +++ b/span-normalizer/span-normalizer/src/main/java/org/hypertrace/core/spannormalizer/jaeger/ExcludeSpanRulesCache.java @@ -14,6 +14,7 @@ import javax.annotation.Nonnull; import lombok.extern.slf4j.Slf4j; import org.hypertrace.core.grpcutils.client.GrpcChannelRegistry; +import org.hypertrace.core.grpcutils.context.ContextualKey; import org.hypertrace.core.grpcutils.context.RequestContext; import org.hypertrace.core.serviceframework.metrics.PlatformMetricsRegistry; import org.hypertrace.core.spannormalizer.client.ConfigServiceClient; @@ -31,7 +32,7 @@ public class ExcludeSpanRulesCache { private static final Duration CACHE_REFRESH_DURATION_DEFAULT = Duration.ofMillis(180000); private static final Duration CACHE_EXPIRY_DURATION_DEFAULT = Duration.ofMillis(300000); private static ExcludeSpanRulesCache INSTANCE; - private final LoadingCache> excludeSpanRulesCache; + private final LoadingCache, List> excludeSpanRulesCache; private ExcludeSpanRulesCache(Config config) { Duration cacheRefreshDuration = @@ -55,18 +56,20 @@ private ExcludeSpanRulesCache(Config config) { CacheLoader.asyncReloading( new CacheLoader<>() { @Override - public List load(@Nonnull String tenantId) { + public List load(@Nonnull ContextualKey key) { try { - return configServiceClient - .getAllExcludeSpanRules(RequestContext.forTenantId(tenantId)) - .getRuleDetailsList() - .stream() - .map(ExcludeSpanRuleDetails::getRule) - .collect(Collectors.toUnmodifiableList()); + return key.callInContext( + () -> + configServiceClient + .getAllExcludeSpanRules(key.getContext()) + .getRuleDetailsList() + .stream() + .map(ExcludeSpanRuleDetails::getRule) + .collect(Collectors.toUnmodifiableList())); } catch (Exception e) { log.error( "Could not get all exclude span rules for tenant id {}:{}", - tenantId, + key.getContext().getTenantId(), e); return Collections.emptyList(); } @@ -85,6 +88,6 @@ public static synchronized ExcludeSpanRulesCache getInstance(Config config) { } public List get(String tenantId) throws ExecutionException { - return excludeSpanRulesCache.get(tenantId); + return excludeSpanRulesCache.get(RequestContext.forTenantId(tenantId).buildContextualKey()); } }