Skip to content

Commit

Permalink
Merge branch 'main' into enha/user-unhandled
Browse files Browse the repository at this point in the history
  • Loading branch information
denrase committed Jul 24, 2023
2 parents db2b18e + 0aaa46e commit 6f1f672
Show file tree
Hide file tree
Showing 46 changed files with 929 additions and 223 deletions.
122 changes: 74 additions & 48 deletions .github/workflows/flutter_integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,71 +21,97 @@ jobs:
runs-on: macos-latest
timeout-minutes: 30
defaults:
run:
working-directory: ./flutter/example
run:
working-directory: ./flutter/example
strategy:
fail-fast: false
matrix:
sdk: ['stable', 'beta']
fail-fast: false
matrix:
sdk: ['stable', 'beta']
steps:
- name: checkout
uses: actions/checkout@v3
- name: checkout
uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '11'
- uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '11'

- uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa # [email protected]
with:
channel: ${{ matrix.sdk }}
- uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa # [email protected]
with:
channel: ${{ matrix.sdk }}

- name: flutter upgrade
run: flutter upgrade
- name: flutter upgrade
run: flutter upgrade

- name: flutter pub get
run: flutter pub get
- name: flutter pub get
run: flutter pub get

- name: Gradle cache
uses: gradle/gradle-build-action@v2

- name: AVD cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-21

- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b #[email protected]
with:
working-directory: ./flutter/example
api-level: 21
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
arch: x86_64
profile: Nexus 6
script: echo "Generated AVD snapshot for caching."

- name: launch android emulator & run android integration test
uses: reactivecircus/android-emulator-runner@50986b1464923454c95e261820bc626f38490ec0 #pin@v2.27.0
uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b #pin@v2.28.0
with:
working-directory: ./flutter/example
api-level: 21
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
arch: x86_64
profile: Nexus 6
script: flutter test integration_test/integration_test.dart --verbose

# Enable after fixing https://github.com/getsentry/sentry-dart/issues/1448
# test-ios:
# runs-on: macos-latest
# timeout-minutes: 30
# defaults:
# run:
# working-directory: ./flutter/example
# strategy:
# fail-fast: false
# matrix:
# # 'beta' is flaky because of https://github.com/flutter/flutter/issues/124340
# sdk: ['stable']
# steps:
# - name: checkout
# uses: actions/checkout@v3
test-ios:
runs-on: macos-13
timeout-minutes: 30
defaults:
run:
working-directory: ./flutter/example
strategy:
fail-fast: false
matrix:
# 'beta' is flaky because of https://github.com/flutter/flutter/issues/124340
sdk: ['stable']
steps:
- name: checkout
uses: actions/checkout@v3

# - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa # [email protected]
# with:
# channel: ${{ matrix.sdk }}
- uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa # [email protected]
with:
channel: ${{ matrix.sdk }}

# - name: flutter upgrade
# run: flutter upgrade
- name: flutter upgrade
run: flutter upgrade

# - name: flutter pub get
# run: flutter pub get
- name: flutter pub get
run: flutter pub get

# - name: launch ios emulator
# uses: futureware-tech/simulator-action@ee05c113b79f056b47f354d7b313555f5491e158 #pin@v2
# with:
# model: 'iPhone 14'
# os_version: '16.2'
- name: launch ios simulator
run: |
simulator_id=$(xcrun simctl create sentryPhone com.apple.CoreSimulator.SimDeviceType.iPhone-14 com.apple.CoreSimulator.SimRuntime.iOS-16-2)
xcrun simctl boot ${simulator_id}
# - name: run ios integration test
# run: flutter test integration_test/integration_test.dart --verbose
- name: run ios integration test
run: flutter test integration_test/integration_test.dart --verbose
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@
- Mark exceptions not handled by user as `handled: false` ([#1535](https://github.com/getsentry/sentry-dart/pull/1535))
- This will affect your release health data, and is therefore considered a breaking change.

### Features

- Send trace origin ([#1534](https://github.com/getsentry/sentry-dart/pull/1534))

[Trace origin](https://develop.sentry.dev/sdk/performance/trace-origin/) indicates what created a trace or a span. Not all transactions and spans contain enough information to tell whether the user or what precisely in the SDK created it. Origin solves this problem. The SDK now sends origin for transactions and spans.

### Dependencies

- Bump Cocoa SDK from v8.8.0 to v8.9.1 ([#1553](https://github.com/getsentry/sentry-dart/pull/1553))
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#891)
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.8.0...8.9.1)
- Bump Android SDK from v6.23.0 to v6.25.2 ([#1554](https://github.com/getsentry/sentry-dart/pull/1554))
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#6252)
- [diff](https://github.com/getsentry/sentry-java/compare/6.23.0...6.25.2)

## 7.8.0

### Enhancements
Expand Down
2 changes: 2 additions & 0 deletions dart/lib/sentry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ export 'src/utils/http_sanitizer.dart';
export 'src/utils/url_details.dart';
// ignore: invalid_export_of_internal_element
export 'src/utils/http_header_utils.dart';
// ignore: invalid_export_of_internal_element
export 'src/sentry_trace_origins.dart';
2 changes: 2 additions & 0 deletions dart/lib/src/http_client/tracing_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:http/http.dart';
import '../hub.dart';
import '../hub_adapter.dart';
import '../protocol.dart';
import '../sentry_trace_origins.dart';
import '../tracing.dart';
import '../utils/tracing_utils.dart';
import '../utils/http_sanitizer.dart';
Expand Down Expand Up @@ -33,6 +34,7 @@ class TracingClient extends BaseClient {
'http.client',
description: description,
);
span?.origin = SentryTraceOrigins.autoHttpHttp;

// if the span is NoOp, we don't want to attach headers
if (span is NoOpSentrySpan) {
Expand Down
7 changes: 7 additions & 0 deletions dart/lib/src/hub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ class Hub {
name,
operation,
description: description,
origin: SentryTraceOrigins.manual,
),
startTimestamp: startTimestamp,
bindToScope: bindToScope,
Expand Down Expand Up @@ -442,6 +443,12 @@ class Hub {
transactionContext.copyWith(samplingDecision: samplingDecision);
}

if (transactionContext.origin == null) {
transactionContext = transactionContext.copyWith(
origin: SentryTraceOrigins.manual,
);
}

final tracer = SentryTracer(
transactionContext,
this,
Expand Down
6 changes: 6 additions & 0 deletions dart/lib/src/noop_sentry_span.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ class NoOpSentrySpan extends ISentrySpan {
@override
SentrySpanContext get context => _spanContext;

@override
String? get origin => null;

@override
set origin(String? origin) {}

@override
SpanStatus? get status => null;

Expand Down
12 changes: 12 additions & 0 deletions dart/lib/src/protocol/sentry_span.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class SentrySpan extends ISentrySpan {
}) {
_startTimestamp = startTimestamp?.toUtc() ?? _hub.options.clock();
_finishedCallback = finishedCallback;
_origin = _context.origin;
}

@override
Expand Down Expand Up @@ -145,6 +146,14 @@ class SentrySpan extends ISentrySpan {
@override
SentrySpanContext get context => _context;

String? _origin;

@override
String? get origin => _origin;

@override
set origin(String? origin) => _origin = origin;

Map<String, dynamic> toJson() {
final json = _context.toJson();
json['start_timestamp'] =
Expand All @@ -162,6 +171,9 @@ class SentrySpan extends ISentrySpan {
if (_tags.isNotEmpty) {
json['tags'] = _tags;
}
if (_origin != null) {
json['origin'] = _origin;
}
return json;
}

Expand Down
11 changes: 11 additions & 0 deletions dart/lib/src/protocol/sentry_trace_context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ class SentryTraceContext {
/// The Span status
final SpanStatus? status;

/// The origin of the span indicates what created the span.
///
/// @note Gets set by the SDK. It is not expected to be set manually by users.
///
/// @see <https://develop.sentry.dev/sdk/performance/trace-origin>
final String? origin;

factory SentryTraceContext.fromJson(Map<String, dynamic> json) {
return SentryTraceContext(
operation: json['op'] as String,
Expand All @@ -41,6 +48,7 @@ class SentryTraceContext {
? null
: SpanStatus.fromString(json['status'] as String),
sampled: true,
origin: json['origin'] == null ? null : json['origin'] as String?,
);
}

Expand All @@ -53,6 +61,7 @@ class SentryTraceContext {
if (parentSpanId != null) 'parent_span_id': parentSpanId!.toString(),
if (description != null) 'description': description,
if (status != null) 'status': status!.toString(),
if (origin != null) 'origin': origin,
};
}

Expand All @@ -64,6 +73,7 @@ class SentryTraceContext {
status: status,
parentSpanId: parentSpanId,
sampled: sampled,
origin: origin,
);

SentryTraceContext({
Expand All @@ -74,6 +84,7 @@ class SentryTraceContext {
required this.operation,
this.description,
this.status,
this.origin,
}) : traceId = traceId ?? SentryId.newId(),
spanId = spanId ?? SpanId.newId();
}
10 changes: 10 additions & 0 deletions dart/lib/src/sentry_span_context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ class SentrySpanContext {
/// consistent across instances of the span.
final String? description;

/// The origin of the span indicates what created the span.
///
/// Gets set by the SDK. It is not expected to be set manually by users.
///
/// See https://develop.sentry.dev/sdk/performance/trace-origin
final String? origin;

/// Item encoded as JSON
Map<String, dynamic> toJson() {
return {
Expand All @@ -28,6 +35,7 @@ class SentrySpanContext {
'op': operation,
if (parentSpanId != null) 'parent_span_id': parentSpanId.toString(),
if (description != null) 'description': description,
if (origin != null) 'origin': origin,
};
}

Expand All @@ -37,6 +45,7 @@ class SentrySpanContext {
this.parentSpanId,
required this.operation,
this.description,
this.origin,
}) : traceId = traceId ?? SentryId.newId(),
spanId = spanId ?? SpanId.newId();

Expand All @@ -53,6 +62,7 @@ class SentrySpanContext {
parentSpanId: parentSpanId,
sampled: sampled,
status: status,
origin: origin,
);
}
}
10 changes: 10 additions & 0 deletions dart/lib/src/sentry_span_interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ abstract class ISentrySpan {
/// Gets the span context.
SentrySpanContext get context;

/// Gets the span origin
String? get origin;

/// Sets span origin.
///
/// Gets set by the SDK. It is not expected to be set manually by users.
///
/// See https://develop.sentry.dev/sdk/performance/trace-origin
set origin(String? origin);

/// Returns the end timestamp if finished
DateTime? get endTimestamp;

Expand Down
21 changes: 21 additions & 0 deletions dart/lib/src/sentry_trace_origins.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:meta/meta.dart';

@internal
class SentryTraceOrigins {
static const manual = 'manual';

static const autoNavigationRouteObserver = 'auto.navigation.route_observer';
static const autoHttpHttp = 'auto.http.http';
static const autoHttpDioHttpClientAdapter =
'auto.http.dio.http_client_adapter';
static const autoHttpDioTransformer = 'auto.http.dio.transformer';
static const autoFile = 'auto.file';
static const autoFileAssetBundle = 'auto.file.asset_bundle';
static const autoDbSqfliteOpenDatabase = 'auto.db.sqflite.open_database';
static const autoDbSqfliteBatch = 'auto.db.sqflite.batch';
static const autoDbSqfliteDatabase = 'auto.db.sqflite.database';
static const autoDbSqfliteDatabaseExecutor =
'auto.db.sqflite.database_executor';
static const autoDbSqfliteDatabaseFactory =
'auto.db.sqflite.database_factory';
}
6 changes: 6 additions & 0 deletions dart/lib/src/sentry_tracer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,12 @@ class SentryTracer extends ISentrySpan {
@override
SentrySpanContext get context => _rootSpan.context;

@override
String? get origin => _rootSpan.origin;

@override
set origin(String? origin) => _rootSpan.origin = origin;

@override
DateTime get startTimestamp => _rootSpan.startTimestamp;

Expand Down
Loading

0 comments on commit 6f1f672

Please sign in to comment.