Skip to content

Commit 327f040

Browse files
committed
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
1 parent b987f0c commit 327f040

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

spanreceiver/spanreceiver.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2018, OpenCensus Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package spanreceiver
16+
17+
import (
18+
commonpb "github.com/census-instrumentation/opencensus-proto/gen-go/agent/common/v1"
19+
tracepb "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1"
20+
)
21+
22+
// SpanReceiver is an interface that receives spans from a Node identifier.
23+
type SpanReceiver interface {
24+
ReceiveSpans(node *commonpb.Node, spans ...*tracepb.Span) (*Acknowledgement, error)
25+
}
26+
27+
type Acknowledgement struct {
28+
SavedSpans uint64
29+
DroppedSpans uint64
30+
}

0 commit comments

Comments
 (0)