Skip to content

contrib/google.golang.org/grpc: add error details to span tags#2228

Merged
zarirhamza merged 9 commits into
DataDog:mainfrom
eyasy1217:add-error-details-to-span-tag
Dec 22, 2023
Merged

contrib/google.golang.org/grpc: add error details to span tags#2228
zarirhamza merged 9 commits into
DataDog:mainfrom
eyasy1217:add-error-details-to-span-tag

Conversation

@eyasy1217

Copy link
Copy Markdown
Contributor

What does this PR do?

If grpc error return value contains details, add it to the span tags
Users can enable this with the WithErrorDetailTags option
Fixes #1993

Motivation

See #1993.

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.

For Datadog employees:

  • If this PR touches code that handles credentials of any kind, such as Datadog API keys, I've requested a review from @DataDog/security-design-and-guidance.
  • This PR doesn't touch any of that.

Unsure? Have a question? Request a review!

@eyasy1217
eyasy1217 marked this pull request as ready for review September 22, 2023 01:41
@eyasy1217
eyasy1217 requested a review from a team September 22, 2023 01:41
@eyasy1217
eyasy1217 marked this pull request as draft September 22, 2023 03:31
@eyasy1217
eyasy1217 force-pushed the add-error-details-to-span-tag branch from 0a05dc4 to af51fc3 Compare September 22, 2023 04:39
if e, ok := status.FromError(err); ok && cfg.withErrorDetailTags {
for i, d := range e.Details() {
if d, ok := d.(proto.Message); ok {
span.SetTag(tagStatusDetailsPrefix+fmt.Sprintf("_%d", i), d.String())

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.

It appears that apm treats them as arrays if they are consecutive numeric strings, otherwise it treats them as objects.
In other words, if the index(i) is off, the array might become an object.
Therefore, I changed the key to a string like "_0" and treated it as an object.

@eyasy1217
eyasy1217 marked this pull request as ready for review September 22, 2023 04:44
@katiehockman katiehockman added the apm:ecosystem contrib/* related feature requests or bugs label Oct 6, 2023
@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 20 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions Bot added the stale Stuck for more than 1 month label Oct 27, 2023
@github-actions github-actions Bot removed the stale Stuck for more than 1 month label Nov 15, 2023
@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 20 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions Bot added the stale Stuck for more than 1 month label Dec 19, 2023

@zarirhamza zarirhamza left a comment

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.

LGTM

@zarirhamza
zarirhamza enabled auto-merge (squash) December 20, 2023 15:28
@ajgajg1134 ajgajg1134 removed the stale Stuck for more than 1 month label Dec 20, 2023
@zarirhamza
zarirhamza merged commit 7938f72 into DataDog:main Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apm:ecosystem contrib/* related feature requests or bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

contrib/google.golang.org/grpc: error details missing in the span

4 participants