MCPcopy Index your code
hub / github.com/Effect-TS/effect / convertOtelTimeInput

Function convertOtelTimeInput

packages/opentelemetry/src/internal/tracer.ts:332–342  ·  view source on GitHub ↗
(input: OtelApi.TimeInput | undefined, clock: Clock.Clock)

Source from the content-addressed store, hash-verified

330 (Array.isArray(u) && u.length === 2 && typeof u[0] === "number" && typeof u[1] === "number")
331
332const convertOtelTimeInput = (input: OtelApi.TimeInput | undefined, clock: Clock.Clock): bigint => {
333 if (input === undefined) {
334 return clock.unsafeCurrentTimeNanos()
335 } else if (typeof input === "number") {
336 return BigInt(Math.round(input * 1_000_000))
337 } else if (input instanceof Date) {
338 return BigInt(input.getTime()) * bigint1e6
339 }
340 const [seconds, nanos] = input
341 return BigInt(seconds) * bigint1e9 + BigInt(nanos)
342}
343
344/** @internal */
345export const currentOtelSpan: Effect.Effect<OtelApi.Span, Cause.NoSuchElementException> = Effect.clockWith((clock) =>

Callers 3

addEventFunction · 0.85
endFunction · 0.85
recordExceptionFunction · 0.85

Calls 1

Tested by

no test coverage detected