Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose diagnostic metadata properties at top level #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let package = Package(
.testTarget(name: "MeterTests",
dependencies: ["Meter"],
resources: [
.copy("Resources"),
.process("Resources"),
]),
.testTarget(name: "BinaryImageTests",
dependencies: ["BinaryImage"]),
Expand Down
46 changes: 31 additions & 15 deletions Sources/Meter/DiagnosticPayload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public class HangMetaData: Codable {
public let osVersion: String
public let platformArchitecture: String
public let regionFormat: String
private let hangDuration: String
public let hangDuration: String

enum CodingKeys: String, CodingKey {
case applicationBuildVersion = "appBuildVersion"
Expand All @@ -284,14 +284,14 @@ public class HangMetaData: Codable {
case hangDuration
}

public init(deviceType: String, applicationBuildVersion: String, applicationVersion: String, osVersion: String, platformArchitecture: String, regionFormat: String) {
public init(deviceType: String, applicationBuildVersion: String, applicationVersion: String, osVersion: String, platformArchitecture: String, regionFormat: String, hangDuration: String) {
self.deviceType = deviceType
self.applicationBuildVersion = applicationBuildVersion
self.applicationVersion = applicationVersion
self.osVersion = osVersion
self.platformArchitecture = platformArchitecture
self.regionFormat = regionFormat
self.hangDuration = ""
self.hangDuration = hangDuration
}

public init(diagnostic: HangDiagnostic) {
Expand All @@ -301,7 +301,7 @@ public class HangMetaData: Codable {
self.osVersion = diagnostic.metaData.osVersion
self.platformArchitecture = diagnostic.metaData.platformArchitecture
self.regionFormat = diagnostic.metaData.regionFormat
self.hangDuration = ""
self.hangDuration = diagnostic.metaData.hangDuration
}

public func jsonRepresentation() -> Data {
Expand All @@ -326,6 +326,10 @@ public class HangDiagnostic: Codable {
self.callStackTree = callStackTree
}

public var hangDuration: String {
return internalMetaData.hangDuration
}

public func jsonRepresentation() -> Data {
return (try? JSONEncoder().encode(self)) ?? Data()
}
Expand All @@ -350,8 +354,8 @@ public class CPUExceptionMetaData: Codable {
public let osVersion: String
public let platformArchitecture: String
public let regionFormat: String
private let totalCPUTime: String
private let totalSampledTime: String
public let totalCPUTime: String
public let totalSampledTime: String

enum CodingKeys: String, CodingKey {
case applicationBuildVersion = "appBuildVersion"
Expand All @@ -364,15 +368,15 @@ public class CPUExceptionMetaData: Codable {
case totalSampledTime
}

public init(deviceType: String, applicationBuildVersion: String, applicationVersion: String, osVersion: String, platformArchitecture: String, regionFormat: String) {
public init(deviceType: String, applicationBuildVersion: String, applicationVersion: String, osVersion: String, platformArchitecture: String, regionFormat: String, totalCPUTime: String, totalSampledTime: String) {
self.deviceType = deviceType
self.applicationBuildVersion = applicationBuildVersion
self.applicationVersion = applicationVersion
self.osVersion = osVersion
self.platformArchitecture = platformArchitecture
self.regionFormat = regionFormat
self.totalCPUTime = ""
self.totalSampledTime = ""
self.totalCPUTime = totalCPUTime
self.totalSampledTime = totalSampledTime
}

public init(diagnostic: CPUExceptionDiagnostic) {
Expand All @@ -382,8 +386,8 @@ public class CPUExceptionMetaData: Codable {
self.osVersion = diagnostic.metaData.osVersion
self.platformArchitecture = diagnostic.metaData.platformArchitecture
self.regionFormat = diagnostic.metaData.regionFormat
self.totalCPUTime = ""
self.totalSampledTime = ""
self.totalCPUTime = diagnostic.metaData.totalCPUTime
self.totalSampledTime = diagnostic.metaData.totalSampledTime
}

public func jsonRepresentation() -> Data {
Expand All @@ -408,6 +412,14 @@ public class CPUExceptionDiagnostic: Codable {
self.callStackTree = callStackTree
}

public var totalCPUTime: String {
return internalMetaData.totalCPUTime
}

public var totalSampledTime: String {
return internalMetaData.totalSampledTime
}

public func jsonRepresentation() -> Data {
return (try? JSONEncoder().encode(self)) ?? Data()
}
Expand All @@ -432,7 +444,7 @@ public class DiskWriteExceptionMetaData: Codable {
public let osVersion: String
public let platformArchitecture: String
public let regionFormat: String
private let writesCaused: String
public let writesCaused: String

enum CodingKeys: String, CodingKey {
case applicationBuildVersion = "appBuildVersion"
Expand All @@ -444,14 +456,14 @@ public class DiskWriteExceptionMetaData: Codable {
case writesCaused
}

public init(deviceType: String, applicationBuildVersion: String, applicationVersion: String, osVersion: String, platformArchitecture: String, regionFormat: String) {
public init(deviceType: String, applicationBuildVersion: String, applicationVersion: String, osVersion: String, platformArchitecture: String, regionFormat: String, writesCaused: String) {
self.deviceType = deviceType
self.applicationBuildVersion = applicationBuildVersion
self.applicationVersion = applicationVersion
self.osVersion = osVersion
self.platformArchitecture = platformArchitecture
self.regionFormat = regionFormat
self.writesCaused = ""
self.writesCaused = writesCaused
}

public init(diagnostic: DiskWriteExceptionDiagnostic) {
Expand All @@ -461,7 +473,7 @@ public class DiskWriteExceptionMetaData: Codable {
self.osVersion = diagnostic.metaData.osVersion
self.platformArchitecture = diagnostic.metaData.platformArchitecture
self.regionFormat = diagnostic.metaData.regionFormat
self.writesCaused = ""
self.writesCaused = diagnostic.metaData.writesCaused
}

public func jsonRepresentation() -> Data {
Expand All @@ -486,6 +498,10 @@ public class DiskWriteExceptionDiagnostic: Codable {
self.callStackTree = callStackTree
}

public var writesCaused: String {
return internalMetaData.writesCaused
}

public func jsonRepresentation() -> Data {
return (try? JSONEncoder().encode(self)) ?? Data()
}
Expand Down