forked from lightstep/lightstep-tracer-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
collector_client_custom.go
41 lines (32 loc) · 1 KB
/
collector_client_custom.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package lightstep
import (
"context"
"fmt"
"io/ioutil"
"github.com/lightstep/lightstep-tracer-common/golang/gogo/collectorpb"
)
func newCustomCollector(opts Options) *customCollectorClient {
return &customCollectorClient{collector: opts.CustomCollector}
}
type customCollectorClient struct {
collector Collector
}
func (client *customCollectorClient) Report(ctx context.Context, req reportRequest) (collectorResponse, error) {
if req.protoRequest == nil {
return nil, fmt.Errorf("protoRequest cannot be null")
}
resp, err := client.collector.Report(ctx, req.protoRequest)
if err != nil {
return nil, err
}
return protoResponse{ReportResponse: resp}, nil
}
func (client *customCollectorClient) Translate(protoRequest *collectorpb.ReportRequest) (reportRequest, error) {
return reportRequest{protoRequest: protoRequest}, nil
}
func (customCollectorClient) ConnectClient() (Connection, error) {
return ioutil.NopCloser(nil), nil
}
func (customCollectorClient) ShouldReconnect() bool {
return false
}