How to use the @opentelemetry/core.timeInputToHrTime function in @opentelemetry/core

To help you get started, we’ve selected a few @opentelemetry/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github open-telemetry / opentelemetry-js / packages / opentelemetry-tracing / src / Span.ts View on Github external
constructor(
    parentTracer: BasicTracer,
    spanName: string,
    spanContext: types.SpanContext,
    kind: types.SpanKind,
    parentSpanId?: string,
    links: types.Link[] = [],
    startTime: types.TimeInput = hrTime()
  ) {
    this.name = spanName;
    this.spanContext = spanContext;
    this.parentSpanId = parentSpanId;
    this.kind = kind;
    this.links = links;
    this.startTime = timeInputToHrTime(startTime);
    this._logger = parentTracer.logger;
    this._traceParams = parentTracer.getActiveTraceParams();
    this._spanProcessor = parentTracer.activeSpanProcessor;
    this._spanProcessor.onStart(this);
  }
github open-telemetry / opentelemetry-js / packages / opentelemetry-tracing / src / Span.ts View on Github external
this._logger.warn('Dropping extra events.');
      this.events.shift();
    }
    if (isTimeInput(attributesOrStartTime)) {
      if (typeof startTime === 'undefined') {
        startTime = attributesOrStartTime as types.TimeInput;
      }
      attributesOrStartTime = undefined;
    }
    if (typeof startTime === 'undefined') {
      startTime = hrTime();
    }
    this.events.push({
      name,
      attributes: attributesOrStartTime as types.Attributes,
      time: timeInputToHrTime(startTime),
    });
    return this;
  }
github open-telemetry / opentelemetry-js / packages / opentelemetry-tracing / src / Span.ts View on Github external
end(endTime: types.TimeInput = hrTime()): void {
    if (this._isSpanEnded()) {
      this._logger.error('You can only call end() on a span once.');
      return;
    }
    this._ended = true;
    this.endTime = timeInputToHrTime(endTime);

    this._duration = hrTimeDuration(this.startTime, this.endTime);
    if (this._duration[0] < 0) {
      this._logger.warn(
        'Inconsistent start and end time, startTime > endTime',
        this.startTime,
        this.endTime
      );
    }

    this._spanProcessor.onEnd(this);
  }