Skip to content

Commit

Permalink
fix(sdk-logs): use Date instead of hrTime() for timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
llc1123 committed May 18, 2023
1 parent 6d74a04 commit cdb9c72
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions experimental/packages/sdk-logs/src/LogRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
timeInputToHrTime,
isAttributeValue,
InstrumentationScope,
hrTime,
} from '@opentelemetry/core';
import type { IResource } from '@opentelemetry/resources';

Expand Down Expand Up @@ -84,16 +83,9 @@ export class LogRecord implements ReadableLogRecord {
context,
} = logRecord;

if (timestamp && observedTimestamp) {
this.hrTime = timeInputToHrTime(timestamp);
this.hrTimeObserved = timeInputToHrTime(observedTimestamp);
} else {
const now = hrTime();
this.hrTime = timestamp ? timeInputToHrTime(timestamp) : now;
this.hrTimeObserved = observedTimestamp
? timeInputToHrTime(observedTimestamp)
: now;
}
const now = new Date();
this.hrTime = timeInputToHrTime(timestamp ?? now);
this.hrTimeObserved = timeInputToHrTime(observedTimestamp ?? now);

if (context) {
const spanContext = api.trace.getSpanContext(context);
Expand Down

0 comments on commit cdb9c72

Please sign in to comment.