otel4s icon indicating copy to clipboard operation
otel4s copied to clipboard

IO(doStuff).trace("", Attributes(...)) syntax

Open lhns opened this issue 1 year ago • 4 comments

trace4cats has this nice extension syntax that allows to introduce tracing into a code base without adding much clutter:

IO(doStuff).trace("", Attributes(...))

I would love for something like this to be in otel4s but it would add another way to do things.

lhns avatar Mar 05 '24 13:03 lhns

That could be useful.

@NthPortal what do you think? Do you have similar use cases at work?

I guess we can make extension syntax available via imports:

import org.typelevel.otel4s.metrics.syntax._ // metrics only syntax
import org.typelevel.otel4s.trace.syntax._ // trace only syntax
import org.typelevel.otel4s.syntax._ // metrics and trace syntax

iRevive avatar Mar 06 '24 09:03 iRevive

originally I was going to say that I don't object particularly, but I realised that it would require another set of macros (or lose the optimisation), so I'm not sure if it's a great idea

NthPortal avatar Mar 07 '24 18:03 NthPortal

Maybe a scala-3-only inline def?

lhns avatar Mar 14 '24 11:03 lhns

We already have macro definitions for both Scala 2 and Scala 3. With some refactoring, we can make it work.

As I mentioned here, perhaps we can launch experimental modules with no guarantee of binary compatibility.

iRevive avatar Mar 15 '24 09:03 iRevive