Skip to content

Commit 869dc5a

Browse files
authored
added protobuf version as exporter user-agent version (#444)
1 parent 27e3fec commit 869dc5a

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

Sources/Exporters/OpenTelemetryProtocolCommon/common/Constants.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
import Foundation
77

88
public enum Constants {
9-
public enum HTTP {
10-
public static let userAgent = "User-Agent"
11-
}
9+
public enum OTLP {
10+
public static let version = "0.20.0"
11+
}
12+
public enum HTTP {
13+
public static let userAgent = "User-Agent"
14+
}
1215
}

Sources/Exporters/OpenTelemetryProtocolCommon/common/Headers.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import Foundation
77
import OpenTelemetryApi
88

99
public struct Headers {
10-
// GetUserAgentHeader returns an OTLP header value of the form "OTel OTLP Exporter Swift/{{ .Version }}"
11-
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#user-agent
12-
public static func getUserAgentHeader() -> String {
13-
var version = OpenTelemetry.version
14-
if !version.isEmpty && version.hasPrefix("v") {
15-
version = String(version.dropFirst(1))
16-
}
17-
let userAgent = "OTel-OTLP-Exporter-Swift/\(version)"
18-
19-
return userAgent
10+
// GetUserAgentHeader returns an OTLP header value of the form "OTel OTLP Exporter Swift/{{ .Version }}"
11+
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#user-agent
12+
public static func getUserAgentHeader() -> String {
13+
var version = Constants.OTLP.version
14+
if !version.isEmpty && version.hasPrefix("v") {
15+
version = String(version.dropFirst(1))
2016
}
17+
let userAgent = "OTel-OTLP-Exporter-Swift/\(version)"
18+
19+
return userAgent
20+
}
2121
}

0 commit comments

Comments
 (0)