-
-
Notifications
You must be signed in to change notification settings - Fork 277
APM for hive #1672
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
Merged
APM for hive #1672
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
7a9ea7d
setup sentry hive library
denrase 2fa0411
Add SentryBox with first test
denrase 071dd1e
test added spans
denrase bee44de
Merge branch 'main' into feat/hive
denrase 5881d84
Add sentry hive impl
denrase 296e25e
introduce base box to avoid duplication
denrase 6ea6914
implement lazy box test
denrase e35a82d
expose sentry hive and updata documentation
denrase 22bed30
add hive to flutter example app
denrase e5c2b9b
test throwing in base_box, cleanup
denrase 7a41832
test lazy box error cases
denrase ee12365
test sentry hive impl failures
denrase f72c0a8
run fix & format
denrase 8fa3182
fix test failure race condition
denrase 08cfc16
add hive workflow, update other workflows
denrase 69d6404
Merge branch 'main' into feat/hive
denrase f5dd006
add changelog entry
denrase 9237bee
remove path+provider from dev_dependencies
denrase 887adb0
add coverage dev dependency
denrase ea89cf6
fix deprecation warnings
denrase 8c7e7cc
Merge branch 'main' into feat/hive
denrase 5f7c196
fix changelog
denrase 2ca2783
move span wrapping on own class to avoid duplication
denrase 380c8a2
add sentry box collection
denrase 71d3f8e
test added spans, fix imports
denrase d286b62
test throwing code
denrase 1f9c37f
Merge branch 'main' into feat/hive
denrase 9e02a29
fix changelog
denrase e888f6f
Merge branch 'main' into feat/hive
denrase 22a1637
change dbSystem value
denrase d959c80
Merge branch 'main' into feat/hive
denrase 158f93f
change db system
denrase aeed961
Merge branch 'main' into feat/hive
denrase f99d255
remove unneccessary async & await
denrase da8309f
Merge branch 'main' into feat/hive
buenaflor 7119d74
Fix analyze
buenaflor 34ea841
Formatting
buenaflor 2db8de9
Add changelog symlink
buenaflor fccc34c
Ignore hive coverage
buenaflor 19ebd4b
Create symlink for dartdoc_options
buenaflor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add SentryBox with first test
- Loading branch information
commit 2fa0411d456e9fde144e9bf92d17489ad8b05076
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| library; | ||
| library sentry_hive; | ||
|
|
||
| export 'src/sentry_hive.dart'; | ||
| export 'src/sentry_box.dart'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,200 @@ | ||
| import 'package:meta/meta.dart'; | ||
| import 'package:hive/hive.dart'; | ||
| import 'package:sentry/sentry.dart'; | ||
|
|
||
| import '../sentry_hive.dart'; | ||
|
|
||
| // ignore: public_member_api_docs | ||
| class SentryBox<E> implements Box<E> { | ||
|
|
||
| final Box<E> _box; | ||
| final Hub _hub; | ||
|
|
||
| // ignore: public_member_api_docs | ||
| SentryBox(this._box, @internal Hub? hub) : _hub = hub ?? HubAdapter(); | ||
|
|
||
| @override | ||
| Future<int> add(E value) async { | ||
| return _asyncWrapInSpan('add', () async { | ||
| return await _box.add(value); | ||
| }); | ||
| } | ||
|
|
||
| @override | ||
| Future<Iterable<int>> addAll(Iterable<E> values) async { | ||
| return _asyncWrapInSpan('addAll', () async { | ||
| return await _box.addAll(values); | ||
| }); | ||
| } | ||
|
|
||
| @override | ||
| Future<int> clear() async { | ||
| return _asyncWrapInSpan('clear', () async { | ||
| return await _box.clear(); | ||
| }); | ||
| } | ||
|
|
||
| @override | ||
| Future<void> close() async { | ||
| return _asyncWrapInSpan('close', () async { | ||
| return await _box.close(); | ||
| }); | ||
| } | ||
|
|
||
| @override | ||
| Future<void> compact() async { | ||
| return _asyncWrapInSpan('compact', () async { | ||
| return await _box.compact(); | ||
| }); | ||
| } | ||
|
|
||
| @override | ||
| bool containsKey(key) { | ||
| return _box.containsKey(key); | ||
| } | ||
|
|
||
| @override | ||
| Future<void> delete(key) async { | ||
| return _asyncWrapInSpan('delete', () async { | ||
| return await _box.delete(key); | ||
| }); | ||
| } | ||
|
|
||
| @override | ||
| // ignore: strict_raw_type | ||
| Future<void> deleteAll(Iterable keys) async { | ||
| return _asyncWrapInSpan('delete', () async { | ||
| return await _box.deleteAll(keys); | ||
| }); | ||
| } | ||
|
|
||
| @override | ||
| Future<void> deleteAt(int index) async { | ||
| return _asyncWrapInSpan('deleteAt', () async { | ||
| return await _box.deleteAt(index); | ||
| }); | ||
| } | ||
|
|
||
| @override | ||
| Future<void> deleteFromDisk() async { | ||
| return _asyncWrapInSpan('deleteFromDisk', () async { | ||
| return await _box.deleteFromDisk(); | ||
| }); | ||
| } | ||
|
|
||
| @override | ||
| Future<void> flush() async { | ||
| return _asyncWrapInSpan('flush', () async { | ||
| return await _box.flush(); | ||
| }); | ||
| } | ||
|
|
||
| @override | ||
| E? get(key, {E? defaultValue}) { | ||
| return _box.get(key, defaultValue: defaultValue); | ||
| } | ||
|
|
||
| @override | ||
| E? getAt(int index) { | ||
| return _box.getAt(index); | ||
| } | ||
|
|
||
| @override | ||
| bool get isEmpty => _box.isEmpty; | ||
|
|
||
| @override | ||
| bool get isNotEmpty => _box.isNotEmpty; | ||
|
|
||
| @override | ||
| bool get isOpen => _box.isOpen; | ||
|
|
||
| @override | ||
| dynamic keyAt(int index) { | ||
| return _box.keyAt(index); | ||
| } | ||
|
|
||
| @override | ||
| // ignore: strict_raw_type | ||
| Iterable get keys => _box.keys; | ||
|
|
||
| @override | ||
| bool get lazy => _box.lazy; | ||
|
|
||
| @override | ||
| int get length => _box.length; | ||
|
|
||
| @override | ||
| String get name => _box.name; | ||
|
|
||
| @override | ||
| String? get path => _box.path; | ||
|
|
||
| @override | ||
| Future<void> put(key, E value) async { | ||
| return _asyncWrapInSpan('put', () async { | ||
| return await _box.put(key, value); | ||
| }); | ||
| } | ||
|
|
||
| @override | ||
| Future<void> putAll(Map<dynamic, E> entries) async { | ||
| return _asyncWrapInSpan('putAll', () async { | ||
| return await _box.putAll(entries); | ||
| }); | ||
| } | ||
|
|
||
| @override | ||
| Future<void> putAt(int index, E value) async { | ||
| return _asyncWrapInSpan('putAt', () async { | ||
| return await _box.putAt(index, value); | ||
| }); | ||
| } | ||
|
|
||
| @override | ||
| Map<dynamic, E> toMap() { | ||
| return _box.toMap(); | ||
| } | ||
|
|
||
| @override | ||
| Iterable<E> get values => _box.values; | ||
|
|
||
| @override | ||
| Iterable<E> valuesBetween({startKey, endKey}) { | ||
| return _box.valuesBetween(startKey: startKey, endKey: endKey); | ||
| } | ||
|
|
||
| @override | ||
| Stream<BoxEvent> watch({key}) { | ||
| return _box.watch(key: key); | ||
| } | ||
|
|
||
| // Helper | ||
|
|
||
| Future<T> _asyncWrapInSpan<T>(String description, Future<T> Function() execute) async { | ||
| final currentSpan = _hub.getSpan(); | ||
| final span = currentSpan?.startChild( | ||
| SentryHive.dbOp, | ||
| description: description, | ||
| ); | ||
|
|
||
| // ignore: invalid_use_of_internal_member | ||
| span?.origin = SentryTraceOrigins.autoDbHiveBox; | ||
|
|
||
| span?.setData(SentryHive.dbSystemKey, SentryHive.dbSystem); | ||
| span?.setData(SentryHive.dbNameKey, name); | ||
|
|
||
| try { | ||
| final result = await execute(); | ||
| span?.status = SpanStatus.ok(); | ||
|
|
||
| return result; | ||
| } catch (exception) { | ||
| span?.throwable = exception; | ||
| span?.status = SpanStatus.internalError(); | ||
|
|
||
| rethrow; | ||
| } finally { | ||
| await span?.finish(); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,19 @@ | ||
| // TODO: Put public facing types in this file. | ||
| import 'package:meta/meta.dart'; | ||
|
|
||
| /// Checks if you are awesome. Spoiler: you are. | ||
| class Awesome { | ||
| bool get isAwesome => true; | ||
| class SentryHive { | ||
| @internal | ||
| // ignore: public_member_api_docs | ||
| static const dbOp = 'db'; | ||
|
|
||
| @internal | ||
| // ignore: public_member_api_docs | ||
| static const dbSystemKey = 'db.system'; | ||
| @internal | ||
| // ignore: public_member_api_docs | ||
| static const dbSystem = 'sqlite'; | ||
|
|
||
| @internal | ||
| // ignore: public_member_api_docs | ||
| static const dbNameKey = 'db.name'; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import 'dart:ffi'; | ||
| import 'dart:io'; | ||
| import 'dart:math'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import 'package:mockito/annotations.dart'; | ||
| import 'package:sentry/sentry.dart'; | ||
|
|
||
| @GenerateMocks( | ||
| [ | ||
| Hub, | ||
| ] | ||
| ) | ||
| void main() {} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.