Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Commit

Permalink
logs dir bash on token and type
Browse files Browse the repository at this point in the history
  • Loading branch information
yyyogev committed Nov 6, 2019
1 parent ab18462 commit ba69ff4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -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);
}

Expand All @@ -50,6 +55,7 @@ public String getAccountToken() {

public void setAccountToken(String accountToken) {
this.accountToken = accountToken;
setQueueDir();
}

public ScheduledExecutorService getSenderExecutors() {
Expand All @@ -62,7 +68,7 @@ public LogzioSender getLogzioSender() {
requestConf = HttpsRequestConfiguration
.builder()
.setLogzioListenerUrl(getUrl())
.setLogzioType(this.type)
.setLogzioType(this.TYPE)
.setLogzioToken(getAccountToken())
.setCompressRequests(this.compressRequests)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public Filters addTerms(String field, List<String> values) {
}

public SearchRequest filters(Filters filters) {
filters.addTerm("type", ConsumerParams.type);
filters.addTerm("type", ConsumerParams.TYPE);
return query(new BoolQuery("must", filters));
}

Expand Down

0 comments on commit ba69ff4

Please sign in to comment.