Source File
trace_client.go
Belonging Package
cloud.google.com/go/trace/apiv2
package trace
import (
gax
gtransport
cloudtracepb
)
var newClientHook clientHook
type CallOptions struct {
BatchWriteSpans []gax.CallOption
CreateSpan []gax.CallOption
}
func () []option.ClientOption {
return []option.ClientOption{
option.WithEndpoint("cloudtrace.googleapis.com:443"),
option.WithGRPCDialOption(grpc.WithDisableServiceConfig()),
option.WithScopes(DefaultAuthScopes()...),
option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
grpc.MaxCallRecvMsgSize(math.MaxInt32))),
}
}
func () *CallOptions {
return &CallOptions{
BatchWriteSpans: []gax.CallOption{},
CreateSpan: []gax.CallOption{
gax.WithRetry(func() gax.Retryer {
return gax.OnCodes([]codes.Code{
codes.Unavailable,
codes.DeadlineExceeded,
}, gax.Backoff{
Initial: 100 * time.Millisecond,
Max: 1000 * time.Millisecond,
Multiplier: 1.20,
})
}),
},
}
}
func ( context.Context, ...option.ClientOption) (*Client, error) {
:= defaultClientOptions()
if newClientHook != nil {
, := newClientHook(, clientHookParams{})
if != nil {
return nil,
}
= append(, ...)
}
, := checkDisableDeadlines()
if != nil {
return nil,
}
, := gtransport.DialPool(, append(, ...)...)
if != nil {
return nil,
}
:= &Client{
connPool: ,
disableDeadlines: ,
CallOptions: defaultCallOptions(),
client: cloudtracepb.NewTraceServiceClient(),
}
.setGoogleClientInfo()
return , nil
}
func ( *Client) () *grpc.ClientConn {
return .connPool.Conn()
}
func ( *Client) ( context.Context, *cloudtracepb.BatchWriteSpansRequest, ...gax.CallOption) error {
if , := .Deadline(); ! && !.disableDeadlines {
, := context.WithTimeout(, 120000*time.Millisecond)
defer ()
=
}
:= metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(.GetName())))
= insertMetadata(, .xGoogMetadata, )
= append(.CallOptions.BatchWriteSpans[0:len(.CallOptions.BatchWriteSpans):len(.CallOptions.BatchWriteSpans)], ...)
:= gax.Invoke(, func( context.Context, gax.CallSettings) error {
var error
_, = .client.BatchWriteSpans(, , .GRPC...)
return
}, ...)
return
}
func ( *Client) ( context.Context, *cloudtracepb.Span, ...gax.CallOption) (*cloudtracepb.Span, error) {
if , := .Deadline(); ! && !.disableDeadlines {
, := context.WithTimeout(, 120000*time.Millisecond)
defer ()
=
}
:= metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(.GetName())))
= insertMetadata(, .xGoogMetadata, )
= append(.CallOptions.CreateSpan[0:len(.CallOptions.CreateSpan):len(.CallOptions.CreateSpan)], ...)
var *cloudtracepb.Span
:= gax.Invoke(, func( context.Context, gax.CallSettings) error {
var error
, = .client.CreateSpan(, , .GRPC...)
return
}, ...)
if != nil {
return nil,
}
return , nil
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |