Documentation ¶
Overview ¶
Package api provides functions to trace the google.golang.org/api package.
WARNING: Please note we periodically re-generate the endpoint metadata that is used to enrich some tags added by this integration using the latest versions of github.com/googleapis/google-api-go-client (which does not follow semver due to the auto-generated nature of the package). For this reason, there might be unexpected changes in some tag values like service.name and resource.name, depending on the google.golang.org/api that you are using in your project. If this is not an acceptable behavior for your use-case, you can disable this feature using the WithEndpointMetadataDisabled option.
Example ¶
package main import ( "fmt" apitrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/google.golang.org/api" cloudresourcemanager "google.golang.org/api/cloudresourcemanager/v1" ) func main() { // create an oauth2 client suitable for use with the google APIs client, _ := apitrace.NewClient( // set scopes like this, which will vary depending on the service apitrace.WithScopes(cloudresourcemanager.CloudPlatformScope)) svc, _ := cloudresourcemanager.New(client) // call google api methods as usual res, _ := svc.Projects.List().Do() for _, project := range res.Projects { fmt.Println(project.Name) } }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewClient ¶
NewClient creates a new oauth http client suitable for use with the google APIs with all requests traced automatically.
func WrapRoundTripper ¶
func WrapRoundTripper(transport http.RoundTripper, options ...Option) http.RoundTripper
WrapRoundTripper wraps a RoundTripper intended for interfacing with Google APIs and traces all requests.
Types ¶
type Option ¶
type Option func(*config)
An Option customizes the config.
func WithAnalytics ¶ added in v1.11.0
WithAnalytics enables Trace Analytics for all started spans.
func WithAnalyticsRate ¶ added in v1.11.0
WithAnalyticsRate sets the sampling rate for Trace Analytics events correlated to started spans.
func WithContext ¶
WithContext sets the context in the config. This can be used to set span parents or pass a context through to the underlying client constructor.
func WithEndpointMetadataDisabled ¶ added in v1.52.0
func WithEndpointMetadataDisabled() Option
WithEndpointMetadataDisabled allows to disable the enriched Google endpoint metadata behavior for this integration. Use this option if you are sensitive to changes in some span tags generated by this integration that might happen when the used Google endpoint metadata gets regenerated in newer dd-trace-go versions.
func WithScopes ¶
WithScopes sets the scopes used to create the oauth2 config for Google APIs.
func WithServiceName ¶
WithServiceName sets the service name in the config. The default service name is inferred from the API definitions based on the http request route.