Skip to content

Commit 16b3fd3

Browse files
author
Nacho Bonafonte
committed
Comment out temporarily deprecated classes and methods, and mark them as phase 2
1 parent 46fbf23 commit 16b3fd3

File tree

8 files changed

+61
-25
lines changed

8 files changed

+61
-25
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
### Stable metrics
2+
3+
Stable metrics is the working name for the otel-swift implementation of the current OpenTelemetry metrics specification.
4+
The existing otel-swift metric implementation is old and out-of-spec. While Stable Metrics is in an experimental phase it will maintaion
5+
the "stable" prefix, and can be expected to be present on overlapping constructs in the implementation.
6+
Expected time line will be as follows:
7+
Phase 1:
8+
Provide access to Stable Metrics along side existing Metrics. Once Stable Metrics are considered stable we will move onto phase 2.
9+
Phase 2:
10+
Mark all existing Metric APIs as deprecated. This will maintained for a period TBD
11+
Phase 3:
12+
Remove deprecated metrics api and remove Stable prefix from Stable metrics.

Sources/OpenTelemetryApi/Metrics/Instruments/Sum/CounterMetric.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import Foundation
77

88
/// Counter instrument.
9-
@available(*,deprecated)
9+
// Phase 2
10+
//@available(*,deprecated)
1011
public protocol CounterMetric {
1112
associatedtype T
1213

Sources/OpenTelemetryApi/Metrics/LabelSet.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import Foundation
77

88
/// Normalized name value pairs of metric labels.
9-
@available(*, deprecated, message: "LabelSet removed from Metric API in OTEP-90")
9+
// Phase 2
10+
//@available(*, deprecated, message: "LabelSet removed from Metric API in OTEP-90")
1011
open class LabelSet: Hashable {
1112
public private(set) var labels: [String: String]
1213

Sources/OpenTelemetryApi/Metrics/Meter.swift

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,44 @@ import Foundation
88
/// Main interface to obtain metric instruments.
99
///
1010
///
11-
@available(*, deprecated, renamed: "StableMeter")
11+
// Phase 2
12+
//@available(*, deprecated, renamed: "StableMeter")
1213
public protocol Meter {
1314

1415
/// Creates Int counter with given name.
1516
/// - Parameters:
1617
/// - name: The name of the counter.
1718
/// - monotonic: indicates if only positive values are expected.
1819
/// - Returns:The counter instance.
19-
@available(*,deprecated, message: "counter instruments are now monotonic only. Use UpDownCounter for non-monotonic.")
20+
// Phase 2
21+
//@available(*,deprecated, message: "counter instruments are now monotonic only. Use UpDownCounter for non-monotonic.")
2022
func createIntCounter(name: String, monotonic: Bool) -> AnyCounterMetric<Int>
2123

2224
/// Creates double counter with given name.
2325
/// - Parameters:
2426
/// - name: indicates if only positive values are expected.
2527
/// - monotonic: The name of the counter.
2628
/// - Returns:The counter instance.
27-
@available(*,deprecated, message: "counter instruments are now monotonic only. Use UpDownCounter for non-monotonic.")
29+
// Phase 2
30+
//@available(*,deprecated, message: "counter instruments are now monotonic only. Use UpDownCounter for non-monotonic.")
2831
func createDoubleCounter(name: String, monotonic: Bool) -> AnyCounterMetric<Double>
2932

3033
/// Creates Int Measure with given name.
3134
/// - Parameters:
3235
/// - name: The name of the measure.
3336
/// - absolute: indicates if only positive values are expected.
3437
/// - Returns:The measure instance.
35-
@available(*,deprecated)
38+
// Phase 2
39+
//@available(*,deprecated)
3640
func createIntMeasure(name: String, absolute: Bool) -> AnyMeasureMetric<Int>
3741

3842
/// Creates double Measure with given name.
3943
/// - Parameters:
4044
/// - name: The name of the measure.
4145
/// - absolute: indicates if only positive values are expected.
4246
/// - Returns:The measure instance.
43-
@available(*,deprecated)
47+
// Phase 2
48+
//@available(*,deprecated)
4449
func createDoubleMeasure(name: String, absolute: Bool) -> AnyMeasureMetric<Double>
4550

4651
/// Creates Int Histogram with given name and boundaries.
@@ -49,7 +54,8 @@ public protocol Meter {
4954
/// - explicitBoundaries: The boundary for sorting values into buckets
5055
/// - absolute: indicates if only positive values are expected.
5156
/// - Returns:The histogram instance.
52-
@available(*,deprecated)
57+
// Phase 2
58+
//@available(*,deprecated)
5359
func createIntHistogram(name: String, explicitBoundaries: Array<Int>?, absolute: Bool) -> AnyHistogramMetric<Int>
5460

5561
/// Creates Double Histogram with given name and boundaries.
@@ -58,7 +64,8 @@ public protocol Meter {
5864
/// - explicitBoundaries: The boundary for sorting values into buckets
5965
/// - absolute: indicates if only positive values are expected.
6066
/// - Returns:The histogram instance.
61-
@available(*,deprecated)
67+
// Phase 2
68+
//@available(*,deprecated)
6269
func createDoubleHistogram(name: String, explicitBoundaries: Array<Double>?, absolute: Bool) -> AnyHistogramMetric<Double>
6370

6471
// Creates a double histogram given the name, boundaries, counts, and start and end dates.
@@ -82,7 +89,8 @@ public protocol Meter {
8289
/// - callback: The callback to be called to observe metric value.
8390
/// - absolute: indicates if only positive values are expected.
8491
/// - Returns:The observer instance.
85-
@available(*,deprecated)
92+
// Phase 2
93+
//@available(*,deprecated)
8694
func createIntObserver(name: String, absolute: Bool, callback: @escaping (IntObserverMetric) -> Void) -> IntObserverMetric
8795

8896
/// Creates Double Observer with given name.
@@ -91,60 +99,70 @@ public protocol Meter {
9199
/// - callback: The callback to be called to observe metric value.
92100
/// - absolute: indicates if only positive values are expected.
93101
/// - Returns:The observer instance.
94-
@available(*,deprecated)
102+
// Phase 2
103+
//@available(*,deprecated)
95104
func createDoubleObserver(name: String, absolute: Bool, callback: @escaping (DoubleObserverMetric) -> Void) -> DoubleObserverMetric
96105

97106
/// Creates Double Observable Gauge with given name.
98107
/// - Parameters:
99108
/// - name: The name of the gauge.
100109
/// - callback: The callback to be called to observe metric value.
101110
/// - Returns:The gauge instance.
102-
@available(*,deprecated)
111+
// Phase 2
112+
//@available(*,deprecated)
103113
func createIntObservableGauge(name: String, callback: @escaping (IntObserverMetric) -> Void) -> IntObserverMetric
104114

105115
/// Creates Int Observable Gauge with given name.
106116
/// - Parameters:
107117
/// - name: The name of the gauge.
108118
/// - callback: The callback to be called to observe metric value.
109119
/// - Returns:The gauge instance.
110-
@available(*,deprecated)
120+
// Phase 2
121+
//@available(*,deprecated)
111122
func createDoubleObservableGauge(name: String, callback: @escaping (DoubleObserverMetric) -> Void) -> DoubleObserverMetric
112123

113124
/// Constructs or retrieves the LabelSet from the given dictionary.
114125
/// - Parameters:
115126
/// - labels: dictionary with key-value pairs.
116127
/// - Returns:The LabelSet with given label key value pairs.
117-
@available(*,deprecated, message: "removed from metrics spec in OTEP-90")
128+
// Phase 2
129+
//@available(*,deprecated, message: "removed from metrics spec in OTEP-90")
118130
func getLabelSet(labels: [String: String]) -> LabelSet
119131
}
120132

121133
public extension Meter {
122-
@available(*,deprecated)
134+
// Phase 2
135+
//@available(*,deprecated)
123136
func createIntCounter(name: String) -> AnyCounterMetric<Int> {
124137
return createIntCounter(name: name, monotonic: true)
125138
}
126139

127-
@available(*,deprecated)
140+
// Phase 2
141+
//@available(*,deprecated)
128142
func createDoubleCounter(name: String) -> AnyCounterMetric<Double> {
129143
return createDoubleCounter(name: name, monotonic: true)
130144
}
131145

132-
@available(*,deprecated)
146+
// Phase 2
147+
//@available(*,deprecated)
133148
func createIntMeasure(name: String) -> AnyMeasureMetric<Int> {
134149
return createIntMeasure(name: name, absolute: true)
135150
}
136151

137-
@available(*,deprecated)
152+
// Phase 2
153+
//@available(*,deprecated)
138154
func createDoubleMeasure(name: String) -> AnyMeasureMetric<Double> {
139155
return createDoubleMeasure(name: name, absolute: true)
140156
}
141157

142-
@available(*,deprecated)
158+
// Phase 2
159+
//@available(*,deprecated)
143160
func createIntObserver(name: String, callback: @escaping (IntObserverMetric) -> Void) -> IntObserverMetric {
144161
return createIntObserver(name: name, absolute: true, callback: callback)
145162
}
146163

147-
@available(*,deprecated)
164+
// Phase 2
165+
//@available(*,deprecated)
148166
func createDoubleObserver(name: String, callback: @escaping (DoubleObserverMetric) -> Void) -> DoubleObserverMetric {
149167
return createDoubleObserver(name: name, absolute: true, callback: callback)
150168
}

Sources/OpenTelemetryApi/Metrics/MeterProvider.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ import Foundation
77

88
/// Creates Meters for an instrumentation library.
99
/// Libraries should use this class as follows to obtain Meter instance.
10-
@available(*, deprecated, renamed: "StableMeterProvider")
10+
// Phase 2
11+
//@available(*, deprecated, renamed: "StableMeterProvider")
1112
public protocol MeterProvider: AnyObject {
1213
/// Returns a Meter for a given name and version.
1314
/// - Parameters:
1415
/// - instrumentationName: Name of the instrumentation library.
1516
/// - instrumentationVersion: Version of the instrumentation library (optional).
1617
/// - Returns: Meter for the given name and version information.
17-
@available(*, deprecated, renamed: "StableMeterProvider.get(name:version:schema_url:)")
18+
// Phase 2
19+
//@available(*, deprecated, renamed: "StableMeterProvider.get(name:version:schema_url:)")
1820
func get(instrumentationName: String, instrumentationVersion: String?) -> Meter
1921
}

Sources/OpenTelemetrySdk/Metrics/Export/MetricProcessor.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
*/
55

66
import Foundation
7-
@available(*, deprecated, renamed: "StableMetricReader")
7+
// Phase 2
8+
//@available(*, deprecated, renamed: "StableMetricReader")
89
public protocol MetricProcessor {
910
/// Finish the current collection cycle and return the metrics it holds.
1011
/// This is called at the end of one collection cycle by the Controller.

Sources/OpenTelemetrySdk/Metrics/MeterProviderSdk.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import Foundation
77
import OpenTelemetryApi
88

9-
@available(*, deprecated, renamed: "StableMeterProviderSdk")
9+
// Phase 2
10+
//@available(*, deprecated, renamed: "StableMeterProviderSdk")
1011
public class MeterProviderSdk: MeterProvider {
1112
private let lock = Lock()
1213
public static let defaultPushInterval: TimeInterval = 60

Sources/OpenTelemetrySdk/Metrics/Stable/State/AsynchronousMetricStorage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class AsynchronousMetricStorage: MetricStorage {
3939
func record(measurement: Measurement) {
4040
let processedAttributes = attributeProcessor.process(incoming: measurement.attributes)
4141
let start = aggregationTemporality == AggregationTemporality.delta ? registeredReader.lastCollectedEpochNanos : measurement.startEpochNano
42-
var newMeasurement = measurement.hasDoubleValue ? Measurement.doubleMeasurement(startEpochNano: start, endEpochNano: measurement.epochNano, value: measurement.doubleValue, attributes: measurement.attributes) : Measurement.longMeasurement(startEpochNano: start, endEpochNano: measurement.epochNano, value: measurement.longValue, attributes: measurement.attributes)
42+
let newMeasurement = measurement.hasDoubleValue ? Measurement.doubleMeasurement(startEpochNano: start, endEpochNano: measurement.epochNano, value: measurement.doubleValue, attributes: processedAttributes) : Measurement.longMeasurement(startEpochNano: start, endEpochNano: measurement.epochNano, value: measurement.longValue, attributes: processedAttributes)
4343
do {
4444
try recordPoint(point: aggregator.toPoint(measurement: newMeasurement))
4545
} catch let HistogramAggregatorError.unsupportedOperation(error) {

0 commit comments

Comments
 (0)