Skip to content

apmotel span.RecordError should handle nil errors, as per OpenTelemetry's implementation #1565

Closed

Description

Is your feature request related to a problem? Please describe.
The apmotel bridge has proved extremely helpful in migrating to OpenTelemetry spans/tracers, but there is one noticeable difference inside the Span implementation: RecordError.

The OpenTelemetry SDK implementation of span.RecordError() includes a nil check for the error that is passed in.

In contrast, the apmotel implementation does no such check. While this is understandable, and arguably more idiomatic, it introduces an issue where you cannot seamlessly drop in the bridge and use span.RecordError how you might expect to with the OpenTelemetry SDK.

Describe the solution you'd like
I believe apmotel's span.RecordError should do the same nil check to improve interoperability with the official OpenTelemetry SDK.

Describe alternatives you've considered
With the official SDK, you might do something like:

err := someOperation()
span.recordError(err)

For this code to coexist with the bridge, we'd then have to add a nil check in before the second line, and we'd have to do so everywhere we've already written a recordError usage like it.

While we could do this, and indeed have opted to so far, we've noticed it just leaves us open to missed cases each time we attempt to adopt the bridge in a service to start its migration to OpenTelemetry.

edit: I have attached a draft PR that implements the requested change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions