<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
  
  <title>Sporadic Writings · Dan Baggott</title>
  <subtitle>Software engineer. Empiricist. Simplifier.</subtitle>
  <link href="https://www.dnbg.dev/feed.xml" rel="self" />
  <link href="https://www.dnbg.dev/" />
  <updated>2016-08-26T00:00:00Z</updated>
  <id>https://www.dnbg.dev/</id>
  <author>
    <name>Dan Baggott</name>
  </author>
  <entry>
    <title>The importance of re-evaluating habits</title>
    <link href="https://www.dnbg.dev/writings/the-importance-of-re-evaluating-habits/" />
    <updated>2016-08-26T00:00:00Z</updated>
    <id>https://www.dnbg.dev/writings/the-importance-of-re-evaluating-habits/</id>
    <content type="html">&lt;p&gt;A few minutes ago I was writing a unit test when I suddenly experienced a feeling that is most easily described as &amp;quot;joy&amp;quot;.  And in that flood of joy, I was reminded that it&#39;s a really good idea to periodically re-evaluate the habits of your life.&lt;/p&gt;
&lt;p&gt;The concept of &amp;quot;habits&amp;quot; often gets a bad rap due to its frequent association with the word &amp;quot;bad&amp;quot; and the inflexibility that habits imply.  Both of those are, in my opinion, unfortunate associations.  I&#39;m a strong believer in the idea that, with a bit &lt;sup class=&quot;footnote-ref&quot;&gt;&lt;a href=&quot;https://www.dnbg.dev/writings/the-importance-of-re-evaluating-habits/#fn1&quot; id=&quot;fnref1&quot;&gt;[1]&lt;/a&gt;&lt;/sup&gt; of self-awareness and focused attention, your habits can be curated and groomed so that the good ones are encouraged to flourish and the bad ones can be gently weeded out.  You can even consciously plant the seeds for new habits.&lt;/p&gt;
&lt;p&gt;Back to unit tests.  While I do have a deep appreciation of unit testing that perhaps even merits an &amp;quot;I ♥ Unit Tests&amp;quot; sticker, my happiness as it relates to testing is usually most profoundly felt when I&#39;m doing one of two things:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;refactoring or otherwise modifying pre-existing code and the code is accompanied by solid test coverage&lt;/li&gt;
&lt;li&gt;I&#39;m writing tricky code with lots of edge cases and I&#39;ve written my tests first and it&#39;s helping me to confidently nail the implementation&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;A few minutes ago, I was doing neither of these two things.  Instead, I was writing some very simple code that, although different in its details from what I&#39;ll show below was, more or less, exactly what you see below (I changed the specifics to avoid the distraction of domain details):&lt;/p&gt;
&lt;pre class=&quot;language-java&quot;&gt;&lt;code class=&quot;language-java&quot;&gt;    &lt;span class=&quot;token annotation punctuation&quot;&gt;@Test&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;shouldThrowExceptionForNegativeAccelerations&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;throws&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Exception&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token function&quot;&gt;assertThatExceptionOfType&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;IllegalArgumentException&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
                &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isThrownBy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&gt;&lt;/span&gt; vehicle&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;accelerate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
                &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;withMessage&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Acceleration must be &gt; 0&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&amp;quot;So, wtf?  Where&#39;s the joy in that?&amp;quot;&lt;/p&gt;
