|
| 1 | +import OpenTelemetryApi |
| 2 | + |
| 3 | +import API |
| 4 | +import Sampling |
| 5 | + |
| 6 | +public struct Instrumentation { |
| 7 | + public var recordMetric: (_ metric: Metric) -> Void |
| 8 | + public var recordCount: (_ metric: Metric) -> Void |
| 9 | + public var recordIncr: (_ metric: Metric) -> Void |
| 10 | + public var recordHistogram: (_ metric: Metric) -> Void |
| 11 | + public var recordUpDownCounter: (_ metric: Metric) -> Void |
| 12 | + public var recordError: (_ error: Error, _ attributes: [String: AttributeValue]) -> Void |
| 13 | + public var recordLog: (_ message: String, _ severity: Severity, _ attributes: [String: AttributeValue]) -> Void |
| 14 | + public var startSpan: (_ name: String, _ attributes: [String: AttributeValue]) -> Span |
| 15 | + public var flush: () -> Bool |
| 16 | + |
| 17 | + public init( |
| 18 | + recordMetric: @escaping (_: Metric) -> Void, |
| 19 | + recordCount: @escaping (_: Metric) -> Void, |
| 20 | + recordIncr: @escaping (_: Metric) -> Void, |
| 21 | + recordHistogram: @escaping (_: Metric) -> Void, |
| 22 | + recordUpDownCounter: @escaping (_: Metric) -> Void, |
| 23 | + recordError: @escaping (_: Error, _: [String : AttributeValue]) -> Void, |
| 24 | + recordLog: @escaping (_: String, _: Severity, _: [String : AttributeValue]) -> Void, |
| 25 | + startSpan: @escaping (_: String, _: [String : AttributeValue]) -> Span, |
| 26 | + flush: @escaping () -> Bool |
| 27 | + ) { |
| 28 | + self.recordMetric = recordMetric |
| 29 | + self.recordCount = recordCount |
| 30 | + self.recordIncr = recordIncr |
| 31 | + self.recordHistogram = recordHistogram |
| 32 | + self.recordUpDownCounter = recordUpDownCounter |
| 33 | + self.recordError = recordError |
| 34 | + self.recordLog = recordLog |
| 35 | + self.startSpan = startSpan |
| 36 | + self.flush = flush |
| 37 | + } |
| 38 | + |
| 39 | + public func recordMetric(metric: Metric) { |
| 40 | + recordMetric(metric) |
| 41 | + } |
| 42 | + |
| 43 | + public func recordCount(metric: Metric) { |
| 44 | + recordCount(metric) |
| 45 | + } |
| 46 | + |
| 47 | + public func recordIncr(metric: Metric) { |
| 48 | + recordIncr(metric) |
| 49 | + } |
| 50 | + |
| 51 | + public func recordHistogram(metric: Metric) { |
| 52 | + recordHistogram(metric) |
| 53 | + } |
| 54 | + |
| 55 | + public func recordUpDownCounter(metric: Metric) { |
| 56 | + recordUpDownCounter(metric) |
| 57 | + } |
| 58 | + |
| 59 | + public func recordError(error: Error, attributes: [String: AttributeValue]) { |
| 60 | + recordError(error, attributes) |
| 61 | + } |
| 62 | + |
| 63 | + public func recordLog(message: String, severity: Severity, attributes: [String: AttributeValue]) { |
| 64 | + recordLog(message, severity, attributes) |
| 65 | + } |
| 66 | + |
| 67 | + public func startSpan(name: String, attributes: [String: AttributeValue]) -> Span { |
| 68 | + startSpan(name, attributes) |
| 69 | + } |
| 70 | +} |
0 commit comments