Skip to content

Commit

Permalink
Merge branch 'main' into chore/8.0.0-merge-main
Browse files Browse the repository at this point in the history
  • Loading branch information
buenaflor committed Jan 24, 2024
2 parents 735cc3f + 7e4a1ec commit ba60f93
Show file tree
Hide file tree
Showing 16 changed files with 72 additions and 28 deletions.
1 change: 1 addition & 0 deletions .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ targets:
sqflite:
hive:
drift:
isar:
- name: github
- name: registry
sdks:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
working-directory: ${{ inputs.package }}
steps:
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d # pin@v1
- uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b # pin@v1
if: ${{ inputs.sdk == 'dart' }}
- uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225 # pin@v2.12.0
if: ${{ inputs.sdk == 'flutter' }}
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,15 @@ jobs:
strategy:
fail-fast: false
matrix:
# TODO: exclude windows for now, because of failing tests in the new image runner
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest, windows-latest, macos-latest]
sdk: [stable, beta]
exclude:
- os: windows-latest
sdk: beta
- os: macos-latest
sdk: beta
steps:
- uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d # pin@v1
- uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b # pin@v1
with:
sdk: ${{ matrix.sdk }}
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/diagrams.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
name: "Create class diagrams of all packages"
steps:
- uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d # pin@v1
- uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b # pin@v1
with:
sdk: stable

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- os: macos-latest
sdk: beta
steps:
- uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d # pin@v1
- uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b # pin@v1
with:
sdk: ${{ matrix.sdk }}
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e_dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
matrix:
sdk: [stable, beta]
steps:
- uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d # pin@v1
- uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b # pin@v1
with:
sdk: ${{ matrix.sdk }}
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- os: macos-latest
sdk: beta
steps:
- uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d # pin@v1
- uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b # pin@v1
with:
sdk: ${{ matrix.sdk }}
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/flutter-symbols.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d # pin@v1
- uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b # pin@v1

- run: dart pub get

Expand All @@ -33,7 +33,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d # pin@v1
- uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b # pin@v1

- run: dart pub get

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:
- "!**/class-diagram.svg"
- "dart/**"
- "flutter/**"
- "metrics/flutter.properties"

jobs:
cancel-previous-workflow:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/format-and-fix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
working-directory: ${{ matrix.package.name }}
steps:
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d # pin@v1
- uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b # pin@v1
if: ${{ matrix.package.sdk == 'dart' }}
- uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225 # pin@v2.12.0
if: ${{ matrix.package.sdk == 'flutter' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/hive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- os: macos-latest
sdk: beta
steps:
- uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d # pin@v1
- uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b # pin@v1
with:
sdk: ${{ matrix.sdk }}
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/logging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- os: macos-latest
sdk: beta
steps:
- uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d # pin@v1
- uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b # pin@v1
with:
sdk: ${{ matrix.sdk }}
- uses: actions/checkout@v4
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

### Features

- APM for isar ([#1726](https://github.com/getsentry/sentry-dart/pull/1726))
- Tracing without performance for Dio integration ([#1837](https://github.com/getsentry/sentry-dart/pull/1837))
- Accept `Map<String, dynamic>` in `Hint` class ([#1807](https://github.com/getsentry/sentry-dart/pull/1807))
- Please check if everything works as expected when using `Hint`
- Factory constructor `Hint.withMap(Map<String, dynamic> map)` now takes `Map<String, dynamic>` instead of `Map<String, Object>`
Expand All @@ -34,7 +36,6 @@
- Set `options.spotlight = Spotlight(enabled: true)` to enable Spotlight
- Add `ConnectivityIntegration` for web ([#1765](https://github.com/getsentry/sentry-dart/pull/1765))
- We only get the info if online/offline on web platform. The added breadcrumb is set to either `wifi` or `none`.
- APM for isar ([#1726](https://github.com/getsentry/sentry-dart/pull/1726))
- Add isar breadcrumbs ([#1800](https://github.com/getsentry/sentry-dart/pull/1800))
- Starting with Flutter 3.16, Sentry adds the [`appFlavor`](https://api.flutter.dev/flutter/services/appFlavor-constant.html) to the `flutter_context` ([#1799](https://github.com/getsentry/sentry-dart/pull/1799))
- Add beforeScreenshotCallback to SentryFlutterOptions ([#1805](https://github.com/getsentry/sentry-dart/pull/1805))
Expand Down
31 changes: 25 additions & 6 deletions dio/lib/src/tracing_client_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,38 @@ class TracingClientAdapter implements HttpClientAdapter {

ResponseBody? response;
try {
if (span != null) {
if (containsTargetOrMatchesRegExp(
// ignore: invalid_use_of_internal_member
_hub.options.tracePropagationTargets,
options.uri.toString(),
)) {
if (containsTargetOrMatchesRegExp(
// ignore: invalid_use_of_internal_member
_hub.options.tracePropagationTargets,
options.uri.toString(),
)) {
if (span != null) {
addSentryTraceHeaderFromSpan(span, options.headers);
addBaggageHeaderFromSpan(
span,
options.headers,
// ignore: invalid_use_of_internal_member
logger: _hub.options.logger,
);
} else {
// ignore: invalid_use_of_internal_member
final scope = _hub.scope;
// ignore: invalid_use_of_internal_member
final propagationContext = scope.propagationContext;

final traceHeader = propagationContext.toSentryTrace();
addSentryTraceHeader(traceHeader, options.headers);

final baggage = propagationContext.baggage;
if (baggage != null) {
final baggageHeader = SentryBaggageHeader.fromBaggage(baggage);
addBaggageHeader(
baggageHeader,
options.headers,
// ignore: invalid_use_of_internal_member
logger: _hub.options.logger,
);
}
}
}

Expand Down
37 changes: 30 additions & 7 deletions dio/test/tracing_client_adapter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,25 +127,48 @@ void main() {
);
});

test('captured span do not add headers if NoOp', () async {
test('do not throw if no span bound to the scope', () async {
final sut = fixture.getSut(
client: fixture.getClient(statusCode: 200, reason: 'OK'),
);

await sut.get<dynamic>(requestOptions);
});

test('set headers from propagationContext when tracing is disabled',
() async {
fixture._options.enableTracing = false;
final sut = fixture.getSut(
client: fixture.getClient(statusCode: 200, reason: 'OK'),
);
await fixture._hub
.configureScope((scope) => scope.span = NoOpSentrySpan());

final propagationContext = fixture._hub.scope.propagationContext;
propagationContext.baggage = SentryBaggage({'foo': 'bar'});

final response = await sut.get<dynamic>(requestOptions);

expect(response.headers['baggage'], null);
expect(response.headers['sentry-trace'], null);
expect(
response.headers['sentry-trace'],
[propagationContext.toSentryTrace().value],
);
expect(response.headers['baggage'], ['foo=bar']);
});

test('do not throw if no span bound to the scope', () async {
test('set headers from propagationContext when no transaction', () async {
final sut = fixture.getSut(
client: fixture.getClient(statusCode: 200, reason: 'OK'),
);

await sut.get<dynamic>(requestOptions);
final propagationContext = fixture._hub.scope.propagationContext;
propagationContext.baggage = SentryBaggage({'foo': 'bar'});

final response = await sut.get<dynamic>(requestOptions);

expect(
response.headers['sentry-trace'],
[propagationContext.toSentryTrace().value],
);
expect(response.headers['baggage'], ['foo=bar']);
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion metrics/flutter.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = 3.16.7
version = 3.16.8
repo = https://github.com/flutter/flutter

0 comments on commit ba60f93

Please sign in to comment.