From 327f0403b93b7d546463bfefc842a2f2c82d21e8 Mon Sep 17 00:00:00 2001 From: Emmanuel T Odeke Date: Thu, 20 Sep 2018 22:25:08 -0700 Subject: [PATCH] spanreceiver: define SpanReceiver interface An interface `SpanReceiver` that receives: (*commonpb.Node, ...*tracepb.Span) to uniquely identify a data source by node alongside the spans it has received from that source. It sends back an acknowledgement and an error. The return signature is `(*Acknowledgement, error)` because it would useful to return to callers information about how many spans were successful, errors that were encountered, allowing for batches of spans to be written like we would with `io.Write`. This will allow callers to retry, report success and failure rates too. Fixes #30 --- spanreceiver/spanreceiver.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 spanreceiver/spanreceiver.go diff --git a/spanreceiver/spanreceiver.go b/spanreceiver/spanreceiver.go new file mode 100644 index 00000000000..118f99bec41 --- /dev/null +++ b/spanreceiver/spanreceiver.go @@ -0,0 +1,30 @@ +// Copyright 2018, OpenCensus Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spanreceiver + +import ( + commonpb "github.com/census-instrumentation/opencensus-proto/gen-go/agent/common/v1" + tracepb "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1" +) + +// SpanReceiver is an interface that receives spans from a Node identifier. +type SpanReceiver interface { + ReceiveSpans(node *commonpb.Node, spans ...*tracepb.Span) (*Acknowledgement, error) +} + +type Acknowledgement struct { + SavedSpans uint64 + DroppedSpans uint64 +}