Skip to content

Commit

Permalink
support gRPC protocol in CollectorExporter
Browse files Browse the repository at this point in the history
  • Loading branch information
huandu committed Mar 27, 2024
1 parent 05f63b6 commit e2b44dd
Show file tree
Hide file tree
Showing 17 changed files with 173 additions and 137 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.dart_tool
.packages
pubspec.lock
opentelemetry-proto
3 changes: 2 additions & 1 deletion lib/sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export 'src/sdk/time_providers/datetime_time_provider.dart'
show DateTimeTimeProvider;
export 'src/sdk/time_providers/time_provider.dart' show TimeProvider;
export 'src/sdk/trace/exporters/span_exporter.dart' show SpanExporter;
export 'src/sdk/trace/exporters/collector_exporter.dart' show CollectorExporter;
export 'src/sdk/trace/exporters/collector_exporter.dart'
show CollectorExporter, CollectorExporterProtocol;
export 'src/sdk/trace/exporters/console_exporter.dart' show ConsoleExporter;
export 'src/sdk/trace/id_generator.dart' show IdGenerator;
export 'src/sdk/trace/sampling/always_off_sampler.dart' show AlwaysOffSampler;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// 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

//
// Generated code. Do not modify.
// source: opentelemetry/proto/collector/trace/v1/trace_service.proto
Expand All @@ -12,17 +9,16 @@
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import

import 'dart:async' as $async;
import 'dart:core' as $core;

import 'package:fixnum/fixnum.dart' as $fixnum;
import 'package:protobuf/protobuf.dart' as $pb;

import '../../../trace/v1/trace.pb.dart' as $2;
import '../../../trace/v1/trace.pb.dart' as $6;

