Skip to content
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

[WIP] #96 dotnet core support #204

Closed
wants to merge 62 commits into from
Closed

[WIP] #96 dotnet core support #204

wants to merge 62 commits into from

Conversation

TheAngryByrd
Copy link

@TheAngryByrd TheAngryByrd commented Nov 19, 2016

This is a work in progress. I've opened this PR early so I can get feedback.

This will add dotnet core support to Logary. Should close #96.

Things that I think need to be done, please correct me if I'm wrong:

  • Port core (Logary, Logary.CSharp)
  • Port tests (is Suave good reference material?)
  • Port adapters
  • Port services
  • Port metrics
  • Port targets
  • Update build script
  • Update CI
  • Figure out packaging story
  • Figure out signing

@TheAngryByrd
Copy link
Author

TheAngryByrd commented Nov 19, 2016

Might have a show stopper for now with StackFrame, which @haf has already commented on: https://github.com/dotnet/corefx/issues/1420#issuecomment-96288400

Looks like it is in net standard 2.0 https://github.com/dotnet/corefx/pull/12527/commits. From my understanding we'll have to wait till then. Unless anyone has a workaround.

@haf
Copy link
Member

haf commented Nov 20, 2016

I suggest that we simply remove GetCurrentLogger() from the .Net Core API until .Net standard 2.0 is the expected version so that we don't have to wait. Conditional compile until then.

@@ -1559,7 +1561,7 @@ module Message =

[<CompiledName "SetTimestamp">]
let setTimestamp (instant : Instant) msg =
{ msg with timestamp = instant.Ticks * Constants.NanosPerTick }
{ msg with timestamp = (instant |> Date.getTicks) * Constants.NanosPerTick }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer the non-piped version when you have only a single argument.

@TheAngryByrd
Copy link
Author

I do have Logary main compiling with a big hack regarding StackFrame: 25e3607#diff-7ec805bc41571a034ed354f519900efeR35

I'm sure this is WRONG and would cause problems but it does mean that's probably the only place we'll have problems.

@@ -597,14 +597,16 @@ module Debugger =
ack *<= () :> Job<_>

RingBuffer.take requests ^=> function
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of this target should be conditionally compiled if it doesn't exist on .Net Core. To be honest I never use it and I don't know if someone else it; it's just a 'hey - it's easy to create new targets'-target for me.

let hourly = FileAge (Duration.FromHours 1L)
let daily = FileAge (Duration.FromHours 24L)
let weekly = FileAge (Duration.FromHours (7L * 24L))
let everyMinute = FileAge (Internals.Date.Duration.fromMinutes 1L)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain a bit about why you modelled the API like this? E.g. isn't Date implying there's no time: hours, minute, seconds, millis etc?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just cruft from the Nodatime API changes. Should be back to normal soon.

@@ -1224,7 +1228,7 @@ module File =
if maxSize <= size then true else apply state rest
| FileAge maxAge :: rest ->
let created = Instant.FromDateTimeUtc(state.fileInfo.CreationTimeUtc)
let age = created - clock.Now
let age = created - (clock |> Internals.Date.getInstant)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Single arg, then don't use |>

@@ -71,7 +71,7 @@ module Impl =
/// All graphite messages are of the following form.
/// metric_path value timestamp\n
let createMsg (path : String) value (timestamp : Instant) =
let line = String.Format("{0} {1} {2}\n", path, value, timestamp.Ticks / NodaConstants.TicksPerSecond)
let line = String.Format("{0} {1} {2}\n", path, value, (timestamp |> Internals.Date.getTicks ) / NodaConstants.TicksPerSecond)
Copy link
Member

@haf haf Nov 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps extension method on Instant like instant.ticks? Why shim it in the first place? Can't NodaTime be upgraded instead? https://www.nuget.org/packages/NodaTime/2.0.0-alpha20160729

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I just didn't want to decide to update Nodatime on the full framework. But we totally could do just that and get rid of that nonsense.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's alright since v4 is still in beta. I haven't frozen the API yet, but we're really getting there. The last couple of weeks have brought tremendous improvements (IMO).

@TheAngryByrd
Copy link
Author

Since the tests are in expecto, should we bother porting them for now?

@haf
Copy link
Member

haf commented Dec 10, 2016

@TheAngryByrd Expecto got .Net Core support yesterday haf/expecto#4

@TheAngryByrd
Copy link
Author

So I just need to wait for the nuget package right?

