diff --git a/Sources/Exporters/OpenTelemetryProtocolCommon/common/Constants.swift b/Sources/Exporters/OpenTelemetryProtocolCommon/common/Constants.swift index 5d2ace4e..be5f8f03 100644 --- a/Sources/Exporters/OpenTelemetryProtocolCommon/common/Constants.swift +++ b/Sources/Exporters/OpenTelemetryProtocolCommon/common/Constants.swift @@ -6,7 +6,10 @@ import Foundation public enum Constants { - public enum HTTP { - public static let userAgent = "User-Agent" - } + public enum OTLP { + public static let version = "0.20.0" + } + public enum HTTP { + public static let userAgent = "User-Agent" + } } diff --git a/Sources/Exporters/OpenTelemetryProtocolCommon/common/Headers.swift b/Sources/Exporters/OpenTelemetryProtocolCommon/common/Headers.swift index bffb43bf..97b8c55a 100644 --- a/Sources/Exporters/OpenTelemetryProtocolCommon/common/Headers.swift +++ b/Sources/Exporters/OpenTelemetryProtocolCommon/common/Headers.swift @@ -7,15 +7,15 @@ import Foundation import OpenTelemetryApi public struct Headers { - // GetUserAgentHeader returns an OTLP header value of the form "OTel OTLP Exporter Swift/{{ .Version }}" - // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#user-agent - public static func getUserAgentHeader() -> String { - var version = OpenTelemetry.version - if !version.isEmpty && version.hasPrefix("v") { - version = String(version.dropFirst(1)) - } - let userAgent = "OTel-OTLP-Exporter-Swift/\(version)" - - return userAgent + // GetUserAgentHeader returns an OTLP header value of the form "OTel OTLP Exporter Swift/{{ .Version }}" + // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#user-agent + public static func getUserAgentHeader() -> String { + var version = Constants.OTLP.version + if !version.isEmpty && version.hasPrefix("v") { + version = String(version.dropFirst(1)) } + let userAgent = "OTel-OTLP-Exporter-Swift/\(version)" + + return userAgent + } }