Structured Logging with Serilog and ELK

ThoughtWorks recently released their Technology Radar report for January 2015 and structured logging was among the techniques that they strongly suggested that the industry adopt. I’ve actually had some exposure to structured logging over the past year and have been very happy with the results. So, I thought I would share my experience. My first exposure to structured logging was in early 2014. I was creating a simple Python application to monitor the amount traffic through my modem throughout the day and I was logging events from my application to logentries....

February 23, 2015

Go-YAML Field Names

I wasted away a good thirty minutes trying to figure out why I couldn’t parse my YAML config file this morning using go-yaml. package main import ( "fmt" "log" "gopkg.in/yaml.v2" ) var configText = ` Message: Welcome UpdateInterval: 5 EmailAddresses: - john.doe@example.com - jane.doe@example.com` type Config struct { Message string UpdateInterval int EmailAddresses []string } func main() { var c Config if err := yaml.Unmarshal([]byte(configText), &c); err != nil { log....

February 14, 2015

Assertions in Moq Callbacks

I learned an important lesson today: do not assert inside of Moq callbacks. In the code below, even if the Assert.AreEqual fails, it will not cause the unit test to fail. moqObj.Setup(m => m.Doit(It.IsAny<string>())).Callback<string>((s) => { Assert.AreEqual("foo", s); }); // Insert test code that invokes `Doit` You could use Verify instead, but it’s not always ideal, particularly when trying to step through the assertions while debugging tests. Instead, you can take this approach suggested by Thomas Ardal....

February 9, 2015

A New Look for 2015

I have wanted to revamp my website for close to a year now. In that time I’ve looked into different blogging engines and tried creating new themes, but I didn’t settle on a path forward until a couple weeks ago. Engine At one point I considered moving to a statically generated site since they were all the rage. I tried out Jekyll and Middleman. I liked both and even wrote up a post on using Zurb’s Foundation with Middleman....

February 2, 2015

Google Analytics Site Speed for Small Websites

If you’re running a small website and using Google Analytics, your site speed metrics graph might look empty. If you don’t get a lot of traffic there will be no samples to measure site performance. This is because the default sampling rate is only 1% (i.e. site speed metrics will only be collected for 1% of your visitors). This is plenty if your running a big site with tons of visitors per day, but if your running a smaller site this isn’t going to be good enough....

January 25, 2015