Span start using withStartTimestamp(Long micro)

Kibana version : 7.3.2

Elasticsearch version : 7.3.2

APM Server version : 7.3.2

APM Agent language and version : java 1.9.0

Fresh install or upgraded from other version? fresh install

Is there anything special in your setup? For example, are you using the Logstash or Kafka outputs? Are you using a load balancer in front of the APM Servers? Have you changed index pattern, generated custom templates, changed agent configuration etc. :-----No

Description of the problem including expected versus actual behavior. Please include screenshots (if relevant) :

Steps to reproduce :
I want to capture my spans with a timestamp . I am using Elastic APM bridge for Open tracing to capture spans

I used the method :- withStartTimestamp(timeInMicros) for this purpose but I passed the time as long format for which I used System.nanoTime()/1000 as the time. The spans stopped showing in Kibana.

Previously I was using Instant.EPOCH.until(starttime, ChronoUnit.MICROS) to capture the time and the spans displayed in Kibana properly.

But I want a java 7 support so I cannot use "java.time.Instant" packages. Why would spans not show up if I pass the time using System.nanoTime()/1000

From the System.nanoTime docs (emphasis mine):

This method can only be used to measure elapsed time and is not related to any other notion of system or wall-clock time. The value returned represents nanoseconds since some fixed but arbitrary origin time (perhaps in the future, so values may be negative). The same origin is used by all invocations of this method in an instance of a Java virtual machine; other virtual machine instances are likely to use a different origin.

You should instead use System.currentTimeMillis() * 1000 for the start time.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.