class ExportTraceServiceRequest extends $pb.GeneratedMessage {
factory ExportTraceServiceRequest({
$core.Iterable<$2.ResourceSpans>? resourceSpans,
$core.Iterable<$6.ResourceSpans>? resourceSpans,
}) {
final $result = create();
if (resourceSpans != null) {
Expand All @@ -35,7 +31,7 @@ class ExportTraceServiceRequest extends $pb.GeneratedMessage {
factory ExportTraceServiceRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);

static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'ExportTraceServiceRequest', package: const $pb.PackageName(_omitMessageNames ? '' : 'opentelemetry.proto.collector.trace.v1'), createEmptyInstance: create)
..pc<$2.ResourceSpans>(1, _omitFieldNames ? '' : 'resourceSpans', $pb.PbFieldType.PM, subBuilder: $2.ResourceSpans.create)
..pc<$6.ResourceSpans>(1, _omitFieldNames ? '' : 'resourceSpans', $pb.PbFieldType.PM, subBuilder: $6.ResourceSpans.create)
..hasRequiredFields = false
;

Expand Down Expand Up @@ -66,7 +62,7 @@ class ExportTraceServiceRequest extends $pb.GeneratedMessage {
/// data from multiple origins typically batch the data before forwarding further and
/// in that case this array will contain multiple elements.
@$pb.TagNumber(1)
$core.List<$2.ResourceSpans> get resourceSpans => $_getList(0);
$core.List<$6.ResourceSpans> get resourceSpans => $_getList(0);
}

class ExportTraceServiceResponse extends $pb.GeneratedMessage {
Expand Down Expand Up @@ -211,15 +207,6 @@ class ExportTracePartialSuccess extends $pb.GeneratedMessage {
void clearErrorMessage() => clearField(2);
}

class TraceServiceApi {
$pb.RpcClient _client;
TraceServiceApi(this._client);

$async.Future<ExportTraceServiceResponse> export($pb.ClientContext? ctx, ExportTraceServiceRequest request) =>
_client.invoke<ExportTraceServiceResponse>(ctx, 'TraceService', 'Export', request, ExportTraceServiceResponse())
;
}


const _omitFieldNames = $core.bool.fromEnvironment('protobuf.omit_field_names');
const _omitMessageNames = $core.bool.fromEnvironment('protobuf.omit_message_names');
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// 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

//
// Generated code. Do not modify.
// source: opentelemetry/proto/collector/trace/v1/trace_service.proto
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// Generated code. Do not modify.
// source: opentelemetry/proto/collector/trace/v1/trace_service.proto
//
// @dart = 2.12

// ignore_for_file: annotate_overrides, camel_case_types, comment_references
// ignore_for_file: constant_identifier_names, library_prefixes
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import

import 'dart:async' as $async;
import 'dart:core' as $core;

import 'package:grpc/service_api.dart' as $grpc;
import 'package:protobuf/protobuf.dart' as $pb;

import 'trace_service.pb.dart' as $1;

export 'trace_service.pb.dart';

@$pb.GrpcServiceName('opentelemetry.proto.collector.trace.v1.TraceService')
class TraceServiceClient extends $grpc.Client {
static final _$export = $grpc.ClientMethod<$1.ExportTraceServiceRequest, $1.ExportTraceServiceResponse>(
'/opentelemetry.proto.collector.trace.v1.TraceService/Export',
($1.ExportTraceServiceRequest value) => value.writeToBuffer(),
($core.List<$core.int> value) => $1.ExportTraceServiceResponse.fromBuffer(value));

TraceServiceClient($grpc.ClientChannel channel,
{$grpc.CallOptions? options,
$core.Iterable<$grpc.ClientInterceptor>? interceptors})
: super(channel, options: options,
interceptors: interceptors);

$grpc.ResponseFuture<$1.ExportTraceServiceResponse> export($1.ExportTraceServiceRequest request, {$grpc.CallOptions? options}) {
return $createUnaryCall(_$export, request, options: options);
}
}

@$pb.GrpcServiceName('opentelemetry.proto.collector.trace.v1.TraceService')
abstract class TraceServiceBase extends $grpc.Service {
$core.String get $name => 'opentelemetry.proto.collector.trace.v1.TraceService';

TraceServiceBase() {
$addMethod($grpc.ServiceMethod<$1.ExportTraceServiceRequest, $1.ExportTraceServiceResponse>(
'Export',
export_Pre,
false,
false,
($core.List<$core.int> value) => $1.ExportTraceServiceRequest.fromBuffer(value),
($1.ExportTraceServiceResponse value) => value.writeToBuffer()));
}

$async.Future<$1.ExportTraceServiceResponse> export_Pre($grpc.ServiceCall call, $async.Future<$1.ExportTraceServiceRequest> request) async {
return export(call, await request);
}

$async.Future<$1.ExportTraceServiceResponse> export($grpc.ServiceCall call, $1.ExportTraceServiceRequest request);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// 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

//
// Generated code. Do not modify.
// source: opentelemetry/proto/collector/trace/v1/trace_service.proto
Expand All @@ -16,10 +13,6 @@ import 'dart:convert' as $convert;
import 'dart:core' as $core;
import 'dart:typed_data' as $typed_data;

import '../../../common/v1/common.pbjson.dart' as $0;
import '../../../resource/v1/resource.pbjson.dart' as $1;
import '../../../trace/v1/trace.pbjson.dart' as $2;

@$core.Deprecated('Use exportTraceServiceRequestDescriptor instead')
const ExportTraceServiceRequest$json = {
'1': 'ExportTraceServiceRequest',
Expand Down Expand Up @@ -61,35 +54,3 @@ final $typed_data.Uint8List exportTracePartialSuccessDescriptor = $convert.base6
'ChlFeHBvcnRUcmFjZVBhcnRpYWxTdWNjZXNzEiUKDnJlamVjdGVkX3NwYW5zGAEgASgDUg1yZW'
'plY3RlZFNwYW5zEiMKDWVycm9yX21lc3NhZ2UYAiABKAlSDGVycm9yTWVzc2FnZQ==');

const $core.Map<$core.String, $core.dynamic> TraceServiceBase$json = {
'1': 'TraceService',
'2': [
{'1': 'Export', '2': '.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest', '3': '.opentelemetry.proto.collector.trace.v1.ExportTraceServiceResponse', '4': {}},
],
};

@$core.Deprecated('Use traceServiceDescriptor instead')
const $core.Map<$core.String, $core.Map<$core.String, $core.dynamic>> TraceServiceBase$messageJson = {
'.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest': ExportTraceServiceRequest$json,
'.opentelemetry.proto.trace.v1.ResourceSpans': $2.ResourceSpans$json,
'.opentelemetry.proto.resource.v1.Resource': $1.Resource$json,
'.opentelemetry.proto.common.v1.KeyValue': $0.KeyValue$json,
'.opentelemetry.proto.common.v1.AnyValue': $0.AnyValue$json,
'.opentelemetry.proto.common.v1.ArrayValue': $0.ArrayValue$json,
'.opentelemetry.proto.common.v1.KeyValueList': $0.KeyValueList$json,
'.opentelemetry.proto.trace.v1.ScopeSpans': $2.ScopeSpans$json,
'.opentelemetry.proto.common.v1.InstrumentationScope': $0.InstrumentationScope$json,
'.opentelemetry.proto.trace.v1.Span': $2.Span$json,
'.opentelemetry.proto.trace.v1.Span.Event': $2.Span_Event$json,
'.opentelemetry.proto.trace.v1.Span.Link': $2.Span_Link$json,
'.opentelemetry.proto.trace.v1.Status': $2.Status$json,
'.opentelemetry.proto.collector.trace.v1.ExportTraceServiceResponse': ExportTraceServiceResponse$json,
'.opentelemetry.proto.collector.trace.v1.ExportTracePartialSuccess': ExportTracePartialSuccess$json,
};

/// Descriptor for `TraceService`. Decode as a `google.protobuf.ServiceDescriptorProto`.
final $typed_data.Uint8List traceServiceDescriptor = $convert.base64Decode(
'CgxUcmFjZVNlcnZpY2USkQEKBkV4cG9ydBJBLm9wZW50ZWxlbWV0cnkucHJvdG8uY29sbGVjdG'
'9yLnRyYWNlLnYxLkV4cG9ydFRyYWNlU2VydmljZVJlcXVlc3QaQi5vcGVudGVsZW1ldHJ5LnBy'
'b3RvLmNvbGxlY3Rvci50cmFjZS52MS5FeHBvcnRUcmFjZVNlcnZpY2VSZXNwb25zZSIA');

Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// 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

//
// Generated code. Do not modify.
// source: opentelemetry/proto/common/v1/common.proto
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// 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

//
// Generated code. Do not modify.
// source: opentelemetry/proto/common/v1/common.proto
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// 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

//
// Generated code. Do not modify.
// source: opentelemetry/proto/common/v1/common.proto
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// 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

//
// Generated code. Do not modify.
// source: opentelemetry/proto/resource/v1/resource.proto
Expand All @@ -16,12 +13,12 @@ import 'dart:core' as $core;

import 'package:protobuf/protobuf.dart' as $pb;

import '../../common/v1/common.pb.dart' as $0;
import '../../common/v1/common.pb.dart' as $3;

/// Resource information.
class Resource extends $pb.GeneratedMessage {
factory Resource({
$core.Iterable<$0.KeyValue>? attributes,
$core.Iterable<$3.KeyValue>? attributes,
$core.int? droppedAttributesCount,
}) {
final $result = create();
Expand All @@ -38,7 +35,7 @@ class Resource extends $pb.GeneratedMessage {
factory Resource.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);

static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'Resource', package: const $pb.PackageName(_omitMessageNames ? '' : 'opentelemetry.proto.resource.v1'), createEmptyInstance: create)
..pc<$0.KeyValue>(1, _omitFieldNames ? '' : 'attributes', $pb.PbFieldType.PM, subBuilder: $0.KeyValue.create)
..pc<$3.KeyValue>(1, _omitFieldNames ? '' : 'attributes', $pb.PbFieldType.PM, subBuilder: $3.KeyValue.create)
..a<$core.int>(2, _omitFieldNames ? '' : 'droppedAttributesCount', $pb.PbFieldType.OU3)
..hasRequiredFields = false
;
Expand Down Expand Up @@ -68,7 +65,7 @@ class Resource extends $pb.GeneratedMessage {
/// Attribute keys MUST be unique (it is not allowed to have more than one
/// attribute with the same key).
@$pb.TagNumber(1)
$core.List<$0.KeyValue> get attributes => $_getList(0);
$core.List<$3.KeyValue> get attributes => $_getList(0);

/// dropped_attributes_count is the number of dropped attributes. If the value is 0, then
/// no attributes were dropped.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// 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

//
// Generated code. Do not modify.
// source: opentelemetry/proto/resource/v1/resource.proto
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// 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

//
// Generated code. Do not modify.
// source: opentelemetry/proto/resource/v1/resource.proto
Expand Down
Loading

0 comments on commit e2b44dd

Please sign in to comment.