From 9f8bdad4ec2fcbf8efb63f81070060a63827fe17 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Thu, 23 Sep 2021 16:48:18 +0200 Subject: [PATCH 1/2] Enrich Dart context with isolate name --- CHANGELOG.md | 2 ++ dart/lib/src/enricher/io_enricher_event_processor.dart | 2 ++ dart/test/enricher/io_enricher_test.dart | 2 ++ 3 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a0f37ebc3..d3deefd609 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Unreleased +* enrich Dart context with isolate name + # 6.1.0-alpha.1 * Performance API for Dart/Flutter (#530) diff --git a/dart/lib/src/enricher/io_enricher_event_processor.dart b/dart/lib/src/enricher/io_enricher_event_processor.dart index da27e06e2c..e850bdf335 100644 --- a/dart/lib/src/enricher/io_enricher_event_processor.dart +++ b/dart/lib/src/enricher/io_enricher_event_processor.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'dart:io'; +import 'dart:isolate'; import '../event_processor.dart'; import '../protocol.dart'; @@ -83,6 +84,7 @@ class IoEnricherEventProcessor extends EventProcessor { return { if (packageConfig != null) 'package_config': packageConfig, 'number_of_processors': Platform.numberOfProcessors, + 'isolate': Isolate.current.debugName, // The following information could potentially contain PII if (includePii) ...{ 'executable': executable, diff --git a/dart/test/enricher/io_enricher_test.dart b/dart/test/enricher/io_enricher_test.dart index c93cb1036a..b9d0f33c08 100644 --- a/dart/test/enricher/io_enricher_test.dart +++ b/dart/test/enricher/io_enricher_test.dart @@ -78,6 +78,7 @@ void main() { final dartContext = event.contexts['dart_context']; expect(dartContext, isNotNull); + expect(dartContext['isolate'], isNotNull); expect(dartContext['number_of_processors'], isNotNull); // Getting the executable sometimes throws //expect(dartContext['executable'], isNotNull); @@ -93,6 +94,7 @@ void main() { final dartContext = event.contexts['dart_context']; expect(dartContext, isNotNull); expect(dartContext['number_of_processors'], isNotNull); + expect(dartContext['isolate'], isNotNull); expect(dartContext['executable'], isNull); expect(dartContext['resolved_executable'], isNull); expect(dartContext['script'], isNull); From 617c8ffa62fda003e9a20174aa886d069a2e627a Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Thu, 23 Sep 2021 16:56:09 +0200 Subject: [PATCH 2/2] Address review comments * only add if null * add PR to changelog --- CHANGELOG.md | 2 +- dart/lib/src/enricher/io_enricher_event_processor.dart | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3deefd609..d8e5ef206d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Unreleased -* enrich Dart context with isolate name +* enrich Dart context with isolate name (#600) # 6.1.0-alpha.1 diff --git a/dart/lib/src/enricher/io_enricher_event_processor.dart b/dart/lib/src/enricher/io_enricher_event_processor.dart index e850bdf335..af010b8a52 100644 --- a/dart/lib/src/enricher/io_enricher_event_processor.dart +++ b/dart/lib/src/enricher/io_enricher_event_processor.dart @@ -64,6 +64,7 @@ class IoEnricherEventProcessor extends EventProcessor { Map _getDartContext(bool includePii) { final args = Platform.executableArguments; final packageConfig = Platform.packageConfig; + final isolate = Isolate.current.debugName; String? executable; if (includePii) { @@ -84,7 +85,7 @@ class IoEnricherEventProcessor extends EventProcessor { return { if (packageConfig != null) 'package_config': packageConfig, 'number_of_processors': Platform.numberOfProcessors, - 'isolate': Isolate.current.debugName, + if (isolate != null) 'isolate': isolate, // The following information could potentially contain PII if (includePii) ...{ 'executable': executable,