caliban icon indicating copy to clipboard operation
caliban copied to clipboard

Improve tracing propagation

Open kyri-petrou opened this issue 1 year ago • 1 comments

⚠️ Binary incompatible changes ⚠️

With this PR, we disable auto-tracing across all of Caliban's codebase and propagate traces via the implicit requirement, or disable them wherever it doesn't make sense to propagate them via Trace.empty.

This is largely driven by an issue recently reported by @frekw, where the stack traces were incorrectly showing that an error was thrown within Caliban's code, since we were not propagating / disabling traces properly.

For example, running the Quick adapter example app, and adding <* ZIO.stackTrace.debug here:

series/2.x:

Stack trace for thread "zio-fiber-43":
	at example.ExampleService.make.$anon.getCharacters(ExampleService.scala:26)
	at example.ExampleApi.makeApi(ExampleApi.scala:87)
	at caliban.QuickAdapter.handlers(QuickAdapter.scala:13)
	at caliban.wrappers.ApolloTracing.apolloTracingField.$anon.wrap(ApolloTracing.scala:210)
	at caliban.QuickAdapter.handlers(QuickAdapter.scala:13)
	at caliban.wrappers.ApolloTracing.apolloTracingOverall.$anon.wrap(ApolloTracing.scala:139)
	at caliban.wrappers.Wrappers.printErrors.$anon.wrap(Wrappers.scala:28)
	at caliban.wrappers.Wrappers.onSlowQueries.$anon.wrap(Wrappers.scala:70)
	at caliban.wrappers.Wrappers.timeout.$anon.wrap(Wrappers.scala:86)

PR:

Stack trace for thread "zio-fiber-43":
	at example.ExampleService.make.$anon.getCharacters(ExampleService.scala:26)
	at example.ExampleApi.makeApi(ExampleApi.scala:87)

Note that while these changes are no binary compatible, they should be mostly source compatible for most users

kyri-petrou avatar Feb 24 '24 03:02 kyri-petrou

I feel sad that we have to pollute our code that much :/

ghostdogpr avatar Feb 28 '24 04:02 ghostdogpr

Closing this and will try a different approach

kyri-petrou avatar Apr 27 '24 01:04 kyri-petrou