&lt;p&gt;The joy, for me, is in the sheer simplicity and readability of the code and the fact that, above all else, the &lt;em&gt;intent&lt;/em&gt;&lt;sup class=&quot;footnote-ref&quot;&gt;&lt;a href=&quot;https://www.dnbg.dev/writings/the-importance-of-re-evaluating-habits/#fn2&quot; id=&quot;fnref2&quot;&gt;[2]&lt;/a&gt;&lt;/sup&gt; of the code sings out clear as a bell.  The joy, for me, is in writing code using an API that is well-thought out and discoverable via auto-complete.  I didn&#39;t have to stumble around with documentation or find the right matchers to quickly do what I wanted to do.  And the joy, in this specific case, was being able to easily make an assertion around the exception type &lt;em&gt;and the message&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;In short, the joy I was feeling was because I was using &lt;a href=&quot;http://joel-costigliola.github.io/assertj/&quot;&gt;AssertJ&lt;/a&gt; for writing my assertions.  The reminder to re-evaluate my habits was because, despite AssertJ being &amp;quot;old news&amp;quot;, it&#39;s only within the last half-year that I finally stopped to look around and realized that my existing coding habits could be improved by switching to AssertJ.  My experience with switching to AssertJ pretty much exactly mirrors the experience I had when, several years ago, I switched to using &lt;a href=&quot;http://mockito.org/&quot;&gt;Mockito&lt;/a&gt; for mocks.&lt;/p&gt;
&lt;p&gt;And so, of course, now I&#39;m wondering what of my other coding habits need re-evaluating?  Any suggestions based on your own experiences of changed habits that brought you more joy (coding or otherwise)?&lt;/p&gt;
&lt;p&gt;Notes:&lt;/p&gt;
&lt;hr class=&quot;footnotes-sep&quot;&gt;
&lt;section class=&quot;footnotes&quot;&gt;
&lt;ol class=&quot;footnotes-list&quot;&gt;
&lt;li id=&quot;fn1&quot; class=&quot;footnote-item&quot;&gt;&lt;p&gt;Ok, sometimes a whole lot more than &amp;quot;a bit&amp;quot; &lt;a href=&quot;https://www.dnbg.dev/writings/the-importance-of-re-evaluating-habits/#fnref1&quot; class=&quot;footnote-backref&quot;&gt;↩︎&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;fn2&quot; class=&quot;footnote-item&quot;&gt;&lt;p&gt;Right up there with &amp;quot;does what it&#39;s supposed to do&amp;quot;, &amp;quot;clarity of intent&amp;quot; is one of the very top things I try to think about when I’m writing or reviewing code.  In fact, without the clarity, it&#39;s so much harder to even evaluate the code! &lt;a href=&quot;https://www.dnbg.dev/writings/the-importance-of-re-evaluating-habits/#fnref2&quot; class=&quot;footnote-backref&quot;&gt;↩︎&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content>
  </entry>
  <entry>
    <title>99.99% uptime in 6 simple steps</title>
    <link href="https://www.dnbg.dev/writings/uptime-in-6-steps/" />
    <updated>2016-08-23T00:00:00Z</updated>
    <id>https://www.dnbg.dev/writings/uptime-in-6-steps/</id>
    <content type="html">&lt;p&gt;The secret to building applications with rock-solid stability is shockingly simple:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;instrument the &lt;em&gt;f**k&lt;/em&gt; out of your application&lt;/li&gt;
