Skip to content

Commit f7d9433

Browse files
committed
wip: fix lint
1 parent 1f6b041 commit f7d9433

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

Diff for: lib/src/sdk/logs/exporters/console_log_record_exporter.dart

+12-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright 2021-2022 Workiva.
22
// Licensed under the Apache License, Version 2.0. Please see https://github.com/Workiva/opentelemetry-dart/blob/master/LICENSE for more information
33

4-
import 'package:opentelemetry/api.dart' as api;
54
import 'package:opentelemetry/src/experimental_sdk.dart' as sdk;
65

76
/// This is implementation of [sdk.ReadWriteLogRecordExporter] that prints LogRecords to the
@@ -29,34 +28,32 @@ class ConsoleLogRecordExporter implements sdk.LogRecordExporter {
2928
/// converts logRecord info into more readable format
3029
Map<String, dynamic> _makeObject(sdk.ReadableLogRecord log) {
3130
final contextInfo = {};
32-
if (log.spanContext != null) {
33-
contextInfo.addAll({
34-
'traceId': log.spanContext!.traceId,
35-
'spanId': log.spanContext!.spanId,
36-
'traceFlags': log.spanContext!.traceFlags,
37-
});
38-
}
31+
contextInfo.addAll({
32+
'traceId': log.spanContext.traceId,
33+
'spanId': log.spanContext.spanId,
34+
'traceFlags': log.spanContext.traceFlags,
35+
});
3936
return {
4037
'resource': {
4138
'attributes': {
42-
for (final attribute in log.resource?.attributes.keys ?? <String>[])
43-
attribute: log.resource!.attributes.get(attribute),
39+
for (final attribute in log.resource.attributes.keys)
40+
attribute: log.resource.attributes.get(attribute),
4441
},
4542
},
4643
'instrumentationScope': {
47-
'name': log.instrumentationScope?.name,
48-
'version': log.instrumentationScope?.version,
49-
'schemaUrl': log.instrumentationScope?.schemaUrl,
44+
'name': log.instrumentationScope.name,
45+
'version': log.instrumentationScope.version,
46+
'schemaUrl': log.instrumentationScope.schemaUrl,
5047
'attributes': {
51-
for (final attribute in log.instrumentationScope?.attributes ?? <api.Attribute>[]) attribute.key: attribute.value,
48+
for (final attribute in log.instrumentationScope.attributes) attribute.key: attribute.value,
5249
}
5350
},
5451
'timestamp': log.timeStamp,
5552
'severityText': log.severityText,
5653
'severityNumber': log.severityNumber,
5754
'body': log.body,
5855
'attributes': {
59-
for (final attribute in log.attributes?.keys ?? <String>[]) attribute: log.resource!.attributes.get(attribute),
56+
for (final attribute in log.attributes.keys) attribute: log.resource.attributes.get(attribute),
6057
},
6158
...contextInfo,
6259
};

Diff for: test/unit/sdk/logs/exporters/inmemory_log_record_exporter_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void main() {
2626
await exporter.export([logRecord]);
2727

2828
expect(exporter.finishedLogRecords.length, 1);
29-
expect(exporter.finishedLogRecords.first.instrumentationScope?.name, 'library_name');
29+
expect(exporter.finishedLogRecords.first.instrumentationScope.name, 'library_name');
3030

3131
await exporter.shutdown();
3232

0 commit comments

Comments
 (0)