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

feat: use GA version of metrics #1281

Merged
merged 5 commits into from
Nov 16, 2022
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
8 changes: 3 additions & 5 deletions packages/opentelemetry-host-metrics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
"access": "public"
},
"peerDependencies": {
"@opentelemetry/api": "^1.0.0"
"@opentelemetry/api": "^1.3.0"
},
"devDependencies": {
"@opentelemetry/api": "^1.0.0",
"@opentelemetry/api": "^1.3.0",
"@types/mocha": "8.2.3",
"@types/node": "18.11.7",
"@types/sinon": "10.0.2",
Expand All @@ -59,9 +59,7 @@
"typescript": "4.3.5"
},
"dependencies": {
"@opentelemetry/api-metrics": "^0.32.0",
"@opentelemetry/core": "^1.0.0",
"@opentelemetry/sdk-metrics": "^0.32.0",
"@opentelemetry/sdk-metrics": "^1.8.0",
"systeminformation": "^5.0.0"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/opentelemetry-host-metrics#readme"
Expand Down
5 changes: 2 additions & 3 deletions packages/opentelemetry-host-metrics/src/BaseMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

import * as api from '@opentelemetry/api';
import * as apiMetrics from '@opentelemetry/api-metrics';
import * as metrics from '@opentelemetry/sdk-metrics';

import { VERSION } from './version';
Expand Down Expand Up @@ -45,15 +44,15 @@ const DEFAULT_NAME = 'opentelemetry-host-metrics';
export abstract class BaseMetrics {
protected _logger = api.diag;
protected _maxTimeoutUpdateMS: number;
protected _meter: apiMetrics.Meter;
protected _meter: api.Meter;
private _name: string;

constructor(config: MetricsCollectorConfig) {
this._name = config.name || DEFAULT_NAME;
this._maxTimeoutUpdateMS =
config.maxTimeoutUpdateMS || DEFAULT_MAX_TIMEOUT_UPDATE_MS;
const meterProvider =
config.meterProvider! || apiMetrics.metrics.getMeterProvider();
config.meterProvider! || api.metrics.getMeterProvider();
if (!config.meterProvider) {
this._logger.warn('No meter provider, using default');
}
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-host-metrics/src/metric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { BaseMetrics } from './BaseMetrics';
import * as api from '@opentelemetry/api-metrics';
import * as api from '@opentelemetry/api';
import * as enums from './enum';

import { getCpuUsageData, getMemoryData } from './stats/common';
Expand Down
8 changes: 4 additions & 4 deletions packages/opentelemetry-host-metrics/test/metric.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

const SI = require('systeminformation');
import { MetricAttributes } from '@opentelemetry/api-metrics';
import { Attributes } from '@opentelemetry/api';
import {
AggregationTemporality,
DataPoint,
Expand All @@ -33,7 +33,7 @@ const cpuJson = require('./mocks/cpu.json');
const networkJson = require('./mocks/network.json');

class TestMetricReader extends MetricReader {
public selectAggregationTemporality(): AggregationTemporality {
public override selectAggregationTemporality(): AggregationTemporality {
return AggregationTemporality.CUMULATIVE;
}
protected async onForceFlush(): Promise<void> {}
Expand Down Expand Up @@ -231,7 +231,7 @@ async function getRecords(

function ensureValue(
metric: MetricData,
attributes: MetricAttributes,
attributes: Attributes,
value: number
) {
const attrHash = hashAttributes(attributes);
Expand All @@ -247,7 +247,7 @@ function ensureValue(
assert.strictEqual(aggValue, value);
}

function hashAttributes(attributes: MetricAttributes) {
function hashAttributes(attributes: Attributes) {
return Object.entries(attributes)
.sort(([a], [b]) => {
return a < b ? -1 : 1;
Expand Down
9 changes: 8 additions & 1 deletion renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@
},
{
"groupName": "Otel Core experimental",
"matchPackageNames": ["@opentelemetry/sdk-node", "@opentelemetry/instrumentation", "@opentelemetry/instrumentation-grpc", "@opentelemetry/instrumentation-http", "@opentelemetry/instrumentation-fetch", "@opentelemetry/instrumentation-xml-http-request", "@opentelemetry/api-metrics", "@opentelemetry/sdk-metrics" ],
"matchPackageNames": [
"@opentelemetry/instrumentation",
"@opentelemetry/instrumentation-grpc",
"@opentelemetry/instrumentation-http",
"@opentelemetry/instrumentation-fetch",
"@opentelemetry/instrumentation-xml-http-request",
"@opentelemetry/sdk-node"
],
"rangeStrategy": "bump"
}
],
Expand Down