<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Josephat Macharia</title>
    <description>The latest articles on DEV Community by Josephat Macharia (@mashaa).</description>
    <link>https://dev.to/mashaa</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F432874%2F0f9b169a-46a0-43a6-9371-136b7831351e.jpeg</url>
      <title>DEV Community: Josephat Macharia</title>
      <link>https://dev.to/mashaa</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mashaa"/>
    <language>en</language>
    <item>
      <title>When Your Codebase Blocks Agile</title>
      <dc:creator>Josephat Macharia</dc:creator>
      <pubDate>Fri, 22 Aug 2025 13:23:03 +0000</pubDate>
      <link>https://dev.to/mashaa/when-your-codebase-blocks-agile-36d8</link>
      <guid>https://dev.to/mashaa/when-your-codebase-blocks-agile-36d8</guid>
      <description>&lt;p&gt;One of the biggest mistakes companies make when they adopt Agile is assuming that changing the process is enough. Daily stand-ups, sprints and Kanban boards are introduced — but the code remains untouched, structured for a world that predates Agile.&lt;/p&gt;

&lt;p&gt;The result? An architecture mismatch that quietly undermines agility. Teams may be “Agile” in ceremony, but in practice, they are slowed down so much that they can hardly respond to change in any meaningful sense.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Hidden Bottleneck&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Agility is about responding quickly to new requirements, shifting priorities and customer needs. But if your codebase is still organized in a way that resists change, every new feature feels like a battle. Instead of building, teams spend disproportionate time:&lt;/p&gt;

&lt;p&gt;Untangling tightly coupled modules&lt;/p&gt;

&lt;p&gt;Reworking brittle dependencies&lt;/p&gt;

&lt;p&gt;Fighting against legacy design decisions&lt;/p&gt;

&lt;p&gt;This isn’t a process problem. It’s an architectural problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Architecture Shapes Agility&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A system’s architecture sets the boundaries for speed, adaptability and collaboration. If the architecture reflects an older way of working — where long release cycles and rigid silos were the norm — Agile practices will only expose those weaknesses faster.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Agile thrives when the codebase itself is:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Modular&lt;/strong&gt; – enabling teams to work independently without constant conflicts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flexible&lt;/strong&gt; – designed for extensions and iterations, not rigid perfection.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Evolvable&lt;/strong&gt; – allowing refactoring and improvement as part of everyday work.&lt;/p&gt;

&lt;p&gt;Without these qualities, your Agile transformation risks becoming Agile in name only.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Road Ahead&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you are considering a move to Agile, be prepared: &lt;strong&gt;restructuring the fundamental architecture of your system is almost certainly in your future&lt;/strong&gt;. The sooner you address it, the faster your teams can deliver value without being slowed down by the very code they’re meant to improve.&lt;/p&gt;

&lt;p&gt;Agility isn’t just about process. It’s about aligning &lt;strong&gt;process and architecture&lt;/strong&gt; so that your teams — and your software — can truly move at the speed of change.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Rethinking Estimation In Agile Development</title>
      <dc:creator>Josephat Macharia</dc:creator>
      <pubDate>Thu, 15 May 2025 18:35:50 +0000</pubDate>
      <link>https://dev.to/mashaa/rethinking-estimation-in-agile-development-4d17</link>
      <guid>https://dev.to/mashaa/rethinking-estimation-in-agile-development-4d17</guid>
      <description>&lt;h1&gt;
  
  
  Estimation
&lt;/h1&gt;

&lt;p&gt;Perhaps we should rethink and reassess our ritual of story estimation.&lt;br&gt;&lt;br&gt;
Direct from the Scrum creator himself:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fixlwivh46bxoi4f63bqv.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fixlwivh46bxoi4f63bqv.jpeg" alt=" " width="396" height="286"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Most story estimation is a waste of everybody's time and a recipe for organisational disappointment.&lt;/p&gt;

&lt;p&gt;One of the ongoing debates in agile circles is that of story sizing. For years, it has seemed to be a settled topic, but there are always new people entering the field that don't know that it's settled, go out looking for how long something is going to take and find a bunch of information that says you should use story points (or t-shirt sizing, or something similar) to figure out how big something is and get an idea of how long it will take.&lt;/p&gt;

&lt;p&gt;So, let's see if we can bring people up to speed. When XP was developed, its creators thought it was important to be able to have an indicative value of the relative complexity of work. &lt;br&gt;
They started with ideal hours, then padded them and then settled on points to abstract away from time, because they found that sizing by hours didn't work very well. Points were never meant to be a predictor of duration.&lt;/p&gt;

&lt;p&gt;After a number of years, just about everybody involved in formalising story points realised it didn't work particularly well, for lots of reasons and suggested we move to something else.&lt;/p&gt;

&lt;p&gt;Here's Ron Jeffries on how his views of story points have changed:&lt;br&gt;
"I like to say that I may have invented story points and if I did, I’m sorry now."&lt;br&gt;
From Story Points Revisited&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn6w7504t0lxi5saaamc6.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn6w7504t0lxi5saaamc6.jpeg" alt=" " width="800" height="122"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For a lot of people, that isn't enough. Knowing that the creators thought it was a mistake isn't enough to enable people to change.&lt;br&gt;
To change, people also need to know what to change to. For that, a detailed breakdown of what to do instead is really valuable. So, here it is:&lt;/p&gt;

&lt;p&gt;Why estimating doesn't work:&lt;br&gt;
✔ Parkinson's Law (the idea that work expands to fill the time allotted for its completion. This may mean you take longer than necessary to complete a task or you procrastinate and complete the task right before the due date.)&lt;br&gt;
✔ Optimism&lt;br&gt;
✔ Inherent uncertainty of creative work (This uncertainty stems from the open-ended nature of creative challenges, where there is rarely a single "right" answer or a clear, pre-defined path to a successful outcome. )&lt;br&gt;
✔ Humans are awful at estimating anything bigger than about 2 days of work&lt;/p&gt;

&lt;p&gt;What to do instead:&lt;br&gt;
💡 Make stories smaller. No, even smaller. (Hint: See "2 days" above)&lt;br&gt;
💡 Actively seek to understand the uncertainty&lt;br&gt;
💡 Use exploratory stories&lt;br&gt;
💡 Write genuine user stories&lt;br&gt;
💡 Remember that user stories are a placeholder for a conversation&lt;br&gt;
💡 Go talk to the user&lt;br&gt;
💡 Utilizes short iterations of &lt;strong&gt;1-2 weeks&lt;/strong&gt; while embracing continuous releases.&lt;br&gt;
💡 Incorporates sprint planning and review while allowing flexibility and no commitment.&lt;br&gt;
💡 No notion of story points or “points per sprint.”&lt;/p&gt;

&lt;h2&gt;
  
  
  The Fallacy of Estimates
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Estimates are inherently based on guesswork.&lt;/li&gt;
&lt;li&gt;Estimation leads to dysfunction and false commitments.&lt;/li&gt;
&lt;li&gt;It's not that things are late 80% of the time; it's that we don't know how to do estimates 80% of the time, so our estimates are always wrong.&lt;/li&gt;
&lt;li&gt;Making decisions based on erroneous estimations leads to significant process breakdown.&lt;/li&gt;
&lt;li&gt;Story points have no meaning, any more than time-based estimates would have.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Velocity
&lt;/h1&gt;

