Skip to content

Commit

Permalink
Enrich Dart context with isolate name (#600)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhnroyal authored Sep 24, 2021
1 parent 6ebc780 commit e159529
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

* enrich Dart context with isolate name (#600)

# 6.1.0-alpha.1

* Performance API for Dart/Flutter (#530)
Expand Down
3 changes: 3 additions & 0 deletions dart/lib/src/enricher/io_enricher_event_processor.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';
import 'dart:io';
import 'dart:isolate';

import '../event_processor.dart';
import '../protocol.dart';
Expand Down Expand Up @@ -63,6 +64,7 @@ class IoEnricherEventProcessor extends EventProcessor {
Map<String, dynamic> _getDartContext(bool includePii) {
final args = Platform.executableArguments;
final packageConfig = Platform.packageConfig;
final isolate = Isolate.current.debugName;

String? executable;
if (includePii) {
Expand All @@ -83,6 +85,7 @@ class IoEnricherEventProcessor extends EventProcessor {
return <String, dynamic>{
if (packageConfig != null) 'package_config': packageConfig,
'number_of_processors': Platform.numberOfProcessors,
if (isolate != null) 'isolate': isolate,
// The following information could potentially contain PII
if (includePii) ...{
'executable': executable,
Expand Down
2 changes: 2 additions & 0 deletions dart/test/enricher/io_enricher_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit e159529

Please sign in to comment.