From 606643a1adeddc4e8791d00a50d486772bf4827d Mon Sep 17 00:00:00 2001 From: "sanhuan.sw" Date: Tue, 15 Aug 2023 15:33:13 +0800 Subject: [PATCH] fix: fix trace agent --- .../web/controller/TraceAgentFacadeImpl.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/TraceAgentFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/TraceAgentFacadeImpl.java index f6570674e..77adccd14 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/TraceAgentFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/TraceAgentFacadeImpl.java @@ -9,6 +9,7 @@ import io.holoinsight.server.home.biz.common.MetaDictType; import io.holoinsight.server.home.biz.common.MetaDictUtil; import io.holoinsight.server.home.biz.service.ApiKeyService; +import io.holoinsight.server.home.biz.service.TenantInitService; import io.holoinsight.server.home.common.util.scope.RequestContext; import io.holoinsight.server.home.dal.model.ApiKey; import io.holoinsight.server.home.web.common.AesUtil; @@ -39,6 +40,10 @@ public class TraceAgentFacadeImpl extends BaseFacade { @Autowired private ApiKeyService apiKeyService; + @Autowired + private TenantInitService tenantInitService; + + @Autowired private TraceAuthEncryptConfiguration traceAuthEncryptConfiguration; @@ -55,10 +60,7 @@ public JsonResult> traceAgent( final JsonResult> result = new JsonResult<>(); try { String tenant = RequestContext.getContext().ms.getTenant(); - Map conditions = new HashMap<>(); - conditions.put("tenant", tenant); - conditions.put("status", true); - List apiKeys = apiKeyService.listByMap(conditions); + List apiKeys = apiKeyService.listByMap(apikeyConditions(tenant, extendInfo)); Map sysMap = new HashMap<>(); String apikey = ""; @@ -98,6 +100,13 @@ public JsonResult> traceAgent( return result; } + public Map apikeyConditions(String tenant, Map extendInfo) { + Map conditions = new HashMap<>(); + conditions.put("tenant", tenantInitService.getTsdbTenant(tenant)); + conditions.put("status", true); + return conditions; + } + public String getCollectorAddress(Map extendInfo) { return MetaDictUtil.getStringValue(MetaDictType.TRACE_AGENT_CONFIG, MetaDictKey.COLLECTOR_HOST); }