-
Notifications
You must be signed in to change notification settings - Fork 37
Telemetry #66
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
Telemetry #66
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
a20a460
Fully generic TableSet leveraging sqlite3 over Persistable instances!
matux e5da9ad
Generic SQL instruction set.
matux 43e7fa6
Added TableSet tests
matux 5c50dcf
Removed old database.
matux d0a7771
Telemetry data structures, removed Result, some documentation.
matux 18706fb
Fully composable processes
matux 2e0269a
Moved Config back to /src
matux 18e9b4a
Refactored Body to carry Telemetry.
matux 338b1cb
Tests now use AsyncNotifier instead of IsolatedNotifier for testability
matux 27c0cd5
Added Record for persistent telemetry readings.
matux eddf495
New language extensions.
matux b024ad8
Added sorting to TableSet, telemetry is always sorted by timestamp.
matux 7586d57
Added Telemetry class that manages telemetry readings.
matux f68c643
Renamed ext dir in Rollbar Dart to extension.
matux bb105fa
Report is now a mixin.
matux e618eae
Updated minimum Dart/Flutter support to 2.17/3.0
matux 61b3141
Updates to language extensions
matux c9dd5a2
Removed logging file.
matux b25e12b
Removed generated Telemetry Mocks and wrote them manually.
matux 08b1793
Renamed PersistentSender to PersistentHttpSender.
matux efea96a
Send telemetry on every occurrence.
matux 0a247e9
Created a ZippedIterable in Rollbar Common.
matux 19575e4
Removed config from PayloadRecord
matux e0f8a55
Mixin for deep equality of nested data structures
matux 984fdb0
Send number of processors to Rollbar.
matux 94d706e
Equatable/Serializable test suite for all our data structures.
matux 6a4968b
Retrieve a sorted by timestamp snapshot of all telemetry events
matux a50174c
Fixed dynamic casting issue in Json in PlatformTransformer.
matux 9f3fd12
Added manual deep test of a payload serialization roundtrip.
matux e93b996
Fixed some tests.
matux 7de9aaa
Enabled persisting payloads by default.
matux 030011f
Don't keep a Config on Telemetry.
matux 01cd7e6
Forcing sqlite3_flutter_libs to 3.5.8 due to #65
matux 383d53d
Use IsolatedNotifier only with Flutter.
matux 5912afd
Use latest pana version again.
matux 508462e
Gitignore local db files.
matux 635f3eb
Share unique database between types with Persistence.
matux 6ba0ea5
Telemetry must be in Notifier since it must share the Isolate memory.
matux e694959
Use proper platform-specific directory to store database file.
matux ca1f612
Added telemetry to example, logging to http sender, fixed timestamp
matux a7cb8e6
Added configurable lifetime threshold for all persistent records.
matux df6801a
All tests passing.
matux 2ef97be
Renamed Event to Occurrence, added @internal attributes to internals.
matux e373514
Cleaning up exports and public api.
matux a858b8d
Cleaned up some tests
matux c2e27e5
Misc cleanup
matux 5f29254
Adjustments to the telemetry API.
matux 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
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
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
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,121 @@ | ||
import 'package:meta/meta.dart'; | ||
import '../../rollbar_common.dart' | ||
show | ||
Persistable, | ||
PersistableFor, | ||
SerializableFor, | ||
UUID, | ||
uuidGen, | ||
Datatype, | ||
JsonMap; | ||
|
||
@sealed | ||
@immutable | ||
class BreadcrumbRecord implements Persistable<UUID> { | ||
@override | ||
final UUID id; | ||
final String breadcrumb; | ||
final DateTime timestamp; | ||
|
||
static Map<String, Datatype> get persistingKeyTypes => { | ||
'id': Datatype.uuid, | ||
'breadcrumb': Datatype.text, | ||
'timestamp': Datatype.integer, | ||
}; | ||
|
||
BreadcrumbRecord({ | ||
UUID? id, | ||
required this.breadcrumb, | ||
DateTime? timestamp, | ||
}) : id = id ?? uuidGen.v4obj(), | ||
timestamp = timestamp ?? DateTime.now().toUtc(); | ||
|
||
BreadcrumbRecord copyWith({ | ||
UUID? id, | ||
String? breadcrumb, | ||
DateTime? timestamp, | ||
}) => | ||
BreadcrumbRecord( | ||
id: id ?? this.id, | ||
breadcrumb: breadcrumb ?? this.breadcrumb, | ||
timestamp: timestamp ?? this.timestamp); | ||
|
||
@override | ||
factory BreadcrumbRecord.fromMap(JsonMap map) => BreadcrumbRecord( | ||
id: map.id, | ||
breadcrumb: map.breadcrumb, | ||
timestamp: map.timestamp, | ||
); | ||
|
||
@override | ||
JsonMap toMap() => { | ||
'id': id.toBytes(), | ||
'breadcrumb': breadcrumb, | ||
'timestamp': timestamp.microsecondsSinceEpoch, | ||
}; | ||
|
||
/// Compares this [BreadcrumbRecord] to another [BreadcrumbRecord]. | ||
/// | ||
/// Comparison is timestamp-based. | ||
/// | ||
/// If [other] is not a [BreadcrumbRecord] instance, an [ArgumentError] is | ||
/// thrown. | ||
/// | ||
/// Returns a value like a [Comparator] when comparing this to [other]. That | ||
/// is, it returns a negative integer if this is ordered before [other], a | ||
/// positive integer if this is ordered after [other], and zero if this and | ||
/// [other] are ordered together. | ||
/// | ||
/// The [other] argument must be a value that is comparable to this object. | ||
@override | ||
int compareTo(other) { | ||
if (other is! BreadcrumbRecord) { | ||
throw ArgumentError('Cannot compare between different types.', other); | ||
} | ||
|
||
return timestamp.compareTo(other.timestamp); | ||
} | ||
|
||
@override | ||
String toString() => 'Record(' | ||
'id: ${id.uuid}, ' | ||
'breadcrumb: $breadcrumb, ' | ||
'timestamp: $timestamp)'; | ||
|
||
@override | ||
bool operator ==(Object other) => | ||
identical(this, other) || | ||
(other is BreadcrumbRecord && | ||
other.id == id && | ||
other.breadcrumb == breadcrumb && | ||
other.timestamp == timestamp); | ||
|
||
@override | ||
int get hashCode => Object.hash(id, breadcrumb, timestamp); | ||
} | ||
|
||
@sealed | ||
class SerializableBreadcrumbRecord implements SerializableFor { | ||
const SerializableBreadcrumbRecord(); | ||
|
||
@override | ||
BreadcrumbRecord fromMap(JsonMap map) => BreadcrumbRecord.fromMap(map); | ||
} | ||
|
||
@sealed | ||
class PersistableBreadcrumbRecord implements PersistableFor { | ||
const PersistableBreadcrumbRecord(); | ||
|
||
@override | ||
Map<String, Datatype> get persistingKeyTypes => | ||
BreadcrumbRecord.persistingKeyTypes; | ||
} | ||
|
||
extension BreadcrumbRecordAttributes on JsonMap { | ||
UUID get id => UUID.fromList(this['id'].whereType<int>().toList()); | ||
String get breadcrumb => this['breadcrumb']; | ||
DateTime get timestamp => DateTime.fromMicrosecondsSinceEpoch( | ||
this['timestamp'], | ||
isUtc: true, | ||
); | ||
} |
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,141 @@ | ||
import 'package:meta/meta.dart'; | ||
import '../../rollbar_common.dart' | ||
show | ||
Persistable, | ||
PersistableFor, | ||
SerializableFor, | ||
UUID, | ||
uuidGen, | ||
Datatype, | ||
JsonMap; | ||
|
||
@sealed | ||
@immutable | ||
class PayloadRecord implements Persistable<UUID> { | ||
matux marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@override | ||
final UUID id; | ||
final String accessToken; | ||
final String endpoint; | ||
final String payload; | ||
final DateTime timestamp; | ||
|
||
static Map<String, Datatype> get persistingKeyTypes => { | ||
'id': Datatype.uuid, | ||
'accessToken': Datatype.text, | ||
'endpoint': Datatype.text, | ||
'payload': Datatype.text, | ||
'timestamp': Datatype.integer, | ||
}; | ||
|
||
PayloadRecord({ | ||
UUID? id, | ||
required this.accessToken, | ||
required this.endpoint, | ||
required this.payload, | ||
DateTime? timestamp, | ||
}) : id = id ?? uuidGen.v4obj(), | ||
timestamp = timestamp ?? DateTime.now().toUtc(); | ||
|
||
PayloadRecord copyWith({ | ||
UUID? id, | ||
String? accessToken, | ||
String? endpoint, | ||
String? payload, | ||
DateTime? timestamp, | ||
}) => | ||
PayloadRecord( | ||
id: id ?? this.id, | ||
accessToken: accessToken ?? this.accessToken, | ||
endpoint: endpoint ?? this.endpoint, | ||
payload: payload ?? this.payload, | ||
timestamp: timestamp ?? this.timestamp); | ||
|
||
@override | ||
factory PayloadRecord.fromMap(JsonMap map) => PayloadRecord( | ||
id: map.id, | ||
accessToken: map.accessToken, | ||
endpoint: map.endpoint, | ||
payload: map.payload, | ||
timestamp: map.timestamp); | ||
|
||
@override | ||
JsonMap toMap() => { | ||
'id': id.toBytes(), | ||
'accessToken': accessToken, | ||
'endpoint': endpoint, | ||
'payload': payload, | ||
'timestamp': timestamp.microsecondsSinceEpoch, | ||
}; | ||
|
||
/// Compares this [PayloadRecord] to another [PayloadRecord]. | ||
/// | ||
/// Comparison is timestamp-based. | ||
/// | ||
/// If [other] is not a [PayloadRecord] instance, an [ArgumentError] is | ||
/// thrown. | ||
/// | ||
/// Returns a value like a [Comparator] when comparing this to [other]. That | ||
/// is, it returns a negative integer if this is ordered before [other], a | ||
/// positive integer if this is ordered after [other], and zero if this and | ||
/// [other] are ordered together. | ||
/// | ||
/// The [other] argument must be a value that is comparable to this object. | ||
@override | ||
int compareTo(other) { | ||
if (other is! PayloadRecord) { | ||
throw ArgumentError('Cannot compare between different types.', other); | ||
} | ||
|
||
return timestamp.compareTo(other.timestamp); | ||
} | ||
|
||
@override | ||
String toString() => 'Record(' | ||
'id: ${id.uuid}, ' | ||
'accessToken: $accessToken, ' | ||
'endpoint: $endpoint, ' | ||
'payload: $payload, ' | ||
'timestamp: $timestamp)'; | ||
|
||
@override | ||
bool operator ==(Object other) => | ||
identical(this, other) || | ||
(other is PayloadRecord && | ||
other.id == id && | ||
other.accessToken == accessToken && | ||
other.endpoint == endpoint && | ||
other.payload == payload && | ||
other.timestamp == timestamp); | ||
|
||
@override | ||
int get hashCode => | ||
Object.hash(id, accessToken, endpoint, payload, timestamp); | ||
} | ||
|
||
@sealed | ||
class SerializablePayloadRecord implements SerializableFor { | ||
const SerializablePayloadRecord(); | ||
|
||
@override | ||
PayloadRecord fromMap(JsonMap map) => PayloadRecord.fromMap(map); | ||
} | ||
|
||
@sealed | ||
class PersistablePayloadRecord implements PersistableFor { | ||
const PersistablePayloadRecord(); | ||
|
||
@override | ||
Map<String, Datatype> get persistingKeyTypes => | ||
PayloadRecord.persistingKeyTypes; | ||
} | ||
|
||
extension PayloadRecordAttributes on JsonMap { | ||
UUID get id => UUID.fromList(this['id'].whereType<int>().toList()); | ||
String get accessToken => this['accessToken']; | ||
String get endpoint => this['endpoint']; | ||
String get payload => this['payload']; | ||
DateTime get timestamp => DateTime.fromMicrosecondsSinceEpoch( | ||
this['timestamp'], | ||
isUtc: true, | ||
); | ||
} |
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.