&lt;p&gt;What if you need to understand velocity? Simple: count the stories. That's your velocity. Once you make stories really small, their variability decreases and you get through more. The Law of Large Numbers will help eliminate some of the variability you used to see in your work, so counting stories becomes a perfectly reasonable way to measure velocity, if you need to (you probably don't).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Velocity is a ratio that compares the hypothetical time needed to complete a project without interruptions to the actual time it takes in practice.&lt;/li&gt;
&lt;li&gt;Essentially, it's a decimal figure ranging from 0 to 1, similar to a percentage.&lt;/li&gt;
&lt;li&gt;Our wrong estimates are tied into this.&lt;/li&gt;
&lt;li&gt;We wrongly attribute decreased velocity to team inefficiency rather than acknowledging systemic barriers (e.g., bureaucratic processes and unnecessary tasks).&lt;/li&gt;
&lt;li&gt;Velocity is another destructive force, often misinterpreted as a measure of efficiency or productivity.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Sprint "Spillover"
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;In Agile methodology, there's no concept of Sprint "spillover."&lt;/li&gt;
&lt;li&gt;Agile embraces change, even during coding, allowing for feedback-driven adjustments.&lt;/li&gt;
&lt;li&gt;Insisting on estimation often means misunderstanding Agile, resorting to what is termed as "fake Scrum."&lt;/li&gt;
&lt;li&gt;True Agile doesn't require committing to a fixed set of stories within a Sprint; instead, it focuses on committing to overall goals, emphasizing adaptability over rigid planning, similar to traditional waterfall approaches.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Some people will say, "Aha! You said estimating was a waste, but you must estimate in order to figure out if a story is less than 2 days." You're right. But that's the extent of estimation's value. If you understand what's needed well enough, you'll be able to get the story to be smaller than 2 days. If you don't, you won't.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It's time to move away from the culture of estimates and focus on delivering valuable software.&lt;/li&gt;
&lt;li&gt;If we are obsessed with estimates, let's employ a difficulty scale that is difficult to translate into time.

&lt;ul&gt;
&lt;li&gt;For example, categorize tickets as &lt;strong&gt;trivial&lt;/strong&gt;, &lt;strong&gt;easy&lt;/strong&gt;, &lt;strong&gt;normal&lt;/strong&gt;, &lt;strong&gt;hard&lt;/strong&gt;, &lt;strong&gt;don't know&lt;/strong&gt;, etc.&lt;/li&gt;
&lt;li&gt;This could provide valuable information for prioritization.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

</description>
      <category>management</category>
      <category>softwaredevelopment</category>
      <category>discuss</category>
      <category>productivity</category>
    </item>
    <item>
      <title>The Rewrite Trap: A Programmer's Survival Guide</title>
      <dc:creator>Josephat Macharia</dc:creator>
      <pubDate>Sun, 22 Dec 2024 16:47:25 +0000</pubDate>
      <link>https://dev.to/mashaa/the-rewrite-trap-a-programmers-survival-guide-2hl3</link>
      <guid>https://dev.to/mashaa/the-rewrite-trap-a-programmers-survival-guide-2hl3</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv725jlr2bxeu5hq6xtv5.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv725jlr2bxeu5hq6xtv5.jpeg" alt=" " width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the world of software development, there's a constant temptation that lurks in the shadows of every legacy codebase: the urge to throw everything away and start fresh.&lt;/p&gt;

&lt;p&gt;It's a siren song that has led many projects to their doom, yet it continues to seduce developers across the industry.&lt;/p&gt;

&lt;p&gt;Let's dive deep into the art of code refactoring and explore why the "rewrite everything" approach is often a costly mistake.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Temptation of the Blank Slate&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There’s a unique allure in starting fresh.&lt;br&gt;
Like an architect yearning to demolish and rebuild, programmers often see existing codebases as messy, convoluted, or just plain ugly.&lt;/p&gt;

&lt;p&gt;It’s natural to feel this way.&lt;br&gt;
Reading someone else’s code (or even your own, months later) is harder than writing new code from scratch. But this impulse to bulldoze can be catastrophic.&lt;/p&gt;

&lt;p&gt;Here’s the truth: existing code is more than just text on a screen. It’s the culmination of countless hours of debugging, testing and adapting to real-world problems.&lt;/p&gt;

&lt;p&gt;Each line however inelegant—represents accumulated knowledge.&lt;/p&gt;

&lt;p&gt;Tossing it aside without due diligence is like throwing away a treasure map because you dislike the handwriting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Complete Rewrites Are Dangerous&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Rewriting an entire codebase might seem like a clean solution, but history shows it’s often a grave mistake.&lt;/p&gt;

&lt;p&gt;Consider these cautionary tales:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Netscape's decision to rewrite their browser from scratch led to a three-year gap between versions 4.0 and 6.0, giving Internet Explorer the opportunity to dominate the browser market.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Borland's attempt to rewrite Quattro Pro ended in failure.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Even Microsoft, with all its resources, had to abandon a complete rewrite of Word.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Rewriting not only wastes time and money but also introduces unknown bugs while losing the hard-earned stability of the original code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Refactor, Don’t Rewrite&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So, what’s the alternative? Incremental refactoring. This approach allows you to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Preserve Battle-Tested Code:&lt;/strong&gt; Even ugly code has survived production, been reviewed and patched over time. Respect the lessons it holds.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Make Incremental Changes:&lt;/strong&gt; Small, focused updates make it easier to track the impact of each change. It’s far less intimidating to fix two failing tests than to face a hundred.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Leverage Existing Tests:&lt;/strong&gt; Never discard old tests without understanding their purpose. These tests may uncover subtle issues you might overlook.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The Right Way to Approach Refactoring&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before refactoring, ask yourself: Why am I doing this?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Performance Issues:&lt;/strong&gt; Profile the code first. Identify bottlenecks and optimize strategically.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Difficulty Adding Features:&lt;/strong&gt; If tight coupling or spaghetti code is the issue, focus on encapsulation and better interfaces.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Code Maintainability:&lt;/strong&gt; Start small, rename variables, clean up formatting and clarify comments. Gradual improvements add up.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Practical Tips for Refactoring Success&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Understand the Existing System:&lt;/strong&gt; Take stock of the codebase and tests. Identify strengths to preserve and weaknesses to address.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Refactor in Small Steps:&lt;/strong&gt; Focus on one area at a time. Verify changes by running tests after each iteration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Avoid Personal Bias:&lt;/strong&gt; Restructure for functionality, not style. If it isn’t broken, don’t fix it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Beware of New Technology:&lt;/strong&gt; Don’t refactor just to use the latest framework or language. Unless there’s a clear, measurable benefit, it’s not worth the risk.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Respect the Past:&lt;/strong&gt; Every “ugly” workaround or patch likely exists for a reason. Investigate before replacing it.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Conclusion: Progress Without Pain&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Refactoring isn’t just about writing better code, it’s about making smarter decisions.&lt;/p&gt;

&lt;p&gt;By respecting the lessons embedded in your existing system and taking a methodical incremental approach, you’ll avoid the pitfalls of hubris and set yourself up for long-term success.&lt;/p&gt;

&lt;p&gt;Remember, code doesn’t need to be perfect, it just needs to work well for the people who use and maintain it.&lt;/p&gt;

