Skip to content

Commit

Permalink
added protobuf version as exporter user-agent version (#444)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryce-b authored Aug 8, 2023
1 parent 27e3fec commit 869dc5a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
20 changes: 10 additions & 10 deletions Sources/Exporters/OpenTelemetryProtocolCommon/common/Headers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

0 comments on commit 869dc5a

Please sign in to comment.