@opentelemetry/api 0.5.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -60,7 +60,7 @@ tracerProvider.addSpanProcessor(
60
60
  * Registering the provider with the API allows it to be discovered
61
61
  * and used by instrumentation libraries. The OpenTelemetry API provides
62
62
  * methods to set global SDK implementations, but the default SDK provides
63
- * a convenience method named `register` which registers sane defaults
63
+ * a convenience method named `register` which registers same defaults
64
64
  * for you.
65
65
  *
66
66
  * By default the NodeTracerProvider uses Trace Context for propagation
@@ -46,5 +46,5 @@ export interface BoundObserver {
46
46
  * retrieve the value.
47
47
  * @param callback
48
48
  */
49
- setCallback(callback: (observerResult: ObserverResult) => {}): void;
49
+ setCallback(callback: (observerResult: ObserverResult) => void): void;
50
50
  }
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { Metric, MetricOptions, Labels, LabelSet } from './Metric';
16
+ import { Metric, MetricOptions } from './Metric';
17
17
  import { BoundCounter, BoundMeasure, BoundObserver } from './BoundInstrument';
18
18
  /**
19
19
  * An interface to allow the recording metrics.
@@ -43,11 +43,4 @@ export interface Meter {
43
43
  * @param [options] the metric options.
44
44
  */
45
45
  createObserver(name: string, options?: MetricOptions): Metric<BoundObserver>;
46
- /**
47
- * Provide a pre-computed re-useable LabelSet by
48
- * converting the unordered labels into a canonicalized
49
- * set of labels with an unique identifier, useful for pre-aggregation.
50
- * @param labels user provided unordered Labels.
51
- */
52
- labels(labels: Labels): LabelSet;
53
46
  }
@@ -67,19 +67,18 @@ export declare enum ValueType {
67
67
  */
68
68
  export interface Metric<T> {
69
69
  /**
70
- * Returns a Instrument associated with specified LabelSet.
70
+ * Returns a Instrument associated with specified Labels.
71
71
  * It is recommended to keep a reference to the Instrument instead of always
72
72
  * calling this method for every operations.
73
- * @param labels the canonicalized LabelSet used to associate with this
74
- * metric instrument.
73
+ * @param labels key-values pairs that are associated with a specific metric
74
+ * that you want to record.
75
75
  */
76
- bind(labels: LabelSet): T;
76
+ bind(labels: Labels): T;
77
77
  /**
78
78
  * Removes the Instrument from the metric, if it is present.
79
- * @param labels the canonicalized LabelSet used to associate with this
80
- * metric instrument.
79
+ * @param labels key-values pairs that are associated with a specific metric.
81
80
  */
82
- unbind(labels: LabelSet): void;
81
+ unbind(labels: Labels): void;
83
82
  /**
84
83
  * Clears all timeseries from the Metric.
85
84
  */
@@ -89,7 +88,7 @@ export interface MetricUtils {
89
88
  /**
90
89
  * Adds the given value to the current value. Values cannot be negative.
91
90
  */
92
- add(value: number, labelSet: LabelSet): void;
91
+ add(value: number, labels: Labels): void;
93
92
  /**
94
93
  * Sets a callback where user can observe value for certain labels
95
94
  * @param callback a function that will be called once to set observers
@@ -99,22 +98,17 @@ export interface MetricUtils {
99
98
  /**
100
99
  * Sets the given value. Values can be negative.
101
100
  */
102
- set(value: number, labelSet: LabelSet): void;
101
+ set(value: number, labels: Labels): void;
103
102
  /**
104
103
  * Records the given value to this measure.
105
104
  */
106
- record(value: number, labelSet: LabelSet): void;
107
- record(value: number, labelSet: LabelSet, correlationContext: CorrelationContext): void;
108
- record(value: number, labelSet: LabelSet, correlationContext: CorrelationContext, spanContext: SpanContext): void;
105
+ record(value: number, labels: Labels): void;
106
+ record(value: number, labels: Labels, correlationContext: CorrelationContext): void;
107
+ record(value: number, labels: Labels, correlationContext: CorrelationContext, spanContext: SpanContext): void;
109
108
  }
110
109
  /**
111
110
  * key-value pairs passed by the user.
112
111
  */
113
- export declare type Labels = Record<string, string>;
114
- /**
115
- * Canonicalized labels with an unique string identifier.
116
- */
117
- export interface LabelSet {
118
- identifier: string;
119
- labels: Labels;
120
- }
112
+ export declare type Labels = {
113
+ [key: string]: string;
114
+ };
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { Meter } from './Meter';
17
- import { MetricOptions, Metric, Labels, LabelSet, MetricUtils } from './Metric';
17
+ import { MetricOptions, Metric, Labels, MetricUtils } from './Metric';
18
18
  import { BoundMeasure, BoundCounter, BoundObserver } from './BoundInstrument';
19
19
  import { CorrelationContext } from '../correlation_context/CorrelationContext';
20
20
  import { SpanContext } from '../trace/span_context';
@@ -43,40 +43,33 @@ export declare class NoopMeter implements Meter {
43
43
  * @param [options] the metric options.
44
44
  */
45
45
  createObserver(name: string, options?: MetricOptions): Metric<BoundObserver>;
46
- labels(labels: Labels): LabelSet;
47
46
  }
48
47
  export declare class NoopMetric<T> implements Metric<T> {
49
48
  private readonly _instrument;
50
49
  constructor(instrument: T);
51
50
  /**
52
- * Returns a Bound Instrument associated with specified LabelSet.
51
+ * Returns a Bound Instrument associated with specified Labels.
53
52
  * It is recommended to keep a reference to the Bound Instrument instead of
54
53
  * always calling this method for every operations.
55
- * @param labels the canonicalized LabelSet used to associate with this
56
- * metric instrument.
54
+ * @param labels key-values pairs that are associated with a specific metric
55
+ * that you want to record.
57
56
  */
58
- bind(labels: LabelSet): T;
59
- /**
60
- * Returns a Bound Instrument for a metric with all labels not set.
61
- */
62
- getDefaultBound(): T;
57
+ bind(labels: Labels): T;
63
58
  /**
64
59
  * Removes the Binding from the metric, if it is present.
65
- * @param labels the canonicalized LabelSet used to associate with this
66
- * metric instrument.
60
+ * @param labels key-values pairs that are associated with a specific metric.
67
61
  */
68
- unbind(labels: LabelSet): void;
62
+ unbind(labels: Labels): void;
69
63
  /**
70
64
  * Clears all timeseries from the Metric.
71
65
  */
72
66
  clear(): void;
73
- setCallback(fn: () => void): void;
74
67
  }
75
68
  export declare class NoopCounterMetric extends NoopMetric<BoundCounter> implements Pick<MetricUtils, 'add'> {
76
- add(value: number, labelSet: LabelSet): void;
69
+ add(value: number, labels: Labels): void;
77
70
  }
78
71
  export declare class NoopMeasureMetric extends NoopMetric<BoundMeasure> implements Pick<MetricUtils, 'record'> {
79
- record(value: number, labelSet: LabelSet, correlationContext?: CorrelationContext, spanContext?: SpanContext): void;
72
+ record(value: number, labels: Labels, correlationContext?: CorrelationContext, spanContext?: SpanContext): void;
80
73
  }
81
74
  export declare class NoopObserverMetric extends NoopMetric<BoundObserver> implements Pick<MetricUtils, 'setCallback'> {
82
75
  setCallback(callback: (observerResult: ObserverResult) => void): void;
@@ -88,7 +81,7 @@ export declare class NoopBoundMeasure implements BoundMeasure {
88
81
  record(value: number, correlationContext?: CorrelationContext, spanContext?: SpanContext): void;
89
82
  }
90
83
  export declare class NoopBoundObserver implements BoundObserver {
91
- setCallback(callback: (observerResult: ObserverResult) => {}): void;
84
+ setCallback(callback: (observerResult: ObserverResult) => void): void;
92
85
  }
93
86
  export declare const NOOP_METER: NoopMeter;
94
87
  export declare const NOOP_BOUND_COUNTER: NoopBoundCounter;
@@ -97,4 +90,3 @@ export declare const NOOP_BOUND_MEASURE: NoopBoundMeasure;
97
90
  export declare const NOOP_MEASURE_METRIC: NoopMeasureMetric;
98
91
  export declare const NOOP_BOUND_OBSERVER: NoopBoundObserver;
99
92
  export declare const NOOP_OBSERVER_METRIC: NoopObserverMetric;
100
- export declare const NOOP_LABEL_SET: LabelSet;
@@ -45,9 +45,6 @@ class NoopMeter {
45
45
  createObserver(name, options) {
46
46
  return exports.NOOP_OBSERVER_METRIC;
47
47
  }
48
- labels(labels) {
49
- return exports.NOOP_LABEL_SET;
50
- }
51
48
  }
52
49
  exports.NoopMeter = NoopMeter;
53
50
  class NoopMetric {
@@ -55,25 +52,18 @@ class NoopMetric {
55
52
  this._instrument = instrument;
56
53
  }
57
54
  /**
58
- * Returns a Bound Instrument associated with specified LabelSet.
55
+ * Returns a Bound Instrument associated with specified Labels.
59
56
  * It is recommended to keep a reference to the Bound Instrument instead of
60
57
  * always calling this method for every operations.
61
- * @param labels the canonicalized LabelSet used to associate with this
62
- * metric instrument.
58
+ * @param labels key-values pairs that are associated with a specific metric
59
+ * that you want to record.
63
60
  */
64
61
  bind(labels) {
65
62
  return this._instrument;
66
63
  }
67
- /**
68
- * Returns a Bound Instrument for a metric with all labels not set.
69
- */
70
- getDefaultBound() {
71
- return this._instrument;
72
- }
73
64
  /**
74
65
  * Removes the Binding from the metric, if it is present.
75
- * @param labels the canonicalized LabelSet used to associate with this
76
- * metric instrument.
66
+ * @param labels key-values pairs that are associated with a specific metric.
77
67
  */
78
68
  unbind(labels) {
79
69
  return;
@@ -84,27 +74,24 @@ class NoopMetric {
84
74
  clear() {
85
75
  return;
86
76
  }
87
- setCallback(fn) {
88
- return;
89
- }
90
77
  }
91
78
  exports.NoopMetric = NoopMetric;
92
79
  class NoopCounterMetric extends NoopMetric {
93
- add(value, labelSet) {
94
- this.bind(labelSet).add(value);
80
+ add(value, labels) {
81
+ this.bind(labels).add(value);
95
82
  }
96
83
  }
97
84
  exports.NoopCounterMetric = NoopCounterMetric;
98
85
  class NoopMeasureMetric extends NoopMetric {
99
- record(value, labelSet, correlationContext, spanContext) {
86
+ record(value, labels, correlationContext, spanContext) {
100
87
  if (typeof correlationContext === 'undefined') {
101
- this.bind(labelSet).record(value);
88
+ this.bind(labels).record(value);
102
89
  }
103
90
  else if (typeof spanContext === 'undefined') {
104
- this.bind(labelSet).record(value, correlationContext);
91
+ this.bind(labels).record(value, correlationContext);
105
92
  }
106
93
  else {
107
- this.bind(labelSet).record(value, correlationContext, spanContext);
94
+ this.bind(labels).record(value, correlationContext, spanContext);
108
95
  }
109
96
  }
110
97
  }
@@ -136,5 +123,4 @@ exports.NOOP_BOUND_MEASURE = new NoopBoundMeasure();
136
123
  exports.NOOP_MEASURE_METRIC = new NoopMeasureMetric(exports.NOOP_BOUND_MEASURE);
137
124
  exports.NOOP_BOUND_OBSERVER = new NoopBoundObserver();
138
125
  exports.NOOP_OBSERVER_METRIC = new NoopObserverMetric(exports.NOOP_BOUND_OBSERVER);
139
- exports.NOOP_LABEL_SET = {};
140
126
  //# sourceMappingURL=NoopMeter.js.map
@@ -13,11 +13,11 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { LabelSet } from './Metric';
16
+ import { Labels } from './Metric';
17
17
  /**
18
18
  * Interface that is being used in function setCallback for Observer Metric
19
19
  */
20
20
  export interface ObserverResult {
21
- observers: Map<LabelSet, Function>;
22
- observe(callback: Function, labelSet: LabelSet): void;
21
+ observers: Map<Labels, Function>;
22
+ observe(callback: Function, labels: Labels): void;
23
23
  }
@@ -39,6 +39,9 @@ export interface SpanOptions {
39
39
  * A parent `SpanContext` (or `Span`, for convenience) that the newly-started
40
40
  * span will be the child of. This overrides the parent span extracted from
41
41
  * the currently active context.
42
+ *
43
+ * A null value here should prevent the SDK from extracting a parent from
44
+ * the current context, forcing the new span to be a root span.
42
45
  */
43
46
  parent?: Span | SpanContext | null;
44
47
  /** A manually specified start time for the created `Span` object. */
@@ -13,4 +13,4 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export declare const VERSION = "0.5.0";
16
+ export declare const VERSION = "0.6.1";
@@ -16,5 +16,5 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  // this is autogenerated file, see scripts/version-update.js
19
- exports.VERSION = '0.5.0';
19
+ exports.VERSION = '0.6.1';
20
20
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentelemetry/api",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "description": "Public API for OpenTelemetry",
5
5
  "main": "build/src/index.js",
6
6
  "types": "build/src/index.d.ts",
@@ -47,10 +47,10 @@
47
47
  "access": "public"
48
48
  },
49
49
  "dependencies": {
50
- "@opentelemetry/context-base": "^0.5.0"
50
+ "@opentelemetry/context-base": "^0.6.1"
51
51
  },
52
52
  "devDependencies": {
53
- "@types/mocha": "^5.2.7",
53
+ "@types/mocha": "^7.0.0",
54
54
  "@types/node": "^12.6.8",
55
55
  "@types/webpack-env": "1.13.9",
56
56
  "codecov": "^3.6.1",
@@ -64,7 +64,7 @@
64
64
  "karma-webpack": "^4.0.2",
65
65
  "linkinator": "^2.0.3",
66
66
  "mocha": "^6.1.0",
67
- "nyc": "^14.1.1",
67
+ "nyc": "^15.0.0",
68
68
  "ts-loader": "^6.0.4",
69
69
  "ts-mocha": "^6.0.0",
70
70
  "tslint-consistent-codestyle": "^1.16.0",
@@ -1,56 +0,0 @@
1
- /*!
2
- * Copyright 2019, OpenTelemetry Authors
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * https://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import { Context } from '@opentelemetry/scope-base';
17
- import { SetterFunction } from './setter';
18
- import { GetterFunction } from './getter';
19
- /**
20
- * Injects {@link Context} into and extracts it from carriers that travel
21
- * in-band across process boundaries. Encoding is expected to conform to the
22
- * HTTP Header Field semantics. Values are often encoded as RPC/HTTP request
23
- * headers.
24
- *
25
- * The carrier of propagated data on both the client (injector) and server
26
- * (extractor) side is usually an object such as http headers.
27
- */
28
- export interface HttpTextFormat {
29
- /**
30
- * Injects values from a given {@link Context} into a carrier.
31
- *
32
- * OpenTelemetry defines a common set of format values (HTTPTextFormat), and
33
- * each has an expected `carrier` type.
34
- *
35
- * @param context the Context from which to extract values to transmit over
36
- * the wire.
37
- * @param carrier the carrier of propagation fields, such as http request
38
- * headers.
39
- * @param setter a function which accepts a carrier, key, and value, which
40
- * sets the key on the carrier to the value.
41
- */
42
- inject(context: Context, carrier: unknown, setter: SetterFunction): void;
43
- /**
44
- * Given a {@link Context} and a carrier, extract context values from a
45
- * carrier and return a new context, created from the old context, with the
46
- * extracted values.
47
- *
48
- * @param context the Context from which to extract values to transmit over
49
- * the wire.
50
- * @param carrier the carrier of propagation fields, such as http request
51
- * headers.
52
- * @param getter a function which accepts a carrier and a key, and returns
53
- * the value from the carrier identified by the key.
54
- */
55
- extract(context: Context, carrier: unknown, getter: GetterFunction): Context;
56
- }
@@ -1,18 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright 2019, OpenTelemetry Authors
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * https://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- //# sourceMappingURL=HttpTextFormat.js.map
@@ -1,27 +0,0 @@
1
- /*!
2
- * Copyright 2019, OpenTelemetry Authors
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * https://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import { Context } from '@opentelemetry/scope-base';
17
- import { HttpTextFormat } from './HttpTextFormat';
18
- /**
19
- * No-op implementations of {@link HttpTextFormat}.
20
- */
21
- export declare class NoopHttpTextFormat implements HttpTextFormat {
22
- /** Noop inject function does nothing */
23
- inject(context: Context, carrier: unknown, setter: Function): void;
24
- /** Noop extract function does nothing and returns the input context */
25
- extract(context: Context, carrier: unknown, getter: Function): Context;
26
- }
27
- export declare const NOOP_HTTP_TEXT_FORMAT: NoopHttpTextFormat;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright 2019, OpenTelemetry Authors
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * https://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- /**
19
- * No-op implementations of {@link HttpTextFormat}.
20
- */
21
- class NoopHttpTextFormat {
22
- /** Noop inject function does nothing */
23
- inject(context, carrier, setter) { }
24
- /** Noop extract function does nothing and returns the input context */
25
- extract(context, carrier, getter) {
26
- return context;
27
- }
28
- }
29
- exports.NoopHttpTextFormat = NoopHttpTextFormat;
30
- exports.NOOP_HTTP_TEXT_FORMAT = new NoopHttpTextFormat();
31
- //# sourceMappingURL=NoopHttpTextFormat.js.map