&lt;p&gt;So next time you’re tempted to rewrite everything, stop and think: What’s the real problem I’m solving? The answer might save you countless hours—and a lot of headaches.&lt;/p&gt;

</description>
      <category>refactoring</category>
      <category>cleancode</category>
      <category>softwareengineering</category>
      <category>programming</category>
    </item>
    <item>
      <title>Introduction To RabbitMQ</title>
      <dc:creator>Josephat Macharia</dc:creator>
      <pubDate>Sun, 31 Oct 2021 14:25:26 +0000</pubDate>
      <link>https://dev.to/mashaa/introduction-to-rabbitmq-49n8</link>
      <guid>https://dev.to/mashaa/introduction-to-rabbitmq-49n8</guid>
      <description>&lt;h3&gt;
  
  
  What is RabbitMQ
&lt;/h3&gt;

&lt;p&gt;RabbitMQ is a message broker that accepts and forwards messages. &lt;br&gt;
It accepts messages from &lt;em&gt;producers&lt;/em&gt;, and delivers them to &lt;em&gt;consumers&lt;/em&gt;. It acts like a &lt;strong&gt;middleman&lt;/strong&gt; which can be used to reduce loads and delivery times taken by web application servers.&lt;/p&gt;

&lt;h4&gt;
  
  
  Message flow in RabbitMQ
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9n502l4r95tmczfgga4m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9n502l4r95tmczfgga4m.png" alt="Alt Text" width="651" height="321"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The producer publishes a message to an exchange. When creating an exchange, the type must be specified.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The exchange receives the message and is now responsible for routing the message. The exchange takes different message attributes into account, such as the routing key, depending on the exchange type.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Bindings must be created from the exchange to queues. In this case, there are two bindings to two different queues from the exchange. The exchange routes the message into the queues depending on message attributes.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;4.The messages stay in the queue until they are handled by a consumer&lt;/p&gt;

&lt;p&gt;5.The consumer handles the message&lt;/p&gt;

&lt;h3&gt;
  
  
  Types of exchanges in RabbitMQ:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Fanout&lt;br&gt;
This exchange basically sends a copy of messages to all the queues it knows. (in the dashboard every queue should be bind ed to one exchange)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Direct&lt;br&gt;
A direct exchange delivers messages to queues based on a message routing key. The routing key is a message attribute added to the message header by the producer. Think of the routing key as an “address” that the exchange is using to decide how to route the message.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Topic&lt;br&gt;
Topic exchanges route messages to one or many queues based on matching between a message routing key and the pattern that was used to bind a queue to an exchange.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;4.Headers&lt;br&gt;
A header exchange is an exchange that route messages to queues based on message header values instead of routing key. If a match is found, it routes the message to the queue whose binding value is matched and if a match is not found, it ignored the message.&lt;/p&gt;

&lt;h3&gt;
  
  
  RabbitMQ Terminologies and Concepts
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Producer&lt;/strong&gt;: A producer is a user application that sends messages to the consumers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Consumer&lt;/strong&gt;: A consumer is a user application that receives messages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Message&lt;/strong&gt;: It’s a simple serialized object from the producer!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exchange&lt;/strong&gt;: An exchange is a very simple thing. On one side it receives messages from producers and the other side pushes them to queues. This is a place that messages come first and its main purpose is to decide which consumer application, the message should go!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Queue&lt;/strong&gt;:&lt;br&gt;
A queue is a buffer that stores messages basically, the exchange routes the message to queues, then the consumer clients receive messages from the queue. We have queues as many as the consumer’s applications&lt;br&gt;
The producers send the message to the exchange first, the exchange decides which queues, the message should go. &lt;/p&gt;

&lt;h3&gt;
  
  
  When to Use RabbitMQ
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;For long-running tasks, when you need to run reliable background jobs. e.g such as file scaning, image scaling or PDF&lt;/li&gt;
&lt;li&gt;communication and integration within, and between applications, i.e as middleman between microservices; where a system simply needs to notify another part of the system to start to work on a task, like ordering handling in a webshop (order placed, update order status, send order, payment, etc.)&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>rabbitmq</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
    <item>
      <title>17 days of code complete Day 2 - Chapter 3 and 4</title>
      <dc:creator>Josephat Macharia</dc:creator>
      <pubDate>Fri, 29 Oct 2021 06:18:08 +0000</pubDate>
      <link>https://dev.to/mashaa/17-days-of-code-complete-day-2-chapter-3-and-4-eo8</link>
      <guid>https://dev.to/mashaa/17-days-of-code-complete-day-2-chapter-3-and-4-eo8</guid>
      <description>&lt;p&gt;On day 2 we will look into chapter 3 and 4.&lt;br&gt;
For more in depth notes of the book, please &lt;a href="https://www.amazon.com/Code-Complete-Practical-Handbook-Construction/dp/0735619670" rel="noopener noreferrer"&gt;purchase the book!&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Chapter 3 Measure Twice, Cut Once Upstream Prerequisites
&lt;/h2&gt;

&lt;p&gt;This chapter describes the work that must be done to prepare for software construc-&lt;br&gt;
tion. As with building construction, much of the success or failure of the project has&lt;br&gt;
already been determined before construction begins. If the foundation hasn’t been&lt;br&gt;
laid well or the planning is inadequate, the best you can do during construction is to&lt;br&gt;
keep damage to a minimum.&lt;br&gt;
This chapter discusses software equivalent of blueprints&lt;br&gt;
and construction permits. You might not have much control over preparations, so the focus of this chapter is on assessing what you have to work with when&lt;br&gt;
construction begins.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key take away
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It is good to plan to specify requirements up front.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Essentially, you’ll need to pick the right balance for your project. If it’s something more stable, where the requirements are well understood and unlikely to change, a more sequential approach is appropriate. But if the requirements may change, or the structure isn’t as well understood, then a more iterative approach will be more beneficial.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The overarching goal of preparation is risk reduction&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Most common project risks in software devel-&lt;br&gt;
opment are poor requirements and poor project planning, thus preparation tends to&lt;br&gt;
focus on improving requirements and project plans.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;From a technical point of&lt;br&gt;
view, planning means understanding what you want to build so that you don’t waste&lt;br&gt;
money building the wrong thing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Explicit requirements keep you from guessing&lt;br&gt;
what the user wants.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Explicit requirements also help to avoid arguments. You decide on the scope of the&lt;br&gt;
system before you begin programming. If you have a disagreement with another pro-&lt;br&gt;
grammer about what the program is supposed to do, you can resolve it by looking at&lt;br&gt;
the written requirements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Software being what it is, iterative approaches are useful much more often than sequential approaches are.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Handling Requirements Changes During Construction
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Use the requirements checklist at the end of the section to assess the quality of your requirements If your requirements aren’t good enough, stop work, back up, and make them right before you proceed.&lt;/li&gt;
&lt;li&gt;Make sure everyone knows the cost of requirements changes, work up a revised schedule and cost estimate so that you can decide whether you want to do it now or later.&lt;/li&gt;
&lt;li&gt;Set up a change-control procedure If your client’s excitement persists, consider
establishing a formal change-control board to review such proposed changes. It’s all
right for customers to change their minds and to realize that they need more capabilities. The problem is their suggesting changes so frequently that you can’t keep up&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Chapter 4 Key Construction Decisions
&lt;/h2&gt;

