Skip to content

feat(v2): add TransportTelemetryData for dynamic transport attributes#481

Merged
westarle merged 4 commits intogoogleapis:mainfrom
westarle:westarle/metrics-transport-data-independent
Mar 12, 2026
Merged

feat(v2): add TransportTelemetryData for dynamic transport attributes#481
westarle merged 4 commits intogoogleapis:mainfrom
westarle:westarle/metrics-transport-data-independent

Conversation

@westarle
Copy link
Copy Markdown
Contributor

No description provided.

@westarle westarle marked this pull request as ready for review March 11, 2026 21:08
@westarle westarle requested a review from a team as a code owner March 11, 2026 21:08
@westarle westarle force-pushed the westarle/metrics-transport-data-independent branch from d6f21a1 to d80099f Compare March 11, 2026 21:23
@westarle westarle enabled auto-merge (squash) March 11, 2026 21:42
Comment thread v2/telemetry.go
Comment thread v2/telemetry.go Outdated

// ExtractTransportTelemetry retrieves a mutable TransportTelemetryData pointer from the context.
func ExtractTransportTelemetry(ctx context.Context) (*TransportTelemetryData, bool) {
data, ok := ctx.Value(transportTelemetryKey{}).(*TransportTelemetryData)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just return ctx.Value() without the variables? You're not doing anything with the (data,ok) values.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this is a type assertion, if I "return" it it only provides the single data value.

I was thinking an 'ok' on the API is idiomatic (vs nil-checking data). WDYT?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh yes, I forgot about the optionality of the bool for a type assertion, that's on me.

You could also consider a single return and document that it can return nil if there was no data? The user isn't directly providing the input to the extractor where they're going to do anything different if something goes wrong.

e.g.

if data := ExtractTransportTelemetry(ctx); data != nil {
  // use the data
}

The other route is if we think extraction could become more complex over time is to use an error type for the second return value, but I don't think we're moving in that direction?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider a single return and document that it can return nil if there was no data

I think this is the best thing.

extraction could become more complex over time

Hope not!

@westarle westarle requested a review from shollyman March 12, 2026 16:46
Copy link
Copy Markdown
Contributor

@shollyman shollyman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One parting thought: you've marked the struct experimental, but not the functions. We should probably add an experiment disclaimer on those as well if you want a little more leeway to evolve.

@westarle westarle merged commit 8a7caf0 into googleapis:main Mar 12, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants