-
-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tracing for File IO integration (#1160)
- Loading branch information
1 parent
62dde43
commit b47809a
Showing
29 changed files
with
1,436 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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 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,64 @@ | ||
name: sentry-file | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- release/** | ||
pull_request: | ||
paths-ignore: | ||
- 'logging/**' | ||
- 'flutter/**' | ||
- 'dio/**' | ||
|
||
jobs: | ||
cancel-previous-workflow: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Cancel Previous Runs | ||
uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 # pin@0.11.0 | ||
with: | ||
access_token: ${{ github.token }} | ||
|
||
build: | ||
name: Build ${{matrix.sdk}} on ${{matrix.os}} | ||
runs-on: ${{ matrix.os }} | ||
timeout-minutes: 30 | ||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: ./file | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
# removing beta because of Dart 2.19.0 | ||
sdk: [stable] | ||
steps: | ||
- uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d # pin@v1 | ||
with: | ||
sdk: ${{ matrix.sdk }} | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Test VM | ||
run: | | ||
dart pub get | ||
dart test -p vm --coverage=coverage --test-randomize-ordering-seed=random --chain-stack-traces | ||
dart pub run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --packages=.dart_tool/package_config.json --report-on=lib | ||
- uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # pin@v3 | ||
if: runner.os == 'Linux' && matrix.sdk == 'stable' | ||
with: | ||
name: sentry_file | ||
files: ./file/coverage/lcov.info | ||
|
||
- uses: VeryGoodOpenSource/very_good_coverage@84e5b54ab888644554e5573dca87d7f76dec9fb3 # pin@v2.0.0 | ||
if: runner.os == 'Linux' && matrix.sdk == 'stable' | ||
with: | ||
path: './file/coverage/lcov.info' | ||
min_coverage: 55 | ||
|
||
analyze: | ||
uses: ./.github/workflows/analyze.yml | ||
with: | ||
package: file | ||
panaThreshold: 90 |
This file contains 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 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 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 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 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 @@ | ||
../CHANGELOG.md |
This file contains 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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Sentry | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains 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,79 @@ | ||
<p align="center"> | ||
<a href="https://sentry.io" target="_blank" align="center"> | ||
<img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280"> | ||
</a> | ||
<br /> | ||
</p> | ||
|
||
Sentry integration for `dart.io.File` | ||
=========== | ||
|
||
| package | build | pub | likes | popularity | pub points | | ||
| ------- | ------- | ------- | ------- | ------- | ------- | | ||
| sentry_file | [![build](https://github.com/getsentry/sentry-dart/workflows/sentry-file/badge.svg?branch=main)](https://github.com/getsentry/sentry-dart/actions?query=workflow%3Asentry-file) | [![pub package](https://img.shields.io/pub/v/sentry_file.svg)](https://pub.dev/packages/sentry_file) | [![likes](https://img.shields.io/pub/likes/sentry_file)](https://pub.dev/packages/sentry_file/score) | [![popularity](https://img.shields.io/pub/popularity/sentry_file)](https://pub.dev/packages/sentry_file/score) | [![pub points](https://img.shields.io/pub/points/sentry_file)](https://pub.dev/packages/sentry_file/score) | ||
|
||
#### Usage | ||
|
||
- Sign up for a Sentry.io account and get a DSN at https://sentry.io. | ||
|
||
- Follow the installing instructions on [pub.dev](https://pub.dev/packages/sentry/install). | ||
|
||
- Initialize the Sentry SDK using the DSN issued by Sentry.io. | ||
|
||
- [Set Up](https://docs.sentry.io/platforms/dart/performance/) Performance. | ||
|
||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
import 'package:sentry_file/sentry_file.dart'; | ||
import 'dart:io'; | ||
Future<void> main() async { | ||
// or SentryFlutter.init | ||
await Sentry.init( | ||
(options) { | ||
options.dsn = 'https://example@sentry.io/example'; | ||
// To set a uniform sample rate | ||
options.tracesSampleRate = 1.0; | ||
}, | ||
appRunner: runApp, // Init your App. | ||
); | ||
} | ||
Future<void> runApp() async { | ||
final file = File('my_file.txt'); | ||
// Call the Sentry extension method to wrap up the File | ||
final sentryFile = file.sentryTrace(); | ||
// Start a transaction if there's no active transaction | ||
final transaction = Sentry.startTransaction( | ||
'MyFileExample', | ||
'file', | ||
bindToScope: true, | ||
); | ||
// create the File | ||
await sentryFile.create(); | ||
// Write some content | ||
await sentryFile.writeAsString('Hello World'); | ||
// Read the content | ||
final text = await sentryFile.readAsString(); | ||
print(text); | ||
// Delete the file | ||
await sentryFile.delete(); | ||
// Finish the transaction | ||
await transaction.finish(status: SpanStatus.ok()); | ||
await Sentry.close(); | ||
} | ||
``` | ||
|
||
#### Resources | ||
|
||
* [![Documentation](https://img.shields.io/badge/documentation-sentry.io-green.svg)](https://docs.sentry.io/platforms/dart/) | ||
* [![Forum](https://img.shields.io/badge/forum-sentry-green.svg)](https://forum.sentry.io/c/sdks) | ||
* [![Discord](https://img.shields.io/discord/621778831602221064)](https://discord.gg/Ww9hbqr) | ||
* [![Stack Overflow](https://img.shields.io/badge/stack%20overflow-sentry-green.svg)](https://stackoverflow.com/questions/tagged/sentry) | ||
* [![Twitter Follow](https://img.shields.io/twitter/follow/getsentry?label=getsentry&style=social)](https://twitter.com/intent/follow?screen_name=getsentry) |
This file contains 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,23 @@ | ||
include: package:lints/recommended.yaml | ||
|
||
analyzer: | ||
exclude: | ||
- example/** # the example has its own 'analysis_options.yaml' | ||
errors: | ||
# treat missing required parameters as a warning (not a hint) | ||
missing_required_param: error | ||
# treat missing returns as a warning (not a hint) | ||
missing_return: error | ||
language: | ||
strict-casts: true | ||
strict-inference: true | ||
strict-raw-types: true | ||
|
||
linter: | ||
rules: | ||
prefer_relative_imports: true | ||
unnecessary_brace_in_string_interps: true | ||
prefer_function_declarations_over_variables: false | ||
no_leading_underscores_for_local_identifiers: false | ||
avoid_renaming_method_parameters: false | ||
unawaited_futures: true |
This file contains 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,51 @@ | ||
import 'package:sentry/sentry.dart'; | ||
import 'package:sentry_file/sentry_file.dart'; | ||
import 'dart:io'; | ||
|
||
Future<void> main() async { | ||
// ATTENTION: Change the DSN below with your own to see the events in Sentry. Get one at sentry.io | ||
const dsn = | ||
'https://e85b375ffb9f43cf8bdf9787768149e0@o447951.ingest.sentry.io/5428562'; | ||
|
||
// or SentryFlutter.init | ||
await Sentry.init( | ||
(options) { | ||
options.dsn = dsn; | ||
// To capture the absolute path of the file | ||
options.sendDefaultPii = true; | ||
// To set a uniform sample rate | ||
options.tracesSampleRate = 1.0; | ||
}, | ||
appRunner: runApp, // Init your App. | ||
); | ||
} | ||
|
||
Future<void> runApp() async { | ||
final file = File('my_file.txt'); | ||
// Call the Sentry extension method to wrap up the File | ||
final sentryFile = file.sentryTrace(); | ||
|
||
// Start a transaction if there's no active transaction | ||
final transaction = Sentry.startTransaction( | ||
'MyFileExample', | ||
'file', | ||
bindToScope: true, | ||
); | ||
|
||
// Create the File | ||
await sentryFile.create(); | ||
// Write some content | ||
await sentryFile.writeAsString('Hello World'); | ||
// Read the content | ||
final text = await sentryFile.readAsString(); | ||
|
||
print(text); | ||
|
||
// Delete the file | ||
await sentryFile.delete(); | ||
|
||
// Finish the transaction | ||
await transaction.finish(status: SpanStatus.ok()); | ||
|
||
await Sentry.close(); | ||
} |
This file contains 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,2 @@ | ||
export 'src/sentry_file.dart'; | ||
export 'src/sentry_file_extension.dart'; |
Oops, something went wrong.