Skip to content
Merged
Show file tree
Hide file tree
Changes from 70 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
1a4b78b
Add TelemetryProcessor for span and log buffering
buenaflor Jan 14, 2026
3897122
Remove SpanV2 and TraceLifecycle dependencies
buenaflor Jan 14, 2026
2c617bb
Remove span-related tests from sentry_client_test
buenaflor Jan 14, 2026
6ef8c3c
Remove span-related processor tests
buenaflor Jan 14, 2026
3ca4c08
Remove span import from Flutter mocks
buenaflor Jan 14, 2026
9b34042
Fix wiring up
buenaflor Jan 14, 2026
e0b564c
Update
buenaflor Jan 14, 2026
6da49c8
Update
buenaflor Jan 14, 2026
1b97198
Update CHANGELOG
buenaflor Jan 14, 2026
82a4374
Update
buenaflor Jan 14, 2026
1a48756
Update
buenaflor Jan 14, 2026
1081ca3
Update
buenaflor Jan 14, 2026
ffd9fc7
Update
buenaflor Jan 15, 2026
b56a272
Update
buenaflor Jan 15, 2026
586ae3d
Update
buenaflor Jan 15, 2026
26d0577
Merge branch 'main' into feat/metrics
buenaflor Jan 15, 2026
1f7ba8f
Merge branch 'main' into feat/metrics
buenaflor Jan 17, 2026
33f991f
feat: integrate telemetry metrics into Sentry options and core functi…
buenaflor Jan 17, 2026
b6bff0d
feat: implement SentryMetrics with Default and NoOp implementations
buenaflor Jan 17, 2026
95fb48d
Merge branch 'main' into feat/metrics
buenaflor Jan 19, 2026
435917d
feat: enhance telemetry metrics with MetricCapturePipeline and defaul…
buenaflor Jan 19, 2026
07b5051
Add more tests
buenaflor Jan 19, 2026
875ca84
feat: enhance metric capturing and logging in MetricCapturePipeline a…
buenaflor Jan 20, 2026
b5eee19
feat: enhance Sentry attribute formatting and replay integration
buenaflor Jan 20, 2026
61bb4bc
feat: include unit in DefaultSentryMetrics and update tests
buenaflor Jan 20, 2026
5b55d0a
fix: update metric logging to use processed metrics
buenaflor Jan 20, 2026
264f72b
Fix missing spec
buenaflor Jan 20, 2026
f49e371
Update CHANGELOG
buenaflor Jan 20, 2026
5cfeba6
Add examples
buenaflor Jan 20, 2026
ee01dbb
Merge branch 'main' into feat/metrics
buenaflor Jan 20, 2026
fbfcc74
Update doc
buenaflor Jan 20, 2026
c7ca90c
Update doc
buenaflor Jan 20, 2026
7f3b491
Update
buenaflor Jan 20, 2026
c4221aa
Update
buenaflor Jan 20, 2026
2a553a2
Update docs
buenaflor Jan 20, 2026
ba9930c
Add support for 'trace_metric' category in RateLimitParser and corres…
buenaflor Jan 20, 2026
e3e55a5
Update comments
buenaflor Jan 20, 2026
e92efaf
Add SentryMetricUnit constants
buenaflor Jan 20, 2026
d530afc
Fix compilation
buenaflor Jan 20, 2026
eb2cad9
Fix analyze
buenaflor Jan 20, 2026
3282f7a
Update
buenaflor Jan 20, 2026
71e67b7
Refactor SentryMetrics handling in SentryOptions to use a private var…
buenaflor Jan 20, 2026
cd836b5
Refactor SentryMetrics in SentryOptions to use a late variable for im…
buenaflor Jan 20, 2026
2648213
Add close
buenaflor Jan 20, 2026
98f48fd
Add close test
buenaflor Jan 20, 2026
756de8a
Refactor logging integration by replacing LogsEnricherIntegration wit…
buenaflor Jan 20, 2026
1f2dc29
Enhance logging tests by adding timestamp verification and attribute …
buenaflor Jan 20, 2026
25b0de7
Refactor SentryLog constructor to require traceId and adjust spanId i…
buenaflor Jan 20, 2026
747259d
Update SentryMetrics initialization in SentryOptions to use a constan…
buenaflor Jan 20, 2026
98bdb7a
Merge branch 'feat/metrics' into ref/log-capture-pipeline
buenaflor Jan 20, 2026
0919930
Refactor logger tests to improve readability by formatting logger.inf…
buenaflor Jan 20, 2026
5055a7e
Remove deprecated test for LogsEnricherIntegration from load_contexts…
buenaflor Jan 20, 2026
d253868
Remove unused import for LogsEnricherIntegration in load_contexts_int…
buenaflor Jan 20, 2026
6cc1513
Use unawaited
buenaflor Jan 21, 2026
f88caed
Merge branch 'feat/metrics' into ref/log-capture-pipeline
buenaflor Jan 21, 2026
f83fc08
Update comment
buenaflor Jan 21, 2026
f8bb409
Update test
buenaflor Jan 21, 2026
b4f5115
Update test
buenaflor Jan 21, 2026
7991bea
Update test
buenaflor Jan 21, 2026
ecc965e
Merge branch 'feat/metrics' into ref/log-capture-pipeline
buenaflor Jan 21, 2026
bbf6e40
Merge branch 'ref/log-capture-pipeline' of github.com:getsentry/sentr…
buenaflor Jan 21, 2026
8534d99
Remove logs enricher
buenaflor Jan 21, 2026
a2674f5
Update tests
buenaflor Jan 21, 2026
6a658cb
Update tests
buenaflor Jan 21, 2026
a786f9f
Update tests
buenaflor Jan 21, 2026
e25645b
Update
buenaflor Jan 21, 2026
b70eee8
Update
buenaflor Jan 21, 2026
7af466a
Update
buenaflor Jan 21, 2026
005a601
Update mocks
buenaflor Jan 21, 2026
647b792
Fix cursor review
buenaflor Jan 21, 2026
4c73da9
Update
buenaflor Jan 21, 2026
5a6123a
Update
buenaflor Jan 21, 2026
86220bd
Update
buenaflor Jan 21, 2026
7b61969
Update
buenaflor Jan 21, 2026
8c29471
Update
buenaflor Jan 21, 2026
58a9bf1
Update
buenaflor Jan 21, 2026
6bb8e65
Update
buenaflor Jan 21, 2026
d74fbc8
Merge branch 'feat/metrics' into ref/log-capture-pipeline
buenaflor Jan 21, 2026
7dc6a2b
Update
buenaflor Jan 21, 2026
813c902
Update
buenaflor Jan 22, 2026
0980050
Merge branch 'feat/metrics' into ref/log-capture-pipeline
buenaflor Jan 22, 2026
e554957
Use export barrel file
buenaflor Jan 22, 2026
e3b882b
Fix analyzer
buenaflor Jan 22, 2026
0d6b55d
Fix review
buenaflor Jan 22, 2026
b1a8690
Fix asserts
buenaflor Jan 22, 2026
b12493b
Merge branch 'feat/metrics' into ref/log-capture-pipeline
buenaflor Jan 22, 2026
87fd7a9
Merge branch 'main' into ref/log-capture-pipeline
buenaflor Jan 22, 2026
d2290ea
Fix analyze
buenaflor Jan 22, 2026
4fbe493
Update CHANGELOG
buenaflor Jan 22, 2026
36e26c0
Update test
buenaflor Jan 22, 2026
4e9efad
Update test
buenaflor Jan 22, 2026
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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

