Skip to content

Commit

Permalink
make maxSpans for zipkin endpoint configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
autata committed Dec 4, 2024
1 parent 16d8f56 commit 1a613d5
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public AstraDistributedQueryService(
this.snapshotMetadataStore = snapshotMetadataStore;
this.datasetMetadataStore = datasetMetadataStore;
this.defaultQueryTimeout = defaultQueryTimeout;

searchMetadataTotalChangeCounter = meterRegistry.counter(SEARCH_METADATA_TOTAL_CHANGE_COUNTER);
this.distributedQueryApdexSatisfied = meterRegistry.counter(DISTRIBUTED_QUERY_APDEX_SATISFIED);
this.distributedQueryApdexTolerating =
Expand Down
2 changes: 1 addition & 1 deletion astra/src/main/java/com/slack/astra/server/Astra.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ private static Set<Service> getServices(
.withRequestTimeout(requestTimeout)
.withTracing(astraConfig.getTracingConfig())
.withAnnotatedService(new ElasticsearchApiService(astraDistributedQueryService))
.withAnnotatedService(new ZipkinService(astraDistributedQueryService))
.withAnnotatedService(new ZipkinService(astraDistributedQueryService, astraConfig.getQueryConfig().getZipkinDefaultMaxSpans()))
.withGrpcService(astraDistributedQueryService)
.build();
services.add(armeriaService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ protected static long convertToMicroSeconds(Instant instant) {
private static final Logger LOG = LoggerFactory.getLogger(ZipkinService.class);
private static long LOOKBACK_MINS = 60 * 24 * 7;

private static final int MAX_SPANS = 20_000;
private final int defaultMaxSpans;

private final AstraQueryServiceBase searcher;

Expand All @@ -160,8 +160,9 @@ protected static long convertToMicroSeconds(Instant instant) {
.serializationInclusion(JsonInclude.Include.NON_EMPTY)
.build();

public ZipkinService(AstraQueryServiceBase searcher) {
public ZipkinService(AstraQueryServiceBase searcher, int defaultMaxSpans) {
this.searcher = searcher;
this.defaultMaxSpans = defaultMaxSpans;
}

@Get
Expand Down Expand Up @@ -216,7 +217,7 @@ public HttpResponse getTraceByTraceId(
long endTime =
endTimeEpochMs.orElseGet(
() -> Instant.now().plus(LOOKBACK_MINS, ChronoUnit.MINUTES).toEpochMilli());
int howMany = maxSpans.orElse(MAX_SPANS);
int howMany = maxSpans.orElse(this.defaultMaxSpans);

brave.Span span = Tracing.currentTracer().currentSpan();
span.tag("startTimeEpochMs", String.valueOf(startTime));
Expand Down
1 change: 1 addition & 0 deletions astra/src/main/proto/astra_configs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ message QueryServiceConfig {
ServerConfig server_config = 1;
int32 default_query_timeout_ms = 2;
string managerConnectString = 3;
int32 zipkin_default_max_spans = 4;
}

enum KafkaOffsetLocation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class ZipkinServiceTest {
@BeforeEach
public void setup() throws IOException {
MockitoAnnotations.openMocks(this);
zipkinService = spy(new ZipkinService(searcher));
zipkinService = spy(new ZipkinService(searcher, 20000));
// Build mockSearchResult
ObjectMapper objectMapper = new ObjectMapper();
JsonNode jsonNode =
Expand Down
1 change: 1 addition & 0 deletions config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ queryConfig:
serverAddress: ${ASTRA_QUERY_SERVER_ADDRESS:-localhost}
requestTimeoutMs: ${ASTRA_QUERY_REQUEST_TIMEOUT_MS:-5000}
defaultQueryTimeoutMs: ${ASTRA_QUERY_DEFAULT_QUERY_TIMEOUT_MS:-3000}
zipkinDefaultMaxSpans: ${ASTRA_QUERY_ZIPKIN_DEFAULT_MAX_SPANS:-20000}
managerConnectString: ${ASTRA_MANAGER_CONNECTION_STRING:-localhost:8083}

metadataStoreConfig:
Expand Down

0 comments on commit 1a613d5

Please sign in to comment.