Lightweight MetricKit-based diagnostics reporting

Overview

License Platforms

MeterReporter

Lightweight MetricKit-based diagnostics reporting.

MeterReporter will capture MetricKit payloads and relay them to a backend. It uses Meter to process and symbolicate payloads. The resulting data is very close to the MetricKit JSON structure. But, it does add some fields to support the additional features.

Integration

dependencies: [
    .package(url: "https://github.com/ChimeHQ/MeterReporter")
]

Usage

let url = URL(string: "https://my.backend.com/reports")!

var config = MeterReporter.Configuration(endpointURL: url)

config.hostIdentifier = Bundle.main.bundleIdentifier

let reporter = MeterReporter(configuration: config)

reporter.start()

Background Uploads

By default, MeterReporter uses URLSession background uploads for both reliability and performance. However, sometimes these can take hours for the OS to actually execute. This can be a pain if you are just testing things out. To make that easier, you can disable background uploads with another property of MeterReporter.Configuration.

NSException Capture

MeterReporter can capture uncaught NSExceptions on macOS. Unfortunately, AppKit interfers with the flow of runtime exceptions. If you want to get this information about uncaught exceptions, some extra work is required.

The top-level NSApplication instance for your app must be a subclass of ExceptionLoggingApplication.

import MeterReporter

class Application: ExceptionLoggingApplication {
}

and, you must update your Info.plist to ensure that the NSPrincipalClass key references this class with .Application .

I realize this is a huge pain. If you feel so motivated, please file feedback with Apple to ask them to make AppKit behave like UIKit in this respect.

I would also strongly recommend setting the NSApplicationCrashOnExceptions defaults key to true. The default setting will allow your application to continue executing post-exception, virtually guaranteeing state corruption and incorrect behavior.

Submission Request

The request made to the endpoint will be an HTTP PUT. The request will also set some headers.

  • Content-Type will be application/vnd.chimehq-mxdiagnostic
  • MeterReporter-Report-Id will be a unique identifier
  • MeterReporter-Platform
  • MeterReporter-Host-Id if configuration.hostIdentifier is non-nil

Suggestions or Feedback

We'd love to hear from you! Get in touch via twitter, an issue, or a pull request.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Comments
  • Prevent crash when MeterReporter is deallocated before upload

    Prevent crash when MeterReporter is deallocated before upload

    If the client calls start() on a MeterReporter instance but does not keep a strong reference to this instance, then it gets deallocated and if any log is available to upload a crash occurs after 10 seconds. Not sure this is the best way to fix this -- maybe intentionally creating a retain cycle is preferable so that clients don't have to retain their MeterReporter.

    opened by Clafou 5
  • Quick way to trigger reports for testing?

    Quick way to trigger reports for testing?

    I integrated MeterReporter into an app as a replacement for Stacksift, which took just a minute. My prior Stacksift setup did successfully send reports.

    But I am now having trouble sending reports so that I can test my backend. I have edited my app with a fatalError() and also tried a forced unwrap crash, but no report is being sent at the next app launch after these crashes, even after 10 seconds when it should kick in. Wells's handleExistingLogs finds no report.

    What is the right approach to test the sending of reports?

    This is the setup code in my AppDelegate:

    var config = MeterReporter.Configuration(endpointURL: URL(string: "https://myendpoint")!)
    config.hostIdentifier = "Test"
    config.backgroundIdentifier = nil
    let reporter = MeterReporter(configuration: config)
    reporter.start()
    
    opened by Clafou 3
  • Is there a visualisation tools for Metrics data

    Is there a visualisation tools for Metrics data

    The XCode Organizer doesn't show Metrics data when the usage and user count are not enough. I'm able to download Metric payload data through debugging. But the problem is I don't have a tool like XCode Organizer to show the metrics payload in graph. Any idea how to interpret the Metric payload json data? Thanks.

    opened by zhouhao27 2
  • Clarify how to disable background uploads

    Clarify how to disable background uploads

    The README says:

    To make that easier, you can disable background uploads with another property of MeterReporter.Configuration.

    But there is no detail on what that property is, and it took me a bit of digging (into the Wells code) to figure out that to disable background uploads you need to set backgroundIdentifier = nil -- maybe making that clearer, at least with a comment for that property, would help!

    opened by Clafou 1
  • Enhancement: Document the server endpoint some more

    Enhancement: Document the server endpoint some more

    The README does state it's going to be a PUT request and what the expected header data is -- but without writing a script to logg something at that endpoint, I wouldn't know what is being put.

    Is it merely JSON (the first paragraph alludes to that)? Will it suffice to store a huge string in a database, or a .json file?

    opened by DivineDominion 4
