diff --git a/lib/src/sdk/trace/exporters/collector_exporter.dart b/lib/src/sdk/trace/exporters/collector_exporter.dart index f22c0e53..07f12ffd 100644 --- a/lib/src/sdk/trace/exporters/collector_exporter.dart +++ b/lib/src/sdk/trace/exporters/collector_exporter.dart @@ -42,19 +42,19 @@ class CollectorExporter implements sdk.SpanExporter { } Future _send( - Uri uri, - List spans, - ) async { - try { - final body = pb_trace_service.ExportTraceServiceRequest( - resourceSpans: _spansToProtobuf(spans)); - final headers = {'Content-Type': 'application/x-protobuf'} - ..addAll(this.headers); - - await client.post(uri, body: body.writeToBuffer(), headers: headers); - } catch (e) { - _log.warning('Failed to export ${spans.length} spans.', e); - } + Uri uri, + List spans, + ) async { + try { + final body = pb_trace_service.ExportTraceServiceRequest( + resourceSpans: _spansToProtobuf(spans)); + final headers = {'Content-Type': 'application/x-protobuf'} + ..addAll(this.headers); + + await client.post(uri, body: body.writeToBuffer(), headers: headers); + } catch (e) { + _log.warning('Failed to export ${spans.length} spans.', e); + } } /// Group and construct the protobuf equivalent of the given list of [api.Span]s. diff --git a/test/unit/mocks.mocks.dart b/test/unit/mocks.mocks.dart index e024c73a..a6984dd0 100644 --- a/test/unit/mocks.mocks.dart +++ b/test/unit/mocks.mocks.dart @@ -1,7 +1,7 @@ // Copyright 2021-2022 Workiva. // Licensed under the Apache License, Version 2.0. Please see https://github.com/Workiva/opentelemetry-dart/blob/master/LICENSE for more information -// Mocks generated by Mockito 5.4.2 from annotations +// Mocks generated by Mockito 5.4.4 from annotations // in opentelemetry/test/unit/mocks.dart. // Do not manually edit this file. @@ -23,6 +23,8 @@ import 'package:opentelemetry/src/sdk/common/attributes.dart' as _i6; // ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_setters_without_getters // ignore_for_file: comment_references +// ignore_for_file: deprecated_member_use +// ignore_for_file: deprecated_member_use_from_same_package // ignore_for_file: implementation_imports // ignore_for_file: invalid_use_of_visible_for_testing_member // ignore_for_file: prefer_const_constructors @@ -512,8 +514,23 @@ class MockHttpClient extends _i1.Mock implements _i3.Client { [url], {#headers: headers}, ), - returnValue: _i9.Future.value(''), - returnValueForMissingStub: _i9.Future.value(''), + returnValue: _i9.Future.value(_i8.dummyValue( + this, + Invocation.method( + #read, + [url], + {#headers: headers}, + ), + )), + returnValueForMissingStub: + _i9.Future.value(_i8.dummyValue( + this, + Invocation.method( + #read, + [url], + {#headers: headers}, + ), + )), ) as _i9.Future); @override @@ -689,8 +706,14 @@ class MockReadOnlySpan extends _i1.Mock implements _i5.ReadOnlySpan { @override String get name => (super.noSuchMethod( Invocation.getter(#name), - returnValue: '', - returnValueForMissingStub: '', + returnValue: _i8.dummyValue( + this, + Invocation.getter(#name), + ), + returnValueForMissingStub: _i8.dummyValue( + this, + Invocation.getter(#name), + ), ) as String); @override diff --git a/test/unit/sdk/exporters/collector_exporter_test.dart b/test/unit/sdk/exporters/collector_exporter_test.dart index 8df9e99e..3b0f5c01 100644 --- a/test/unit/sdk/exporters/collector_exporter_test.dart +++ b/test/unit/sdk/exporters/collector_exporter_test.dart @@ -195,8 +195,8 @@ void main() { sub.cancel(); verify(mockClient.post(uri, - body: anything, headers: {'Content-Type': 'application/x-protobuf'})) - .called(1); + body: anything, + headers: {'Content-Type': 'application/x-protobuf'})).called(1); expect(records, hasLength(1)); expect(records[0].level, equals(Level.WARNING));