Use microseconds in the rageshake exporter
Fixes times being off by a factor of 1000
This commit is contained in:
parent
f627835646
commit
0de1aa74ee
1 changed files with 5 additions and 5 deletions
|
@ -1,5 +1,5 @@
|
||||||
import { Attributes } from "@opentelemetry/api";
|
import { Attributes } from "@opentelemetry/api";
|
||||||
import { hrTimeToMilliseconds } from "@opentelemetry/core";
|
import { hrTimeToMicroseconds } from "@opentelemetry/core";
|
||||||
import {
|
import {
|
||||||
SpanProcessor,
|
SpanProcessor,
|
||||||
ReadableSpan,
|
ReadableSpan,
|
||||||
|
@ -32,7 +32,7 @@ export class RageshakeSpanProcessor implements SpanProcessor {
|
||||||
* Dumps the spans collected so far as Jaeger-compatible JSON.
|
* Dumps the spans collected so far as Jaeger-compatible JSON.
|
||||||
*/
|
*/
|
||||||
public dump(): string {
|
public dump(): string {
|
||||||
const now = Date.now();
|
const now = Date.now() * 1000; // Jaeger works in microseconds
|
||||||
const traces = new Map<string, ReadableSpan[]>();
|
const traces = new Map<string, ReadableSpan[]>();
|
||||||
|
|
||||||
// Organize spans by their trace IDs
|
// Organize spans by their trace IDs
|
||||||
|
@ -70,12 +70,12 @@ export class RageshakeSpanProcessor implements SpanProcessor {
|
||||||
processes,
|
processes,
|
||||||
spans: spans.map((span) => {
|
spans: spans.map((span) => {
|
||||||
const ctx = span.spanContext();
|
const ctx = span.spanContext();
|
||||||
const startTime = hrTimeToMilliseconds(span.startTime);
|
const startTime = hrTimeToMicroseconds(span.startTime);
|
||||||
// If the span has not yet ended, pretend that it ends now
|
// If the span has not yet ended, pretend that it ends now
|
||||||
const duration =
|
const duration =
|
||||||
span.duration[0] === -1
|
span.duration[0] === -1
|
||||||
? now - startTime
|
? now - startTime
|
||||||
: hrTimeToMilliseconds(span.duration);
|
: hrTimeToMicroseconds(span.duration);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
traceID: traceId,
|
traceID: traceId,
|
||||||
|
@ -97,7 +97,7 @@ export class RageshakeSpanProcessor implements SpanProcessor {
|
||||||
],
|
],
|
||||||
tags: dumpAttributes(span.attributes),
|
tags: dumpAttributes(span.attributes),
|
||||||
logs: span.events.map((event) => ({
|
logs: span.events.map((event) => ({
|
||||||
timestamp: hrTimeToMilliseconds(event.time),
|
timestamp: hrTimeToMicroseconds(event.time),
|
||||||
fields: dumpAttributes(event.attributes ?? {}),
|
fields: dumpAttributes(event.attributes ?? {}),
|
||||||
})),
|
})),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue