Skip to content

Commit 8d8099c

Browse files
authored
feat(logs): add origin to logs created by LoggingIntegration (#3153)
* Update * Update * Update * Update * Update * Update * Update * Update
1 parent 267cbb7 commit 8d8099c

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Features
66

7+
- Add `sentry.origin` to logs created by `LoggingIntegration` ([#3153](https://github.com/getsentry/sentry-dart/pull/3153))
78
- 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))
89

910
## 9.7.0-beta.1

packages/logging/lib/src/logging_integration.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'dart:async';
22

3+
import 'package:meta/meta.dart';
34
import 'package:logging/logging.dart';
45
import 'package:sentry/sentry.dart';
56

@@ -49,6 +50,10 @@ class LoggingIntegration implements Integration<SentryOptions> {
4950
late Hub _hub;
5051
late SentryOptions _options;
5152

53+
@internal
54+
// ignore: public_member_api_docs
55+
static const origin = 'auto.log.logging';
56+
5257
@override
5358
void call(Hub hub, SentryOptions options) {
5459
_hub = hub;
@@ -98,6 +103,7 @@ class LoggingIntegration implements Integration<SentryOptions> {
98103
'loggerName': SentryLogAttribute.string(record.loggerName),
99104
'sequenceNumber': SentryLogAttribute.int(record.sequenceNumber),
100105
'time': SentryLogAttribute.int(record.time.millisecondsSinceEpoch),
106+
'sentry.origin': SentryLogAttribute.string(origin),
101107
};
102108

103109
// Map log levels based on value ranges

packages/logging/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ platforms:
2020
dependencies:
2121
logging: ^1.0.0
2222
sentry: 9.7.0-beta.1
23+
meta: ^1.17.0
2324

2425
dev_dependencies:
2526
lints: '>=2.0.0'
2627
test: ^1.21.1
2728
yaml: ^3.1.0 # needed for version match (code and pubspec)
2829
coverage: ^1.3.0
29-
meta: ^1.3.0

packages/logging/test/logging_integration_test.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,10 @@ void main() {
330330
expect(basicAttributes['loggerName']?.value, 'TestLogger');
331331
expect(basicAttributes['sequenceNumber']?.value, isA<int>());
332332
expect(basicAttributes['time']?.value, isA<int>());
333+
expect(
334+
basicAttributes['sentry.origin']?.value,
335+
LoggingIntegration.origin,
336+
);
333337
expect(basicAttributes.containsKey('error'), false);
334338
expect(basicAttributes.containsKey('stackTrace'), false);
335339

0 commit comments

Comments
 (0)