From ba69ff470e92e5fe56b773e628e3fd8907ee2aa3 Mon Sep 17 00:00:00 2001 From: yyyogev Date: Wed, 6 Nov 2019 12:39:37 +0200 Subject: [PATCH] logs dir bash on token and type --- .../zipkin2/storage/logzio/ConsumerParams.java | 14 ++++++++++---- .../storage/logzio/client/SearchRequest.java | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/storage-logzio/src/main/java/zipkin2/storage/logzio/ConsumerParams.java b/storage-logzio/src/main/java/zipkin2/storage/logzio/ConsumerParams.java index 8d4dec4..a0e05a2 100644 --- a/storage-logzio/src/main/java/zipkin2/storage/logzio/ConsumerParams.java +++ b/storage-logzio/src/main/java/zipkin2/storage/logzio/ConsumerParams.java @@ -3,11 +3,13 @@ import io.logz.sender.HttpsRequestConfiguration; import io.logz.sender.LogzioSender; import io.logz.sender.SenderStatusReporter; +import io.logz.sender.com.google.common.hash.Hashing; import io.logz.sender.exceptions.LogzioParameterErrorException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; +import java.nio.charset.StandardCharsets; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -16,7 +18,7 @@ public class ConsumerParams { private static final Logger logger = LoggerFactory.getLogger(ConsumerParams.class); private String url; - public static final String type = "zipkinSpan"; + public static final String TYPE = "zipkinSpan"; private String accountToken; private final int threadPoolSize = 3; private final boolean compressRequests = true; @@ -29,10 +31,13 @@ public class ConsumerParams { private int senderDrainInterval; private int cleanSentTracesInterval; - public ConsumerParams() { + public void setQueueDir() { + String tokenTypeSha = Hashing.sha256() + .hashString(TYPE + accountToken, StandardCharsets.UTF_8) + .toString(); String queuePath = System.getProperty("user.dir"); queuePath += queuePath.endsWith("/") ? "" : "/"; - queuePath += "logzio-storage"; + queuePath += "logzio-storage" + tokenTypeSha; this.queueDir = new File(queuePath); } @@ -50,6 +55,7 @@ public String getAccountToken() { public void setAccountToken(String accountToken) { this.accountToken = accountToken; + setQueueDir(); } public ScheduledExecutorService getSenderExecutors() { @@ -62,7 +68,7 @@ public LogzioSender getLogzioSender() { requestConf = HttpsRequestConfiguration .builder() .setLogzioListenerUrl(getUrl()) - .setLogzioType(this.type) + .setLogzioType(this.TYPE) .setLogzioToken(getAccountToken()) .setCompressRequests(this.compressRequests) .build(); diff --git a/storage-logzio/src/main/java/zipkin2/storage/logzio/client/SearchRequest.java b/storage-logzio/src/main/java/zipkin2/storage/logzio/client/SearchRequest.java index 30e274f..669d705 100644 --- a/storage-logzio/src/main/java/zipkin2/storage/logzio/client/SearchRequest.java +++ b/storage-logzio/src/main/java/zipkin2/storage/logzio/client/SearchRequest.java @@ -54,7 +54,7 @@ public Filters addTerms(String field, List values) { } public SearchRequest filters(Filters filters) { - filters.addTerm("type", ConsumerParams.type); + filters.addTerm("type", ConsumerParams.TYPE); return query(new BoolQuery("must", filters)); }