Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<D: SwiftProtobuf.Decoder>(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<V: SwiftProtobuf.Visitor>(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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down
Loading
Loading