Skip to content

Commit

Permalink
Merge pull request #155 from Workiva/O11Y-4317
Browse files Browse the repository at this point in the history
O11Y-4317: update generated mocks and format project
  • Loading branch information
rmconsole7-wk authored Mar 6, 2024
2 parents fe77198 + 5e7326a commit 05f63b6
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 20 deletions.
26 changes: 13 additions & 13 deletions lib/src/sdk/trace/exporters/collector_exporter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ class CollectorExporter implements sdk.SpanExporter {
}

Future<void> _send(
Uri uri,
List<sdk.ReadOnlySpan> 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<sdk.ReadOnlySpan> 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.
Expand Down
33 changes: 28 additions & 5 deletions test/unit/mocks.mocks.dart
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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
Expand Down Expand Up @@ -512,8 +514,23 @@ class MockHttpClient extends _i1.Mock implements _i3.Client {
[url],
{#headers: headers},
),
returnValue: _i9.Future<String>.value(''),
returnValueForMissingStub: _i9.Future<String>.value(''),
returnValue: _i9.Future<String>.value(_i8.dummyValue<String>(
this,
Invocation.method(
#read,
[url],
{#headers: headers},
),
)),
returnValueForMissingStub:
_i9.Future<String>.value(_i8.dummyValue<String>(
this,
Invocation.method(
#read,
[url],
{#headers: headers},
),
)),
) as _i9.Future<String>);

@override
Expand Down Expand Up @@ -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<String>(
this,
Invocation.getter(#name),
),
returnValueForMissingStub: _i8.dummyValue<String>(
this,
Invocation.getter(#name),
),
) as String);

@override
Expand Down
4 changes: 2 additions & 2 deletions test/unit/sdk/exporters/collector_exporter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 05f63b6

Please sign in to comment.