-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tracing-effectful package #11
Conversation
3d98bc1
to
def458b
Compare
def458b
to
0e505ba
Compare
Thanks 👍 I pushed a commit with a PoC that monomorphizes Can you clean it up? :) |
Oooh, that's very cool. Will gladly integrate and cleanup, thanks ! |
-> Eff es a | ||
runTracing actn = runTracing' actn . pure | ||
|
||
runTracing' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
runTracing' | |
runTracingMaybe |
Do you remember our conversation about functions with ticks at the end? ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did, but I was just mimicking what was done in Control.Monad.Trace
!
@@ -0,0 +1,114 @@ | |||
cabal-version: 3.0 | |||
-- The cabal-version field refers to the version of the .cabal specification, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove these cabal comments, they're quite noisy.
-- other-extensions: | ||
|
||
-- Other library packages from which modules are imported. | ||
build-depends: base ^>=4.17.2.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes it work with GHC 9.4 only. Also, please put upper bound for base
to be 5
so we don't have to bump it when updating GHC.
|
||
-- Extra doc files to be distributed with the package, such as a CHANGELOG or a README. | ||
extra-doc-files: CHANGELOG.md | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the tested-with
field (as is in tracing.cabal
) and regenerate CI with haskell-ci
(haskell-ci regenerate
in the repo root will do the job).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, that "Done" was a bit optimistic ! Took me quite a while to get the CI to build everything - oddly enough, some of the build plans seemed to be different between the CI and my own machine, though I switched to the same GHC and cabal version as the ones that failed on the CI. But this is now fixed.
48ab66a
to
82a2e34
Compare
82a2e34
to
2ee6557
Compare
instance (MonadBaseControl IO m, MonadIO m) => MonadTrace (TraceT m) where | ||
traceWith :: Builder -> Scope -> (Scope -> IO a) -> IO a | ||
traceWith bldr parentScope f = do | ||
let mbParentSpn = scopeSpan parentScope |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't all these liftIO
calls redundant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course they are 🤦♂️ Fixed, as well as the liftBase
s in addSpanEntryWith
.
let mbTV = scopes >>= scopeTags | ||
for_ mbTV $ \tv -> liftBase . atomically . modifyTVar' tv $ Map.insert key val | ||
addSpanEntryWith scopes key (LogValue val mbTime) = do | ||
let mbTV = scopes >>= scopeLogs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, but liftBase
.
ed9f65b
to
4c35bd6
Compare
Also apply cabal-fmt to our cabal files while we're at it
4c35bd6
to
98c2710
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why you merged this since I wasn't finished with the review.
@@ -0,0 +1,3 @@ | |||
packages: | |||
. | |||
../ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is redundant, the cabal project file should be in the root only 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this, tracing-effectful tries to fetch the hackage version of tracking.
|
||
tested-with: GHC == { 8.10.7, 9.0.2, 9.2.8, 9.4.8, 9.6.4, 9.8.2 } | ||
tested-with: | ||
GHC ==8.10.7 || ==9.0.2 || ==9.2.8 || ==9.4.8 || ==9.6.4 || ==9.8.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this changed? Did you use cabal-fmt or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I used cabal-fmt. Do you prefer the { }
version ?
, aeson <=2.3 | ||
, base <5 | ||
, base16-bytestring <=1.1 | ||
, bytestring <=0.13 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why you added all these upper bounds here.
Upper bounds should be done with <
on major versions, which is really not the case here. Also, most of the times you can get away without adding any because they tend to be extremely annoying to update when bumping deps en masse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1°) I added them because the CI steps generated by haskell-ci requested them. I had originally blindly followed the CI, which suggested using cabal gen-bounds
, but of course this broke when testing against various GHC versions.
2°) I agreed they are extremely annoying, because I had to spend quite a while fixing them. I can remove the bound check on the CI if need be (and remove bounds in the cabal file right after). Would this be a good solution ?
I thought the PR was approved, I completely forgot there is no "approval required" before merging on this repo. |
This is a proposed solution to implement CORE-6093.
This has been tested on a dummy client like this:
I'd reaaaaaally wish to find a less ugly solution to the implementation of
traceWith
.I'll detail a bit the issue. We want to factorize code between the
MonadTrace
historic implementation and theTrace
effect, which is why I put it in a separate, callable function. It has to be a higher-order-function, so that our MonadTrace can give thelocal
function from itsMonadReader
, and so that ourTrace
effect can use the equivalentlocalStaticRep
.However, we can't have the whole
traceWith
function operate inMonadBaseControl IO m, MonadIO m
world, because if we do, the whole call has to be wrapped inunsafeEff_
... and then we can't uselocalStaticRep
because we're not inEff
anymore.I tried many things, and the last one I could find was to use
MonadMask
: sinceEff
has an instance, we can stay in Eff intraceWith
. We "just" have to provide a lifting function:liftBase
in ourMonadTrace
and the infamousunsafeEff_
in ourTrace
effect. There might be a better way to do it (there most likely is), but I'm not smart enough (or hopefully, not experienced enough with Effectful) to find it.(Also, splitting the
traceWith
function in two part, to get the part that actually produces thespn
on the one hand and the conditional branch on the other, would perhaps be a good improvement, but it's outside the scope of this PR).