Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into ritm-absolute
Browse files Browse the repository at this point in the history
  • Loading branch information
mhassan1 committed Dec 5, 2022
2 parents 64b9bb8 + 91f94a8 commit a8e857d
Show file tree
Hide file tree
Showing 321 changed files with 7,704 additions and 4,737 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/
### :house: (Internal)

* chore: automatically generate tsconfigs [#3432](https://github.com/open-telemetry/opentelemetry-js/pull/3432) @legendecas
* chore: enforce format with prettier [#3444](https://github.com/open-telemetry/opentelemetry-js/pull/3444) @legendecas

## 1.8.0

Expand Down
7 changes: 5 additions & 2 deletions api/src/api/diag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class DiagAPI implements DiagLogger, DiagLoggerApi {

const setLogger: DiagLoggerApi['setLogger'] = (
logger,
optionsOrLogLevel = { logLevel: DiagLogLevel.INFO },
optionsOrLogLevel = { logLevel: DiagLogLevel.INFO }
) => {
if (logger === self) {
// There isn't much we can do here.
Expand All @@ -88,7 +88,10 @@ export class DiagAPI implements DiagLogger, DiagLoggerApi {
}

const oldLogger = getGlobal('diag');
const newLogger = createLogLevelDiagLogger(optionsOrLogLevel.logLevel ?? DiagLogLevel.INFO, logger);
const newLogger = createLogLevelDiagLogger(
optionsOrLogLevel.logLevel ?? DiagLogLevel.INFO,
logger
);
// There already is an logger registered. We'll let it know before overwriting it.
if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
const stack = new Error().stack ?? '<failed to generate stacktrace>';
Expand Down
12 changes: 10 additions & 2 deletions api/src/api/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
import { Meter, MeterOptions } from '../metrics/Meter';
import { MeterProvider } from '../metrics/MeterProvider';
import { NOOP_METER_PROVIDER } from '../metrics/NoopMeterProvider';
import { getGlobal, registerGlobal, unregisterGlobal } from '../internal/global-utils';
import {
getGlobal,
registerGlobal,
unregisterGlobal,
} from '../internal/global-utils';
import { DiagAPI } from './diag';

const API_NAME = 'metrics';
Expand Down Expand Up @@ -58,7 +62,11 @@ export class MetricsAPI {
/**
* Returns a meter from the global meter provider.
*/
public getMeter(name: string, version?: string, options?: MeterOptions): Meter {
public getMeter(
name: string,
version?: string,
options?: MeterOptions
): Meter {
return this.getMeterProvider().getMeter(name, version, options);
}

Expand Down
14 changes: 7 additions & 7 deletions api/src/common/Attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* Note: only the own enumerable keys are counted as valid attribute keys.
*/
export interface Attributes {
[attributeKey: string]: AttributeValue | undefined;
[attributeKey: string]: AttributeValue | undefined;
}

/**
Expand All @@ -29,9 +29,9 @@ export interface Attributes {
* null or undefined attribute values are invalid and will result in undefined behavior.
*/
export type AttributeValue =
| string
| number
| boolean
| Array<null | undefined | string>
| Array<null | undefined | number>
| Array<null | undefined | boolean>;
| string
| number
| boolean
| Array<null | undefined | string>
| Array<null | undefined | number>
| Array<null | undefined | boolean>;
14 changes: 7 additions & 7 deletions api/src/diag/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ export interface LoggerOptions {

export interface DiagLoggerApi {
/**
* Set the global DiagLogger and DiagLogLevel.
* If a global diag logger is already set, this will override it.
*
* @param logger - The {@link DiagLogger} instance to set as the default logger.
* @param options - A {@link LoggerOptions} object. If not provided, default values will be set.
* @returns `true` if the logger was successfully registered, else `false`
*/
* Set the global DiagLogger and DiagLogLevel.
* If a global diag logger is already set, this will override it.
*
* @param logger - The {@link DiagLogger} instance to set as the default logger.
* @param options - A {@link LoggerOptions} object. If not provided, default values will be set.
* @returns `true` if the logger was successfully registered, else `false`
*/
setLogger(logger: DiagLogger, options?: LoggerOptions): boolean;

/**
Expand Down
42 changes: 8 additions & 34 deletions api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,15 @@
* limitations under the License.
*/

export {
BaggageEntry,
BaggageEntryMetadata,
Baggage,
} from './baggage/types';
export { BaggageEntry, BaggageEntryMetadata, Baggage } from './baggage/types';
export { baggageEntryMetadataFromString } from './baggage/utils';
export { Exception } from './common/Exception';
export { HrTime, TimeInput } from './common/Time';
export { Attributes, AttributeValue } from './common/Attributes';

// Context APIs
export {
createContextKey,
ROOT_CONTEXT,
} from './context/context';
export {
Context,
ContextManager,
} from './context/types';
export { createContextKey, ROOT_CONTEXT } from './context/context';
export { Context, ContextManager } from './context/types';
export type { ContextAPI } from './api/context';

// Diag APIs
Expand All @@ -46,16 +36,9 @@ export {
export type { DiagAPI } from './api/diag';

// Metrics APIs
export {
createNoopMeter,
} from './metrics/NoopMeter';
export {
MeterOptions,
Meter,
} from './metrics/Meter';
export {
MeterProvider,
} from './metrics/MeterProvider';
export { createNoopMeter } from './metrics/NoopMeter';
export { MeterOptions, Meter } from './metrics/Meter';
export { MeterProvider } from './metrics/MeterProvider';
export {
ValueType,
Counter,
Expand Down Expand Up @@ -87,10 +70,7 @@ export {
export type { PropagationAPI } from './api/propagation';

// Trace APIs
export {
SpanAttributes,
SpanAttributeValue,
} from './trace/attributes';
export { SpanAttributes, SpanAttributeValue } from './trace/attributes';
export { Link } from './trace/link';
export { ProxyTracer, TracerDelegator } from './trace/ProxyTracer';
export { ProxyTracerProvider } from './trace/ProxyTracerProvider';
Expand Down Expand Up @@ -128,13 +108,7 @@ import { propagation } from './propagation-api';
import { trace } from './trace-api';

// Named export.
export {
context,
diag,
metrics,
propagation,
trace,
};
export { context, diag, metrics, propagation, trace };
// Default export.
export default {
context,
Expand Down
27 changes: 21 additions & 6 deletions api/src/metrics/Meter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ export interface Meter {
* @param name the name of the metric.
* @param [options] the metric options.
*/
createUpDownCounter<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): UpDownCounter<AttributesTypes>;
createUpDownCounter<
AttributesTypes extends MetricAttributes = MetricAttributes
>(
name: string,
options?: MetricOptions
): UpDownCounter<AttributesTypes>;

/**
* Creates a new `ObservableGauge` metric.
Expand All @@ -94,7 +99,9 @@ export interface Meter {
* @param name the name of the metric.
* @param [options] the metric options.
*/
createObservableGauge<AttributesTypes extends MetricAttributes = MetricAttributes>(
createObservableGauge<
AttributesTypes extends MetricAttributes = MetricAttributes
>(
name: string,
options?: MetricOptions
): ObservableGauge<AttributesTypes>;
Expand All @@ -107,7 +114,9 @@ export interface Meter {
* @param name the name of the metric.
* @param [options] the metric options.
*/
createObservableCounter<AttributesTypes extends MetricAttributes = MetricAttributes>(
createObservableCounter<
AttributesTypes extends MetricAttributes = MetricAttributes
>(
name: string,
options?: MetricOptions
): ObservableCounter<AttributesTypes>;
Expand All @@ -120,7 +129,9 @@ export interface Meter {
* @param name the name of the metric.
* @param [options] the metric options.
*/
createObservableUpDownCounter<AttributesTypes extends MetricAttributes = MetricAttributes>(
createObservableUpDownCounter<
AttributesTypes extends MetricAttributes = MetricAttributes
>(
name: string,
options?: MetricOptions
): ObservableUpDownCounter<AttributesTypes>;
Expand All @@ -139,7 +150,9 @@ export interface Meter {
* @param callback the batch observable callback
* @param observables the observables associated with this batch observable callback
*/
addBatchObservableCallback<AttributesTypes extends MetricAttributes = MetricAttributes>(
addBatchObservableCallback<
AttributesTypes extends MetricAttributes = MetricAttributes
>(
callback: BatchObservableCallback<AttributesTypes>,
observables: Observable<AttributesTypes>[]
): void;
Expand All @@ -153,7 +166,9 @@ export interface Meter {
* @param callback the batch observable callback
* @param observables the observables associated with this batch observable callback
*/
removeBatchObservableCallback<AttributesTypes extends MetricAttributes = MetricAttributes>(
removeBatchObservableCallback<
AttributesTypes extends MetricAttributes = MetricAttributes
>(
callback: BatchObservableCallback<AttributesTypes>,
observables: Observable<AttributesTypes>[]
): void;
Expand Down
42 changes: 31 additions & 11 deletions api/src/metrics/Metric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,27 @@ export enum ValueType {
* <li> count the number of 5xx errors. </li>
* <ol>
*/
export interface Counter<AttributesTypes extends MetricAttributes = MetricAttributes> {
export interface Counter<
AttributesTypes extends MetricAttributes = MetricAttributes
> {
/**
* Increment value of counter by the input. Inputs must not be negative.
*/
add(value: number, attributes?: AttributesTypes, context?: Context): void;
}

export interface UpDownCounter<AttributesTypes extends MetricAttributes = MetricAttributes> {
export interface UpDownCounter<
AttributesTypes extends MetricAttributes = MetricAttributes
> {
/**
* Increment value of counter by the input. Inputs may be negative.
*/
add(value: number, attributes?: AttributesTypes, context?: Context): void;
}

export interface Histogram<AttributesTypes extends MetricAttributes = MetricAttributes> {
export interface Histogram<
AttributesTypes extends MetricAttributes = MetricAttributes
> {
/**
* Records a measurement. Value of the measurement must not be negative.
*/
Expand All @@ -96,16 +102,24 @@ export type MetricAttributeValue = AttributeValue;
/**
* The observable callback for Observable instruments.
*/
export type ObservableCallback<AttributesTypes extends MetricAttributes = MetricAttributes> =
(observableResult: ObservableResult<AttributesTypes>) => void | Promise<void>;
export type ObservableCallback<
AttributesTypes extends MetricAttributes = MetricAttributes
> = (
observableResult: ObservableResult<AttributesTypes>
) => void | Promise<void>;

/**
* The observable callback for a batch of Observable instruments.
*/
export type BatchObservableCallback<AttributesTypes extends MetricAttributes = MetricAttributes> =
(observableResult: BatchObservableResult<AttributesTypes>) => void | Promise<void>;
export type BatchObservableCallback<
AttributesTypes extends MetricAttributes = MetricAttributes
> = (
observableResult: BatchObservableResult<AttributesTypes>
) => void | Promise<void>;

export interface Observable<AttributesTypes extends MetricAttributes = MetricAttributes> {
export interface Observable<
AttributesTypes extends MetricAttributes = MetricAttributes
> {
/**
* Sets up a function that will be called whenever a metric collection is initiated.
*
Expand All @@ -119,6 +133,12 @@ export interface Observable<AttributesTypes extends MetricAttributes = MetricAtt
removeCallback(callback: ObservableCallback<AttributesTypes>): void;
}

export type ObservableCounter<AttributesTypes extends MetricAttributes=MetricAttributes> = Observable<AttributesTypes>;
export type ObservableUpDownCounter<AttributesTypes extends MetricAttributes=MetricAttributes> = Observable<AttributesTypes>;
export type ObservableGauge<AttributesTypes extends MetricAttributes=MetricAttributes> = Observable<AttributesTypes>;
export type ObservableCounter<
AttributesTypes extends MetricAttributes = MetricAttributes
> = Observable<AttributesTypes>;
export type ObservableUpDownCounter<
AttributesTypes extends MetricAttributes = MetricAttributes
> = Observable<AttributesTypes>;
export type ObservableGauge<
AttributesTypes extends MetricAttributes = MetricAttributes
> = Observable<AttributesTypes>;
Loading

0 comments on commit a8e857d

Please sign in to comment.