-
Notifications
You must be signed in to change notification settings - Fork 585
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
Tracing Updates #2009
Tracing Updates #2009
Conversation
The only places where tracing is typically done is when shelling out to other applications. AssemblyInfoFile is completely within FAKE so it seems weird to trace these tasks as standard. Is someone requires tracing, they can wrap the call to these functions themselves
Yes removing tracing from assemblyinfofile is one version. I noticed that they produce quite a lot of output. However, in an ideal world we would be able to control this better instead of removing them (Actually you can by implementing a custom ITraceListener. For example we could decide to only "show" top-level tasks and not print others (or make that opt-in on verbose) Regarding the What do you think? |
I removed because it was inconsistent...happy to leave it in. |
Both changes are fine (and I agree we need changes here). I'm happy to take them as-is. Just trying to explain why those changes in particular have not been made yet. Maybe we should ask on twitter if people have better ideas then the |
Oh I get you now, sorry I misunderstood. I'm not sure what you mean by function suffix (do you mean passing the function as a delegate) |
@BlythMeister It's just about the name of the new functions... |
Oh right! |
@matthid how about simplifying to tracefn and tracefnAuto? |
@matthid i've updated the function names having the word task and function made no sense...i'm not sure what else to call them because essentially they are tracing a function :S |
# Conflicts: # src/app/Fake.Core.Target/Target.fs # src/app/Fake.Core.Trace/TraceListener.fs
🎉 it builds 😄 |
I have over 100 projects in a repo...this spamming 100 log lines isn't that useful. If this level is required, then you can trace around the calls to save the assembly info
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.
Some hints regarding latest changes and another idea for the high-order function.
@@ -15,6 +17,8 @@ type KnownTags = | |||
match x with | |||
| Task n | |||
| Target n | |||
| FinalTarget n | |||
| FailureTarget n |
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 a breaking change and you need to update the various listeners (AppVeyor, Travis, ...) to handle these new cases.
Problem is we don't have warning as errors on for "missing cases on match"
An alternative would be to add the info to the Target
case and add a "Targettype" or something like that.
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.
The only listener which mentions Target is the console one, so i didn't think this would be a breaking change...
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.
Ok makes sense, so we go like this because adding another TargetType
would most likely be more breaking.
src/app/Fake.Core.Target/Target.fs
Outdated
let target = get name | ||
runSimpleContextInternal target context) context | ||
let target = get name | ||
use t = Trace.traceFailureTarget target.Name (match target.Description with Some d -> d | _ -> "NoDescription") (dependencyString target) |
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.
instead of "NoDescription"
we use null
now and properly handle that case in the listeners.
A better solution would be to use string option
(which now is at the table considering the more breaking addition - see other comment), see #1996
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.
Updated and have also made this a string option and fixed all the listeners we have.
src/app/Fake.Core.Trace/Trace.fs
Outdated
/// Traces a function execution | ||
/// If no exception is thrown then trace is marked as success | ||
/// Any exception thrown will result in a mark failed and exception re-thrown | ||
let traceFunction name description func = |
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.
What about an in-line high order function
useWith (traceTask name description) (fun _ ->
// callback
)
implemented like
let inline useWith (d:ISafeDisposable) f =
use t = d
try let result = f () in t.MarkSuccess(); result with _ -> t.MarkFailed(); reraise()
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 like it, implemented :)
@matthid updates made following your review :) |
src/app/Fake.Core.Trace/Trace.fs
Outdated
/// Traces a function execution | ||
/// If no exception is thrown then trace is marked as success | ||
/// Any exception thrown will result in a mark failed and exception re-thrown | ||
let inline useWith (d:ISafeDisposable) f = |
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 it looks quite reasonable. I guess there are two versions, one where MarkSuccess
is automatic and one where it is explicit.
I guess we could have either 2 functions or a boolean parameter. We could forward the t
to f
in order to allow f
to change it's state internally.
(Reason is that calling nothing is equal to inconclusive
)
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.
Because the signature of f would be different it had to be 2 functions.
I wonder if we really need the manually set one or if we can just have the automatic one
Another design would be
instead of
with reversed parameters |
@matthid backing out the string option stuff....that is seriously breaking! |
This should be done (if it builds) |
Actually I like the pipe into Trace.useWith...seems cleaner. I'll update to be like that tomorrow |
@BlythMeister What was the error, is it on CI somewhere? |
There were over 100 places which needed updating to pass a string option rather than string.. |
Yes because the change bobbled to the top, which could be prevented. But I'm okish with using |
Yeah I think separating so we sort that typing later would be good. I'll have another play with the trace wrapper function and see if I can get something which fits nicely. |
@matthid ok i think i've found a nice way to get this to work :) Manual mode
Automatic mode
In both cases, if the func raises an exception, the trace is set to failed (even if you have called I've also put the |
I thought it would need to be |> Trace.useWith (Trace.Manual(fun t -> Because of Also I have no problem with providing the |
You know what...your right. I'll simplify tomorrow (England football tonight 😂) |
@matthid hopefully that's the last change :) |
Sorry for the back and forth... |
No need to be sorry, i really enjoy adding stuff and the back and forth! |
@matthid if your happy with this change now, any ideas when we can get it in? |
Everything looks good, it will probably be part of the next 5.1.1 or 5.2 (more likely) release. This is kind of hard to check in the github PR view. |
Is there a way to get a nuget package with this (and any other pre-release)? |
If staging is fine I can merge it and look later. Problem with staging (currently) is that packages are deleted after two versions (basically two commits on release/next) this means you need to update often when I'm working on it and builds might break... (we got 1gb space on myget and that is basically just a couple of deployments, because we push so much stuff) |
That works for me...I'm currently re working our company build tools (hence so many prs) so I can live with fragile...what is the myget URL? |
@BlythMeister Ok it is available after the build finished, the URLs are documented here: https://fake.build/contributing.html#Staging-environment Staging is automatically deployed and always the latest state of the release/next branch (current PR: #2011). (Well the latest green vsts build to be exact). After the build finished it takes a couple of minutes to be available. |
Remove tracing from Assembly file. Tracing seems to be used when calling out to external process, but this function does not do that, so seems silly
Add wrapper functions for tracing, can be used as follows: