-
Notifications
You must be signed in to change notification settings - Fork 792
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: metrics API revision based on specs and rfcs
- Loading branch information
1 parent
50047b3
commit c4b2d10
Showing
9 changed files
with
304 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* Copyright 2019, OpenTelemetry Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { DistributedContext } from '../distributed_context/DistributedContext'; | ||
import { SpanContext } from '../trace/span_context'; | ||
|
||
export enum MeasureType { | ||
DOUBLE = 0, | ||
LONG = 1, | ||
} | ||
|
||
/** | ||
* Options needed for measure creation | ||
*/ | ||
export interface MeasureOptions { | ||
// Description of the Measure. | ||
description?: string; | ||
|
||
// Unit of the Measure. | ||
unit?: string; | ||
|
||
// Type of the Measure. Default type is DOUBLE. | ||
type?: MeasureType; | ||
} | ||
|
||
/** Measure to report instantaneous measurement of a value. */ | ||
export interface Measure { | ||
/** | ||
* Records the given value to this measure. | ||
* @param value the measurement to record. | ||
* @param distContext the distContext associated with the measurements. | ||
* @param spanContext the {@link SpanContext} that identifies the {@link Span} | ||
* for which the measurements are associated with. | ||
*/ | ||
record(value: number): void; | ||
record(value: number, distContext: DistributedContext): void; | ||
record( | ||
value: number, | ||
distContext: DistributedContext, | ||
spanContext: SpanContext | ||
): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* Copyright 2019, OpenTelemetry Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { Metric, MetricOptions } from './Metric'; | ||
import { CounterHandle, GaugeHandle } from './Handle'; | ||
import { MeasureOptions, Measure } from './Measure'; | ||
|
||
/** | ||
* An interface to allow the recording metrics. | ||
* | ||
* {@link Metric}s are used for recording pre-defined aggregation (Gauge and | ||
* Counter), or raw values ({@link Measure}) in which the aggregation and labels | ||
* for the exported metric are deferred. | ||
*/ | ||
export interface Meter { | ||
/** | ||
* Creates and returns a new {@link Measure}. | ||
* @param name the name of the metric. | ||
* @param [options] the measure options. | ||
*/ | ||
createMeasure(name: string, options?: MeasureOptions): Measure; | ||
|
||
/** | ||
* Creates a new counter metric. | ||
* @param name the name of the metric. | ||
* @param [options] the metric options. | ||
*/ | ||
createCounter(name: string, options?: MetricOptions): Metric<CounterHandle>; | ||
|
||
// TODO: Measurements can have a long or double type. However, it looks like | ||
// the metric timeseries API (according to spec) accepts values instead of | ||
// Measurements, meaning that if you accept a `number`, the type gets lost. | ||
// Both java and csharp have gone down the route of having two gauge interfaces, | ||
// GaugeDoubleTimeseries and GaugeLongTimeseries, with param for that type. It'd | ||
// be cool to only have a single interface, but maybe having two is necessary? | ||
// Maybe include the type as a metrics option? Probs a good gh issue, the same goes for Measure types. | ||
|
||
/** | ||
* Creates a new gauge metric. | ||
* @param name the name of the metric. | ||
* @param [options] the metric options. | ||
*/ | ||
createGauge(name: string, options?: MetricOptions): Metric<GaugeHandle>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/** | ||
* Copyright 2019, OpenTelemetry Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { Resource } from '../resources/Resource'; | ||
|
||
/** | ||
* Options needed for metric creation | ||
*/ | ||
export interface MetricOptions { | ||
/** The description of the Metric. */ | ||
description?: string; | ||
|
||
/** The unit of the Metric values. */ | ||
unit?: string; | ||
|
||
/** The list of label keys for the Metric. */ | ||
labelKeys?: string[]; | ||
|
||
/** The map of constant labels for the Metric. */ | ||
constantLabels?: Map<string, string>; | ||
|
||
/** The resource the Metric is associated with. */ | ||
resource?: Resource; | ||
|
||
/** The name of the component that reports the Metric. */ | ||
component?: string; | ||
} | ||
|
||
/** | ||
* Metric represents a base class for different types of metric | ||
* pre aggregations. | ||
*/ | ||
export interface Metric<T> { | ||
/** | ||
* Returns a Handle associated with specified label values. | ||
* It is recommended to keep a reference to the Handle instead of always | ||
* calling this method for every operations. | ||
* @param labelValues the list of label values. | ||
*/ | ||
getHandle(labelValues: string[]): T; | ||
|
||
/** | ||
* Returns a Handle for a metric with all labels not set. | ||
*/ | ||
getDefaultHandle(): T; | ||
|
||
/** | ||
* Removes the Handle from the metric, if it is present. | ||
* @param labelValues the list of label values. | ||
*/ | ||
removeHandle(labelValues: string[]): void; | ||
|
||
/** | ||
* Clears all timeseries from the Metric. | ||
*/ | ||
clear(): void; | ||
|
||
/** | ||
* what should the callback signature be? | ||
*/ | ||
setCallback(fn: () => void): void; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.