&lt;p&gt;This chapter focuses on preparations that individual programmers and technical leads are responsible for, directly or indirectly. It discusses the software equivalent of how to select specific tools for your tool belt and how to load your&lt;br&gt;
truck before you head out to the job site.&lt;/p&gt;

&lt;p&gt;Programmers may be similarly influenced by their languages. The words available in a&lt;br&gt;
programming language for expressing your programming thoughts certainly deter-&lt;br&gt;
mine how you express your thoughts and might even determine what thoughts you&lt;br&gt;
can express.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Your programming tools don’t have to&lt;br&gt;
determine how you think about programming.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Programmers who program “in” a language limit their thoughts to constructs that the language&lt;br&gt;
directly supports. If the language tools are primitive, the programmer’s thoughts will also be primitive.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Programmers who program “into” a language first decide what thoughts they want to express, and then they determine how to express those thoughts using the tools provided by their specific language.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Your position on the technology wave determines what approaches will be effective or even possible. Identify where you are on the technology wave, and adjust your plans and expectations accordingly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Establish programming conventions before you begin programming. It’s nearly&lt;br&gt;
impossible to change code to match them later.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Every programming language has strengths and weaknesses. Be aware of the specific strengths and weaknesses of the language you’re using.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  My thoughts
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Its hard for programmers to adopt to the test first approach.&lt;/li&gt;
&lt;li&gt;Ensuring the programmer has stepped through their code in the debugger before they check it in is not easy.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>programming</category>
    </item>
    <item>
      <title>How To Build APIs That Are Resilent From 3rd Party Failures</title>
      <dc:creator>Josephat Macharia</dc:creator>
      <pubDate>Thu, 28 Oct 2021 20:27:52 +0000</pubDate>
      <link>https://dev.to/mashaa/handling-system-failures-during-3rd-party-api-communications-499j</link>
      <guid>https://dev.to/mashaa/handling-system-failures-during-3rd-party-api-communications-499j</guid>
      <description>&lt;p&gt;There are many possible reasons for failures, from an outage of a third-party service (API, DB, etc.) to a hardware failure, to the “classic” software bug (after all, software developers are humans too, aren’t we? 🤔).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Fault tolerance is a requirement, not a feature.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This post is an a attempt to address handling system failures during 3rd Party API communications.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7up532noq9qwjsmbpyf3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7up532noq9qwjsmbpyf3.png" alt="handling system 3rd party api failure" width="491" height="271"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  What are some of the failure points?
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The network connectivity between the application and the third party system might be disrupted causing communication timeouts or lost information.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The third party system has an internal error or machine failure causing the application not to receive a response.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Third party system has not been paid for, e.g late in account payment renewal.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;We have an internal error or machine failure. Depending on the timing of this failure, two things could happen:&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; 1. Inability to send the request.

 2. Inability to receive the response from the third party.
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  How do we respond to a user request when failure occurs?
&lt;/h4&gt;

&lt;p&gt;The diagram below attempts to show a process that would be followed to achieve resilience in API communication failure&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5vo41ag2yjgg9e2a87kg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5vo41ag2yjgg9e2a87kg.png" alt="handle payment failure photo" width="800" height="565"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In each of the options described above a timeout, internal error or connection error will result in a request not retrieving the optimal response for customers.&lt;/p&gt;

&lt;h4&gt;
  
  
  What are the possible actions to take when retry will not succeed and is unlikely to help?
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Notifications:  when such 3rd party failure occurs, notifications should be sent for quick action such as calling the customer back to manage expectation and give way out that lets them know that you have their back.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Showing descriptive messages that will aid to let the customer know what to do. e.g refresh, retry&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h5&gt;
  
  
  To improve the resilience of the application we should consider the following patterns:
&lt;/h5&gt;

&lt;p&gt;1.Retry&lt;br&gt;
2.Caching&lt;br&gt;
3.Persistence&lt;br&gt;
4.Circuit Breaker&lt;/p&gt;

&lt;h5&gt;
  
  
  Retry
&lt;/h5&gt;

&lt;p&gt;For a &lt;strong&gt;reliable and robust&lt;/strong&gt; retrying solution it should be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Smart - To answer this, we use exponential backoff retrying.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Customizable - Standard way to handle errors, we should control which errors should be retried and which shouldn’t by throwing exceptions for the errors that should be retried and by catching the others.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  Caching
&lt;/h5&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;We record each request in the database before sending the information to an external party. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We should have a status attribute that tracks which part of the process the request is in. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We update the request with a new status based on the response, normally either created, declined or successful.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h5&gt;
  
  
  Persistence
&lt;/h5&gt;

&lt;p&gt;To get more inspiration Uber manages the reprocessing of their data using kafka topics and dead-letter queues. See &lt;a href="https://eng.uber.com/reliable-reprocessing/" rel="noopener noreferrer"&gt;https://eng.uber.com/reliable-reprocessing/&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Uber’s idea would fit many of our needs, so we can design a solution based on it.&lt;/p&gt;

&lt;p&gt;First, our error handling solution should identify that there is an error. Then, it needs to grab the relevant context of the error (in this example, the handled HTTP request). &lt;br&gt;
After that, it should send that context to some persistence layer, for later re-execution of the service flow.&lt;br&gt;
When a failure occurs in one of the HTTP requests, the request context (request body, query params, etc.) will be sent as a Kafka message to the first retry Kafka topic. &lt;/p&gt;

&lt;p&gt;As for the re-execution part, a polling of the first retry topic is added and if that processing fails too, it will be sent to the second  topic and so forth, until it’s sent to the dlq (“dead-letter queue”) topic, for manual analysis. (The number of retry topics is arbitrary in this example, it can be any number).&lt;br&gt;
Let’s see how the solution I described applies to service A below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fohf3fn2bav58dqvrcg70.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fohf3fn2bav58dqvrcg70.png" alt=" " width="660" height="572"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Summary
&lt;/h4&gt;

&lt;p&gt;If we implement the solutions I’ve described, we can be much more confident now when our system has failures, the system requires fewer manual interventions when it fails, and most importantly, we sleep well at night!&lt;/p&gt;

&lt;p&gt;I hope this post helped you by providing you with some new ideas for handling failures in your applications.&lt;/p&gt;

&lt;p&gt;Feel free to comment below with any questions/thoughts :-)&lt;/p&gt;

