Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade for opentelemtry js v0.12.0 #189

Merged
merged 1 commit into from
Oct 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions packages/opentelemetry-cloud-monitoring-exporter/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions packages/opentelemetry-cloud-monitoring-exporter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
"registry": "https://wombat-dressing-room.appspot.com"
},
"devDependencies": {
"@opentelemetry/api": "^0.11.0",
"@opentelemetry/core": "^0.11.0",
"@opentelemetry/metrics": "^0.11.0",
"@opentelemetry/resources": "^0.11.0",
"@opentelemetry/api": "^0.12.0",
"@opentelemetry/core": "^0.12.0",
"@opentelemetry/metrics": "^0.12.0",
"@opentelemetry/resources": "^0.12.0",
"@types/mocha": "7.0.2",
"@types/nock": "11.1.0",
"@types/node": "12.12.51",
Expand All @@ -60,9 +60,9 @@
"googleapis": "^46.0.0"
},
"peerDependencies": {
"@opentelemetry/api": "^0.11.0",
"@opentelemetry/core": "^0.11.0",
"@opentelemetry/metrics": "^0.11.0",
"@opentelemetry/resources": "^0.11.0"
"@opentelemetry/api": "^0.12.0",
"@opentelemetry/core": "^0.12.0",
"@opentelemetry/metrics": "^0.12.0",
"@opentelemetry/resources": "^0.12.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class MetricExporter implements IMetricExporter {
cb(ExportResult.SUCCESS);
}

shutdown(): void {}
async shutdown(): Promise<void> {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious, where did this change come from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They changed the interface in the SDK: open-telemetry/opentelemetry-js#1439


/**
* Returns true if the given metricDescriptor is successfully registered to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
MetricDescriptor as OTMetricDescriptor,
MetricKind as OTMetricKind,
MetricRecord,
Distribution as OTDistribution,
Histogram as OTHistogram,
Point as OTPoint,
PointValueType,
Expand Down Expand Up @@ -232,10 +231,6 @@ function transformPoint(

/** Transforms a OpenTelemetry Point's value to a StackDriver Point value. */
function transformValue(valueType: OTValueType, value: PointValueType) {
if (isDistributionValue(value)) {
throw Error('unsupported distribution value type');
// no buckets aggregated, which is a required param in `distributionValue` for Cloud Monitoring v3
}
if (isHistogramValue(value)) {
return {
distributionValue: {
Expand All @@ -258,17 +253,8 @@ function transformValue(valueType: OTValueType, value: PointValueType) {
throw Error(`unsupported value type: ${valueType}`);
}

/** Returns true if value is of type OTDistribution */
function isDistributionValue(
value: number | OTDistribution | OTHistogram
): value is OTDistribution {
return Object.prototype.hasOwnProperty.call(value, 'min');
}

/** Returns true if value is of type OTHistogram */
function isHistogramValue(
value: number | OTDistribution | OTHistogram
): value is OTHistogram {
function isHistogramValue(value: PointValueType): value is OTHistogram {
return Object.prototype.hasOwnProperty.call(value, 'buckets');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
MetricDescriptor as OTMetricDescriptor,
Point as OTPoint,
MeterProvider,
Distribution,
Histogram,
} from '@opentelemetry/metrics';
import { ValueType as OTValueType, Labels } from '@opentelemetry/api';
Expand Down Expand Up @@ -342,34 +341,6 @@ describe('transform', () => {
assert(result.interval.startTime);
});

it('should export a distribution value', () => {
const metricDescriptor: OTMetricDescriptor = {
name: METRIC_NAME,
description: METRIC_DESCRIPTION,
unit: DEFAULT_UNIT,
metricKind: OTMetricKind.COUNTER,
valueType: OTValueType.DOUBLE,
};
const point: OTPoint<Distribution> = {
value: {
min: 20.0,
max: 75.4,
last: 40.3,
count: 22,
sum: 150,
},
timestamp: process.hrtime(),
};

assert.throws(() => {
return TEST_ONLY.transformPoint(
point,
metricDescriptor,
new Date().toISOString()
);
}, /unsupported distribution value type/);
});

it('should export a histogram value', () => {
const metricDescriptor: OTMetricDescriptor = {
name: METRIC_NAME,
Expand Down
56 changes: 28 additions & 28 deletions packages/opentelemetry-cloud-trace-exporter/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions packages/opentelemetry-cloud-trace-exporter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
"registry": "https://wombat-dressing-room.appspot.com"
},
"devDependencies": {
"@opentelemetry/api": "^0.11.0",
"@opentelemetry/resources": "^0.11.0",
"@opentelemetry/tracing": "^0.11.0",
"@opentelemetry/api": "^0.12.0",
"@opentelemetry/resources": "^0.12.0",
"@opentelemetry/tracing": "^0.12.0",
"@types/mocha": "7.0.2",
"@types/node": "12.12.51",
"@types/sinon": "9.0.4",
Expand All @@ -61,9 +61,9 @@
"grpc": "^1.24.3"
},
"peerDependencies": {
"@opentelemetry/api": "^0.11.0",
"@opentelemetry/core": "^0.11.0",
"@opentelemetry/resources": "^0.11.0",
"@opentelemetry/tracing": "^0.11.0"
"@opentelemetry/api": "^0.12.0",
"@opentelemetry/core": "^0.12.0",
"@opentelemetry/resources": "^0.12.0",
"@opentelemetry/tracing": "^0.12.0"
}
}
2 changes: 1 addition & 1 deletion packages/opentelemetry-cloud-trace-exporter/src/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class TraceExporter implements SpanExporter {
resultCallback(result);
}

shutdown(): void {}
async shutdown(): Promise<void> {}
aabmass marked this conversation as resolved.
Show resolved Hide resolved

/**
* Sends new spans to new or existing traces in the Google Cloud Trace format to the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ describe('transform', () => {
});

it('should drop unknown attribute types', () => {
// @ts-expect-error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test is asserting that unsupported attribute types (like object here) are dropped, but it creates a TS error since it is not allowed. In this case, we expect the TS error but want to validate the behavior too

readableSpan.attributes.testUnknownType = { message: 'dropped' };
const result = transformer(readableSpan);
assert.deepStrictEqual(result.attributes!.droppedAttributesCount, 1);
Expand Down Expand Up @@ -172,6 +173,7 @@ describe('transform', () => {
},
attributes: {
testAttr: 'value',
// @ts-expect-error
droppedAttr: {},
},
});
Expand Down Expand Up @@ -230,6 +232,7 @@ describe('transform', () => {
name: 'something happened',
attributes: {
error: true,
// @ts-expect-error
dropped: {},
},
time: [1566156729, 809],
Expand Down
24 changes: 12 additions & 12 deletions packages/opentelemetry-cloud-trace-propagator/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading