lightstep-tracer
Version:
> ❗ **This instrumentation is no longer recommended**. Please review [documentation on setting up and configuring the OpenTelemetry Node.js Launcher](https://github.com/lightstep/otel-launcher-node) or [OpenTelemetry JS (Browser)](https://github.com/open-
65 lines (56 loc) • 2.15 kB
JavaScript
import { crouton_thrift } from '../platform_abstraction_layer'; // eslint-disable-line camelcase
import _each from '../_each'; // eslint-disable-line camelcase
import * as coerce from './coerce';
export default class ReportImp {
constructor(runtime, oldestMicros, youngestMicros, spanRecords, internalLogs, counters, timestampOffsetMicros) {
this._runtime = runtime;
this._oldestMicros = oldestMicros;
this._youngestMicros = youngestMicros;
this._spanRecords = spanRecords;
this._internalLogs = internalLogs;
this._counters = counters;
this._timestampOffsetMicros = timestampOffsetMicros;
}
getSpanRecords() {
return this._spanRecords;
}
getInternalLogs() {
return this._internalLogs;
}
getCounters() {
return this._counters;
}
toThrift() {
_each(this._spanRecords, (span) => {
span.runtime_guid = this._runtimeGUID;
});
let thriftCounters = [];
_each(this._counters, (value, key) => {
if (value === 0) {
return;
}
// eslint-disable-next-line camelcase
thriftCounters.push(new crouton_thrift.MetricsSample({
name : coerce.toString(key),
double_value : coerce.toNumber(value),
}));
});
let thriftSpanRecords = [];
_each(this._spanRecords, (spanRecord) => {
thriftSpanRecords.push(spanRecord._toThrift());
});
// eslint-disable-next-line camelcase
return new crouton_thrift.ReportRequest({
runtime : this._runtime.toThrift(),
oldest_micros : this._oldestMicros,
youngest_micros : this._youngestMicros,
span_records : thriftSpanRecords,
internal_logs : this._internalLogs,
// eslint-disable-next-line camelcase
internal_metrics : new crouton_thrift.Metrics({
counts : thriftCounters,
}),
timestamp_offset_micros : this._timestampOffsetMicros,
});
}
}