diff --git a/CHANGELOG.md b/CHANGELOG.md index 60b7fb7029..15b3a78a8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Features +- Add `sentry.origin` to logs created by `LoggingIntegration` ([#3153](https://github.com/getsentry/sentry-dart/pull/3153)) - Tag all spans with thread info on non-web platforms ([#3101](https://github.com/getsentry/sentry-dart/pull/3101), [#3144](https://github.com/getsentry/sentry-dart/pull/3144)) ## 9.7.0-beta.1 diff --git a/packages/logging/lib/src/logging_integration.dart b/packages/logging/lib/src/logging_integration.dart index 49630c6651..e4bb44f550 100644 --- a/packages/logging/lib/src/logging_integration.dart +++ b/packages/logging/lib/src/logging_integration.dart @@ -1,5 +1,6 @@ import 'dart:async'; +import 'package:meta/meta.dart'; import 'package:logging/logging.dart'; import 'package:sentry/sentry.dart'; @@ -49,6 +50,10 @@ class LoggingIntegration implements Integration { late Hub _hub; late SentryOptions _options; + @internal + // ignore: public_member_api_docs + static const origin = 'auto.log.logging'; + @override void call(Hub hub, SentryOptions options) { _hub = hub; @@ -98,6 +103,7 @@ class LoggingIntegration implements Integration { 'loggerName': SentryLogAttribute.string(record.loggerName), 'sequenceNumber': SentryLogAttribute.int(record.sequenceNumber), 'time': SentryLogAttribute.int(record.time.millisecondsSinceEpoch), + 'sentry.origin': SentryLogAttribute.string(origin), }; // Map log levels based on value ranges diff --git a/packages/logging/pubspec.yaml b/packages/logging/pubspec.yaml index 8c5b5929e0..0cfdcf0da0 100644 --- a/packages/logging/pubspec.yaml +++ b/packages/logging/pubspec.yaml @@ -20,10 +20,10 @@ platforms: dependencies: logging: ^1.0.0 sentry: 9.7.0-beta.1 + meta: ^1.17.0 dev_dependencies: lints: '>=2.0.0' test: ^1.21.1 yaml: ^3.1.0 # needed for version match (code and pubspec) coverage: ^1.3.0 - meta: ^1.3.0 diff --git a/packages/logging/test/logging_integration_test.dart b/packages/logging/test/logging_integration_test.dart index 8332965505..bc42f37d32 100644 --- a/packages/logging/test/logging_integration_test.dart +++ b/packages/logging/test/logging_integration_test.dart @@ -330,6 +330,10 @@ void main() { expect(basicAttributes['loggerName']?.value, 'TestLogger'); expect(basicAttributes['sequenceNumber']?.value, isA()); expect(basicAttributes['time']?.value, isA()); + expect( + basicAttributes['sentry.origin']?.value, + LoggingIntegration.origin, + ); expect(basicAttributes.containsKey('error'), false); expect(basicAttributes.containsKey('stackTrace'), false);