From 28861aa80cbbf946fdafe265e1c8c0629b679806 Mon Sep 17 00:00:00 2001 From: Bryce Buchanan Date: Mon, 28 Apr 2025 16:21:00 -0700 Subject: [PATCH 1/3] updated opentelemetry-proto to v1.5.0 --- .../proto/common.pb.swift | 60 +- .../proto/logs.pb.swift | 78 +- .../proto/logs_service.pb.swift | 14 +- .../proto/metrics.pb.swift | 213 +-- .../proto/metrics_service.pb.swift | 14 +- .../proto/profiles.pb.swift | 1471 +++++++++++++++++ .../proto/profiles_service.pb.swift | 223 +++ .../proto/resource.pb.swift | 8 +- .../proto/trace.pb.swift | 534 ++++-- .../proto/trace_service.pb.swift | 14 +- .../proto/logs_service.grpc.swift | 20 +- .../proto/metrics_service.grpc.swift | 20 +- .../proto/profiles_service.grpc.swift | 315 ++++ .../proto/trace_service.grpc.swift | 20 +- 14 files changed, 2539 insertions(+), 465 deletions(-) create mode 100644 Sources/Exporters/OpenTelemetryProtocolCommon/proto/profiles.pb.swift create mode 100644 Sources/Exporters/OpenTelemetryProtocolCommon/proto/profiles_service.pb.swift create mode 100644 Sources/Exporters/OpenTelemetryProtocolGrpc/proto/profiles_service.grpc.swift diff --git a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/common.pb.swift b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/common.pb.swift index 416058ad8..3aaa01136 100644 --- a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/common.pb.swift +++ b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/common.pb.swift @@ -1,5 +1,6 @@ // DO NOT EDIT. // swift-format-ignore-file +// swiftlint:disable all // // Generated by the Swift generator plugin for the protocol buffer compiler. // Source: opentelemetry/proto/common/v1/common.proto @@ -37,7 +38,7 @@ fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAP /// AnyValue is used to represent any type of attribute value. AnyValue may contain a /// primitive value such as a string or integer or it may contain an arbitrary nested /// object containing arrays, key-value lists and primitives. -public struct Opentelemetry_Proto_Common_V1_AnyValue { +public struct Opentelemetry_Proto_Common_V1_AnyValue: @unchecked Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -106,7 +107,7 @@ public struct Opentelemetry_Proto_Common_V1_AnyValue { /// The value is one of the listed fields. It is valid for all values to be unspecified /// in which case this AnyValue is considered to be "empty". - public enum OneOf_Value: Equatable { + public enum OneOf_Value: Equatable, @unchecked Sendable { case stringValue(String) case boolValue(Bool) case intValue(Int64) @@ -115,44 +116,6 @@ public struct Opentelemetry_Proto_Common_V1_AnyValue { case kvlistValue(Opentelemetry_Proto_Common_V1_KeyValueList) case bytesValue(Data) - #if !swift(>=4.1) - public static func ==(lhs: Opentelemetry_Proto_Common_V1_AnyValue.OneOf_Value, rhs: Opentelemetry_Proto_Common_V1_AnyValue.OneOf_Value) -> Bool { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch (lhs, rhs) { - case (.stringValue, .stringValue): return { - guard case .stringValue(let l) = lhs, case .stringValue(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.boolValue, .boolValue): return { - guard case .boolValue(let l) = lhs, case .boolValue(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.intValue, .intValue): return { - guard case .intValue(let l) = lhs, case .intValue(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.doubleValue, .doubleValue): return { - guard case .doubleValue(let l) = lhs, case .doubleValue(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.arrayValue, .arrayValue): return { - guard case .arrayValue(let l) = lhs, case .arrayValue(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.kvlistValue, .kvlistValue): return { - guard case .kvlistValue(let l) = lhs, case .kvlistValue(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.bytesValue, .bytesValue): return { - guard case .bytesValue(let l) = lhs, case .bytesValue(let r) = rhs else { preconditionFailure() } - return l == r - }() - default: return false - } - } - #endif } public init() {} @@ -160,7 +123,7 @@ public struct Opentelemetry_Proto_Common_V1_AnyValue { /// ArrayValue is a list of AnyValue messages. We need ArrayValue as a message /// since oneof in AnyValue does not allow repeated fields. -public struct Opentelemetry_Proto_Common_V1_ArrayValue { +public struct Opentelemetry_Proto_Common_V1_ArrayValue: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -178,7 +141,7 @@ public struct Opentelemetry_Proto_Common_V1_ArrayValue { /// a list of KeyValue messages (e.g. in Span) we use `repeated KeyValue` directly to /// avoid unnecessary extra wrapping (which slows down the protocol). The 2 approaches /// are semantically equivalent. -public struct Opentelemetry_Proto_Common_V1_KeyValueList { +public struct Opentelemetry_Proto_Common_V1_KeyValueList: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -196,7 +159,7 @@ public struct Opentelemetry_Proto_Common_V1_KeyValueList { /// KeyValue is a key-value pair that is used to store Span attributes, Link /// attributes, etc. -public struct Opentelemetry_Proto_Common_V1_KeyValue { +public struct Opentelemetry_Proto_Common_V1_KeyValue: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -221,7 +184,7 @@ public struct Opentelemetry_Proto_Common_V1_KeyValue { /// InstrumentationScope is a message representing the instrumentation scope information /// such as the fully qualified name and version. -public struct Opentelemetry_Proto_Common_V1_InstrumentationScope { +public struct Opentelemetry_Proto_Common_V1_InstrumentationScope: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -243,15 +206,6 @@ public struct Opentelemetry_Proto_Common_V1_InstrumentationScope { public init() {} } -#if swift(>=5.5) && canImport(_Concurrency) -extension Opentelemetry_Proto_Common_V1_AnyValue: @unchecked Sendable {} -extension Opentelemetry_Proto_Common_V1_AnyValue.OneOf_Value: @unchecked Sendable {} -extension Opentelemetry_Proto_Common_V1_ArrayValue: @unchecked Sendable {} -extension Opentelemetry_Proto_Common_V1_KeyValueList: @unchecked Sendable {} -extension Opentelemetry_Proto_Common_V1_KeyValue: @unchecked Sendable {} -extension Opentelemetry_Proto_Common_V1_InstrumentationScope: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - // MARK: - Code below here is support for the SwiftProtobuf runtime. fileprivate let _protobuf_package = "opentelemetry.proto.common.v1" diff --git a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/logs.pb.swift b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/logs.pb.swift index 595677722..c34dffe39 100644 --- a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/logs.pb.swift +++ b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/logs.pb.swift @@ -1,5 +1,6 @@ // DO NOT EDIT. // swift-format-ignore-file +// swiftlint:disable all // // Generated by the Swift generator plugin for the protocol buffer compiler. // Source: opentelemetry/proto/logs/v1/logs.proto @@ -35,7 +36,7 @@ fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAP } /// Possible values for LogRecord.SeverityNumber. -public enum Opentelemetry_Proto_Logs_V1_SeverityNumber: SwiftProtobuf.Enum { +public enum Opentelemetry_Proto_Logs_V1_SeverityNumber: SwiftProtobuf.Enum, Swift.CaseIterable { public typealias RawValue = Int /// UNSPECIFIED is the default SeverityNumber, it MUST NOT be used. @@ -132,13 +133,8 @@ public enum Opentelemetry_Proto_Logs_V1_SeverityNumber: SwiftProtobuf.Enum { } } -} - -#if swift(>=4.2) - -extension Opentelemetry_Proto_Logs_V1_SeverityNumber: CaseIterable { // The compiler won't synthesize support with the UNRECOGNIZED case. - public static var allCases: [Opentelemetry_Proto_Logs_V1_SeverityNumber] = [ + public static let allCases: [Opentelemetry_Proto_Logs_V1_SeverityNumber] = [ .unspecified, .trace, .trace2, @@ -165,16 +161,17 @@ extension Opentelemetry_Proto_Logs_V1_SeverityNumber: CaseIterable { .fatal3, .fatal4, ] -} -#endif // swift(>=4.2) +} -/// LogRecordFlags is defined as a protobuf 'uint32' type and is to be used as -/// bit-fields. Each non-zero value defined in this enum is a bit-mask. -/// To extract the bit-field, for example, use an expression like: +/// LogRecordFlags represents constants used to interpret the +/// LogRecord.flags field, which is protobuf 'fixed32' type and is to +/// be used as bit-fields. Each non-zero value defined in this enum is +/// a bit-mask. To extract the bit-field, for example, use an +/// expression like: /// /// (logRecord.flags & LOG_RECORD_FLAGS_TRACE_FLAGS_MASK) -public enum Opentelemetry_Proto_Logs_V1_LogRecordFlags: SwiftProtobuf.Enum { +public enum Opentelemetry_Proto_Logs_V1_LogRecordFlags: SwiftProtobuf.Enum, Swift.CaseIterable { public typealias RawValue = Int /// The zero value for the enum. Should not be used for comparisons. @@ -205,19 +202,13 @@ public enum Opentelemetry_Proto_Logs_V1_LogRecordFlags: SwiftProtobuf.Enum { } } -} - -#if swift(>=4.2) - -extension Opentelemetry_Proto_Logs_V1_LogRecordFlags: CaseIterable { // The compiler won't synthesize support with the UNRECOGNIZED case. - public static var allCases: [Opentelemetry_Proto_Logs_V1_LogRecordFlags] = [ + public static let allCases: [Opentelemetry_Proto_Logs_V1_LogRecordFlags] = [ .doNotUse, .traceFlagsMask, ] -} -#endif // swift(>=4.2) +} /// LogsData represents the logs data that can be stored in a persistent storage, /// OR can be embedded by other protocols that transfer OTLP logs data but do not @@ -229,7 +220,7 @@ extension Opentelemetry_Proto_Logs_V1_LogRecordFlags: CaseIterable { /// /// When new fields are added into this message, the OTLP request MUST be updated /// as well. -public struct Opentelemetry_Proto_Logs_V1_LogsData { +public struct Opentelemetry_Proto_Logs_V1_LogsData: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -247,7 +238,7 @@ public struct Opentelemetry_Proto_Logs_V1_LogsData { } /// A collection of ScopeLogs from a Resource. -public struct Opentelemetry_Proto_Logs_V1_ResourceLogs { +public struct Opentelemetry_Proto_Logs_V1_ResourceLogs: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -266,6 +257,10 @@ public struct Opentelemetry_Proto_Logs_V1_ResourceLogs { /// A list of ScopeLogs that originate from a resource. public var scopeLogs: [Opentelemetry_Proto_Logs_V1_ScopeLogs] = [] + /// The Schema URL, if known. This is the identifier of the Schema that the resource data + /// is recorded in. Notably, the last part of the URL path is the version number of the + /// schema: http[s]://server[:port]/path/. To learn more about Schema URL see + /// https://opentelemetry.io/docs/specs/otel/schemas/#schema-url /// This schema_url applies to the data in the "resource" field. It does not apply /// to the data in the "scope_logs" field which have their own schema_url field. public var schemaURL: String = String() @@ -278,7 +273,7 @@ public struct Opentelemetry_Proto_Logs_V1_ResourceLogs { } /// A collection of Logs produced by a Scope. -public struct Opentelemetry_Proto_Logs_V1_ScopeLogs { +public struct Opentelemetry_Proto_Logs_V1_ScopeLogs: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -298,6 +293,10 @@ public struct Opentelemetry_Proto_Logs_V1_ScopeLogs { /// A list of log records. public var logRecords: [Opentelemetry_Proto_Logs_V1_LogRecord] = [] + /// The Schema URL, if known. This is the identifier of the Schema that the log data + /// is recorded in. Notably, the last part of the URL path is the version number of the + /// schema: http[s]://server[:port]/path/. To learn more about Schema URL see + /// https://opentelemetry.io/docs/specs/otel/schemas/#schema-url /// This schema_url applies to all logs in the "logs" field. public var schemaURL: String = String() @@ -310,7 +309,7 @@ public struct Opentelemetry_Proto_Logs_V1_ScopeLogs { /// A log record according to OpenTelemetry Log Data Model: /// https://github.com/open-telemetry/oteps/blob/main/text/logs/0097-log-data-model.md -public struct Opentelemetry_Proto_Logs_V1_LogRecord { +public struct Opentelemetry_Proto_Logs_V1_LogRecord: @unchecked Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -398,6 +397,20 @@ public struct Opentelemetry_Proto_Logs_V1_LogRecord { /// - the field contains an invalid value. public var spanID: Data = Data() + /// A unique identifier of event category/type. + /// All events with the same event_name are expected to conform to the same + /// schema for both their attributes and their body. + /// + /// Recommended to be fully qualified and short (no longer than 256 characters). + /// + /// Presence of event_name on the log record identifies this record + /// as an event. + /// + /// [Optional]. + /// + /// Status: [Development] + public var eventName: String = String() + public var unknownFields = SwiftProtobuf.UnknownStorage() public init() {} @@ -405,15 +418,6 @@ public struct Opentelemetry_Proto_Logs_V1_LogRecord { fileprivate var _body: Opentelemetry_Proto_Common_V1_AnyValue? = nil } -#if swift(>=5.5) && canImport(_Concurrency) -extension Opentelemetry_Proto_Logs_V1_SeverityNumber: @unchecked Sendable {} -extension Opentelemetry_Proto_Logs_V1_LogRecordFlags: @unchecked Sendable {} -extension Opentelemetry_Proto_Logs_V1_LogsData: @unchecked Sendable {} -extension Opentelemetry_Proto_Logs_V1_ResourceLogs: @unchecked Sendable {} -extension Opentelemetry_Proto_Logs_V1_ScopeLogs: @unchecked Sendable {} -extension Opentelemetry_Proto_Logs_V1_LogRecord: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - // MARK: - Code below here is support for the SwiftProtobuf runtime. fileprivate let _protobuf_package = "opentelemetry.proto.logs.v1" @@ -596,6 +600,7 @@ extension Opentelemetry_Proto_Logs_V1_LogRecord: SwiftProtobuf.Message, SwiftPro 8: .same(proto: "flags"), 9: .standard(proto: "trace_id"), 10: .standard(proto: "span_id"), + 12: .standard(proto: "event_name"), ] public mutating func decodeMessage(decoder: inout D) throws { @@ -614,6 +619,7 @@ extension Opentelemetry_Proto_Logs_V1_LogRecord: SwiftProtobuf.Message, SwiftPro case 9: try { try decoder.decodeSingularBytesField(value: &self.traceID) }() case 10: try { try decoder.decodeSingularBytesField(value: &self.spanID) }() case 11: try { try decoder.decodeSingularFixed64Field(value: &self.observedTimeUnixNano) }() + case 12: try { try decoder.decodeSingularStringField(value: &self.eventName) }() default: break } } @@ -654,6 +660,9 @@ extension Opentelemetry_Proto_Logs_V1_LogRecord: SwiftProtobuf.Message, SwiftPro if self.observedTimeUnixNano != 0 { try visitor.visitSingularFixed64Field(value: self.observedTimeUnixNano, fieldNumber: 11) } + if !self.eventName.isEmpty { + try visitor.visitSingularStringField(value: self.eventName, fieldNumber: 12) + } try unknownFields.traverse(visitor: &visitor) } @@ -668,6 +677,7 @@ extension Opentelemetry_Proto_Logs_V1_LogRecord: SwiftProtobuf.Message, SwiftPro if lhs.flags != rhs.flags {return false} if lhs.traceID != rhs.traceID {return false} if lhs.spanID != rhs.spanID {return false} + if lhs.eventName != rhs.eventName {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } diff --git a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/logs_service.pb.swift b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/logs_service.pb.swift index a9289e3b3..af8e77178 100644 --- a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/logs_service.pb.swift +++ b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/logs_service.pb.swift @@ -1,5 +1,6 @@ // DO NOT EDIT. // swift-format-ignore-file +// swiftlint:disable all // // Generated by the Swift generator plugin for the protocol buffer compiler. // Source: opentelemetry/proto/collector/logs/v1/logs_service.proto @@ -21,7 +22,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -import Foundation import SwiftProtobuf // If the compiler emits an error on this type, it is because this file @@ -34,7 +34,7 @@ fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAP typealias Version = _2 } -public struct Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceRequest { +public struct Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceRequest: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -51,7 +51,7 @@ public struct Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceRequest { public init() {} } -public struct Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceResponse { +public struct Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceResponse: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -87,7 +87,7 @@ public struct Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceResponse { fileprivate var _partialSuccess: Opentelemetry_Proto_Collector_Logs_V1_ExportLogsPartialSuccess? = nil } -public struct Opentelemetry_Proto_Collector_Logs_V1_ExportLogsPartialSuccess { +public struct Opentelemetry_Proto_Collector_Logs_V1_ExportLogsPartialSuccess: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -112,12 +112,6 @@ public struct Opentelemetry_Proto_Collector_Logs_V1_ExportLogsPartialSuccess { public init() {} } -#if swift(>=5.5) && canImport(_Concurrency) -extension Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceRequest: @unchecked Sendable {} -extension Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceResponse: @unchecked Sendable {} -extension Opentelemetry_Proto_Collector_Logs_V1_ExportLogsPartialSuccess: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - // MARK: - Code below here is support for the SwiftProtobuf runtime. fileprivate let _protobuf_package = "opentelemetry.proto.collector.logs.v1" diff --git a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/metrics.pb.swift b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/metrics.pb.swift index c0c4219c3..e847bc995 100644 --- a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/metrics.pb.swift +++ b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/metrics.pb.swift @@ -1,5 +1,6 @@ // DO NOT EDIT. // swift-format-ignore-file +// swiftlint:disable all // // Generated by the Swift generator plugin for the protocol buffer compiler. // Source: opentelemetry/proto/metrics/v1/metrics.proto @@ -37,7 +38,7 @@ fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAP /// AggregationTemporality defines how a metric aggregator reports aggregated /// values. It describes how those values relate to the time interval over /// which they are aggregated. -public enum Opentelemetry_Proto_Metrics_V1_AggregationTemporality: SwiftProtobuf.Enum { +public enum Opentelemetry_Proto_Metrics_V1_AggregationTemporality: SwiftProtobuf.Enum, Swift.CaseIterable { public typealias RawValue = Int /// UNSPECIFIED is the default AggregationTemporality, it MUST not be used. @@ -129,20 +130,14 @@ public enum Opentelemetry_Proto_Metrics_V1_AggregationTemporality: SwiftProtobuf } } -} - -#if swift(>=4.2) - -extension Opentelemetry_Proto_Metrics_V1_AggregationTemporality: CaseIterable { // The compiler won't synthesize support with the UNRECOGNIZED case. - public static var allCases: [Opentelemetry_Proto_Metrics_V1_AggregationTemporality] = [ + public static let allCases: [Opentelemetry_Proto_Metrics_V1_AggregationTemporality] = [ .unspecified, .delta, .cumulative, ] -} -#endif // swift(>=4.2) +} /// DataPointFlags is defined as a protobuf 'uint32' type and is to be used as a /// bit-field representing 32 distinct boolean flags. Each flag defined in this @@ -150,7 +145,7 @@ extension Opentelemetry_Proto_Metrics_V1_AggregationTemporality: CaseIterable { /// a data point, for example, use an expression like: /// /// (point.flags & DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK) == DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK -public enum Opentelemetry_Proto_Metrics_V1_DataPointFlags: SwiftProtobuf.Enum { +public enum Opentelemetry_Proto_Metrics_V1_DataPointFlags: SwiftProtobuf.Enum, Swift.CaseIterable { public typealias RawValue = Int /// The zero value for the enum. Should not be used for comparisons. @@ -183,31 +178,43 @@ public enum Opentelemetry_Proto_Metrics_V1_DataPointFlags: SwiftProtobuf.Enum { } } -} - -#if swift(>=4.2) - -extension Opentelemetry_Proto_Metrics_V1_DataPointFlags: CaseIterable { // The compiler won't synthesize support with the UNRECOGNIZED case. - public static var allCases: [Opentelemetry_Proto_Metrics_V1_DataPointFlags] = [ + public static let allCases: [Opentelemetry_Proto_Metrics_V1_DataPointFlags] = [ .doNotUse, .noRecordedValueMask, ] -} -#endif // swift(>=4.2) +} /// MetricsData represents the metrics data that can be stored in a persistent /// storage, OR can be embedded by other protocols that transfer OTLP metrics /// data but do not implement the OTLP protocol. /// +/// MetricsData +/// └─── ResourceMetrics +/// ├── Resource +/// ├── SchemaURL +/// └── ScopeMetrics +/// ├── Scope +/// ├── SchemaURL +/// └── Metric +/// ├── Name +/// ├── Description +/// ├── Unit +/// └── data +/// ├── Gauge +/// ├── Sum +/// ├── Histogram +/// ├── ExponentialHistogram +/// └── Summary +/// /// The main difference between this message and collector protocol is that /// in this message there will not be any "control" or "metadata" specific to /// OTLP protocol. /// /// When new fields are added into this message, the OTLP request MUST be updated /// as well. -public struct Opentelemetry_Proto_Metrics_V1_MetricsData { +public struct Opentelemetry_Proto_Metrics_V1_MetricsData: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -225,7 +232,7 @@ public struct Opentelemetry_Proto_Metrics_V1_MetricsData { } /// A collection of ScopeMetrics from a Resource. -public struct Opentelemetry_Proto_Metrics_V1_ResourceMetrics { +public struct Opentelemetry_Proto_Metrics_V1_ResourceMetrics: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -244,6 +251,10 @@ public struct Opentelemetry_Proto_Metrics_V1_ResourceMetrics { /// A list of metrics that originate from a resource. public var scopeMetrics: [Opentelemetry_Proto_Metrics_V1_ScopeMetrics] = [] + /// The Schema URL, if known. This is the identifier of the Schema that the resource data + /// is recorded in. Notably, the last part of the URL path is the version number of the + /// schema: http[s]://server[:port]/path/. To learn more about Schema URL see + /// https://opentelemetry.io/docs/specs/otel/schemas/#schema-url /// This schema_url applies to the data in the "resource" field. It does not apply /// to the data in the "scope_metrics" field which have their own schema_url field. public var schemaURL: String = String() @@ -256,7 +267,7 @@ public struct Opentelemetry_Proto_Metrics_V1_ResourceMetrics { } /// A collection of Metrics produced by an Scope. -public struct Opentelemetry_Proto_Metrics_V1_ScopeMetrics { +public struct Opentelemetry_Proto_Metrics_V1_ScopeMetrics: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -276,6 +287,10 @@ public struct Opentelemetry_Proto_Metrics_V1_ScopeMetrics { /// A list of metrics that originate from an instrumentation library. public var metrics: [Opentelemetry_Proto_Metrics_V1_Metric] = [] + /// The Schema URL, if known. This is the identifier of the Schema that the metric data + /// is recorded in. Notably, the last part of the URL path is the version number of the + /// schema: http[s]://server[:port]/path/. To learn more about Schema URL see + /// https://opentelemetry.io/docs/specs/otel/schemas/#schema-url /// This schema_url applies to all metrics in the "metrics" field. public var schemaURL: String = String() @@ -291,7 +306,6 @@ public struct Opentelemetry_Proto_Metrics_V1_ScopeMetrics { /// /// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/data-model.md /// -/// /// The data model and relation between entities is shown in the /// diagram below. Here, "DataPoint" is the term used to refer to any /// one of the specific data point value types, and "points" is the term used @@ -303,7 +317,7 @@ public struct Opentelemetry_Proto_Metrics_V1_ScopeMetrics { /// - DataPoint contains timestamps, attributes, and one of the possible value type /// fields. /// -/// Metric +/// Metric /// +------------+ /// |name | /// |description | @@ -371,12 +385,12 @@ public struct Opentelemetry_Proto_Metrics_V1_ScopeMetrics { /// to support correct rate calculation. Although it may be omitted /// when the start time is truly unknown, setting StartTimeUnixNano is /// strongly encouraged. -public struct Opentelemetry_Proto_Metrics_V1_Metric { +public struct Opentelemetry_Proto_Metrics_V1_Metric: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. - /// name of the metric, including its DNS name prefix. It must be unique. + /// name of the metric. public var name: String = String() /// description of the metric, which can be used in documentation. @@ -431,48 +445,27 @@ public struct Opentelemetry_Proto_Metrics_V1_Metric { set {data = .summary(newValue)} } + /// Additional metadata attributes that describe the metric. [Optional]. + /// Attributes are non-identifying. + /// Consumers SHOULD NOT need to be aware of these attributes. + /// These attributes MAY be used to encode information allowing + /// for lossless roundtrip translation to / from another data model. + /// Attribute keys MUST be unique (it is not allowed to have more than one + /// attribute with the same key). + public var metadata: [Opentelemetry_Proto_Common_V1_KeyValue] = [] + public var unknownFields = SwiftProtobuf.UnknownStorage() /// Data determines the aggregation type (if any) of the metric, what is the /// reported value type for the data points, as well as the relatationship to /// the time interval over which they are reported. - public enum OneOf_Data: Equatable { + public enum OneOf_Data: Equatable, Sendable { case gauge(Opentelemetry_Proto_Metrics_V1_Gauge) case sum(Opentelemetry_Proto_Metrics_V1_Sum) case histogram(Opentelemetry_Proto_Metrics_V1_Histogram) case exponentialHistogram(Opentelemetry_Proto_Metrics_V1_ExponentialHistogram) case summary(Opentelemetry_Proto_Metrics_V1_Summary) - #if !swift(>=4.1) - public static func ==(lhs: Opentelemetry_Proto_Metrics_V1_Metric.OneOf_Data, rhs: Opentelemetry_Proto_Metrics_V1_Metric.OneOf_Data) -> Bool { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch (lhs, rhs) { - case (.gauge, .gauge): return { - guard case .gauge(let l) = lhs, case .gauge(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.sum, .sum): return { - guard case .sum(let l) = lhs, case .sum(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.histogram, .histogram): return { - guard case .histogram(let l) = lhs, case .histogram(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.exponentialHistogram, .exponentialHistogram): return { - guard case .exponentialHistogram(let l) = lhs, case .exponentialHistogram(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.summary, .summary): return { - guard case .summary(let l) = lhs, case .summary(let r) = rhs else { preconditionFailure() } - return l == r - }() - default: return false - } - } - #endif } public init() {} @@ -487,7 +480,7 @@ public struct Opentelemetry_Proto_Metrics_V1_Metric { /// aggregation, regardless of aggregation temporalities. Therefore, /// AggregationTemporality is not included. Consequently, this also means /// "StartTimeUnixNano" is ignored for all data points. -public struct Opentelemetry_Proto_Metrics_V1_Gauge { +public struct Opentelemetry_Proto_Metrics_V1_Gauge: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -501,7 +494,7 @@ public struct Opentelemetry_Proto_Metrics_V1_Gauge { /// Sum represents the type of a scalar metric that is calculated as a sum of all /// reported measurements over a time interval. -public struct Opentelemetry_Proto_Metrics_V1_Sum { +public struct Opentelemetry_Proto_Metrics_V1_Sum: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -522,7 +515,7 @@ public struct Opentelemetry_Proto_Metrics_V1_Sum { /// Histogram represents the type of a metric that is calculated by aggregating /// as a Histogram of all reported measurements over a time interval. -public struct Opentelemetry_Proto_Metrics_V1_Histogram { +public struct Opentelemetry_Proto_Metrics_V1_Histogram: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -540,7 +533,7 @@ public struct Opentelemetry_Proto_Metrics_V1_Histogram { /// ExponentialHistogram represents the type of a metric that is calculated by aggregating /// as a ExponentialHistogram of all reported double measurements over a time interval. -public struct Opentelemetry_Proto_Metrics_V1_ExponentialHistogram { +public struct Opentelemetry_Proto_Metrics_V1_ExponentialHistogram: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -562,7 +555,10 @@ public struct Opentelemetry_Proto_Metrics_V1_ExponentialHistogram { /// data type. These data points cannot always be merged in a meaningful way. /// While they can be useful in some applications, histogram data points are /// recommended for new applications. -public struct Opentelemetry_Proto_Metrics_V1_Summary { +/// Summary metrics do not have an aggregation temporality field. This is +/// because the count and sum fields of a SummaryDataPoint are assumed to be +/// cumulative values. +public struct Opentelemetry_Proto_Metrics_V1_Summary: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -576,7 +572,7 @@ public struct Opentelemetry_Proto_Metrics_V1_Summary { /// NumberDataPoint is a single data point in a timeseries that describes the /// time-varying scalar value of a metric. -public struct Opentelemetry_Proto_Metrics_V1_NumberDataPoint { +public struct Opentelemetry_Proto_Metrics_V1_NumberDataPoint: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -632,28 +628,10 @@ public struct Opentelemetry_Proto_Metrics_V1_NumberDataPoint { /// The value itself. A point is considered invalid when one of the recognized /// value fields is not present inside this oneof. - public enum OneOf_Value: Equatable { + public enum OneOf_Value: Equatable, Sendable { case asDouble(Double) case asInt(Int64) - #if !swift(>=4.1) - public static func ==(lhs: Opentelemetry_Proto_Metrics_V1_NumberDataPoint.OneOf_Value, rhs: Opentelemetry_Proto_Metrics_V1_NumberDataPoint.OneOf_Value) -> Bool { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch (lhs, rhs) { - case (.asDouble, .asDouble): return { - guard case .asDouble(let l) = lhs, case .asDouble(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.asInt, .asInt): return { - guard case .asInt(let l) = lhs, case .asInt(let r) = rhs else { preconditionFailure() } - return l == r - }() - default: return false - } - } - #endif } public init() {} @@ -669,7 +647,7 @@ public struct Opentelemetry_Proto_Metrics_V1_NumberDataPoint { /// If the histogram does not contain the distribution of values, then both /// "explicit_bounds" and "bucket_counts" must be omitted and only "count" and /// "sum" are known. -public struct Opentelemetry_Proto_Metrics_V1_HistogramDataPoint { +public struct Opentelemetry_Proto_Metrics_V1_HistogramDataPoint: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -780,7 +758,7 @@ public struct Opentelemetry_Proto_Metrics_V1_HistogramDataPoint { /// time-varying values of a ExponentialHistogram of double values. A ExponentialHistogram contains /// summary statistics for a population of values, it may optionally contain the /// distribution of those values across a set of buckets. -public struct Opentelemetry_Proto_Metrics_V1_ExponentialHistogramDataPoint { +public struct Opentelemetry_Proto_Metrics_V1_ExponentialHistogramDataPoint: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -913,7 +891,7 @@ public struct Opentelemetry_Proto_Metrics_V1_ExponentialHistogramDataPoint { /// Buckets are a set of bucket counts, encoded in a contiguous array /// of counts. - public struct Buckets { + public struct Buckets: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -949,8 +927,9 @@ public struct Opentelemetry_Proto_Metrics_V1_ExponentialHistogramDataPoint { } /// SummaryDataPoint is a single data point in a timeseries that describes the -/// time-varying values of a Summary metric. -public struct Opentelemetry_Proto_Metrics_V1_SummaryDataPoint { +/// time-varying values of a Summary metric. The count and sum fields represent +/// cumulative values. +public struct Opentelemetry_Proto_Metrics_V1_SummaryDataPoint: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -1005,7 +984,7 @@ public struct Opentelemetry_Proto_Metrics_V1_SummaryDataPoint { /// /// See the following issue for more context: /// https://github.com/open-telemetry/opentelemetry-proto/issues/125 - public struct ValueAtQuantile { + public struct ValueAtQuantile: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -1031,7 +1010,7 @@ public struct Opentelemetry_Proto_Metrics_V1_SummaryDataPoint { /// Exemplars also hold information about the environment when the measurement /// was recorded, for example the span and trace ID of the active span when the /// exemplar was recorded. -public struct Opentelemetry_Proto_Metrics_V1_Exemplar { +public struct Opentelemetry_Proto_Metrics_V1_Exemplar: @unchecked Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -1083,57 +1062,15 @@ public struct Opentelemetry_Proto_Metrics_V1_Exemplar { /// The value of the measurement that was recorded. An exemplar is /// considered invalid when one of the recognized value fields is not present /// inside this oneof. - public enum OneOf_Value: Equatable { + public enum OneOf_Value: Equatable, Sendable { case asDouble(Double) case asInt(Int64) - #if !swift(>=4.1) - public static func ==(lhs: Opentelemetry_Proto_Metrics_V1_Exemplar.OneOf_Value, rhs: Opentelemetry_Proto_Metrics_V1_Exemplar.OneOf_Value) -> Bool { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch (lhs, rhs) { - case (.asDouble, .asDouble): return { - guard case .asDouble(let l) = lhs, case .asDouble(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.asInt, .asInt): return { - guard case .asInt(let l) = lhs, case .asInt(let r) = rhs else { preconditionFailure() } - return l == r - }() - default: return false - } - } - #endif } public init() {} } -#if swift(>=5.5) && canImport(_Concurrency) -extension Opentelemetry_Proto_Metrics_V1_AggregationTemporality: @unchecked Sendable {} -extension Opentelemetry_Proto_Metrics_V1_DataPointFlags: @unchecked Sendable {} -extension Opentelemetry_Proto_Metrics_V1_MetricsData: @unchecked Sendable {} -extension Opentelemetry_Proto_Metrics_V1_ResourceMetrics: @unchecked Sendable {} -extension Opentelemetry_Proto_Metrics_V1_ScopeMetrics: @unchecked Sendable {} -extension Opentelemetry_Proto_Metrics_V1_Metric: @unchecked Sendable {} -extension Opentelemetry_Proto_Metrics_V1_Metric.OneOf_Data: @unchecked Sendable {} -extension Opentelemetry_Proto_Metrics_V1_Gauge: @unchecked Sendable {} -extension Opentelemetry_Proto_Metrics_V1_Sum: @unchecked Sendable {} -extension Opentelemetry_Proto_Metrics_V1_Histogram: @unchecked Sendable {} -extension Opentelemetry_Proto_Metrics_V1_ExponentialHistogram: @unchecked Sendable {} -extension Opentelemetry_Proto_Metrics_V1_Summary: @unchecked Sendable {} -extension Opentelemetry_Proto_Metrics_V1_NumberDataPoint: @unchecked Sendable {} -extension Opentelemetry_Proto_Metrics_V1_NumberDataPoint.OneOf_Value: @unchecked Sendable {} -extension Opentelemetry_Proto_Metrics_V1_HistogramDataPoint: @unchecked Sendable {} -extension Opentelemetry_Proto_Metrics_V1_ExponentialHistogramDataPoint: @unchecked Sendable {} -extension Opentelemetry_Proto_Metrics_V1_ExponentialHistogramDataPoint.Buckets: @unchecked Sendable {} -extension Opentelemetry_Proto_Metrics_V1_SummaryDataPoint: @unchecked Sendable {} -extension Opentelemetry_Proto_Metrics_V1_SummaryDataPoint.ValueAtQuantile: @unchecked Sendable {} -extension Opentelemetry_Proto_Metrics_V1_Exemplar: @unchecked Sendable {} -extension Opentelemetry_Proto_Metrics_V1_Exemplar.OneOf_Value: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - // MARK: - Code below here is support for the SwiftProtobuf runtime. fileprivate let _protobuf_package = "opentelemetry.proto.metrics.v1" @@ -1292,6 +1229,7 @@ extension Opentelemetry_Proto_Metrics_V1_Metric: SwiftProtobuf.Message, SwiftPro 9: .same(proto: "histogram"), 10: .standard(proto: "exponential_histogram"), 11: .same(proto: "summary"), + 12: .same(proto: "metadata"), ] public mutating func decodeMessage(decoder: inout D) throws { @@ -1368,6 +1306,7 @@ extension Opentelemetry_Proto_Metrics_V1_Metric: SwiftProtobuf.Message, SwiftPro self.data = .summary(v) } }() + case 12: try { try decoder.decodeRepeatedMessageField(value: &self.metadata) }() default: break } } @@ -1410,6 +1349,9 @@ extension Opentelemetry_Proto_Metrics_V1_Metric: SwiftProtobuf.Message, SwiftPro }() case nil: break } + if !self.metadata.isEmpty { + try visitor.visitRepeatedMessageField(value: self.metadata, fieldNumber: 12) + } try unknownFields.traverse(visitor: &visitor) } @@ -1418,6 +1360,7 @@ extension Opentelemetry_Proto_Metrics_V1_Metric: SwiftProtobuf.Message, SwiftPro if lhs.description_p != rhs.description_p {return false} if lhs.unit != rhs.unit {return false} if lhs.data != rhs.data {return false} + if lhs.metadata != rhs.metadata {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } @@ -1876,7 +1819,7 @@ extension Opentelemetry_Proto_Metrics_V1_ExponentialHistogramDataPoint: SwiftPro try { if let v = self._max { try visitor.visitSingularDoubleField(value: v, fieldNumber: 13) } }() - if self.zeroThreshold != 0 { + if self.zeroThreshold.bitPattern != 0 { try visitor.visitSingularDoubleField(value: self.zeroThreshold, fieldNumber: 14) } try unknownFields.traverse(visitor: &visitor) @@ -1980,7 +1923,7 @@ extension Opentelemetry_Proto_Metrics_V1_SummaryDataPoint: SwiftProtobuf.Message if self.count != 0 { try visitor.visitSingularFixed64Field(value: self.count, fieldNumber: 4) } - if self.sum != 0 { + if self.sum.bitPattern != 0 { try visitor.visitSingularDoubleField(value: self.sum, fieldNumber: 5) } if !self.quantileValues.isEmpty { @@ -2029,10 +1972,10 @@ extension Opentelemetry_Proto_Metrics_V1_SummaryDataPoint.ValueAtQuantile: Swift } public func traverse(visitor: inout V) throws { - if self.quantile != 0 { + if self.quantile.bitPattern != 0 { try visitor.visitSingularDoubleField(value: self.quantile, fieldNumber: 1) } - if self.value != 0 { + if self.value.bitPattern != 0 { try visitor.visitSingularDoubleField(value: self.value, fieldNumber: 2) } try unknownFields.traverse(visitor: &visitor) diff --git a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/metrics_service.pb.swift b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/metrics_service.pb.swift index dba137610..7c1138351 100644 --- a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/metrics_service.pb.swift +++ b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/metrics_service.pb.swift @@ -1,5 +1,6 @@ // DO NOT EDIT. // swift-format-ignore-file +// swiftlint:disable all // // Generated by the Swift generator plugin for the protocol buffer compiler. // Source: opentelemetry/proto/collector/metrics/v1/metrics_service.proto @@ -21,7 +22,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -import Foundation import SwiftProtobuf // If the compiler emits an error on this type, it is because this file @@ -34,7 +34,7 @@ fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAP typealias Version = _2 } -public struct Opentelemetry_Proto_Collector_Metrics_V1_ExportMetricsServiceRequest { +public struct Opentelemetry_Proto_Collector_Metrics_V1_ExportMetricsServiceRequest: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -51,7 +51,7 @@ public struct Opentelemetry_Proto_Collector_Metrics_V1_ExportMetricsServiceReque public init() {} } -public struct Opentelemetry_Proto_Collector_Metrics_V1_ExportMetricsServiceResponse { +public struct Opentelemetry_Proto_Collector_Metrics_V1_ExportMetricsServiceResponse: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -87,7 +87,7 @@ public struct Opentelemetry_Proto_Collector_Metrics_V1_ExportMetricsServiceRespo fileprivate var _partialSuccess: Opentelemetry_Proto_Collector_Metrics_V1_ExportMetricsPartialSuccess? = nil } -public struct Opentelemetry_Proto_Collector_Metrics_V1_ExportMetricsPartialSuccess { +public struct Opentelemetry_Proto_Collector_Metrics_V1_ExportMetricsPartialSuccess: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -112,12 +112,6 @@ public struct Opentelemetry_Proto_Collector_Metrics_V1_ExportMetricsPartialSucce public init() {} } -#if swift(>=5.5) && canImport(_Concurrency) -extension Opentelemetry_Proto_Collector_Metrics_V1_ExportMetricsServiceRequest: @unchecked Sendable {} -extension Opentelemetry_Proto_Collector_Metrics_V1_ExportMetricsServiceResponse: @unchecked Sendable {} -extension Opentelemetry_Proto_Collector_Metrics_V1_ExportMetricsPartialSuccess: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - // MARK: - Code below here is support for the SwiftProtobuf runtime. fileprivate let _protobuf_package = "opentelemetry.proto.collector.metrics.v1" diff --git a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/profiles.pb.swift b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/profiles.pb.swift new file mode 100644 index 000000000..3c1936011 --- /dev/null +++ b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/profiles.pb.swift @@ -0,0 +1,1471 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// swiftlint:disable all +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: opentelemetry/proto/profiles/v1development/profiles.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +// Copyright 2023, 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 +// +// http://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. +// +// This file includes work covered by the following copyright and permission notices: +// +// Copyright 2016 Google Inc. All Rights Reserved. +// +// 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 +// +// http://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 Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +/// Specifies the method of aggregating metric values, either DELTA (change since last report) +/// or CUMULATIVE (total since a fixed start time). +public enum Opentelemetry_Proto_Profiles_V1development_AggregationTemporality: SwiftProtobuf.Enum, Swift.CaseIterable { + public typealias RawValue = Int + + /// UNSPECIFIED is the default AggregationTemporality, it MUST not be used. + case unspecified // = 0 + + ///* DELTA is an AggregationTemporality for a profiler which reports + ///changes since last report time. Successive metrics contain aggregation of + ///values from continuous and non-overlapping intervals. + /// + ///The values for a DELTA metric are based only on the time interval + ///associated with one measurement cycle. There is no dependency on + ///previous measurements like is the case for CUMULATIVE metrics. + /// + ///For example, consider a system measuring the number of requests that + ///it receives and reports the sum of these requests every second as a + ///DELTA metric: + /// + ///1. The system starts receiving at time=t_0. + ///2. A request is received, the system measures 1 request. + ///3. A request is received, the system measures 1 request. + ///4. A request is received, the system measures 1 request. + ///5. The 1 second collection cycle ends. A metric is exported for the + ///number of requests received over the interval of time t_0 to + ///t_0+1 with a value of 3. + ///6. A request is received, the system measures 1 request. + ///7. A request is received, the system measures 1 request. + ///8. The 1 second collection cycle ends. A metric is exported for the + ///number of requests received over the interval of time t_0+1 to + ///t_0+2 with a value of 2. + case delta // = 1 + + ///* CUMULATIVE is an AggregationTemporality for a profiler which + ///reports changes since a fixed start time. This means that current values + ///of a CUMULATIVE metric depend on all previous measurements since the + ///start time. Because of this, the sender is required to retain this state + ///in some form. If this state is lost or invalidated, the CUMULATIVE metric + ///values MUST be reset and a new fixed start time following the last + ///reported measurement time sent MUST be used. + /// + ///For example, consider a system measuring the number of requests that + ///it receives and reports the sum of these requests every second as a + ///CUMULATIVE metric: + /// + ///1. The system starts receiving at time=t_0. + ///2. A request is received, the system measures 1 request. + ///3. A request is received, the system measures 1 request. + ///4. A request is received, the system measures 1 request. + ///5. The 1 second collection cycle ends. A metric is exported for the + ///number of requests received over the interval of time t_0 to + ///t_0+1 with a value of 3. + ///6. A request is received, the system measures 1 request. + ///7. A request is received, the system measures 1 request. + ///8. The 1 second collection cycle ends. A metric is exported for the + ///number of requests received over the interval of time t_0 to + ///t_0+2 with a value of 5. + ///9. The system experiences a fault and loses state. + ///10. The system recovers and resumes receiving at time=t_1. + ///11. A request is received, the system measures 1 request. + ///12. The 1 second collection cycle ends. A metric is exported for the + ///number of requests received over the interval of time t_1 to + ///t_1+1 with a value of 1. + /// + ///Note: Even though, when reporting changes since last report time, using + ///CUMULATIVE is valid, it is not recommended. + case cumulative // = 2 + case UNRECOGNIZED(Int) + + public init() { + self = .unspecified + } + + public init?(rawValue: Int) { + switch rawValue { + case 0: self = .unspecified + case 1: self = .delta + case 2: self = .cumulative + default: self = .UNRECOGNIZED(rawValue) + } + } + + public var rawValue: Int { + switch self { + case .unspecified: return 0 + case .delta: return 1 + case .cumulative: return 2 + case .UNRECOGNIZED(let i): return i + } + } + + // The compiler won't synthesize support with the UNRECOGNIZED case. + public static let allCases: [Opentelemetry_Proto_Profiles_V1development_AggregationTemporality] = [ + .unspecified, + .delta, + .cumulative, + ] + +} + +/// ProfilesData represents the profiles data that can be stored in persistent storage, +/// OR can be embedded by other protocols that transfer OTLP profiles data but do not +/// implement the OTLP protocol. +/// +/// The main difference between this message and collector protocol is that +/// in this message there will not be any "control" or "metadata" specific to +/// OTLP protocol. +/// +/// When new fields are added into this message, the OTLP request MUST be updated +/// as well. +public struct Opentelemetry_Proto_Profiles_V1development_ProfilesData: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// An array of ResourceProfiles. + /// For data coming from a single resource this array will typically contain + /// one element. Intermediary nodes that receive data from multiple origins + /// typically batch the data before forwarding further and in that case this + /// array will contain multiple elements. + public var resourceProfiles: [Opentelemetry_Proto_Profiles_V1development_ResourceProfiles] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// A collection of ScopeProfiles from a Resource. +public struct Opentelemetry_Proto_Profiles_V1development_ResourceProfiles: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The resource for the profiles in this message. + /// If this field is not set then no resource info is known. + public var resource: Opentelemetry_Proto_Resource_V1_Resource { + get {return _resource ?? Opentelemetry_Proto_Resource_V1_Resource()} + set {_resource = newValue} + } + /// Returns true if `resource` has been explicitly set. + public var hasResource: Bool {return self._resource != nil} + /// Clears the value of `resource`. Subsequent reads from it will return its default value. + public mutating func clearResource() {self._resource = nil} + + /// A list of ScopeProfiles that originate from a resource. + public var scopeProfiles: [Opentelemetry_Proto_Profiles_V1development_ScopeProfiles] = [] + + /// The Schema URL, if known. This is the identifier of the Schema that the resource data + /// is recorded in. Notably, the last part of the URL path is the version number of the + /// schema: http[s]://server[:port]/path/. To learn more about Schema URL see + /// https://opentelemetry.io/docs/specs/otel/schemas/#schema-url + /// This schema_url applies to the data in the "resource" field. It does not apply + /// to the data in the "scope_profiles" field which have their own schema_url field. + public var schemaURL: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _resource: Opentelemetry_Proto_Resource_V1_Resource? = nil +} + +/// A collection of Profiles produced by an InstrumentationScope. +public struct Opentelemetry_Proto_Profiles_V1development_ScopeProfiles: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The instrumentation scope information for the profiles in this message. + /// Semantically when InstrumentationScope isn't set, it is equivalent with + /// an empty instrumentation scope name (unknown). + public var scope: Opentelemetry_Proto_Common_V1_InstrumentationScope { + get {return _scope ?? Opentelemetry_Proto_Common_V1_InstrumentationScope()} + set {_scope = newValue} + } + /// Returns true if `scope` has been explicitly set. + public var hasScope: Bool {return self._scope != nil} + /// Clears the value of `scope`. Subsequent reads from it will return its default value. + public mutating func clearScope() {self._scope = nil} + + /// A list of Profiles that originate from an instrumentation scope. + public var profiles: [Opentelemetry_Proto_Profiles_V1development_Profile] = [] + + /// The Schema URL, if known. This is the identifier of the Schema that the profile data + /// is recorded in. Notably, the last part of the URL path is the version number of the + /// schema: http[s]://server[:port]/path/. To learn more about Schema URL see + /// https://opentelemetry.io/docs/specs/otel/schemas/#schema-url + /// This schema_url applies to all profiles in the "profiles" field. + public var schemaURL: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _scope: Opentelemetry_Proto_Common_V1_InstrumentationScope? = nil +} + +/// Represents a complete profile, including sample types, samples, +/// mappings to binaries, locations, functions, string table, and additional metadata. +/// It modifies and annotates pprof Profile with OpenTelemetry specific fields. +/// +/// Note that whilst fields in this message retain the name and field id from pprof in most cases +/// for ease of understanding data migration, it is not intended that pprof:Profile and +/// OpenTelemetry:Profile encoding be wire compatible. +public struct Opentelemetry_Proto_Profiles_V1development_Profile: @unchecked Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// A description of the samples associated with each Sample.value. + /// For a cpu profile this might be: + /// [["cpu","nanoseconds"]] or [["wall","seconds"]] or [["syscall","count"]] + /// For a heap profile, this might be: + /// [["allocations","count"], ["space","bytes"]], + /// If one of the values represents the number of events represented + /// by the sample, by convention it should be at index 0 and use + /// sample_type.unit == "count". + public var sampleType: [Opentelemetry_Proto_Profiles_V1development_ValueType] { + get {return _storage._sampleType} + set {_uniqueStorage()._sampleType = newValue} + } + + /// The set of samples recorded in this profile. + public var sample: [Opentelemetry_Proto_Profiles_V1development_Sample] { + get {return _storage._sample} + set {_uniqueStorage()._sample = newValue} + } + + /// Mapping from address ranges to the image/binary/library mapped + /// into that address range. mapping[0] will be the main binary. + /// If multiple binaries contribute to the Profile and no main + /// binary can be identified, mapping[0] has no special meaning. + public var mappingTable: [Opentelemetry_Proto_Profiles_V1development_Mapping] { + get {return _storage._mappingTable} + set {_uniqueStorage()._mappingTable = newValue} + } + + /// Locations referenced by samples via location_indices. + public var locationTable: [Opentelemetry_Proto_Profiles_V1development_Location] { + get {return _storage._locationTable} + set {_uniqueStorage()._locationTable = newValue} + } + + /// Array of locations referenced by samples. + public var locationIndices: [Int32] { + get {return _storage._locationIndices} + set {_uniqueStorage()._locationIndices = newValue} + } + + /// Functions referenced by locations. + public var functionTable: [Opentelemetry_Proto_Profiles_V1development_Function] { + get {return _storage._functionTable} + set {_uniqueStorage()._functionTable = newValue} + } + + /// Lookup table for attributes. + public var attributeTable: [Opentelemetry_Proto_Common_V1_KeyValue] { + get {return _storage._attributeTable} + set {_uniqueStorage()._attributeTable = newValue} + } + + /// Represents a mapping between Attribute Keys and Units. + public var attributeUnits: [Opentelemetry_Proto_Profiles_V1development_AttributeUnit] { + get {return _storage._attributeUnits} + set {_uniqueStorage()._attributeUnits = newValue} + } + + /// Lookup table for links. + public var linkTable: [Opentelemetry_Proto_Profiles_V1development_Link] { + get {return _storage._linkTable} + set {_uniqueStorage()._linkTable = newValue} + } + + /// A common table for strings referenced by various messages. + /// string_table[0] must always be "". + public var stringTable: [String] { + get {return _storage._stringTable} + set {_uniqueStorage()._stringTable = newValue} + } + + /// Time of collection (UTC) represented as nanoseconds past the epoch. + public var timeNanos: Int64 { + get {return _storage._timeNanos} + set {_uniqueStorage()._timeNanos = newValue} + } + + /// Duration of the profile, if a duration makes sense. + public var durationNanos: Int64 { + get {return _storage._durationNanos} + set {_uniqueStorage()._durationNanos = newValue} + } + + /// The kind of events between sampled occurrences. + /// e.g [ "cpu","cycles" ] or [ "heap","bytes" ] + public var periodType: Opentelemetry_Proto_Profiles_V1development_ValueType { + get {return _storage._periodType ?? Opentelemetry_Proto_Profiles_V1development_ValueType()} + set {_uniqueStorage()._periodType = newValue} + } + /// Returns true if `periodType` has been explicitly set. + public var hasPeriodType: Bool {return _storage._periodType != nil} + /// Clears the value of `periodType`. Subsequent reads from it will return its default value. + public mutating func clearPeriodType() {_uniqueStorage()._periodType = nil} + + /// The number of events between sampled occurrences. + public var period: Int64 { + get {return _storage._period} + set {_uniqueStorage()._period = newValue} + } + + /// Free-form text associated with the profile. The text is displayed as is + /// to the user by the tools that read profiles (e.g. by pprof). This field + /// should not be used to store any machine-readable information, it is only + /// for human-friendly content. The profile must stay functional if this field + /// is cleaned. + public var commentStrindices: [Int32] { + get {return _storage._commentStrindices} + set {_uniqueStorage()._commentStrindices = newValue} + } + + /// Index into the string table of the type of the preferred sample + /// value. If unset, clients should default to the last sample value. + public var defaultSampleTypeStrindex: Int32 { + get {return _storage._defaultSampleTypeStrindex} + set {_uniqueStorage()._defaultSampleTypeStrindex = newValue} + } + + /// A globally unique identifier for a profile. The ID is a 16-byte array. An ID with + /// all zeroes is considered invalid. + /// + /// This field is required. + public var profileID: Data { + get {return _storage._profileID} + set {_uniqueStorage()._profileID = newValue} + } + + /// dropped_attributes_count is the number of attributes that were discarded. Attributes + /// can be discarded because their keys are too long or because there are too many + /// attributes. If this value is 0, then no attributes were dropped. + public var droppedAttributesCount: UInt32 { + get {return _storage._droppedAttributesCount} + set {_uniqueStorage()._droppedAttributesCount = newValue} + } + + /// Specifies format of the original payload. Common values are defined in semantic conventions. [required if original_payload is present] + public var originalPayloadFormat: String { + get {return _storage._originalPayloadFormat} + set {_uniqueStorage()._originalPayloadFormat = newValue} + } + + /// Original payload can be stored in this field. This can be useful for users who want to get the original payload. + /// Formats such as JFR are highly extensible and can contain more information than what is defined in this spec. + /// Inclusion of original payload should be configurable by the user. Default behavior should be to not include the original payload. + /// If the original payload is in pprof format, it SHOULD not be included in this field. + /// The field is optional, however if it is present then equivalent converted data should be populated in other fields + /// of this message as far as is practicable. + public var originalPayload: Data { + get {return _storage._originalPayload} + set {_uniqueStorage()._originalPayload = newValue} + } + + /// References to attributes in attribute_table. [optional] + /// It is a collection of key/value pairs. Note, global attributes + /// like server name can be set using the resource API. Examples of attributes: + /// + /// "/http/user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" + /// "/http/server_latency": 300 + /// "abc.com/myattribute": true + /// "abc.com/score": 10.239 + /// + /// The OpenTelemetry API specification further restricts the allowed value types: + /// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/README.md#attribute + /// Attribute keys MUST be unique (it is not allowed to have more than one + /// attribute with the same key). + public var attributeIndices: [Int32] { + get {return _storage._attributeIndices} + set {_uniqueStorage()._attributeIndices = newValue} + } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _storage = _StorageClass.defaultInstance +} + +/// Represents a mapping between Attribute Keys and Units. +public struct Opentelemetry_Proto_Profiles_V1development_AttributeUnit: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Index into string table. + public var attributeKeyStrindex: Int32 = 0 + + /// Index into string table. + public var unitStrindex: Int32 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// A pointer from a profile Sample to a trace Span. +/// Connects a profile sample to a trace span, identified by unique trace and span IDs. +public struct Opentelemetry_Proto_Profiles_V1development_Link: @unchecked Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// A unique identifier of a trace that this linked span is part of. The ID is a + /// 16-byte array. + public var traceID: Data = Data() + + /// A unique identifier for the linked span. The ID is an 8-byte array. + public var spanID: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// ValueType describes the type and units of a value, with an optional aggregation temporality. +public struct Opentelemetry_Proto_Profiles_V1development_ValueType: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Index into string table. + public var typeStrindex: Int32 = 0 + + /// Index into string table. + public var unitStrindex: Int32 = 0 + + public var aggregationTemporality: Opentelemetry_Proto_Profiles_V1development_AggregationTemporality = .unspecified + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Each Sample records values encountered in some program +/// context. The program context is typically a stack trace, perhaps +/// augmented with auxiliary information like the thread-id, some +/// indicator of a higher level request being handled etc. +public struct Opentelemetry_Proto_Profiles_V1development_Sample: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// locations_start_index along with locations_length refers to to a slice of locations in Profile.location_indices. + public var locationsStartIndex: Int32 = 0 + + /// locations_length along with locations_start_index refers to a slice of locations in Profile.location_indices. + /// Supersedes location_index. + public var locationsLength: Int32 = 0 + + /// The type and unit of each value is defined by the corresponding + /// entry in Profile.sample_type. All samples must have the same + /// number of values, the same as the length of Profile.sample_type. + /// When aggregating multiple samples into a single sample, the + /// result has a list of values that is the element-wise sum of the + /// lists of the originals. + public var value: [Int64] = [] + + /// References to attributes in Profile.attribute_table. [optional] + public var attributeIndices: [Int32] = [] + + /// Reference to link in Profile.link_table. [optional] + public var linkIndex: Int32 { + get {return _linkIndex ?? 0} + set {_linkIndex = newValue} + } + /// Returns true if `linkIndex` has been explicitly set. + public var hasLinkIndex: Bool {return self._linkIndex != nil} + /// Clears the value of `linkIndex`. Subsequent reads from it will return its default value. + public mutating func clearLinkIndex() {self._linkIndex = nil} + + /// Timestamps associated with Sample represented in nanoseconds. These timestamps are expected + /// to fall within the Profile's time range. [optional] + public var timestampsUnixNano: [UInt64] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _linkIndex: Int32? = nil +} + +/// Describes the mapping of a binary in memory, including its address range, +/// file offset, and metadata like build ID +public struct Opentelemetry_Proto_Profiles_V1development_Mapping: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Address at which the binary (or DLL) is loaded into memory. + public var memoryStart: UInt64 = 0 + + /// The limit of the address range occupied by this mapping. + public var memoryLimit: UInt64 = 0 + + /// Offset in the binary that corresponds to the first mapped address. + public var fileOffset: UInt64 = 0 + + /// The object this entry is loaded from. This can be a filename on + /// disk for the main binary and shared libraries, or virtual + /// abstractions like "[vdso]". + public var filenameStrindex: Int32 = 0 + + /// References to attributes in Profile.attribute_table. [optional] + public var attributeIndices: [Int32] = [] + + /// The following fields indicate the resolution of symbolic info. + public var hasFunctions_p: Bool = false + + public var hasFilenames_p: Bool = false + + public var hasLineNumbers_p: Bool = false + + public var hasInlineFrames_p: Bool = false + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Describes function and line table debug information. +public struct Opentelemetry_Proto_Profiles_V1development_Location: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Reference to mapping in Profile.mapping_table. + /// It can be unset if the mapping is unknown or not applicable for + /// this profile type. + public var mappingIndex: Int32 { + get {return _mappingIndex ?? 0} + set {_mappingIndex = newValue} + } + /// Returns true if `mappingIndex` has been explicitly set. + public var hasMappingIndex: Bool {return self._mappingIndex != nil} + /// Clears the value of `mappingIndex`. Subsequent reads from it will return its default value. + public mutating func clearMappingIndex() {self._mappingIndex = nil} + + /// The instruction address for this location, if available. It + /// should be within [Mapping.memory_start...Mapping.memory_limit] + /// for the corresponding mapping. A non-leaf address may be in the + /// middle of a call instruction. It is up to display tools to find + /// the beginning of the instruction if necessary. + public var address: UInt64 = 0 + + /// Multiple line indicates this location has inlined functions, + /// where the last entry represents the caller into which the + /// preceding entries were inlined. + /// + /// E.g., if memcpy() is inlined into printf: + /// line[0].function_name == "memcpy" + /// line[1].function_name == "printf" + public var line: [Opentelemetry_Proto_Profiles_V1development_Line] = [] + + /// Provides an indication that multiple symbols map to this location's + /// address, for example due to identical code folding by the linker. In that + /// case the line information above represents one of the multiple + /// symbols. This field must be recomputed when the symbolization state of the + /// profile changes. + public var isFolded: Bool = false + + /// References to attributes in Profile.attribute_table. [optional] + public var attributeIndices: [Int32] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _mappingIndex: Int32? = nil +} + +/// Details a specific line in a source code, linked to a function. +public struct Opentelemetry_Proto_Profiles_V1development_Line: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Reference to function in Profile.function_table. + public var functionIndex: Int32 = 0 + + /// Line number in source code. + public var line: Int64 = 0 + + /// Column number in source code. + public var column: Int64 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Describes a function, including its human-readable name, system name, +/// source file, and starting line number in the source. +public struct Opentelemetry_Proto_Profiles_V1development_Function: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Name of the function, in human-readable form if available. + public var nameStrindex: Int32 = 0 + + /// Name of the function, as identified by the system. + /// For instance, it can be a C++ mangled name. + public var systemNameStrindex: Int32 = 0 + + /// Source file containing the function. + public var filenameStrindex: Int32 = 0 + + /// Line number in source file. + public var startLine: Int64 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "opentelemetry.proto.profiles.v1development" + +extension Opentelemetry_Proto_Profiles_V1development_AggregationTemporality: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "AGGREGATION_TEMPORALITY_UNSPECIFIED"), + 1: .same(proto: "AGGREGATION_TEMPORALITY_DELTA"), + 2: .same(proto: "AGGREGATION_TEMPORALITY_CUMULATIVE"), + ] +} + +extension Opentelemetry_Proto_Profiles_V1development_ProfilesData: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ProfilesData" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "resource_profiles"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.resourceProfiles) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.resourceProfiles.isEmpty { + try visitor.visitRepeatedMessageField(value: self.resourceProfiles, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Opentelemetry_Proto_Profiles_V1development_ProfilesData, rhs: Opentelemetry_Proto_Profiles_V1development_ProfilesData) -> Bool { + if lhs.resourceProfiles != rhs.resourceProfiles {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Opentelemetry_Proto_Profiles_V1development_ResourceProfiles: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ResourceProfiles" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "resource"), + 2: .standard(proto: "scope_profiles"), + 3: .standard(proto: "schema_url"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._resource) }() + case 2: try { try decoder.decodeRepeatedMessageField(value: &self.scopeProfiles) }() + case 3: try { try decoder.decodeSingularStringField(value: &self.schemaURL) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._resource { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + if !self.scopeProfiles.isEmpty { + try visitor.visitRepeatedMessageField(value: self.scopeProfiles, fieldNumber: 2) + } + if !self.schemaURL.isEmpty { + try visitor.visitSingularStringField(value: self.schemaURL, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Opentelemetry_Proto_Profiles_V1development_ResourceProfiles, rhs: Opentelemetry_Proto_Profiles_V1development_ResourceProfiles) -> Bool { + if lhs._resource != rhs._resource {return false} + if lhs.scopeProfiles != rhs.scopeProfiles {return false} + if lhs.schemaURL != rhs.schemaURL {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Opentelemetry_Proto_Profiles_V1development_ScopeProfiles: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ScopeProfiles" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "scope"), + 2: .same(proto: "profiles"), + 3: .standard(proto: "schema_url"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._scope) }() + case 2: try { try decoder.decodeRepeatedMessageField(value: &self.profiles) }() + case 3: try { try decoder.decodeSingularStringField(value: &self.schemaURL) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._scope { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + if !self.profiles.isEmpty { + try visitor.visitRepeatedMessageField(value: self.profiles, fieldNumber: 2) + } + if !self.schemaURL.isEmpty { + try visitor.visitSingularStringField(value: self.schemaURL, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Opentelemetry_Proto_Profiles_V1development_ScopeProfiles, rhs: Opentelemetry_Proto_Profiles_V1development_ScopeProfiles) -> Bool { + if lhs._scope != rhs._scope {return false} + if lhs.profiles != rhs.profiles {return false} + if lhs.schemaURL != rhs.schemaURL {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Opentelemetry_Proto_Profiles_V1development_Profile: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".Profile" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "sample_type"), + 2: .same(proto: "sample"), + 3: .standard(proto: "mapping_table"), + 4: .standard(proto: "location_table"), + 5: .standard(proto: "location_indices"), + 6: .standard(proto: "function_table"), + 7: .standard(proto: "attribute_table"), + 8: .standard(proto: "attribute_units"), + 9: .standard(proto: "link_table"), + 10: .standard(proto: "string_table"), + 11: .standard(proto: "time_nanos"), + 12: .standard(proto: "duration_nanos"), + 13: .standard(proto: "period_type"), + 14: .same(proto: "period"), + 15: .standard(proto: "comment_strindices"), + 16: .standard(proto: "default_sample_type_strindex"), + 17: .standard(proto: "profile_id"), + 19: .standard(proto: "dropped_attributes_count"), + 20: .standard(proto: "original_payload_format"), + 21: .standard(proto: "original_payload"), + 22: .standard(proto: "attribute_indices"), + ] + + fileprivate class _StorageClass { + var _sampleType: [Opentelemetry_Proto_Profiles_V1development_ValueType] = [] + var _sample: [Opentelemetry_Proto_Profiles_V1development_Sample] = [] + var _mappingTable: [Opentelemetry_Proto_Profiles_V1development_Mapping] = [] + var _locationTable: [Opentelemetry_Proto_Profiles_V1development_Location] = [] + var _locationIndices: [Int32] = [] + var _functionTable: [Opentelemetry_Proto_Profiles_V1development_Function] = [] + var _attributeTable: [Opentelemetry_Proto_Common_V1_KeyValue] = [] + var _attributeUnits: [Opentelemetry_Proto_Profiles_V1development_AttributeUnit] = [] + var _linkTable: [Opentelemetry_Proto_Profiles_V1development_Link] = [] + var _stringTable: [String] = [] + var _timeNanos: Int64 = 0 + var _durationNanos: Int64 = 0 + var _periodType: Opentelemetry_Proto_Profiles_V1development_ValueType? = nil + var _period: Int64 = 0 + var _commentStrindices: [Int32] = [] + var _defaultSampleTypeStrindex: Int32 = 0 + var _profileID: Data = Data() + var _droppedAttributesCount: UInt32 = 0 + var _originalPayloadFormat: String = String() + var _originalPayload: Data = Data() + var _attributeIndices: [Int32] = [] + + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif + + private init() {} + + init(copying source: _StorageClass) { + _sampleType = source._sampleType + _sample = source._sample + _mappingTable = source._mappingTable + _locationTable = source._locationTable + _locationIndices = source._locationIndices + _functionTable = source._functionTable + _attributeTable = source._attributeTable + _attributeUnits = source._attributeUnits + _linkTable = source._linkTable + _stringTable = source._stringTable + _timeNanos = source._timeNanos + _durationNanos = source._durationNanos + _periodType = source._periodType + _period = source._period + _commentStrindices = source._commentStrindices + _defaultSampleTypeStrindex = source._defaultSampleTypeStrindex + _profileID = source._profileID + _droppedAttributesCount = source._droppedAttributesCount + _originalPayloadFormat = source._originalPayloadFormat + _originalPayload = source._originalPayload + _attributeIndices = source._attributeIndices + } + } + + fileprivate mutating func _uniqueStorage() -> _StorageClass { + if !isKnownUniquelyReferenced(&_storage) { + _storage = _StorageClass(copying: _storage) + } + return _storage + } + + public mutating func decodeMessage(decoder: inout D) throws { + _ = _uniqueStorage() + try withExtendedLifetime(_storage) { (_storage: _StorageClass) in + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &_storage._sampleType) }() + case 2: try { try decoder.decodeRepeatedMessageField(value: &_storage._sample) }() + case 3: try { try decoder.decodeRepeatedMessageField(value: &_storage._mappingTable) }() + case 4: try { try decoder.decodeRepeatedMessageField(value: &_storage._locationTable) }() + case 5: try { try decoder.decodeRepeatedInt32Field(value: &_storage._locationIndices) }() + case 6: try { try decoder.decodeRepeatedMessageField(value: &_storage._functionTable) }() + case 7: try { try decoder.decodeRepeatedMessageField(value: &_storage._attributeTable) }() + case 8: try { try decoder.decodeRepeatedMessageField(value: &_storage._attributeUnits) }() + case 9: try { try decoder.decodeRepeatedMessageField(value: &_storage._linkTable) }() + case 10: try { try decoder.decodeRepeatedStringField(value: &_storage._stringTable) }() + case 11: try { try decoder.decodeSingularInt64Field(value: &_storage._timeNanos) }() + case 12: try { try decoder.decodeSingularInt64Field(value: &_storage._durationNanos) }() + case 13: try { try decoder.decodeSingularMessageField(value: &_storage._periodType) }() + case 14: try { try decoder.decodeSingularInt64Field(value: &_storage._period) }() + case 15: try { try decoder.decodeRepeatedInt32Field(value: &_storage._commentStrindices) }() + case 16: try { try decoder.decodeSingularInt32Field(value: &_storage._defaultSampleTypeStrindex) }() + case 17: try { try decoder.decodeSingularBytesField(value: &_storage._profileID) }() + case 19: try { try decoder.decodeSingularUInt32Field(value: &_storage._droppedAttributesCount) }() + case 20: try { try decoder.decodeSingularStringField(value: &_storage._originalPayloadFormat) }() + case 21: try { try decoder.decodeSingularBytesField(value: &_storage._originalPayload) }() + case 22: try { try decoder.decodeRepeatedInt32Field(value: &_storage._attributeIndices) }() + default: break + } + } + } + } + + public func traverse(visitor: inout V) throws { + try withExtendedLifetime(_storage) { (_storage: _StorageClass) in + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if !_storage._sampleType.isEmpty { + try visitor.visitRepeatedMessageField(value: _storage._sampleType, fieldNumber: 1) + } + if !_storage._sample.isEmpty { + try visitor.visitRepeatedMessageField(value: _storage._sample, fieldNumber: 2) + } + if !_storage._mappingTable.isEmpty { + try visitor.visitRepeatedMessageField(value: _storage._mappingTable, fieldNumber: 3) + } + if !_storage._locationTable.isEmpty { + try visitor.visitRepeatedMessageField(value: _storage._locationTable, fieldNumber: 4) + } + if !_storage._locationIndices.isEmpty { + try visitor.visitPackedInt32Field(value: _storage._locationIndices, fieldNumber: 5) + } + if !_storage._functionTable.isEmpty { + try visitor.visitRepeatedMessageField(value: _storage._functionTable, fieldNumber: 6) + } + if !_storage._attributeTable.isEmpty { + try visitor.visitRepeatedMessageField(value: _storage._attributeTable, fieldNumber: 7) + } + if !_storage._attributeUnits.isEmpty { + try visitor.visitRepeatedMessageField(value: _storage._attributeUnits, fieldNumber: 8) + } + if !_storage._linkTable.isEmpty { + try visitor.visitRepeatedMessageField(value: _storage._linkTable, fieldNumber: 9) + } + if !_storage._stringTable.isEmpty { + try visitor.visitRepeatedStringField(value: _storage._stringTable, fieldNumber: 10) + } + if _storage._timeNanos != 0 { + try visitor.visitSingularInt64Field(value: _storage._timeNanos, fieldNumber: 11) + } + if _storage._durationNanos != 0 { + try visitor.visitSingularInt64Field(value: _storage._durationNanos, fieldNumber: 12) + } + try { if let v = _storage._periodType { + try visitor.visitSingularMessageField(value: v, fieldNumber: 13) + } }() + if _storage._period != 0 { + try visitor.visitSingularInt64Field(value: _storage._period, fieldNumber: 14) + } + if !_storage._commentStrindices.isEmpty { + try visitor.visitPackedInt32Field(value: _storage._commentStrindices, fieldNumber: 15) + } + if _storage._defaultSampleTypeStrindex != 0 { + try visitor.visitSingularInt32Field(value: _storage._defaultSampleTypeStrindex, fieldNumber: 16) + } + if !_storage._profileID.isEmpty { + try visitor.visitSingularBytesField(value: _storage._profileID, fieldNumber: 17) + } + if _storage._droppedAttributesCount != 0 { + try visitor.visitSingularUInt32Field(value: _storage._droppedAttributesCount, fieldNumber: 19) + } + if !_storage._originalPayloadFormat.isEmpty { + try visitor.visitSingularStringField(value: _storage._originalPayloadFormat, fieldNumber: 20) + } + if !_storage._originalPayload.isEmpty { + try visitor.visitSingularBytesField(value: _storage._originalPayload, fieldNumber: 21) + } + if !_storage._attributeIndices.isEmpty { + try visitor.visitPackedInt32Field(value: _storage._attributeIndices, fieldNumber: 22) + } + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Opentelemetry_Proto_Profiles_V1development_Profile, rhs: Opentelemetry_Proto_Profiles_V1development_Profile) -> Bool { + if lhs._storage !== rhs._storage { + let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in + let _storage = _args.0 + let rhs_storage = _args.1 + if _storage._sampleType != rhs_storage._sampleType {return false} + if _storage._sample != rhs_storage._sample {return false} + if _storage._mappingTable != rhs_storage._mappingTable {return false} + if _storage._locationTable != rhs_storage._locationTable {return false} + if _storage._locationIndices != rhs_storage._locationIndices {return false} + if _storage._functionTable != rhs_storage._functionTable {return false} + if _storage._attributeTable != rhs_storage._attributeTable {return false} + if _storage._attributeUnits != rhs_storage._attributeUnits {return false} + if _storage._linkTable != rhs_storage._linkTable {return false} + if _storage._stringTable != rhs_storage._stringTable {return false} + if _storage._timeNanos != rhs_storage._timeNanos {return false} + if _storage._durationNanos != rhs_storage._durationNanos {return false} + if _storage._periodType != rhs_storage._periodType {return false} + if _storage._period != rhs_storage._period {return false} + if _storage._commentStrindices != rhs_storage._commentStrindices {return false} + if _storage._defaultSampleTypeStrindex != rhs_storage._defaultSampleTypeStrindex {return false} + if _storage._profileID != rhs_storage._profileID {return false} + if _storage._droppedAttributesCount != rhs_storage._droppedAttributesCount {return false} + if _storage._originalPayloadFormat != rhs_storage._originalPayloadFormat {return false} + if _storage._originalPayload != rhs_storage._originalPayload {return false} + if _storage._attributeIndices != rhs_storage._attributeIndices {return false} + return true + } + if !storagesAreEqual {return false} + } + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Opentelemetry_Proto_Profiles_V1development_AttributeUnit: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".AttributeUnit" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "attribute_key_strindex"), + 2: .standard(proto: "unit_strindex"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularInt32Field(value: &self.attributeKeyStrindex) }() + case 2: try { try decoder.decodeSingularInt32Field(value: &self.unitStrindex) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if self.attributeKeyStrindex != 0 { + try visitor.visitSingularInt32Field(value: self.attributeKeyStrindex, fieldNumber: 1) + } + if self.unitStrindex != 0 { + try visitor.visitSingularInt32Field(value: self.unitStrindex, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Opentelemetry_Proto_Profiles_V1development_AttributeUnit, rhs: Opentelemetry_Proto_Profiles_V1development_AttributeUnit) -> Bool { + if lhs.attributeKeyStrindex != rhs.attributeKeyStrindex {return false} + if lhs.unitStrindex != rhs.unitStrindex {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Opentelemetry_Proto_Profiles_V1development_Link: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".Link" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "trace_id"), + 2: .standard(proto: "span_id"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.traceID) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.spanID) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.traceID.isEmpty { + try visitor.visitSingularBytesField(value: self.traceID, fieldNumber: 1) + } + if !self.spanID.isEmpty { + try visitor.visitSingularBytesField(value: self.spanID, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Opentelemetry_Proto_Profiles_V1development_Link, rhs: Opentelemetry_Proto_Profiles_V1development_Link) -> Bool { + if lhs.traceID != rhs.traceID {return false} + if lhs.spanID != rhs.spanID {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Opentelemetry_Proto_Profiles_V1development_ValueType: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ValueType" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "type_strindex"), + 2: .standard(proto: "unit_strindex"), + 3: .standard(proto: "aggregation_temporality"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularInt32Field(value: &self.typeStrindex) }() + case 2: try { try decoder.decodeSingularInt32Field(value: &self.unitStrindex) }() + case 3: try { try decoder.decodeSingularEnumField(value: &self.aggregationTemporality) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if self.typeStrindex != 0 { + try visitor.visitSingularInt32Field(value: self.typeStrindex, fieldNumber: 1) + } + if self.unitStrindex != 0 { + try visitor.visitSingularInt32Field(value: self.unitStrindex, fieldNumber: 2) + } + if self.aggregationTemporality != .unspecified { + try visitor.visitSingularEnumField(value: self.aggregationTemporality, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Opentelemetry_Proto_Profiles_V1development_ValueType, rhs: Opentelemetry_Proto_Profiles_V1development_ValueType) -> Bool { + if lhs.typeStrindex != rhs.typeStrindex {return false} + if lhs.unitStrindex != rhs.unitStrindex {return false} + if lhs.aggregationTemporality != rhs.aggregationTemporality {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Opentelemetry_Proto_Profiles_V1development_Sample: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".Sample" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "locations_start_index"), + 2: .standard(proto: "locations_length"), + 3: .same(proto: "value"), + 4: .standard(proto: "attribute_indices"), + 5: .standard(proto: "link_index"), + 6: .standard(proto: "timestamps_unix_nano"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularInt32Field(value: &self.locationsStartIndex) }() + case 2: try { try decoder.decodeSingularInt32Field(value: &self.locationsLength) }() + case 3: try { try decoder.decodeRepeatedInt64Field(value: &self.value) }() + case 4: try { try decoder.decodeRepeatedInt32Field(value: &self.attributeIndices) }() + case 5: try { try decoder.decodeSingularInt32Field(value: &self._linkIndex) }() + case 6: try { try decoder.decodeRepeatedUInt64Field(value: &self.timestampsUnixNano) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if self.locationsStartIndex != 0 { + try visitor.visitSingularInt32Field(value: self.locationsStartIndex, fieldNumber: 1) + } + if self.locationsLength != 0 { + try visitor.visitSingularInt32Field(value: self.locationsLength, fieldNumber: 2) + } + if !self.value.isEmpty { + try visitor.visitPackedInt64Field(value: self.value, fieldNumber: 3) + } + if !self.attributeIndices.isEmpty { + try visitor.visitPackedInt32Field(value: self.attributeIndices, fieldNumber: 4) + } + try { if let v = self._linkIndex { + try visitor.visitSingularInt32Field(value: v, fieldNumber: 5) + } }() + if !self.timestampsUnixNano.isEmpty { + try visitor.visitPackedUInt64Field(value: self.timestampsUnixNano, fieldNumber: 6) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Opentelemetry_Proto_Profiles_V1development_Sample, rhs: Opentelemetry_Proto_Profiles_V1development_Sample) -> Bool { + if lhs.locationsStartIndex != rhs.locationsStartIndex {return false} + if lhs.locationsLength != rhs.locationsLength {return false} + if lhs.value != rhs.value {return false} + if lhs.attributeIndices != rhs.attributeIndices {return false} + if lhs._linkIndex != rhs._linkIndex {return false} + if lhs.timestampsUnixNano != rhs.timestampsUnixNano {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Opentelemetry_Proto_Profiles_V1development_Mapping: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".Mapping" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "memory_start"), + 2: .standard(proto: "memory_limit"), + 3: .standard(proto: "file_offset"), + 4: .standard(proto: "filename_strindex"), + 5: .standard(proto: "attribute_indices"), + 6: .standard(proto: "has_functions"), + 7: .standard(proto: "has_filenames"), + 8: .standard(proto: "has_line_numbers"), + 9: .standard(proto: "has_inline_frames"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularUInt64Field(value: &self.memoryStart) }() + case 2: try { try decoder.decodeSingularUInt64Field(value: &self.memoryLimit) }() + case 3: try { try decoder.decodeSingularUInt64Field(value: &self.fileOffset) }() + case 4: try { try decoder.decodeSingularInt32Field(value: &self.filenameStrindex) }() + case 5: try { try decoder.decodeRepeatedInt32Field(value: &self.attributeIndices) }() + case 6: try { try decoder.decodeSingularBoolField(value: &self.hasFunctions_p) }() + case 7: try { try decoder.decodeSingularBoolField(value: &self.hasFilenames_p) }() + case 8: try { try decoder.decodeSingularBoolField(value: &self.hasLineNumbers_p) }() + case 9: try { try decoder.decodeSingularBoolField(value: &self.hasInlineFrames_p) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if self.memoryStart != 0 { + try visitor.visitSingularUInt64Field(value: self.memoryStart, fieldNumber: 1) + } + if self.memoryLimit != 0 { + try visitor.visitSingularUInt64Field(value: self.memoryLimit, fieldNumber: 2) + } + if self.fileOffset != 0 { + try visitor.visitSingularUInt64Field(value: self.fileOffset, fieldNumber: 3) + } + if self.filenameStrindex != 0 { + try visitor.visitSingularInt32Field(value: self.filenameStrindex, fieldNumber: 4) + } + if !self.attributeIndices.isEmpty { + try visitor.visitPackedInt32Field(value: self.attributeIndices, fieldNumber: 5) + } + if self.hasFunctions_p != false { + try visitor.visitSingularBoolField(value: self.hasFunctions_p, fieldNumber: 6) + } + if self.hasFilenames_p != false { + try visitor.visitSingularBoolField(value: self.hasFilenames_p, fieldNumber: 7) + } + if self.hasLineNumbers_p != false { + try visitor.visitSingularBoolField(value: self.hasLineNumbers_p, fieldNumber: 8) + } + if self.hasInlineFrames_p != false { + try visitor.visitSingularBoolField(value: self.hasInlineFrames_p, fieldNumber: 9) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Opentelemetry_Proto_Profiles_V1development_Mapping, rhs: Opentelemetry_Proto_Profiles_V1development_Mapping) -> Bool { + if lhs.memoryStart != rhs.memoryStart {return false} + if lhs.memoryLimit != rhs.memoryLimit {return false} + if lhs.fileOffset != rhs.fileOffset {return false} + if lhs.filenameStrindex != rhs.filenameStrindex {return false} + if lhs.attributeIndices != rhs.attributeIndices {return false} + if lhs.hasFunctions_p != rhs.hasFunctions_p {return false} + if lhs.hasFilenames_p != rhs.hasFilenames_p {return false} + if lhs.hasLineNumbers_p != rhs.hasLineNumbers_p {return false} + if lhs.hasInlineFrames_p != rhs.hasInlineFrames_p {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Opentelemetry_Proto_Profiles_V1development_Location: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".Location" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "mapping_index"), + 2: .same(proto: "address"), + 3: .same(proto: "line"), + 4: .standard(proto: "is_folded"), + 5: .standard(proto: "attribute_indices"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularInt32Field(value: &self._mappingIndex) }() + case 2: try { try decoder.decodeSingularUInt64Field(value: &self.address) }() + case 3: try { try decoder.decodeRepeatedMessageField(value: &self.line) }() + case 4: try { try decoder.decodeSingularBoolField(value: &self.isFolded) }() + case 5: try { try decoder.decodeRepeatedInt32Field(value: &self.attributeIndices) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._mappingIndex { + try visitor.visitSingularInt32Field(value: v, fieldNumber: 1) + } }() + if self.address != 0 { + try visitor.visitSingularUInt64Field(value: self.address, fieldNumber: 2) + } + if !self.line.isEmpty { + try visitor.visitRepeatedMessageField(value: self.line, fieldNumber: 3) + } + if self.isFolded != false { + try visitor.visitSingularBoolField(value: self.isFolded, fieldNumber: 4) + } + if !self.attributeIndices.isEmpty { + try visitor.visitPackedInt32Field(value: self.attributeIndices, fieldNumber: 5) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Opentelemetry_Proto_Profiles_V1development_Location, rhs: Opentelemetry_Proto_Profiles_V1development_Location) -> Bool { + if lhs._mappingIndex != rhs._mappingIndex {return false} + if lhs.address != rhs.address {return false} + if lhs.line != rhs.line {return false} + if lhs.isFolded != rhs.isFolded {return false} + if lhs.attributeIndices != rhs.attributeIndices {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Opentelemetry_Proto_Profiles_V1development_Line: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".Line" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "function_index"), + 2: .same(proto: "line"), + 3: .same(proto: "column"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularInt32Field(value: &self.functionIndex) }() + case 2: try { try decoder.decodeSingularInt64Field(value: &self.line) }() + case 3: try { try decoder.decodeSingularInt64Field(value: &self.column) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if self.functionIndex != 0 { + try visitor.visitSingularInt32Field(value: self.functionIndex, fieldNumber: 1) + } + if self.line != 0 { + try visitor.visitSingularInt64Field(value: self.line, fieldNumber: 2) + } + if self.column != 0 { + try visitor.visitSingularInt64Field(value: self.column, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Opentelemetry_Proto_Profiles_V1development_Line, rhs: Opentelemetry_Proto_Profiles_V1development_Line) -> Bool { + if lhs.functionIndex != rhs.functionIndex {return false} + if lhs.line != rhs.line {return false} + if lhs.column != rhs.column {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Opentelemetry_Proto_Profiles_V1development_Function: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".Function" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "name_strindex"), + 2: .standard(proto: "system_name_strindex"), + 3: .standard(proto: "filename_strindex"), + 4: .standard(proto: "start_line"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularInt32Field(value: &self.nameStrindex) }() + case 2: try { try decoder.decodeSingularInt32Field(value: &self.systemNameStrindex) }() + case 3: try { try decoder.decodeSingularInt32Field(value: &self.filenameStrindex) }() + case 4: try { try decoder.decodeSingularInt64Field(value: &self.startLine) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if self.nameStrindex != 0 { + try visitor.visitSingularInt32Field(value: self.nameStrindex, fieldNumber: 1) + } + if self.systemNameStrindex != 0 { + try visitor.visitSingularInt32Field(value: self.systemNameStrindex, fieldNumber: 2) + } + if self.filenameStrindex != 0 { + try visitor.visitSingularInt32Field(value: self.filenameStrindex, fieldNumber: 3) + } + if self.startLine != 0 { + try visitor.visitSingularInt64Field(value: self.startLine, fieldNumber: 4) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Opentelemetry_Proto_Profiles_V1development_Function, rhs: Opentelemetry_Proto_Profiles_V1development_Function) -> Bool { + if lhs.nameStrindex != rhs.nameStrindex {return false} + if lhs.systemNameStrindex != rhs.systemNameStrindex {return false} + if lhs.filenameStrindex != rhs.filenameStrindex {return false} + if lhs.startLine != rhs.startLine {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/profiles_service.pb.swift b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/profiles_service.pb.swift new file mode 100644 index 000000000..20976b2e0 --- /dev/null +++ b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/profiles_service.pb.swift @@ -0,0 +1,223 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// swiftlint:disable all +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: opentelemetry/proto/collector/profiles/v1development/profiles_service.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +// Copyright 2023, 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 +// +// http://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 SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +public struct Opentelemetry_Proto_Collector_Profiles_V1development_ExportProfilesServiceRequest: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// An array of ResourceProfiles. + /// For data coming from a single resource this array will typically contain one + /// element. Intermediary nodes (such as OpenTelemetry Collector) that receive + /// data from multiple origins typically batch the data before forwarding further and + /// in that case this array will contain multiple elements. + public var resourceProfiles: [Opentelemetry_Proto_Profiles_V1development_ResourceProfiles] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Opentelemetry_Proto_Collector_Profiles_V1development_ExportProfilesServiceResponse: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The details of a partially successful export request. + /// + /// If the request is only partially accepted + /// (i.e. when the server accepts only parts of the data and rejects the rest) + /// the server MUST initialize the `partial_success` field and MUST + /// set the `rejected_` with the number of items it rejected. + /// + /// Servers MAY also make use of the `partial_success` field to convey + /// warnings/suggestions to senders even when the request was fully accepted. + /// In such cases, the `rejected_` MUST have a value of `0` and + /// the `error_message` MUST be non-empty. + /// + /// A `partial_success` message with an empty value (rejected_ = 0 and + /// `error_message` = "") is equivalent to it not being set/present. Senders + /// SHOULD interpret it the same way as in the full success case. + public var partialSuccess: Opentelemetry_Proto_Collector_Profiles_V1development_ExportProfilesPartialSuccess { + get {return _partialSuccess ?? Opentelemetry_Proto_Collector_Profiles_V1development_ExportProfilesPartialSuccess()} + set {_partialSuccess = newValue} + } + /// Returns true if `partialSuccess` has been explicitly set. + public var hasPartialSuccess: Bool {return self._partialSuccess != nil} + /// Clears the value of `partialSuccess`. Subsequent reads from it will return its default value. + public mutating func clearPartialSuccess() {self._partialSuccess = nil} + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _partialSuccess: Opentelemetry_Proto_Collector_Profiles_V1development_ExportProfilesPartialSuccess? = nil +} + +public struct Opentelemetry_Proto_Collector_Profiles_V1development_ExportProfilesPartialSuccess: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The number of rejected profiles. + /// + /// A `rejected_` field holding a `0` value indicates that the + /// request was fully accepted. + public var rejectedProfiles: Int64 = 0 + + /// A developer-facing human-readable message in English. It should be used + /// either to explain why the server rejected parts of the data during a partial + /// success or to convey warnings/suggestions during a full success. The message + /// should offer guidance on how users can address such issues. + /// + /// error_message is an optional field. An error_message with an empty value + /// is equivalent to it not being set. + public var errorMessage: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "opentelemetry.proto.collector.profiles.v1development" + +extension Opentelemetry_Proto_Collector_Profiles_V1development_ExportProfilesServiceRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ExportProfilesServiceRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "resource_profiles"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.resourceProfiles) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.resourceProfiles.isEmpty { + try visitor.visitRepeatedMessageField(value: self.resourceProfiles, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Opentelemetry_Proto_Collector_Profiles_V1development_ExportProfilesServiceRequest, rhs: Opentelemetry_Proto_Collector_Profiles_V1development_ExportProfilesServiceRequest) -> Bool { + if lhs.resourceProfiles != rhs.resourceProfiles {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Opentelemetry_Proto_Collector_Profiles_V1development_ExportProfilesServiceResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ExportProfilesServiceResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "partial_success"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._partialSuccess) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._partialSuccess { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Opentelemetry_Proto_Collector_Profiles_V1development_ExportProfilesServiceResponse, rhs: Opentelemetry_Proto_Collector_Profiles_V1development_ExportProfilesServiceResponse) -> Bool { + if lhs._partialSuccess != rhs._partialSuccess {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Opentelemetry_Proto_Collector_Profiles_V1development_ExportProfilesPartialSuccess: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ExportProfilesPartialSuccess" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "rejected_profiles"), + 2: .standard(proto: "error_message"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularInt64Field(value: &self.rejectedProfiles) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.errorMessage) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if self.rejectedProfiles != 0 { + try visitor.visitSingularInt64Field(value: self.rejectedProfiles, fieldNumber: 1) + } + if !self.errorMessage.isEmpty { + try visitor.visitSingularStringField(value: self.errorMessage, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Opentelemetry_Proto_Collector_Profiles_V1development_ExportProfilesPartialSuccess, rhs: Opentelemetry_Proto_Collector_Profiles_V1development_ExportProfilesPartialSuccess) -> Bool { + if lhs.rejectedProfiles != rhs.rejectedProfiles {return false} + if lhs.errorMessage != rhs.errorMessage {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/resource.pb.swift b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/resource.pb.swift index 3c12514be..5198114b9 100644 --- a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/resource.pb.swift +++ b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/resource.pb.swift @@ -1,5 +1,6 @@ // DO NOT EDIT. // swift-format-ignore-file +// swiftlint:disable all // // Generated by the Swift generator plugin for the protocol buffer compiler. // Source: opentelemetry/proto/resource/v1/resource.proto @@ -21,7 +22,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -import Foundation import SwiftProtobuf // If the compiler emits an error on this type, it is because this file @@ -35,7 +35,7 @@ fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAP } /// Resource information. -public struct Opentelemetry_Proto_Resource_V1_Resource { +public struct Opentelemetry_Proto_Resource_V1_Resource: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -54,10 +54,6 @@ public struct Opentelemetry_Proto_Resource_V1_Resource { public init() {} } -#if swift(>=5.5) && canImport(_Concurrency) -extension Opentelemetry_Proto_Resource_V1_Resource: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - // MARK: - Code below here is support for the SwiftProtobuf runtime. fileprivate let _protobuf_package = "opentelemetry.proto.resource.v1" diff --git a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/trace.pb.swift b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/trace.pb.swift index b8959b95f..b130318b1 100644 --- a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/trace.pb.swift +++ b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/trace.pb.swift @@ -1,5 +1,6 @@ // DO NOT EDIT. // swift-format-ignore-file +// swiftlint:disable all // // Generated by the Swift generator plugin for the protocol buffer compiler. // Source: opentelemetry/proto/trace/v1/trace.proto @@ -34,6 +35,71 @@ fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAP typealias Version = _2 } +/// SpanFlags represents constants used to interpret the +/// Span.flags field, which is protobuf 'fixed32' type and is to +/// be used as bit-fields. Each non-zero value defined in this enum is +/// a bit-mask. To extract the bit-field, for example, use an +/// expression like: +/// +/// (span.flags & SPAN_FLAGS_TRACE_FLAGS_MASK) +/// +/// See https://www.w3.org/TR/trace-context-2/#trace-flags for the flag definitions. +/// +/// Note that Span flags were introduced in version 1.1 of the +/// OpenTelemetry protocol. Older Span producers do not set this +/// field, consequently consumers should not rely on the absence of a +/// particular flag bit to indicate the presence of a particular feature. +public enum Opentelemetry_Proto_Trace_V1_SpanFlags: SwiftProtobuf.Enum, Swift.CaseIterable { + public typealias RawValue = Int + + /// The zero value for the enum. Should not be used for comparisons. + /// Instead use bitwise "and" with the appropriate mask as shown above. + case doNotUse // = 0 + + /// Bits 0-7 are used for trace flags. + case traceFlagsMask // = 255 + + /// Bits 8 and 9 are used to indicate that the parent span or link span is remote. + /// Bit 8 (`HAS_IS_REMOTE`) indicates whether the value is known. + /// Bit 9 (`IS_REMOTE`) indicates whether the span or link is remote. + case contextHasIsRemoteMask // = 256 + case contextIsRemoteMask // = 512 + case UNRECOGNIZED(Int) + + public init() { + self = .doNotUse + } + + public init?(rawValue: Int) { + switch rawValue { + case 0: self = .doNotUse + case 255: self = .traceFlagsMask + case 256: self = .contextHasIsRemoteMask + case 512: self = .contextIsRemoteMask + default: self = .UNRECOGNIZED(rawValue) + } + } + + public var rawValue: Int { + switch self { + case .doNotUse: return 0 + case .traceFlagsMask: return 255 + case .contextHasIsRemoteMask: return 256 + case .contextIsRemoteMask: return 512 + case .UNRECOGNIZED(let i): return i + } + } + + // The compiler won't synthesize support with the UNRECOGNIZED case. + public static let allCases: [Opentelemetry_Proto_Trace_V1_SpanFlags] = [ + .doNotUse, + .traceFlagsMask, + .contextHasIsRemoteMask, + .contextIsRemoteMask, + ] + +} + /// TracesData represents the traces data that can be stored in a persistent storage, /// OR can be embedded by other protocols that transfer OTLP traces data but do /// not implement the OTLP protocol. @@ -44,7 +110,7 @@ fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAP /// /// When new fields are added into this message, the OTLP request MUST be updated /// as well. -public struct Opentelemetry_Proto_Trace_V1_TracesData { +public struct Opentelemetry_Proto_Trace_V1_TracesData: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -62,7 +128,7 @@ public struct Opentelemetry_Proto_Trace_V1_TracesData { } /// A collection of ScopeSpans from a Resource. -public struct Opentelemetry_Proto_Trace_V1_ResourceSpans { +public struct Opentelemetry_Proto_Trace_V1_ResourceSpans: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -81,6 +147,10 @@ public struct Opentelemetry_Proto_Trace_V1_ResourceSpans { /// A list of ScopeSpans that originate from a resource. public var scopeSpans: [Opentelemetry_Proto_Trace_V1_ScopeSpans] = [] + /// The Schema URL, if known. This is the identifier of the Schema that the resource data + /// is recorded in. Notably, the last part of the URL path is the version number of the + /// schema: http[s]://server[:port]/path/. To learn more about Schema URL see + /// https://opentelemetry.io/docs/specs/otel/schemas/#schema-url /// This schema_url applies to the data in the "resource" field. It does not apply /// to the data in the "scope_spans" field which have their own schema_url field. public var schemaURL: String = String() @@ -93,7 +163,7 @@ public struct Opentelemetry_Proto_Trace_V1_ResourceSpans { } /// A collection of Spans produced by an InstrumentationScope. -public struct Opentelemetry_Proto_Trace_V1_ScopeSpans { +public struct Opentelemetry_Proto_Trace_V1_ScopeSpans: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -113,6 +183,10 @@ public struct Opentelemetry_Proto_Trace_V1_ScopeSpans { /// A list of Spans that originate from an instrumentation scope. public var spans: [Opentelemetry_Proto_Trace_V1_Span] = [] + /// The Schema URL, if known. This is the identifier of the Schema that the span data + /// is recorded in. Notably, the last part of the URL path is the version number of the + /// schema: http[s]://server[:port]/path/. To learn more about Schema URL see + /// https://opentelemetry.io/docs/specs/otel/schemas/#schema-url /// This schema_url applies to all spans and span events in the "spans" field. public var schemaURL: String = String() @@ -126,7 +200,7 @@ public struct Opentelemetry_Proto_Trace_V1_ScopeSpans { /// A Span represents a single operation performed by a single component of the system. /// /// The next available field id is 17. -public struct Opentelemetry_Proto_Trace_V1_Span { +public struct Opentelemetry_Proto_Trace_V1_Span: @unchecked Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -137,7 +211,10 @@ public struct Opentelemetry_Proto_Trace_V1_Span { /// is zero-length and thus is also invalid). /// /// This field is required. - public var traceID: Data = Data() + public var traceID: Data { + get {return _storage._traceID} + set {_uniqueStorage()._traceID = newValue} + } /// A unique identifier for a span within a trace, assigned when the span /// is created. The ID is an 8-byte array. An ID with all zeroes OR of length @@ -145,16 +222,51 @@ public struct Opentelemetry_Proto_Trace_V1_Span { /// is zero-length and thus is also invalid). /// /// This field is required. - public var spanID: Data = Data() + public var spanID: Data { + get {return _storage._spanID} + set {_uniqueStorage()._spanID = newValue} + } /// trace_state conveys information about request position in multiple distributed tracing graphs. /// It is a trace_state in w3c-trace-context format: https://www.w3.org/TR/trace-context/#tracestate-header /// See also https://github.com/w3c/distributed-tracing for more details about this field. - public var traceState: String = String() + public var traceState: String { + get {return _storage._traceState} + set {_uniqueStorage()._traceState = newValue} + } /// The `span_id` of this span's parent span. If this is a root span, then this /// field must be empty. The ID is an 8-byte array. - public var parentSpanID: Data = Data() + public var parentSpanID: Data { + get {return _storage._parentSpanID} + set {_uniqueStorage()._parentSpanID = newValue} + } + + /// Flags, a bit field. + /// + /// Bits 0-7 (8 least significant bits) are the trace flags as defined in W3C Trace + /// Context specification. To read the 8-bit W3C trace flag, use + /// `flags & SPAN_FLAGS_TRACE_FLAGS_MASK`. + /// + /// See https://www.w3.org/TR/trace-context-2/#trace-flags for the flag definitions. + /// + /// Bits 8 and 9 represent the 3 states of whether a span's parent + /// is remote. The states are (unknown, is not remote, is remote). + /// To read whether the value is known, use `(flags & SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK) != 0`. + /// To read whether the span is remote, use `(flags & SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK) != 0`. + /// + /// When creating span messages, if the message is logically forwarded from another source + /// with an equivalent flags fields (i.e., usually another OTLP span message), the field SHOULD + /// be copied as-is. If creating from a source that does not have an equivalent flags field + /// (such as a runtime representation of an OpenTelemetry span), the high 22 bits MUST + /// be set to zero. + /// Readers MUST NOT assume that bits 10-31 (22 most significant bits) will be zero. + /// + /// [Optional]. + public var flags: UInt32 { + get {return _storage._flags} + set {_uniqueStorage()._flags = newValue} + } /// A description of the span's operation. /// @@ -167,12 +279,18 @@ public struct Opentelemetry_Proto_Trace_V1_Span { /// Empty value is equivalent to an unknown span name. /// /// This field is required. - public var name: String = String() + public var name: String { + get {return _storage._name} + set {_uniqueStorage()._name = newValue} + } /// Distinguishes between spans generated in a particular context. For example, /// two spans with the same name may be distinguished using `CLIENT` (caller) /// and `SERVER` (callee) to identify queueing latency associated with the span. - public var kind: Opentelemetry_Proto_Trace_V1_Span.SpanKind = .unspecified + public var kind: Opentelemetry_Proto_Trace_V1_Span.SpanKind { + get {return _storage._kind} + set {_uniqueStorage()._kind = newValue} + } /// start_time_unix_nano is the start time of the span. On the client side, this is the time /// kept by the local machine where the span execution starts. On the server side, this @@ -180,7 +298,10 @@ public struct Opentelemetry_Proto_Trace_V1_Span { /// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. /// /// This field is semantically required and it is expected that end_time >= start_time. - public var startTimeUnixNano: UInt64 = 0 + public var startTimeUnixNano: UInt64 { + get {return _storage._startTimeUnixNano} + set {_uniqueStorage()._startTimeUnixNano = newValue} + } /// end_time_unix_nano is the end time of the span. On the client side, this is the time /// kept by the local machine where the span execution ends. On the server side, this @@ -188,7 +309,10 @@ public struct Opentelemetry_Proto_Trace_V1_Span { /// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. /// /// This field is semantically required and it is expected that end_time >= start_time. - public var endTimeUnixNano: UInt64 = 0 + public var endTimeUnixNano: UInt64 { + get {return _storage._endTimeUnixNano} + set {_uniqueStorage()._endTimeUnixNano = newValue} + } /// attributes is a collection of key/value pairs. Note, global attributes /// like server name can be set using the resource API. Examples of attributes: @@ -202,44 +326,62 @@ public struct Opentelemetry_Proto_Trace_V1_Span { /// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/README.md#attribute /// Attribute keys MUST be unique (it is not allowed to have more than one /// attribute with the same key). - public var attributes: [Opentelemetry_Proto_Common_V1_KeyValue] = [] + public var attributes: [Opentelemetry_Proto_Common_V1_KeyValue] { + get {return _storage._attributes} + set {_uniqueStorage()._attributes = newValue} + } /// dropped_attributes_count is the number of attributes that were discarded. Attributes /// can be discarded because their keys are too long or because there are too many /// attributes. If this value is 0, then no attributes were dropped. - public var droppedAttributesCount: UInt32 = 0 + public var droppedAttributesCount: UInt32 { + get {return _storage._droppedAttributesCount} + set {_uniqueStorage()._droppedAttributesCount = newValue} + } /// events is a collection of Event items. - public var events: [Opentelemetry_Proto_Trace_V1_Span.Event] = [] + public var events: [Opentelemetry_Proto_Trace_V1_Span.Event] { + get {return _storage._events} + set {_uniqueStorage()._events = newValue} + } /// dropped_events_count is the number of dropped events. If the value is 0, then no /// events were dropped. - public var droppedEventsCount: UInt32 = 0 + public var droppedEventsCount: UInt32 { + get {return _storage._droppedEventsCount} + set {_uniqueStorage()._droppedEventsCount = newValue} + } /// links is a collection of Links, which are references from this span to a span /// in the same or different trace. - public var links: [Opentelemetry_Proto_Trace_V1_Span.Link] = [] + public var links: [Opentelemetry_Proto_Trace_V1_Span.Link] { + get {return _storage._links} + set {_uniqueStorage()._links = newValue} + } /// dropped_links_count is the number of dropped links after the maximum size was /// enforced. If this value is 0, then no links were dropped. - public var droppedLinksCount: UInt32 = 0 + public var droppedLinksCount: UInt32 { + get {return _storage._droppedLinksCount} + set {_uniqueStorage()._droppedLinksCount = newValue} + } /// An optional final status for this span. Semantically when Status isn't set, it means /// span's status code is unset, i.e. assume STATUS_CODE_UNSET (code = 0). public var status: Opentelemetry_Proto_Trace_V1_Status { - get {return _status ?? Opentelemetry_Proto_Trace_V1_Status()} - set {_status = newValue} + get {return _storage._status ?? Opentelemetry_Proto_Trace_V1_Status()} + set {_uniqueStorage()._status = newValue} } /// Returns true if `status` has been explicitly set. - public var hasStatus: Bool {return self._status != nil} + public var hasStatus: Bool {return _storage._status != nil} /// Clears the value of `status`. Subsequent reads from it will return its default value. - public mutating func clearStatus() {self._status = nil} + public mutating func clearStatus() {_uniqueStorage()._status = nil} public var unknownFields = SwiftProtobuf.UnknownStorage() /// SpanKind is the type of span. Can be used to specify additional relationships between spans /// in addition to a parent/child relationship. - public enum SpanKind: SwiftProtobuf.Enum { + public enum SpanKind: SwiftProtobuf.Enum, Swift.CaseIterable { public typealias RawValue = Int /// Unspecified. Do NOT use as default. @@ -297,11 +439,21 @@ public struct Opentelemetry_Proto_Trace_V1_Span { } } + // The compiler won't synthesize support with the UNRECOGNIZED case. + public static let allCases: [Opentelemetry_Proto_Trace_V1_Span.SpanKind] = [ + .unspecified, + .internal, + .server, + .client, + .producer, + .consumer, + ] + } /// Event is a time-stamped annotation of the span, consisting of user-supplied /// text description and key-value pairs. - public struct Event { + public struct Event: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -331,7 +483,7 @@ public struct Opentelemetry_Proto_Trace_V1_Span { /// different trace. For example, this can be used in batching operations, /// where a single batch handler processes multiple requests from different /// traces or when the handler receives a request from a different project. - public struct Link { + public struct Link: @unchecked Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -355,6 +507,25 @@ public struct Opentelemetry_Proto_Trace_V1_Span { /// then no attributes were dropped. public var droppedAttributesCount: UInt32 = 0 + /// Flags, a bit field. + /// + /// Bits 0-7 (8 least significant bits) are the trace flags as defined in W3C Trace + /// Context specification. To read the 8-bit W3C trace flag, use + /// `flags & SPAN_FLAGS_TRACE_FLAGS_MASK`. + /// + /// See https://www.w3.org/TR/trace-context-2/#trace-flags for the flag definitions. + /// + /// Bits 8 and 9 represent the 3 states of whether the link is remote. + /// The states are (unknown, is not remote, is remote). + /// To read whether the value is known, use `(flags & SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK) != 0`. + /// To read whether the link is remote, use `(flags & SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK) != 0`. + /// + /// Readers MUST NOT assume that bits 10-31 (22 most significant bits) will be zero. + /// When creating new spans, bits 10-31 (most-significant 22-bits) MUST be zero. + /// + /// [Optional]. + public var flags: UInt32 = 0 + public var unknownFields = SwiftProtobuf.UnknownStorage() public init() {} @@ -362,28 +533,12 @@ public struct Opentelemetry_Proto_Trace_V1_Span { public init() {} - fileprivate var _status: Opentelemetry_Proto_Trace_V1_Status? = nil + fileprivate var _storage = _StorageClass.defaultInstance } -#if swift(>=4.2) - -extension Opentelemetry_Proto_Trace_V1_Span.SpanKind: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - public static var allCases: [Opentelemetry_Proto_Trace_V1_Span.SpanKind] = [ - .unspecified, - .internal, - .server, - .client, - .producer, - .consumer, - ] -} - -#endif // swift(>=4.2) - /// The Status type defines a logical error model that is suitable for different /// programming environments, including REST APIs and RPC APIs. -public struct Opentelemetry_Proto_Trace_V1_Status { +public struct Opentelemetry_Proto_Trace_V1_Status: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -398,7 +553,7 @@ public struct Opentelemetry_Proto_Trace_V1_Status { /// For the semantics of status codes see /// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#set-status - public enum StatusCode: SwiftProtobuf.Enum { + public enum StatusCode: SwiftProtobuf.Enum, Swift.CaseIterable { public typealias RawValue = Int /// The default status. @@ -434,40 +589,31 @@ public struct Opentelemetry_Proto_Trace_V1_Status { } } + // The compiler won't synthesize support with the UNRECOGNIZED case. + public static let allCases: [Opentelemetry_Proto_Trace_V1_Status.StatusCode] = [ + .unset, + .ok, + .error, + ] + } public init() {} } -#if swift(>=4.2) - -extension Opentelemetry_Proto_Trace_V1_Status.StatusCode: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - public static var allCases: [Opentelemetry_Proto_Trace_V1_Status.StatusCode] = [ - .unset, - .ok, - .error, - ] -} - -#endif // swift(>=4.2) - -#if swift(>=5.5) && canImport(_Concurrency) -extension Opentelemetry_Proto_Trace_V1_TracesData: @unchecked Sendable {} -extension Opentelemetry_Proto_Trace_V1_ResourceSpans: @unchecked Sendable {} -extension Opentelemetry_Proto_Trace_V1_ScopeSpans: @unchecked Sendable {} -extension Opentelemetry_Proto_Trace_V1_Span: @unchecked Sendable {} -extension Opentelemetry_Proto_Trace_V1_Span.SpanKind: @unchecked Sendable {} -extension Opentelemetry_Proto_Trace_V1_Span.Event: @unchecked Sendable {} -extension Opentelemetry_Proto_Trace_V1_Span.Link: @unchecked Sendable {} -extension Opentelemetry_Proto_Trace_V1_Status: @unchecked Sendable {} -extension Opentelemetry_Proto_Trace_V1_Status.StatusCode: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - // MARK: - Code below here is support for the SwiftProtobuf runtime. fileprivate let _protobuf_package = "opentelemetry.proto.trace.v1" +extension Opentelemetry_Proto_Trace_V1_SpanFlags: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "SPAN_FLAGS_DO_NOT_USE"), + 255: .same(proto: "SPAN_FLAGS_TRACE_FLAGS_MASK"), + 256: .same(proto: "SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK"), + 512: .same(proto: "SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK"), + ] +} + extension Opentelemetry_Proto_Trace_V1_TracesData: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { public static let protoMessageName: String = _protobuf_package + ".TracesData" public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ @@ -603,6 +749,7 @@ extension Opentelemetry_Proto_Trace_V1_Span: SwiftProtobuf.Message, SwiftProtobu 2: .standard(proto: "span_id"), 3: .standard(proto: "trace_state"), 4: .standard(proto: "parent_span_id"), + 16: .same(proto: "flags"), 5: .same(proto: "name"), 6: .same(proto: "kind"), 7: .standard(proto: "start_time_unix_nano"), @@ -616,101 +763,176 @@ extension Opentelemetry_Proto_Trace_V1_Span: SwiftProtobuf.Message, SwiftProtobu 15: .same(proto: "status"), ] + fileprivate class _StorageClass { + var _traceID: Data = Data() + var _spanID: Data = Data() + var _traceState: String = String() + var _parentSpanID: Data = Data() + var _flags: UInt32 = 0 + var _name: String = String() + var _kind: Opentelemetry_Proto_Trace_V1_Span.SpanKind = .unspecified + var _startTimeUnixNano: UInt64 = 0 + var _endTimeUnixNano: UInt64 = 0 + var _attributes: [Opentelemetry_Proto_Common_V1_KeyValue] = [] + var _droppedAttributesCount: UInt32 = 0 + var _events: [Opentelemetry_Proto_Trace_V1_Span.Event] = [] + var _droppedEventsCount: UInt32 = 0 + var _links: [Opentelemetry_Proto_Trace_V1_Span.Link] = [] + var _droppedLinksCount: UInt32 = 0 + var _status: Opentelemetry_Proto_Trace_V1_Status? = nil + + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif + + private init() {} + + init(copying source: _StorageClass) { + _traceID = source._traceID + _spanID = source._spanID + _traceState = source._traceState + _parentSpanID = source._parentSpanID + _flags = source._flags + _name = source._name + _kind = source._kind + _startTimeUnixNano = source._startTimeUnixNano + _endTimeUnixNano = source._endTimeUnixNano + _attributes = source._attributes + _droppedAttributesCount = source._droppedAttributesCount + _events = source._events + _droppedEventsCount = source._droppedEventsCount + _links = source._links + _droppedLinksCount = source._droppedLinksCount + _status = source._status + } + } + + fileprivate mutating func _uniqueStorage() -> _StorageClass { + if !isKnownUniquelyReferenced(&_storage) { + _storage = _StorageClass(copying: _storage) + } + return _storage + } + public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.traceID) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self.spanID) }() - case 3: try { try decoder.decodeSingularStringField(value: &self.traceState) }() - case 4: try { try decoder.decodeSingularBytesField(value: &self.parentSpanID) }() - case 5: try { try decoder.decodeSingularStringField(value: &self.name) }() - case 6: try { try decoder.decodeSingularEnumField(value: &self.kind) }() - case 7: try { try decoder.decodeSingularFixed64Field(value: &self.startTimeUnixNano) }() - case 8: try { try decoder.decodeSingularFixed64Field(value: &self.endTimeUnixNano) }() - case 9: try { try decoder.decodeRepeatedMessageField(value: &self.attributes) }() - case 10: try { try decoder.decodeSingularUInt32Field(value: &self.droppedAttributesCount) }() - case 11: try { try decoder.decodeRepeatedMessageField(value: &self.events) }() - case 12: try { try decoder.decodeSingularUInt32Field(value: &self.droppedEventsCount) }() - case 13: try { try decoder.decodeRepeatedMessageField(value: &self.links) }() - case 14: try { try decoder.decodeSingularUInt32Field(value: &self.droppedLinksCount) }() - case 15: try { try decoder.decodeSingularMessageField(value: &self._status) }() - default: break + _ = _uniqueStorage() + try withExtendedLifetime(_storage) { (_storage: _StorageClass) in + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &_storage._traceID) }() + case 2: try { try decoder.decodeSingularBytesField(value: &_storage._spanID) }() + case 3: try { try decoder.decodeSingularStringField(value: &_storage._traceState) }() + case 4: try { try decoder.decodeSingularBytesField(value: &_storage._parentSpanID) }() + case 5: try { try decoder.decodeSingularStringField(value: &_storage._name) }() + case 6: try { try decoder.decodeSingularEnumField(value: &_storage._kind) }() + case 7: try { try decoder.decodeSingularFixed64Field(value: &_storage._startTimeUnixNano) }() + case 8: try { try decoder.decodeSingularFixed64Field(value: &_storage._endTimeUnixNano) }() + case 9: try { try decoder.decodeRepeatedMessageField(value: &_storage._attributes) }() + case 10: try { try decoder.decodeSingularUInt32Field(value: &_storage._droppedAttributesCount) }() + case 11: try { try decoder.decodeRepeatedMessageField(value: &_storage._events) }() + case 12: try { try decoder.decodeSingularUInt32Field(value: &_storage._droppedEventsCount) }() + case 13: try { try decoder.decodeRepeatedMessageField(value: &_storage._links) }() + case 14: try { try decoder.decodeSingularUInt32Field(value: &_storage._droppedLinksCount) }() + case 15: try { try decoder.decodeSingularMessageField(value: &_storage._status) }() + case 16: try { try decoder.decodeSingularFixed32Field(value: &_storage._flags) }() + default: break + } } } } public func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - if !self.traceID.isEmpty { - try visitor.visitSingularBytesField(value: self.traceID, fieldNumber: 1) - } - if !self.spanID.isEmpty { - try visitor.visitSingularBytesField(value: self.spanID, fieldNumber: 2) - } - if !self.traceState.isEmpty { - try visitor.visitSingularStringField(value: self.traceState, fieldNumber: 3) - } - if !self.parentSpanID.isEmpty { - try visitor.visitSingularBytesField(value: self.parentSpanID, fieldNumber: 4) - } - if !self.name.isEmpty { - try visitor.visitSingularStringField(value: self.name, fieldNumber: 5) - } - if self.kind != .unspecified { - try visitor.visitSingularEnumField(value: self.kind, fieldNumber: 6) - } - if self.startTimeUnixNano != 0 { - try visitor.visitSingularFixed64Field(value: self.startTimeUnixNano, fieldNumber: 7) - } - if self.endTimeUnixNano != 0 { - try visitor.visitSingularFixed64Field(value: self.endTimeUnixNano, fieldNumber: 8) - } - if !self.attributes.isEmpty { - try visitor.visitRepeatedMessageField(value: self.attributes, fieldNumber: 9) - } - if self.droppedAttributesCount != 0 { - try visitor.visitSingularUInt32Field(value: self.droppedAttributesCount, fieldNumber: 10) - } - if !self.events.isEmpty { - try visitor.visitRepeatedMessageField(value: self.events, fieldNumber: 11) - } - if self.droppedEventsCount != 0 { - try visitor.visitSingularUInt32Field(value: self.droppedEventsCount, fieldNumber: 12) - } - if !self.links.isEmpty { - try visitor.visitRepeatedMessageField(value: self.links, fieldNumber: 13) - } - if self.droppedLinksCount != 0 { - try visitor.visitSingularUInt32Field(value: self.droppedLinksCount, fieldNumber: 14) + try withExtendedLifetime(_storage) { (_storage: _StorageClass) in + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if !_storage._traceID.isEmpty { + try visitor.visitSingularBytesField(value: _storage._traceID, fieldNumber: 1) + } + if !_storage._spanID.isEmpty { + try visitor.visitSingularBytesField(value: _storage._spanID, fieldNumber: 2) + } + if !_storage._traceState.isEmpty { + try visitor.visitSingularStringField(value: _storage._traceState, fieldNumber: 3) + } + if !_storage._parentSpanID.isEmpty { + try visitor.visitSingularBytesField(value: _storage._parentSpanID, fieldNumber: 4) + } + if !_storage._name.isEmpty { + try visitor.visitSingularStringField(value: _storage._name, fieldNumber: 5) + } + if _storage._kind != .unspecified { + try visitor.visitSingularEnumField(value: _storage._kind, fieldNumber: 6) + } + if _storage._startTimeUnixNano != 0 { + try visitor.visitSingularFixed64Field(value: _storage._startTimeUnixNano, fieldNumber: 7) + } + if _storage._endTimeUnixNano != 0 { + try visitor.visitSingularFixed64Field(value: _storage._endTimeUnixNano, fieldNumber: 8) + } + if !_storage._attributes.isEmpty { + try visitor.visitRepeatedMessageField(value: _storage._attributes, fieldNumber: 9) + } + if _storage._droppedAttributesCount != 0 { + try visitor.visitSingularUInt32Field(value: _storage._droppedAttributesCount, fieldNumber: 10) + } + if !_storage._events.isEmpty { + try visitor.visitRepeatedMessageField(value: _storage._events, fieldNumber: 11) + } + if _storage._droppedEventsCount != 0 { + try visitor.visitSingularUInt32Field(value: _storage._droppedEventsCount, fieldNumber: 12) + } + if !_storage._links.isEmpty { + try visitor.visitRepeatedMessageField(value: _storage._links, fieldNumber: 13) + } + if _storage._droppedLinksCount != 0 { + try visitor.visitSingularUInt32Field(value: _storage._droppedLinksCount, fieldNumber: 14) + } + try { if let v = _storage._status { + try visitor.visitSingularMessageField(value: v, fieldNumber: 15) + } }() + if _storage._flags != 0 { + try visitor.visitSingularFixed32Field(value: _storage._flags, fieldNumber: 16) + } } - try { if let v = self._status { - try visitor.visitSingularMessageField(value: v, fieldNumber: 15) - } }() try unknownFields.traverse(visitor: &visitor) } public static func ==(lhs: Opentelemetry_Proto_Trace_V1_Span, rhs: Opentelemetry_Proto_Trace_V1_Span) -> Bool { - if lhs.traceID != rhs.traceID {return false} - if lhs.spanID != rhs.spanID {return false} - if lhs.traceState != rhs.traceState {return false} - if lhs.parentSpanID != rhs.parentSpanID {return false} - if lhs.name != rhs.name {return false} - if lhs.kind != rhs.kind {return false} - if lhs.startTimeUnixNano != rhs.startTimeUnixNano {return false} - if lhs.endTimeUnixNano != rhs.endTimeUnixNano {return false} - if lhs.attributes != rhs.attributes {return false} - if lhs.droppedAttributesCount != rhs.droppedAttributesCount {return false} - if lhs.events != rhs.events {return false} - if lhs.droppedEventsCount != rhs.droppedEventsCount {return false} - if lhs.links != rhs.links {return false} - if lhs.droppedLinksCount != rhs.droppedLinksCount {return false} - if lhs._status != rhs._status {return false} + if lhs._storage !== rhs._storage { + let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in + let _storage = _args.0 + let rhs_storage = _args.1 + if _storage._traceID != rhs_storage._traceID {return false} + if _storage._spanID != rhs_storage._spanID {return false} + if _storage._traceState != rhs_storage._traceState {return false} + if _storage._parentSpanID != rhs_storage._parentSpanID {return false} + if _storage._flags != rhs_storage._flags {return false} + if _storage._name != rhs_storage._name {return false} + if _storage._kind != rhs_storage._kind {return false} + if _storage._startTimeUnixNano != rhs_storage._startTimeUnixNano {return false} + if _storage._endTimeUnixNano != rhs_storage._endTimeUnixNano {return false} + if _storage._attributes != rhs_storage._attributes {return false} + if _storage._droppedAttributesCount != rhs_storage._droppedAttributesCount {return false} + if _storage._events != rhs_storage._events {return false} + if _storage._droppedEventsCount != rhs_storage._droppedEventsCount {return false} + if _storage._links != rhs_storage._links {return false} + if _storage._droppedLinksCount != rhs_storage._droppedLinksCount {return false} + if _storage._status != rhs_storage._status {return false} + return true + } + if !storagesAreEqual {return false} + } if lhs.unknownFields != rhs.unknownFields {return false} return true } @@ -785,6 +1007,7 @@ extension Opentelemetry_Proto_Trace_V1_Span.Link: SwiftProtobuf.Message, SwiftPr 3: .standard(proto: "trace_state"), 4: .same(proto: "attributes"), 5: .standard(proto: "dropped_attributes_count"), + 6: .same(proto: "flags"), ] public mutating func decodeMessage(decoder: inout D) throws { @@ -798,6 +1021,7 @@ extension Opentelemetry_Proto_Trace_V1_Span.Link: SwiftProtobuf.Message, SwiftPr case 3: try { try decoder.decodeSingularStringField(value: &self.traceState) }() case 4: try { try decoder.decodeRepeatedMessageField(value: &self.attributes) }() case 5: try { try decoder.decodeSingularUInt32Field(value: &self.droppedAttributesCount) }() + case 6: try { try decoder.decodeSingularFixed32Field(value: &self.flags) }() default: break } } @@ -819,6 +1043,9 @@ extension Opentelemetry_Proto_Trace_V1_Span.Link: SwiftProtobuf.Message, SwiftPr if self.droppedAttributesCount != 0 { try visitor.visitSingularUInt32Field(value: self.droppedAttributesCount, fieldNumber: 5) } + if self.flags != 0 { + try visitor.visitSingularFixed32Field(value: self.flags, fieldNumber: 6) + } try unknownFields.traverse(visitor: &visitor) } @@ -828,6 +1055,7 @@ extension Opentelemetry_Proto_Trace_V1_Span.Link: SwiftProtobuf.Message, SwiftPr if lhs.traceState != rhs.traceState {return false} if lhs.attributes != rhs.attributes {return false} if lhs.droppedAttributesCount != rhs.droppedAttributesCount {return false} + if lhs.flags != rhs.flags {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } diff --git a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/trace_service.pb.swift b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/trace_service.pb.swift index 2cf6fec16..3be4943bb 100644 --- a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/trace_service.pb.swift +++ b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/trace_service.pb.swift @@ -1,5 +1,6 @@ // DO NOT EDIT. // swift-format-ignore-file +// swiftlint:disable all // // Generated by the Swift generator plugin for the protocol buffer compiler. // Source: opentelemetry/proto/collector/trace/v1/trace_service.proto @@ -21,7 +22,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -import Foundation import SwiftProtobuf // If the compiler emits an error on this type, it is because this file @@ -34,7 +34,7 @@ fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAP typealias Version = _2 } -public struct Opentelemetry_Proto_Collector_Trace_V1_ExportTraceServiceRequest { +public struct Opentelemetry_Proto_Collector_Trace_V1_ExportTraceServiceRequest: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -51,7 +51,7 @@ public struct Opentelemetry_Proto_Collector_Trace_V1_ExportTraceServiceRequest { public init() {} } -public struct Opentelemetry_Proto_Collector_Trace_V1_ExportTraceServiceResponse { +public struct Opentelemetry_Proto_Collector_Trace_V1_ExportTraceServiceResponse: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -87,7 +87,7 @@ public struct Opentelemetry_Proto_Collector_Trace_V1_ExportTraceServiceResponse fileprivate var _partialSuccess: Opentelemetry_Proto_Collector_Trace_V1_ExportTracePartialSuccess? = nil } -public struct Opentelemetry_Proto_Collector_Trace_V1_ExportTracePartialSuccess { +public struct Opentelemetry_Proto_Collector_Trace_V1_ExportTracePartialSuccess: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -112,12 +112,6 @@ public struct Opentelemetry_Proto_Collector_Trace_V1_ExportTracePartialSuccess { public init() {} } -#if swift(>=5.5) && canImport(_Concurrency) -extension Opentelemetry_Proto_Collector_Trace_V1_ExportTraceServiceRequest: @unchecked Sendable {} -extension Opentelemetry_Proto_Collector_Trace_V1_ExportTraceServiceResponse: @unchecked Sendable {} -extension Opentelemetry_Proto_Collector_Trace_V1_ExportTracePartialSuccess: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - // MARK: - Code below here is support for the SwiftProtobuf runtime. fileprivate let _protobuf_package = "opentelemetry.proto.collector.trace.v1" diff --git a/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/logs_service.grpc.swift b/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/logs_service.grpc.swift index 00ae6feb6..708d7a118 100644 --- a/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/logs_service.grpc.swift +++ b/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/logs_service.grpc.swift @@ -5,22 +5,6 @@ // Generated by the protocol buffer compiler. // Source: opentelemetry/proto/collector/logs/v1/logs_service.proto // - -// -// Copyright 2018, gRPC Authors All rights reserved. -// -// 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 -// -// http://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 GRPC import NIO import NIOConcurrencyHelpers @@ -204,7 +188,7 @@ public enum Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClientMetadata { name: "LogsService", fullName: "opentelemetry.proto.collector.logs.v1.LogsService", methods: [ - Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClientMetadata.Methods.export + Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClientMetadata.Methods.export, ] ) @@ -321,7 +305,7 @@ public enum Opentelemetry_Proto_Collector_Logs_V1_LogsServiceServerMetadata { name: "LogsService", fullName: "opentelemetry.proto.collector.logs.v1.LogsService", methods: [ - Opentelemetry_Proto_Collector_Logs_V1_LogsServiceServerMetadata.Methods.export + Opentelemetry_Proto_Collector_Logs_V1_LogsServiceServerMetadata.Methods.export, ] ) diff --git a/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/metrics_service.grpc.swift b/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/metrics_service.grpc.swift index 4da928a68..d048f3b0a 100644 --- a/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/metrics_service.grpc.swift +++ b/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/metrics_service.grpc.swift @@ -5,22 +5,6 @@ // Generated by the protocol buffer compiler. // Source: opentelemetry/proto/collector/metrics/v1/metrics_service.proto // - -// -// Copyright 2018, gRPC Authors All rights reserved. -// -// 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 -// -// http://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 GRPC import NIO import NIOConcurrencyHelpers @@ -204,7 +188,7 @@ public enum Opentelemetry_Proto_Collector_Metrics_V1_MetricsServiceClientMetadat name: "MetricsService", fullName: "opentelemetry.proto.collector.metrics.v1.MetricsService", methods: [ - Opentelemetry_Proto_Collector_Metrics_V1_MetricsServiceClientMetadata.Methods.export + Opentelemetry_Proto_Collector_Metrics_V1_MetricsServiceClientMetadata.Methods.export, ] ) @@ -321,7 +305,7 @@ public enum Opentelemetry_Proto_Collector_Metrics_V1_MetricsServiceServerMetadat name: "MetricsService", fullName: "opentelemetry.proto.collector.metrics.v1.MetricsService", methods: [ - Opentelemetry_Proto_Collector_Metrics_V1_MetricsServiceServerMetadata.Methods.export + Opentelemetry_Proto_Collector_Metrics_V1_MetricsServiceServerMetadata.Methods.export, ] ) diff --git a/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/profiles_service.grpc.swift b/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/profiles_service.grpc.swift new file mode 100644 index 000000000..e4656664c --- /dev/null +++ b/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/profiles_service.grpc.swift @@ -0,0 +1,315 @@ +// +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the protocol buffer compiler. +// Source: opentelemetry/proto/collector/profiles/v1development/profiles_service.proto +// +import GRPC +import NIO +import NIOConcurrencyHelpers +import SwiftProtobuf +import OpenTelemetryProtocolExporterCommon + +/// Service that can be used to push profiles between one Application instrumented with +/// OpenTelemetry and a collector, or between a collector and a central collector. +/// +/// Usage: instantiate `Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceClient`, then call methods of this protocol to make API calls. +public protocol Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceClientProtocol: GRPCClient { + var serviceName: String { get } + var interceptors: Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceClientInterceptorFactoryProtocol? { get } + + func export( + _ request: Opentelemetry_Proto_Collector_Profiles_V1development_ExportProfilesServiceRequest, + callOptions: CallOptions? + ) -> UnaryCall +} + +extension Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceClientProtocol { + public var serviceName: String { + return "opentelemetry.proto.collector.profiles.v1development.ProfilesService" + } + + /// For performance reasons, it is recommended to keep this RPC + /// alive for the entire life of the application. + /// + /// - Parameters: + /// - request: Request to send to Export. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func export( + _ request: Opentelemetry_Proto_Collector_Profiles_V1development_ExportProfilesServiceRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return self.makeUnaryCall( + path: Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceClientMetadata.Methods.export.path, + request: request, + callOptions: callOptions ?? self.defaultCallOptions, + interceptors: self.interceptors?.makeExportInterceptors() ?? [] + ) + } +} + +@available(*, deprecated) +extension Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceClient: @unchecked Sendable {} + +@available(*, deprecated, renamed: "Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceNIOClient") +public final class Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceClient: Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceClientProtocol { + private let lock = Lock() + private var _defaultCallOptions: CallOptions + private var _interceptors: Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceClientInterceptorFactoryProtocol? + public let channel: GRPCChannel + public var defaultCallOptions: CallOptions { + get { self.lock.withLock { return self._defaultCallOptions } } + set { self.lock.withLockVoid { self._defaultCallOptions = newValue } } + } + public var interceptors: Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceClientInterceptorFactoryProtocol? { + get { self.lock.withLock { return self._interceptors } } + set { self.lock.withLockVoid { self._interceptors = newValue } } + } + + /// Creates a client for the opentelemetry.proto.collector.profiles.v1development.ProfilesService service. + /// + /// - Parameters: + /// - channel: `GRPCChannel` to the service host. + /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them. + /// - interceptors: A factory providing interceptors for each RPC. + public init( + channel: GRPCChannel, + defaultCallOptions: CallOptions = CallOptions(), + interceptors: Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceClientInterceptorFactoryProtocol? = nil + ) { + self.channel = channel + self._defaultCallOptions = defaultCallOptions + self._interceptors = interceptors + } +} + +public struct Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceNIOClient: Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceClientProtocol { + public var channel: GRPCChannel + public var defaultCallOptions: CallOptions + public var interceptors: Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceClientInterceptorFactoryProtocol? + + /// Creates a client for the opentelemetry.proto.collector.profiles.v1development.ProfilesService service. + /// + /// - Parameters: + /// - channel: `GRPCChannel` to the service host. + /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them. + /// - interceptors: A factory providing interceptors for each RPC. + public init( + channel: GRPCChannel, + defaultCallOptions: CallOptions = CallOptions(), + interceptors: Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceClientInterceptorFactoryProtocol? = nil + ) { + self.channel = channel + self.defaultCallOptions = defaultCallOptions + self.interceptors = interceptors + } +} + +/// Service that can be used to push profiles between one Application instrumented with +/// OpenTelemetry and a collector, or between a collector and a central collector. +@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) +public protocol Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceAsyncClientProtocol: GRPCClient { + static var serviceDescriptor: GRPCServiceDescriptor { get } + var interceptors: Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceClientInterceptorFactoryProtocol? { get } + + func makeExportCall( + _ request: Opentelemetry_Proto_Collector_Profiles_V1development_ExportProfilesServiceRequest, + callOptions: CallOptions? + ) -> GRPCAsyncUnaryCall +} + +@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) +extension Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceAsyncClientProtocol { + public static var serviceDescriptor: GRPCServiceDescriptor { + return Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceClientMetadata.serviceDescriptor + } + + public var interceptors: Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceClientInterceptorFactoryProtocol? { + return nil + } + + public func makeExportCall( + _ request: Opentelemetry_Proto_Collector_Profiles_V1development_ExportProfilesServiceRequest, + callOptions: CallOptions? = nil + ) -> GRPCAsyncUnaryCall { + return self.makeAsyncUnaryCall( + path: Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceClientMetadata.Methods.export.path, + request: request, + callOptions: callOptions ?? self.defaultCallOptions, + interceptors: self.interceptors?.makeExportInterceptors() ?? [] + ) + } +} + +@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) +extension Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceAsyncClientProtocol { + public func export( + _ request: Opentelemetry_Proto_Collector_Profiles_V1development_ExportProfilesServiceRequest, + callOptions: CallOptions? = nil + ) async throws -> Opentelemetry_Proto_Collector_Profiles_V1development_ExportProfilesServiceResponse { + return try await self.performAsyncUnaryCall( + path: Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceClientMetadata.Methods.export.path, + request: request, + callOptions: callOptions ?? self.defaultCallOptions, + interceptors: self.interceptors?.makeExportInterceptors() ?? [] + ) + } +} + +@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) +public struct Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceAsyncClient: Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceAsyncClientProtocol { + public var channel: GRPCChannel + public var defaultCallOptions: CallOptions + public var interceptors: Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceClientInterceptorFactoryProtocol? + + public init( + channel: GRPCChannel, + defaultCallOptions: CallOptions = CallOptions(), + interceptors: Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceClientInterceptorFactoryProtocol? = nil + ) { + self.channel = channel + self.defaultCallOptions = defaultCallOptions + self.interceptors = interceptors + } +} + +public protocol Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceClientInterceptorFactoryProtocol: Sendable { + + /// - Returns: Interceptors to use when invoking 'export'. + func makeExportInterceptors() -> [ClientInterceptor] +} + +public enum Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceClientMetadata { + public static let serviceDescriptor = GRPCServiceDescriptor( + name: "ProfilesService", + fullName: "opentelemetry.proto.collector.profiles.v1development.ProfilesService", + methods: [ + Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceClientMetadata.Methods.export, + ] + ) + + public enum Methods { + public static let export = GRPCMethodDescriptor( + name: "Export", + path: "/opentelemetry.proto.collector.profiles.v1development.ProfilesService/Export", + type: GRPCCallType.unary + ) + } +} + +/// Service that can be used to push profiles between one Application instrumented with +/// OpenTelemetry and a collector, or between a collector and a central collector. +/// +/// To build a server, implement a class that conforms to this protocol. +public protocol Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceProvider: CallHandlerProvider { + var interceptors: Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceServerInterceptorFactoryProtocol? { get } + + /// For performance reasons, it is recommended to keep this RPC + /// alive for the entire life of the application. + func export(request: Opentelemetry_Proto_Collector_Profiles_V1development_ExportProfilesServiceRequest, context: StatusOnlyCallContext) -> EventLoopFuture +} + +extension Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceProvider { + public var serviceName: Substring { + return Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceServerMetadata.serviceDescriptor.fullName[...] + } + + /// Determines, calls and returns the appropriate request handler, depending on the request's method. + /// Returns nil for methods not handled by this service. + public func handle( + method name: Substring, + context: CallHandlerContext + ) -> GRPCServerHandlerProtocol? { + switch name { + case "Export": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: self.interceptors?.makeExportInterceptors() ?? [], + userFunction: self.export(request:context:) + ) + + default: + return nil + } + } +} + +/// Service that can be used to push profiles between one Application instrumented with +/// OpenTelemetry and a collector, or between a collector and a central collector. +/// +/// To implement a server, implement an object which conforms to this protocol. +@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) +public protocol Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceAsyncProvider: CallHandlerProvider, Sendable { + static var serviceDescriptor: GRPCServiceDescriptor { get } + var interceptors: Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceServerInterceptorFactoryProtocol? { get } + + /// For performance reasons, it is recommended to keep this RPC + /// alive for the entire life of the application. + func export( + request: Opentelemetry_Proto_Collector_Profiles_V1development_ExportProfilesServiceRequest, + context: GRPCAsyncServerCallContext + ) async throws -> Opentelemetry_Proto_Collector_Profiles_V1development_ExportProfilesServiceResponse +} + +@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) +extension Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceAsyncProvider { + public static var serviceDescriptor: GRPCServiceDescriptor { + return Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceServerMetadata.serviceDescriptor + } + + public var serviceName: Substring { + return Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceServerMetadata.serviceDescriptor.fullName[...] + } + + public var interceptors: Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceServerInterceptorFactoryProtocol? { + return nil + } + + public func handle( + method name: Substring, + context: CallHandlerContext + ) -> GRPCServerHandlerProtocol? { + switch name { + case "Export": + return GRPCAsyncServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: self.interceptors?.makeExportInterceptors() ?? [], + wrapping: { try await self.export(request: $0, context: $1) } + ) + + default: + return nil + } + } +} + +public protocol Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceServerInterceptorFactoryProtocol: Sendable { + + /// - Returns: Interceptors to use when handling 'export'. + /// Defaults to calling `self.makeInterceptors()`. + func makeExportInterceptors() -> [ServerInterceptor] +} + +public enum Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceServerMetadata { + public static let serviceDescriptor = GRPCServiceDescriptor( + name: "ProfilesService", + fullName: "opentelemetry.proto.collector.profiles.v1development.ProfilesService", + methods: [ + Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceServerMetadata.Methods.export, + ] + ) + + public enum Methods { + public static let export = GRPCMethodDescriptor( + name: "Export", + path: "/opentelemetry.proto.collector.profiles.v1development.ProfilesService/Export", + type: GRPCCallType.unary + ) + } +} diff --git a/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/trace_service.grpc.swift b/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/trace_service.grpc.swift index e12fca0f2..2ba3bb236 100644 --- a/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/trace_service.grpc.swift +++ b/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/trace_service.grpc.swift @@ -5,22 +5,6 @@ // Generated by the protocol buffer compiler. // Source: opentelemetry/proto/collector/trace/v1/trace_service.proto // - -// -// Copyright 2018, gRPC Authors All rights reserved. -// -// 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 -// -// http://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 GRPC import NIO import NIOConcurrencyHelpers @@ -204,7 +188,7 @@ public enum Opentelemetry_Proto_Collector_Trace_V1_TraceServiceClientMetadata { name: "TraceService", fullName: "opentelemetry.proto.collector.trace.v1.TraceService", methods: [ - Opentelemetry_Proto_Collector_Trace_V1_TraceServiceClientMetadata.Methods.export + Opentelemetry_Proto_Collector_Trace_V1_TraceServiceClientMetadata.Methods.export, ] ) @@ -321,7 +305,7 @@ public enum Opentelemetry_Proto_Collector_Trace_V1_TraceServiceServerMetadata { name: "TraceService", fullName: "opentelemetry.proto.collector.trace.v1.TraceService", methods: [ - Opentelemetry_Proto_Collector_Trace_V1_TraceServiceServerMetadata.Methods.export + Opentelemetry_Proto_Collector_Trace_V1_TraceServiceServerMetadata.Methods.export, ] ) From 9bb87de8b1c5cb8711353700c10d94461d0d7f18 Mon Sep 17 00:00:00 2001 From: Bryce Buchanan Date: Wed, 30 Apr 2025 15:03:45 -0700 Subject: [PATCH 2/3] added entity, entity builder, and updated Resource with entites --- .../OpenTelemetrySdk/Resources/Entity.swift | 25 +++++++++ .../Resources/EntityBuilder.swift | 32 +++++++++++ .../OpenTelemetrySdk/Resources/Resource.swift | 53 +++++++++++++++++-- 3 files changed, 106 insertions(+), 4 deletions(-) create mode 100644 Sources/OpenTelemetrySdk/Resources/Entity.swift create mode 100644 Sources/OpenTelemetrySdk/Resources/EntityBuilder.swift diff --git a/Sources/OpenTelemetrySdk/Resources/Entity.swift b/Sources/OpenTelemetrySdk/Resources/Entity.swift new file mode 100644 index 000000000..8db058f53 --- /dev/null +++ b/Sources/OpenTelemetrySdk/Resources/Entity.swift @@ -0,0 +1,25 @@ +// +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 +// + +import OpenTelemetryApi + +public struct Entity : Codable, Hashable, Equatable { + /// type : Defines the type of the Entity. MUST not change during the lifetime of the entity. + /// For example: "service" or "host". This field is required and MUST not be empty for valid entities. + public let type: String + + /// id: A set of attributes that identifies the Entity. + /// MUST not change during the lifetime of the Entity. The Id must contain at least one attribute. + public let identifiers: [String: AttributeValue] + + /// A set of descriptive (non-identifying) attributes of the Entity. + /// MAY change over the lifetime of the entity. MAY be empty. These attributes are not part of Entity's identity. + public var attributes: [String: AttributeValue] + + + public static func builder(type: String) -> EntityBuilder { + .init(type: type) + } +} diff --git a/Sources/OpenTelemetrySdk/Resources/EntityBuilder.swift b/Sources/OpenTelemetrySdk/Resources/EntityBuilder.swift new file mode 100644 index 000000000..67fda7f21 --- /dev/null +++ b/Sources/OpenTelemetrySdk/Resources/EntityBuilder.swift @@ -0,0 +1,32 @@ +// +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 +// + +import OpenTelemetryApi + +public class EntityBuilder { + private var type: String + private var identifiers: [String: AttributeValue] = [:] + private var attributes: [String: AttributeValue] = [:] + + internal init(type: String) { + self.type = type + } + + public func with(identifiers: [String: AttributeValue]) -> Self { + self.identifiers = identifiers + return self + } + + public func with(attributes: [String: AttributeValue]) -> Self { + self.attributes = attributes + return self + } + + public func build() -> Entity { + return Entity(type: type, + identifiers: identifiers, + attributes: attributes) + } +} diff --git a/Sources/OpenTelemetrySdk/Resources/Resource.swift b/Sources/OpenTelemetrySdk/Resources/Resource.swift index 7b78946fa..8d5cc87b2 100644 --- a/Sources/OpenTelemetrySdk/Resources/Resource.swift +++ b/Sources/OpenTelemetrySdk/Resources/Resource.swift @@ -14,6 +14,8 @@ public struct Resource: Equatable, Hashable, Codable { /// A dictionary of labels that describe the resource. public var attributes: [String: AttributeValue] + public private(set) var entities : [Entity] = [] + /// Returns a default Resource. public init() { let executableName = ProcessInfo.processInfo.processName @@ -30,6 +32,35 @@ public struct Resource: Equatable, Hashable, Codable { ) } + private static func mergeEntities(_ lhs: [Entity], _ rhs: [Entity]) -> [Entity] { + if lhs.isEmpty { + return rhs + } + + if rhs.isEmpty { + return lhs + } + var entityMap = [String: Entity]() + lhs.forEach { entityMap[$0.type] = $0 } + rhs.forEach { entity in + if !entityMap.contains(where: { key, _ in + entity.type == key + }) { + entityMap[entity.type] = entity + } else { + if let old = entityMap[entity.type] { + let new = Entity.builder(type: old.type) + .with(identifiers: old.identifiers) + .with(attributes: entity.attributes + .merging(old.attributes) { _, old in old }) + .build() + entityMap[entity.type] = new + } + } + } + return Array(entityMap.values) + } + /// Returns an empty Resource. static var empty: Resource { return self.init(attributes: [String: AttributeValue]()) @@ -37,12 +68,24 @@ public struct Resource: Equatable, Hashable, Codable { /// Returns a Resource. /// - Parameter labels: a dictionary of labels that describe the resource. - public init(attributes: [String: AttributeValue]) { + public init(attributes: [String: AttributeValue], entities: [Entity] = []) { + self.entities = entities if Resource.checkAttributes(attributes: attributes) { - self.attributes = attributes + self.attributes = attributes.filter { key, _ in + for entity in entities { + if entity.attributes.contains(where: { attribute in attribute.key == key }) { + return true + } + if entity.identifiers.contains(where: { attribute in attribute.key == key }) { + return true + } + } + return false + } } else { self.attributes = [String: AttributeValue]() } + } /// Modifies the current Resource by merging with the other Resource. @@ -50,6 +93,7 @@ public struct Resource: Equatable, Hashable, Codable { /// - Parameter other: the Resource that will be merged with this public mutating func merge(other: Resource) { attributes.merge(other.attributes) { _, other in other } + entities = Resource.mergeEntities(entities, other.entities) } /// Returns a new, merged Resource by merging the current Resource with the other Resource. @@ -57,10 +101,11 @@ public struct Resource: Equatable, Hashable, Codable { /// - Parameter other: the Resource that will be merged with this public func merging(other: Resource) -> Resource { let labelsCopy = attributes.merging(other.attributes) { _, other in other } - return Resource(attributes: labelsCopy) + let entities = Resource.mergeEntities(self.entities, other.entities) + return Resource(attributes: labelsCopy, entities: entities) } - private static func checkAttributes(attributes: [String: AttributeValue]) -> Bool { + internal static func checkAttributes(attributes: [String: AttributeValue]) -> Bool { for entry in attributes where !isValidAndNotEmpty(name: entry.key) { return false } From 2c7403787bf9eda64302695b37331c488f0f800f Mon Sep 17 00:00:00 2001 From: Bryce Buchanan Date: Wed, 7 May 2025 14:32:53 -0700 Subject: [PATCH 3/3] added detectors and updated protobufs --- .../common/ResourceAdapter.swift | 10 + .../proto/common.pb.swift | 92 +++ .../proto/logs.pb.swift | 2 - .../proto/metrics.pb.swift | 13 +- .../proto/profiles.pb.swift | 535 +++++++----------- .../proto/resource.pb.swift | 13 + .../proto/logs_service.grpc.swift | 7 +- .../proto/metrics_service.grpc.swift | 8 +- .../proto/profiles_service.grpc.swift | 8 +- .../proto/trace_service.grpc.swift | 8 +- .../Resources/Detectors/ProcessDetector.swift | 26 + .../Resources/Detectors/ServiceDetector.swift | 19 + .../Detectors/TelemetrySdkDetector.swift | 21 + .../OpenTelemetrySdk/Resources/Entity.swift | 4 +- .../Resources/EntityBuilder.swift | 16 +- .../Resources/EntityDetector.swift | 9 + .../OpenTelemetrySdk/Resources/Resource.swift | 26 +- .../Resources/ResourceBuilder.swift | 46 ++ 18 files changed, 471 insertions(+), 392 deletions(-) create mode 100644 Sources/OpenTelemetrySdk/Resources/Detectors/ProcessDetector.swift create mode 100644 Sources/OpenTelemetrySdk/Resources/Detectors/ServiceDetector.swift create mode 100644 Sources/OpenTelemetrySdk/Resources/Detectors/TelemetrySdkDetector.swift create mode 100644 Sources/OpenTelemetrySdk/Resources/EntityDetector.swift create mode 100644 Sources/OpenTelemetrySdk/Resources/ResourceBuilder.swift diff --git a/Sources/Exporters/OpenTelemetryProtocolCommon/common/ResourceAdapter.swift b/Sources/Exporters/OpenTelemetryProtocolCommon/common/ResourceAdapter.swift index 501d385fb..b19d25345 100644 --- a/Sources/Exporters/OpenTelemetryProtocolCommon/common/ResourceAdapter.swift +++ b/Sources/Exporters/OpenTelemetryProtocolCommon/common/ResourceAdapter.swift @@ -13,6 +13,16 @@ public enum ResourceAdapter { let protoAttribute = CommonAdapter.toProtoAttribute(key: $0.key, attributeValue: $0.value) outputResource.attributes.append(protoAttribute) } + resource.entities.forEach { + if $0.identifierKeys.isEmpty { + return + } + var entityRef = Opentelemetry_Proto_Common_V1_EntityRef() + entityRef.type = $0.type + entityRef.idKeys = Array($0.identifierKeys) + entityRef.descriptionKeys = Array($0.attributeKeys) + outputResource.entityRefs.append(entityRef) + } return outputResource } } diff --git a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/common.pb.swift b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/common.pb.swift index 3aaa01136..4b599020e 100644 --- a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/common.pb.swift +++ b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/common.pb.swift @@ -206,6 +206,48 @@ public struct Opentelemetry_Proto_Common_V1_InstrumentationScope: Sendable { public init() {} } +/// A reference to an Entity. +/// Entity represents an object of interest associated with produced telemetry: e.g spans, metrics, profiles, or logs. +/// +/// Status: [Development] +public struct Opentelemetry_Proto_Common_V1_EntityRef: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The Schema URL, if known. This is the identifier of the Schema that the entity data + /// is recorded in. To learn more about Schema URL see + /// https://opentelemetry.io/docs/specs/otel/schemas/#schema-url + /// + /// This schema_url applies to the data in this message and to the Resource attributes + /// referenced by id_keys and description_keys. + /// TODO: discuss if we are happy with this somewhat complicated definition of what + /// the schema_url applies to. + /// + /// This field obsoletes the schema_url field in ResourceMetrics/ResourceSpans/ResourceLogs. + public var schemaURL: String = String() + + /// Defines the type of the entity. MUST not change during the lifetime of the entity. + /// For example: "service" or "host". This field is required and MUST not be empty + /// for valid entities. + public var type: String = String() + + /// Attribute Keys that identify the entity. + /// MUST not change during the lifetime of the entity. The Id must contain at least one attribute. + /// These keys MUST exist in the containing {message}.attributes. + public var idKeys: [String] = [] + + /// Descriptive (non-identifying) attribute keys of the entity. + /// MAY change over the lifetime of the entity. MAY be empty. + /// These attribute keys are not part of entity's identity. + /// These keys MUST exist in the containing {message}.attributes. + public var descriptionKeys: [String] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + // MARK: - Code below here is support for the SwiftProtobuf runtime. fileprivate let _protobuf_package = "opentelemetry.proto.common.v1" @@ -500,3 +542,53 @@ extension Opentelemetry_Proto_Common_V1_InstrumentationScope: SwiftProtobuf.Mess return true } } + +extension Opentelemetry_Proto_Common_V1_EntityRef: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".EntityRef" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "schema_url"), + 2: .same(proto: "type"), + 3: .standard(proto: "id_keys"), + 4: .standard(proto: "description_keys"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.schemaURL) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.type) }() + case 3: try { try decoder.decodeRepeatedStringField(value: &self.idKeys) }() + case 4: try { try decoder.decodeRepeatedStringField(value: &self.descriptionKeys) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.schemaURL.isEmpty { + try visitor.visitSingularStringField(value: self.schemaURL, fieldNumber: 1) + } + if !self.type.isEmpty { + try visitor.visitSingularStringField(value: self.type, fieldNumber: 2) + } + if !self.idKeys.isEmpty { + try visitor.visitRepeatedStringField(value: self.idKeys, fieldNumber: 3) + } + if !self.descriptionKeys.isEmpty { + try visitor.visitRepeatedStringField(value: self.descriptionKeys, fieldNumber: 4) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Opentelemetry_Proto_Common_V1_EntityRef, rhs: Opentelemetry_Proto_Common_V1_EntityRef) -> Bool { + if lhs.schemaURL != rhs.schemaURL {return false} + if lhs.type != rhs.type {return false} + if lhs.idKeys != rhs.idKeys {return false} + if lhs.descriptionKeys != rhs.descriptionKeys {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/logs.pb.swift b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/logs.pb.swift index c34dffe39..0889e8912 100644 --- a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/logs.pb.swift +++ b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/logs.pb.swift @@ -407,8 +407,6 @@ public struct Opentelemetry_Proto_Logs_V1_LogRecord: @unchecked Sendable { /// as an event. /// /// [Optional]. - /// - /// Status: [Development] public var eventName: String = String() public var unknownFields = SwiftProtobuf.UnknownStorage() diff --git a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/metrics.pb.swift b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/metrics.pb.swift index e847bc995..2063cda4a 100644 --- a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/metrics.pb.swift +++ b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/metrics.pb.swift @@ -397,7 +397,7 @@ public struct Opentelemetry_Proto_Metrics_V1_Metric: Sendable { public var description_p: String = String() /// unit in which the metric value is reported. Follows the format - /// described by http://unitsofmeasure.org/ucum.html. + /// described by https://unitsofmeasure.org/ucum.html. public var unit: String = String() /// Data determines the aggregation type (if any) of the metric, what is the @@ -551,7 +551,7 @@ public struct Opentelemetry_Proto_Metrics_V1_ExponentialHistogram: Sendable { /// Summary metric data are used to convey quantile summaries, /// a Prometheus (see: https://prometheus.io/docs/concepts/metric_types/#summary) -/// and OpenMetrics (see: https://github.com/OpenObservability/OpenMetrics/blob/4dbf6075567ab43296eed941037c12951faafb92/protos/prometheus.proto#L45) +/// and OpenMetrics (see: https://github.com/prometheus/OpenMetrics/blob/4dbf6075567ab43296eed941037c12951faafb92/protos/prometheus.proto#L45) /// data type. These data points cannot always be merged in a meaningful way. /// While they can be useful in some applications, histogram data points are /// recommended for new applications. @@ -699,7 +699,9 @@ public struct Opentelemetry_Proto_Metrics_V1_HistogramDataPoint: Sendable { /// The sum of the bucket_counts must equal the value in the count field. /// /// The number of elements in bucket_counts array must be by one greater than - /// the number of elements in explicit_bounds array. + /// the number of elements in explicit_bounds array. The exception to this rule + /// is when the length of bucket_counts is 0, then the length of explicit_bounds + /// must also be 0. public var bucketCounts: [UInt64] = [] /// explicit_bounds specifies buckets with explicitly defined bounds for values. @@ -715,6 +717,9 @@ public struct Opentelemetry_Proto_Metrics_V1_HistogramDataPoint: Sendable { /// Histogram buckets are inclusive of their upper boundary, except the last /// bucket where the boundary is at infinity. This format is intentionally /// compatible with the OpenMetrics histogram definition. + /// + /// If bucket_counts length is 0 then explicit_bounds length must also be 0, + /// otherwise the data point is invalid. public var explicitBounds: [Double] = [] /// (Optional) List of exemplars collected from @@ -897,7 +902,7 @@ public struct Opentelemetry_Proto_Metrics_V1_ExponentialHistogramDataPoint: Send // methods supported on all messages. /// Offset is the bucket index of the first entry in the bucket_counts array. - /// + /// /// Note: This uses a varint encoding as a simple form of compression. public var offset: Int32 = 0 diff --git a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/profiles.pb.swift b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/profiles.pb.swift index 3c1936011..75e00c0cd 100644 --- a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/profiles.pb.swift +++ b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/profiles.pb.swift @@ -168,12 +168,37 @@ public struct Opentelemetry_Proto_Profiles_V1development_ProfilesData: Sendable // methods supported on all messages. /// An array of ResourceProfiles. - /// For data coming from a single resource this array will typically contain - /// one element. Intermediary nodes that receive data from multiple origins - /// typically batch the data before forwarding further and in that case this - /// array will contain multiple elements. + /// For data coming from an SDK profiler, this array will typically contain one + /// element. Host-level profilers will usually create one ResourceProfile per + /// container, as well as one additional ResourceProfile grouping all samples + /// from non-containerized processes. + /// Other resource groupings are possible as well and clarified via + /// Resource.attributes and semantic conventions. public var resourceProfiles: [Opentelemetry_Proto_Profiles_V1development_ResourceProfiles] = [] + /// Mappings from address ranges to the image/binary/library mapped + /// into that address range referenced by locations via Location.mapping_index. + public var mappingTable: [Opentelemetry_Proto_Profiles_V1development_Mapping] = [] + + /// Locations referenced by samples via Profile.location_indices. + public var locationTable: [Opentelemetry_Proto_Profiles_V1development_Location] = [] + + /// Functions referenced by locations via Line.function_index. + public var functionTable: [Opentelemetry_Proto_Profiles_V1development_Function] = [] + + /// Links referenced by samples via Sample.link_index. + public var linkTable: [Opentelemetry_Proto_Profiles_V1development_Link] = [] + + /// A common table for strings referenced by various messages. + /// string_table[0] must always be "". + public var stringTable: [String] = [] + + /// A common table for attributes referenced by various messages. + public var attributeTable: [Opentelemetry_Proto_Common_V1_KeyValue] = [] + + /// Represents a mapping between Attribute Keys and Units. + public var attributeUnits: [Opentelemetry_Proto_Profiles_V1development_AttributeUnit] = [] + public var unknownFields = SwiftProtobuf.UnknownStorage() public init() {} @@ -269,137 +294,57 @@ public struct Opentelemetry_Proto_Profiles_V1development_Profile: @unchecked Sen /// If one of the values represents the number of events represented /// by the sample, by convention it should be at index 0 and use /// sample_type.unit == "count". - public var sampleType: [Opentelemetry_Proto_Profiles_V1development_ValueType] { - get {return _storage._sampleType} - set {_uniqueStorage()._sampleType = newValue} - } + public var sampleType: [Opentelemetry_Proto_Profiles_V1development_ValueType] = [] /// The set of samples recorded in this profile. - public var sample: [Opentelemetry_Proto_Profiles_V1development_Sample] { - get {return _storage._sample} - set {_uniqueStorage()._sample = newValue} - } - - /// Mapping from address ranges to the image/binary/library mapped - /// into that address range. mapping[0] will be the main binary. - /// If multiple binaries contribute to the Profile and no main - /// binary can be identified, mapping[0] has no special meaning. - public var mappingTable: [Opentelemetry_Proto_Profiles_V1development_Mapping] { - get {return _storage._mappingTable} - set {_uniqueStorage()._mappingTable = newValue} - } - - /// Locations referenced by samples via location_indices. - public var locationTable: [Opentelemetry_Proto_Profiles_V1development_Location] { - get {return _storage._locationTable} - set {_uniqueStorage()._locationTable = newValue} - } - - /// Array of locations referenced by samples. - public var locationIndices: [Int32] { - get {return _storage._locationIndices} - set {_uniqueStorage()._locationIndices = newValue} - } - - /// Functions referenced by locations. - public var functionTable: [Opentelemetry_Proto_Profiles_V1development_Function] { - get {return _storage._functionTable} - set {_uniqueStorage()._functionTable = newValue} - } - - /// Lookup table for attributes. - public var attributeTable: [Opentelemetry_Proto_Common_V1_KeyValue] { - get {return _storage._attributeTable} - set {_uniqueStorage()._attributeTable = newValue} - } - - /// Represents a mapping between Attribute Keys and Units. - public var attributeUnits: [Opentelemetry_Proto_Profiles_V1development_AttributeUnit] { - get {return _storage._attributeUnits} - set {_uniqueStorage()._attributeUnits = newValue} - } - - /// Lookup table for links. - public var linkTable: [Opentelemetry_Proto_Profiles_V1development_Link] { - get {return _storage._linkTable} - set {_uniqueStorage()._linkTable = newValue} - } + public var sample: [Opentelemetry_Proto_Profiles_V1development_Sample] = [] - /// A common table for strings referenced by various messages. - /// string_table[0] must always be "". - public var stringTable: [String] { - get {return _storage._stringTable} - set {_uniqueStorage()._stringTable = newValue} - } + /// References to locations in ProfilesData.location_table. + public var locationIndices: [Int32] = [] /// Time of collection (UTC) represented as nanoseconds past the epoch. - public var timeNanos: Int64 { - get {return _storage._timeNanos} - set {_uniqueStorage()._timeNanos = newValue} - } + public var timeNanos: Int64 = 0 /// Duration of the profile, if a duration makes sense. - public var durationNanos: Int64 { - get {return _storage._durationNanos} - set {_uniqueStorage()._durationNanos = newValue} - } + public var durationNanos: Int64 = 0 /// The kind of events between sampled occurrences. /// e.g [ "cpu","cycles" ] or [ "heap","bytes" ] public var periodType: Opentelemetry_Proto_Profiles_V1development_ValueType { - get {return _storage._periodType ?? Opentelemetry_Proto_Profiles_V1development_ValueType()} - set {_uniqueStorage()._periodType = newValue} + get {return _periodType ?? Opentelemetry_Proto_Profiles_V1development_ValueType()} + set {_periodType = newValue} } /// Returns true if `periodType` has been explicitly set. - public var hasPeriodType: Bool {return _storage._periodType != nil} + public var hasPeriodType: Bool {return self._periodType != nil} /// Clears the value of `periodType`. Subsequent reads from it will return its default value. - public mutating func clearPeriodType() {_uniqueStorage()._periodType = nil} + public mutating func clearPeriodType() {self._periodType = nil} /// The number of events between sampled occurrences. - public var period: Int64 { - get {return _storage._period} - set {_uniqueStorage()._period = newValue} - } + public var period: Int64 = 0 /// Free-form text associated with the profile. The text is displayed as is /// to the user by the tools that read profiles (e.g. by pprof). This field /// should not be used to store any machine-readable information, it is only /// for human-friendly content. The profile must stay functional if this field /// is cleaned. - public var commentStrindices: [Int32] { - get {return _storage._commentStrindices} - set {_uniqueStorage()._commentStrindices = newValue} - } + public var commentStrindices: [Int32] = [] - /// Index into the string table of the type of the preferred sample - /// value. If unset, clients should default to the last sample value. - public var defaultSampleTypeStrindex: Int32 { - get {return _storage._defaultSampleTypeStrindex} - set {_uniqueStorage()._defaultSampleTypeStrindex = newValue} - } + /// Index into the sample_type array to the default sample type. + public var defaultSampleTypeIndex: Int32 = 0 /// A globally unique identifier for a profile. The ID is a 16-byte array. An ID with /// all zeroes is considered invalid. /// /// This field is required. - public var profileID: Data { - get {return _storage._profileID} - set {_uniqueStorage()._profileID = newValue} - } + public var profileID: Data = Data() /// dropped_attributes_count is the number of attributes that were discarded. Attributes /// can be discarded because their keys are too long or because there are too many /// attributes. If this value is 0, then no attributes were dropped. - public var droppedAttributesCount: UInt32 { - get {return _storage._droppedAttributesCount} - set {_uniqueStorage()._droppedAttributesCount = newValue} - } + public var droppedAttributesCount: UInt32 = 0 /// Specifies format of the original payload. Common values are defined in semantic conventions. [required if original_payload is present] - public var originalPayloadFormat: String { - get {return _storage._originalPayloadFormat} - set {_uniqueStorage()._originalPayloadFormat = newValue} - } + public var originalPayloadFormat: String = String() /// Original payload can be stored in this field. This can be useful for users who want to get the original payload. /// Formats such as JFR are highly extensible and can contain more information than what is defined in this spec. @@ -407,10 +352,7 @@ public struct Opentelemetry_Proto_Profiles_V1development_Profile: @unchecked Sen /// If the original payload is in pprof format, it SHOULD not be included in this field. /// The field is optional, however if it is present then equivalent converted data should be populated in other fields /// of this message as far as is practicable. - public var originalPayload: Data { - get {return _storage._originalPayload} - set {_uniqueStorage()._originalPayload = newValue} - } + public var originalPayload: Data = Data() /// References to attributes in attribute_table. [optional] /// It is a collection of key/value pairs. Note, global attributes @@ -425,16 +367,13 @@ public struct Opentelemetry_Proto_Profiles_V1development_Profile: @unchecked Sen /// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/README.md#attribute /// Attribute keys MUST be unique (it is not allowed to have more than one /// attribute with the same key). - public var attributeIndices: [Int32] { - get {return _storage._attributeIndices} - set {_uniqueStorage()._attributeIndices = newValue} - } + public var attributeIndices: [Int32] = [] public var unknownFields = SwiftProtobuf.UnknownStorage() public init() {} - fileprivate var _storage = _StorageClass.defaultInstance + fileprivate var _periodType: Opentelemetry_Proto_Profiles_V1development_ValueType? = nil } /// Represents a mapping between Attribute Keys and Units. @@ -479,10 +418,10 @@ public struct Opentelemetry_Proto_Profiles_V1development_ValueType: Sendable { // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. - /// Index into string table. + /// Index into ProfilesData.string_table. public var typeStrindex: Int32 = 0 - /// Index into string table. + /// Index into ProfilesData.string_table. public var unitStrindex: Int32 = 0 public var aggregationTemporality: Opentelemetry_Proto_Profiles_V1development_AggregationTemporality = .unspecified @@ -516,10 +455,10 @@ public struct Opentelemetry_Proto_Profiles_V1development_Sample: Sendable { /// lists of the originals. public var value: [Int64] = [] - /// References to attributes in Profile.attribute_table. [optional] + /// References to attributes in ProfilesData.attribute_table. [optional] public var attributeIndices: [Int32] = [] - /// Reference to link in Profile.link_table. [optional] + /// Reference to link in ProfilesData.link_table. [optional] public var linkIndex: Int32 { get {return _linkIndex ?? 0} set {_linkIndex = newValue} @@ -561,7 +500,7 @@ public struct Opentelemetry_Proto_Profiles_V1development_Mapping: Sendable { /// abstractions like "[vdso]". public var filenameStrindex: Int32 = 0 - /// References to attributes in Profile.attribute_table. [optional] + /// References to attributes in ProfilesData.attribute_table. [optional] public var attributeIndices: [Int32] = [] /// The following fields indicate the resolution of symbolic info. @@ -584,7 +523,7 @@ public struct Opentelemetry_Proto_Profiles_V1development_Location: Sendable { // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. - /// Reference to mapping in Profile.mapping_table. + /// Reference to mapping in ProfilesData.mapping_table. /// It can be unset if the mapping is unknown or not applicable for /// this profile type. public var mappingIndex: Int32 { @@ -619,7 +558,7 @@ public struct Opentelemetry_Proto_Profiles_V1development_Location: Sendable { /// profile changes. public var isFolded: Bool = false - /// References to attributes in Profile.attribute_table. [optional] + /// References to attributes in ProfilesData.attribute_table. [optional] public var attributeIndices: [Int32] = [] public var unknownFields = SwiftProtobuf.UnknownStorage() @@ -635,13 +574,13 @@ public struct Opentelemetry_Proto_Profiles_V1development_Line: Sendable { // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. - /// Reference to function in Profile.function_table. + /// Reference to function in ProfilesData.function_table. public var functionIndex: Int32 = 0 - /// Line number in source code. + /// Line number in source code. 0 means unset. public var line: Int64 = 0 - /// Column number in source code. + /// Column number in source code. 0 means unset. public var column: Int64 = 0 public var unknownFields = SwiftProtobuf.UnknownStorage() @@ -656,17 +595,17 @@ public struct Opentelemetry_Proto_Profiles_V1development_Function: Sendable { // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. - /// Name of the function, in human-readable form if available. + /// Function name. Empty string if not available. public var nameStrindex: Int32 = 0 - /// Name of the function, as identified by the system. - /// For instance, it can be a C++ mangled name. + /// Function name, as identified by the system. For instance, + /// it can be a C++ mangled name. Empty string if not available. public var systemNameStrindex: Int32 = 0 - /// Source file containing the function. + /// Source file containing the function. Empty string if not available. public var filenameStrindex: Int32 = 0 - /// Line number in source file. + /// Line number in source file. 0 means unset. public var startLine: Int64 = 0 public var unknownFields = SwiftProtobuf.UnknownStorage() @@ -690,6 +629,13 @@ extension Opentelemetry_Proto_Profiles_V1development_ProfilesData: SwiftProtobuf public static let protoMessageName: String = _protobuf_package + ".ProfilesData" public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 1: .standard(proto: "resource_profiles"), + 2: .standard(proto: "mapping_table"), + 3: .standard(proto: "location_table"), + 4: .standard(proto: "function_table"), + 5: .standard(proto: "link_table"), + 6: .standard(proto: "string_table"), + 7: .standard(proto: "attribute_table"), + 8: .standard(proto: "attribute_units"), ] public mutating func decodeMessage(decoder: inout D) throws { @@ -699,6 +645,13 @@ extension Opentelemetry_Proto_Profiles_V1development_ProfilesData: SwiftProtobuf // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { case 1: try { try decoder.decodeRepeatedMessageField(value: &self.resourceProfiles) }() + case 2: try { try decoder.decodeRepeatedMessageField(value: &self.mappingTable) }() + case 3: try { try decoder.decodeRepeatedMessageField(value: &self.locationTable) }() + case 4: try { try decoder.decodeRepeatedMessageField(value: &self.functionTable) }() + case 5: try { try decoder.decodeRepeatedMessageField(value: &self.linkTable) }() + case 6: try { try decoder.decodeRepeatedStringField(value: &self.stringTable) }() + case 7: try { try decoder.decodeRepeatedMessageField(value: &self.attributeTable) }() + case 8: try { try decoder.decodeRepeatedMessageField(value: &self.attributeUnits) }() default: break } } @@ -708,11 +661,39 @@ extension Opentelemetry_Proto_Profiles_V1development_ProfilesData: SwiftProtobuf if !self.resourceProfiles.isEmpty { try visitor.visitRepeatedMessageField(value: self.resourceProfiles, fieldNumber: 1) } + if !self.mappingTable.isEmpty { + try visitor.visitRepeatedMessageField(value: self.mappingTable, fieldNumber: 2) + } + if !self.locationTable.isEmpty { + try visitor.visitRepeatedMessageField(value: self.locationTable, fieldNumber: 3) + } + if !self.functionTable.isEmpty { + try visitor.visitRepeatedMessageField(value: self.functionTable, fieldNumber: 4) + } + if !self.linkTable.isEmpty { + try visitor.visitRepeatedMessageField(value: self.linkTable, fieldNumber: 5) + } + if !self.stringTable.isEmpty { + try visitor.visitRepeatedStringField(value: self.stringTable, fieldNumber: 6) + } + if !self.attributeTable.isEmpty { + try visitor.visitRepeatedMessageField(value: self.attributeTable, fieldNumber: 7) + } + if !self.attributeUnits.isEmpty { + try visitor.visitRepeatedMessageField(value: self.attributeUnits, fieldNumber: 8) + } try unknownFields.traverse(visitor: &visitor) } public static func ==(lhs: Opentelemetry_Proto_Profiles_V1development_ProfilesData, rhs: Opentelemetry_Proto_Profiles_V1development_ProfilesData) -> Bool { if lhs.resourceProfiles != rhs.resourceProfiles {return false} + if lhs.mappingTable != rhs.mappingTable {return false} + if lhs.locationTable != rhs.locationTable {return false} + if lhs.functionTable != rhs.functionTable {return false} + if lhs.linkTable != rhs.linkTable {return false} + if lhs.stringTable != rhs.stringTable {return false} + if lhs.attributeTable != rhs.attributeTable {return false} + if lhs.attributeUnits != rhs.attributeUnits {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } @@ -819,232 +800,110 @@ extension Opentelemetry_Proto_Profiles_V1development_Profile: SwiftProtobuf.Mess public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 1: .standard(proto: "sample_type"), 2: .same(proto: "sample"), - 3: .standard(proto: "mapping_table"), - 4: .standard(proto: "location_table"), - 5: .standard(proto: "location_indices"), - 6: .standard(proto: "function_table"), - 7: .standard(proto: "attribute_table"), - 8: .standard(proto: "attribute_units"), - 9: .standard(proto: "link_table"), - 10: .standard(proto: "string_table"), - 11: .standard(proto: "time_nanos"), - 12: .standard(proto: "duration_nanos"), - 13: .standard(proto: "period_type"), - 14: .same(proto: "period"), - 15: .standard(proto: "comment_strindices"), - 16: .standard(proto: "default_sample_type_strindex"), - 17: .standard(proto: "profile_id"), - 19: .standard(proto: "dropped_attributes_count"), - 20: .standard(proto: "original_payload_format"), - 21: .standard(proto: "original_payload"), - 22: .standard(proto: "attribute_indices"), + 3: .standard(proto: "location_indices"), + 4: .standard(proto: "time_nanos"), + 5: .standard(proto: "duration_nanos"), + 6: .standard(proto: "period_type"), + 7: .same(proto: "period"), + 8: .standard(proto: "comment_strindices"), + 9: .standard(proto: "default_sample_type_index"), + 10: .standard(proto: "profile_id"), + 11: .standard(proto: "dropped_attributes_count"), + 12: .standard(proto: "original_payload_format"), + 13: .standard(proto: "original_payload"), + 14: .standard(proto: "attribute_indices"), ] - fileprivate class _StorageClass { - var _sampleType: [Opentelemetry_Proto_Profiles_V1development_ValueType] = [] - var _sample: [Opentelemetry_Proto_Profiles_V1development_Sample] = [] - var _mappingTable: [Opentelemetry_Proto_Profiles_V1development_Mapping] = [] - var _locationTable: [Opentelemetry_Proto_Profiles_V1development_Location] = [] - var _locationIndices: [Int32] = [] - var _functionTable: [Opentelemetry_Proto_Profiles_V1development_Function] = [] - var _attributeTable: [Opentelemetry_Proto_Common_V1_KeyValue] = [] - var _attributeUnits: [Opentelemetry_Proto_Profiles_V1development_AttributeUnit] = [] - var _linkTable: [Opentelemetry_Proto_Profiles_V1development_Link] = [] - var _stringTable: [String] = [] - var _timeNanos: Int64 = 0 - var _durationNanos: Int64 = 0 - var _periodType: Opentelemetry_Proto_Profiles_V1development_ValueType? = nil - var _period: Int64 = 0 - var _commentStrindices: [Int32] = [] - var _defaultSampleTypeStrindex: Int32 = 0 - var _profileID: Data = Data() - var _droppedAttributesCount: UInt32 = 0 - var _originalPayloadFormat: String = String() - var _originalPayload: Data = Data() - var _attributeIndices: [Int32] = [] - - #if swift(>=5.10) - // This property is used as the initial default value for new instances of the type. - // The type itself is protecting the reference to its storage via CoW semantics. - // This will force a copy to be made of this reference when the first mutation occurs; - // hence, it is safe to mark this as `nonisolated(unsafe)`. - static nonisolated(unsafe) let defaultInstance = _StorageClass() - #else - static let defaultInstance = _StorageClass() - #endif - - private init() {} - - init(copying source: _StorageClass) { - _sampleType = source._sampleType - _sample = source._sample - _mappingTable = source._mappingTable - _locationTable = source._locationTable - _locationIndices = source._locationIndices - _functionTable = source._functionTable - _attributeTable = source._attributeTable - _attributeUnits = source._attributeUnits - _linkTable = source._linkTable - _stringTable = source._stringTable - _timeNanos = source._timeNanos - _durationNanos = source._durationNanos - _periodType = source._periodType - _period = source._period - _commentStrindices = source._commentStrindices - _defaultSampleTypeStrindex = source._defaultSampleTypeStrindex - _profileID = source._profileID - _droppedAttributesCount = source._droppedAttributesCount - _originalPayloadFormat = source._originalPayloadFormat - _originalPayload = source._originalPayload - _attributeIndices = source._attributeIndices - } - } - - fileprivate mutating func _uniqueStorage() -> _StorageClass { - if !isKnownUniquelyReferenced(&_storage) { - _storage = _StorageClass(copying: _storage) - } - return _storage - } - public mutating func decodeMessage(decoder: inout D) throws { - _ = _uniqueStorage() - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeRepeatedMessageField(value: &_storage._sampleType) }() - case 2: try { try decoder.decodeRepeatedMessageField(value: &_storage._sample) }() - case 3: try { try decoder.decodeRepeatedMessageField(value: &_storage._mappingTable) }() - case 4: try { try decoder.decodeRepeatedMessageField(value: &_storage._locationTable) }() - case 5: try { try decoder.decodeRepeatedInt32Field(value: &_storage._locationIndices) }() - case 6: try { try decoder.decodeRepeatedMessageField(value: &_storage._functionTable) }() - case 7: try { try decoder.decodeRepeatedMessageField(value: &_storage._attributeTable) }() - case 8: try { try decoder.decodeRepeatedMessageField(value: &_storage._attributeUnits) }() - case 9: try { try decoder.decodeRepeatedMessageField(value: &_storage._linkTable) }() - case 10: try { try decoder.decodeRepeatedStringField(value: &_storage._stringTable) }() - case 11: try { try decoder.decodeSingularInt64Field(value: &_storage._timeNanos) }() - case 12: try { try decoder.decodeSingularInt64Field(value: &_storage._durationNanos) }() - case 13: try { try decoder.decodeSingularMessageField(value: &_storage._periodType) }() - case 14: try { try decoder.decodeSingularInt64Field(value: &_storage._period) }() - case 15: try { try decoder.decodeRepeatedInt32Field(value: &_storage._commentStrindices) }() - case 16: try { try decoder.decodeSingularInt32Field(value: &_storage._defaultSampleTypeStrindex) }() - case 17: try { try decoder.decodeSingularBytesField(value: &_storage._profileID) }() - case 19: try { try decoder.decodeSingularUInt32Field(value: &_storage._droppedAttributesCount) }() - case 20: try { try decoder.decodeSingularStringField(value: &_storage._originalPayloadFormat) }() - case 21: try { try decoder.decodeSingularBytesField(value: &_storage._originalPayload) }() - case 22: try { try decoder.decodeRepeatedInt32Field(value: &_storage._attributeIndices) }() - default: break - } + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.sampleType) }() + case 2: try { try decoder.decodeRepeatedMessageField(value: &self.sample) }() + case 3: try { try decoder.decodeRepeatedInt32Field(value: &self.locationIndices) }() + case 4: try { try decoder.decodeSingularInt64Field(value: &self.timeNanos) }() + case 5: try { try decoder.decodeSingularInt64Field(value: &self.durationNanos) }() + case 6: try { try decoder.decodeSingularMessageField(value: &self._periodType) }() + case 7: try { try decoder.decodeSingularInt64Field(value: &self.period) }() + case 8: try { try decoder.decodeRepeatedInt32Field(value: &self.commentStrindices) }() + case 9: try { try decoder.decodeSingularInt32Field(value: &self.defaultSampleTypeIndex) }() + case 10: try { try decoder.decodeSingularBytesField(value: &self.profileID) }() + case 11: try { try decoder.decodeSingularUInt32Field(value: &self.droppedAttributesCount) }() + case 12: try { try decoder.decodeSingularStringField(value: &self.originalPayloadFormat) }() + case 13: try { try decoder.decodeSingularBytesField(value: &self.originalPayload) }() + case 14: try { try decoder.decodeRepeatedInt32Field(value: &self.attributeIndices) }() + default: break } } } public func traverse(visitor: inout V) throws { - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - if !_storage._sampleType.isEmpty { - try visitor.visitRepeatedMessageField(value: _storage._sampleType, fieldNumber: 1) - } - if !_storage._sample.isEmpty { - try visitor.visitRepeatedMessageField(value: _storage._sample, fieldNumber: 2) - } - if !_storage._mappingTable.isEmpty { - try visitor.visitRepeatedMessageField(value: _storage._mappingTable, fieldNumber: 3) - } - if !_storage._locationTable.isEmpty { - try visitor.visitRepeatedMessageField(value: _storage._locationTable, fieldNumber: 4) - } - if !_storage._locationIndices.isEmpty { - try visitor.visitPackedInt32Field(value: _storage._locationIndices, fieldNumber: 5) - } - if !_storage._functionTable.isEmpty { - try visitor.visitRepeatedMessageField(value: _storage._functionTable, fieldNumber: 6) - } - if !_storage._attributeTable.isEmpty { - try visitor.visitRepeatedMessageField(value: _storage._attributeTable, fieldNumber: 7) - } - if !_storage._attributeUnits.isEmpty { - try visitor.visitRepeatedMessageField(value: _storage._attributeUnits, fieldNumber: 8) - } - if !_storage._linkTable.isEmpty { - try visitor.visitRepeatedMessageField(value: _storage._linkTable, fieldNumber: 9) - } - if !_storage._stringTable.isEmpty { - try visitor.visitRepeatedStringField(value: _storage._stringTable, fieldNumber: 10) - } - if _storage._timeNanos != 0 { - try visitor.visitSingularInt64Field(value: _storage._timeNanos, fieldNumber: 11) - } - if _storage._durationNanos != 0 { - try visitor.visitSingularInt64Field(value: _storage._durationNanos, fieldNumber: 12) - } - try { if let v = _storage._periodType { - try visitor.visitSingularMessageField(value: v, fieldNumber: 13) - } }() - if _storage._period != 0 { - try visitor.visitSingularInt64Field(value: _storage._period, fieldNumber: 14) - } - if !_storage._commentStrindices.isEmpty { - try visitor.visitPackedInt32Field(value: _storage._commentStrindices, fieldNumber: 15) - } - if _storage._defaultSampleTypeStrindex != 0 { - try visitor.visitSingularInt32Field(value: _storage._defaultSampleTypeStrindex, fieldNumber: 16) - } - if !_storage._profileID.isEmpty { - try visitor.visitSingularBytesField(value: _storage._profileID, fieldNumber: 17) - } - if _storage._droppedAttributesCount != 0 { - try visitor.visitSingularUInt32Field(value: _storage._droppedAttributesCount, fieldNumber: 19) - } - if !_storage._originalPayloadFormat.isEmpty { - try visitor.visitSingularStringField(value: _storage._originalPayloadFormat, fieldNumber: 20) - } - if !_storage._originalPayload.isEmpty { - try visitor.visitSingularBytesField(value: _storage._originalPayload, fieldNumber: 21) - } - if !_storage._attributeIndices.isEmpty { - try visitor.visitPackedInt32Field(value: _storage._attributeIndices, fieldNumber: 22) - } + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if !self.sampleType.isEmpty { + try visitor.visitRepeatedMessageField(value: self.sampleType, fieldNumber: 1) + } + if !self.sample.isEmpty { + try visitor.visitRepeatedMessageField(value: self.sample, fieldNumber: 2) + } + if !self.locationIndices.isEmpty { + try visitor.visitPackedInt32Field(value: self.locationIndices, fieldNumber: 3) + } + if self.timeNanos != 0 { + try visitor.visitSingularInt64Field(value: self.timeNanos, fieldNumber: 4) + } + if self.durationNanos != 0 { + try visitor.visitSingularInt64Field(value: self.durationNanos, fieldNumber: 5) + } + try { if let v = self._periodType { + try visitor.visitSingularMessageField(value: v, fieldNumber: 6) + } }() + if self.period != 0 { + try visitor.visitSingularInt64Field(value: self.period, fieldNumber: 7) + } + if !self.commentStrindices.isEmpty { + try visitor.visitPackedInt32Field(value: self.commentStrindices, fieldNumber: 8) + } + if self.defaultSampleTypeIndex != 0 { + try visitor.visitSingularInt32Field(value: self.defaultSampleTypeIndex, fieldNumber: 9) + } + if !self.profileID.isEmpty { + try visitor.visitSingularBytesField(value: self.profileID, fieldNumber: 10) + } + if self.droppedAttributesCount != 0 { + try visitor.visitSingularUInt32Field(value: self.droppedAttributesCount, fieldNumber: 11) + } + if !self.originalPayloadFormat.isEmpty { + try visitor.visitSingularStringField(value: self.originalPayloadFormat, fieldNumber: 12) + } + if !self.originalPayload.isEmpty { + try visitor.visitSingularBytesField(value: self.originalPayload, fieldNumber: 13) + } + if !self.attributeIndices.isEmpty { + try visitor.visitPackedInt32Field(value: self.attributeIndices, fieldNumber: 14) } try unknownFields.traverse(visitor: &visitor) } public static func ==(lhs: Opentelemetry_Proto_Profiles_V1development_Profile, rhs: Opentelemetry_Proto_Profiles_V1development_Profile) -> Bool { - if lhs._storage !== rhs._storage { - let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in - let _storage = _args.0 - let rhs_storage = _args.1 - if _storage._sampleType != rhs_storage._sampleType {return false} - if _storage._sample != rhs_storage._sample {return false} - if _storage._mappingTable != rhs_storage._mappingTable {return false} - if _storage._locationTable != rhs_storage._locationTable {return false} - if _storage._locationIndices != rhs_storage._locationIndices {return false} - if _storage._functionTable != rhs_storage._functionTable {return false} - if _storage._attributeTable != rhs_storage._attributeTable {return false} - if _storage._attributeUnits != rhs_storage._attributeUnits {return false} - if _storage._linkTable != rhs_storage._linkTable {return false} - if _storage._stringTable != rhs_storage._stringTable {return false} - if _storage._timeNanos != rhs_storage._timeNanos {return false} - if _storage._durationNanos != rhs_storage._durationNanos {return false} - if _storage._periodType != rhs_storage._periodType {return false} - if _storage._period != rhs_storage._period {return false} - if _storage._commentStrindices != rhs_storage._commentStrindices {return false} - if _storage._defaultSampleTypeStrindex != rhs_storage._defaultSampleTypeStrindex {return false} - if _storage._profileID != rhs_storage._profileID {return false} - if _storage._droppedAttributesCount != rhs_storage._droppedAttributesCount {return false} - if _storage._originalPayloadFormat != rhs_storage._originalPayloadFormat {return false} - if _storage._originalPayload != rhs_storage._originalPayload {return false} - if _storage._attributeIndices != rhs_storage._attributeIndices {return false} - return true - } - if !storagesAreEqual {return false} - } + if lhs.sampleType != rhs.sampleType {return false} + if lhs.sample != rhs.sample {return false} + if lhs.locationIndices != rhs.locationIndices {return false} + if lhs.timeNanos != rhs.timeNanos {return false} + if lhs.durationNanos != rhs.durationNanos {return false} + if lhs._periodType != rhs._periodType {return false} + if lhs.period != rhs.period {return false} + if lhs.commentStrindices != rhs.commentStrindices {return false} + if lhs.defaultSampleTypeIndex != rhs.defaultSampleTypeIndex {return false} + if lhs.profileID != rhs.profileID {return false} + if lhs.droppedAttributesCount != rhs.droppedAttributesCount {return false} + if lhs.originalPayloadFormat != rhs.originalPayloadFormat {return false} + if lhs.originalPayload != rhs.originalPayload {return false} + if lhs.attributeIndices != rhs.attributeIndices {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } diff --git a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/resource.pb.swift b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/resource.pb.swift index 5198114b9..a654d7f62 100644 --- a/Sources/Exporters/OpenTelemetryProtocolCommon/proto/resource.pb.swift +++ b/Sources/Exporters/OpenTelemetryProtocolCommon/proto/resource.pb.swift @@ -49,6 +49,13 @@ public struct Opentelemetry_Proto_Resource_V1_Resource: Sendable { /// no attributes were dropped. public var droppedAttributesCount: UInt32 = 0 + /// Set of entities that participate in this Resource. + /// + /// Note: keys in the references MUST exist in attributes of this message. + /// + /// Status: [Development] + public var entityRefs: [Opentelemetry_Proto_Common_V1_EntityRef] = [] + public var unknownFields = SwiftProtobuf.UnknownStorage() public init() {} @@ -63,6 +70,7 @@ extension Opentelemetry_Proto_Resource_V1_Resource: SwiftProtobuf.Message, Swift public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 1: .same(proto: "attributes"), 2: .standard(proto: "dropped_attributes_count"), + 3: .standard(proto: "entity_refs"), ] public mutating func decodeMessage(decoder: inout D) throws { @@ -73,6 +81,7 @@ extension Opentelemetry_Proto_Resource_V1_Resource: SwiftProtobuf.Message, Swift switch fieldNumber { case 1: try { try decoder.decodeRepeatedMessageField(value: &self.attributes) }() case 2: try { try decoder.decodeSingularUInt32Field(value: &self.droppedAttributesCount) }() + case 3: try { try decoder.decodeRepeatedMessageField(value: &self.entityRefs) }() default: break } } @@ -85,12 +94,16 @@ extension Opentelemetry_Proto_Resource_V1_Resource: SwiftProtobuf.Message, Swift if self.droppedAttributesCount != 0 { try visitor.visitSingularUInt32Field(value: self.droppedAttributesCount, fieldNumber: 2) } + if !self.entityRefs.isEmpty { + try visitor.visitRepeatedMessageField(value: self.entityRefs, fieldNumber: 3) + } try unknownFields.traverse(visitor: &visitor) } public static func ==(lhs: Opentelemetry_Proto_Resource_V1_Resource, rhs: Opentelemetry_Proto_Resource_V1_Resource) -> Bool { if lhs.attributes != rhs.attributes {return false} if lhs.droppedAttributesCount != rhs.droppedAttributesCount {return false} + if lhs.entityRefs != rhs.entityRefs {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } diff --git a/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/logs_service.grpc.swift b/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/logs_service.grpc.swift index 708d7a118..a3cd20ee0 100644 --- a/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/logs_service.grpc.swift +++ b/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/logs_service.grpc.swift @@ -31,8 +31,7 @@ extension Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClientProtocol { return "opentelemetry.proto.collector.logs.v1.LogsService" } - /// For performance reasons, it is recommended to keep this RPC - /// alive for the entire life of the application. + /// Unary call to Export /// /// - Parameters: /// - request: Request to send to Export. @@ -209,8 +208,6 @@ public enum Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClientMetadata { public protocol Opentelemetry_Proto_Collector_Logs_V1_LogsServiceProvider: CallHandlerProvider { var interceptors: Opentelemetry_Proto_Collector_Logs_V1_LogsServiceServerInterceptorFactoryProtocol? { get } - /// For performance reasons, it is recommended to keep this RPC - /// alive for the entire life of the application. func export(request: Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceRequest, context: StatusOnlyCallContext) -> EventLoopFuture } @@ -251,8 +248,6 @@ public protocol Opentelemetry_Proto_Collector_Logs_V1_LogsServiceAsyncProvider: static var serviceDescriptor: GRPCServiceDescriptor { get } var interceptors: Opentelemetry_Proto_Collector_Logs_V1_LogsServiceServerInterceptorFactoryProtocol? { get } - /// For performance reasons, it is recommended to keep this RPC - /// alive for the entire life of the application. func export( request: Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceRequest, context: GRPCAsyncServerCallContext diff --git a/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/metrics_service.grpc.swift b/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/metrics_service.grpc.swift index d048f3b0a..a206ca0d3 100644 --- a/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/metrics_service.grpc.swift +++ b/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/metrics_service.grpc.swift @@ -11,6 +11,7 @@ import NIOConcurrencyHelpers import SwiftProtobuf import OpenTelemetryProtocolExporterCommon + /// Service that can be used to push metrics between one Application /// instrumented with OpenTelemetry and a collector, or between a collector and a /// central collector. @@ -31,8 +32,7 @@ extension Opentelemetry_Proto_Collector_Metrics_V1_MetricsServiceClientProtocol return "opentelemetry.proto.collector.metrics.v1.MetricsService" } - /// For performance reasons, it is recommended to keep this RPC - /// alive for the entire life of the application. + /// Unary call to Export /// /// - Parameters: /// - request: Request to send to Export. @@ -209,8 +209,6 @@ public enum Opentelemetry_Proto_Collector_Metrics_V1_MetricsServiceClientMetadat public protocol Opentelemetry_Proto_Collector_Metrics_V1_MetricsServiceProvider: CallHandlerProvider { var interceptors: Opentelemetry_Proto_Collector_Metrics_V1_MetricsServiceServerInterceptorFactoryProtocol? { get } - /// For performance reasons, it is recommended to keep this RPC - /// alive for the entire life of the application. func export(request: Opentelemetry_Proto_Collector_Metrics_V1_ExportMetricsServiceRequest, context: StatusOnlyCallContext) -> EventLoopFuture } @@ -251,8 +249,6 @@ public protocol Opentelemetry_Proto_Collector_Metrics_V1_MetricsServiceAsyncProv static var serviceDescriptor: GRPCServiceDescriptor { get } var interceptors: Opentelemetry_Proto_Collector_Metrics_V1_MetricsServiceServerInterceptorFactoryProtocol? { get } - /// For performance reasons, it is recommended to keep this RPC - /// alive for the entire life of the application. func export( request: Opentelemetry_Proto_Collector_Metrics_V1_ExportMetricsServiceRequest, context: GRPCAsyncServerCallContext diff --git a/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/profiles_service.grpc.swift b/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/profiles_service.grpc.swift index e4656664c..8b3ab7440 100644 --- a/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/profiles_service.grpc.swift +++ b/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/profiles_service.grpc.swift @@ -11,6 +11,7 @@ import NIOConcurrencyHelpers import SwiftProtobuf import OpenTelemetryProtocolExporterCommon + /// Service that can be used to push profiles between one Application instrumented with /// OpenTelemetry and a collector, or between a collector and a central collector. /// @@ -30,8 +31,7 @@ extension Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceCl return "opentelemetry.proto.collector.profiles.v1development.ProfilesService" } - /// For performance reasons, it is recommended to keep this RPC - /// alive for the entire life of the application. + /// Unary call to Export /// /// - Parameters: /// - request: Request to send to Export. @@ -206,8 +206,6 @@ public enum Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesService public protocol Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceProvider: CallHandlerProvider { var interceptors: Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceServerInterceptorFactoryProtocol? { get } - /// For performance reasons, it is recommended to keep this RPC - /// alive for the entire life of the application. func export(request: Opentelemetry_Proto_Collector_Profiles_V1development_ExportProfilesServiceRequest, context: StatusOnlyCallContext) -> EventLoopFuture } @@ -247,8 +245,6 @@ public protocol Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesSer static var serviceDescriptor: GRPCServiceDescriptor { get } var interceptors: Opentelemetry_Proto_Collector_Profiles_V1development_ProfilesServiceServerInterceptorFactoryProtocol? { get } - /// For performance reasons, it is recommended to keep this RPC - /// alive for the entire life of the application. func export( request: Opentelemetry_Proto_Collector_Profiles_V1development_ExportProfilesServiceRequest, context: GRPCAsyncServerCallContext diff --git a/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/trace_service.grpc.swift b/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/trace_service.grpc.swift index 2ba3bb236..125c09892 100644 --- a/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/trace_service.grpc.swift +++ b/Sources/Exporters/OpenTelemetryProtocolGrpc/proto/trace_service.grpc.swift @@ -11,6 +11,7 @@ import NIOConcurrencyHelpers import SwiftProtobuf import OpenTelemetryProtocolExporterCommon + /// Service that can be used to push spans between one Application instrumented with /// OpenTelemetry and a collector, or between a collector and a central collector (in this /// case spans are sent/received to/from multiple Applications). @@ -31,8 +32,7 @@ extension Opentelemetry_Proto_Collector_Trace_V1_TraceServiceClientProtocol { return "opentelemetry.proto.collector.trace.v1.TraceService" } - /// For performance reasons, it is recommended to keep this RPC - /// alive for the entire life of the application. + /// Unary call to Export /// /// - Parameters: /// - request: Request to send to Export. @@ -209,8 +209,6 @@ public enum Opentelemetry_Proto_Collector_Trace_V1_TraceServiceClientMetadata { public protocol Opentelemetry_Proto_Collector_Trace_V1_TraceServiceProvider: CallHandlerProvider { var interceptors: Opentelemetry_Proto_Collector_Trace_V1_TraceServiceServerInterceptorFactoryProtocol? { get } - /// For performance reasons, it is recommended to keep this RPC - /// alive for the entire life of the application. func export(request: Opentelemetry_Proto_Collector_Trace_V1_ExportTraceServiceRequest, context: StatusOnlyCallContext) -> EventLoopFuture } @@ -251,8 +249,6 @@ public protocol Opentelemetry_Proto_Collector_Trace_V1_TraceServiceAsyncProvider static var serviceDescriptor: GRPCServiceDescriptor { get } var interceptors: Opentelemetry_Proto_Collector_Trace_V1_TraceServiceServerInterceptorFactoryProtocol? { get } - /// For performance reasons, it is recommended to keep this RPC - /// alive for the entire life of the application. func export( request: Opentelemetry_Proto_Collector_Trace_V1_ExportTraceServiceRequest, context: GRPCAsyncServerCallContext diff --git a/Sources/OpenTelemetrySdk/Resources/Detectors/ProcessDetector.swift b/Sources/OpenTelemetrySdk/Resources/Detectors/ProcessDetector.swift new file mode 100644 index 000000000..ee8e87ab2 --- /dev/null +++ b/Sources/OpenTelemetrySdk/Resources/Detectors/ProcessDetector.swift @@ -0,0 +1,26 @@ +// +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 +// + +import Foundation + +public struct ProcessDetector : EntityDetector { + public init() {} + public func detectEntities() -> [Entity] { + return [Entity.builder(type: "process") + .with(identifiersKeys: [ + ResourceAttributes.processExecutableName.rawValue, + ]) + .with(attributeKeys: [ + ResourceAttributes.processExecutablePath.rawValue, + ResourceAttributes.processPid.rawValue, + ResourceAttributes.processOwner.rawValue, + ResourceAttributes.processParentPid.rawValue, + ResourceAttributes.processCommandArgs.rawValue, + ResourceAttributes.processCommandLine.rawValue, + + ]) + .build()] + } +} diff --git a/Sources/OpenTelemetrySdk/Resources/Detectors/ServiceDetector.swift b/Sources/OpenTelemetrySdk/Resources/Detectors/ServiceDetector.swift new file mode 100644 index 000000000..744382d9e --- /dev/null +++ b/Sources/OpenTelemetrySdk/Resources/Detectors/ServiceDetector.swift @@ -0,0 +1,19 @@ +// +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 +// + +public struct ServiceDetector : EntityDetector { + public init() {} + public func detectEntities() -> [Entity] { + return [Entity.builder(type: "service") + .with(identifiersKeys: [ + ResourceAttributes.serviceName.rawValue, + ]) + .with(attributeKeys: [ + ResourceAttributes.serviceVersion.rawValue, + ResourceAttributes.serviceNamespace.rawValue, + ]) + .build()] + } +} diff --git a/Sources/OpenTelemetrySdk/Resources/Detectors/TelemetrySdkDetector.swift b/Sources/OpenTelemetrySdk/Resources/Detectors/TelemetrySdkDetector.swift new file mode 100644 index 000000000..d323c912b --- /dev/null +++ b/Sources/OpenTelemetrySdk/Resources/Detectors/TelemetrySdkDetector.swift @@ -0,0 +1,21 @@ +// +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 +// + +import Foundation + +public struct TelemetrySdkDetector : EntityDetector { + public init() {} + public func detectEntities() -> [Entity] { + return [Entity.builder(type: "telemetry.sdk") + .with(identifiersKeys: [ + ResourceAttributes.telemetrySdkName.rawValue, + ResourceAttributes.telemetrySdkLanguage.rawValue, + ]) + .with(attributeKeys: [ + ResourceAttributes.telemetrySdkVersion.rawValue, + ]) + .build()] + } +} diff --git a/Sources/OpenTelemetrySdk/Resources/Entity.swift b/Sources/OpenTelemetrySdk/Resources/Entity.swift index 8db058f53..f99cd616f 100644 --- a/Sources/OpenTelemetrySdk/Resources/Entity.swift +++ b/Sources/OpenTelemetrySdk/Resources/Entity.swift @@ -12,11 +12,11 @@ public struct Entity : Codable, Hashable, Equatable { /// id: A set of attributes that identifies the Entity. /// MUST not change during the lifetime of the Entity. The Id must contain at least one attribute. - public let identifiers: [String: AttributeValue] + public let identifierKeys: Set /// A set of descriptive (non-identifying) attributes of the Entity. /// MAY change over the lifetime of the entity. MAY be empty. These attributes are not part of Entity's identity. - public var attributes: [String: AttributeValue] + public var attributeKeys: Set public static func builder(type: String) -> EntityBuilder { diff --git a/Sources/OpenTelemetrySdk/Resources/EntityBuilder.swift b/Sources/OpenTelemetrySdk/Resources/EntityBuilder.swift index 67fda7f21..513df853a 100644 --- a/Sources/OpenTelemetrySdk/Resources/EntityBuilder.swift +++ b/Sources/OpenTelemetrySdk/Resources/EntityBuilder.swift @@ -7,26 +7,26 @@ import OpenTelemetryApi public class EntityBuilder { private var type: String - private var identifiers: [String: AttributeValue] = [:] - private var attributes: [String: AttributeValue] = [:] + private var identifierKeys: Set = [] + private var attributeKeys: Set = [] internal init(type: String) { self.type = type } - public func with(identifiers: [String: AttributeValue]) -> Self { - self.identifiers = identifiers + public func with(identifiersKeys: [String]) -> Self { + self.identifierKeys = Set(identifiersKeys) return self } - public func with(attributes: [String: AttributeValue]) -> Self { - self.attributes = attributes + public func with(attributeKeys: [String]) -> Self { + self.attributeKeys = Set(attributeKeys) return self } public func build() -> Entity { return Entity(type: type, - identifiers: identifiers, - attributes: attributes) + identifierKeys: identifierKeys, + attributeKeys: attributeKeys) } } diff --git a/Sources/OpenTelemetrySdk/Resources/EntityDetector.swift b/Sources/OpenTelemetrySdk/Resources/EntityDetector.swift new file mode 100644 index 000000000..a3a148373 --- /dev/null +++ b/Sources/OpenTelemetrySdk/Resources/EntityDetector.swift @@ -0,0 +1,9 @@ +// +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 +// + + +public protocol EntityDetector { + func detectEntities() -> [Entity] +} diff --git a/Sources/OpenTelemetrySdk/Resources/Resource.swift b/Sources/OpenTelemetrySdk/Resources/Resource.swift index 8d5cc87b2..0e4e72b55 100644 --- a/Sources/OpenTelemetrySdk/Resources/Resource.swift +++ b/Sources/OpenTelemetrySdk/Resources/Resource.swift @@ -32,6 +32,15 @@ public struct Resource: Equatable, Hashable, Codable { ) } + public func builder() -> ResourceBuilder { + return ResourceBuilder() + .add(attributes: self.attributes) + } + + public static func builder() -> ResourceBuilder { + return ResourceBuilder() + } + private static func mergeEntities(_ lhs: [Entity], _ rhs: [Entity]) -> [Entity] { if lhs.isEmpty { return rhs @@ -50,9 +59,8 @@ public struct Resource: Equatable, Hashable, Codable { } else { if let old = entityMap[entity.type] { let new = Entity.builder(type: old.type) - .with(identifiers: old.identifiers) - .with(attributes: entity.attributes - .merging(old.attributes) { _, old in old }) + .with(identifiersKeys: Array(entity.identifierKeys.union(old.identifierKeys))) + .with(attributeKeys: Array(entity.attributeKeys.union(old.attributeKeys))) .build() entityMap[entity.type] = new } @@ -71,17 +79,7 @@ public struct Resource: Equatable, Hashable, Codable { public init(attributes: [String: AttributeValue], entities: [Entity] = []) { self.entities = entities if Resource.checkAttributes(attributes: attributes) { - self.attributes = attributes.filter { key, _ in - for entity in entities { - if entity.attributes.contains(where: { attribute in attribute.key == key }) { - return true - } - if entity.identifiers.contains(where: { attribute in attribute.key == key }) { - return true - } - } - return false - } + self.attributes = attributes } else { self.attributes = [String: AttributeValue]() } diff --git a/Sources/OpenTelemetrySdk/Resources/ResourceBuilder.swift b/Sources/OpenTelemetrySdk/Resources/ResourceBuilder.swift new file mode 100644 index 000000000..c14af6185 --- /dev/null +++ b/Sources/OpenTelemetrySdk/Resources/ResourceBuilder.swift @@ -0,0 +1,46 @@ +// +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 +// + +import OpenTelemetryApi +#if canImport(os.log) +import os.log +#endif + +public class ResourceBuilder { + private var attributes: [String: AttributeValue] = [:] + private var entities: [Entity] = [] + + public func add(entityDetector: EntityDetector) -> Self { + entities.append(contentsOf: entityDetector.detectEntities()) + return self + } + + public func add(attributes: [String: AttributeValue]) -> Self { + for element in attributes { + _ = self.add(key: element.key, value: element.value) + } + return self + } + + func add(key: String, value: AttributeValue) -> Self { + if(!Resource.checkAttributes(attributes: [key: value])) { +#if canImport(os.log) + os_log( + .error, + "Failed to add attribute %@: %@, invalid key.", + key, + value.description + ) +#endif + return self + } + attributes[key] = value + return self + } + + public func build() -> Resource { + Resource(attributes: self.attributes, entities: entities) + } +}