</description>
      <category>devops</category>
      <category>programming</category>
    </item>
    <item>
      <title>When To Use NoSQL Document Databases: MongoDB, CouchDB</title>
      <dc:creator>Josephat Macharia</dc:creator>
      <pubDate>Sat, 08 May 2021 10:33:59 +0000</pubDate>
      <link>https://dev.to/mashaa/when-to-use-nosql-document-databases-mongodb-couchdb-2m27</link>
      <guid>https://dev.to/mashaa/when-to-use-nosql-document-databases-mongodb-couchdb-2m27</guid>
      <description>&lt;h2&gt;
  
  
  Why NoSQL Databases Were Invented
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;When traditional databases were introduced
they were able to handle the size by running 
on bigger machines&lt;/li&gt;
&lt;li&gt;NoSQL means that the database does not employ tables, rows and columns for data organization&lt;/li&gt;
&lt;li&gt;Relational databases could horizontally scale which means being able to copy their data to other machines so reads could be distributed.&lt;/li&gt;
&lt;li&gt;There was no easy way to distribute writes&lt;/li&gt;
&lt;li&gt;To fix this problem, leading technological companies introduced new databases referred to as NoSQL.&lt;/li&gt;
&lt;li&gt;Therefore NoSQL databases were designed to scale large datasets horizontally which means &lt;strong&gt;scaling large datasets&lt;/strong&gt; was the primary motivator to create NoSQL databases.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Types Of NoSQL Databases
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Key/value &lt;/li&gt;
&lt;li&gt;Graph databases&lt;/li&gt;
&lt;li&gt;Column-oriented&lt;/li&gt;
&lt;li&gt;Document-oriented&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Industry examples of Document Databases
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MongoDB&lt;/li&gt;
&lt;li&gt;CouchDB&lt;/li&gt;
&lt;li&gt;Cosmos DB&lt;/li&gt;
&lt;li&gt;CrateDB&lt;/li&gt;
&lt;li&gt;Couchbase Server &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What Is A Document 
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A way to organize and store data as a set of field value pairs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Features Of Document databases
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Relationships are obvious using embedded arrays and documents.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The biggest benefit to developers of using a document-oriented database is that developers use structure like maps, hashes, dictionaries, and JSON objects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The document model use a similar structure resulting in the representation that is easier and more natural, as it is the same in the code and the application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This means there is no complex mapping between your applications data object and the database.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Today, we know that modern data sets can grow to be huge, that data is polymorphic by nature, and that our modern applications have to be resilient and always up.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;NoSQL databases, and in particular a document-oriented database like MongoDB, are a more natural way to work with modern data.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why Use Document Databases
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Applications that take records that are fairly complex and need to access those records in a fairly complex way&lt;/li&gt;
&lt;li&gt;Allows one to have a lot of records with a lot of engineering&lt;/li&gt;
&lt;li&gt;Allows you to have different categories of data and access them the same way&lt;/li&gt;
&lt;li&gt;For rapid application development&lt;/li&gt;
&lt;li&gt;When you need a flexible schema&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  When To Use Document Databases
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;When the schema is easily changeable.&lt;/li&gt;
&lt;li&gt;When you want to scale (especially horizontal): they are built for scale since their horizontal partitioning is inbuilt since they expect a lot of scale.&lt;/li&gt;
&lt;li&gt;When you require simplicity e.g fewer tables, fewer relationships&lt;/li&gt;
&lt;li&gt;When you want to aggregate data since they are built for aggregation&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  When Not To Use Document Databases
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;When you require to make a lot of updates since consistency is not guaranteed, the data may not be consistent (two nodes might have different data for the same ID)&lt;/li&gt;
&lt;li&gt;They are not read optimized since they read each block and filter out the rows&lt;/li&gt;
&lt;li&gt;They do not have implicit information of relations in data, therefore joins are hard if you have more than one table.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>nosql</category>
      <category>database</category>
    </item>
    <item>
      <title>How Monitoring Works: Prometheus, Grafana and StatsD</title>
      <dc:creator>Josephat Macharia</dc:creator>
      <pubDate>Tue, 27 Apr 2021 07:15:04 +0000</pubDate>
      <link>https://dev.to/mashaa/monitoring-statsd-prometheus-and-grafana-1bpm</link>
      <guid>https://dev.to/mashaa/monitoring-statsd-prometheus-and-grafana-1bpm</guid>
      <description>&lt;h2&gt;
  
  
  What is Monitoring?
&lt;/h2&gt;

&lt;p&gt;The Periodic tracking (for example, daily, weekly, monthly, quarterly, annually) of any activity’s progress by systematically gathering and analyzing data and information&lt;/p&gt;

&lt;h2&gt;
  
  
  Why monitor?
&lt;/h2&gt;

&lt;p&gt;Helps to answer the following:(Imagine or picture this):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What is happenning right now?&lt;/li&gt;
&lt;li&gt;When did things change or what has changed (has it gone up or down did it change when we did this deploy)&lt;/li&gt;
&lt;li&gt;When did it happen&lt;/li&gt;
&lt;li&gt;How often does it happen e.g how many times a second, a day when do people use this feature, how many queries am i sending to the 
database&lt;/li&gt;
&lt;li&gt;How long did it happen.&lt;/li&gt;
&lt;li&gt;Enhance reliability: software bugs can be prevented via:

&lt;ul&gt;
&lt;li&gt;testing&lt;/li&gt;
&lt;li&gt;measuring&lt;/li&gt;
&lt;li&gt;monitoring&lt;/li&gt;
&lt;li&gt;analyzing.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is a metric?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The unit that is being monitored for a specific target.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Things to monitor?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;request latency&lt;/li&gt;
&lt;li&gt;request count&lt;/li&gt;
&lt;li&gt;number of exceptions&lt;/li&gt;
&lt;li&gt;cpu utilization&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to Monitor?
&lt;/h2&gt;

&lt;p&gt;we can use traditional methods but why reinvent the wheel use &lt;strong&gt;monitoring tools&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What do monitoring tools offer?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;collection&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Describes how the measurements are taken.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;storage&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;how to get metrics you measured from where you measured into something that will store them long term (usually called time series databases).&lt;/li&gt;
&lt;li&gt;This storage also needs to be capable of fetching that stuff quickly for analysis/graphing/alerting etc.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;graphing &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;visualizing and analyzing metrics collected.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;aggregation windows&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;how long you can keep metrics before you run out of space or the storage becomes slow.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;alerting&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;channels used to notify users when things happen.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  What are some of the common measurement/metric types?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Counter&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F93jec35uoyt6znb6ic29.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F93jec35uoyt6znb6ic29.png" alt="Alt Text" width="640" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use this for situations where you want to know “how many times has x happened”.&lt;/li&gt;
&lt;li&gt;for example total number of HTTP requests, or the total number of bytes sent in HTTP&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Gauge &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F1ov1dlfdn1m7xqjow1me.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F1ov1dlfdn1m7xqjow1me.png" alt="Alt Text" width="640" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A representation of a metric that can go both up and down.&lt;/li&gt;
&lt;li&gt; “what is the current value of x now”.&lt;/li&gt;
&lt;li&gt; what is the current value of logged in users now.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Histogram &lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F2ewg0yqus7470i5e6mdw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F2ewg0yqus7470i5e6mdw.png" alt="Alt Text" width="640" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This represents observed metrics sharded into distinct buckets.&lt;/li&gt;
&lt;li&gt;Think of this as a mechanism to track “how long something took” or “how big something was”.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Monitoring patterns for reporting metrics
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Pull model

&lt;ul&gt;
&lt;li&gt;the monitoring system "scrapes" the application at a predefined HTTP endpoint.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Push model, the application sends the data to the monitoring system.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjlk5096iinpk9fxd8vfu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjlk5096iinpk9fxd8vfu.png" alt="Alt Text" width="640" height="114"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;An example of a monitoring system working in the pull model is &lt;strong&gt;Prometheus&lt;/strong&gt;. &lt;strong&gt;StatsD&lt;/strong&gt; is an example of a monitoring system where the application pushes the metrics to the system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Monitoring tools
&lt;/h2&gt;

