Skip to content
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
1 change: 1 addition & 0 deletions api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ fix(api): prioritize `esnext` export condition as it is more specific [#5458](ht

### :house: (Internal)

* refactor(api): refactor to avoid circular deps by merging observable types into `Metric.ts` [#6441](https://github.com/open-telemetry/opentelemetry-js/pull/6441) @pichlermarc
* refactor(api): remove "export *" in favor of explicit named exports [#4880](https://github.com/open-telemetry/opentelemetry-js/pull/4880) @robbkidd
* chore: enable tsconfig isolatedModules [#5697](https://github.com/open-telemetry/opentelemetry-js/pull/5697) @legendecas
* chore: disallow constructor parameter property syntax [#6187](https://github.com/open-telemetry/opentelemetry-js/pull/6187) @legendecas
Expand Down
4 changes: 2 additions & 2 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"clean": "tsc --build --clean tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
"compile": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
"lint:fix": "eslint . --ext .ts --fix",
"lint": "eslint . --ext .ts",
"lint": "eslint . --ext .ts && npm run cycle-check",
"test:browser": "karma start --single-run",
"test": "nyc mocha 'test/**/*.test.ts'",
"test:webworker": "karma start karma.worker.js --single-run",
Expand Down Expand Up @@ -72,7 +72,7 @@
"@types/webpack": "5.28.5",
"@types/webpack-env": "1.16.3",
"babel-plugin-istanbul": "7.0.1",
"dpdm": "3.13.1",
"dpdm": "4.0.1",
"karma": "6.4.4",
"karma-chrome-launcher": "3.1.0",
"karma-coverage": "2.2.1",
Expand Down
12 changes: 5 additions & 7 deletions api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,19 @@ export type {
Gauge,
Histogram,
MetricOptions,
UpDownCounter,
MetricAdvice,
MetricAttributes,
MetricAttributeValue,
Observable,
ObservableCounter,
ObservableGauge,
ObservableUpDownCounter,
UpDownCounter,
BatchObservableCallback,
MetricAdvice,
MetricAttributes,
MetricAttributeValue,
ObservableCallback,
} from './metrics/Metric';
export type {
BatchObservableResult,
ObservableResult,
} from './metrics/ObservableResult';
} from './metrics/Metric';
export type { MetricsAPI } from './api/metrics';

// Propagation APIs
Expand Down
47 changes: 46 additions & 1 deletion api/src/metrics/Metric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import { Attributes, AttributeValue } from '../common/Attributes';
import { Context } from '../context/types';
import { BatchObservableResult, ObservableResult } from './ObservableResult';

/**
* Advisory options influencing aggregation configuration parameters.
Expand Down Expand Up @@ -148,6 +147,52 @@ export type MetricAttributes = Attributes;
*/
export type MetricAttributeValue = AttributeValue;

/**
* Interface that is being used in callback function for Observable Metric.
*
* @since 1.3.0
*/
export interface ObservableResult<
AttributesTypes extends MetricAttributes = MetricAttributes,
> {
/**
* Observe a measurement of the value associated with the given attributes.
*
* @param value The value to be observed.
* @param attributes The attributes associated with the value. If more than
* one value is associated with the same attributes values, SDK may pick the
* last one or simply drop the entire observable result.
*/
observe(
this: ObservableResult<AttributesTypes>,
value: number,
attributes?: AttributesTypes
): void;
}

/**
* Interface that is being used in batch observable callback function.
*/
export interface BatchObservableResult<
AttributesTypes extends MetricAttributes = MetricAttributes,
> {
/**
* Observe a measurement of the value associated with the given attributes.
*
* @param metric The observable metric to be observed.
* @param value The value to be observed.
* @param attributes The attributes associated with the value. If more than
* one value is associated with the same attributes values, SDK may pick the
* last one or simply drop the entire observable result.
*/
observe(
this: BatchObservableResult<AttributesTypes>,
metric: Observable<AttributesTypes>,
value: number,
attributes?: AttributesTypes
): void;
}

/**
* The observable callback for Observable instruments.
*
Expand Down
63 changes: 0 additions & 63 deletions api/src/metrics/ObservableResult.ts

This file was deleted.

Loading