Skip to content

Commit

Permalink
feat: drift apm (#1709)
Browse files Browse the repository at this point in the history
* draft impl

* improve code

* Add open span

* Refactor to extend lazy database

* Update

* SentryTransactionExecutor

* Implement tracing batch and transactions

* Update tests

* update changelog

* Formatting

* Update workflows

* Update deps

* Fix analyze issues

* Format

* Add example

* Update descriptions

* Fix deps

* Update run commands

* Update workflow

* Update example

* Update workflow

* Format

* Fix dart analyze

* Try changing deps

* Add to craft

* Change to flutter test

* Revert flutter test mock

* change dir manually

* download and extract sqlite.dll for windows

* Try downloading sqlite3

* set up dart

* fix path to file

* use pub get

* Use flutter pub get

* fix

* skip windows test

* fix analyze

* fix drift.yml

* format

* Remove redundant test

* Remove debug print

* update trace origin

* Improvements

* Improvements

* Add to flutter example
  • Loading branch information
buenaflor authored Nov 15, 2023
1 parent 48adddf commit 051e97a
Show file tree
Hide file tree
Showing 44 changed files with 4,925 additions and 36 deletions.
3 changes: 3 additions & 0 deletions .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ targets:
dio:
file:
sqflite:
drift:
- name: github
- name: registry
sdks:
Expand All @@ -20,3 +21,5 @@ targets:
pub:sentry_dio:
pub:sentry_file:
pub:sentry_sqflite:
# This needs to be published on pub.dev first before uncommenting
# pub:sentry_drift:
1 change: 1 addition & 0 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- "dio/**"
- "file/**"
- "sqflite/**"
- "drift/**"

jobs:
cancel-previous-workflow:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/dio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- "flutter/**"
- "file/**"
- "sqflite/**"
- "drift/**"

jobs:
cancel-previous-workflow:
Expand Down
114 changes: 114 additions & 0 deletions .github/workflows/drift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: sentry-drift
on:
push:
branches:
- main
- release/**
pull_request:
paths-ignore:
- "**/*.md"
- "logging/**"
- "flutter/**"
- "dio/**"
- "file/**"
- "sqflite/**"

jobs:
cancel-previous-workflow:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@01ce38bf961b4e243a6342cbade0dbc8ba3f0432 # pin@0.12.0
with:
access_token: ${{ github.token }}

build:
name: ${{ matrix.target }} | ${{ matrix.os }} | ${{ matrix.sdk }}
runs-on: ${{ matrix.os }}
timeout-minutes: 30
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
target: ["ios", "android", "macos", "linux", "windows"]
sdk: ["stable", "beta"]
exclude:
- os: ubuntu-latest
target: ios
- os: ubuntu-latest
target: macos
- os: ubuntu-latest
target: windows
- os: windows-latest
target: ios
- os: windows-latest
target: android
- os: windows-latest
target: macos
- os: windows-latest
target: linux
# macos-latest is taking hours due to limited resources
- os: macos-latest
target: android
- os: macos-latest
target: linux
- os: macos-latest
target: windows
# Bad CPU type in executable
- os: macos-latest
sdk: beta

steps:
- uses: actions/checkout@v4

- uses: actions/setup-java@v3
if: ${{ matrix.target == 'android' }}
with:
java-version: "11"
distribution: "adopt"

# Install required dependencies for Flutter on Linux on Ubuntu
- name: "Setup Linux"
run: |
sudo apt update
sudo apt install -y cmake dbus libblkid-dev libgtk-3-dev liblzma-dev ninja-build pkg-config xvfb
sudo apt install -y network-manager upower
if: matrix.os == 'ubuntu-latest' && matrix.target == 'linux'

- uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa # pin@v2.10.0
with:
channel: ${{ matrix.sdk }}

- run: flutter upgrade

- name: Pub Get
run: |
cd drift
flutter pub get
- name: Test VM with coverage
run: |
cd drift
flutter test --coverage --test-randomize-ordering-seed=random
- uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # pin@v3
if: runner.os == 'Linux' && matrix.sdk == 'stable' && matrix.target == 'linux'
with:
name: sentry_drift
file: ./drift/coverage/lcov.info
functionalities: "search" # remove after https://github.com/codecov/codecov-action/issues/600

- uses: VeryGoodOpenSource/very_good_coverage@e5c91bc7ce9843e87c800b3bcafdfb86fbe28491 # pin@v2.1.0
if: runner.os == 'Linux' && matrix.sdk == 'stable' && matrix.target == 'linux'
with:
path: "./drift/coverage/lcov.info"
min_coverage: 80

analyze:
uses: ./.github/workflows/analyze.yml
with:
package: drift
sdk: flutter
1 change: 1 addition & 0 deletions .github/workflows/e2e_dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- "flutter/**"
- "file/**"
- "sqflite/**"
- "drift/**"

env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- "flutter/**"
- "dio/**"
- "sqflite/**"
- "drift/**"

jobs:
cancel-previous-workflow:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/flutter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- "dio/**"
- "file/**"
- "sqflite/**"
- "drift/**"

jobs:
cancel-previous-workflow:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/logging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- "flutter/**"
- "file/**"
- "sqflite/**"
- "drift/**"

jobs:
cancel-previous-workflow:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/min_version_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- "**/*.md"
- "file/**"
- "sqflite/**"
- "drift/**"

jobs:
cancel-previous-workflow:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/sqflite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- "flutter/**"
- "dio/**"
- "file/**"
- "drift/**"

jobs:
cancel-previous-workflow:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dio/coverage/*
file/coverage/*
flutter/coverage/*
sqflite/coverage/*
drift/coverage/*

pubspec.lock
Podfile.lock
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

### Features

- Add APM integration for Drift ([#1709](https://github.com/getsentry/sentry-dart/pull/1709))
- StackTraces in `PlatformException.message` will get nicely formatted too when present ([#1716](https://github.com/getsentry/sentry-dart/pull/1716))
- Breadcrumbs for database operations ([#1656](https://github.com/getsentry/sentry-dart/pull/1656))
- Add `attachScreenshotOnlyWhenResumed` to options ([#1700](https://github.com/getsentry/sentry-dart/pull/1700))
Expand Down
3 changes: 3 additions & 0 deletions dart/lib/src/sentry_trace_origins.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ class SentryTraceOrigins {
'auto.db.sqflite.database_executor';
static const autoDbSqfliteDatabaseFactory =
'auto.db.sqflite.database_factory';
static const autoDbDriftQueryExecutor = 'auto.db.drift.query.executor';
static const autoDbDriftTransactionExecutor =
'auto.db.drift.transaction.executor';
}
14 changes: 14 additions & 0 deletions drift/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Omit committing pubspec.lock for library packages; see
# https://dart.dev/guides/libraries/private-files#pubspeclock.
pubspec.lock

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/
Loading

0 comments on commit 051e97a

Please sign in to comment.