-
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
Utility for creating an no-op Tracer #206
Comments
Personally, I don't find it cumbersome to set up tracing normally even if not needed (yet). You can use Concretely having loadApp f = do
-- ...
- withTracerProvider $ tracerProvider -> do
- let appTracer = makeTracer tracerProvider "my-app" tracerOptions
- f App {..}
+ appTracer <- noTracer
+ f App {..} ? It doesn't seem like a huge win to me, but I guess I'm not against it existing so 👍 That said, I think I'm smelling a bit of a design flaw here. Before saying more, what are the specifics of where you hit this? Which functions require |
It's |
It's a service that handles requests for "Demo Districts" -- instances of Freckle with "demo" data used for sales. I think tracing would be great there.
Ideally these would use
Don't these use |
Alright but what if I just don't want to do that right now
The tracing that is common to all HTTP requests is hidden under the |
It's exactly the same use case as NoLoggingT. Sometimes a tool you're using outputs extra information (logging, tracing, same thing), sometimes you want it, sometimes you don't. |
Today? Still set up tracing in the code (it's like 2 lines) and use
"a utility" here is (a function in) |
I think this is the incorrect design I'm smelling. It's that |
(To reiterate: if you want to implement Maybe what I'm feeling is this: any given app should decide if its one of two styles.
(1) should use (2) should use A function like Back to the concrete example: 🤷 |
What is the runtime, though? I have no idea what this application is for or where it's run. Since this thing hits the production database, it is theoretically just as capable of causing an incident as anything else, so tracing on it would be good.
No, it's calling utilities in various other packages in
Truly has nothing to do with it
Yes, my preferred approach here would have been to define a newtype to something like
So although I can define instance MonadIO m => MonadTracer (NoTracer m) where
getTracer = liftIO noTracer Is this a problem? I'm not really sure, I don't know what the I/O that constructs the tracer provider is or whether it's too expensive to repeat every time you do a tracing operation. Alternatively... what do you think about just shoving it into an noTracer :: Tracer
noTracer = unsafePerformIO $ do
tracerProvider <- createTracerProvider [] emptyTracerProviderOptions
pure $ makeTracer tracerProvider "" tracerOptions
newtype NoTracer m a = NoTracer (m a)
deriving newtype (Functor, Applicative, Monad)
instance Monad m => MonadTracer (NoTracer m) where
getTracer = pure noTracer |
Anyway I put in a task to add the telemetry so hopefully that thought doesn't get lost. |
Yup, I think we've already agreed there.
Ah right. The app is not
Apologies. I thought, instance (MonadUnliftIO m, HasTracer app) => MonadHttp (AppT app m) where Was at least part of your issue. And you said some things that I mistook as confirmation. Nevermind.
I don't see how it's necessary. Why doesn't the loadApp f = do
-- ...
appTracer <- noTracer
f App {..} |
It does, and that's what I'm currently doing, but I thought we wanted to arrive at a solution that could be used only with deriving-via and didn't require adding the |
Oh sorry, no that's not what I meant by
I'm not sure what exactly I meant there, but whatever it was, it was a solution to a different problem anyway. What I thought the problem was: I want to use Your actual problem: I want to use a bunch of stuff in my own app ( |
I just had the annoyance of adapting an application that doesn't use tracing to a library that does; I need a no-op
Tracer
to satisfy aMonadTracer
constraint.It would be neat if
MonadTracer
were actually something likegetTracer :: m (Maybe Tracer)
rather thanm Tracer
.Alternatively it would be nice to just have a utility for easily creating a do-nothing
Tracer
.The text was updated successfully, but these errors were encountered: