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

feat: Performance monitoring #909

Merged
merged 18 commits into from
Mar 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
# Changelog

## unreleased
## Unreleased

### Features

- feat: Performance Monitoring API (#909, #977, #961, #932, #919)

### Breaking Changes

- SentryEvent.timestamp changed to nullable.

## 7.0.0-alpha.1

Features and fixes:

- ref: Add read-only scope property to Hub #975

Breaking Changes:
### Breaking Changes

- ref: Add read-only scope property to Hub #975
- ref: Remove SentryException.userReported #974
- ref: Replace SentryLogLevel with SentryLevel #978

Expand Down
17 changes: 12 additions & 5 deletions Samples/iOS-ObjectiveC/iOS-ObjectiveC/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand All @@ -24,7 +24,7 @@
<nil key="highlightedColor"/>
</label>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="AVC-4r-eVc">
<rect key="frame" x="8" y="116.5" width="398" height="180"/>
<rect key="frame" x="8" y="116.5" width="398" height="210"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="rUC-at-hwU">
<rect key="frame" x="0.0" y="0.0" width="398" height="30"/>
Expand Down Expand Up @@ -62,8 +62,15 @@
<action selector="captureException:" destination="BYZ-38-t0r" eventType="touchUpInside" id="ezD-qB-SSr"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="PFR-up-CPy">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="I9B-iL-of0">
<rect key="frame" x="0.0" y="150" width="398" height="30"/>
<state key="normal" title="captureTransaction"/>
<connections>
<action selector="captureTransaction:" destination="BYZ-38-t0r" eventType="touchUpInside" id="uaN-VO-vJA"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="PFR-up-CPy">
<rect key="frame" x="0.0" y="180" width="398" height="30"/>
<state key="normal" title="crash"/>
<connections>
<action selector="crash:" destination="BYZ-38-t0r" eventType="touchUpInside" id="6xT-zA-EZI"/>
Expand All @@ -85,7 +92,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="133" y="139"/>
<point key="canvasLocation" x="12" y="3"/>
</scene>
</scenes>
<resources>
Expand Down
10 changes: 10 additions & 0 deletions Samples/iOS-ObjectiveC/iOS-ObjectiveC/ViewController.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#import "ViewController.h"

@import Sentry;

@interface
Expand Down Expand Up @@ -99,6 +100,15 @@ - (IBAction)captureException:(id)sender
[SentrySDK captureException:exception withScope:scope];
}

- (IBAction)captureTransaction:(id)sender
{
SentryTransaction *fakeTransaction = [SentrySDK startTransactionWithName:@"Some Transaction"];

dispatch_after(
dispatch_time(DISPATCH_TIME_NOW, (int64_t)(arc4random_uniform(100) + 400 * NSEC_PER_MSEC)),
dispatch_get_main_queue(), ^{ [fakeTransaction finish]; });
}

