Skip to content

Commit

Permalink
added protobuf version as exporter user-agent version
Browse files Browse the repository at this point in the history
  • Loading branch information
bryce-b committed Jul 24, 2023
1 parent a109095 commit c94925b
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))

Check warning on line 15 in Sources/Exporters/OpenTelemetryProtocolCommon/common/Headers.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Exporters/OpenTelemetryProtocolCommon/common/Headers.swift#L15

Added line #L15 was not covered by tests
}
let userAgent = "OTel-OTLP-Exporter-Swift/\(version)"

return userAgent
}
}

0 comments on commit c94925b

Please sign in to comment.