Skip to content

Commit

Permalink
Revert "Update OpenTelemetry-JS to v1.17.1 (#2)"
Browse files Browse the repository at this point in the history
This reverts commit 1941d00.

The OTLP JSON schema change broke things, we need to do a full upgrade
separately.
  • Loading branch information
danopia committed May 3, 2024
1 parent 1941d00 commit f341014
Show file tree
Hide file tree
Showing 13 changed files with 183 additions and 334 deletions.
2 changes: 1 addition & 1 deletion hack/bundle-opentelemetry.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env -S deno run --allow-run --allow-read --allow-write=. --allow-env --allow-sys --allow-ffi
#!/usr/bin/env -S deno run --allow-run --allow-read --allow-write=. --allow-env

// pass --refresh-yarn to force rerunning yarn on the opentelemetry packages

Expand Down
2 changes: 1 addition & 1 deletion hack/opentelemetry-js
Submodule opentelemetry-js updated 204 files
2 changes: 1 addition & 1 deletion opentelemetry/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

const _globalThis = typeof globalThis === 'object' ? globalThis : global;

const VERSION = "1.6.0";
const VERSION = "1.4.1";

const re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
function _makeCompatibilityCheck(ownVersion) {
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry/core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ declare enum ExportResultCode {
FAILED = 1
}

declare const VERSION = "1.17.1";
declare const VERSION = "1.15.2";

declare type ParsedBaggageKeyValue = {
key: string;
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ function getIdGenerator(bytes) {

const otperformance = performance;

const VERSION$1 = "1.17.1";
const VERSION$1 = "1.15.2";

const SDK_INFO = {
[SemanticResourceAttributes.TELEMETRY_SDK_NAME]: 'opentelemetry',
Expand Down
41 changes: 12 additions & 29 deletions opentelemetry/otlp-transformer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

import { HrTime } from './api.d.ts';
import { ReadableSpan } from './sdk-trace-base.d.ts';
import { ResourceMetrics } from './sdk-metrics.d.ts';
import { ReadableLogRecord } from './sdk-logs.d.ts';
Expand Down Expand Up @@ -64,22 +63,6 @@ interface IKeyValueList {
/** KeyValueList values */
values: IKeyValue[];
}
interface IFixed64 {
low: number;
high: number;
}

declare class UnsignedLong {
low: number;
high: number;
constructor(low: number, high: number);
static fromU32(value: number): UnsignedLong;
multiply(value: UnsignedLong): UnsignedLong;
add(value: UnsignedLong): UnsignedLong;
static fromString(str: string): UnsignedLong;
}

declare function hrTimeToFixed64Nanos(hrTime: HrTime): IFixed64;

/** Properties of a Resource. */
interface IResource {
Expand Down Expand Up @@ -179,9 +162,9 @@ interface INumberDataPoint {
/** NumberDataPoint attributes */
attributes: IKeyValue[];
/** NumberDataPoint startTimeUnixNano */
startTimeUnixNano?: IFixed64 | string;
startTimeUnixNano?: number;
/** NumberDataPoint timeUnixNano */
timeUnixNano?: IFixed64 | string;
timeUnixNano?: number;
/** NumberDataPoint asDouble */
asDouble?: number | null;
/** NumberDataPoint asInt */
Expand All @@ -196,9 +179,9 @@ interface IHistogramDataPoint {
/** HistogramDataPoint attributes */
attributes?: IKeyValue[];
/** HistogramDataPoint startTimeUnixNano */
startTimeUnixNano?: IFixed64 | string;
startTimeUnixNano?: number;
/** HistogramDataPoint timeUnixNano */
timeUnixNano?: IFixed64 | string;
timeUnixNano?: number;
/** HistogramDataPoint count */
count?: number;
/** HistogramDataPoint sum */
Expand All @@ -221,9 +204,9 @@ interface IExponentialHistogramDataPoint {
/** ExponentialHistogramDataPoint attributes */
attributes?: IKeyValue[];
/** ExponentialHistogramDataPoint startTimeUnixNano */
startTimeUnixNano?: IFixed64 | string;
startTimeUnixNano?: number;
/** ExponentialHistogramDataPoint timeUnixNano */
timeUnixNano?: IFixed64 | string;
timeUnixNano?: number;
/** ExponentialHistogramDataPoint count */
count?: number;
/** ExponentialHistogramDataPoint sum */
Expand Down Expand Up @@ -409,9 +392,9 @@ interface ISpan {
/** Span kind */
kind: ESpanKind;
/** Span startTimeUnixNano */
startTimeUnixNano: IFixed64;
startTimeUnixNano: number;
/** Span endTimeUnixNano */
endTimeUnixNano: IFixed64;
endTimeUnixNano: number;
/** Span attributes */
attributes: IKeyValue[];
/** Span droppedAttributesCount */
Expand Down Expand Up @@ -476,7 +459,7 @@ declare enum EStatusCode {
/** Properties of an Event. */
interface IEvent {
/** Event timeUnixNano */
timeUnixNano: IFixed64;
timeUnixNano: number;
/** Event name */
name: string;
/** Event attributes */
Expand Down Expand Up @@ -534,9 +517,9 @@ interface IScopeLogs {
/** Properties of a LogRecord. */
interface ILogRecord {
/** LogRecord timeUnixNano */
timeUnixNano: IFixed64;
timeUnixNano: number;
/** LogRecord observedTimeUnixNano */
observedTimeUnixNano: IFixed64;
observedTimeUnixNano: number;
/** LogRecord severityNumber */
severityNumber?: ESeverityNumber;
/** LogRecord severityText */
Expand Down Expand Up @@ -592,4 +575,4 @@ declare function createExportMetricsServiceRequest(resourceMetrics: ResourceMetr

declare function createExportLogsServiceRequest(logRecords: ReadableLogRecord[], useHex?: boolean): IExportLogsServiceRequest;

export { EAggregationTemporality, ESeverityNumber, ESpanKind, EStatusCode, IAnyValue, IArrayValue, IBuckets, IEvent, IExemplar, IExponentialHistogram, IExponentialHistogramDataPoint, IExportLogsPartialSuccess, IExportLogsServiceRequest, IExportLogsServiceResponse, IExportMetricsPartialSuccess, IExportMetricsServiceRequest, IExportMetricsServiceResponse, IExportTracePartialSuccess, IExportTraceServiceRequest, IExportTraceServiceResponse, IFixed64, IGauge, IHistogram, IHistogramDataPoint, IInstrumentationScope, IKeyValue, IKeyValueList, ILink, ILogRecord, IMetric, INumberDataPoint, IResource, IResourceLogs, IResourceMetrics, IResourceSpans, IScopeLogs, IScopeMetrics, IScopeSpans, ISpan, IStatus, ISum, ISummary, ISummaryDataPoint, IValueAtQuantile, UnsignedLong, createExportLogsServiceRequest, createExportMetricsServiceRequest, createExportTraceServiceRequest, hrTimeToFixed64Nanos };
export { EAggregationTemporality, ESeverityNumber, ESpanKind, EStatusCode, IAnyValue, IArrayValue, IBuckets, IEvent, IExemplar, IExponentialHistogram, IExponentialHistogramDataPoint, IExportLogsPartialSuccess, IExportLogsServiceRequest, IExportLogsServiceResponse, IExportMetricsPartialSuccess, IExportMetricsServiceRequest, IExportMetricsServiceResponse, IExportTracePartialSuccess, IExportTraceServiceRequest, IExportTraceServiceResponse, IGauge, IHistogram, IHistogramDataPoint, IInstrumentationScope, IKeyValue, IKeyValueList, ILink, ILogRecord, IMetric, INumberDataPoint, IResource, IResourceLogs, IResourceMetrics, IResourceSpans, IScopeLogs, IScopeMetrics, IScopeSpans, ISpan, IStatus, ISum, ISummary, ISummaryDataPoint, IValueAtQuantile, createExportLogsServiceRequest, createExportMetricsServiceRequest, createExportTraceServiceRequest };
121 changes: 13 additions & 108 deletions opentelemetry/otlp-transformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,105 +16,10 @@
/// <reference types="./otlp-transformer.d.ts" />

import * as core from './core.js';
import { hexToBase64 } from './core.js';
import { hrTimeToNanoseconds, hexToBase64 } from './core.js';
import { ValueType } from './api.js';
import { DataPointType, AggregationTemporality } from './sdk-metrics.js';

const TWO_PWR_32 = (1 << 16) * (1 << 16);
class UnsignedLong {
constructor(low, high) {
this.low = low;
this.high = high;
}
static fromU32(value) {
return new UnsignedLong(value % TWO_PWR_32 | 0, 0);
}
multiply(value) {
const a48 = this.high >>> 16;
const a32 = this.high & 0xffff;
const a16 = this.low >>> 16;
const a00 = this.low & 0xffff;
const b48 = value.high >>> 16;
const b32 = value.high & 0xffff;
const b16 = value.low >>> 16;
const b00 = value.low & 0xffff;
let c48 = 0;
let c32 = 0;
let c16 = 0;
let c00 = 0;
c00 += a00 * b00;
c16 += c00 >>> 16;
c00 &= 0xffff;
c16 += a16 * b00;
c32 += c16 >>> 16;
c16 &= 0xffff;
c16 += a00 * b16;
c32 += c16 >>> 16;
c16 &= 0xffff;
c32 += a32 * b00;
c48 += c32 >>> 16;
c32 &= 0xffff;
c32 += a16 * b16;
c48 += c32 >>> 16;
c32 &= 0xffff;
c32 += a00 * b32;
c48 += c32 >>> 16;
c32 &= 0xffff;
c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48;
c48 &= 0xffff;
return new UnsignedLong((c16 << 16) | c00, (c48 << 16) | c32);
}
add(value) {
const a48 = this.high >>> 16;
const a32 = this.high & 0xffff;
const a16 = this.low >>> 16;
const a00 = this.low & 0xffff;
const b48 = value.high >>> 16;
const b32 = value.high & 0xffff;
const b16 = value.low >>> 16;
const b00 = value.low & 0xffff;
let c48 = 0;
let c32 = 0;
let c16 = 0;
let c00 = 0;
c00 += a00 + b00;
c16 += c00 >>> 16;
c00 &= 0xffff;
c16 += a16 + b16;
c32 += c16 >>> 16;
c16 &= 0xffff;
c32 += a32 + b32;
c48 += c32 >>> 16;
c32 &= 0xffff;
c48 += a48 + b48;
c48 &= 0xffff;
return new UnsignedLong((c16 << 16) | c00, (c48 << 16) | c32);
}
static fromString(str) {
let result = UnsignedLong.fromU32(0);
for (let i = 0; i < str.length; i += 8) {
const size = Math.min(8, str.length - i);
const value = parseInt(str.substring(i, i + size));
if (size < 8) {
const power = UnsignedLong.fromU32(Math.pow(10, size));
result = result.multiply(power).add(UnsignedLong.fromU32(value));
}
else {
result = result.multiply(UnsignedLong.fromU32(100000000));
result = result.add(UnsignedLong.fromU32(value));
}
}
return result;
}
}

const NANOSECONDS = UnsignedLong.fromU32(1000000000);
function hrTimeToFixed64Nanos(hrTime) {
return UnsignedLong.fromU32(hrTime[0])
.multiply(NANOSECONDS)
.add(UnsignedLong.fromU32(hrTime[1]));
}

var ESpanKind;
(function (ESpanKind) {
ESpanKind[ESpanKind["SPAN_KIND_UNSPECIFIED"] = 0] = "SPAN_KIND_UNSPECIFIED";
Expand Down Expand Up @@ -173,8 +78,8 @@ function sdkSpanToOtlpSpan(span, useHex) {
traceState: ctx.traceState?.serialize(),
name: span.name,
kind: span.kind == null ? 0 : span.kind + 1,
startTimeUnixNano: hrTimeToFixed64Nanos(span.startTime),
endTimeUnixNano: hrTimeToFixed64Nanos(span.endTime),
startTimeUnixNano: hrTimeToNanoseconds(span.startTime),
endTimeUnixNano: hrTimeToNanoseconds(span.endTime),
attributes: toAttributes(span.attributes),
droppedAttributesCount: span.droppedAttributesCount,
events: span.events.map(toOtlpSpanEvent),
Expand Down Expand Up @@ -206,7 +111,7 @@ function toOtlpSpanEvent(timedEvent) {
? toAttributes(timedEvent.attributes)
: [],
name: timedEvent.name,
timeUnixNano: hrTimeToFixed64Nanos(timedEvent.time),
timeUnixNano: hrTimeToNanoseconds(timedEvent.time),
droppedAttributesCount: timedEvent.droppedAttributesCount || 0,
};
}
Expand Down Expand Up @@ -329,8 +234,8 @@ function toMetric(metricData) {
function toSingularDataPoint(dataPoint, valueType) {
const out = {
attributes: toAttributes(dataPoint.attributes),
startTimeUnixNano: hrTimeToFixed64Nanos(dataPoint.startTime),
timeUnixNano: hrTimeToFixed64Nanos(dataPoint.endTime),
startTimeUnixNano: hrTimeToNanoseconds(dataPoint.startTime),
timeUnixNano: hrTimeToNanoseconds(dataPoint.endTime),
};
switch (valueType) {
case ValueType.INT:
Expand Down Expand Up @@ -358,8 +263,8 @@ function toHistogramDataPoints(metricData) {
sum: histogram.sum,
min: histogram.min,
max: histogram.max,
startTimeUnixNano: hrTimeToFixed64Nanos(dataPoint.startTime),
timeUnixNano: hrTimeToFixed64Nanos(dataPoint.endTime),
startTimeUnixNano: hrTimeToNanoseconds(dataPoint.startTime),
timeUnixNano: hrTimeToNanoseconds(dataPoint.endTime),
};
});
}
Expand All @@ -382,8 +287,8 @@ function toExponentialHistogramDataPoints(metricData) {
},
scale: histogram.scale,
zeroCount: histogram.zeroCount,
startTimeUnixNano: hrTimeToFixed64Nanos(dataPoint.startTime),
timeUnixNano: hrTimeToFixed64Nanos(dataPoint.endTime),
startTimeUnixNano: hrTimeToNanoseconds(dataPoint.startTime),
timeUnixNano: hrTimeToNanoseconds(dataPoint.endTime),
};
});
}
Expand Down Expand Up @@ -446,8 +351,8 @@ function logRecordsToResourceLogs(logRecords, useHex) {
}
function toLogRecord(log, useHex) {
return {
timeUnixNano: hrTimeToFixed64Nanos(log.hrTime),
observedTimeUnixNano: hrTimeToFixed64Nanos(log.hrTimeObserved),
timeUnixNano: hrTimeToNanoseconds(log.hrTime),
observedTimeUnixNano: hrTimeToNanoseconds(log.hrTimeObserved),
severityNumber: toSeverityNumber(log.severityNumber),
severityText: log.severityText,
body: toAnyValue(log.body),
Expand All @@ -474,4 +379,4 @@ function toLogAttributes(attributes) {
return Object.keys(attributes).map(key => toKeyValue(key, attributes[key]));
}

export { ESpanKind, UnsignedLong, createExportLogsServiceRequest, createExportMetricsServiceRequest, createExportTraceServiceRequest, hrTimeToFixed64Nanos };
export { ESpanKind, createExportLogsServiceRequest, createExportMetricsServiceRequest, createExportTraceServiceRequest };
Loading

0 comments on commit f341014

Please sign in to comment.