Skip to content

Commit

Permalink
special handling for duration_ms within the zipkin api (#951)
Browse files Browse the repository at this point in the history
  • Loading branch information
vthacker authored Jun 12, 2024
1 parent 7b43d7e commit b714979
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions astra/src/main/java/com/slack/astra/zipkinApi/ZipkinService.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
import com.slack.astra.server.AstraQueryServiceBase;
import com.slack.astra.util.JsonUtil;
import java.io.IOException;
import java.time.Duration;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -80,6 +82,16 @@ protected static String convertLogWireMessageToZipkinSpan(List<LogWireMessage> m
messageTags.put(k, String.valueOf(value));
}
}

// TODO: today at Slack the duration is sent as "duration_ms"
// We we have this special handling which should be addressed upstream
// and then removed from here
if (duration == 0) {
Object value =
message.getSource().getOrDefault(LogMessage.ReservedField.DURATION_MS.fieldName, 0);
duration = TimeUnit.MICROSECONDS.convert(Duration.ofMillis(((Number) value).intValue()));
}

// these are some mandatory fields without which the grafana zipkin plugin fails to display
// the span
if (messageTraceId == null) {
Expand Down

0 comments on commit b714979

Please sign in to comment.