Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions span-normalizer/span-normalizer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String, List<ExcludeSpanRule>> excludeSpanRulesCache;
private final LoadingCache<ContextualKey<Void>, List<ExcludeSpanRule>> excludeSpanRulesCache;

private ExcludeSpanRulesCache(Config config) {
Duration cacheRefreshDuration =
Expand All @@ -55,18 +56,20 @@ private ExcludeSpanRulesCache(Config config) {
CacheLoader.asyncReloading(
new CacheLoader<>() {
@Override
public List<ExcludeSpanRule> load(@Nonnull String tenantId) {
public List<ExcludeSpanRule> load(@Nonnull ContextualKey<Void> 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();
}
Expand All @@ -85,6 +88,6 @@ public static synchronized ExcludeSpanRulesCache getInstance(Config config) {
}

public List<ExcludeSpanRule> get(String tenantId) throws ExecutionException {
return excludeSpanRulesCache.get(tenantId);
return excludeSpanRulesCache.get(RequestContext.forTenantId(tenantId).buildContextualKey());
}
}