Releases(0.1.0)
Owner
Chime
Chime
Lightweight app to view your WoT (BB, Blitz) stats (XVM based)

KTTC Lite Приложение для танкистов, следящих за своей статистикой! Функционал Базовая статистика аккаунта WoT, WoT Blitz Расширенная статистика XVM (W

Ярослав Стрельников 3 Aug 31, 2022
A nano-sized weather station based on a Raspberry Pi with an API, iOS & Mac Catalyst app, and sensor-based automations.

Nanotool A nano-sized weather station based on a Raspberry Pi with an API, iOS & Mac Catalyst app, and sensor-based automations. Descriere Vremea este

CMD 3 Aug 18, 2022
An ultra-lightweight native Discord client for vintage and modern Mac OS

Discord Lite An ultra-lightweight native Discord client for vintage and modern Mac OS Minimum System Requirements Mac OS X version 10.4 (Tiger) PowerP

null 155 Jan 2, 2023
The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs!

SwiftGen SwiftGen is a tool to automatically generate Swift code for resources of your projects (like images, localised strings, etc), to make them ty

null 8.3k Dec 31, 2022
Type-based input validation.

Ensure Type-based input validation try Ensure<PackageIsCool>(wrappedValue: packages.ensure) Validators A Validator is a type that validates an input.

Build Passed 5 Jan 22, 2022
🛠 A flexible and easy template created to speed up the development of your iOS application based on the MVP pattern.

Model-View-Presenter template A flexible and easy template created to speed up the development of your iOS application based on the MVP pattern. This

Tamerlan Satualdypov 22 Nov 9, 2022
Control Nvidia jetbot which is based on Jetson Nano via iOS app

jetbot-remote-control This is very basic example project which control Nvidia Jetbot remotely via iOS app Based on jetbot of Nvidia, adding sample sou

Nguyen Quoc Thanh 13 Oct 6, 2021
XCode Preview template for UIkit based project.

SwiftPreview XCode Preview template for UIkit based project. Support custom file template class inherit from UIView and UIViewController. How to use?

Won Heo 10 Mar 31, 2022
This repository hosts the PushwooshGeozones iOS SDK as an XCFramework based Swift Package.

This repository hosts the PushwooshGeozones iOS SDK as an XCFramework based Swift Package. Use this repository's Swift Package in Xcode 12+

Pushwoosh 2 Nov 23, 2021
A navigation frameword based on the Coordinator pattern and is a compact version from XCoordinator.

Coordinator A navigation frameword based on the Coordinator pattern and is a compact version from XCoordinator. Example To run the example project, cl

Duc Pham 3 Jul 9, 2022
iPad Comic reader based on ComicFLow

Overview Finally a comic reader for iPad done right! ComicFlow was designed with one goal in mind: providing the best experience for comic fans with l

Pablo Clemente Pérez 0 Dec 2, 2021
A GUI based virtualisation tool for running Linux on macOS Big Sur (x86 or arm64)

Project Mendacius GUI based virtualization tool to run Linux, based on the Virtualization framework introduced by Apple for macOS Big Sur with support

Praneet 113 Nov 18, 2022
UIKit-based app project template for Swift Playgrounds 4

playgrounds-uikit-app This is a simplistic sample template for Swift Playgrounds 4 to begin with a UIKit-based app delegate & window scene instead of

Steven Troughton-Smith 39 Sep 19, 2022
OpenAPI specification generator for Vapor based Swift projects.

VaporToOpenAPI VaporToOpenAPI is a Swift library which can generate output compatible with OpenAPI version 3.0.1 from Vapor code. You can use generate

null 3 Dec 15, 2022
GraphQL based Jetpack Compose, Wear Compose and SwiftUI Kotlin Multiplatform sample

GraphQL based Jetpack Compose, Wear Compose and SwiftUI Kotlin Multiplatform sample

John O'Reilly 151 Jan 3, 2023
🐦 An asynchronous Twitter library based on the Twitter v2 API

Twift Twift is an asynchronous Swift library for the Twitter v2 API. No external dependencies Only one callback-based method (requestUserCredentials)

Daniel Eden 91 Jan 1, 2023
Contacts is an iOS app based on MVP (Model View Presenter) software architectural pattern.

Contacts Description Contacts is an iOS app based on MVP (Model View Presenter) software architectural pattern. Run Requirements Xcode 10.2.1 Swift 5.

Tirupati Balan 4 Apr 26, 2022
DBZ-Legends - A SwiftUI based app for all the DBZ peeps out there

DBZ-Legends Just a simple UI based app for all the DBZ fans. You can tap on the

Sougato Roy 2 Apr 5, 2022
3DProject: MR based IOS application

3DProject Driving Question This is MR based IOS application. MR is to place a me

null 1 Feb 16, 2022