Skip to content

Commit

Permalink
Merge branch 'main' into fix/4130
Browse files Browse the repository at this point in the history
  • Loading branch information
pichlermarc authored Sep 28, 2023
2 parents c423a61 + f0ceabc commit dfd73b2
Show file tree
Hide file tree
Showing 31 changed files with 535 additions and 424 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/
* fix(sdk-metrics): do not report empty scopes and metrics [#4135](https://github.com/open-telemetry/opentelemetry-js/pull/4135) @pichlermarc
* Instruments that were created, but did not have measurements will not be exported anymore
* Meters (Scopes) that were created, but did not have any instruments with measurements under them will not be exported anymore.
* fix(exporter-zipkin): round duration to the nearest int in annotations to be compliant with zipkin protocol [#4167](https://github.com/open-telemetry/opentelemetry-js/pull/4167) @FelipeEmerim

### :books: (Refine Doc)

Expand Down
1 change: 1 addition & 0 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ All notable changes to experimental packages in this project will be documented

### :bug: (Bug Fix)

* fix(otlp-transformer): Avoid precision loss when converting from HrTime to unix nanoseconds. [#4062](https://github.com/open-telemetry/opentelemetry-js/pull/4062)
* fix(exporter-logs-otlp-http): add @opentelemetry/api-logs as dependency

## 0.41.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export function ensureExportedLogRecordIsCorrect(logRecord: ILogRecord) {
ensureExportedAttributesAreCorrect(logRecord.attributes);
assert.strictEqual(
logRecord.timeUnixNano,
'1680253513123241728',
'1680253513123241635',
'timeUnixNano is wrong'
);
assert.strictEqual(
Expand Down
14 changes: 10 additions & 4 deletions experimental/packages/exporter-logs-otlp-http/test/logHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { Resource } from '@opentelemetry/resources';
import * as assert from 'assert';
import { VERSION } from '@opentelemetry/core';
import {
hrTimeToFixed64Nanos,
IAnyValue,
IExportLogsServiceRequest,
IKeyValue,
Expand Down Expand Up @@ -76,17 +77,22 @@ export function ensureExportedBodyIsCorrect(body?: IAnyValue) {
);
}

function hrTimeToFixed64(hrTime: HrTime) {
const { low, high } = hrTimeToFixed64Nanos(hrTime);
return { low, high };
}

export function ensureExportedLogRecordIsCorrect(logRecord: ILogRecord) {
ensureExportedBodyIsCorrect(logRecord.body);
ensureExportedAttributesAreCorrect(logRecord.attributes);
assert.strictEqual(
assert.deepStrictEqual(
logRecord.timeUnixNano,
1680253513123241700,
hrTimeToFixed64(mockedReadableLogRecord.hrTime),
'timeUnixNano is wrong'
);
assert.strictEqual(
assert.deepStrictEqual(
logRecord.observedTimeUnixNano,
1680253513123241700,
hrTimeToFixed64(mockedReadableLogRecord.hrTimeObserved),
'observedTimeUnixNano is wrong'
);
assert.strictEqual(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ export function ensureExportedLogRecordIsCorrect(logRecord: ILogRecord) {
ensureExportedAttributesAreCorrect(logRecord.attributes);
assert.strictEqual(
logRecord.timeUnixNano,
'1680253513123241728',
'1680253513123241635',
'timeUnixNano is wrong'
);
assert.strictEqual(
logRecord.observedTimeUnixNano,
'1680253513123241728',
'1680253513123241635',
'observedTimeUnixNano is wrong'
);
assert.strictEqual(
Expand Down
20 changes: 10 additions & 10 deletions experimental/packages/exporter-trace-otlp-grpc/test/traceHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,49 +114,49 @@ export function ensureExportedEventsAreCorrect(events: IEvent[]) {
[
{
attributes: [],
timeUnixNano: '1574120165429803008',
timeUnixNano: '1574120165429803070',
name: 'fetchStart',
droppedAttributesCount: 0,
},
{
attributes: [],
timeUnixNano: '1574120165429803008',
timeUnixNano: '1574120165429803070',
name: 'domainLookupStart',
droppedAttributesCount: 0,
},
{
attributes: [],
timeUnixNano: '1574120165429803008',
timeUnixNano: '1574120165429803070',
name: 'domainLookupEnd',
droppedAttributesCount: 0,
},
{
attributes: [],
timeUnixNano: '1574120165429803008',
timeUnixNano: '1574120165429803070',
name: 'connectStart',
droppedAttributesCount: 0,
},
{
attributes: [],
timeUnixNano: '1574120165429803008',
timeUnixNano: '1574120165429803070',
name: 'connectEnd',
droppedAttributesCount: 0,
},
{
attributes: [],
timeUnixNano: '1574120165435513088',
timeUnixNano: '1574120165435513070',
name: 'requestStart',
droppedAttributesCount: 0,
},
{
attributes: [],
timeUnixNano: '1574120165436923136',
timeUnixNano: '1574120165436923070',
name: 'responseStart',
droppedAttributesCount: 0,
},
{
attributes: [],
timeUnixNano: '1574120165438688000',
timeUnixNano: '1574120165438688070',
name: 'responseEnd',
droppedAttributesCount: 0,
},
Expand Down Expand Up @@ -235,12 +235,12 @@ export function ensureExportedSpanIsCorrect(span: ISpan) {
assert.strictEqual(span.kind, 'SPAN_KIND_INTERNAL', 'kind is wrong');
assert.strictEqual(
span.startTimeUnixNano,
'1574120165429803008',
'1574120165429803070',
'startTimeUnixNano is wrong'
);
assert.strictEqual(
span.endTimeUnixNano,
'1574120165438688000',
'1574120165438688070',
'endTimeUnixNano is wrong'
);
assert.strictEqual(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ describe('OTLPTraceExporter - node with json over http', () => {

fakeRequest.on('end', () => {
const responseBody = buff.toString();

const json = JSON.parse(responseBody) as IExportTraceServiceRequest;
const span1 = json.resourceSpans?.[0].scopeSpans?.[0].spans?.[0];
assert.ok(typeof span1 !== 'undefined', "span doesn't exist");
Expand Down
30 changes: 18 additions & 12 deletions experimental/packages/exporter-trace-otlp-http/test/traceHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
ILink,
IResource,
ISpan,
UnsignedLong,
} from '@opentelemetry/otlp-transformer';

if (typeof Buffer === 'undefined') {
Expand Down Expand Up @@ -243,54 +244,59 @@ export const multiInstrumentationLibraryTrace: ReadableSpan[] = [
},
];

function fixed64FromString(str: string) {
const { low, high } = UnsignedLong.fromString(str);
return { low, high };
}

export function ensureEventsAreCorrect(events: IEvent[]) {
assert.deepStrictEqual(
events,
[
{
timeUnixNano: 1574120165429803000,
timeUnixNano: fixed64FromString('1574120165429803070'),
name: 'fetchStart',
attributes: [],
droppedAttributesCount: 0,
},
{
timeUnixNano: 1574120165429803000,
timeUnixNano: fixed64FromString('1574120165429803070'),
name: 'domainLookupStart',
attributes: [],
droppedAttributesCount: 0,
},
{
timeUnixNano: 1574120165429803000,
timeUnixNano: fixed64FromString('1574120165429803070'),
name: 'domainLookupEnd',
attributes: [],
droppedAttributesCount: 0,
},
{
timeUnixNano: 1574120165429803000,
timeUnixNano: fixed64FromString('1574120165429803070'),
name: 'connectStart',
attributes: [],
droppedAttributesCount: 0,
},
{
timeUnixNano: 1574120165429803000,
timeUnixNano: fixed64FromString('1574120165429803070'),
name: 'connectEnd',
attributes: [],
droppedAttributesCount: 0,
},
{
timeUnixNano: 1574120165435513000,
timeUnixNano: fixed64FromString('1574120165435513070'),
name: 'requestStart',
attributes: [],
droppedAttributesCount: 0,
},
{
timeUnixNano: 1574120165436923100,
timeUnixNano: fixed64FromString('1574120165436923070'),
name: 'responseStart',
attributes: [],
droppedAttributesCount: 0,
},
{
timeUnixNano: 1574120165438688000,
timeUnixNano: fixed64FromString('1574120165438688070'),
name: 'responseEnd',
attributes: [],
droppedAttributesCount: 0,
Expand Down Expand Up @@ -364,14 +370,14 @@ export function ensureSpanIsCorrect(span: ISpan, useHex = true) {
);
assert.strictEqual(span.name, 'documentFetch', 'name is wrong');
assert.strictEqual(span.kind, ESpanKind.SPAN_KIND_INTERNAL, 'kind is wrong');
assert.strictEqual(
assert.deepStrictEqual(
span.startTimeUnixNano,
1574120165429803008,
fixed64FromString('1574120165429803070'),
'startTimeUnixNano is wrong'
);
assert.strictEqual(
assert.deepStrictEqual(
span.endTimeUnixNano,
1574120165438688000,
fixed64FromString('1574120165438688070'),
'endTimeUnixNano is wrong'
);
assert.strictEqual(
Expand Down
20 changes: 10 additions & 10 deletions experimental/packages/exporter-trace-otlp-proto/test/traceHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,42 +109,42 @@ export function ensureProtoEventsAreCorrect(events: IEvent[]) {
events,
[
{
timeUnixNano: '1574120165429803008',
timeUnixNano: '1574120165429803070',
name: 'fetchStart',
droppedAttributesCount: 0,
},
{
timeUnixNano: '1574120165429803008',
timeUnixNano: '1574120165429803070',
name: 'domainLookupStart',
droppedAttributesCount: 0,
},
{
timeUnixNano: '1574120165429803008',
timeUnixNano: '1574120165429803070',
name: 'domainLookupEnd',
droppedAttributesCount: 0,
},
{
timeUnixNano: '1574120165429803008',
timeUnixNano: '1574120165429803070',
name: 'connectStart',
droppedAttributesCount: 0,
},
{
timeUnixNano: '1574120165429803008',
timeUnixNano: '1574120165429803070',
name: 'connectEnd',
droppedAttributesCount: 0,
},
{
timeUnixNano: '1574120165435513088',
timeUnixNano: '1574120165435513070',
name: 'requestStart',
droppedAttributesCount: 0,
},
{
timeUnixNano: '1574120165436923136',
timeUnixNano: '1574120165436923070',
name: 'responseStart',
droppedAttributesCount: 0,
},
{
timeUnixNano: '1574120165438688000',
timeUnixNano: '1574120165438688070',
name: 'responseEnd',
droppedAttributesCount: 0,
},
Expand Down Expand Up @@ -219,12 +219,12 @@ export function ensureProtoSpanIsCorrect(span: ISpan) {
assert.strictEqual(span.kind, 'SPAN_KIND_INTERNAL', 'kind is wrong');
assert.strictEqual(
span.startTimeUnixNano,
'1574120165429803008',
'1574120165429803070',
'startTimeUnixNano is wrong'
);
assert.strictEqual(
span.endTimeUnixNano,
'1574120165438688000',
'1574120165438688070',
'endTimeUnixNano is wrong'
);
assert.strictEqual(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,18 +253,23 @@ const testOTLPMetricExporter = (params: TestParams) => {
exportedData[0].scopeMetrics[0].metrics[histogramIndex];
ensureExportedCounterIsCorrect(
counter,
counter.sum?.dataPoints[0].timeUnixNano,
counter.sum?.dataPoints[0].startTimeUnixNano
metrics.scopeMetrics[0].metrics[counterIndex].dataPoints[0].endTime,
metrics.scopeMetrics[0].metrics[counterIndex].dataPoints[0]
.startTime
);
ensureExportedObservableGaugeIsCorrect(
observableGauge,
observableGauge.gauge?.dataPoints[0].timeUnixNano,
observableGauge.gauge?.dataPoints[0].startTimeUnixNano
metrics.scopeMetrics[0].metrics[observableIndex].dataPoints[0]
.endTime,
metrics.scopeMetrics[0].metrics[observableIndex].dataPoints[0]
.startTime
);
ensureExportedHistogramIsCorrect(
histogram,
histogram.histogram?.dataPoints[0].timeUnixNano,
histogram.histogram?.dataPoints[0].startTimeUnixNano,
metrics.scopeMetrics[0].metrics[histogramIndex].dataPoints[0]
.endTime,
metrics.scopeMetrics[0].metrics[histogramIndex].dataPoints[0]
.startTime,
[0, 100],
['0', '2', '0']
);
Expand Down
Loading

0 comments on commit dfd73b2

Please sign in to comment.