&lt;li&gt;monitor the instrumentation&lt;/li&gt;
&lt;li&gt;experience problems&lt;/li&gt;
&lt;li&gt;fill in any instrumentation/monitoring gaps that would have helped you &lt;em&gt;notice or understand&lt;/em&gt; the problem sooner or more easily&lt;/li&gt;
&lt;li&gt;fix the root cause of the problem&lt;/li&gt;
&lt;li&gt;wait for the next problem&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;Robust applications do not spring forth fully formed as if from the head of Zeus, they evolve over time.&lt;/strong&gt; &lt;sup class=&quot;footnote-ref&quot;&gt;&lt;a href=&quot;https://www.dnbg.dev/writings/uptime-in-6-steps/#fn1&quot; id=&quot;fnref1&quot;&gt;[1]&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;The beauty of this heuristic is its simplicity and that it &lt;strong&gt;leverage the fact that you already have to deal with live site problems&lt;/strong&gt;; it also guarantees that you&#39;ll be working on shoring up your defenses against real-world problems and not imagined concerns.  Although simple in concept, it takes a surprising amount of discipline to execute on the plan as there&#39;s always the pressure to take short-cuts (or outright skip!) steps 4 and/or 5.&lt;/p&gt;
&lt;p&gt;For example, how many times have you seen a problem &amp;quot;fixed&amp;quot; by restarting a service?  Whatever time would have been spent fixing the actual issue is almost aways more than made up for by the cumulative time, distraction, and fatigue that would otherwise be wasted repeatedly responding to the same problem. &lt;sup class=&quot;footnote-ref&quot;&gt;&lt;a href=&quot;https://www.dnbg.dev/writings/uptime-in-6-steps/#fn2&quot; id=&quot;fnref2&quot;&gt;[2]&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;Similarly, when you&#39;re under pressure to get back to your other project, it&#39;s all too tempting to skip adding the instrumentation / monitoring that would have let you instantly understand what the underlying problem was in the first place.  Typically, the rationale is something like: &amp;quot;&lt;em&gt;I fixed the root problem, it won&#39;t happen again, and so I don&#39;t need to add any additional instrumentation or monitoring&lt;/em&gt;.&amp;quot; &lt;sup class=&quot;footnote-ref&quot;&gt;&lt;a href=&quot;https://www.dnbg.dev/writings/uptime-in-6-steps/#fn3&quot; id=&quot;fnref3&quot;&gt;[3]&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;The mistake with that line of thinking is that even if the same problem really won&#39;t ever happen again, &lt;strong&gt;adding the additional instrumentation / monitoring will help you more quickly understand and respond to &lt;em&gt;all problems of that same category&lt;/em&gt;.&lt;/strong&gt;  This is a critical point!  It&#39;s gaining the protection against entire classes of problems that is the key to step 4 and that allows you to, down the road, identify novel problems before they impact users.&lt;/p&gt;
&lt;p&gt;As a trivial example, if your JVM process crashed due to a memory leak, after you fix the underlying leak, you should still add the missing monitoring of the JVM&#39;s heap size (and possibly GC times, etc) so that all &lt;em&gt;future&lt;/em&gt; memory-related issues are recognized &lt;em&gt;before&lt;/em&gt; they crash or otherwise impair the JVM.&lt;/p&gt;
&lt;p&gt;Having successfully improved a number of applications using this iterative approach, I&#39;m convinced that the short-term costs of investing in improving existing systems is well worth the long-term gains.  Live applications that require little to no operational overhead and developer involvement are worth their weight in gold in terms of overall team productivity (not to mention end-user experience!). &lt;strong&gt;Interrupting in-progress work to put out a live fire is, besides being unpleasant, horribly inefficient and disruptive to the larger endeavor of succeeding at whatever it is you&#39;re trying to do.&lt;/strong&gt;  In the extreme cases, operational fatigue from regularly being in a reactive mode is a complete morale and productivity killer.&lt;/p&gt;
&lt;p&gt;What follows are some practical suggestions based on my personal experience.  The suggestions are, of course, neither comprehensive (they primarily focus on one aspect of monitoring Java-based applications) nor exclusive (there&#39;s lots of other routes you can take).  However, I can say that what follows has been validated in critical production systems -- including a core system that now handles millions of searches a day across a catalog of a billion products and through which a majority of company revenue flows.  If what I describe is compatible with your ecosystem, I&#39;m confident you&#39;ll be happy with the end results.&lt;/p&gt;
&lt;h4&gt;&lt;strong&gt;Avoid Tight Coupling (that includes monitoring!)&lt;/strong&gt;&lt;/h4&gt;
&lt;p&gt;One of the challenges of monitoring complex systems that can slowly (or quickly) creep up on you is that complex systems typically require similarly complex monitoring.  &lt;strong&gt;If you&#39;re not careful, you end up distributing &lt;em&gt;deep understanding&lt;/em&gt; of your application&#39;s internals into your monitoring system.&lt;/strong&gt;  This creates tight coupling between the two systems.  Needless to say, tight coupling, whether at a code-level or a systems-level, always creates fragility, is more difficult to maintain, and slows down development.  Seemingly trivial changes to your application end up cascading into your monitoring layer.  At best, you keep track of the dependencies and carefully make changes to the two systems in concert.  At worst, you&#39;re unpleasantly surprised by a bunch of alerts going off when you deploy and you end up either rolling back the release, disabling the alerts (hopefully temporarily!), or scrambling to update the monitoring.&lt;/p&gt;
&lt;p&gt;Although some amount of understanding of your applications by your monitoring layer is usually unavoidable, &lt;strong&gt;one simple way to avoid tight coupling is to make the system being monitored responsible for what constitutes a healthy internal state&lt;/strong&gt;.  When the application is in charge of self-reporting its healthiness, it&#39;s free to interrogate deep implementation details without having to explicitly surface those implementation details.  And suddenly, it&#39;s easy to evolve the monitoring as the implementation details change.  Moreover, b/c the code is living in one place, &lt;strong&gt;any friction to adding extensive monitoring of the health of your application&#39;s internals disappears.&lt;/strong&gt;  For one approach on how to do this, keep reading.&lt;/p&gt;
&lt;h4&gt;&lt;strong&gt;Dropwizard &amp;amp; Metrics&lt;/strong&gt;&lt;/h4&gt;
&lt;p&gt;At my current job, we&#39;ve been implementing a lot of our services using the Java framework &lt;a href=&quot;http://www.dropwizard.io/&quot;&gt;Dropwizard&lt;/a&gt;.  It self-describes itself as a &amp;quot;framework for developing ops-friendly, high-performance, RESTful web services.&amp;quot; In this context, what I really like about Dropwizard is the &amp;quot;ops-friendly&amp;quot; part.  And, specifically, the fact that it uses the &lt;a href=&quot;http://metrics.dropwizard.io&quot;&gt;Metrics&lt;/a&gt; library to expose a very simple but very powerful &lt;code&gt;/healthcheck&lt;/code&gt; endpoint over http. &lt;sup class=&quot;footnote-ref&quot;&gt;&lt;a href=&quot;https://www.dnbg.dev/writings/uptime-in-6-steps/#fn4&quot; id=&quot;fnref4&quot;&gt;[4]&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;You can &lt;a href=&quot;http://www.dropwizard.io/1.0.0/docs/manual/core.html#health-checks&quot;&gt;read up on health checks&lt;/a&gt; but, in short, what they give you is the ability to easily write a &amp;quot;small self-test which your application performs to verify that a specific component or responsibility is performing correctly.&amp;quot;  &lt;strong&gt;The &lt;code&gt;/healthcheck&lt;/code&gt; endpoint provides a &lt;em&gt;consistent hook across applications&lt;/em&gt; that allows your monitoring systems to interrogate the health of your applications without needing to understand a single implementation detail.&lt;/strong&gt;  Requests to the endpoint return a 200 status code if all of the internal health checks pass and a 500 status code if something is not healthy.  You won&#39;t be surprised that there&#39;s some friendly json to let you know what check(s) failed.&lt;/p&gt;
&lt;p&gt;Out of the box, Dropwizard comes with a check to verify that there are no thread deadlocks and, beyond that, you&#39;re heavily encouraged to write your own checks.  &lt;em&gt;Lots of them.&lt;/em&gt;  Checks are incredibly simple to write and you can use them to check on the health of anything you can think of...  In the past, we&#39;ve used them for all sorts of things such as:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;JCBC connection pool is functioning&lt;/li&gt;
&lt;li&gt;Elasticsearch cluster is accessible&lt;/li&gt;
&lt;li&gt;AWS S3 Bucket is accessible&lt;/li&gt;
&lt;li&gt;AWS Redshift Cluster is available/healthy&lt;/li&gt;
&lt;li&gt;Guava-based Service is running&lt;/li&gt;
&lt;li&gt;Queues are accessible and not backing up&lt;/li&gt;
&lt;li&gt;Batch processing job has not failed&lt;/li&gt;
&lt;li&gt;In-memory data is not stale&lt;/li&gt;
&lt;li&gt;etc, etc, etc&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;The real beauty/point here is that you can write specific checks to verify any aspect of &lt;em&gt;your&lt;/em&gt; application&#39;s functionality, dependencies, etc.  Moreover, those checks live within your same application, eliminating coupling across systems and friction during development.&lt;/strong&gt;  Less friction means more checks.&lt;/p&gt;
&lt;p&gt;Although a super powerful and useful approach, health checks, by design, aren&#39;t an all purpose monitoring system.  Specifically, the semantics are pass/fail and there&#39;s no concept of &amp;quot;warn&amp;quot; or any (built-in) ability to externally adjust thresholds for alerting.  However, it&#39;s such an incredibly useful facility that I heavily rely on it to perform core monitoring of the health of the applications I build.  You do need to be thoughtful as to what kind of checks you add to the system keeping in mind that they need be unambiguous and actionable red/green checks.&lt;/p&gt;
&lt;p&gt;It&#39;s worth noting that the Metrics library also exposes a &lt;code&gt;/metrics&lt;/code&gt; endpoint with low-level and fairly comprehensive instrumentation of the JVM, service requests, error logging, etc.  If you&#39;re not already familiar with it, think along the lines of request rates, response times broken out by percentiles, etc.  Although I&#39;m not going to focus on that functionality in this post, it&#39;s extremely helpful, supports a wide-range of custom metrics, and provides a nice complement to the &lt;code&gt;/healthcheck&lt;/code&gt; endpoint.  There&#39;s also a wide range of &amp;quot;reporters&amp;quot; that allow publishing of metric data into systems like, for example, Graphite. &lt;sup class=&quot;footnote-ref&quot;&gt;&lt;a href=&quot;https://www.dnbg.dev/writings/uptime-in-6-steps/#fn5&quot; id=&quot;fnref5&quot;&gt;[5]&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;As an example of health checks in action, here&#39;s a somewhat fictionalized healthy response illustrating the simple red/green semantics of the healthchecks and the optional inclusion of a detailed human-oriented message (typically you always include detailed messages, stack traces, etc if there&#39;s a failure):&lt;/p&gt;
&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;token property&quot;&gt;&quot;deadlocks&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;token property&quot;&gt;&quot;healthy&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
	&lt;span class=&quot;token property&quot;&gt;&quot;messageProcessorIsRunningHealthCheck&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;token property&quot;&gt;&quot;healthy&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
	&lt;span class=&quot;token property&quot;&gt;&quot;messageQueueHealthCheck&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;token property&quot;&gt;&quot;healthy&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
		&lt;span class=&quot;token property&quot;&gt;&quot;message&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;There are 106 queued messages (want &amp;lt;= 250000) and 10 consumers (want &gt;= 10)&quot;&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
	&lt;span class=&quot;token property&quot;&gt;&quot;importerServiceIsRunningHealthCheck&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;token property&quot;&gt;&quot;healthy&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
	&lt;span class=&quot;token property&quot;&gt;&quot;merchandiseColorSizeLoaderHealthCheck&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;token property&quot;&gt;&quot;healthy&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
	&lt;span class=&quot;token property&quot;&gt;&quot;rabbitMQHealthCheck&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;token property&quot;&gt;&quot;healthy&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
	&lt;span class=&quot;token property&quot;&gt;&quot;redshiftClusterHealthCheck&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;token property&quot;&gt;&quot;healthy&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
		&lt;span class=&quot;token property&quot;&gt;&quot;message&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Cluster status is &#39;available&#39; and maintenance window is UTC &#39;fri:08:30-fri:09:00&#39; (currently 2016-08-23T16:14:37.497Z)&quot;&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
	&lt;span class=&quot;token property&quot;&gt;&quot;redshiftDataSourceHealthCheck&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;token property&quot;&gt;&quot;healthy&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
	&lt;span class=&quot;token property&quot;&gt;&quot;s3BucketIsReadableHealthCheck&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;token property&quot;&gt;&quot;healthy&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
	&lt;span class=&quot;token property&quot;&gt;&quot;sqsHealthCheck&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;token property&quot;&gt;&quot;healthy&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;&lt;strong&gt;Alerting on /healthcheck failures from New Relic&lt;/strong&gt;&lt;/h4&gt;
&lt;p&gt;Although the Metrics library provides the &lt;code&gt;/healthcheck&lt;/code&gt; endpoint, you still need something to regularly probe the application and alert you if it enters an unhealthy state.  At my current company, we use New Relic for a substantial portion of our monitoring.  New Relic has nothing out of the box to support this type of monitoring but it does have an extensible plugin framework that you can customize as necessary.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The &lt;a href=&quot;https://github.com/dbaggott/newrelic-dropwizard#new-relic-dropwizard-plugin--&quot;&gt;Dropwizard plugin for New Relic that I wrote&lt;/a&gt; provides the bridge between New Relic and your Metrics-enabled applications.&lt;/strong&gt;  The plugin allows you to easily receive alerts via NR whenever your Dropwizard application enters into an unhealthy state. Additionally, you can optionally configure NR to send alerts whenever the rate of 4xx responses, 5xx responses, logged errors, and/or JVM heap utilization exceeds configured thresholds. Thresholds for alerting can be configured on a per application basis within NR.&lt;/p&gt;
&lt;p&gt;In addition to providing a basis for alerting on your application, the plugin comes with a fairly rich UI to provide historical data on both your healthcheck failures as well as a whole slew of performance metrics (i.e., the ones exposed via the &lt;code&gt;/metrics&lt;/code&gt; endpoint).&lt;/p&gt;
&lt;p&gt;Here&#39;s one of the views of the New Relic plugin dashboard (you can see samples of the rest &lt;a href=&quot;https://github.com/dbaggott/newrelic-dropwizard#new-relic-plugin-dashboard-ui&quot;&gt;over on github&lt;/a&gt;):&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://www.dnbg.dev/images/writings/healthcheck-overview.png&quot; alt=&quot;Overview&quot;&gt;&lt;/p&gt;
&lt;h4&gt;&lt;strong&gt;Peace of Mind&lt;/strong&gt;&lt;/h4&gt;
&lt;p&gt;If you&#39;re anything like me, then you&#39;ve probably woken up in the middle of the night with that &amp;quot;oh crap&amp;quot; feeling as you suddenly realize that there&#39;s some (perhaps unlikely) edge case failure scenario that you didn&#39;t previously consider and which, if it went undetected, would be insidiously bad.  Now, when that happens to me, I&#39;m often able to go right back to sleep because I know that the next day I&#39;ll simply write a new health check.&lt;/p&gt;
&lt;p&gt;Sleep well!&lt;/p&gt;
&lt;p&gt;Notes:&lt;/p&gt;
&lt;hr class=&quot;footnotes-sep&quot;&gt;
&lt;section class=&quot;footnotes&quot;&gt;
&lt;ol class=&quot;footnotes-list&quot;&gt;
&lt;li id=&quot;fn1&quot; class=&quot;footnote-item&quot;&gt;&lt;p&gt;Poetic license aside, the truth is that there is &lt;strong&gt;some&lt;/strong&gt; amount of &amp;quot;springing forth fully formed&amp;quot; as there are any number of problems and failure scenarios that can and should! be anticipated and planned for using the benefit of your own and others&#39; experiences.  Although outside of the scope of this post, sound design is best baked into your architecture and application from the beginning. &lt;a href=&quot;https://www.dnbg.dev/writings/uptime-in-6-steps/#fnref1&quot; class=&quot;footnote-backref&quot;&gt;↩︎&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;fn2&quot; class=&quot;footnote-item&quot;&gt;&lt;p&gt;Moreover, sometimes the underlying cause of an intermittent crash also has less obvious non-intermittent symptoms such as a general performance degradation that you only discover in the process of fixing the intermittent crash! &lt;a href=&quot;https://www.dnbg.dev/writings/uptime-in-6-steps/#fnref2&quot; class=&quot;footnote-backref&quot;&gt;↩︎&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;fn3&quot; class=&quot;footnote-item&quot;&gt;&lt;p&gt;Guilty as charged although I try very, very hard to avoid that pitfall! &lt;a href=&quot;https://www.dnbg.dev/writings/uptime-in-6-steps/#fnref3&quot; class=&quot;footnote-backref&quot;&gt;↩︎&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;fn4&quot; class=&quot;footnote-item&quot;&gt;&lt;p&gt;While the Metrics library comes bundled with Dropwizard, it is a separate library and can be used in any Java-based application -- run embedded Jetty or similar if your application does not already service http requests and you want the http endpoints. &lt;a href=&quot;https://www.dnbg.dev/writings/uptime-in-6-steps/#fnref4&quot; class=&quot;footnote-backref&quot;&gt;↩︎&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;fn5&quot; class=&quot;footnote-item&quot;&gt;&lt;p&gt;I should also add that, because of the significant operational benefits, I&#39;ve taken to using Dropwizard for non-service applications as well as service applications.  Not only are the &lt;code&gt;/healthcheck&lt;/code&gt; and &lt;code&gt;/metrics&lt;/code&gt; endpoints and the reporting of metrics into systems like Graphite invaluable, but having an easy hook for adding runtime operations via &lt;a href=&quot;http://www.dropwizard.io/1.0.0/docs/manual/core.html#tasks&quot;&gt;Tasks&lt;/a&gt; is awesome!  I&#39;ve used it to create simple admin APIs for things like temporarily pausing a processor, throttling processing rate, etc &lt;a href=&quot;https://www.dnbg.dev/writings/uptime-in-6-steps/#fnref5&quot; class=&quot;footnote-backref&quot;&gt;↩︎&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content>
  </entry>
  <entry>
    <title>Jekyll &amp; GitHub == continuously deployed website in 10 minutes</title>
    <link href="https://www.dnbg.dev/writings/jekyll-and-github/" />
    <updated>2016-08-16T00:00:00Z</updated>
    <id>https://www.dnbg.dev/writings/jekyll-and-github/</id>
    <content type="html">&lt;p&gt;&lt;em&gt;This site has since moved off GitHub Pages: it&#39;s now built with Eleventy and served from AWS. The post is as I wrote it in 2016.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I very recently got around to building this website.  Now that it&#39;s up and I&#39;m thinking back on the process, I&#39;m finding myself surprised/pleased that the part that took me the longest was figuring out how I wanted to host the site.  I&#39;m sufficiently thrilled with the simplicity and benefits of where I ended up that I wanted to share.&lt;/p&gt;
&lt;p&gt;For context, I should first say that my core requirements for a site are very modest.  Primarily, I want a site where I can share some professional information about myself and make the occasional blog post to share the ah-has! and general ups and downs of writing software.  Secondarily, I wanted to avoid paying anything more than a nominal service fee for hosting the site.  And, of course, I wanted to bring normal engineering standards to the process of maintaining the website.&lt;/p&gt;
&lt;p&gt;After consider a number of options (eg &lt;a href=&quot;https://www.djangoproject.com/&quot;&gt;Django&lt;/a&gt; hosted on &lt;a href=&quot;https://www.digitalocean.com/&quot;&gt;DigitalOcean&lt;/a&gt;), I ended up using &lt;a href=&quot;https://pages.github.com/&quot;&gt;GitHub Pages&lt;/a&gt; coupled with &lt;a href=&quot;https://jekyllrb.com/&quot;&gt;Jekyll&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This is hardly new or groundbreaking technology and &lt;a href=&quot;https://help.github.com/articles/using-jekyll-as-a-static-site-generator-with-github-pages/&quot;&gt;there&lt;/a&gt; are already &lt;a href=&quot;https://jekyllrb.com/docs/github-pages/&quot;&gt;plenty&lt;/a&gt; of &lt;a href=&quot;http://jmcglone.com/guides/github-pages/&quot;&gt;great&lt;/a&gt; tutorials &lt;a href=&quot;https://www.smashingmagazine.com/2014/08/build-blog-jekyll-github-pages/&quot;&gt;out there&lt;/a&gt;, so I won&#39;t talk about any of that except to say that it was very, very easy to get a site up and running.&lt;/p&gt;
&lt;p&gt;Instead, I want to share why I personally love this approach:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Free (as in no work) Continuous Deployments&lt;/strong&gt;: GitHub provides tight integration with Jekyll and you get automatic builds and deployments of your site on check-in.  As soon as you merge into master, your change is live.  Not having to think about building or deploying the site (not to mention maintaining a server) is invaluable.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Trivial Site Previewing&lt;/strong&gt;: Jekyll makes it super easy to preview changes to your website locally before pushing your changes via the &lt;code&gt;jekyll serve --watch&lt;/code&gt; command which allows you to view your site on localhost.  &amp;quot;Edit and refresh&amp;quot; makes for rapid iterations.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Familiarity of Markdown&lt;/strong&gt;: I&#39;m writing this blog post in simple and familiar markdown which means I really don&#39;t have to concern myself with anything other than the content.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Versioned Content&lt;/strong&gt;: Github makes drafting (and backing up) changes very easy.  For example, I made a &amp;quot;feature&amp;quot; branch for this post and I can commit and push to that branch as often as I want.  I can take as long as I want to finish the post and have as many in-progress posts as I want without ever worrying about losing them.  And all of that happens automatically b/c it is based on my normal development practices.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Free&lt;/strong&gt;: I was willing to pay some nominal amount for website hosting so it&#39;s the icing on the cake that this approach is also free.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Jekyll&lt;/strong&gt;: Jekyll is new to me but the learning curve for doing simple things is not at all steep and my sense is that, if I ever need it, it affords a considerable amount of flexibility and functionality.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Simple&lt;/strong&gt;:  Once you&#39;re set-up, doing something like adding a blog post consists of adding a single file with some metadata (date, tile, categories, and tags) and the markdown-based content.  Its hard to imagine it being easier.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If you&#39;re thinking about putting together a website or already have one and are experiencing any pain in maintaining it, I highly recommend this approach.  As someone who was already using GitHub, it&#39;s been a 100% friction free experience for me as it dovetails perfectly with the tool sets and development habits that I already have.  Create your website using standard tools and everything else happens automatically and painlessly.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>AAE</title>
    <link href="https://www.dnbg.dev/writings/aae/" />
    <updated>2012-12-06T00:00:00Z</updated>
    <id>https://www.dnbg.dev/writings/aae/</id>
    <content type="html">&lt;p&gt;&lt;em&gt;This is based on an email that I originally sent out to fellow engineers at my company.  I probably would have written it somewhat differently for a wider audience (I ony edited it slightly for readability) but, that being said, I strongly believe that acronyms (however well-intentioned) are, at best, not super helpful and, more often, are extremely obfuscating.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I&#39;ll just come right out and say what I think: when writing code, acronyms (and other abbreviations) are evil and should be avoided like a plague of blood-sucking demon bats.&lt;/p&gt;
&lt;p&gt;Here&#39;s the (reasonable) arguments for acronyms/abbreviations that I can think of:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;They are shorter to type&lt;/li&gt;
&lt;li&gt;They take up less screen space and therefore make the code more compact and easier to read&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;That&#39;s not very many reasons and I don&#39;t think either of these reasons are good enough reasons to justify their use.  Modern IDEs have auto-completion and so you don&#39;t actually have to type out variable names.  So, generally speaking, typing a long variable name is just as fast as typing a short one.   The second reason is a little bit more compelling to me.  However, I think that whatever benefit is gained by having more compact code is more than offset by the loss of clarity in the code itself.  There&#39;s just no getting around it:  acronyms and abbreviations simply don&#39;t make sense unless you know what they mean and our goal should be to make our code as easy to understand as possibly can.  The best code self-documents itself by using clear and informative names that don&#39;t require any domain-specific knowledge.&lt;/p&gt;
&lt;p&gt;For example, consider this real-life code I came across detailing two properties on a &amp;quot;member&amp;quot; user object:&lt;/p&gt;
&lt;pre class=&quot;language-csharp&quot;&gt;&lt;code class=&quot;language-csharp&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token return-type class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;bool&lt;/span&gt;&lt;/span&gt; AllowMss &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token return-type class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;bool&lt;/span&gt;&lt;/span&gt; AllowFpis &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What does that mean?  I have no idea!  The only person who knows is someone who is already fairly familiar with the code.  How could a new engineer (or even someone who has worked at that particular company for many years but is coming to the code for the first time) possibly be expected to know what it means?&lt;/p&gt;
&lt;p&gt;Or consider some more real-life code for an e-commerce site that had has a concept of virtual money called &amp;quot;cafe cash&amp;quot;: if you look in checkout-related code, you&#39;ll discover places where the abbreviation &#39;CC&#39; can stand for either credit card &lt;strong&gt;or&lt;/strong&gt; cafe cash.  The inconsistent use even happens within the same class!  But, even if CC were consistently used to always mean &amp;quot;credit card&amp;quot;, someone who is looking at the code and knows that there&#39;s also a concept of &amp;quot;cafe cash&amp;quot; is still going to wonder whether the CC might stand for cafe cash.  I would go farther though: even for code bases where there is no such thing as cafe cash, what&#39;s the clearer name?&lt;/p&gt;
&lt;p&gt;PayByCC or PayByCreditCard?&lt;/p&gt;
&lt;p&gt;You can&#39;t get much clearer than PayByCreditCard!  Everyone will instantly understand that.  Even out of context.  Sure, a lot of people will guess by context that PayByCC means PayByCreditCard but there are going to people who need to hunt around in the code to figure that out / make sure their guess is correct.  And, even if you know what it means, you are still mentally translating PayByCC into PayByCreditCard in your head every time you look at it.  I say there&#39;s no reason to make yourself or anyone else perform that extra cycle!&lt;/p&gt;
&lt;p&gt;What&#39;s a pnlPoliticalContribution?  What&#39;s a CbaEmail?  I&#39;m sure that CBA seemed totally obvious when the code I found it in was written but it&#39;s not at all obvious to someone who didn&#39;t work on that particular project.  What&#39;s cbStoreSpecial mean?  Is a taxId referring to the id of a taxonomy node or taxes?  These are all needless opportunities for ambiguity and confusion and therefore heartache in working with the code and bugs for end-users.&lt;/p&gt;
&lt;p&gt;So, in my opinion, when should you use acronyms, abbreviations, or otherwise shortened names in your code?  I say never do that unless:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;you would expect someone interviewing for a job to know what the name means (id, url, http, api, util, svg, etc)&lt;/li&gt;
&lt;li&gt;the scope of the variable name is extremely limited (a small number of lines of code) and using a shortened name &lt;em&gt;very&lt;/em&gt; &lt;em&gt;significantly&lt;/em&gt; improves readability and then only do so judiciously (i.e. still don&#39;t do it)&lt;/li&gt;
&lt;li&gt;for universal conventions such as an index variable name like &lt;code&gt;i&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;There&#39;s probably a small number of other reasonable exceptions besides those three.  But, generally speaking, I really think that using full names is a great and simple way to write better code.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;ps Of course, I&#39;m ignoring the importance of code compaction for things like javascript and css where the code is sent across the network.  But that&#39;s what compression and minification are for!&lt;/em&gt;&lt;/p&gt;
</content>
  </entry>
</feed>