These are chat archives for exceptionless/Discuss

4th
Mar 2016
Eric J. Smith
@ejsmith
Mar 04 2016 14:03
morning everyone. :-)
@niemyjski how is the logging conversion going?
Blake Niemyjski
@niemyjski
Mar 04 2016 14:36
eh
just doing support
and there is a lot of it
mayrlou is slacking
she doesn’t email and drive? :D
Eric J. Smith
@ejsmith
Mar 04 2016 14:36
guess not
Blake Niemyjski
@niemyjski
Mar 04 2016 14:36
@ejsmith your stats changes are giving me tons of headaches
Eric J. Smith
@ejsmith
Mar 04 2016 14:37
cool :-)
don’t come skiing unless its done. :-)
Blake Niemyjski
@niemyjski
Mar 04 2016 14:37
Screen Shot 2016-03-04 at 8.37.11 AM.png
also, I’m not sure how logging is injected in the test projects
need to take a look at that
I brought in TestWithLoggingBase
but
yeah
not sure how that works
brb
Eric J. Smith
@ejsmith
Mar 04 2016 14:43
the display stats calls need to go away, but I would like to create an easier way to output them to the log… it’s kind of a pain right now.
Blake Niemyjski
@niemyjski
Mar 04 2016 14:54
yeah
I agree
Blake Niemyjski
@niemyjski
Mar 04 2016 15:01
I’m going to say you dropped 10 IQ points watching that and now I want to push you down a mountain
lol
Eric J. Smith
@ejsmith
Mar 04 2016 15:02
haha
Blake Niemyjski
@niemyjski
Mar 04 2016 15:02
DAAM eric
Eric J. Smith
@ejsmith
Mar 04 2016 15:02
LOL
welp
making great progress over here
Blake Niemyjski
@niemyjski
Mar 04 2016 15:12
Screen Shot 2016-03-04 at 9.12.11 AM.png
The constructor of type InMemoryMetricsClient contains parameter 'buffered' of type Boolean which can not be used for constructor injection because it is a value type.
Eric J. Smith
@ejsmith
Mar 04 2016 15:13
yeah, none of the services can just be created, you are setting configuration in the ctor
queues, storage, etc
I have thought about changing those up to use a configuration object instead of a bunch of params.
but you would still need to do something in the container.
Blake Niemyjski
@niemyjski
Mar 04 2016 15:15
changed from Register<IMetric, InMemory..>() to
container.RegisterSingleton<IMetricsClient>(() => new InMemoryMetricsClient(loggerFactory: loggerFactory));
think we should pass in the logger factory here
?
Eric J. Smith
@ejsmith
Mar 04 2016 15:15
depends on where.
in the apps.. don’t know that we need to use logging.
Blake Niemyjski
@niemyjski
Mar 04 2016 15:16
ok
Eric J. Smith
@ejsmith
Mar 04 2016 15:16
guess if it’s just logging errors
Blake Niemyjski
@niemyjski
Mar 04 2016 15:16
eh
Eric J. Smith
@ejsmith
Mar 04 2016 15:16
guess we probably do want that.
if they get an error it should probably be in our logs.
so I guess we probably should do that.
Blake Niemyjski
@niemyjski
Mar 04 2016 15:24
namespace Exceptionless.Api.Tests.Jobs {
public class JobBootstrapper : BootstrappedServiceProviderBase {
protected override IServiceProvider BootstrapInternal(ILoggerFactory loggerFactory) {
I don’t get how loggerFactory would ever be set there
public JobTests(ITestOutputHelper output) : base(output) {
ServiceProvider.SetServiceProvider(typeof(JobBootstrapper));
}
    [Fact]
    public async Task CanRunJobWithNoBootstrapperAsync() {
        var job = new JobRunner(Settings.Current.GetLoggerFactory()).CreateJobInstance(typeof(TestJob).AssemblyQualifiedName);
but yet we are passing it in to JobRunner
doesn’t make any sense
unless it flows through from the ctor of JobRunner
Eric J. Smith
@ejsmith
Mar 04 2016 15:26
it flows into the bootstrapper from the jobrunner
then you need to register it in the container in the bootstrapper
why are you doing typeof(TestJob).AssemblyQualifiedName ?
hmm… that is creating a job instance, not running it.
Blake Niemyjski
@niemyjski
Mar 04 2016 15:28
yeah
and my bootstrapper isn’t getting it
Eric J. Smith
@ejsmith
Mar 04 2016 15:29
look at mine.
public class FoundatioBootstrapper : BootstrappedServiceProviderBase {
    protected override IServiceProvider BootstrapInternal(ILoggerFactory loggerFactory) {
        container.RegisterLogger(loggerFactory);
    public static void RegisterLogger(this IServiceProvider serviceProvider, ILoggerFactory loggerFactory) {
        var container = serviceProvider as Container;
        if (container == null)
            return;

        container.RegisterSingleton<ILoggerFactory>(loggerFactory);
        container.RegisterSingleton(typeof(ILogger<>), typeof(Logger<>));
    }
Blake Niemyjski
@niemyjski
Mar 04 2016 15:30
yeah
that happens in the core project
but here it’s null
because it isn’t set inside of the bootstrap internal
Eric J. Smith
@ejsmith
Mar 04 2016 15:31
here where?
Blake Niemyjski
@niemyjski
Mar 04 2016 15:31
inside of my bootstrapper
Eric J. Smith
@ejsmith
Mar 04 2016 15:31
you have to pass it into the JobRunner
new JobRunner(loggerFactory)
Blake Niemyjski
@niemyjski
Mar 04 2016 15:31
namespace Exceptionless.Api.Tests.Jobs {
public class JobBootstrapper : BootstrappedServiceProviderBase {
protected override IServiceProvider BootstrapInternal(ILoggerFactory loggerFactory) {
var container = new Container();
container.Options.AllowOverridingRegistrations = true;
I am
public class JobTests : TestWithLoggingBase {
    public JobTests(ITestOutputHelper output) : base(output) {
        ServiceProvider.SetServiceProvider(typeof(JobBootstrapper));
    }

    [Fact]
    public async Task CanRunJobWithNoBootstrapperAsync() {
        var job = new JobRunner(Settings.Current.GetLoggerFactory()).CreateJobInstance(typeof(TestJob).AssemblyQualifiedName);
        Assert.NotNull(job);
        Assert.Equal(0, TestJob.RunCount);
        Assert.Equal(JobResult.Success, await job.RunAsync());
        Assert.Equal(1, TestJob.RunCount);
    }

    [Fact]
    public void CanRunJobWithBootstrapper() {
        var job = new JobRunner(Settings.Current.GetLoggerFactory()).CreateJobInstance(typeof(EventPostsJob).AssemblyQualifiedName);
        Assert.NotNull(job);
    }
}
I also think TestWithLoggingBase should expose the logger factory
Eric J. Smith
@ejsmith
Mar 04 2016 15:32
it does
Log
d
Blake Niemyjski
@niemyjski
Mar 04 2016 15:33
hmm
Blake Niemyjski
@niemyjski
Mar 04 2016 15:39
    public JobBase CreateJobInstance(string jobTypeName) {
        var jobType = TypeHelper.ResolveType(jobTypeName, typeof(JobBase), _logger);
        if (jobType == null)
            return null;

        return CreateJobInstance(jobType);
    }

    public JobBase CreateJobInstance(Type jobType) {
        if (!typeof(JobBase).IsAssignableFrom(jobType)) {
            _logger.Error("Job Type must derive from Job.");
            return null;
        }

        var job = ServiceProvider.Current.GetService(jobType) as JobBase;
        if (job == null) {
            _logger.Error("Unable to create job instance.");
            return null;
        }

        return job;
    }
look it only passes the _logger to one of them and not the logger factory
hmm
looks like it’s getting it from the di system
and not flowing it through
kinda stinks a bit
but not sure what all we can do
be back in a bit
I’m going to go get breakfast and run some quick errands
Eric J. Smith
@ejsmith
Mar 04 2016 15:42
its not going to work if you don’t bootstrap.
you have to register it in your container.
Foundatio doesn’t know what container you use.
so just creating a job instance like that without a bootstrapper isn’t going to get logging.
unless you register it in your container before.
that looks pretty cool.
Blake Niemyjski
@niemyjski
Mar 04 2016 16:26
Cool
Eric J. Smith
@ejsmith
Mar 04 2016 16:54
Swift seems to be taking off like a rocket.
language seems pretty nice.
Blake Niemyjski
@niemyjski
Mar 04 2016 17:02
Yeah let's rewrite lol
Eric J. Smith
@ejsmith
Mar 04 2016 17:18
nice
Blake Niemyjski
@niemyjski
Mar 04 2016 17:36
@ejsmith are there tests for the stats stuff
Screen Shot 2016-03-04 at 11.35.49 AM.png
cause it seems broken
Blake Niemyjski
@niemyjski
Mar 04 2016 18:04
@ejsmith is there any reason our metric tests shouldn’t share a base class
kinda crazy..
Eric J. Smith
@ejsmith
Mar 04 2016 18:06
buffered
you have to flush them
if you are going to check immediately.
or disable buffering
Blake Niemyjski
@niemyjski
Mar 04 2016 18:06
yeah
should have disabled buffering and then tests specific to buffering
..
Eric J. Smith
@ejsmith
Mar 04 2016 18:07
where is that test?
Blake Niemyjski
@niemyjski
Mar 04 2016 18:07
in exceptionless
using the in memory metrics client..
Eric J. Smith
@ejsmith
Mar 04 2016 18:07
why do you have a test for seeing if the metrics work?
that should be in Foundatio
Blake Niemyjski
@niemyjski
Mar 04 2016 18:08
idk
we did
and it’s failing
so it’s a good thing
Eric J. Smith
@ejsmith
Mar 04 2016 18:08
well delete it
its buffered
it will fail
Blake Niemyjski
@niemyjski
Mar 04 2016 18:08
how is anyone supposed to know that
was a bad change in my mind to go from a metrics client that wasn’t buffered
to one that is
and now it’s going to break everything to unspecting people
Eric J. Smith
@ejsmith
Mar 04 2016 18:09
lol
Blake Niemyjski
@niemyjski
Mar 04 2016 18:09
I had no indication it was buffered
Eric J. Smith
@ejsmith
Mar 04 2016 18:09
the statsd metrics client was buffered
Blake Niemyjski
@niemyjski
Mar 04 2016 18:09
how long is it buffered for
well the one I was testing was in memory
and I waited a few minutes and reset the executing line and it was never flushed
are all of them buffered/non buffered?
Eric J. Smith
@ejsmith
Mar 04 2016 18:10
stats should be buffered dude they are being hit like crazy
turn it off in your tests
stop being a nub
and remove that test… Foundatio has tests for that.
Blake Niemyjski
@niemyjski
Mar 04 2016 18:12
our tests would be easier if IMetricsClientStats inheired IMetricsClient
Eric J. Smith
@ejsmith
Mar 04 2016 18:13
why would it do that?
makes no sense
Blake Niemyjski
@niemyjski
Mar 04 2016 18:14
    public abstract IMetricsClientStats GetMetricsClient(bool buffered = false);

    public virtual async Task CanSetGaugesAsync() {
        var client = GetMetricsClient();
        if (client == null)
            return;

        await client.GaugeAsync("mygauge", 12d);
        var stats = await client.GetGaugeStatsAsync("mygauge");
        Assert.Equal(12d, (await client.GetGaugeStatsAsync("mygauge")).Last);
        await client.GaugeAsync("mygauge", 10d);
        await client.GaugeAsync("mygauge", 5d);
        await client.GaugeAsync("mygauge", 4d);
        await client.GaugeAsync("mygauge", 12d);
        await client.GaugeAsync("mygauge", 20d);
        Assert.Equal(20d, (await client.GetGaugeStatsAsync("mygauge")).Last);
    }
so I could do something like that
instead of doing extra checks
Eric J. Smith
@ejsmith
Mar 04 2016 18:14
again, is this freakin test in Exceptionless?
Blake Niemyjski
@niemyjski
Mar 04 2016 18:14
would someone ever implement IMetricClientStats without implementing IMetricsClient
Eric J. Smith
@ejsmith
Mar 04 2016 18:14
because it shouldn’t be there.
Blake Niemyjski
@niemyjski
Mar 04 2016 18:14
I’m moving this to foundatio ffs
cause there isn’t a gauge tests
and there should be
@ejsmith can I add an interface for IBufferedMetricsClient
that has a single flush method
Blake Niemyjski
@niemyjski
Mar 04 2016 18:40
mother trucker
never got latest
and I should have
Blake Niemyjski
@niemyjski
Mar 04 2016 18:52
@ejsmith
exceptionless/Foundatio@f6c648f
makes me feel a bit better :D
wish we could do the same for statsd but I’m fine with it now
Eric J. Smith
@ejsmith
Mar 04 2016 18:56
I have another one for queue stats
Blake Niemyjski
@niemyjski
Mar 04 2016 18:57
ah
Eric J. Smith
@ejsmith
Mar 04 2016 18:57
its in the queue tests right now… maybe should be with the metrics
Blake Niemyjski
@niemyjski
Mar 04 2016 18:57
I already closed the solution
yeah
can you update that
I want to finish with this migration
just got all the logging stuff converted and all tests pass
Eric J. Smith
@ejsmith
Mar 04 2016 18:59
nice!
Blake Niemyjski
@niemyjski
Mar 04 2016 19:00
now onto automapper
lol
just pushed a branch
Eric J. Smith
@ejsmith
Mar 04 2016 19:05
the automapper changes were easy.
Blake Niemyjski
@niemyjski
Mar 04 2016 19:05
yeah
going to do that now
:)
Eric J. Smith
@ejsmith
Mar 04 2016 19:06
cool
if only some damn guy that you knew would update their ES client.
Blake Niemyjski
@niemyjski
Mar 04 2016 19:08
I’m going to get on them right now
Eric J. Smith
@ejsmith
Mar 04 2016 19:09
Niemyjskify™ that dude!
Blake Niemyjski
@niemyjski
Mar 04 2016 19:12
asked him
Eric J. Smith
@ejsmith
Mar 04 2016 19:13
he is blocking everyone
bug fix in there that we need and blocking us from upgrading to JSON.NET 8 which has some big perf improvements.
Blake Niemyjski
@niemyjski
Mar 04 2016 19:15
yeah
Blake Niemyjski
@niemyjski
Mar 04 2016 23:41
wish I could find the person doing botnets and spam and curb stomp them
:)