Opentelemetry-go: Remove `WithSpan`

Created on 31 Jul 2020  路  7Comments  路  Source: open-telemetry/opentelemetry-go

The WithSpan method of the Tracer interface is a thin wrapper around the Start method in the default SDK, and expected to be the same for all SDK implementations. Additionally the function signature has been questioned if the closure will indeed serve users. Instead of trying to make a catch all, we'll remove the method and allow users to implement this in the way that best suits their purpose.

trace API required-for-ga

Most helpful comment

We could introduce a helper, for example.

All 7 comments

I'm also considering if this method should just be dropped from the Tracer interface.

I support removing WithSpan. Anything it does we should be able to accomplish by a defer span.End(). The sort of thing you can't do unless you have a WithSpan-like function is automatically call pprof.Do(), but users can do that on their own.

For those of you who belong to the "Honeycomb Pollinators" Slack team, I've brought this up several times before (here and here). I too am mystified by the WithSpan signature.

There is good support for removing WithSpan.

We could introduce a helper, for example.

Perhaps we should specify that span.End() should call recover() and automatically record an error.

Perhaps we should specify that span.End() should call recover() and automatically record an error.

That seems timely as it seems to be something the spec is looking to add: https://github.com/open-telemetry/opentelemetry-specification/pull/761/files#diff-05dabeeb80a46b2c02de5a02b8151b2cR18

Was this page helpful?
0 / 5 - 0 ratings