Skip to content

Commit f506708

Browse files
committed
Merge branch 'main' into fix/discard-empty-stack-frames
2 parents 4aa7eec + 6852b33 commit f506708

33 files changed

+553
-96
lines changed

.github/workflows/flutter_test.yml

+16-13
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,20 @@ jobs:
5959
path: |
6060
~/.android/avd/*
6161
~/.android/adb*
62-
key: avd-21
62+
key: avd-31
6363

6464
- name: create AVD and generate snapshot for caching
6565
if: steps.avd-cache.outputs.cache-hit != 'true'
6666
uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b #[email protected]
6767
with:
6868
working-directory: ./flutter/example
69-
api-level: 21
70-
force-avd-creation: false
71-
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
72-
disable-animations: false
73-
arch: x86_64
69+
api-level: 31
7470
profile: Nexus 6
71+
arch: x86_64
72+
force-avd-creation: false
73+
avd-name: macOS-avd-x86_64-31
74+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
75+
disable-animations: true
7576
script: echo 'Generated AVD snapshot for caching.'
7677

7778
- name: build apk
@@ -82,24 +83,26 @@ jobs:
8283
uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b #[email protected]
8384
with:
8485
working-directory: ./flutter/example/android
85-
api-level: 21
86+
api-level: 31
87+
profile: Nexus 6
88+
arch: x86_64
8689
force-avd-creation: false
90+
avd-name: macOS-avd-x86_64-31
8791
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
8892
disable-animations: true
89-
arch: x86_64
90-
profile: Nexus 6
9193
script: ./gradlew testDebugUnitTest
9294

9395
- name: launch android emulator & run android integration test
9496
uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b #[email protected]
9597
with:
9698
working-directory: ./flutter/example
97-
api-level: 21
99+
api-level: 31
100+
profile: Nexus 6
101+
arch: x86_64
98102
force-avd-creation: false
103+
avd-name: macOS-avd-x86_64-31
99104
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
100105
disable-animations: true
101-
arch: x86_64
102-
profile: Nexus 6
103106
script: flutter test integration_test/integration_test.dart --verbose
104107

105108
test-ios:
@@ -134,7 +137,7 @@ jobs:
134137
- name: launch ios simulator
135138
id: sim
136139
run: |
137-
simulator_id=$(xcrun simctl create sentryPhone com.apple.CoreSimulator.SimDeviceType.iPhone-14 com.apple.CoreSimulator.SimRuntime.iOS-16-2)
140+
simulator_id=$(xcrun simctl create sentryPhone com.apple.CoreSimulator.SimDeviceType.iPhone-14 com.apple.CoreSimulator.SimRuntime.iOS-16-4)
138141
echo "SIMULATOR_ID=${simulator_id}" >> "$GITHUB_OUTPUT"
139142
xcrun simctl boot ${simulator_id}
140143
# Disable flutter integration tests because of flaky execution

CHANGELOG.md

+12-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
## Unreleased
44

5+
### Enhancements
6+
7+
- Add http.request.method attribute to http spans data ([#1633](https://github.com/getsentry/sentry-dart/pull/1633))
8+
- Add db.system and db.name attributes to db spans data ([#1629](https://github.com/getsentry/sentry-dart/pull/1629))
9+
10+
### Features
11+
12+
- Tracing without performance ([#1621](https://github.com/getsentry/sentry-dart/pull/1621))
13+
514
### Fixes
615

716
- Normalize data properties of `SentryUser` and `Breadcrumb` before sending over method channel ([#1591](https://github.com/getsentry/sentry-dart/pull/1591))
@@ -13,9 +22,9 @@
1322
- Bump Android SDK from v6.25.2 to v6.28.0 ([#1586](https://github.com/getsentry/sentry-dart/pull/1586))
1423
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#6280)
1524
- [diff](https://github.com/getsentry/sentry-java/compare/6.25.2...6.28.0)
16-
- Bump Cocoa SDK from v8.9.1 to v8.10.0 ([#1584](https://github.com/getsentry/sentry-dart/pull/1584), [#1606](https://github.com/getsentry/sentry-dart/pull/1606))
17-
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8100)
18-
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.9.1...8.10.0)
25+
- Bump Cocoa SDK from v8.9.1 to v8.11.0 ([#1584](https://github.com/getsentry/sentry-dart/pull/1584), [#1606](https://github.com/getsentry/sentry-dart/pull/1606), [#1626](https://github.com/getsentry/sentry-dart/pull/1626))
26+
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8110)
27+
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.9.1...8.11.0)
1928

2029
## 7.9.0
2130

dart/lib/src/http_client/tracing_client.dart

+19-6
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,33 @@ class TracingClient extends BaseClient {
4141
span = null;
4242
}
4343

44-
span?.setData('http.method', request.method);
44+
span?.setData('http.request.method', request.method);
4545
urlDetails?.applyToSpan(span);
4646

4747
StreamedResponse? response;
4848
try {
49-
if (span != null) {
50-
if (containsTargetOrMatchesRegExp(
51-
_hub.options.tracePropagationTargets, request.url.toString())) {
52-
addSentryTraceHeader(span, request.headers);
53-
addBaggageHeader(
49+
if (containsTargetOrMatchesRegExp(
50+
_hub.options.tracePropagationTargets, request.url.toString())) {
51+
if (span != null) {
52+
addSentryTraceHeaderFromSpan(span, request.headers);
53+
addBaggageHeaderFromSpan(
5454
span,
5555
request.headers,
5656
logger: _hub.options.logger,
5757
);
58+
} else {
59+
final scope = _hub.scope;
60+
final propagationContext = scope.propagationContext;
61+
62+
final traceHeader = propagationContext.toSentryTrace();
63+
addSentryTraceHeader(traceHeader, request.headers);
64+
65+
final baggage = propagationContext.baggage;
66+
if (baggage != null) {
67+
final baggageHeader = SentryBaggageHeader.fromBaggage(baggage);
68+
addBaggageHeader(baggageHeader, request.headers,
69+
logger: _hub.options.logger);
70+
}
5871
}
5972
}
6073

dart/lib/src/hub.dart

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'dart:async';
22
import 'dart:collection';
33

44
import 'package:meta/meta.dart';
5+
import 'propagation_context.dart';
56
import 'transport/data_category.dart';
67

78
import '../sentry.dart';
@@ -65,6 +66,9 @@ class Hub {
6566
/// Last event id recorded by the Hub
6667
SentryId get lastEventId => _lastEventId;
6768

69+
@internal
70+
Scope get scope => _peek().scope;
71+
6872
/// Captures the event.
6973
Future<SentryId> captureEvent(
7074
SentryEvent event, {
@@ -426,10 +430,8 @@ class Hub {
426430
"Instance is disabled and this 'startTransaction' call is a no-op.",
427431
);
428432
} else if (!_options.isTracingEnabled()) {
429-
_options.logger(
430-
SentryLevel.info,
431-
"Tracing is disabled and this 'startTransaction' returns a no-op.",
432-
);
433+
final item = _peek();
434+
item.scope.propagationContext = PropagationContext();
433435
} else {
434436
final item = _peek();
435437

dart/lib/src/hub_adapter.dart

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'hint.dart';
55

66
import 'hub.dart';
77
import 'protocol.dart';
8+
import 'scope.dart';
89
import 'sentry.dart';
910
import 'sentry_client.dart';
1011
import 'sentry_user_feedback.dart';
@@ -166,4 +167,7 @@ class HubAdapter implements Hub {
166167
String transaction,
167168
) =>
168169
Sentry.currentHub.setSpanContext(throwable, span, transaction);
170+
171+
@override
172+
Scope get scope => Sentry.currentHub.scope;
169173
}

dart/lib/src/noop_hub.dart

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'package:meta/meta.dart';
55
import 'hint.dart';
66
import 'hub.dart';
77
import 'protocol.dart';
8+
import 'scope.dart';
89
import 'sentry_client.dart';
910
import 'sentry_options.dart';
1011
import 'sentry_user_feedback.dart';
@@ -118,4 +119,7 @@ class NoOpHub implements Hub {
118119

119120
@override
120121
void setSpanContext(throwable, ISentrySpan span, String transaction) {}
122+
123+
@override
124+
Scope get scope => Scope(_options);
121125
}

dart/lib/src/propagation_context.dart

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import 'package:meta/meta.dart';
2+
import 'protocol.dart';
3+
import 'sentry_baggage.dart';
4+
5+
@internal
6+
class PropagationContext {
7+
late SentryId traceId = SentryId.newId();
8+
late SpanId spanId = SpanId.newId();
9+
SentryBaggage? baggage;
10+
11+
SentryTraceHeader toSentryTrace() => SentryTraceHeader(traceId, spanId);
12+
}

dart/lib/src/protocol/sentry_trace_context.dart

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import 'package:meta/meta.dart';
22

3+
import '../../sentry.dart';
4+
import '../propagation_context.dart';
35
import '../protocol.dart';
46

57
@immutable
@@ -87,4 +89,14 @@ class SentryTraceContext {
8789
this.origin,
8890
}) : traceId = traceId ?? SentryId.newId(),
8991
spanId = spanId ?? SpanId.newId();
92+
93+
@internal
94+
factory SentryTraceContext.fromPropagationContext(
95+
PropagationContext propagationContext) {
96+
return SentryTraceContext(
97+
traceId: propagationContext.traceId,
98+
spanId: propagationContext.spanId,
99+
operation: 'default',
100+
);
101+
}
90102
}

dart/lib/src/scope.dart

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import 'dart:async';
22
import 'dart:collection';
33

4+
import 'package:meta/meta.dart';
5+
46
import 'event_processor.dart';
57
import 'hint.dart';
8+
import 'propagation_context.dart';
69
import 'protocol.dart';
710
import 'scope_observer.dart';
811
import 'sentry_attachment/sentry_attachment.dart';
@@ -39,6 +42,9 @@ class Scope {
3942
/// Returns active transaction or null if there is no active transaction.
4043
ISentrySpan? span;
4144

45+
@internal
46+
PropagationContext propagationContext = PropagationContext();
47+
4248
SentryUser? _user;
4349

4450
/// Get the current user.
@@ -311,10 +317,15 @@ class Scope {
311317
});
312318

313319
final newSpan = span;
314-
if (event.contexts.trace == null && newSpan != null) {
315-
event.contexts.trace = newSpan.context.toTraceContext(
316-
sampled: newSpan.samplingDecision?.sampled,
317-
);
320+
if (event.contexts.trace == null) {
321+
if (newSpan != null) {
322+
event.contexts.trace = newSpan.context.toTraceContext(
323+
sampled: newSpan.samplingDecision?.sampled,
324+
);
325+
} else {
326+
event.contexts.trace =
327+
SentryTraceContext.fromPropagationContext(propagationContext);
328+
}
318329
}
319330

320331
SentryEvent? processedEvent = event;

dart/lib/src/sentry_baggage.dart

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import 'protocol/sentry_level.dart';
1+
import 'package:meta/meta.dart';
2+
import 'scope.dart';
3+
import 'protocol.dart';
4+
25
import 'sentry_options.dart';
36

47
class SentryBaggage {
@@ -87,6 +90,27 @@ class SentryBaggage {
8790
return SentryBaggage(keyValues, logger: logger);
8891
}
8992

93+
@internal
94+
setValuesFromScope(Scope scope, SentryOptions options) {
95+
final propagationContext = scope.propagationContext;
96+
setTraceId(propagationContext.traceId.toString());
97+
if (options.dsn != null) {
98+
setPublicKey(Dsn.parse(options.dsn!).publicKey);
99+
}
100+
if (options.release != null) {
101+
setRelease(options.release!);
102+
}
103+
if (options.environment != null) {
104+
setEnvironment(options.environment!);
105+
}
106+
if (scope.user?.id != null) {
107+
setUserId(scope.user!.id!);
108+
}
109+
if (scope.user?.segment != null) {
110+
setUserSegment(scope.user!.segment!);
111+
}
112+
}
113+
90114
static Map<String, String> _extractKeyValuesFromBaggageString(
91115
String headerValue, {
92116
SentryLogger? logger,

dart/lib/src/sentry_client.dart

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'dart:async';
22
import 'dart:math';
33
import 'package:meta/meta.dart';
4+
import 'sentry_baggage.dart';
45
import 'sentry_attachment/sentry_attachment.dart';
56

67
import 'event_processor.dart';
@@ -122,11 +123,24 @@ class SentryClient {
122123
attachments.add(viewHierarchy);
123124
}
124125

126+
var traceContext = scope?.span?.traceContext();
127+
if (traceContext == null) {
128+
if (scope?.propagationContext.baggage == null) {
129+
scope?.propagationContext.baggage =
130+
SentryBaggage({}, logger: _options.logger);
131+
scope?.propagationContext.baggage?.setValuesFromScope(scope, _options);
132+
}
133+
if (scope != null) {
134+
traceContext = SentryTraceContextHeader.fromBaggage(
135+
scope.propagationContext.baggage!);
136+
}
137+
}
138+
125139
final envelope = SentryEnvelope.fromEvent(
126140
preparedEvent,
127141
_options.sdk,
128142
dsn: _options.dsn,
129-
traceContext: scope?.span?.traceContext(),
143+
traceContext: traceContext,
130144
attachments: attachments.isNotEmpty ? attachments : null,
131145
);
132146

dart/lib/src/sentry_trace_context_header.dart

+9
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,13 @@ class SentryTraceContextHeader {
7979

8080
return baggage;
8181
}
82+
83+
factory SentryTraceContextHeader.fromBaggage(SentryBaggage baggage) {
84+
return SentryTraceContextHeader(
85+
SentryId.fromId(baggage.get('sentry-trace_id').toString()),
86+
baggage.get('sentry-public_key').toString(),
87+
release: baggage.get('sentry-release'),
88+
environment: baggage.get('sentry-environment'),
89+
);
90+
}
8291
}

0 commit comments

Comments
 (0)