# Span start using withStartTimestamp(Long micro)

**URL:** <https://discuss.elastic.co/t/span-start-using-withstarttimestamp-long-micro/208992>\
**Category:** APM\
**Tags:** java\
**Created:** [November 22, 2019, 12:57am UTC](https://discuss.elastic.co/t/span-start-using-withstarttimestamp-long-micro/208992 "2019-11-22T00:57:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anjana1](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@anjana1](https://discuss.elastic.co/u/anjana1)\
**Post date:** [November 22, 2019, 12:57am UTC](https://discuss.elastic.co/t/span-start-using-withstarttimestamp-long-micro/208992/1 "2019-11-22T00:57:21Z")

</div>

**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

---

<div class="post-metadata">

**Author:** ![axw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/axw/32/28197_2.png) [@axw](https://discuss.elastic.co/u/axw)\
**Post date:** [November 22, 2019, 1:56am UTC](https://discuss.elastic.co/t/span-start-using-withstarttimestamp-long-micro/208992/2 "2019-11-22T01:56:39Z")

</div>

From the [System.nanoTime docs](https://docs.oracle.com/javase/8/docs/api/java/lang/System.html#nanoTime--) (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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 12, 2019, 9:56pm UTC](https://discuss.elastic.co/t/span-start-using-withstarttimestamp-long-micro/208992/3 "2019-12-12T21:56:56Z")

</div>

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