@haf
Copy link
Member

haf commented Dec 12, 2016

Rebase needed. Expecto has had its PR merged https://github.com/haf/expecto/releases/tag/v2.0.0 and haf/expecto#4 but actually releasing a nuget with it is contingent on this improvement request in albacore: Albacore/albacore#221

Meanwhile expecto could be compiled with .net core support locally to further this PR.

@haf
Copy link
Member

haf commented Dec 12, 2016

I'm planning to make DVar a dependency for Logary https://github.com/haf/DVar/releases/tag/v0.1.0 – it's a single file of 125 lines of code that depends on System and System.Threading; so it will need to be ported – or rather – compiled – for .Net core as well.

This will enable the use-case of having targets transparently reconfiguring their endpoints based on load-balancing and services going up or down. Or another use-case could be load-balancing for a cluster (access to three different kafka-servers, rather than a single one), or another one could be client stickyness to a server.

The actual use-case I'm introducing it for is that Windows Performance Counters can suddenly "disappear" which means they have to be re-queried; this happens whenever more than one process with an identical executable-name is started and queries for its own performance counters.

@TheAngryByrd
Copy link
Author

TheAngryByrd commented Dec 12, 2016

Ok, I'll try to rebase it tonight.

For expecto, Have you compiled and referenced locally before? The only thing google is telling me is to create a nuget package and host it locally on my file system. Seems like a pain (but i guess this is .net core after all), any guidance is appreciated.

If you're planning on using paket files for the Dvar, it looks like it should just work. Probably just add to the project.json like: https://github.com/logary/logary/blob/102e7b99c3027452ca8ab7653a239813befd3435/src/Logary/project.json#L8

@haf-lynx
Copy link

haf-lynx commented Dec 15, 2016

Hi Jimmy,

Yes, you can compile it locally to create the package, then place the path of the folder that the nuget is in, inside a paket.local file. Then run paket.restore to override the public nugets with your local ones.

This should work for .Net core as well.

@haf haf mentioned this pull request Dec 19, 2016
@haf
Copy link
Member

haf commented Dec 19, 2016

This is only really blocked on Albacore/albacore#221 now.

@haf
Copy link
Member

haf commented Jun 28, 2017

The debugging may not be needed any more? https://github.com/haf/expecto/blob/master/.travis.yml#L28

@TheAngryByrd
Copy link
Author

TheAngryByrd commented Jun 28, 2017

I can get it to build on osx locally just fine, I'm just derping over travis for some reason.

@TheAngryByrd
Copy link
Author

Appveyor: Uhhh... what? Is expecto throwing on whitespace?

Albacore::CommandFailedError: Command failed with status (1):
  src\tests\Logary.Adapters.Facade.Tests\bin\Release\net462\Logary.Adapters.Facade.Tests.exe --sequenced 
ERROR unknown options: 

Travis: Whyyyyy, builds locally on osx fine

When using TimeScope
» should contain Running op message (FAIL)
Machine.Specifications.SpecificationException: Should contain "Running op" but is ""
  at Logary.CSharp.Tests.When_using_TimeScope+<>c.<.ctor>b__9_2 () [0x00000] in <8580c6f697cb454fa4a7f95b234c1ac6>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in <dbb16e0bacdc4a0f87478e401bc29b6c>:0 
» should contain Inner message (FAIL)
Machine.Specifications.SpecificationException: Should contain "Inner" but is ""
  at Logary.CSharp.Tests.When_using_TimeScope+<>c.<.ctor>b__9_3 () [0x00000] in <8580c6f697cb454fa4a7f95b234c1ac6>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parame

@haf
Copy link
Member

haf commented Jun 30, 2017

@TheAngryByrd My guess is that you've discovered that whitespace can indeed be passed as parameters to processes, just that you need to use the API of the operating system. It sounds like a parsing error in Argu stemming from this, rather than bugs in Expecto.

@TheAngryByrd
Copy link
Author

Curious as to why it's windows specific though. Guess I'll try to reprodice with Argu.

@Thorium
Copy link
Contributor

Thorium commented Oct 16, 2017

What is the .NET Coreapp 2.0 status for Logary? This 7/10 seems pretty good, last update at June, and now the Coreapp 2.0 is already released.

Could we get an alpha-Nuget-package, please? :-)

@TheAngryByrd TheAngryByrd mentioned this pull request Dec 5, 2017
@haf haf closed this Feb 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.net core support
4 participants