Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Jakub Kozłowski
    @kubukoz
    glad :)
    Anton Solovyev
    @Rosteelton

    It's me again. I am trying to wrap Client[F]. (I have Trace[F] instance there)

      def apply[F[_]: Trace: Sync](client: Client[F]): Client[F] = {
        Client[F] { request =>
          val spanName: String = ???
          for {
            b <- Trace[F].span(spanName) { //should be F[]
              }
          //only have Resource[F, Response[F]] type for
          //client.run(modifiedRequest))
          } yield ???
        }
      }

    Can't get how to transform Resource to wrap it with Trace[F].span

    Ryan Zeigler
    @rzeigler
    You can use the Trace[F].span wherever you use the Response[F] rather than during construction time.
    Anton Solovyev
    @Rosteelton
    Yes, but I would like to wrap all endpoints that this client will call.
    Ryan Zeigler
    @rzeigler
    So spans are produced in their own resource. You might have to work directly in Kleisli to extract the span and produce a child span directly inside that resource.
    Christopher Davenport
    @ChristopherDavenport
    I built a middleware specifically for that in http4s.
    Adam Rosien
    @arosien
    that's like an fp haiku
    run map apply
    map lift
    map map lift
    grasshopper
    Anton Solovyev
    @Rosteelton
    @rzeigler I can't get one moment. In that case I will get Client[Kleisli[F, Span[F], *]. But all my code there doesn't know anything about Kleisli (I have only F[_]: Trace)
    Ryan Zeigler
    @rzeigler
    So, what I would suggest you do is write http4s client middleware that does what you want. If the F[_] is in fact Kleisli[F, Span[F], *] then you can decorate the client ahead of time.
    You would do this while your are wiring up your client and you should be mostly operating in concrete monads anyway
    Christopher Davenport
    @ChristopherDavenport
    Right, pass in your client as an argument that's already middlewared up.
    Bradford Toney
    @bluemoon
    So i'm looking to implement natchez and I understand that kleisli does not work with ConcurrentEffect, some of my program has it anyways. If I'm trying to work around it do I want do something like keeping my effect as F[_] and then using Kleisli.liftK on the specific code I'm working with or are there better ways to do this? (I'm fairly new to Kleisli and how best to handle this)
    Ryan Zeigler
    @rzeigler
    So, one thing that is worth mentioning, you can usually implement an algebra in F that requires ConcurrentEffect and then use FunctorK type things to lift into the Kleisli. You won't be able to trace through the algebra that needs the ConcurrentEffect bound, but you can integrate it in the rest of the system. The implementation of mapK can sometimes even be done for you using cats-tagless.
    Bradford Toney
    @bluemoon
    That makes sense, it sounds like i'll need to "flatten" (reconfigure the bounds of ConcurrentEffect) some of my algebras so that it works nicely, I'll have a look at cats-tagless as well
    Gavin Bisesi
    @Daenyth
    :wave: Hey folks. Is there a microsite for natchez, or any documentation beside scaladoc+readme?
    @bluemoon it doesn't help you today, but some good news: in CE3 you won't have that problem
    Rob Norris
    @tpolecat
    @Daenyth no, it needs doc. Note the version number. People just started using it anyway.
    Gavin Bisesi
    @Daenyth
    No criticism on that score :)
    just scoping out what's there - it's an ecosystem niche with no mature options
    natchez generally should beat "do it in-house" regardless of version
    Rob Norris
    @tpolecat
    I would welcome any contribution on that front. There’s not a lot to it really.
    Generalizing the Kleisli instance to Local would also be good.
    Gavin Bisesi
    @Daenyth
    I'm not familiar enough with the tooling to know what needs doing
    if there was a baseline "just copies the readme" microsite with editable pages that's probably enough to start gathering PRs
    Rob Norris
    @tpolecat
    There's a lot going on. I need to make a persistent branch for ce3 and I can copy/paste the doc setup from skunk while I'm in there.
    Gavin Bisesi
    @Daenyth
    :+1:
    Ryan Zeigler
    @rzeigler
    Related to the Kleisli instance we actually have a LensedSpan type class that we use to pack different bits it with the span and produces Trace using the explicit lens operation on Kleisli trace. I can PR this if something you would want (and it would save us in the long term from a random implicit import).
    We are a little behind I just hate upgrading those components because grpc has no concept of compatibility from what I can tell
    Rob Norris
    @tpolecat
    Yeah I need to look at how the auto-lens stuff works.
    There are way too many fires burning atm. Between Scala 3 and CE3 there's not a lot of time for extinguishing other things.
    Keir Lawson
    @keirlawson
    Anyone any success combining Natchez with fs2? struggling a little as to how to combine .span which wants a Kleisli[F, Span[F], A] and the type I want to produce which is a fs2.Stream[Kleisli[F, Span[F], *], A]
    Ryan Zeigler
    @rzeigler
    Are you trying to track how long the entire stream runs or individual operations within it?
    Keir Lawson
    @keirlawson
    The entire stream
    Ryan Zeigler
    @rzeigler
    You can stick a span around the compile action.
    i.e. Trace[F].span(“stream”)(s.compile.drain)
    Rob Norris
    @tpolecat
    There is a lingering PR to create a Trace instance for streams but I haven’t had any time to think about it.
    Keir Lawson
    @keirlawson
    @rzeigler I'm wanting to pass back the traced stream elsewhere though, rather than turn it into an F at the point of adding the tracing
    Ryan Zeigler
    @rzeigler
    So, the alternative option (and I haven't really exploded this, is that spans are resources yourself. I think you could probably define a pipe that traces a stream and does something like
    Stream.eval(Kleisli.ask).flatMap(span => Stream.resource(span.subspan("name"))) >> innerStream
    Adam Rosien
    @arosien
    exploding spans are definitely cool
    Ryan Zeigler
    @rzeigler
    I swear, sometimes my brain explodes. I wish I could play that off like phone autocorrect, but I definitely typed it on a keyboard.
    Adam Rosien
    @arosien
    does flatMap prevent exploding spans? nobody knows.
    Keir Lawson
    @keirlawson
    @rzeigler your solution seems (as in it compiles :D ) to work for me with a little sprinkling of mapKs and translates to make everything line up :)
    Keir Lawson
    @keirlawson
    Generalising slightly from the above problem, so far as I can see if I have F[_] : Trace there's no way to have Stream[F, A] that embeds a subspan without wrapping in an F[_] given the present Trace API, unless I specifically assume that F is Kleisli, is this correct? If so this seems to be a bit of a pain point for writing transparent wrappers around other libs that inolve Stream, perhaps the API could be adjusted to accomodate scenarios like this?
    Rob Norris
    @tpolecat
    Trace[F] should imply Trace[Stream[F
    There is a WIP out there somewhere
    Keir Lawson
    @keirlawson
    I find myself copying and pasting convenience code to make Natchez' Trace constraint place nice with munit-cats-effect between various projects and I was wondering if it would make sense to A. add an munit module to Natchez, B. add a Natchez module to munit-cats-effect, C. create a library independent of the two or D. not bother cos its only a wee bit of code
    (asking here as there isn't really a channel for munit-cats-effect)
    Rob Norris
    @tpolecat
    I hesitate to add more stuff to natchez at this point, I was actually thinking of busting it up.