Unable to manually specify span startTime / endTime #1833
Replies: 4 comments 10 replies
-
I think time values should be in nano seconds since epoch. Could you check with that? |
Beta Was this translation helpful? Give feedback.
-
Please provide the versions of OpenTelemetry libraries and your collector version. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Thanks for the response! Re: 1. / 2. - In my original post (I know this thread is starting to get long!) I actually tried passing a number as milliseconds but didn't get the expected output (maybe I'm missing something here?) // millis
startTime = (new Date("2019-01-01T00:00:00.000Z")).getTime()
endTime = (new Date("2019-01-01T00:22:00.000Z")).getTime()
span = tracer.startSpan('using_millis', { startTime });
span.end(endTime); Re: 3. For my use case I don't need nanosecond level precision, but thanks for the tip. This example works in my environment! // hr times
startTime = [Math.trunc(new Date("2019-01-01T00:00:00.000Z").getTime() / 1000), 0]
endTime = [Math.trunc(new Date("2019-01-01T00:22:00.000Z").getTime() / 1000), 0]
span = tracer.startSpan('using_hr_format', { startTime });
span.end(endTime); Re: 4. A mis-configured URL was a good idea, but I confirmed the collector endpoint URL was correct. It turns out that when I manually specify the dates using date objects, numbers with scientific notion are being sent from the http exporter. (I can use the same exact exporter configuration without manually specifying dates, and it works as expected.) {"resourceSpans":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"otel-collector-time-test"}},{"key":"telemetry.sdk.language","value":{"stringValue":"nodejs"}},{"key":"telemetry.sdk.name","value":{"stringValue":"opentelemetry"}},{"key":"telemetry.sdk.version","value":{"stringValue":"0.14.0"}}],"droppedAttributesCount":0},"instrumentationLibrarySpans":[{"spans":[{"traceId":"6007def3c983acf629b7a51ce9e25013","spanId":"dc830c716e596fa5","name":"using_date_objects","kind":1,"startTimeUnixNano":1.5463008e+21,"endTimeUnixNano":1.54630212e+21,"attributes":[],"droppedAttributesCount":0,"events":[],"droppedEventsCount":0,"status":{"code":0},"links":[],"droppedLinksCount":0}],"instrumentationLibrary":{"name":"otel-collector-time-test","version":"*"}}]}]} Re: 5. Your input date 2019 is less than origin - If I understand correctly, does the library do some internal tracking of the time that the span was instantiated, and this has some influence on how start / end dates are interpreted? I just realized that the file you referenced ( My only other thought is - I wonder if the http exporter should be handling times >= Thanks again for your help |
Beta Was this translation helpful? Give feedback.
-
I'd like to manually specify the start and end time for spans in order to evaluate how well different OTEL compatible services support visualizing long running traces that extend for multiple days / weeks.
I've tried constructing spans with epochs in seconds / milliseconds, and using
Date
objects. None of which seem to yield spans with the expected start / end times.Example code
Console Output
OTEL Collector (using HTTP)
The HTTP exporter does not actually send the traces to the collector, likely due to the following error:
OTEL Collector (using GRPC)
Beta Was this translation helpful? Give feedback.
All reactions