Skip to content

Commit

Permalink
chore: upgrade for opentelemtry js v0.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
aabmass committed Oct 28, 2020
1 parent 48898d5 commit 8b42fd6
Show file tree
Hide file tree
Showing 15 changed files with 183 additions and 205 deletions.
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> {}

/**
* 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> {}

/**
* 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
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

0 comments on commit 8b42fd6

Please sign in to comment.