// NewClient creates a new Google Stackdriver Trace client.
NewClient creates a new Google Stackdriver Trace client.
// NewClient creates a new Google Stackdriver Trace client .
func NewClient(ctx context.Context, projectID string, opts ...option.ClientOption) (*Client, error) {
	o := []option.ClientOption{
		option.WithScopes(cloudPlatformScope),
		option.WithUserAgent(userAgent),
	}
	o = append(o, opts...)
	hc, basePath, err := transport.NewHTTPClient(ctx, o...)
	if err != nil {
		return nil, fmt.Errorf("creating HTTP client for Google Stackdriver Trace API: %v", err)
	}
	apiService, err := api.New(hc)
	if err != nil {
		return nil, fmt.Errorf("creating Google Stackdriver Trace API client: %v", err)
	}
	if basePath != "" {
		apiService.BasePath = basePath
	}
	c := &Client{
		service:   apiService,
		projectID: projectID,
	}
	bundler := bundler.NewBundler((*api.Trace)(nil), func(bundle interface{}) {
		traces := bundle.([]*api.Trace)
		err := c.upload(traces)
		if err != nil {
			log.Printf("failed to upload %d traces to the Cloud Trace server.", len(traces))
		}
	})
	bundler.DelayThreshold = 2 * time.Second
	bundler.BundleCountThreshold = 100
	bundler.BundleByteThreshold = 1000
	bundler.BundleByteLimit = 1000
	bundler.BufferedByteLimit = 10000
	c.bundler = bundler
	return c, nil
}
func NewClient ( ctx context . Context , projectID string , opts ... option . ClientOption ) ( * Client , error ) { o := [ ] option . ClientOption { option . WithScopes ( cloudPlatformScope ) , option . WithUserAgent ( userAgent ) , } o = append ( o , opts ... ) hc , basePath , err := transport . NewHTTPClient ( ctx , o ... ) if err != nil { return nil , fmt . Errorf ( " " , err ) } apiService , err := api . New ( hc ) if err != nil { return nil , fmt . Errorf ( " " , err ) } if basePath != " " { apiService . BasePath = basePath } c := & Client { service : apiService , projectID : projectID , } bundler := bundler . NewBundler ( ( * api . Trace ) ( nil ) , func ( bundle interface { } ) { traces := bundle . ( [ ] * api . Trace ) err := c . upload ( traces ) if err != nil { log . Printf ( " " , len ( traces ) ) } } ) bundler . DelayThreshold = 2 * time . Second bundler . BundleCountThreshold = 100 bundler . BundleByteThreshold = 1000 bundler . BundleByteLimit = 1000 bundler . BufferedByteLimit = 10000 c . bundler = bundler return c , nil }
NewClient creates a new Google Stackdriver Trace client.
NewClient creates a new Google Stackdriver Trace client .
// An option set a basepath, so override api.New's default. // We're not measuring bytes here, we're counting traces and spans as one "byte" each.