&lt;p&gt;We will focus on the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;StatsD&lt;/li&gt;
&lt;li&gt;Prometheus&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Whats is StatsD
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;System for instrumenting metrics&lt;/li&gt;
&lt;li&gt;statsd is semi real time and little historical&lt;/li&gt;
&lt;li&gt;a funnel that collects data&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why it was creatd?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Devops guys did not understand the internals of an application apart from its CPU utilization and network IO.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How it works?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;StatsD will accept measurements from all over your network with UDP.&lt;/li&gt;
&lt;li&gt;Aggregates them into 10-seconds chunks.&lt;/li&gt;
&lt;li&gt;Sends them off to somewhere that will store the data e.g Graphite&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What are the components of StatsD?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fthpdqihfuqlk5sugoqqj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fthpdqihfuqlk5sugoqqj.png" alt="Alt Text" width="800" height="284"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;API Client   --&amp;gt; this integrates with your actual application.
&lt;/li&gt;
&lt;li&gt;UDP Protocol --&amp;gt; API client just wraps over the UDP protocol.&lt;/li&gt;
&lt;li&gt;Daemon --&amp;gt;   this deamon runs on your actual application service.&lt;/li&gt;
&lt;li&gt;Metrics collection: you fit your application with metrics which will send UDP packets to a local daemon
the local daemon will aggregate these packets together and send them in batch to a backend&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What metric types are available?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;counters - how many x times something happened&lt;/li&gt;
&lt;li&gt;timers - it took this long e,g on average&lt;/li&gt;
&lt;li&gt;gauges  - % completion
&lt;/li&gt;
&lt;li&gt;sets - keep track of unique values&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How does it integrate with my app
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Push metrics from your code&lt;/li&gt;
&lt;li&gt;clients are available for many languages e.g ntest statsd&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Which backends it can integrate with
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;graphite&lt;/li&gt;
&lt;li&gt;mysql, influxdb, mongodb&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Prometheus  
&lt;/h2&gt;

&lt;p&gt;A monitoring tool that actively scrapes data, stores it, and supports queries, graphs, and alerts, as well as provides endpoints to other API consumers like Grafana or even Graphite itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why it exists
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Created to monitor highly dynamic container environments like kubernates and docker swarm etc&lt;/li&gt;
&lt;li&gt;However it can used in a traditional non container infrastructure.&lt;/li&gt;
&lt;li&gt;It has become the mainstream monotoring tool of choice in container and microservice world.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Where can i use it?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;When running multiple servers that run containerized applications and there are x(processes)
running on that infrastructure and things are interconnected.&lt;/li&gt;
&lt;li&gt;In complex infrastructure with lots of servers distributed &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What can go wrong in complex infrastructure?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;One service can crush and cause failure to others.This can be difficult to debug manually.&lt;/li&gt;
&lt;li&gt;Application downtime&lt;/li&gt;
&lt;li&gt;Errors&lt;/li&gt;
&lt;li&gt;Overloaded and running out of resources&lt;/li&gt;
&lt;li&gt;Response latency&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is the remedy for problems in complex infrastructure
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Have a tool that constantly monitors all the services.&lt;/li&gt;
&lt;li&gt;Alerts the maintainers as soon as one service crashes e.g you know what happened.&lt;/li&gt;
&lt;li&gt;Identify problems before they occur and alert the system admin responsible for that infrastructure to prevent that issue e.g

&lt;ul&gt;
&lt;li&gt;when the application is about to run out of storage space&lt;/li&gt;
&lt;li&gt;when an application becomes too slow, have tool that detects network spikes&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  What it offers
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Automated monitoring and alerting for devops workflow&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Architecture/How it works
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frck6bqxdumvhn2wvau9z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frck6bqxdumvhn2wvau9z.png" alt="Alt Text" width="800" height="560"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Prometheus Server&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Does the actual monitoring work and made up of three components

&lt;ol&gt;
&lt;li&gt;Storage: time series database --&amp;gt; stores all the metrics data e.g current cpu usage, no_of_requests&lt;/li&gt;
&lt;li&gt;Data retrieval worker responsible for getting or pulling those metrics and pushing them to the database&lt;/li&gt;
&lt;li&gt;Server API That accepts queries for that stored data and used to display the data/visualize inside prometheus or other graph tool&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is the work of prometheus alert Manager
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Responsible for firing alerts via different channels e.g email, slack.&lt;/li&gt;
&lt;li&gt;Determines who receives? how it triggers.&lt;/li&gt;
&lt;li&gt;Reads the rule, if the condition is met then an alert is fired.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Where is data stored
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Stores the data on disk also integrates with remote storage.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What are the characteristics
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Designed to be reliable even when other services have an outage.&lt;/li&gt;
&lt;li&gt;Standalone and self containing --&amp;gt; does not depend on network storage&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What it Monitors
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A particulat thing e.g a linux server, windows, database server&lt;/li&gt;
&lt;li&gt;Things it monitors are called targets 

&lt;ul&gt;
&lt;li&gt;For linux server it can be, CPU status, memory disk, space usage&lt;/li&gt;
&lt;li&gt;For application server it can be exceptions count, number of request and request duration&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  There are 3 primitive metrics types
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Counter --&amp;gt; How many times x happened&lt;/li&gt;
&lt;li&gt;Gauge  --&amp;gt; what is the current value of x now or what is the current capacity of disk space now&lt;/li&gt;
&lt;li&gt;Histogram/Timer ---&amp;gt; How long or how big&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How it collects metrics
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;It pulls metrics from a http endpoint whose host adress exposes a &lt;strong&gt;/metrics&lt;/strong&gt; endpoint.
for that to work:

&lt;ul&gt;
&lt;li&gt;The target must expose the &lt;strong&gt;/metrics&lt;/strong&gt; endpoint&lt;/li&gt;
&lt;li&gt;Data available at &lt;strong&gt;/metrics&lt;/strong&gt; must be in a format that prometheus understands&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Target Endpoints and exporters
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Some servers are already exposing the /metrics endpoint so no extra work is needed to get metrics from them&lt;/li&gt;
&lt;li&gt;Many services dont have native prometheus endpoint and need an extra component known as an exporter&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Exporter is a script or service that fetches  metrics from ur target and converts them into a format prometheus understands&lt;br&gt;
and exposes these metrics to its own /metrics endpoint&lt;/p&gt;

&lt;h2&gt;
  
  
  How to monitor a linux/windows server
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Download a node exporter&lt;/li&gt;
&lt;li&gt;untar and execute&lt;/li&gt;
&lt;li&gt;converts metrics of the server&lt;/li&gt;
&lt;li&gt;exposes /metrics endpoint&lt;/li&gt;
&lt;li&gt;configure promethues to scrape this endpoint&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to monitor an application
&lt;/h2&gt;

&lt;p&gt;At application level you can monitor the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How long request are taking

&lt;ul&gt;
&lt;li&gt;How many requests
Use client libraries to expose /metrics endpoint&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why care
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In push mechanism applications/servers push to a centralized platform&lt;/li&gt;
&lt;li&gt;high load of network traffic: when working with many microservices and you have each service pushing their metrics
to the monitoring system it creates a high load of traffic in your infrastructre and your monitoring can be your bottleneck&lt;/li&gt;
&lt;li&gt;must install a daemon on each target to push data to the monitoring server.&lt;/li&gt;
&lt;li&gt;Better detect/insight if service is up and running&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;note: for shortlived gateway it offers a pushgateway&lt;/p&gt;

&lt;h2&gt;
  
  
  How it know what to scape and when?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;All that is confugured in promethues.yml:

&lt;ul&gt;
&lt;li&gt;define what targets to scrape and at what interval.&lt;/li&gt;
&lt;li&gt;It uses a service discovery to discover those endpoints.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is it does not do well
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Dificult to scale when you have 100 of servers you might want to have multiple prometheus servers that somewhat
aggregate all these metrics data and configuring that can be dificlut&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Workarounds
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Increase prometheus server capacity.&lt;/li&gt;
&lt;li&gt;Limit number of metrics.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Graphana
&lt;/h2&gt;

&lt;p&gt;Allows you to query, visualize alert and understand your metrics no matter where they are stored.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Enables you to create, explore and share dashboards with your team.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
Explore metrics &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ad-hoc queries are queries that are made interactively, with the purpose of exploring data. An ad-hoc query is commonly followed by another, more specific query&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;1.tns_request_duration_seconds_count&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;is a counter, a type of metric whose value only ever increases. Rather than visualizing the actual value, you can use counters to calculate the rate of change, i.e. how fast the value increases.

&lt;ol&gt;
&lt;li&gt;Add the rate function to your query to visualize the rate of requests per second. Enter the following in the Query editor and then press Shift + Enter.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;rate(tns_request_duration_seconds_count[5m])&lt;/p&gt;

&lt;p&gt;Immediately below the graph there’s an area where each time series is listed with a colored icon next to it. This area is called the legend.&lt;/p&gt;

&lt;p&gt;PromQL lets you group the time series by their labels, using the sum function.&lt;/p&gt;

&lt;p&gt;Add the sum function to your query to group time series by route:&lt;/p&gt;

&lt;p&gt;sum(rate(tns_request_duration_seconds_count[5m])) by(route)&lt;/p&gt;

&lt;h2&gt;
  
  
  Add a logging data source
&lt;/h2&gt;

&lt;p&gt;Grafana supports log data sources, like Loki. Just like for metrics, you first need to add your data source to Grafana.&lt;/p&gt;

&lt;h2&gt;
  
  
  Loki
&lt;/h2&gt;

&lt;p&gt;Grafana Loki is a set of components that can be composed into a fully featured logging stack.&lt;/p&gt;

&lt;p&gt;Grafana supports log data sources, like Loki. Just like for metrics, you first need to add your data source to Grafana.&lt;/p&gt;

&lt;p&gt;Explore logs&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;{filename="/var/log/tns-app.log"}&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Grafana displays all logs within the log file of the sample application. The height of each bar encodes the number of logs that were generated at that time.&lt;/p&gt;

&lt;p&gt;{filename="/var/log/tns-app.log"} |= "error"&lt;/p&gt;

&lt;p&gt;Logs are helpful for understanding what went wrong&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;you can correlate logs with metrics from Prometheus to better understand the context of the error.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Build a Dashboard
&lt;/h2&gt;

&lt;p&gt;A dashboard gives you an at-a-glance view of your data and lets you track metrics through different visualizations.&lt;/p&gt;

&lt;p&gt;Dashboards consist of panels, each representing a part of the story you want your dashboard to tell.&lt;/p&gt;

&lt;p&gt;Every panel consists of a query and a visualization. The query defines what data you want to display, whereas the visualization defines how the data is displayed.&lt;br&gt;
Unlike other logging systems, Loki is built around the idea of only indexing metadata about your logs: labels (just like Prometheus labels).&lt;/p&gt;

&lt;h2&gt;
  
  
  Annotate events
&lt;/h2&gt;

&lt;p&gt;When things go bad, it often helps if you understand the context in which the failure occurred. Time of last deploy, system changes, or database migration can offer insight into what might have caused an outage. Annotations allow you to represent such events directly on your graphs.&lt;/p&gt;

&lt;p&gt;query annotations&lt;br&gt;
{filename="/var/log/tns-app.log"} |= "error"&lt;/p&gt;

&lt;h2&gt;
  
  
  Alerts
&lt;/h2&gt;

&lt;p&gt;Alerts allow you to identify problems in your system moments after they occur. By quickly identifying unintended changes in your system, you can minimize disruptions to your services.&lt;/p&gt;

&lt;p&gt;Alerts consists of two parts:&lt;/p&gt;

&lt;p&gt;Notification channel - How the alert is delivered. When the conditions of an alert rule are met, the Grafana notifies the channels configured for that alert.&lt;br&gt;
Alert rules - When the alert is triggered. Alert rules are defined by one or more conditions that are regularly evaluated by Grafana.&lt;/p&gt;

&lt;p&gt;Supported Alert Notification Channels&lt;br&gt;
Email&lt;br&gt;
Slack&lt;br&gt;
Kafka&lt;br&gt;
Google Hangouts Chat&lt;br&gt;
Microsoft Teams&lt;br&gt;
etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  Others to look at
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;TICK stack&lt;/li&gt;
&lt;li&gt;Google cloud Monitoring&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devops</category>
      <category>monitoring</category>
      <category>programming</category>
    </item>
    <item>
      <title>Document Databases e.g MongoDB</title>
      <dc:creator>Josephat Macharia</dc:creator>
      <pubDate>Tue, 27 Oct 2020 14:25:36 +0000</pubDate>
      <link>https://dev.to/mashaa/document-databases-e-g-mongodb-508k</link>
      <guid>https://dev.to/mashaa/document-databases-e-g-mongodb-508k</guid>
      <description>&lt;p&gt;This course focuses on mapping the knowledge of:&lt;/p&gt;

&lt;p&gt;architects designing a database schema&lt;br&gt;
developers accessing the database from an application&lt;br&gt;
from SQL or RDBMS (Relational DataBase Management Systems) to MongoDB&lt;/p&gt;

</description>
    </item>
    <item>
      <title>17 days of code complete Day 1 - Chapter 1 and 2</title>
      <dc:creator>Josephat Macharia</dc:creator>
      <pubDate>Mon, 14 Sep 2020 21:19:04 +0000</pubDate>
      <link>https://dev.to/mashaa/17-days-of-code-complete-day-1-chapter-one-and-two-4740</link>
      <guid>https://dev.to/mashaa/17-days-of-code-complete-day-1-chapter-one-and-two-4740</guid>
      <description>&lt;p&gt;In the coming days i will be giving a summary and my own review and thoughts of &lt;a href="https://www.amazon.com/Code-Complete-Practical-Handbook-Construction/dp/0735619670" rel="noopener noreferrer"&gt;Code Complete&lt;/a&gt; book by Steve McConnell chapter by chapter. I hope you find this book review helpful.&lt;/p&gt;

&lt;h2&gt;
  
  
  Chapter 1
&lt;/h2&gt;

&lt;p&gt;What Is Software Construction?&lt;/p&gt;

&lt;p&gt;In common usage, “construction” refers to&lt;br&gt;
the process of building. The construction process might include some aspects of&lt;br&gt;
planning, designing, and checking your work, but mostly “construction” refers to&lt;br&gt;
the hands-on part of creating something&lt;/p&gt;

&lt;h2&gt;
  
  
  Construction activities:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;coding and debugging &lt;/li&gt;
