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

refactor(sdk-metrics) Swap workaround types for @otel/api types #5254

Merged
merged 1 commit into from
Dec 13, 2024
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
2 changes: 2 additions & 0 deletions CHANGELOG_NEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### :boom: Breaking Change

* feat(sdk-metrics)!: bump minimum version of `@opentelemetry/api` peer dependency to 1.9.0 [#5254](https://github.com/open-telemetry/opentelemetry-js/pull/5254) @chancancode
* chore(shim-opentracing): replace deprecated SpanAttributes [#4430](https://github.com/open-telemetry/opentelemetry-js/pull/4430) @JamieDanielson
* chore(otel-core): replace deprecated SpanAttributes [#4408](https://github.com/open-telemetry/opentelemetry-js/pull/4408) @JamieDanielson
* feat(sdk-metrics)!: remove MeterProvider.addMetricReader() in favor of constructor option [#4419](https://github.com/open-telemetry/opentelemetry-js/pull/4419) @pichlermarc
Expand All @@ -23,6 +24,7 @@

### :house: (Internal)

* refactor(sdk-metrics): remove `Gauge` and `MetricAdvice` workaround types in favor of the upstream `@opentelemetry/api` types [#5254](https://github.com/open-telemetry/opentelemetry-js/pull/5254) @chancancode
Copy link
Member

Choose a reason for hiding this comment

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

ah there still needs to be an entry to breaking as we drop support for old API versions 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, that's right, fixed!

* chore: remove checks for unsupported node versions [#4341](https://github.com/open-telemetry/opentelemetry-js/pull/4341) @dyladan
* refactor(sdk-trace-base): remove `BasicTracerProvider._registeredSpanProcessors` private property. [#5134](https://github.com/open-telemetry/opentelemetry-js/pull/5134) @david-luna
* refactor(sdk-trace-base): rename `BasicTracerProvider.activeSpanProcessor` private property. [#5211](https://github.com/open-telemetry/opentelemetry-js/pull/5211) @david-luna
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion packages/sdk-metrics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"webpack-merge": "5.10.0"
},
"peerDependencies": {
"@opentelemetry/api": ">=1.3.0 <1.10.0"
"@opentelemetry/api": ">=1.9.0 <1.10.0"
chancancode marked this conversation as resolved.
Show resolved Hide resolved
},
"dependencies": {
"@opentelemetry/core": "1.29.0",
Expand Down
20 changes: 9 additions & 11 deletions packages/sdk-metrics/src/InstrumentDescriptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
* limitations under the License.
*/

import { MetricOptions, ValueType, diag } from '@opentelemetry/api';
import {
MetricAdvice,
MetricOptions,
ValueType,
diag,
} from '@opentelemetry/api';
import { View } from './view/View';
import { equalsCaseInsensitive } from './utils';

Expand Down Expand Up @@ -44,18 +49,11 @@ export interface InstrumentDescriptor {
readonly type: InstrumentType;
readonly valueType: ValueType;
/**
* @experimental
* See {@link MetricAdvice}
*
* This is intentionally not using the API's type as it's only available from @opentelemetry/api 1.7.0 and up.
* In SDK 2.0 we'll be able to bump the minimum API version and remove this workaround.
* @experimental
Copy link
Contributor Author

@chancancode chancancode Dec 11, 2024

Choose a reason for hiding this comment

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

Kept the @experimental tag since the upstream type is itself @experimental. If it's not worth it I can also just remove the doc comment altogether.

FWIW, the entire InstrumentDescriptor interface is marked as @deprecated in sdk-metrics/index.ts in favor of MetricDescriptor, which does not have this field. But since @pichlermarc opened #5224 pretty recently, I assume the intention is to still keep this and carry it forward into 2.0.

Copy link
Member

Choose a reason for hiding this comment

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

Keeping it experimental is good - we'll bump it to stable in a separate issue. 👍

The InstrumentDescriptor is marked as deprecated as we will stop exporting it. Most properties will move to a MetricDescriptor and InstrumentDescriptor will extend it for internal use. Issue to follow.

*/
readonly advice: {
/**
* Hint the explicit bucket boundaries for SDK if the metric has been
* aggregated with a HistogramAggregator.
*/
explicitBucketBoundaries?: number[];
};
readonly advice: MetricAdvice;
}

export function createInstrumentDescriptor(
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-metrics/src/Instruments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
ValueType,
UpDownCounter,
Counter,
Gauge,
Histogram,
Observable,
ObservableCallback,
Expand All @@ -36,7 +37,6 @@ import {
AsyncWritableMetricStorage,
WritableMetricStorage,
} from './state/WritableMetricStorage';
import { Gauge } from './types';

export class SyncInstrument {
constructor(
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-metrics/src/Meter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import {
Meter as IMeter,
MetricOptions,
Gauge,
Histogram,
Counter,
UpDownCounter,
Expand All @@ -40,7 +41,6 @@ import {
UpDownCounterInstrument,
} from './Instruments';
import { MeterSharedState } from './state/MeterSharedState';
import { Gauge } from './types';

/**
* This class implements the {@link IMeter} interface.
Expand Down
12 changes: 0 additions & 12 deletions packages/sdk-metrics/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Context, Attributes } from '@opentelemetry/api';

export type CommonReaderOptions = {
timeoutMillis?: number;
Expand All @@ -24,14 +23,3 @@ export type CollectionOptions = CommonReaderOptions;
export type ShutdownOptions = CommonReaderOptions;

export type ForceFlushOptions = CommonReaderOptions;

/**
* This is intentionally not using the API's type as it's only available from @opentelemetry/api 1.9.0 and up.
* In SDK 2.0 we'll be able to bump the minimum API version and remove this workaround.
*/
export interface Gauge<AttributesTypes extends Attributes = Attributes> {
/**
* Records a measurement. Value of the measurement must not be negative.
*/
record(value: number, attributes?: AttributesTypes, context?: Context): void;
}
Loading