Skip to content

[Orchestrion]: Enable Error Capture for Functions Returning Types Implementing error #3168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
korECM opened this issue Feb 9, 2025 · 1 comment
Assignees
Labels
enhancement quick change/addition that does not need full team approval orchestrion Issues pertaining to orchestrion support

Comments

@korECM
Copy link
Contributor

korECM commented Feb 9, 2025

Package Name

No response

Package Version(s)

No response

Describe the feature you'd like

I would like the dd-trace-go instrumentation to support error capture for functions whose return types implement the error interface, even if the return type is not explicitly defined as error.
This would involve extending the template helper (e.g., creating a helper like ResultHasError) to check whether a type implements error using something like types.Implements, rather than doing a strict type equality check.

Is your feature request related to a problem?

Yes, it is. Currently, when using the //dd:span tag, the error capture functionality only activates if the function’s return type is strictly error.

{{ with .Function.ResultOfType "error" -}}
  defer func(){
    span.Finish(tracer.WithError({{ . }}))
  }()
{{ else -}}
  defer span.Finish()
{{- end -}}

This causes issues when a function returns a different type (or an interface implementing error) since the error is not captured, leading to missing error reporting in spans.
As a workaround, users are forced to either change the function signature to return error explicitly or resort to manually handling errors with the dd-trace-go API.

Describe alternatives you've considered

No response

Additional context

This feature request was sparked by a discussion on the Orchestrion GitHub discussions.
I believe that modifying the dd-trace-go templates to allow error capture for types that implement error will improve usability for a broader range of scenarios.

I would be happy to work on this change if it's considered a worthwhile improvement by the maintainers.

@korECM korECM added the enhancement quick change/addition that does not need full team approval label Feb 9, 2025
@github-actions github-actions bot added the needs-triage New issues that have not yet been triaged label Feb 9, 2025
@korECM
Copy link
Contributor Author

korECM commented Feb 9, 2025

This is the issue for adding ResultHasError function in orchestrion

@eliottness eliottness removed the needs-triage New issues that have not yet been triaged label Feb 11, 2025
@darccio darccio assigned darccio and kakkoyun and unassigned darccio Feb 18, 2025
@RomainMuller RomainMuller added the orchestrion Issues pertaining to orchestrion support label Apr 15, 2025
@RomainMuller RomainMuller changed the title [FEATURE]: Enable Error Capture for Functions Returning Types Implementing error [Orchestrion]: Enable Error Capture for Functions Returning Types Implementing error Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement quick change/addition that does not need full team approval orchestrion Issues pertaining to orchestrion support
Projects
None yet
Development

No branches or pull requests

5 participants