Skip to content

compute/metadata: accept request context #4483

@tam7t

Description

@tam7t

Is your feature request related to a problem? Please describe.

cloud.google.com/go/compute/metadata API does have a way to make propagage a context to http requests. This means a context cannot be used to control RPC lifetime and that when open telemetry is used the requests from the metadata client are not associated with the parent span.

Describe the solution you'd like
Perhaps the package *WithContext variants of the existing functions could be added that allow passing in a request context.

Describe alternatives you've considered

Additional context

I'm able to attach tracing to the package by using the go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp package, but traces are not associated with parent spans.

hc := &http.Client{
	Transport: otelhttp.NewTransport(&http.Transport{
		Dial: (&net.Dialer{
			Timeout:   2 * time.Second,
			KeepAlive: 30 * time.Second,
		}).Dial,
	}),
	Timeout: 60 * time.Second,
}
mc := metadata.NewClient(hc)

Metadata

Metadata

Assignees

Labels

api: computeIssues related to the Compute Engine API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions