Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
696ba61
todo
vaind Aug 17, 2023
4f85144
feat: expose cocoa profiling via method channels
vaind Aug 18, 2023
de6f244
feat: prepare profiler interfaces and hub integration
vaind Aug 22, 2023
7c73348
fix CI
vaind Aug 23, 2023
42af467
integrate dart & cocoa profiling
vaind Aug 24, 2023
162c2ba
fix API breakage
vaind Aug 26, 2023
31a92e5
fix tests
vaind Aug 28, 2023
b12978e
dart format
vaind Aug 28, 2023
3582adf
ci: fix pana
vaind Aug 29, 2023
1d74bac
update tests
vaind Aug 29, 2023
8d23d3f
analysis issues
vaind Aug 29, 2023
c9be10c
update to the latest cocoa SDK API
vaind Sep 5, 2023
32c6e5d
linter issue
vaind Sep 7, 2023
0ae79d4
fix import
vaind Sep 12, 2023
df9fb5b
refactor: SentryNative integration
vaind Sep 12, 2023
0fb649c
update cocoa native binding to use ffi startProfiler()
vaind Sep 12, 2023
dccb853
tmp: findPrimeNumber in example
vaind Sep 12, 2023
6119812
fix: make FFI dependency conditional (web/vm)
vaind Sep 18, 2023
5218efa
exclude generated binding code from code coverage
vaind Sep 18, 2023
4c8f2bf
test: profiler integration test
vaind Sep 18, 2023
e0bb3ab
workaround for the integration test issue
vaind Sep 18, 2023
8a4fed7
chore: formatting
vaind Sep 19, 2023
2d29cb6
Merge branch 'main' into feat/profiling
vaind Sep 19, 2023
4748a00
Merge branch 'main' into feat/profiling
vaind Sep 20, 2023
39d1187
chore: remove obsolete code
vaind Sep 25, 2023
50994d4
Update flutter/example/lib/main.dart
vaind Oct 3, 2023
6e599fb
renames
vaind Oct 3, 2023
e7582d7
Breadcrumbs for file I/O operations (#1649)
denrase Sep 25, 2023
36b052e
ci: don't run CI on markdown updates (#1651)
vaind Sep 25, 2023
813b947
fixup mock names after renames
vaind Oct 3, 2023
ce59509
Merge branch 'main' into feat/profiling
stefanosiano Oct 4, 2023
e13e7de
more renames (Sentry prefix)
vaind Oct 4, 2023
8e6bd13
chore: update changelog
vaind Oct 4, 2023
227b701
Merge branch 'main' into feat/profiling
vaind Oct 26, 2023
defdfa6
don't inline findPrimeNumber profiler-test function
vaind Oct 27, 2023
4074f01
fixup changelog
vaind Oct 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix API breakage
  • Loading branch information
vaind committed Sep 18, 2023
commit 162c2ba8556e7cf48ac084e9cfa667abaaf28ff1
2 changes: 0 additions & 2 deletions dart/lib/src/hub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,6 @@ class Hub {
Future<SentryId> captureTransaction(
SentryTransaction transaction, {
SentryTraceContextHeader? traceContext,
ProfileInfo? profileInfo,
}) async {
var sentryId = SentryId.empty();

Expand Down Expand Up @@ -541,7 +540,6 @@ class Hub {
transaction,
scope: item.scope,
traceContext: traceContext,
profileInfo: profileInfo,
);
} catch (exception, stackTrace) {
_options.logger(
Expand Down
3 changes: 1 addition & 2 deletions dart/lib/src/hub_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ class HubAdapter implements Hub {
@override
Future<SentryId> captureTransaction(
SentryTransaction transaction, {
SentryTraceContextHeader? traceContext,
ProfileInfo? profileInfo,
SentryTraceContextHeader? traceContext
}) =>
Sentry.currentHub.captureTransaction(
transaction,
Expand Down
1 change: 0 additions & 1 deletion dart/lib/src/noop_hub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ class NoOpHub implements Hub {
Future<SentryId> captureTransaction(
SentryTransaction transaction, {
SentryTraceContextHeader? traceContext,
ProfileInfo? profileInfo,
}) async =>
SentryId.empty();

Expand Down
30 changes: 15 additions & 15 deletions dart/lib/src/protocol/sentry_transaction.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:meta/meta.dart';

import '../profiling.dart';
import '../protocol.dart';
import '../sentry_tracer.dart';
import '../utils.dart';
Expand All @@ -11,12 +10,13 @@ class SentryTransaction extends SentryEvent {
late final DateTime startTimestamp;
static const String _type = 'transaction';
late final List<SentrySpan> spans;
final SentryTracer _tracer;
@internal
final SentryTracer tracer;
late final Map<String, SentryMeasurement> measurements;
late final SentryTransactionInfo? transactionInfo;

SentryTransaction(
this._tracer, {
this.tracer, {
SentryId? eventId,
DateTime? timestamp,
String? platform,
Expand All @@ -40,37 +40,37 @@ class SentryTransaction extends SentryEvent {
SentryTransactionInfo? transactionInfo,
}) : super(
eventId: eventId,
timestamp: timestamp ?? _tracer.endTimestamp,
timestamp: timestamp ?? tracer.endTimestamp,
platform: platform,
serverName: serverName,
release: release,
dist: dist,
environment: environment,
transaction: transaction ?? _tracer.name,
throwable: throwable ?? _tracer.throwable,
tags: tags ?? _tracer.tags,
transaction: transaction ?? tracer.name,
throwable: throwable ?? tracer.throwable,
tags: tags ?? tracer.tags,
// ignore: deprecated_member_use_from_same_package
extra: extra ?? _tracer.data,
extra: extra ?? tracer.data,
user: user,
contexts: contexts,
breadcrumbs: breadcrumbs,
sdk: sdk,
request: request,
type: _type,
) {
startTimestamp = _tracer.startTimestamp;
startTimestamp = tracer.startTimestamp;

final spanContext = _tracer.context;
spans = _tracer.children;
final spanContext = tracer.context;
spans = tracer.children;
this.measurements = measurements ?? {};

this.contexts.trace = spanContext.toTraceContext(
sampled: _tracer.samplingDecision?.sampled,
status: _tracer.status,
sampled: tracer.samplingDecision?.sampled,
status: tracer.status,
);

this.transactionInfo = transactionInfo ??
SentryTransactionInfo(_tracer.transactionNameSource.name);
SentryTransactionInfo(tracer.transactionNameSource.name);
}

@override
Expand Down Expand Up @@ -137,7 +137,7 @@ class SentryTransaction extends SentryEvent {
SentryTransactionInfo? transactionInfo,
}) =>
SentryTransaction(
_tracer,
tracer,
eventId: eventId ?? this.eventId,
timestamp: timestamp ?? this.timestamp,
platform: platform ?? this.platform,
Expand Down
4 changes: 2 additions & 2 deletions dart/lib/src/sentry_client.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:async';
import 'dart:math';
import 'package:meta/meta.dart';
import 'profiling.dart';
import 'sentry_baggage.dart';
import 'sentry_attachment/sentry_attachment.dart';

Expand Down Expand Up @@ -299,7 +298,6 @@ class SentryClient {
SentryTransaction transaction, {
Scope? scope,
SentryTraceContextHeader? traceContext,
ProfileInfo? profileInfo,
}) async {
SentryTransaction? preparedTransaction =
_prepareEvent(transaction) as SentryTransaction;
Expand Down Expand Up @@ -347,6 +345,8 @@ class SentryClient {
traceContext: traceContext,
attachments: attachments,
);

final profileInfo = preparedTransaction.tracer.profileInfo;
if (profileInfo != null) {
envelope.items.add(profileInfo.asEnvelopeItem());
}
Expand Down
1 change: 0 additions & 1 deletion dart/lib/src/sentry_envelope_item.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:async';
import 'dart:convert';
import 'package:meta/meta.dart';

import 'client_reports/client_report.dart';
import 'protocol.dart';
Expand Down
8 changes: 6 additions & 2 deletions dart/lib/src/sentry_tracer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ class SentryTracer extends ISentrySpan {

SentryTraceContextHeader? _sentryTraceContextHeader;

// Profiler attached to this tracer.
late final Profiler? profiler;

// Resulting profile, after it has been collected. This is later used by
// SentryClient to attach as an envelope item when sending the transaction.
ProfileInfo? profileInfo;

/// If [waitForChildren] is true, this transaction will not finish until all
/// its children are finished.
///
Expand Down Expand Up @@ -141,14 +146,13 @@ class SentryTracer extends ISentrySpan {
final transaction = SentryTransaction(this);
transaction.measurements.addAll(_measurements);

final profileInfo = (status == null || status == SpanStatus.ok())
profileInfo = (status == null || status == SpanStatus.ok())
? await profiler?.finishFor(transaction)
: null;

await _hub.captureTransaction(
transaction,
traceContext: traceContext(),
profileInfo: profileInfo,
);
} finally {
profiler?.dispose();
Expand Down
1 change: 0 additions & 1 deletion dart/test/hub_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:collection/collection.dart';
import 'package:mockito/mockito.dart';
import 'package:sentry/sentry.dart';
import 'package:sentry/src/client_reports/discard_reason.dart';
import 'package:sentry/src/profiling.dart';
import 'package:sentry/src/sentry_tracer.dart';
import 'package:sentry/src/transport/data_category.dart';
import 'package:test/test.dart';
Expand Down
2 changes: 0 additions & 2 deletions dart/test/mocks/mock_hub.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:meta/meta.dart';
import 'package:sentry/sentry.dart';
import 'package:sentry/src/profiling.dart';

import '../mocks.dart';
import 'mock_sentry_client.dart';
Expand Down Expand Up @@ -111,7 +110,6 @@ class MockHub with NoSuchMethodProvider implements Hub {
Future<SentryId> captureTransaction(
SentryTransaction transaction, {
SentryTraceContextHeader? traceContext,
ProfileInfo? profileInfo,
}) async {
captureTransactionCalls
.add(CaptureTransactionCall(transaction, traceContext));
Expand Down
2 changes: 0 additions & 2 deletions dart/test/mocks/mock_sentry_client.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:sentry/sentry.dart';
import 'package:sentry/src/profiling.dart';

import 'no_such_method_provider.dart';

Expand Down Expand Up @@ -85,7 +84,6 @@ class MockSentryClient with NoSuchMethodProvider implements SentryClient {
SentryTransaction transaction, {
Scope? scope,
SentryTraceContextHeader? traceContext,
ProfileInfo? profileInfo,
}) async {
captureTransactionCalls
.add(CaptureTransactionCall(transaction, traceContext));
Expand Down
6 changes: 4 additions & 2 deletions flutter/test/mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ class TestMockSentryNative implements SentryNative {
}

@override
Future<dynamic> collectProfile(SentryId traceId, int startTimeNs) {
Future<Map<String, dynamic>?> collectProfile(
SentryId traceId, int startTimeNs) {
numberOfCollectProfileCalls++;
return Future.value(null);
}
Expand Down Expand Up @@ -362,7 +363,8 @@ class MockNativeChannel implements SentryNativeChannel {
}

@override
Future<dynamic> collectProfile(SentryId traceId, int startTimeNs) {
Future<Map<String, dynamic>?> collectProfile(
SentryId traceId, int startTimeNs) {
numberOfCollectProfileCalls++;
return Future.value(null);
}
Expand Down