From 0244f5a510c86e9d7959040a092e14fd700f5fb2 Mon Sep 17 00:00:00 2001 From: Joannis Orlandos Date: Fri, 8 Mar 2024 17:56:39 +0100 Subject: [PATCH 1/2] Generate Swift protobuf code for logging support --- Makefile | 4 +- .../opentelemetry/proto/logs/v1/logs.pb.swift | 674 ++++++++++++++++++ .../collector/logs/v1/logs_service.grpc.swift | 203 ++++++ .../collector/logs/v1/logs_service.pb.swift | 231 ++++++ .../metrics/v1/metrics_service.pb.swift | 6 + .../collector/trace/v1/trace_service.pb.swift | 6 + .../collector/logs/v1/logs_service.grpc.swift | 129 ++++ .../collector/logs/v1/logs_service.pb.swift | 231 ++++++ .../metrics/v1/metrics_service.pb.swift | 6 + .../collector/trace/v1/trace_service.pb.swift | 6 + .../OTLPGRPCTests/OTLPGRPCMockCollector.swift | 19 +- module-mapping.proto | 1 + 12 files changed, 1497 insertions(+), 19 deletions(-) create mode 100644 Sources/OTLPCore/Generated/opentelemetry/proto/logs/v1/logs.pb.swift create mode 100644 Sources/OTLPGRPC/Generated/opentelemetry/proto/collector/logs/v1/logs_service.grpc.swift create mode 100644 Sources/OTLPGRPC/Generated/opentelemetry/proto/collector/logs/v1/logs_service.pb.swift create mode 100644 Tests/OTLPGRPCTests/Generated/opentelemetry/proto/collector/logs/v1/logs_service.grpc.swift create mode 100644 Tests/OTLPGRPCTests/Generated/opentelemetry/proto/collector/logs/v1/logs_service.pb.swift diff --git a/Makefile b/Makefile index f14fb9ff..50af66d1 100644 --- a/Makefile +++ b/Makefile @@ -73,16 +73,18 @@ OTLP_SERVER_GRPC_SWIFT_ROOT = Tests/OTLPGRPCTests/Generated OTLP_CORE_PROTOS += $(PROTO_ROOT)/opentelemetry/proto/common/v1/common.proto OTLP_CORE_PROTOS += $(PROTO_ROOT)/opentelemetry/proto/resource/v1/resource.proto +OTLP_CORE_PROTOS += $(PROTO_ROOT)/opentelemetry/proto/logs/v1/logs.proto OTLP_CORE_PROTOS += $(PROTO_ROOT)/opentelemetry/proto/metrics/v1/metrics.proto OTLP_CORE_PROTOS += $(PROTO_ROOT)/opentelemetry/proto/trace/v1/trace.proto +OTLP_GRPC_PROTOS += $(PROTO_ROOT)/opentelemetry/proto/collector/logs/v1/logs_service.proto OTLP_GRPC_PROTOS += $(PROTO_ROOT)/opentelemetry/proto/collector/metrics/v1/metrics_service.proto OTLP_GRPC_PROTOS += $(PROTO_ROOT)/opentelemetry/proto/collector/trace/v1/trace_service.proto OTLP_CORE_SWIFTS = $(patsubst $(PROTO_ROOT)/%.proto,$(OTLP_CORE_SWIFT_ROOT)/%.pb.swift,$(OTLP_CORE_PROTOS)) OTLP_CLIENT_GRPC_SWIFTS = $(subst $(PROTO_ROOT),$(OTLP_CLIENT_GRPC_SWIFT_ROOT),$(OTLP_GRPC_PROTOS:.proto=.pb.swift) $(OTLP_GRPC_PROTOS:.proto=.grpc.swift)) -OTLP_SERVER_GRPC_SWIFTS = $(subst $(PROTO_ROOT),$(OTLP_CLIENT_GRPC_SWIFT_ROOT),$(OTLP_GRPC_PROTOS:.proto=.pb.swift) $(OTLP_GRPC_PROTOS:.proto=.grpc.swift)) +OTLP_SERVER_GRPC_SWIFTS = $(subst $(PROTO_ROOT),$(OTLP_SERVER_GRPC_SWIFT_ROOT),$(OTLP_GRPC_PROTOS:.proto=.pb.swift) $(OTLP_GRPC_PROTOS:.proto=.grpc.swift)) $(OTLP_CORE_SWIFTS): $(OTLP_CORE_PROTOS) $(PROTO_MODULEMAP) $(PROTOC_GEN_SWIFT) @mkdir -pv $(OTLP_CORE_SWIFT_ROOT) diff --git a/Sources/OTLPCore/Generated/opentelemetry/proto/logs/v1/logs.pb.swift b/Sources/OTLPCore/Generated/opentelemetry/proto/logs/v1/logs.pb.swift new file mode 100644 index 00000000..1cbe13ce --- /dev/null +++ b/Sources/OTLPCore/Generated/opentelemetry/proto/logs/v1/logs.pb.swift @@ -0,0 +1,674 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: opentelemetry/proto/logs/v1/logs.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +// Copyright 2020, 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 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 +} + +/// Possible values for LogRecord.SeverityNumber. +public enum Opentelemetry_Proto_Logs_V1_SeverityNumber: SwiftProtobuf.Enum { + public typealias RawValue = Int + + /// UNSPECIFIED is the default SeverityNumber, it MUST NOT be used. + case unspecified // = 0 + case trace // = 1 + case trace2 // = 2 + case trace3 // = 3 + case trace4 // = 4 + case debug // = 5 + case debug2 // = 6 + case debug3 // = 7 + case debug4 // = 8 + case info // = 9 + case info2 // = 10 + case info3 // = 11 + case info4 // = 12 + case warn // = 13 + case warn2 // = 14 + case warn3 // = 15 + case warn4 // = 16 + case error // = 17 + case error2 // = 18 + case error3 // = 19 + case error4 // = 20 + case fatal // = 21 + case fatal2 // = 22 + case fatal3 // = 23 + case fatal4 // = 24 + case UNRECOGNIZED(Int) + + public init() { + self = .unspecified + } + + public init?(rawValue: Int) { + switch rawValue { + case 0: self = .unspecified + case 1: self = .trace + case 2: self = .trace2 + case 3: self = .trace3 + case 4: self = .trace4 + case 5: self = .debug + case 6: self = .debug2 + case 7: self = .debug3 + case 8: self = .debug4 + case 9: self = .info + case 10: self = .info2 + case 11: self = .info3 + case 12: self = .info4 + case 13: self = .warn + case 14: self = .warn2 + case 15: self = .warn3 + case 16: self = .warn4 + case 17: self = .error + case 18: self = .error2 + case 19: self = .error3 + case 20: self = .error4 + case 21: self = .fatal + case 22: self = .fatal2 + case 23: self = .fatal3 + case 24: self = .fatal4 + default: self = .UNRECOGNIZED(rawValue) + } + } + + public var rawValue: Int { + switch self { + case .unspecified: return 0 + case .trace: return 1 + case .trace2: return 2 + case .trace3: return 3 + case .trace4: return 4 + case .debug: return 5 + case .debug2: return 6 + case .debug3: return 7 + case .debug4: return 8 + case .info: return 9 + case .info2: return 10 + case .info3: return 11 + case .info4: return 12 + case .warn: return 13 + case .warn2: return 14 + case .warn3: return 15 + case .warn4: return 16 + case .error: return 17 + case .error2: return 18 + case .error3: return 19 + case .error4: return 20 + case .fatal: return 21 + case .fatal2: return 22 + case .fatal3: return 23 + case .fatal4: return 24 + case .UNRECOGNIZED(let i): return i + } + } + +} + +#if swift(>=4.2) + +extension Opentelemetry_Proto_Logs_V1_SeverityNumber: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + public static let allCases: [Opentelemetry_Proto_Logs_V1_SeverityNumber] = [ + .unspecified, + .trace, + .trace2, + .trace3, + .trace4, + .debug, + .debug2, + .debug3, + .debug4, + .info, + .info2, + .info3, + .info4, + .warn, + .warn2, + .warn3, + .warn4, + .error, + .error2, + .error3, + .error4, + .fatal, + .fatal2, + .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: +/// +/// (logRecord.flags & LOG_RECORD_FLAGS_TRACE_FLAGS_MASK) +public enum Opentelemetry_Proto_Logs_V1_LogRecordFlags: SwiftProtobuf.Enum { + 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 + case UNRECOGNIZED(Int) + + public init() { + self = .doNotUse + } + + public init?(rawValue: Int) { + switch rawValue { + case 0: self = .doNotUse + case 255: self = .traceFlagsMask + default: self = .UNRECOGNIZED(rawValue) + } + } + + public var rawValue: Int { + switch self { + case .doNotUse: return 0 + case .traceFlagsMask: return 255 + case .UNRECOGNIZED(let i): return i + } + } + +} + +#if swift(>=4.2) + +extension Opentelemetry_Proto_Logs_V1_LogRecordFlags: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + 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 +/// 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_Logs_V1_LogsData { + // 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 ResourceLogs. + /// 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 resourceLogs: [Opentelemetry_Proto_Logs_V1_ResourceLogs] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// A collection of ScopeLogs from a Resource. +public struct Opentelemetry_Proto_Logs_V1_ResourceLogs { + // 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 logs in this message. + /// If this field is not set then resource info is unknown. + 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 ScopeLogs that originate from a resource. + public var scopeLogs: [Opentelemetry_Proto_Logs_V1_ScopeLogs] = [] + + /// 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() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _resource: Opentelemetry_Proto_Resource_V1_Resource? = nil +} + +/// A collection of Logs produced by a Scope. +public struct Opentelemetry_Proto_Logs_V1_ScopeLogs { + // 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 logs 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 log records. + public var logRecords: [Opentelemetry_Proto_Logs_V1_LogRecord] = [] + + /// This schema_url applies to all logs in the "logs" field. + public var schemaURL: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _scope: Opentelemetry_Proto_Common_V1_InstrumentationScope? = nil +} + +/// 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 { + // 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. + + /// time_unix_nano is the time when the event occurred. + /// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. + /// Value of 0 indicates unknown or missing timestamp. + public var timeUnixNano: UInt64 = 0 + + /// Time when the event was observed by the collection system. + /// For events that originate in OpenTelemetry (e.g. using OpenTelemetry Logging SDK) + /// this timestamp is typically set at the generation time and is equal to Timestamp. + /// For events originating externally and collected by OpenTelemetry (e.g. using + /// Collector) this is the time when OpenTelemetry's code observed the event measured + /// by the clock of the OpenTelemetry code. This field MUST be set once the event is + /// observed by OpenTelemetry. + /// + /// For converting OpenTelemetry log data to formats that support only one timestamp or + /// when receiving OpenTelemetry log data by recipients that support only one timestamp + /// internally the following logic is recommended: + /// - Use time_unix_nano if it is present, otherwise use observed_time_unix_nano. + /// + /// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. + /// Value of 0 indicates unknown or missing timestamp. + public var observedTimeUnixNano: UInt64 = 0 + + /// Numerical value of the severity, normalized to values described in Log Data Model. + /// [Optional]. + public var severityNumber: Opentelemetry_Proto_Logs_V1_SeverityNumber = .unspecified + + /// The severity text (also known as log level). The original string representation as + /// it is known at the source. [Optional]. + public var severityText: String = String() + + /// A value containing the body of the log record. Can be for example a human-readable + /// string message (including multi-line) describing the event in a free form or it can + /// be a structured data composed of arrays and maps of other values. [Optional]. + public var body: Opentelemetry_Proto_Common_V1_AnyValue { + get {return _body ?? Opentelemetry_Proto_Common_V1_AnyValue()} + set {_body = newValue} + } + /// Returns true if `body` has been explicitly set. + public var hasBody: Bool {return self._body != nil} + /// Clears the value of `body`. Subsequent reads from it will return its default value. + public mutating func clearBody() {self._body = nil} + + /// Additional attributes that describe the specific event occurrence. [Optional]. + /// 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 droppedAttributesCount: UInt32 = 0 + + /// Flags, a bit field. 8 least significant bits are the trace flags as + /// defined in W3C Trace Context specification. 24 most significant bits are reserved + /// and must be set to 0. Readers must not assume that 24 most significant bits + /// will be zero and must correctly mask the bits when reading 8-bit trace flag (use + /// flags & LOG_RECORD_FLAGS_TRACE_FLAGS_MASK). [Optional]. + public var flags: UInt32 = 0 + + /// A unique identifier for a trace. All logs from the same trace share + /// the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes OR + /// of length other than 16 bytes is considered invalid (empty string in OTLP/JSON + /// is zero-length and thus is also invalid). + /// + /// This field is optional. + /// + /// The receivers SHOULD assume that the log record is not associated with a + /// trace if any of the following is true: + /// - the field is not present, + /// - the field contains an invalid value. + public var traceID: Data = Data() + + /// 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 + /// other than 8 bytes is considered invalid (empty string in OTLP/JSON + /// is zero-length and thus is also invalid). + /// + /// This field is optional. If the sender specifies a valid span_id then it SHOULD also + /// specify a valid trace_id. + /// + /// The receivers SHOULD assume that the log record is not associated with a + /// span if any of the following is true: + /// - the field is not present, + /// - the field contains an invalid value. + public var spanID: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + 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" + +extension Opentelemetry_Proto_Logs_V1_SeverityNumber: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "SEVERITY_NUMBER_UNSPECIFIED"), + 1: .same(proto: "SEVERITY_NUMBER_TRACE"), + 2: .same(proto: "SEVERITY_NUMBER_TRACE2"), + 3: .same(proto: "SEVERITY_NUMBER_TRACE3"), + 4: .same(proto: "SEVERITY_NUMBER_TRACE4"), + 5: .same(proto: "SEVERITY_NUMBER_DEBUG"), + 6: .same(proto: "SEVERITY_NUMBER_DEBUG2"), + 7: .same(proto: "SEVERITY_NUMBER_DEBUG3"), + 8: .same(proto: "SEVERITY_NUMBER_DEBUG4"), + 9: .same(proto: "SEVERITY_NUMBER_INFO"), + 10: .same(proto: "SEVERITY_NUMBER_INFO2"), + 11: .same(proto: "SEVERITY_NUMBER_INFO3"), + 12: .same(proto: "SEVERITY_NUMBER_INFO4"), + 13: .same(proto: "SEVERITY_NUMBER_WARN"), + 14: .same(proto: "SEVERITY_NUMBER_WARN2"), + 15: .same(proto: "SEVERITY_NUMBER_WARN3"), + 16: .same(proto: "SEVERITY_NUMBER_WARN4"), + 17: .same(proto: "SEVERITY_NUMBER_ERROR"), + 18: .same(proto: "SEVERITY_NUMBER_ERROR2"), + 19: .same(proto: "SEVERITY_NUMBER_ERROR3"), + 20: .same(proto: "SEVERITY_NUMBER_ERROR4"), + 21: .same(proto: "SEVERITY_NUMBER_FATAL"), + 22: .same(proto: "SEVERITY_NUMBER_FATAL2"), + 23: .same(proto: "SEVERITY_NUMBER_FATAL3"), + 24: .same(proto: "SEVERITY_NUMBER_FATAL4"), + ] +} + +extension Opentelemetry_Proto_Logs_V1_LogRecordFlags: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "LOG_RECORD_FLAGS_DO_NOT_USE"), + 255: .same(proto: "LOG_RECORD_FLAGS_TRACE_FLAGS_MASK"), + ] +} + +extension Opentelemetry_Proto_Logs_V1_LogsData: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".LogsData" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "resource_logs"), + ] + + 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.resourceLogs) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.resourceLogs.isEmpty { + try visitor.visitRepeatedMessageField(value: self.resourceLogs, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Opentelemetry_Proto_Logs_V1_LogsData, rhs: Opentelemetry_Proto_Logs_V1_LogsData) -> Bool { + if lhs.resourceLogs != rhs.resourceLogs {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Opentelemetry_Proto_Logs_V1_ResourceLogs: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ResourceLogs" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "resource"), + 2: .standard(proto: "scope_logs"), + 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.scopeLogs) }() + 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.scopeLogs.isEmpty { + try visitor.visitRepeatedMessageField(value: self.scopeLogs, 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_Logs_V1_ResourceLogs, rhs: Opentelemetry_Proto_Logs_V1_ResourceLogs) -> Bool { + if lhs._resource != rhs._resource {return false} + if lhs.scopeLogs != rhs.scopeLogs {return false} + if lhs.schemaURL != rhs.schemaURL {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Opentelemetry_Proto_Logs_V1_ScopeLogs: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ScopeLogs" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "scope"), + 2: .standard(proto: "log_records"), + 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.logRecords) }() + 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.logRecords.isEmpty { + try visitor.visitRepeatedMessageField(value: self.logRecords, 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_Logs_V1_ScopeLogs, rhs: Opentelemetry_Proto_Logs_V1_ScopeLogs) -> Bool { + if lhs._scope != rhs._scope {return false} + if lhs.logRecords != rhs.logRecords {return false} + if lhs.schemaURL != rhs.schemaURL {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Opentelemetry_Proto_Logs_V1_LogRecord: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".LogRecord" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "time_unix_nano"), + 11: .standard(proto: "observed_time_unix_nano"), + 2: .standard(proto: "severity_number"), + 3: .standard(proto: "severity_text"), + 5: .same(proto: "body"), + 6: .same(proto: "attributes"), + 7: .standard(proto: "dropped_attributes_count"), + 8: .same(proto: "flags"), + 9: .standard(proto: "trace_id"), + 10: .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.decodeSingularFixed64Field(value: &self.timeUnixNano) }() + case 2: try { try decoder.decodeSingularEnumField(value: &self.severityNumber) }() + case 3: try { try decoder.decodeSingularStringField(value: &self.severityText) }() + case 5: try { try decoder.decodeSingularMessageField(value: &self._body) }() + case 6: try { try decoder.decodeRepeatedMessageField(value: &self.attributes) }() + case 7: try { try decoder.decodeSingularUInt32Field(value: &self.droppedAttributesCount) }() + case 8: try { try decoder.decodeSingularFixed32Field(value: &self.flags) }() + 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) }() + 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.timeUnixNano != 0 { + try visitor.visitSingularFixed64Field(value: self.timeUnixNano, fieldNumber: 1) + } + if self.severityNumber != .unspecified { + try visitor.visitSingularEnumField(value: self.severityNumber, fieldNumber: 2) + } + if !self.severityText.isEmpty { + try visitor.visitSingularStringField(value: self.severityText, fieldNumber: 3) + } + try { if let v = self._body { + try visitor.visitSingularMessageField(value: v, fieldNumber: 5) + } }() + if !self.attributes.isEmpty { + try visitor.visitRepeatedMessageField(value: self.attributes, fieldNumber: 6) + } + if self.droppedAttributesCount != 0 { + try visitor.visitSingularUInt32Field(value: self.droppedAttributesCount, fieldNumber: 7) + } + if self.flags != 0 { + try visitor.visitSingularFixed32Field(value: self.flags, fieldNumber: 8) + } + if !self.traceID.isEmpty { + try visitor.visitSingularBytesField(value: self.traceID, fieldNumber: 9) + } + if !self.spanID.isEmpty { + try visitor.visitSingularBytesField(value: self.spanID, fieldNumber: 10) + } + if self.observedTimeUnixNano != 0 { + try visitor.visitSingularFixed64Field(value: self.observedTimeUnixNano, fieldNumber: 11) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Opentelemetry_Proto_Logs_V1_LogRecord, rhs: Opentelemetry_Proto_Logs_V1_LogRecord) -> Bool { + if lhs.timeUnixNano != rhs.timeUnixNano {return false} + if lhs.observedTimeUnixNano != rhs.observedTimeUnixNano {return false} + if lhs.severityNumber != rhs.severityNumber {return false} + if lhs.severityText != rhs.severityText {return false} + if lhs._body != rhs._body {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.traceID != rhs.traceID {return false} + if lhs.spanID != rhs.spanID {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/Sources/OTLPGRPC/Generated/opentelemetry/proto/collector/logs/v1/logs_service.grpc.swift b/Sources/OTLPGRPC/Generated/opentelemetry/proto/collector/logs/v1/logs_service.grpc.swift new file mode 100644 index 00000000..3633c8e8 --- /dev/null +++ b/Sources/OTLPGRPC/Generated/opentelemetry/proto/collector/logs/v1/logs_service.grpc.swift @@ -0,0 +1,203 @@ +// +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the protocol buffer compiler. +// Source: opentelemetry/proto/collector/logs/v1/logs_service.proto +// +import GRPC +import NIO +import NIOConcurrencyHelpers +import SwiftProtobuf + + +/// Service that can be used to push logs between one Application instrumented with +/// OpenTelemetry and an collector, or between an collector and a central collector (in this +/// case logs are sent/received to/from multiple Applications). +/// +/// Usage: instantiate `Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClient`, then call methods of this protocol to make API calls. +internal protocol Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClientProtocol: GRPCClient { + var serviceName: String { get } + var interceptors: Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClientInterceptorFactoryProtocol? { get } + + func export( + _ request: Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceRequest, + callOptions: CallOptions? + ) -> UnaryCall +} + +extension Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClientProtocol { + internal var serviceName: String { + 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. + /// + /// - Parameters: + /// - request: Request to send to Export. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + internal func export( + _ request: Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return self.makeUnaryCall( + path: Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClientMetadata.Methods.export.path, + request: request, + callOptions: callOptions ?? self.defaultCallOptions, + interceptors: self.interceptors?.makeExportInterceptors() ?? [] + ) + } +} + +@available(*, deprecated) +extension Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClient: @unchecked Sendable {} + +@available(*, deprecated, renamed: "Opentelemetry_Proto_Collector_Logs_V1_LogsServiceNIOClient") +internal final class Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClient: Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClientProtocol { + private let lock = Lock() + private var _defaultCallOptions: CallOptions + private var _interceptors: Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClientInterceptorFactoryProtocol? + internal let channel: GRPCChannel + internal var defaultCallOptions: CallOptions { + get { self.lock.withLock { return self._defaultCallOptions } } + set { self.lock.withLockVoid { self._defaultCallOptions = newValue } } + } + internal var interceptors: Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClientInterceptorFactoryProtocol? { + get { self.lock.withLock { return self._interceptors } } + set { self.lock.withLockVoid { self._interceptors = newValue } } + } + + /// Creates a client for the opentelemetry.proto.collector.logs.v1.LogsService 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. + internal init( + channel: GRPCChannel, + defaultCallOptions: CallOptions = CallOptions(), + interceptors: Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClientInterceptorFactoryProtocol? = nil + ) { + self.channel = channel + self._defaultCallOptions = defaultCallOptions + self._interceptors = interceptors + } +} + +internal struct Opentelemetry_Proto_Collector_Logs_V1_LogsServiceNIOClient: Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClientProtocol { + internal var channel: GRPCChannel + internal var defaultCallOptions: CallOptions + internal var interceptors: Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClientInterceptorFactoryProtocol? + + /// Creates a client for the opentelemetry.proto.collector.logs.v1.LogsService 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. + internal init( + channel: GRPCChannel, + defaultCallOptions: CallOptions = CallOptions(), + interceptors: Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClientInterceptorFactoryProtocol? = nil + ) { + self.channel = channel + self.defaultCallOptions = defaultCallOptions + self.interceptors = interceptors + } +} + +/// Service that can be used to push logs between one Application instrumented with +/// OpenTelemetry and an collector, or between an collector and a central collector (in this +/// case logs are sent/received to/from multiple Applications). +@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) +internal protocol Opentelemetry_Proto_Collector_Logs_V1_LogsServiceAsyncClientProtocol: GRPCClient { + static var serviceDescriptor: GRPCServiceDescriptor { get } + var interceptors: Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClientInterceptorFactoryProtocol? { get } + + func makeExportCall( + _ request: Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceRequest, + callOptions: CallOptions? + ) -> GRPCAsyncUnaryCall +} + +@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) +extension Opentelemetry_Proto_Collector_Logs_V1_LogsServiceAsyncClientProtocol { + internal static var serviceDescriptor: GRPCServiceDescriptor { + return Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClientMetadata.serviceDescriptor + } + + internal var interceptors: Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClientInterceptorFactoryProtocol? { + return nil + } + + internal func makeExportCall( + _ request: Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceRequest, + callOptions: CallOptions? = nil + ) -> GRPCAsyncUnaryCall { + return self.makeAsyncUnaryCall( + path: Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClientMetadata.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_Logs_V1_LogsServiceAsyncClientProtocol { + internal func export( + _ request: Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceRequest, + callOptions: CallOptions? = nil + ) async throws -> Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceResponse { + return try await self.performAsyncUnaryCall( + path: Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClientMetadata.Methods.export.path, + request: request, + callOptions: callOptions ?? self.defaultCallOptions, + interceptors: self.interceptors?.makeExportInterceptors() ?? [] + ) + } +} + +@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) +internal struct Opentelemetry_Proto_Collector_Logs_V1_LogsServiceAsyncClient: Opentelemetry_Proto_Collector_Logs_V1_LogsServiceAsyncClientProtocol { + internal var channel: GRPCChannel + internal var defaultCallOptions: CallOptions + internal var interceptors: Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClientInterceptorFactoryProtocol? + + internal init( + channel: GRPCChannel, + defaultCallOptions: CallOptions = CallOptions(), + interceptors: Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClientInterceptorFactoryProtocol? = nil + ) { + self.channel = channel + self.defaultCallOptions = defaultCallOptions + self.interceptors = interceptors + } +} + +internal protocol Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClientInterceptorFactoryProtocol: Sendable { + + /// - Returns: Interceptors to use when invoking 'export'. + func makeExportInterceptors() -> [ClientInterceptor] +} + +internal enum Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClientMetadata { + internal static let serviceDescriptor = GRPCServiceDescriptor( + name: "LogsService", + fullName: "opentelemetry.proto.collector.logs.v1.LogsService", + methods: [ + Opentelemetry_Proto_Collector_Logs_V1_LogsServiceClientMetadata.Methods.export, + ] + ) + + internal enum Methods { + internal static let export = GRPCMethodDescriptor( + name: "Export", + path: "/opentelemetry.proto.collector.logs.v1.LogsService/Export", + type: GRPCCallType.unary + ) + } +} + diff --git a/Sources/OTLPGRPC/Generated/opentelemetry/proto/collector/logs/v1/logs_service.pb.swift b/Sources/OTLPGRPC/Generated/opentelemetry/proto/collector/logs/v1/logs_service.pb.swift new file mode 100644 index 00000000..e4178464 --- /dev/null +++ b/Sources/OTLPGRPC/Generated/opentelemetry/proto/collector/logs/v1/logs_service.pb.swift @@ -0,0 +1,231 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: opentelemetry/proto/collector/logs/v1/logs_service.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +// Copyright 2020, 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 Foundation +import SwiftProtobuf + +import OTLPCore + +// 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 +} + +struct Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceRequest { + // 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 ResourceLogs. + /// 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. + var resourceLogs: [OTLPCore.Opentelemetry_Proto_Logs_V1_ResourceLogs] = [] + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceResponse { + // 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. + var partialSuccess: Opentelemetry_Proto_Collector_Logs_V1_ExportLogsPartialSuccess { + get {return _partialSuccess ?? Opentelemetry_Proto_Collector_Logs_V1_ExportLogsPartialSuccess()} + set {_partialSuccess = newValue} + } + /// Returns true if `partialSuccess` has been explicitly set. + var hasPartialSuccess: Bool {return self._partialSuccess != nil} + /// Clears the value of `partialSuccess`. Subsequent reads from it will return its default value. + mutating func clearPartialSuccess() {self._partialSuccess = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _partialSuccess: Opentelemetry_Proto_Collector_Logs_V1_ExportLogsPartialSuccess? = nil +} + +struct Opentelemetry_Proto_Collector_Logs_V1_ExportLogsPartialSuccess { + // 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 log records. + /// + /// A `rejected_` field holding a `0` value indicates that the + /// request was fully accepted. + var rejectedLogRecords: 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. + var errorMessage: String = String() + + var unknownFields = SwiftProtobuf.UnknownStorage() + + 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" + +extension Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".ExportLogsServiceRequest" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "resource_logs"), + ] + + 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.resourceLogs) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if !self.resourceLogs.isEmpty { + try visitor.visitRepeatedMessageField(value: self.resourceLogs, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceRequest, rhs: Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceRequest) -> Bool { + if lhs.resourceLogs != rhs.resourceLogs {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".ExportLogsServiceResponse" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "partial_success"), + ] + + 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 + } + } + } + + 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) + } + + static func ==(lhs: Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceResponse, rhs: Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceResponse) -> Bool { + if lhs._partialSuccess != rhs._partialSuccess {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Opentelemetry_Proto_Collector_Logs_V1_ExportLogsPartialSuccess: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".ExportLogsPartialSuccess" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "rejected_log_records"), + 2: .standard(proto: "error_message"), + ] + + 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.rejectedLogRecords) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.errorMessage) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if self.rejectedLogRecords != 0 { + try visitor.visitSingularInt64Field(value: self.rejectedLogRecords, fieldNumber: 1) + } + if !self.errorMessage.isEmpty { + try visitor.visitSingularStringField(value: self.errorMessage, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Opentelemetry_Proto_Collector_Logs_V1_ExportLogsPartialSuccess, rhs: Opentelemetry_Proto_Collector_Logs_V1_ExportLogsPartialSuccess) -> Bool { + if lhs.rejectedLogRecords != rhs.rejectedLogRecords {return false} + if lhs.errorMessage != rhs.errorMessage {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/Sources/OTLPGRPC/Generated/opentelemetry/proto/collector/metrics/v1/metrics_service.pb.swift b/Sources/OTLPGRPC/Generated/opentelemetry/proto/collector/metrics/v1/metrics_service.pb.swift index 116ded6e..893f383e 100644 --- a/Sources/OTLPGRPC/Generated/opentelemetry/proto/collector/metrics/v1/metrics_service.pb.swift +++ b/Sources/OTLPGRPC/Generated/opentelemetry/proto/collector/metrics/v1/metrics_service.pb.swift @@ -114,6 +114,12 @@ struct Opentelemetry_Proto_Collector_Metrics_V1_ExportMetricsPartialSuccess { 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/OTLPGRPC/Generated/opentelemetry/proto/collector/trace/v1/trace_service.pb.swift b/Sources/OTLPGRPC/Generated/opentelemetry/proto/collector/trace/v1/trace_service.pb.swift index 60269a56..242de20d 100644 --- a/Sources/OTLPGRPC/Generated/opentelemetry/proto/collector/trace/v1/trace_service.pb.swift +++ b/Sources/OTLPGRPC/Generated/opentelemetry/proto/collector/trace/v1/trace_service.pb.swift @@ -114,6 +114,12 @@ struct Opentelemetry_Proto_Collector_Trace_V1_ExportTracePartialSuccess { 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/Tests/OTLPGRPCTests/Generated/opentelemetry/proto/collector/logs/v1/logs_service.grpc.swift b/Tests/OTLPGRPCTests/Generated/opentelemetry/proto/collector/logs/v1/logs_service.grpc.swift new file mode 100644 index 00000000..e96cb21b --- /dev/null +++ b/Tests/OTLPGRPCTests/Generated/opentelemetry/proto/collector/logs/v1/logs_service.grpc.swift @@ -0,0 +1,129 @@ +// +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the protocol buffer compiler. +// Source: opentelemetry/proto/collector/logs/v1/logs_service.proto +// +import GRPC +import NIO +import NIOConcurrencyHelpers +import SwiftProtobuf + + +/// Service that can be used to push logs between one Application instrumented with +/// OpenTelemetry and an collector, or between an collector and a central collector (in this +/// case logs are sent/received to/from multiple Applications). +/// +/// To build a server, implement a class that conforms to this protocol. +internal 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 +} + +extension Opentelemetry_Proto_Collector_Logs_V1_LogsServiceProvider { + internal var serviceName: Substring { + return Opentelemetry_Proto_Collector_Logs_V1_LogsServiceServerMetadata.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. + internal 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 logs between one Application instrumented with +/// OpenTelemetry and an collector, or between an collector and a central collector (in this +/// case logs are sent/received to/from multiple Applications). +/// +/// To implement a server, implement an object which conforms to this protocol. +@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) +internal protocol Opentelemetry_Proto_Collector_Logs_V1_LogsServiceAsyncProvider: CallHandlerProvider, Sendable { + 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 + ) async throws -> Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceResponse +} + +@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) +extension Opentelemetry_Proto_Collector_Logs_V1_LogsServiceAsyncProvider { + internal static var serviceDescriptor: GRPCServiceDescriptor { + return Opentelemetry_Proto_Collector_Logs_V1_LogsServiceServerMetadata.serviceDescriptor + } + + internal var serviceName: Substring { + return Opentelemetry_Proto_Collector_Logs_V1_LogsServiceServerMetadata.serviceDescriptor.fullName[...] + } + + internal var interceptors: Opentelemetry_Proto_Collector_Logs_V1_LogsServiceServerInterceptorFactoryProtocol? { + return nil + } + + internal 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 + } + } +} + +internal protocol Opentelemetry_Proto_Collector_Logs_V1_LogsServiceServerInterceptorFactoryProtocol: Sendable { + + /// - Returns: Interceptors to use when handling 'export'. + /// Defaults to calling `self.makeInterceptors()`. + func makeExportInterceptors() -> [ServerInterceptor] +} + +internal enum Opentelemetry_Proto_Collector_Logs_V1_LogsServiceServerMetadata { + internal static let serviceDescriptor = GRPCServiceDescriptor( + name: "LogsService", + fullName: "opentelemetry.proto.collector.logs.v1.LogsService", + methods: [ + Opentelemetry_Proto_Collector_Logs_V1_LogsServiceServerMetadata.Methods.export, + ] + ) + + internal enum Methods { + internal static let export = GRPCMethodDescriptor( + name: "Export", + path: "/opentelemetry.proto.collector.logs.v1.LogsService/Export", + type: GRPCCallType.unary + ) + } +} diff --git a/Tests/OTLPGRPCTests/Generated/opentelemetry/proto/collector/logs/v1/logs_service.pb.swift b/Tests/OTLPGRPCTests/Generated/opentelemetry/proto/collector/logs/v1/logs_service.pb.swift new file mode 100644 index 00000000..e4178464 --- /dev/null +++ b/Tests/OTLPGRPCTests/Generated/opentelemetry/proto/collector/logs/v1/logs_service.pb.swift @@ -0,0 +1,231 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: opentelemetry/proto/collector/logs/v1/logs_service.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +// Copyright 2020, 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 Foundation +import SwiftProtobuf + +import OTLPCore + +// 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 +} + +struct Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceRequest { + // 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 ResourceLogs. + /// 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. + var resourceLogs: [OTLPCore.Opentelemetry_Proto_Logs_V1_ResourceLogs] = [] + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceResponse { + // 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. + var partialSuccess: Opentelemetry_Proto_Collector_Logs_V1_ExportLogsPartialSuccess { + get {return _partialSuccess ?? Opentelemetry_Proto_Collector_Logs_V1_ExportLogsPartialSuccess()} + set {_partialSuccess = newValue} + } + /// Returns true if `partialSuccess` has been explicitly set. + var hasPartialSuccess: Bool {return self._partialSuccess != nil} + /// Clears the value of `partialSuccess`. Subsequent reads from it will return its default value. + mutating func clearPartialSuccess() {self._partialSuccess = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _partialSuccess: Opentelemetry_Proto_Collector_Logs_V1_ExportLogsPartialSuccess? = nil +} + +struct Opentelemetry_Proto_Collector_Logs_V1_ExportLogsPartialSuccess { + // 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 log records. + /// + /// A `rejected_` field holding a `0` value indicates that the + /// request was fully accepted. + var rejectedLogRecords: 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. + var errorMessage: String = String() + + var unknownFields = SwiftProtobuf.UnknownStorage() + + 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" + +extension Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".ExportLogsServiceRequest" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "resource_logs"), + ] + + 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.resourceLogs) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if !self.resourceLogs.isEmpty { + try visitor.visitRepeatedMessageField(value: self.resourceLogs, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceRequest, rhs: Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceRequest) -> Bool { + if lhs.resourceLogs != rhs.resourceLogs {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".ExportLogsServiceResponse" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "partial_success"), + ] + + 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 + } + } + } + + 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) + } + + static func ==(lhs: Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceResponse, rhs: Opentelemetry_Proto_Collector_Logs_V1_ExportLogsServiceResponse) -> Bool { + if lhs._partialSuccess != rhs._partialSuccess {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Opentelemetry_Proto_Collector_Logs_V1_ExportLogsPartialSuccess: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".ExportLogsPartialSuccess" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "rejected_log_records"), + 2: .standard(proto: "error_message"), + ] + + 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.rejectedLogRecords) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.errorMessage) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if self.rejectedLogRecords != 0 { + try visitor.visitSingularInt64Field(value: self.rejectedLogRecords, fieldNumber: 1) + } + if !self.errorMessage.isEmpty { + try visitor.visitSingularStringField(value: self.errorMessage, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Opentelemetry_Proto_Collector_Logs_V1_ExportLogsPartialSuccess, rhs: Opentelemetry_Proto_Collector_Logs_V1_ExportLogsPartialSuccess) -> Bool { + if lhs.rejectedLogRecords != rhs.rejectedLogRecords {return false} + if lhs.errorMessage != rhs.errorMessage {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/Tests/OTLPGRPCTests/Generated/opentelemetry/proto/collector/metrics/v1/metrics_service.pb.swift b/Tests/OTLPGRPCTests/Generated/opentelemetry/proto/collector/metrics/v1/metrics_service.pb.swift index 116ded6e..893f383e 100644 --- a/Tests/OTLPGRPCTests/Generated/opentelemetry/proto/collector/metrics/v1/metrics_service.pb.swift +++ b/Tests/OTLPGRPCTests/Generated/opentelemetry/proto/collector/metrics/v1/metrics_service.pb.swift @@ -114,6 +114,12 @@ struct Opentelemetry_Proto_Collector_Metrics_V1_ExportMetricsPartialSuccess { 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/Tests/OTLPGRPCTests/Generated/opentelemetry/proto/collector/trace/v1/trace_service.pb.swift b/Tests/OTLPGRPCTests/Generated/opentelemetry/proto/collector/trace/v1/trace_service.pb.swift index 60269a56..242de20d 100644 --- a/Tests/OTLPGRPCTests/Generated/opentelemetry/proto/collector/trace/v1/trace_service.pb.swift +++ b/Tests/OTLPGRPCTests/Generated/opentelemetry/proto/collector/trace/v1/trace_service.pb.swift @@ -114,6 +114,12 @@ struct Opentelemetry_Proto_Collector_Trace_V1_ExportTracePartialSuccess { 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/Tests/OTLPGRPCTests/OTLPGRPCMockCollector.swift b/Tests/OTLPGRPCTests/OTLPGRPCMockCollector.swift index 69da4773..a3d069d4 100644 --- a/Tests/OTLPGRPCTests/OTLPGRPCMockCollector.swift +++ b/Tests/OTLPGRPCTests/OTLPGRPCMockCollector.swift @@ -83,21 +83,4 @@ final class MetricsServiceProvider: Sendable, Opentelemetry_Proto_Collector_Metr requests.append(RecordedRequest(exportRequest: request, context: context)) return ExportResponse() } -} - -/// This _used_ to be in the generated code, but not with latest versions of swift-protobuf/grpc-swift plugins. -/// -/// The only thing stopping them being Sendable is the `unknownFields: SwiftProtobuf.UnknownStorage` property, which has -/// the following TODO in the swift-protobuf repo: -/// -/// > `UnknownStorage` should be `Sendable` but we cannot do so yet without possibly breaking compatibility. -/// -/// We'll workaround this by marking things as sendable here until that is addressed. -#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 {} - 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) +} \ No newline at end of file diff --git a/module-mapping.proto b/module-mapping.proto index cc34bb66..41f63a40 100644 --- a/module-mapping.proto +++ b/module-mapping.proto @@ -2,6 +2,7 @@ mapping { module_name: "OTLPCore" proto_file_path: "opentelemetry/proto/common/v1/common.proto" proto_file_path: "opentelemetry/proto/resource/v1/resource.proto" + proto_file_path: "opentelemetry/proto/logs/v1/logs.proto" proto_file_path: "opentelemetry/proto/metrics/v1/metrics.proto" proto_file_path: "opentelemetry/proto/trace/v1/trace.proto" } From 9b7c1378175df6f29fa35731401e70742303de1c Mon Sep 17 00:00:00 2001 From: Moritz Lang Date: Wed, 13 Mar 2024 07:42:43 +0100 Subject: [PATCH 2/2] Add missing final newline --- Tests/OTLPGRPCTests/OTLPGRPCMockCollector.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/OTLPGRPCTests/OTLPGRPCMockCollector.swift b/Tests/OTLPGRPCTests/OTLPGRPCMockCollector.swift index a3d069d4..9af413e9 100644 --- a/Tests/OTLPGRPCTests/OTLPGRPCMockCollector.swift +++ b/Tests/OTLPGRPCTests/OTLPGRPCMockCollector.swift @@ -83,4 +83,4 @@ final class MetricsServiceProvider: Sendable, Opentelemetry_Proto_Collector_Metr requests.append(RecordedRequest(exportRequest: request, context: context)) return ExportResponse() } -} \ No newline at end of file +}