- (IBAction)crash:(id)sender
{
[SentrySDK crash];
Expand Down
4 changes: 4 additions & 0 deletions Samples/iOS-Swift/iOS-Swift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
637AFDB6243B02770034958B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 637AFDB4243B02770034958B /* LaunchScreen.storyboard */; };
7B3427F825876A5200056519 /* Tongariro.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 7B3427F725876A5200056519 /* Tongariro.jpg */; };
7B4AC44025D16AA00070736A /* RandomErrors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B4AC43F25D16AA00070736A /* RandomErrors.swift */; };
8E8C57AF25EF16E6001CEEFA /* TraceTestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E8C57AE25EF16E6001CEEFA /* TraceTestViewController.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -71,6 +72,7 @@
63F93AA9245AC91600A500DB /* iOS-Swift.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "iOS-Swift.entitlements"; sourceTree = "<group>"; };
7B3427F725876A5200056519 /* Tongariro.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = Tongariro.jpg; sourceTree = "<group>"; };
7B4AC43F25D16AA00070736A /* RandomErrors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RandomErrors.swift; sourceTree = "<group>"; };
8E8C57AE25EF16E6001CEEFA /* TraceTestViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TraceTestViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -133,6 +135,7 @@
7B3427F725876A5200056519 /* Tongariro.jpg */,
637AFDB4243B02770034958B /* LaunchScreen.storyboard */,
637AFDB7243B02770034958B /* Info.plist */,
8E8C57AE25EF16E6001CEEFA /* TraceTestViewController.swift */,
);
path = "iOS-Swift";
sourceTree = "<group>";
Expand Down Expand Up @@ -236,6 +239,7 @@
files = (
637AFDAE243B02760034958B /* ViewController.swift in Sources */,
637AFDAA243B02760034958B /* AppDelegate.swift in Sources */,
8E8C57AF25EF16E6001CEEFA /* TraceTestViewController.swift in Sources */,
637AFDAC243B02760034958B /* SceneDelegate.swift in Sources */,
7B4AC44025D16AA00070736A /* RandomErrors.swift in Sources */,
);
Expand Down
56 changes: 51 additions & 5 deletions Samples/iOS-Swift/iOS-Swift/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17126"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand All @@ -24,7 +24,7 @@
<nil key="highlightedColor"/>
</label>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="480-5y-FtF">
<rect key="frame" x="8" y="95.5" width="398" height="210"/>
<rect key="frame" x="8" y="95.5" width="398" height="270"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="QJW-l9-sD6">
<rect key="frame" x="0.0" y="0.0" width="398" height="30"/>
Expand Down Expand Up @@ -68,8 +68,22 @@
<action selector="captureNSException:" destination="BYZ-38-t0r" eventType="touchUpInside" id="BT7-dZ-MrB"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="lgF-Uq-3Bb">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="cdR-H3-8fr">
<rect key="frame" x="0.0" y="180" width="398" height="30"/>
<state key="normal" title="Capture Transaction"/>
<connections>
<action selector="captureTransaction:" destination="BYZ-38-t0r" eventType="touchUpInside" id="kff-pT-Uf4"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="8CV-WC-ffq">
<rect key="frame" x="0.0" y="210" width="398" height="30"/>
<state key="normal" title="Test Navigation Transaction"/>
<connections>
<segue destination="cay-7M-Gvd" kind="show" id="boD-GG-VVF"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="lgF-Uq-3Bb">
<rect key="frame" x="0.0" y="240" width="398" height="30"/>
<state key="normal" title="crash"/>
<connections>
<action selector="crash:" destination="BYZ-38-t0r" eventType="touchUpInside" id="imm-ZO-4Af"/>
Expand All @@ -94,6 +108,38 @@
</objects>
<point key="canvasLocation" x="132" y="139"/>
</scene>
<!--Trace Test View Controller-->
<scene sceneID="nC1-NO-4uj">
<objects>
<viewController id="cay-7M-Gvd" customClass="TraceTestViewController" customModule="iOS_Swift" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="i9I-wJ-Z2B">
<rect key="frame" x="0.0" y="0.0" width="414" height="842"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="oQQ-QQ-VWP">
<rect key="frame" x="87" y="284" width="240" height="240"/>
<constraints>
<constraint firstAttribute="height" constant="240" id="iMc-sb-nxg"/>
<constraint firstAttribute="width" constant="240" id="uUA-q8-18d"/>
</constraints>
</imageView>
</subviews>
<viewLayoutGuide key="safeArea" id="MSB-Vw-wUr"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="oQQ-QQ-VWP" firstAttribute="centerX" secondItem="MSB-Vw-wUr" secondAttribute="centerX" id="M7C-iR-4Pj"/>
<constraint firstItem="oQQ-QQ-VWP" firstAttribute="centerY" secondItem="MSB-Vw-wUr" secondAttribute="centerY" id="eGm-Ek-ygH"/>
</constraints>
</view>
<navigationItem key="navigationItem" id="Afi-mu-igL"/>
<connections>
<outlet property="imageView" destination="oQQ-QQ-VWP" id="ePP-uk-wGM"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="JzG-vp-oCD" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1224.6376811594205" y="503.57142857142856"/>
</scene>
<!--View Controller-->
<scene sceneID="HP6-1Y-hca">
<objects>
Expand Down Expand Up @@ -124,7 +170,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="5Rz-Om-HMJ" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1053.6231884057972" y="137.94642857142856"/>
<point key="canvasLocation" x="1226" y="-148"/>
</scene>
</scenes>
<resources>
Expand Down
52 changes: 52 additions & 0 deletions Samples/iOS-Swift/iOS-Swift/TraceTestViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import Foundation
import Sentry
import UIKit

class TraceTestViewController: UIViewController {

var loadSpan: Span?
@IBOutlet weak var imageView: UIImageView!

required init?(coder: NSCoder) {
super.init(coder: coder)
initialize()
}

override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
initialize()
}

override func viewDidLoad() {
super.viewDidLoad()
}

private func initialize() {
//Start a transaction to determine how long it take to display the view.
loadSpan = SentrySDK.startTransaction(name: "TraceTestViewController", operation: "navigation")
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

let child = loadSpan?.startChild(name: "Download Image", operation: "network")
guard let imgUrl = URL(string: "https://sentry-brand.storage.googleapis.com/sentry-logo-black.png") else {
return
}

let dataTask = URLSession.shared.dataTask(with: imgUrl) { (data, _, error) in
DispatchQueue.main.async {
var spanStatus = SentrySpanStatus.ok
if let err = error {
SentrySDK.capture(error: err)
spanStatus = .unknownError
} else if let image = data {
self.imageView.image = UIImage(data: image)
}
child?.finish(status: spanStatus)
self.loadSpan?.finish()
}
}
dataTask.resume()
}
}
7 changes: 7 additions & 0 deletions Samples/iOS-Swift/iOS-Swift/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ class ViewController: UIViewController {
SentrySDK.capture(exception: exception, scope: scope)
}

@IBAction func captureTransaction(_ sender: Any) {
let transaction = SentrySDK.startTransaction(name: "Some Transaction", operation: "Some Operation")
DispatchQueue.main.asyncAfter(deadline: .now() + Double.random(in: 0.4...0.6), execute: {
transaction.finish()
})
}

@IBAction func crash(_ sender: Any) {
SentrySDK.crash()
}
Expand Down
Loading