## Unreleased

### Features

- Trace connected metrics ([#3450](https://github.com/getsentry/sentry-dart/pull/3450))
- This feature is enabled by default.
- To send metrics use the following APIs:
- `Sentry.metrics.gauge(...)`
- `Sentry.metrics.count(...)`
- `Sentry.metrics.distribution(...)`

### Dependencies

- Bump Android SDK from v8.28.0 to v8.30.0 ([#3451](https://github.com/getsentry/sentry-dart/pull/3451))
Expand Down
3 changes: 2 additions & 1 deletion packages/dart/lib/sentry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export 'src/utils/tracing_utils.dart';
export 'src/utils/url_details.dart';
// ignore: invalid_export_of_internal_element
export 'src/utils/breadcrumb_log_level.dart';
export 'src/sentry_logger.dart';
Comment thread
buenaflor marked this conversation as resolved.
export 'src/telemetry/log/logger.dart';
export 'src/telemetry/metric/metrics.dart';
// ignore: invalid_export_of_internal_element
export 'src/utils/internal_logger.dart' show SentryInternalLogger;
2 changes: 2 additions & 0 deletions packages/dart/lib/src/client_reports/discarded_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ extension _DataCategoryExtension on DataCategory {
return 'feedback';
case DataCategory.metricBucket:
return 'metric_bucket';
case DataCategory.metric:
return 'trace_metric';
}
}
}
77 changes: 77 additions & 0 deletions packages/dart/lib/src/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,80 @@ class SentrySpanDescriptions {
static String dbOpen({required String dbName}) => 'Open database $dbName';
static String dbClose({required String dbName}) => 'Close database $dbName';
}

/// Semantic attributes for telemetry.
///
/// Not all attributes apply to every telemetry type.
///
/// See https://getsentry.github.io/sentry-conventions/generated/attributes/
/// for more details.
@internal
abstract class SemanticAttributesConstants {
SemanticAttributesConstants._();

/// The source of a span, also referred to as transaction source.
///
/// Known values are: `'custom'`, `'url'`, `'route'`, `'component'`, `'view'`, `'task'`.
static const sentrySpanSource = 'sentry.span.source';

/// Attributes that holds the sample rate that was locally applied to a span.
/// If this attribute is not defined, it means that the span inherited a sampling decision.
///
/// NOTE: Is only defined on root spans.
static const sentrySampleRate = 'sentry.sample_rate';

/// Use this attribute to represent the origin of a span.
static const sentryOrigin = 'sentry.origin';

/// The release version of the application
static const sentryRelease = 'sentry.release';

/// The environment name (e.g., "production", "staging", "development")
static const sentryEnvironment = 'sentry.environment';

/// The segment name (e.g., "GET /users")
static const sentrySegmentName = 'sentry.segment.name';

/// The span id of the segment that this span belongs to.
static const sentrySegmentId = 'sentry.segment.id';

/// The name of the Sentry SDK (e.g., "sentry.dart.flutter")
static const sentrySdkName = 'sentry.sdk.name';

/// The version of the Sentry SDK
static const sentrySdkVersion = 'sentry.sdk.version';

/// The replay ID.
static const sentryReplayId = 'sentry.replay_id';

/// Whether the replay is buffering (onErrorSampleRate).
static const sentryInternalReplayIsBuffering =
'sentry._internal.replay_is_buffering';

/// The user ID (gated by `sendDefaultPii`).
static const userId = 'user.id';

/// The user email (gated by `sendDefaultPii`).
static const userEmail = 'user.email';

/// The user IP address (gated by `sendDefaultPii`).
static const userIpAddress = 'user.ip_address';

/// The user username (gated by `sendDefaultPii`).
static const userName = 'user.name';

/// The operating system name.
static const osName = 'os.name';

/// The operating system version.
static const osVersion = 'os.version';

/// The device brand (e.g., "Apple", "Samsung").
static const deviceBrand = 'device.brand';

/// The device model identifier (e.g., "iPhone14,2").
static const deviceModel = 'device.model';

/// The device family (e.g., "iOS", "Android").
static const deviceFamily = 'device.family';
}
33 changes: 33 additions & 0 deletions packages/dart/lib/src/hub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'client_reports/discard_reason.dart';
import 'profiling.dart';
import 'sentry_tracer.dart';
import 'sentry_traces_sampler.dart';
import 'telemetry/metric/metric.dart';
import 'transport/data_category.dart';

/// Configures the scope through the callback.
Expand Down Expand Up @@ -317,6 +318,38 @@ class Hub {
}
}

Future<void> captureMetric(SentryMetric metric) async {
if (!_isEnabled) {
_options.log(
SentryLevel.warning,
"Instance is disabled and this 'captureMetric' call is a no-op.",
);
} else {
final item = _peek();
late Scope scope;
final s = _cloneAndRunWithScope(item.scope, null);
if (s is Future<Scope>) {
scope = await s;
} else {
scope = s;
}

try {
await item.client.captureMetric(
metric,
scope: scope,
);
} catch (exception, stacktrace) {
_options.log(
SentryLevel.error,
'Error while capturing metric',
exception: exception,
stackTrace: stacktrace,
);
}
}
}

FutureOr<Scope> _cloneAndRunWithScope(
Scope scope, ScopeCallback? withScope) async {
if (withScope != null) {
Expand Down
8 changes: 7 additions & 1 deletion packages/dart/lib/src/hub_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import 'sentry.dart';
import 'sentry_client.dart';
import 'sentry_options.dart';
import 'telemetry/metric/metric.dart';
import 'tracing.dart';

/// Hub adapter to make Integrations testable
Expand Down Expand Up @@ -198,7 +199,12 @@
);

@override
FutureOr<void> captureLog(SentryLog log) => Sentry.currentHub.captureLog(log);
FutureOr<void> captureLog(SentryLog log, {Scope? scope}) =>
Sentry.currentHub.captureLog(log, scope: scope);

Check failure on line 203 in packages/dart/lib/src/hub_adapter.dart

View workflow job for this annotation

GitHub Actions / analyze / analyze

The named parameter 'scope' isn't defined.

Try correcting the name to an existing named parameter's name, or defining a named parameter with the name 'scope'. See https://dart.dev/diagnostics/undefined_named_parameter to learn more about this problem.

@override
Future<void> captureMetric(SentryMetric metric) =>
Sentry.currentHub.captureMetric(metric);

@override
void setAttributes(Map<String, SentryAttribute> attributes) =>
Expand Down
37 changes: 0 additions & 37 deletions packages/dart/lib/src/logs_enricher_integration.dart

This file was deleted.

6 changes: 5 additions & 1 deletion packages/dart/lib/src/noop_hub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'protocol/sentry_feedback.dart';
import 'scope.dart';
import 'sentry_client.dart';
import 'sentry_options.dart';
import 'telemetry/metric/metric.dart';
import 'tracing.dart';

class NoOpHub implements Hub {
Expand Down Expand Up @@ -95,7 +96,10 @@ class NoOpHub implements Hub {
SentryId.empty();

@override
FutureOr<void> captureLog(SentryLog log) async {}
FutureOr<void> captureLog(SentryLog log, {Scope? scope}) async {}

@override
Future<void> captureMetric(SentryMetric metric) async {}

@override
ISentrySpan startTransaction(
Expand Down
4 changes: 4 additions & 0 deletions packages/dart/lib/src/noop_sentry_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'scope.dart';
import 'sentry_client.dart';
import 'sentry_envelope.dart';
import 'sentry_trace_context_header.dart';
import 'telemetry/metric/metric.dart';

class NoOpSentryClient implements SentryClient {
NoOpSentryClient._();
Expand Down Expand Up @@ -69,4 +70,7 @@ class NoOpSentryClient implements SentryClient {

@override
FutureOr<void> captureLog(SentryLog log, {Scope? scope}) async {}

@override
Future<void> captureMetric(SentryMetric metric, {Scope? scope}) async {}
}
4 changes: 2 additions & 2 deletions packages/dart/lib/src/protocol.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ export 'protocol/span_status.dart';
export 'sentry_event_like.dart';
export 'protocol/sentry_feature_flag.dart';
export 'protocol/sentry_feature_flags.dart';
export 'protocol/sentry_log.dart';
export 'protocol/sentry_log_level.dart';
export 'telemetry/log/log.dart';
export 'telemetry/log/log_level.dart';
export 'protocol/sentry_attribute.dart';
12 changes: 10 additions & 2 deletions packages/dart/lib/src/sdk_lifecycle_hooks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:async';
import 'package:meta/meta.dart';

import '../sentry.dart';
import 'telemetry/metric/metric.dart';

@internal
typedef SdkLifecycleCallback<T extends SdkLifecycleEvent> = FutureOr<void>
Expand Down Expand Up @@ -67,8 +68,8 @@ class SdkLifecycleRegistry {
}

@internal
class OnBeforeCaptureLog extends SdkLifecycleEvent {
OnBeforeCaptureLog(this.log);
class OnProcessLog extends SdkLifecycleEvent {
OnProcessLog(this.log);

final SentryLog log;
}
Expand Down Expand Up @@ -96,3 +97,10 @@ class OnSpanFinish extends SdkLifecycleEvent {

final ISentrySpan span;
}

@internal
class OnProcessMetric extends SdkLifecycleEvent {
final SentryMetric metric;

OnProcessMetric(this.metric);
}
11 changes: 8 additions & 3 deletions packages/dart/lib/src/sentry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ import 'sentry_attachment/sentry_attachment.dart';
import 'sentry_client.dart';
import 'sentry_options.dart';
import 'sentry_run_zoned_guarded.dart';
import 'telemetry/metric/metrics_setup_integration.dart';
import 'telemetry/metric/metrics.dart';
import 'telemetry/processing/processor_integration.dart';
import 'tracing.dart';
import 'transport/data_category.dart';
import 'transport/task_queue.dart';
import 'feature_flags_integration.dart';
import 'sentry_logger.dart';
import 'logs_enricher_integration.dart';
import 'telemetry/log/logger.dart';
import 'telemetry/log/log_setup_integration.dart';

/// Configuration options callback
typedef OptionsConfiguration = FutureOr<void> Function(SentryOptions);
Expand Down Expand Up @@ -110,8 +112,9 @@ class Sentry {
options.addIntegration(LoadDartDebugImagesIntegration());
}

options.addIntegration(MetricsSetupIntegration());
options.addIntegration(LogSetupIntegration());
options.addIntegration(FeatureFlagsIntegration());
options.addIntegration(LogsEnricherIntegration());
options.addIntegration(InMemoryTelemetryProcessorIntegration());

options.addEventProcessor(EnricherEventProcessor(options));
Expand Down Expand Up @@ -450,4 +453,6 @@ class Sentry {
);

static SentryLogger get logger => currentHub.options.logger;

static SentryMetrics get metrics => currentHub.options.metrics;
}
Loading
Loading