Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
01de6a3
Add tests for traces.
beekhc Oct 28, 2025
315e2c3
add diagnostic tests
beekhc Oct 28, 2025
a485cbe
add more clear TODOs for the README
beekhc Oct 28, 2025
3b7ed39
clean up the readme
beekhc Oct 28, 2025
78ef56c
fix the readme
beekhc Oct 28, 2025
53b543a
implement standard exception attributes
beekhc Oct 28, 2025
094edf9
change priority of exception fields
beekhc Oct 28, 2025
97c383f
fill out more readme exception details
beekhc Oct 28, 2025
da03d98
add a podspec
beekhc Oct 28, 2025
87bbe65
change "we" in the README
beekhc Oct 28, 2025
5d3045e
rename MetricKitSubscriber to MetricKitInstrumentation
beekhc Oct 28, 2025
4f8e2d8
remove some TODOs
beekhc Oct 29, 2025
a2c2607
update Package.resolved
beekhc Oct 29, 2025
cdc3d7e
Rename the MetricKitInstrumentation file.
beekhc Oct 29, 2025
9ec3374
Fix macOS version guards
beekhc Oct 29, 2025
1152417
Merge branch 'main' into beeklimt.metrickit
beekhc Oct 29, 2025
c647e49
Clean up version guards some more.
beekhc Oct 29, 2025
3ac7fd8
try adding version guards to tests
beekhc Oct 29, 2025
c7d2420
try again to fix the version guards
beekhc Oct 29, 2025
bb080d8
Remove macOS support.
beekhc Oct 30, 2025
4256cd2
docs: Add a proposal for a MetricKit format.
beekhc Nov 4, 2025
5f6038f
feat: Transform stacktraces to match the new doc.
beekhc Nov 5, 2025
8a9ff82
fix: Remove extraneous stacktrace_json field.
beekhc Nov 5, 2025
74c3e26
Merge branch 'main' into beeklimt.metrickit
beekhc Nov 5, 2025
42754f8
cleanup: rename offsetIntoBinaryTextSegment to offsetAddress
beekhc Nov 7, 2025
738399c
Merge branch 'main' into beeklimt.metrickit
beekhc Nov 7, 2025
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
25 changes: 25 additions & 0 deletions OpenTelemetry-Swift-Instrumentation-MetricKit.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Pod::Spec.new do |spec|
spec.name = "OpenTelemetry-Swift-Instrumentation-MetricKit"
spec.version = "2.2.0"
spec.summary = "Swift OpenTelemetry MetricKit Instrumentation"

spec.homepage = "https://github.com/open-telemetry/opentelemetry-swift"
spec.documentation_url = "https://opentelemetry.io/docs/languages/swift"
spec.license = { :type => "Apache 2.0", :file => "LICENSE" }
spec.authors = "OpenTelemetry Authors"

spec.source = { :git => "https://github.com/open-telemetry/opentelemetry-swift.git", :tag => spec.version.to_s }
spec.source_files = "Sources/Instrumentation/MetricKit/*.swift"
spec.exclude_files = "Sources/Instrumentation/MetricKit/README.md"

spec.swift_version = "5.10"
spec.ios.deployment_target = "13.0"
spec.osx.deployment_target = "12.0"
spec.watchos.deployment_target = "6.0"
spec.visionos.deployment_target = "1.0"
spec.module_name = "MetricKitInstrumentation"

spec.dependency 'OpenTelemetry-Swift-Sdk', '~> 2.1.1'
spec.pod_target_xcconfig = { "OTHER_SWIFT_FLAGS" => "-module-name MetricKitInstrumentation -package-name opentelemetry_swift_metrickit_instrumentation" }

end
20 changes: 19 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ extension Package {
.executable(name: "OTLPExporter", targets: ["OTLPExporter"]),
.executable(name: "OTLPHTTPExporter", targets: ["OTLPHTTPExporter"]),
.library(name: "SignPostIntegration", targets: ["SignPostIntegration"]),
.library(name: "ResourceExtension", targets: ["ResourceExtension"])
.library(name: "ResourceExtension", targets: ["ResourceExtension"]),
.library(name: "MetricKitInstrumentation", targets: ["MetricKitInstrumentation"])
])
targets.append(contentsOf: [
.target(
Expand Down Expand Up @@ -381,6 +382,23 @@ extension Package {
],
path: "Tests/InstrumentationTests/SDKResourceExtensionTests"
),
.target(
name: "MetricKitInstrumentation",
dependencies: [
.product(name: "OpenTelemetrySdk", package: "opentelemetry-swift-core")
],
path: "Sources/Instrumentation/MetricKit",
exclude: ["README.md"]
),
.testTarget(
name: "MetricKitInstrumentationTests",
dependencies: [
"MetricKitInstrumentation",
"InMemoryExporter",
.product(name: "OpenTelemetrySdk", package: "opentelemetry-swift-core")
],
path: "Tests/InstrumentationTests/MetricKitTests"
),
.executableTarget(
name: "PrometheusSample",
dependencies: [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#if canImport(MetricKit) && !os(tvOS) && !os(macOS)
import Foundation
import OpenTelemetryApi

/// A protocol to make it easier to write generic functions for AttributeValues.
protocol AttributeValueConvertable {
func attributeValue() -> AttributeValue
}

extension Int: AttributeValueConvertable {
func attributeValue() -> AttributeValue {
AttributeValue.int(self)
}
}
extension Bool: AttributeValueConvertable {
func attributeValue() -> AttributeValue {
AttributeValue.bool(self)
}
}
extension String: AttributeValueConvertable {
func attributeValue() -> AttributeValue {
AttributeValue.string(self)
}
}

extension [String]: AttributeValueConvertable {
func attributeValue() -> AttributeValue {
AttributeValue.array(AttributeArray(values: self.map { AttributeValue.string($0) }))
}
}

extension TimeInterval: AttributeValueConvertable {
func attributeValue() -> AttributeValue {
// The OTel standard for time durations is seconds, which is also what TimeInterval is.
// https://opentelemetry.io/docs/specs/semconv/general/metrics/
AttributeValue.double(self)
}
}

extension Measurement: AttributeValueConvertable {
func attributeValue() -> AttributeValue {
// Convert to the "base unit", such as seconds or bytes.
let value =
if let unit = self.unit as? Dimension {
unit.converter.baseUnitValue(fromValue: self.value)
} else {
self.value
}
return AttributeValue.double(value)
}
}
#endif
Loading
Loading