&lt;li&gt;detailed design &lt;/li&gt;
&lt;li&gt;unit testing&lt;/li&gt;
&lt;li&gt;integration testing&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tasks involved in construction activities:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Verifying that the groundwork has been laid so that construction can proceed
successfully.&lt;/li&gt;
&lt;li&gt;Determining how your code will be tested.&lt;/li&gt;
&lt;li&gt;Designing and writing classes and routines.&lt;/li&gt;
&lt;li&gt;Creating and naming variables and named constants.&lt;/li&gt;
&lt;li&gt;Selecting control structures and organizing blocks of statements.&lt;/li&gt;
&lt;li&gt;Unit testing, integration testing, and debugging your own code.&lt;/li&gt;
&lt;li&gt;Reviewing other team members’ low-level designs and code and having
them review yours.&lt;/li&gt;
&lt;li&gt;Polishing code by carefully formatting and commenting it.&lt;/li&gt;
&lt;li&gt;Integrating software components that were created separately.&lt;/li&gt;
&lt;li&gt;Tuning code to make it smaller and faster.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Nonconstruction activities:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Management.&lt;/li&gt;
&lt;li&gt;Requirements development.&lt;/li&gt;
&lt;li&gt;Software architecture.&lt;/li&gt;
&lt;li&gt;User-interface design.&lt;/li&gt;
&lt;li&gt;System testing and maintenance&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why Is Software Construction Important? 
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Putting construction in its context with other activities helps&lt;br&gt;
keep the focus on the right tasks during construction and appropriately&lt;br&gt;
emphasizes important nonconstruction activities.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Construction is a large part of software development.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Construction is the central activity in software development.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;individual programmer’s productivity can improve enormously. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  My thoughts:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;When tuning code to make it smaller and faster one should be pragmatic about choosing algorithms, the fastest is not always the best for the job&lt;/li&gt;
&lt;li&gt;Design to test, build the tests before you implement the code.build testability into the software from the very beginning.&lt;/li&gt;
&lt;li&gt;Continuous integration and delivery should be part of the construction process to prevent the &lt;em&gt;integration hell&lt;/em&gt;, although integrating code frequently does not by itself offer any guarantees about the quality of the new code or functionality.&lt;/li&gt;
&lt;li&gt;Although not mandatory including acceptance testing to be part of the construction process minimizes the amount of bugs that could be realized. &lt;/li&gt;
&lt;li&gt;Well written code should be self documenting and does not need comments. &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Chapter 2: Metaphors for a Richer Understanding of Software Development
&lt;/h2&gt;

&lt;p&gt;A software metaphor is more like a searchlight than a roadmap. It doesn’t tell&lt;br&gt;
you where to find the answer; it tells you how to look for it. A metaphor serves&lt;br&gt;
more as a heuristic than it does as an algorithm.&lt;/p&gt;

&lt;p&gt;An &lt;em&gt;algorithm&lt;/em&gt; is predictable, deterministic, and not subject to chance&lt;/p&gt;

&lt;p&gt;A &lt;em&gt;heuristic&lt;/em&gt; is a technique that helps you look for an answer. Its results are&lt;br&gt;
subject to chance because a heuristic tells you only how to look, not what to find.&lt;br&gt;
It doesn’t tell you how to get directly from point A to point B; it might not even&lt;br&gt;
know where point A and point B are. In effect, a heuristic is an algorithm in a&lt;br&gt;
clown suit. It’s less predictable, it’s more fun, and it comes without a 30-day&lt;br&gt;
money-back guarantee&lt;/p&gt;

&lt;p&gt;The main difference between the two is the level of indirection from the solution.&lt;br&gt;
An algorithm gives you the instructions directly. A heuristic tells you how to discover the instructions for&lt;br&gt;
yourself, or at least where to look for them.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Use Software Metaphors
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Use them to give you insight into your programming problems and processes.&lt;/li&gt;
&lt;li&gt;Use them to help you think about your Programming activities and to help you imagine better ways of doing things.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Importance of Metaphors
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Metaphors have the virtue of an expected behavior that is understood by all.&lt;/li&gt;
&lt;li&gt;Unnecessary communication and misunderstandings are reduced.&lt;/li&gt;
&lt;li&gt;Learning and education are quicker.&lt;/li&gt;
&lt;li&gt;In effect, metaphors are a way of internalizing and abstracting concepts allowing one’s
thinking to be on a higher plane and low-levelmistakes to be avoided.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Common Software Metaphors
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Software Penmanship: Writing Code&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;“writing code.” The writing metaphor suggests that developing a
program is like writing a casual letter—you sit down with pen, ink, and paper
and write it from start to finish.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Software Farming: Growing a System&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating software as something like planting seeds and growing
crops. You design a piece, code a piece, test a piece, and add it to the system a
little bit at a time. By taking small steps, you minimize the trouble you can get
into at any one time.&lt;/li&gt;
&lt;li&gt;If you buy into the farming metaphor, you might find yourself talking
about fertilizing the system plan, thinning the detailed design, increasing code
yields through effective land management, and harvesting the code itself. &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Software Oyster Farming: System Accretion&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Learn how to add to your software systems a
small amount at a time. Other words closely related to 
accretion are
“incremental,” “iterative,” “adaptive,” and “evolutionary.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;4.Software Construction: Building Software&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If you’re building a first-class software product, you&lt;br&gt;
might build your own scientific functions for better speed or accuracy. You&lt;br&gt;
might build your own container classes, user interface &lt;br&gt;
classes and database&lt;br&gt;
classes to give your system a seamless, perfectly consistent &lt;br&gt;
look and feel.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Both building construction and software construction both benefit from&lt;br&gt;
appropriate levels of planning. If you build software in the wrong order, it’s hard&lt;br&gt;
to code, hard to test, and hard to debug. It can take longer to complete, or the&lt;br&gt;
project can fall apart because everyone’s work is too complex and therefore too&lt;br&gt;
confusing when it’s all combined.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The more experienced you have with the&lt;br&gt;
kind of software you’re building, the more details you can take for granted. You&lt;br&gt;
just want to be sure that you plan enough so that lack of planning doesn’t create&lt;br&gt;
major problems later.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In software you might generally use flexible,&lt;br&gt;
lightweight development approaches, but sometimes rigid, heavyweight&lt;br&gt;
approaches are required to achieve safety goals and other goals.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Making structural changes in a program costs more than adding or deleting peripheral features.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;5.Toolbox Metaphor&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A good craftsman knows the&lt;br&gt;
right tool for the job and knows how to use it correctly. Programmers do too.&lt;br&gt;
The more you learn about programming, the more you fill your mental toolbox&lt;br&gt;
with analytical tools and the knowledge of when to use them and how to use&lt;br&gt;
them correctly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The toolbox metaphor helps to keep all the methods, techniques, and tips in&lt;br&gt;
perspective—ready for use when appropriate.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To extend the “building a house metaphor” construction workers do not use a single tool — the hammer — to build a house. Instead, they have a complete toolbox full of different implements for the varied tasks involved in construction. Likewise, in software engineering, or data science, the person who only knows one method will not get very far.You should be open to learning from others, respond constructively to feedback, and fill your toolbox with the appropriate techniques.&lt;/p&gt;

</description>
      <category>programming</category>
    </item>
  </channel>
</rss>
