<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ metrics - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ metrics - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Sun, 20 Sep 2026 21:09:19 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/metrics/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How OpenTelemetry Works: A Complete Guide ]]>
                </title>
                <description>
                    <![CDATA[ If you’re a software developer or DevOps engineer, you've probably come across OpenTelemetry. It comes up a lot, especially when talking about observability, monitoring, or debugging distributed syste ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-opentelemetry-works/</link>
                <guid isPermaLink="false">6a999540c11d1e5beaccfefc</guid>
                
                    <category>
                        <![CDATA[ OpenTelemetry ]]>
                    </category>
                
                    <category>
                        <![CDATA[ observability ]]>
                    </category>
                
                    <category>
                        <![CDATA[ distributed tracing ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Devops ]]>
                    </category>
                
                    <category>
                        <![CDATA[ cloud native ]]>
                    </category>
                
                    <category>
                        <![CDATA[ monitoring ]]>
                    </category>
                
                    <category>
                        <![CDATA[ OTLP ]]>
                    </category>
                
                    <category>
                        <![CDATA[ opentelemetry collector ]]>
                    </category>
                
                    <category>
                        <![CDATA[ metrics ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Logs ]]>
                    </category>
                
                    <category>
                        <![CDATA[ traces ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Chosen Vincent ]]>
                </dc:creator>
                <pubDate>Thu, 03 Sep 2026 15:41:52 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/uploads/covers/5e1e335a7a1d3fcc59028c64/32307170-27b3-463c-bae9-da3dbfd2a634.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>If you’re a software developer or DevOps engineer,&nbsp;you've probably come across OpenTelemetry. It comes up a lot, especially when talking about observability, monitoring, or debugging distributed systems.</p>
<p>You might even know the basic definition, but knowing what OpenTelemetry is vs how it actually works are two different things.</p>
<p>By the end of this guide, you'll understand how OpenTelemetry works end-to-end, from the moment a request enters your application to the moment you can see it in your observability backend. You'll learn how traces, spans, context propagation, and exporters all fit together into one pipeline.</p>
<p>If you're completely new to OpenTelemetry, don't worry: the next section will get you up to speed before we go any further.</p>
<h2 id="heading-table-of-contents">Table of Contents</h2>
<ul>
<li><p><a href="#heading-what-is-opentelemetry">What is OpenTelemetry?</a></p>
</li>
<li><p><a href="#heading-how-opentelemetry-works">How OpenTelemetry Works</a></p>
<ul>
<li><p><a href="#heading-step-1-instrument-your-application">Step 1: Instrument Your Application</a></p>
</li>
<li><p><a href="#heading-step-2-opentelemetry-creates-telemetry-signals">Step 2: OpenTelemetry Creates Telemetry Signals</a></p>
</li>
<li><p><a href="#heading-step-3-traces-follow-requests-through-your-application">Step 3: Traces Follow Requests Through Your Application</a></p>
</li>
<li><p><a href="#heading-step-4-context-propagation-connects-work-across-services">Step 4: Context Propagation Connects Work Across Services</a></p>
</li>
<li><p><a href="#heading-step-5-the-opentelemetry-sdk-processes-the-telemetry">Step 5: The OpenTelemetry SDK Processes the Telemetry</a></p>
</li>
<li><p><a href="#heading-step-6-exporters-send-the-telemetry">Step 6: Exporters Send the Telemetry</a></p>
</li>
<li><p><a href="#heading-step-7-the-opentelemetry-collector-receives-and-processes-the-data">Step 7: The OpenTelemetry Collector Receives and Processes the Data</a></p>
</li>
<li><p><a href="#heading-step-8-an-observability-backend-stores-and-analyzes-the-telemetry">Step 8: An Observability Backend Stores and Analyzes the Telemetry</a></p>
</li>
</ul>
</li>
<li><p><a href="#heading-putting-the-opentelemetry-flow-together">Putting the OpenTelemetry Flow Together</a></p>
</li>
<li><p><a href="#heading-do-you-need-every-opentelemetry-component">Do You Need Every OpenTelemetry Component?</a></p>
</li>
<li><p><a href="#heading-why-use-opentelemetry">Why Use OpenTelemetry?</a></p>
</li>
<li><p><a href="#heading-conclusion">Conclusion</a></p>
</li>
</ul>
<h2 id="heading-what-is-opentelemetry">What is OpenTelemetry?</h2>
<p><a href="https://opentelemetry.io/docs/">OpenTelemetry</a> is an open-source, vendor-neutral observability framework. It gives you a standard way to instrument your application, generate telemetry data, and export that data to any observability backend of your choice.</p>
<p>Before OpenTelemetry, every monitoring tool had its own way of collecting data. If you used Datadog, you’ll have to instrument your app the Datadog way. If you switched to Jaeger, you started over. OpenTelemetry changed that by giving you one standard way to instrument your application, regardless of which backend you use</p>
<p>[!NOTE] OpenTelemetry is not a monitoring platform, dashboard, or data store. It provides the tools and standards for collecting and exporting telemetry from your application to an observability backend, where the data can be stored, queried, and analyzed.</p>
<p>The data OpenTelemetry collects is called telemetry. It's the information your application produces about itself as it runs, and it comes in three forms:</p>
<ul>
<li><p><strong>Traces</strong> tell you how a request traveled through your system.</p>
</li>
<li><p><strong>Metrics</strong> give you numbers, like how many requests per second your app is handling, or how much memory it's using.</p>
</li>
<li><p><strong>Logs</strong> are timestamped records of specific events that happened inside your application.</p>
</li>
</ul>
<h2 id="heading-how-opentelemetry-works">How OpenTelemetry Works</h2>
<p>When a request hits your application, a lot happens behind the scenes. OpenTelemetry's job is to capture all of that activity (the traces, metrics, and logs) and send them to the right place.</p>
<p>Here’s what it looks like:</p>
<img src="https://cdn.hashnode.com/uploads/covers/62bc299d9c913efac56c91a4/238d33f9-2a15-49b4-993b-43c073a48305.png" alt="A flow diagram showing the six stages of the OpenTelemetry pipeline: the application is instrumented, telemetry is processed by the SDK, sent through an exporter, received by the Collector, and finally stored in an observability backend." style="display: block;" width="600" height="400" loading="lazy">

<p>Each stage has a specific job. Let's walk through them one by one.</p>
<h3 id="heading-step-1-instrument-your-application">Step 1: Instrument Your Application</h3>
<p>Before OpenTelemetry can capture anything, your application needs to be instrumented. Instrumentation is simply the process of adding code that tells OpenTelemetry what to watch and what to record.</p>
<p>There are two ways to instrument your application: automatically or manually.</p>
<h4 id="heading-1-automatic-instrumentation">1. Automatic instrumentation</h4>
<p>This is the easiest one to start with. You add a library to your project, and it instruments your application for you with no changes to your existing code.</p>
<p>For example, if you're running a Node.js Express app, you can add the OpenTelemetry auto-instrumentation package, and it will automatically start capturing incoming HTTP requests, outgoing calls, database queries, and more.</p>
<p>Here's what that setup looks like:</p>
<pre><code class="language-javascript">const { NodeSDK } = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');

const sdk = new NodeSDK({
&nbsp; instrumentations: [getNodeAutoInstrumentations()],
});

sdk.start();
</code></pre>
<p>Once this runs before your app starts, OpenTelemetry begins capturing telemetry automatically. For a complete setup guide, see <a href="https://opentelemetry.io/docs/languages/js/getting-started/nodejs/">Getting started with OpenTelemetry in Node.js</a>.</p>
<h4 id="heading-2-manual-instrumentation">2. Manual instrumentation</h4>
<p>Automatic instrumentation covers a lot, but it can't capture everything that happens inside your own code. If you want to track what happens inside a specific function, like how long it takes to process a payment or validate a user, you need to add that yourself.</p>
<p>Here's a simple example. Let’s say you have a function that processes an order:</p>
<pre><code class="language-javascript">function processOrder(orderId) {
  // processing logic
}
</code></pre>
<p>With manual instrumentation, you wrap it like this:</p>
<pre><code class="language-javascript">const { trace } = require('@opentelemetry/api');

const tracer = trace.getTracer('order-service');

function processOrder(orderId) {
  return tracer.startActiveSpan('processOrder', (span) =&gt; {
    // processing logic

    span.end();
  });
}
</code></pre>
<p>What happens is that you created a span. That span now records when <code>processOrder</code> started, when it ended, and how long it took. You'll learn more about spans in Step 3.</p>
<p>For the full manual instrumentation reference, see <a href="https://opentelemetry.io/docs/languages/js/instrumentation/#traces">OpenTelemetry JavaScript instrumentation</a>.</p>
<h3 id="heading-step-2-opentelemetry-creates-telemetry-signals">Step 2: OpenTelemetry Creates Telemetry Signals</h3>
<p>Once your application is instrumented, OpenTelemetry starts producing telemetry data about what your application is doing. That data comes in three forms, called signals, which we've already briefly talked about: <a href="https://opentelemetry.io/docs/concepts/signals/traces/">traces</a>, <a href="https://opentelemetry.io/docs/concepts/signals/metrics/">metrics</a>, and <a href="https://opentelemetry.io/docs/concepts/signals/logs/">logs</a>. Each signal answers a different kind of observability question.</p>
<p><strong>Traces</strong> show you how a request moved through your system, which services it touched, and how long each step took. <strong>Metrics</strong> give you numbers over time, things like request rate, error rate, and memory usage. <strong>Logs</strong> are timestamped records of specific events that happened inside your application.</p>
<p>Here's a quick comparison:</p>
<table>
<thead>
<tr>
<th>Signal</th>
<th>What to shows</th>
<th>Example</th>
<th>Question it answers</th>
</tr>
</thead>
<tbody><tr>
<td>Trace</td>
<td>The journey of a request through your system</td>
<td>A checkout request passing through your API, order service, and database</td>
<td>Why is this request slow? Where did it fail?</td>
</tr>
<tr>
<td>Metric</td>
<td>A measured value over time</td>
<td>200 requests per second, 95ms average response time</td>
<td>Is my application healthy right now?</td>
</tr>
<tr>
<td>Log</td>
<td>A record of a specific event</td>
<td><code>ERROR: payment failed for order #1234</code></td>
<td>What exactly happened at this point in time?</td>
</tr>
</tbody></table>
<p>You don't have to choose between them. In practice, you'll use all three together. A metric tells you something is wrong, a trace shows you where, and a log tells you exactly what happened.</p>
<h3 id="heading-step-3-traces-follow-requests-through-your-application">Step 3: Traces Follow Requests Through Your Application</h3>
<p>When a user sends a request to your application, that request usually touches multiple services before a response comes back. A trace is the complete record of that journey, from the moment the request enters your system to the moment it finishes.</p>
<p>A trace is actually made up of smaller units called <strong>spans</strong>. Each span represents one operation, like an API call, a database query, or a function execution, and together they give you the full picture of what happened.</p>
<p>Every trace gets a unique trace ID, and every span gets its own span ID. The trace ID is what links all the spans together. No matter how many services a request passes through, they all share the same trace ID, so you can follow the request from start to finish in your observability backend.</p>
<p>Here's a simple example. A user places an order, and the request flows through four services:</p>
<img src="https://cdn.hashnode.com/uploads/covers/62bc299d9c913efac56c91a4/f1672972-b0d7-4a60-964a-7583946affad.png" alt="Trace tree diagram showing four spans under trace ID abc123: API Gateway (0–5ms), Order Service (5–20ms), Payment Service (20–45ms), and Database (45–50ms)." style="display: block;" width="600" height="400" loading="lazy">

<p>Each span has a start time and an end time, so you can see how long each operation took. If something slowed down or failed, you can pinpoint exactly where it happened just by looking at the spans.</p>
<h3 id="heading-step-4-context-propagation-connects-work-across-services">Step 4: Context Propagation Connects Work Across Services</h3>
<p>In Step 3, you saw how a single trace is made up of spans from multiple services. But here's a question you need to ask: how does OpenTelemetry know that a span in your payment service belongs to the same trace as a span in your order service?</p>
<p>Without something connecting them, each service would record its own spans independently. Your API gateway would see one operation, your order service would see another, and your payment service would see a third. They'd look like completely separate requests with no relationship to each other, which makes debugging across services nearly impossible.</p>
<p>That's where context propagation comes in. As a request moves from one service to another, OpenTelemetry attaches the trace context to it, typically as HTTP headers. That context carries the trace ID and the parent span ID, so every service that handles the request knows which trace it belongs to and where it sits in the chain.</p>
<p>Here's what that looks like in practice:</p>
<img src="https://cdn.hashnode.com/uploads/covers/62bc299d9c913efac56c91a4/526efe4d-2d79-4cdb-b42d-80d8b304312a.png" alt="Context propagation diagram showing trace ID abc123 traveling across API Gateway (span-id: 001), Order Service (span-id: 002), and Payment Service (span-id: 003) via HTTP headers." style="display: block;" width="600" height="400" loading="lazy">

<p>All three services share the same trace ID. That's what lets your observability backend connect the spans together into one complete trace.</p>
<p>OpenTelemetry doesn't invent its own rules for this. It follows the <a href="https://opentelemetry.io/docs/concepts/context-propagation/#propagation">W3C Trace Context</a> standard, a widely adopted specification that defines how trace context should be formatted and passed between services, so it works consistently across different languages, frameworks, and vendors.</p>
<p>The good news is that if you're using automatic instrumentation, context propagation happens automatically. OpenTelemetry handles the headers for you, so you don't have to think about it unless you're working with a custom transport or a non-standard setup.</p>
<h3 id="heading-step-5-the-opentelemetry-sdk-processes-the-telemetry">Step 5: The OpenTelemetry SDK Processes the Telemetry</h3>
<p>At this point, OpenTelemetry is capturing telemetry and keeping traces connected across services. But between the moment a span is created and the moment it leaves your application, something has to process it. That's the SDK's job.</p>
<p>When your instrumented code creates a span, it does that through the OpenTelemetry API. The API is what you interact with as a developer, things like <code>trace.getTracer()</code> and <code>tracer.startActiveSpan()</code>. But the API alone doesn't process or send anything. It needs the SDK behind it to actually do the work.</p>
<img src="https://cdn.hashnode.com/uploads/covers/62bc299d9c913efac56c91a4/e35443fa-2eff-461d-983a-d6bf3bcd5163.png" alt="A flow diagram showing what happens inside OpenTelemetry before data leaves your application: instrumentation creates telemetry, the API receives it, the SDK processes it, a processor prepares it, and the exporter sends it out." style="display: block;" width="600" height="400" loading="lazy">

<p>Once the SDK receives the telemetry, it runs it through a processor. The processor is responsible for things like batching spans together before sending them, adding extra attributes, or filtering out data you don't need. The most common one you'll see is the <code>BatchSpanProcessor</code>, which groups spans and exports them in batches rather than one at a time, making it more efficient in production.</p>
<p>Before the processor even runs, the SDK also handles sampling. Sampling lets you control how much telemetry you actually collect. In high-traffic applications, recording every single span would generate an enormous amount of data. With sampling, you can tell the SDK to only capture a percentage of traces, which keeps your costs and data volume manageable without losing visibility.</p>
<p>Once the processor is done, it hands the data to the exporter, which is what actually sends it to its destination. You'll see how that works in the next step.</p>
<h3 id="heading-step-6-exporters-send-the-telemetry">Step 6: Exporters Send the Telemetry</h3>
<p>The exporter's job is simple: take the telemetry the SDK prepared and send it to whatever destination you've configured.</p>
<p>OpenTelemetry uses OTLP, the OpenTelemetry Protocol, to transport telemetry data. It's a standard wire protocol designed specifically for transmitting traces, metrics, and logs, and it runs over either HTTP or gRPC.</p>
<p>[!NOTE] OTLP and OpenTelemetry are not the same thing. OpenTelemetry is the full framework, covering instrumentation, the SDK, the Collector, and more. OTLP is just the protocol it uses to transport data.</p>
<p>Although OTLP is the default, not every exporter uses it. Some exporters send data directly to specific backends in their own format, like Jaeger or Prometheus. So depending on your setup, you might use an OTLP exporter to send data to a Collector or backend, or a vendor-specific exporter to send it directly."</p>
<h3 id="heading-step-7-the-opentelemetry-collector-receives-and-processes-the-data">Step 7: The OpenTelemetry Collector Receives and Processes the Data</h3>
<p>The OpenTelemetry Collector is a standalone service that sits between your application and your observability backend. It receives telemetry data, processes it, and forwards it to one or more destinations.</p>
<p>Using the Collector is common but not mandatory. You can configure your exporter to send data directly to your backend and skip the Collector entirely. But in most production setups, teams add a Collector because it gives them a central place to manage telemetry, without touching application code.</p>
<p>The Collector has three stages:</p>
<ul>
<li><p><strong>Receivers</strong> accept incoming telemetry from your applications, typically over OTLP.</p>
</li>
<li><p><strong>Processors</strong> transform the data at the Collector level, things like batching spans, filtering out noise, or adding attributes before forwarding.</p>
</li>
<li><p><strong>Exporters</strong> send the processed data to your backend, or multiple backends if needed.</p>
</li>
</ul>
<p>Here's a minimal Collector configuration:</p>
<pre><code class="language-yaml">receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317

processors:
  batch:

exporters:
  otlphttp:
    endpoint: https://your-backend.com

service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [batch]
      exporters: [otlphttp]
</code></pre>
<p>This config accepts traces over gRPC, batches them for efficiency, and forwards them to an observability backend over HTTP.</p>
<p>The Collector can also receive data from multiple applications simultaneously and route it to one or more destinations. So instead of each application shipping telemetry directly to your backend, they all send it to the Collector, and the Collector handles the rest.</p>
<p>For the full configuration, see the <a href="https://opentelemetry.io/docs/collector/configuration/">OpenTelemetry Collector configuration docs</a>.</p>
<h3 id="heading-step-8-an-observability-backend-stores-and-analyzes-the-telemetry">Step 8: An Observability Backend Stores and Analyzes the Telemetry</h3>
<p>This is where OpenTelemetry's job ends. Once your telemetry leaves the Collector, it arrives at your observability backend.</p>
<p>The backend is what stores your data, lets you query it, and gives you the dashboards and alerts you actually interact with day to day. OpenTelemetry doesn't provide any of that. It gets the data there, and the backend does the rest.</p>
<p>A few popular backends that support OpenTelemetry natively:</p>
<ul>
<li><p><strong>Open-source:</strong> Jaeger, Prometheus, Grafana Tempo</p>
</li>
<li><p><strong>Commercial:</strong> Datadog, New Relic, Honeycomb, Dynatrace, Elastic, Lightstep, Grafana Cloud, Middleware.</p>
</li>
</ul>
<p>Once your data is in the backend, you can search through traces to debug a slow request, build dashboards to monitor your application's health, and set up alerts when something goes wrong.</p>
<h2 id="heading-putting-the-opentelemetry-flow-together">Putting the OpenTelemetry Flow Together</h2>
<p>Let’s assume a user initiates a bank transfer on a mobile banking app. The request hits your API gateway, and because your application is instrumented, OpenTelemetry immediately starts capturing what’s happening. It creates a span for the incoming request and assigns it a trace ID.</p>
<p>As the request moves to the authentication service, context propagation carries that trace ID along in the request headers. The authentication service creates its own span and attaches it to the same trace. The same thing happens when the authentication service calls the transaction service, and when the transaction service hits the database to process the transfer. Four services and four spans, with one trace ID connecting them all.</p>
<p>Meanwhile, the SDK processes the telemetry in the background, runs the spans through the batch processor, and hands them to the exporter. The exporter packages everything into OTLP and sends it to the Collector, which applies your processing rules and forwards it to your observability backend.</p>
<p>Here’s a summary of every component involved in that flow:</p>
<table>
<thead>
<tr>
<th><strong>Component</strong></th>
<th>Role</th>
</tr>
</thead>
<tbody><tr>
<td>Instrumentation</td>
<td>Captures what’s happening inside your application</td>
</tr>
<tr>
<td>API</td>
<td>Exposes the methods your code calls to create spans, metrics, and logs</td>
</tr>
<tr>
<td>SDK</td>
<td>Processes and prepares telemetry for export</td>
</tr>
<tr>
<td>Exporter</td>
<td>Packages and sends telemetry via OTLP</td>
</tr>
<tr>
<td>Collector</td>
<td>Receives, processes, and routes telemetry to your backend</td>
</tr>
<tr>
<td>Observability backend</td>
<td>Stores, queries, and visualizes your telemetry</td>
</tr>
</tbody></table>
<p>From that single transfer request, you now have a complete trace in your backend. When you open your dashboard and search the trace ID, you'll see every service, every span, and every millisecond of that transaction laid out in front of you.</p>
<h2 id="heading-do-you-need-every-opentelemetry-component">Do You Need Every OpenTelemetry Component?</h2>
<p>To be honest, you don’t need every component to get started with OpenTelemetry. The pipeline you’ve seen throughout this article is the full setup, but not every team uses all of that.</p>
<ol>
<li><p><strong>Without the Collector:</strong> Your exporter sends telemetry directly to your backend with nothing in between. Works well for smaller projects or when you're just getting started.</p>
</li>
<li><p><strong>With the Collector:</strong> The more common production setup. Teams add the Collector when they need more control, like routing telemetry to multiple backends, filtering sensitive data, or managing telemetry from dozens of services in one place.</p>
</li>
</ol>
<p>The Collector is powerful, but it’s not mandatory. Start without it if your setup is simple, and add it when you actually need it.</p>
<h2 id="heading-why-use-opentelemetry">Why Use OpenTelemetry?</h2>
<p>You've now seen how every piece of OpenTelemetry fits together. Here's why it's worth using:</p>
<ul>
<li><p><strong>Vendor-neutral instrumentation:</strong> Before OpenTelemetry, switching observability tools meant you had to re-instrument your entire application from scratch. With OpenTelemetry, you instrument once and switch backends freely.</p>
</li>
<li><p><strong>Consistent telemetry across services and languages:</strong> Your backend might be in Go, your microservices in Python, and your data pipeline in Java. OpenTelemetry has SDKs for all of them, and they all produce telemetry in the same format, so your whole stack speaks the same language.</p>
</li>
<li><p><strong>Correlated observability signals:</strong> Traces, metrics, and logs all flow through the same pipeline. So when something goes wrong, a spike in your metrics leads you to a trace, and that trace points you to the exact log entry where things broke down.</p>
</li>
<li><p><strong>It's becoming the industry standard:</strong> Most observability backends already support OpenTelemetry natively. Instead of learning a vendor-specific instrumentation approach every time you adopt a new tool, you learn OpenTelemetry once and it works everywhere.</p>
</li>
</ul>
<h2 id="heading-conclusion">Conclusion</h2>
<p>OpenTelemetry gives you a standard way to instrument your application, collect telemetry, and ship it to any backend you choose, without locking you into a specific vendor or tool.</p>
<p>If you remember nothing else from this article, remember this: you instrument your application, generate telemetry, process it, export it, and analyze it. Every step has a component behind it, and now you know what each one does.</p>
<p>If you're just getting started, you don't need to set everything up at once. Start with instrumentation, get your telemetry flowing to a backend, and add the Collector when you need it. You can always add more as your needs grow.</p>
<p>If you found this helpful, I'd love to connect. You can find me on <a href="https://www.linkedin.com/in/chosenvincent1">LinkedIn</a> or <a href="https://x.com/ChosenVincent1">X</a>. Feel free to reach out if you have questions or just want to talk about observability and developer tooling.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ From Metrics to Meaning: How PaaS Helps Developers Understand Production ]]>
                </title>
                <description>
                    <![CDATA[ Modern production systems generate more data than most developers can realistically process. Every request emits logs. Every service exports metrics. Every dependency introduces another layer of signa ]]>
                </description>
                <link>https://www.freecodecamp.org/news/from-metrics-to-meaning-how-paas-helps-developers-understand-production/</link>
                <guid isPermaLink="false">69ea4e46904b91543899894d</guid>
                
                    <category>
                        <![CDATA[ PaaS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ infrastructure ]]>
                    </category>
                
                    <category>
                        <![CDATA[ metrics ]]>
                    </category>
                
                    <category>
                        <![CDATA[ production ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Manish Shivanandhan ]]>
                </dc:creator>
                <pubDate>Thu, 23 Apr 2026 16:52:22 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/uploads/covers/5e1e335a7a1d3fcc59028c64/e30cdb93-e709-4f28-89fc-ba004735e400.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Modern production systems generate more data than most developers can realistically process.</p>
<p>Every request emits logs. Every service exports metrics. Every dependency introduces another layer of signals.</p>
<p>In theory, this should make systems easier to understand. In practice, it does the opposite.</p>
<p>Dashboards become dense, alerts become noisy, and when something breaks, the same questions still come up: What's actually wrong? Who's affected? Where do you even start?</p>
<p>The problem isn't observability. It's interpretation.</p>
<p>Most teams aren't short on metrics. They're short on meaning.</p>
<p>And that gap exists because developers are often forced to reason about infrastructure when they should be focused on application behaviour.</p>
<p>Metrics exist to describe systems, but without the right level of abstraction, they become another layer of complexity.</p>
<p>This is where modern PaaS platforms change the equation. They don't remove metrics. Instead, they turn them into signals that developers can actually use.</p>
<p>This article breaks down five metrics that consistently matter in production systems. More importantly, it shows how a PaaS helps translate these metrics into something actionable, without requiring developers to act as infrastructure operators.</p>
<p>I’ll be using the <a href="https://sevalla.com/">Sevalla</a> dashboard to explain these metrics, but other platforms like Railway and Render will have similar metrics.</p>
<h3 id="heading-what-well-cover">What We'll Cover:</h3>
<ul>
<li><p><a href="#heading-what-a-paas-actually-does">What a PaaS Actually Does</a></p>
</li>
<li><p><a href="#heading-latency-becomes-a-clear-performance-signal">Latency Becomes a Clear Performance Signal</a></p>
</li>
<li><p><a href="#heading-error-rate-becomes-a-reliable-indicator-of-failure">Error Rate Becomes a Reliable Indicator of Failure</a></p>
</li>
<li><p><a href="#heading-throughput-becomes-context-instead-of-a-problem">Throughput Becomes Context Instead of a Problem</a></p>
</li>
<li><p><a href="#heading-resource-utilisation-moves-out-of-the-critical-path">Resource Utilisation Moves Out of the Critical Path</a></p>
</li>
<li><p><a href="#heading-instance-health-becomes-invisible-by-design">Instance Health Becomes Invisible by Design</a></p>
</li>
<li><p><a href="#heading-from-metrics-to-meaning">From Metrics to Meaning</a></p>
</li>
<li><p><a href="#heading-why-this-matters-for-developers">Why This Matters for Developers</a></p>
</li>
<li><p><a href="#heading-the-real-advantage-is-clarity">The Real Advantage Is Clarity</a></p>
</li>
</ul>
<h2 id="heading-what-a-paas-actually-does">What a PaaS Actually Does</h2>
<p>A Platform as a Service (PaaS) is an abstraction layer over infrastructure that handles deployment, scaling, networking, and runtime management for you.</p>
<p>Instead of provisioning servers, configuring load balancers, and setting up autoscaling rules, you deploy your application and the platform takes care of how it runs in production.</p>
<p>Platforms like Sevalla, Railway, and Render operate on this model. The key shift is responsibility.</p>
<p>In a traditional setup, developers are responsible for both application behaviour and infrastructure behaviour. If latency spikes or errors increase, you have to determine whether the issue is in your code, your scaling rules, or the underlying system.</p>
<p>A PaaS moves most of that infrastructure responsibility into the platform.</p>
<p>You still get access to metrics, but many of the variables behind those metrics –instance lifecycle, scaling decisions, resource allocation –&nbsp;are handled automatically.</p>
<p>This changes how you interpret what you see.</p>
<p>Metrics stop being signals that require cross-layer investigation, and start becoming signals that map more directly to application behaviour.</p>
<p>Now let's see what can happen if your team switches to using a PaaS.</p>
<h2 id="heading-latency-becomes-a-clear-performance-signal"><strong>Latency Becomes a Clear Performance Signal</strong></h2>
<img src="https://cdn.hashnode.com/uploads/covers/66c6d8f04fa7fe6a6e337edd/4b0ed69b-d122-497c-9cd4-ad8d7b29584a.webp" alt="Latency graph" style="display: block;" width="1535" height="410" loading="lazy">

<p>Latency is the most direct representation of user experience. It tells you how long your system takes to respond.</p>
<p>When latency increases, users feel it immediately. Pages slow down. APIs become unreliable. Even small delays impact engagement.</p>
<p>Most developers know to look at percentiles like p95 or p99 instead of averages. The slowest requests are what define perceived performance.</p>
<p>But in many environments, understanding latency isn't straightforward.</p>
<p>A spike could come from inefficient code. Or from cold starts. Or from scaling delays. Or from network routing issues. Developers are forced to investigate layers they didn't build.</p>
<p>This is where a PaaS changes the role of latency.</p>
<img src="https://cdn.hashnode.com/uploads/covers/66c6d8f04fa7fe6a6e337edd/d22aac3e-5a50-4f6c-baa9-63afc388da54.webp" alt="Speed metrics" style="display: block;" width="1536" height="562" loading="lazy">

<p>Instead of being a starting point for infrastructure debugging, latency becomes a clean signal of application performance. Scaling, routing, and resource allocation are handled by the platform. What remains is a clearer relationship between code and outcome.</p>
<p>When latency increases, developers can focus on what they actually control: queries, logic, and dependencies.</p>
<p>The metric stays the same. The meaning becomes clearer.</p>
<h2 id="heading-error-rate-becomes-a-reliable-indicator-of-failure"><strong>Error Rate Becomes a Reliable Indicator of Failure</strong></h2>
<img src="https://cdn.hashnode.com/uploads/covers/66c6d8f04fa7fe6a6e337edd/664b6eab-f43d-4aec-a412-825d0c7c060b.webp" alt="Error rate graph" style="display: block;" width="1226" height="288" loading="lazy">

<p>Error rate answers a simple question. Is the system working or not?</p>
<p>It's usually measured as the percentage of requests that fail due to server-side issues. These are failures users can't recover from. A broken checkout flow or a failed API call directly impacts trust.</p>
<p>In theory, error rate should be one of the easiest metrics to act on. In practice, it rarely is.</p>
<p>Errors can come from application bugs, but also from timeouts, resource limits, failed deployments, or unstable instances. Developers end up correlating errors with infrastructure events just to understand what happened.</p>
<p>This slows everything down.</p>
<p>A PaaS reduces this ambiguity.</p>
<p>Failures caused by scaling, instance crashes, or transient infrastructure issues are handled at the platform level. Retries, isolation, and recovery mechanisms are built in.</p>
<p>What remains is a tighter link between error rate and application correctness.</p>
<p>When the error rate increases, it's far more likely to be something in the code or a dependency, not an invisible infrastructure issue.</p>
<p>This shifts the error rate from a noisy metric into a reliable signal.</p>
<h2 id="heading-throughput-becomes-context-instead-of-a-problem"><strong>Throughput Becomes Context Instead of a Problem</strong></h2>
<img src="https://cdn.hashnode.com/uploads/covers/66c6d8f04fa7fe6a6e337edd/045bbee4-8d29-4a9f-a6e7-e235e08bc920.webp" alt="Throughput graph" style="display: block;" width="1533" height="398" loading="lazy">

<p>Throughput measures how many requests your system handles over time.</p>
<p>It provides context for everything else. Latency and error rate only make sense when you know how much traffic the system is handling.</p>
<p>A spike in latency during high traffic is expected. The same spike during low traffic is a warning sign.</p>
<p>But in many systems, throughput introduces operational complexity. Traffic changes require scaling decisions. Teams define autoscaling rules, tune thresholds, and try to predict demand. When things go wrong, they revisit those decisions.</p>
<p>Developers end up thinking about capacity instead of behaviour.</p>
<p>A PaaS shifts this responsibility. Scaling is automatic. Traffic spikes are absorbed by the platform. Developers don't need to decide how many instances should be running or when to scale.</p>
<p>Throughput becomes what it should be: context.</p>
<p>It helps explain what's happening, without forcing developers to manage how the system adapts.</p>
<h2 id="heading-resource-utilisation-moves-out-of-the-critical-path"><strong>Resource Utilisation Moves Out of the Critical Path</strong></h2>
<img src="https://cdn.hashnode.com/uploads/covers/66c6d8f04fa7fe6a6e337edd/3636488f-7648-4db8-ae00-1c8374ca46ba.webp" alt="Sytem utilization" style="display: block;" width="1534" height="517" loading="lazy">

<p>Resource utilization measures how much CPU, memory, and I/O your system consumes.</p>
<p>Traditionally, this has been central to operating systems. High CPU or memory usage signals potential issues. Teams monitor these metrics to avoid failures and plan scaling.</p>
<p>But for most developers, resource utilization isn't where value is created.</p>
<p>Yet in many environments, developers are still responsible for interpreting these signals. They tune memory limits, investigate CPU spikes, and try to optimise resource usage to keep systems stable.</p>
<p>This is operational work.</p>
<p>A PaaS changes the role of these metrics.</p>
<p>Resource management is handled by the platform. Allocation, scaling, and isolation happen automatically. Developers don't need to constantly watch CPU graphs or memory charts to keep the system running.</p>
<p>These metrics still exist, but they move into the background.</p>
<p>They become diagnostic tools rather than primary signals.</p>
<p>Developers can focus on performance at the application level, instead of managing how infrastructure behaves under load.</p>
<h2 id="heading-instance-health-becomes-invisible-by-design"><strong>Instance Health Becomes Invisible by Design</strong></h2>
<img src="https://cdn.hashnode.com/uploads/covers/66c6d8f04fa7fe6a6e337edd/fd4a755d-c90c-45fd-843e-9be5e5f85caf.webp" alt="Instance health" style="display: block;" width="1544" height="417" loading="lazy">

<p>Instance health tracks restarts, crashes, and lifecycle events.</p>
<p>In many systems, this is a critical metric. Frequent restarts indicate instability. Memory leaks, crashes, or resource exhaustion often show up here first.</p>
<p>Teams monitor instance health to catch issues early and prevent cascading failures.</p>
<p>But this also reveals something important: developers are aware of, and responsible for, the lifecycle of infrastructure. They track restarts, investigate crashes, and try to stabilise the system manually.</p>
<p>A PaaS removes this responsibility.</p>
<p>Unhealthy instances are restarted automatically. Load is redistributed. Capacity is maintained without manual intervention.</p>
<p>Instance health doesn't disappear, but it no longer requires constant attention. It becomes part of the platform’s internal behaviour, not something developers need to actively manage.</p>
<h2 id="heading-from-metrics-to-meaning"><strong>From Metrics to Meaning</strong></h2>
<p>These five metrics haven't changed.</p>
<p>Latency still reflects performance. Error rate still reflects correctness. Throughput still reflects demand. Resource utilization still reflects efficiency. Instance health still reflects stability.</p>
<p>What changes is how much work it takes to interpret them.</p>
<p>In lower-level environments, developers have to connect these signals themselves. A latency spike leads to checking throughput, then resource usage, then instance behaviour. Each step requires context, assumptions, and time.</p>
<p>This is where complexity accumulates.</p>
<p>A PaaS reduces that gap.</p>
<p>It handles scaling, recovery, and resource management so that metrics map more directly to application behaviour. The signals become easier to interpret because fewer variables are exposed.</p>
<p>Instead of asking multiple questions across layers, developers can move more directly from symptom to cause.</p>
<h2 id="heading-why-this-matters-for-developers"><strong>Why This Matters for Developers</strong></h2>
<p>Most developers don't want to manage infrastructure. They want to build features, ship improvements, and respond to user needs.</p>
<p>But as systems grow, operational responsibility expands. Monitoring becomes more complex. Debugging requires more context. A significant portion of time shifts from building to maintaining.</p>
<p>Metrics are part of this shift.</p>
<p>They're necessary, but they also reflect how much of the system you're responsible for understanding.</p>
<p>A PaaS doesn't eliminate metrics. It reduces the effort required to make sense of them.</p>
<p>It ensures that when something changes in production, the signals developers see are closer to the reality they care about: application behaviour. User experience. System correctness.</p>
<h2 id="heading-the-real-advantage-is-clarity"><strong>The Real Advantage Is Clarity</strong></h2>
<p>The goal is not to have fewer metrics.</p>
<p>It's to have metrics that mean something without requiring deep infrastructure reasoning.</p>
<p>These five metrics form a complete picture of system health. But their real value depends on how directly they map to what developers control.</p>
<p>The more layers you have to think about, the harder mapping becomes.</p>
<p>A good PaaS removes those layers. It turns metrics from raw data into usable signals.</p>
<p>And that shift from metrics to meaning is what allows developers to understand production systems without being buried under them.</p>
<p><em>Join my</em> <a href="https://applyaito.substack.com/"><em><strong>Applied AI newsletter</strong></em></a> <em>to learn how to build and ship real AI systems. Practical projects, production-ready code, and direct Q&amp;A. You can also</em> <a href="https://www.linkedin.com/in/manishmshiva/"><em><strong>connect with me on</strong></em> <em><strong>LinkedIn</strong></em></a><em><strong>.</strong></em></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Key Metrics That Can Make or Break Your Startup ]]>
                </title>
                <description>
                    <![CDATA[ If you’ve built something worth pitching – something more than a fancy hobby with a login screen – you need to know your numbers. Not "I’ll get back to you" know them, know them like you know your co-founder's coffee order. I have seen too many found... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/key-metrics-that-can-make-or-break-your-startup/</link>
                <guid isPermaLink="false">6894eea1ba8a1138e41767a1</guid>
                
                    <category>
                        <![CDATA[ startup ]]>
                    </category>
                
                    <category>
                        <![CDATA[ finance ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Founder ]]>
                    </category>
                
                    <category>
                        <![CDATA[ ideas ]]>
                    </category>
                
                    <category>
                        <![CDATA[ business ]]>
                    </category>
                
                    <category>
                        <![CDATA[ beginner ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Business and Finance  ]]>
                    </category>
                
                    <category>
                        <![CDATA[ metrics ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Productivity ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Product Management ]]>
                    </category>
                
                    <category>
                        <![CDATA[ performance ]]>
                    </category>
                
                    <category>
                        <![CDATA[ #reporting ]]>
                    </category>
                
                    <category>
                        <![CDATA[ ycombinator ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Aditya Vikram Kashyap ]]>
                </dc:creator>
                <pubDate>Thu, 07 Aug 2025 18:21:21 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1754590848364/2e68c07e-d5d8-4da7-bc41-3798c991bfbc.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>If you’ve built something worth pitching – something more than a fancy hobby with a login screen – you need to know your numbers. Not "I’ll get back to you" know them, know them like you know your co-founder's coffee order.</p>
<p>I have seen too many founders who are smart, legit, and ambitious get ghosted by investors simply because they couldn't walk through their unit economics.</p>
<p>It's not personal. It's math.</p>
<p>So here it is: Numbers that will either carry your pitch or quietly kill it, explained by someone who has sat through them time and time again, with examples, and no fluff.</p>
<h3 id="heading-heres-what-well-cover">Here’s what we’ll cover:</h3>
<ul>
<li><p><a class="post-section-overview" href="#heading-1-burn-rate-how-fast-are-you-lighting-your-cash-on-fire">1. Burn Rate: How Fast Are You Lighting Your Cash on Fire?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-2-cash-runway-how-long-before-you-run-out-of-cash">2. Cash Runway: How Long Before You Run Out of Cash?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-3-cac-customer-acquisition-cost-how-much-does-it-cost-to-convince-someone-to-pay-you">3. CAC (Customer Acquisition Cost): How Much Does it Cost to Convince Someone to Pay You?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-4-customer-lifetime-value-ltv-how-much-is-one-customer-worth-over-time">4. Customer Lifetime Value (LTV): How Much is One Customer Worth Over Time?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-5-gross-profit-margin-what-do-you-actually-keep-after-delivering-your-service-or-product">5. Gross Profit Margin: What Do You Actually Keep After Delivering Your Service or Product?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-6-monthly-annual-recurring-revenue-mrr-arr">6. Monthly / Annual Recurring Revenue (MRR / ARR)</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-7-churn-rate-how-fast-are-your-users-leaving">7. Churn Rate: How Fast Are Your Users Leaving</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-8-payback-period-how-long-before-you-recover-your-cac">8. Payback Period: How Long Before You Recover Your CAC?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-9-earnings-before-interest-taxes-depreciation-and-amortization-ebitda">9. Earnings Before Interest, Taxes, Depreciation, and Amortization (EBITDA)</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-10-valuation-whats-your-company-worth-and-what-supports-that-number">10. Valuation: What’s Your Company Worth – and What Supports that Number?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-real-talk-before-you-close-that-tab">Real Talk Before You Close That Tab</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-real-experience">Real Experience</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-why-this-matters">Why This Matters</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-conclusion-and-final-thoughts">Conclusion and Final Thoughts</a></p>
</li>
</ul>
<h2 id="heading-1-burn-rate-how-fast-are-you-lighting-your-cash-on-fire">1. Burn Rate: How Fast Are You Lighting Your Cash on Fire?</h2>
<p>Burn rate is the speed at which a startup is spending its cash. Basically, how fast are you consuming your venture capital to cover over overhead until you generate positive cash flow from operations? It’s a measure of negative cash flow.</p>
<p>If you’re spending $80K a month to keep the lights on (payroll, AWS, your workspace snacks, and so on), that’s how much cash you’re burning each month. But many startups calculate two different burn rates: gross burn (how much cash you’re spending, ignoring any revenue), and net burn (monthly operating experiences minus any cash you take in each month). Net burn basically measures how fast your cash is shrinking, and it’s often what investors care more about.</p>
<p>Real talk: investors want to know when the plane runs out of fuel before they board. Thats what this metric helps them understand – how fast you’re going through the money you have.</p>
<p>At some point, if a company has a high burn rate, it has to reduce structural costs by cutting expenditures on labor, rent, marketing, and/or capital equipment. The burn rate is an important metric for any company, but it's particularly important for startups that aren't yet generating revenue. It tells managers and investors how fast the company is spending its capital</p>
<p><a target="_blank" href="https://www.youtube.com/watch?v=BpS3shZI35A">Watch this video</a> to understand more about Burn Rate.</p>
<h2 id="heading-2-cash-runway-how-long-before-you-run-out-of-cash">2. Cash Runway: How Long Before You Run Out of Cash?</h2>
<p>Cash runway tells how long a startup can continue to operate at a certain burn rate until they are out of cash. For startups without revenue, you can calculate this by dividing available cash by total monthly expenses. Available cash is defined as the funds that are accessible now or can be accessed at a later time relatively quickly to pay for expenses.</p>
<p>When you’re making this calculation, it’s important to not include any anticipated fundraising and other uncertain sources of capital.</p>
<p>Actively managing cash runway is crucial for startup survival and growth. With a significant percentage of startups failing due to cash shortages, founders need to closely monitor their cash burn rate and runway.</p>
<p>The length of runway needed varies based on factors including the startup’s stage, industry, and milestones. In tighter venture capital markets, startups should plan for longer runways and consider strategies such as increasing revenue, reducing expenses, or raising additional capital. Regularly updating financial models and understanding metrics like the burn multiple can help you make informed decisions to extend your runway and align your growth ambitions with financial stability.</p>
<p>While it’s a simple calculation at face value, a cash runway analysis is nuanced and unique to every startup and can be impacted by a multitude of circumstances.</p>
<p>To calculate this, you just divide your total cash reserves by the amount you’re spending each month. Say you’ve got $250K in the bank and you’re spending $50K/month: 250/50 = 5. So you’ve got 5 months. Not 6. Not “it depends” – 5. That’s your runway.</p>
<p>Investors ask “If we don’t fund you, how long do you survive?” If you don’t know that answer, you're not fundraising – you’re freelancing with hope.</p>
<p><a target="_blank" href="https://youtu.be/vtaMwtQgFGE?si=-Hcf_h_LxKYChdBa">Here is a video</a> that explains cash runway with real world examples and the thought process behind it.</p>
<p>And <a target="_blank" href="https://www.jpmorgan.com/insights/business-planning/does-your-startup-have-enough-runway-to-survive">here’s an article</a> from JP Morgan breaking down cash runway, its importance, and what can you to to maximize it.</p>
<h3 id="heading-burn-rate-vs-runway">Burn Rate vs Runway</h3>
<p>So, let’s just make this super clear: burn rate is simply how much you spend each month to run your operation – that is, your negative cash flow. Runway is how many months there are left before your bank balance reaches zero.</p>
<p>So again, why do these numbers matter?</p>
<p>Because burn rate tells you how quickly you need to find more revenue or funding. Runway tells investors whether you are going to still be around by the time they finish their due diligence.</p>
<p>They are not just numbers. They are your survival clock.</p>
<p>Smart founders utilize these metrics to:</p>
<ul>
<li><p>Trim the fat without cutting muscle – know what to focus on and what to let go</p>
</li>
<li><p>Forecast hiring/fundraising deadlines – know the process and prep for it. Numbers don’t line but they sure can get you ghosted.</p>
</li>
<li><p>Assure investors you’re not going to come knocking again in 90 days – establishing credibility is key, make an investor realize its not just a hobby, you mean business.</p>
</li>
</ul>
<p>The goal: Extend runway without stalling momentum. Keep the plane in the air, while building a bigger engine.</p>
<h2 id="heading-3-cac-customer-acquisition-cost-how-much-does-it-cost-to-convince-someone-to-pay-you">3. CAC (Customer Acquisition Cost): How Much Does it Cost to Convince Someone to Pay You?</h2>
<p>Cost of acquisition refers to the entire cost that a business incurs to obtain a new client or asset. This includes the purchase price, shipping, installation, and marketing costs for the asset acquired. CAC takes into account the total expenditure on all marketing, advertising, and sales for the period, which you then divide by the number of new customers for the period.</p>
<p>In this case, all the upfront costs incurred to purchase a business asset, including equipment or inventory, are part of the cost of acquisition. Cost of acquisition includes:</p>
<ul>
<li><p>Purchase price of the item</p>
</li>
<li><p>Costs to ship it to its point of use</p>
</li>
<li><p>Costs to install the item</p>
</li>
<li><p>Costs to get it up and running (in the case of equipment) or ready for sale (in the case of inventory) condition</p>
</li>
<li><p>Marketing sales teams salaries</p>
</li>
<li><p>All sales and consulting marketing expenses geared to get new consumers should all be included</p>
</li>
</ul>
<p><strong>Formula:</strong><br>CAC = (Total Marketing + Sales Expenses) / Number of New Customers Acquired</p>
<p>Say you spent $10K last month across paid ads, content creation, outbound campaigns, and sales team costs. You onboarded 100 new customers, so your CAC = $100.</p>
<p>But is that good?</p>
<p>It depends on:</p>
<ul>
<li><p>Your pricing model (one-time vs. subscription)</p>
</li>
<li><p>Your margin (how much of that sale do you actually keep?)</p>
</li>
<li><p>Your customer retention (how long do they stick around?)</p>
</li>
</ul>
<p>If you’re selling a $20 product once, a $100 CAC is a non-starter. But if that customer brings in $50/month for 12 months, you’ve got a solid return.</p>
<p><strong>Watch for red flags:</strong></p>
<ul>
<li><p>CAC is rising but revenue isn’t</p>
</li>
<li><p>You’re overly reliant on paid ads (especially if organic/referral is flat)</p>
</li>
<li><p>You don’t know CAC by channel (averages hide leaks)</p>
</li>
</ul>
<p>A healthy CAC is one that pays itself back quickly and can be improved over time as you optimize funnels and messaging</p>
<p><a target="_blank" href="https://www.youtube.com/watch?v=KFJ3ip30QPM">Here is a video</a> that breaks down CAC for you.</p>
<h2 id="heading-4-customer-lifetime-value-ltv-how-much-is-one-customer-worth-over-time">4. Customer Lifetime Value (LTV): How Much is One Customer Worth Over Time?</h2>
<p>Customer Lifetime Value is the average monetary value of each customer to your business. LTV takes into account how much a unique customer is expected to spend with your business. It’s an important metric so you know how much new customers are worth to your business over their lifespan as a customer.</p>
<p>Let’s say you charge $25/month. The average customer sticks around 12 months.<br>LTV = $300.</p>
<p>In this case, if your CAC is $80? You’re in the green. But if it’s $350? You’re basically paying people to hang out (and losing money on them).</p>
<p>Now, let’s connect this to CAC.</p>
<p>Say your CAC is $80. You’re doing fine – your LTV is ~4x CAC. That’s what investors want to see.</p>
<p>Rule of thumb: you want your LTV to be at least 3x your CAC. A 1:1 ratio means you’re barely breaking even, before operational costs and the math stops working at scale. So if you can hit a 3:1 ratio, great – and based off my experience, your business will be much more appealing if it’s closer to 5:1.</p>
<p>And keep in mind that different models can have different thresholds. For example, a SaaS company with low churn can afford higher CACs, while an e-commerce platform might need faster payback. And marketplaces and freemium models may have lower LTV per user, but they can often more easily offset it with volume.</p>
<p>If you don’t know your LTV or can’t defend it with data, it becomes hard to justify spend – and easy for investors to walk.</p>
<p>If you want to know more, <a target="_blank" href="https://www.youtube.com/watch?v=vA1YX8963ts">this video</a> walks you through the basics.</p>
<p>And <a target="_blank" href="https://www.youtube.com/watch?v=773zBQVPx_Q">here’s a video</a> that beautifully explains the CAC and LTV relationship.</p>
<h2 id="heading-5-gross-profit-margin-what-do-you-actually-keep-after-delivering-your-service-or-product">5. Gross Profit Margin: What Do You Actually Keep After Delivering Your Service or Product?</h2>
<p>Gross profit margin shows the amount of money a business collects after it pays for all its expenses. It’s usually calculated as a percentage of sales. This specific metric is also referred to as the gross margin ratio.</p>
<p>Companies use gross margin as a measure of how production costs relate to revenue. If a company's gross margin falls because it is making less revenue, it may try to cut labor costs, find cheaper suppliers of materials, or increase prices to increase revenue.</p>
<p>Gross profit margins can also allow a business to measure how efficient a company is, or compare two very differently sized companies that share a common revenue stream or product</p>
<p>If you sell a subscription for $50/month and it costs you $10/month to host, maintain, and support it, your gross margin is 80%.</p>
<ul>
<li><p>Good: SaaS companies often hit 70–90%.</p>
</li>
<li><p>Bad: If you're below 30%, your "scalable" business will collapse under weight.</p>
</li>
</ul>
<p>Want to know the conceptual math behind this metric and how it differs from Profit Margin? <a target="_blank" href="https://www.youtube.com/watch?v=9xAMe0QBFhU&amp;t=45s">Here is a fantastic video</a> that easily breaks it down.</p>
<h2 id="heading-6-monthly-annual-recurring-revenue-mrr-arr">6. Monthly / Annual Recurring Revenue (MRR / ARR)</h2>
<p>Annual recurring revenue (ARR) is revenue a company expects to see from its product and service offerings, calculated over the course of a year. Companies that sell annual subscriptions like using ARR as a sales metric to track what they anticipate making in a year.</p>
<p>ARR tends to be used if companies sell a product or service in the software as a service (SaaS) space, but it can also be useful in terms of streaming services, cell phone bills, and (almost) anything else with a predictable, recurring charge.</p>
<p>ARR is calculated annually, whereas monthly recurring revenue (MRR) is calculated monthly. MRR is useful in that it shows what’s happening on a month-to-month basis. For example, if you change your price in April, you can see the immediate effects of that change in May. MRR also helps track fluctuations in revenue based on outside factors like holiday shopping seasons and economic conditions.</p>
<p>In a nutshell, Monthly / Annual Recurring Revenue = predictable income.</p>
<p>If you’re pulling $20K/month in subscriptions, that’s $240K ARR. Simple.</p>
<p>What investors care about:</p>
<ul>
<li><ul>
<li><p>Is it growing?</p>
<ul>
<li><p>How fast?</p>
</li>
<li><p>And how stable is it?</p>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<p><a target="_blank" href="https://youtu.be/qwo7WFWusO4?si=pCelTr2slb2OLuw9">Here is a founder breaking down the metric</a> and explaining the relationship between MRR/ARR.</p>
<h2 id="heading-7-churn-rate-how-fast-are-your-users-leaving">7. Churn Rate: How Fast Are Your Users Leaving</h2>
<p>The churn rate, also known as attrition rate, represents the rate at which a customer stops doing business with a company. Customer churn is typically expressed as the percentage of service subscribers that discontinue their service subscriptions within a time frame. Churn can also be expressed as the rate at which employees leave their jobs in a given time.</p>
<p>In order for a business to grow its number of clients, its growth rate (which takes into account new customers) must be higher than its churn rate.</p>
<p>The benefit of calculating a churn rate is that it can clarify how well a business is retaining its customers, which is a measure of the quality of service the business is providing and the usefulness of that service.</p>
<p>When a business can see its churn rate increasing from period to period, this suggests that a critical aspect of how it is running the business might be problematic or flawed.</p>
<p>It could be the result of:</p>
<ul>
<li><p>A faulty product(s)</p>
</li>
<li><p>Bad customer service</p>
</li>
<li><p>Costs exceed utility to customers</p>
</li>
</ul>
<p>And so on.</p>
<p>The churn rate will indicate to a business that it needs to learn why its customers are leaving, and where it needs to adjust its business. It’s more expensive to attract new customers than it is to retain them, so reducing the churn rate can save a business resources in the future.</p>
<p>Real talk: Say you had 500 users at the start of the month, and you lost 50 by the end of the month. That’s 10% churn – which is high! Annualize that and…ouch. You're not growing. You're replacing.</p>
<p>Make sure you fix this before you fundraise. Or at least explain why churn’s high and what you’re doing to plug the holes.</p>
<p><a target="_blank" href="https://www.youtube.com/watch?v=Jlg5J_Mpq7g">Here is a video</a> that beautifully explains Churn Rate.</p>
<h2 id="heading-8-payback-period-how-long-before-you-recover-your-cac">8. Payback Period: How Long Before You Recover Your CAC?</h2>
<p>The payback period is a popular tool for determining investment return. People invest money for the purpose of getting it back and generating a positive return on the money they invested. The shorter the payback period, the more beneficial the investment will be.</p>
<p>The payback period does not factor in the time value of money. You can determine it simply by counting the number of years until the principal paid in is returned.</p>
<p>This metric measures how quickly your customer pays you back for the cost of acquiring them. The payback period doesn’t take into account the total profitability of an investment. It’s just concerned with paying the investment back.</p>
<p>There are two common interpretations:</p>
<ol>
<li><p><strong>Customer-Level Payback:</strong> If your CAC is $250 and your customer pays $50/month, it’ll take 5 months to recover the acquisition cost.</p>
</li>
<li><p><strong>Investment-Level Payback:</strong> You spend $100,000 on a new sales hire, tool stack, or feature. You want to know how long it takes for that investment to generate $100,000 in profit.</p>
</li>
</ol>
<p>Both use the same principle: the shorter the payback period, the less cash you need to float your growth.</p>
<p>If you want a target, aim for 6 months for customer-level payback. Closer to 3-6 is ideal. Long payback periods mean you need deep pockets – or exceptional retention – to stay afloat.</p>
<p><a target="_blank" href="https://www.youtube.com/watch?v=KbtTk2azIjY">Here’s a video</a> where you can learn more.</p>
<h2 id="heading-9-earnings-before-interest-taxes-depreciation-and-amortization-ebitda">9. Earnings Before Interest, Taxes, Depreciation, and Amortization (EBITDA)</h2>
<p>EBITDA stands for Earning Before Interest, Taxes, Depreciation, and Amortization. You can think of this as just your company's operating profit if you wanted a very rudimentary way of referring to it.</p>
<p>It’s not flashy. It’s not fun. But it tells investors: “Here’s what we really make once the accounting fog clears.” and “Are we generating real profits from our actual operations?”</p>
<p>EBITDA is what investors look at because it is the best way of comparing apples to apples when considering startups. EBITDA can provide investors a measure of your operational health.</p>
<p>A negative EBITDA for an early stage company isn't going to raise any eyebrows. Just don’t act surprised when someone brings it up. You need to do that math before the pitch. But, if you have a growing early stage company that's moving from negative EBITDA to positive? Now your getting into grown folks business.</p>
<p><a target="_blank" href="https://www.youtube.com/watch?v=DH901SrBv9Q">Here’s a video</a> that explains the basics of EBITDA.</p>
<p>And <a target="_blank" href="https://www.youtube.com/watch?v=D58oCe_7BBM">here’s another video</a> that explains how investors look at EBITDA and its value in determining your business’s worth.</p>
<h2 id="heading-10-valuation-whats-your-company-worth-and-what-supports-that-number">10. Valuation: What’s Your Company Worth – and What Supports that Number?</h2>
<p>Valuation is a focused exercise that determines the value of an asset, investment, or company. So, how much your company’s worth. And the goal is typically to determine whether that value is a fair value.</p>
<p>Valuations can be conducted in one of two ways:</p>
<ul>
<li><p>an absolute valuation, which evaluates a company on its own merits and entirely independently of other factors/companies, or</p>
</li>
<li><p>a relative valuation, which evaluates the company relative to other similar firms, or assets, in the same sector or industry. This determines if the company, or asset, is worth that much relative to others.</p>
</li>
</ul>
<p>Depending on how the analysis and conclusions are reached, there are a variety of methods and techniques used to develop valuations. And as you’d expect, there’s often significant variability between outputs (or valuations) based on the inputs and context.</p>
<p>While valuations are predominantly quantitatively driven, there’s often a significant subjective influence that come from the assumptions and estimates made along the way. Valuations are also subject to developing situations and events outside of the analysis or the control of the analyst – for example, earnings reports or material news, or economic news – that can result in a change to a valuation stance.</p>
<p>If you’re pre-revenue and you’re saying $30M because a friend raised at that, please stop. Their experience likely has nothing to do with yours.</p>
<p>Valuation = traction + market comps + revenue + momentum + team.</p>
<p>Valuation isn’t just about what you want – it’s about what you can defend.</p>
<p>Startups are typically valued using:</p>
<ul>
<li><p><strong>Comparable Analysis (Comps):</strong> What similar companies are worth</p>
</li>
<li><p><strong>Discounted Cash Flow (DCF):</strong> Projecting future cash and discounting it back</p>
</li>
<li><p><strong>Revenue Multiples:</strong> Often 5x–10x for SaaS, but varies wildly</p>
</li>
<li><p><strong>Precedent Transactions:</strong> What investors paid in past rounds for similar startups</p>
</li>
</ul>
<p>But that’s the math.</p>
<p>Here’s the messy truth: <strong>Valuation = Traction + Team + TAM (total addressable market) + Timing + Storytelling.</strong></p>
<p>Hard factors:</p>
<ul>
<li><p>MRR/ARR</p>
</li>
<li><p>Growth rate</p>
</li>
<li><p>Churn</p>
</li>
<li><p>CAC:LTV</p>
</li>
<li><p>Gross margins</p>
</li>
</ul>
<p>Soft factors:</p>
<ul>
<li><p>Founding team’s track record</p>
</li>
<li><p>Market momentum</p>
</li>
<li><p>Hype or scarcity</p>
</li>
</ul>
<p>Don’t inflate. Don’t anchor to your friend’s raise. Know your comps. And show why <em>your</em> model is defensible, not just desirable. Inflated numbers make investors run. They don’t correct you – they just ghost you.</p>
<p>There are numerous books written on valuation and each technique could be its own PhD. But my role here is to give you a sneak peak into the metrics.</p>
<p>Here’s a <a target="_blank" href="https://www.youtube.com/watch?v=T3Ud5WQCrzQ">basic video on valuation</a> if you’re interested in a deeper dive.</p>
<p>And <a target="_blank" href="https://www.youtube.com/watch?v=znmQ7oMiQrM&amp;list=PLUkh9m2BorqnKWu0g5ZUps_CbQ-JGtbI9">here’s a more detailed video course</a> outlining different forms of valuation. Professor Damodaran from New York University is considered to be one of the aces and thought leaders when it comes to valuation. In this video course he explains stepwise and beautifully so you can understand and explore the fascinating world of valuations.</p>
<h2 id="heading-real-talk-before-you-close-that-tab">Real Talk Before You Close That Tab</h2>
<h3 id="heading-real-experience">Real Experience</h3>
<p>I met a founder once – early days, rough product, but you could tell he actually cared. He wasn't trying to look good. No buzzwords. No "disrupt" talk. Just someone trying to solve something annoying and important.</p>
<p>He walked into the room with a twinkle. Not swagger – just that gentle intensity. We were leaning in.</p>
<p>Then, in the middle of the pitch, someone asked, "So what's your monthly burn?" And I swear to you, he said, "Umm... I think my co-founder has that. I haven't looked in a while."</p>
<p>That was it.</p>
<p>No freak out. No awkward pause. Just... a cluck. Like a window closing in the background.</p>
<p>The product? Still smart. But the moment? Gone.</p>
<p>Nobody was mad. Nobody laughed. We even said thank you. But nobody followed up.</p>
<p>Why? Because it didn't feel like a business. It felt like a maybe.</p>
<h3 id="heading-why-this-matters">Why This Matters</h3>
<p>I’ve seen so many versions of that same scene play out. It’s never about charisma. It’s not even about the idea, half the time.</p>
<p>It’s about whether the person asking for money actually knows what they’re building. Not the dream, the mechanics. The guts, nuts and bolds of the business. The ugly Excel math nobody brags about on Twitter.</p>
<p>Unfortunately, no simple pitch deck will do that part for you. No co-founder can answer those questions on your behalf.</p>
<p>If it’s your vision, own the math. If it’s your company, learn the cost of keeping it alive.</p>
<p>The rest? The logos, the taglines, the “go-to-market” plans?.... All of that’s just packaging.</p>
<p>And you don’t have to be perfect either. You just have to be in it. Eyes open. Numbers in your head.<br>Because if you’re asking people to believe in what you’re building, you’d better believe in the scaffolding holding it up.</p>
<p>So yeah, know your CAC. Your LTV. Your margins. Your churn. Not to check some box on an investor’s sheet, but to prove to yourself and the investor that the thing you’re spending your life on…has legs. That it can stand. And run.</p>
<p>And maybe, someday, outlast you. Maybe!</p>
<h2 id="heading-conclusion-and-final-thoughts"><strong>Conclusion and Final Thoughts</strong></h2>
<p>I hope this was helpful to you, especially if you’re a founder or aspiring founder trying to build the next big thing. While there a many more ratios and concepts, these are the crux of them.</p>
<p>A lot of other complex ratios and valuations are either built using these metrics or refer them in some way. And each of these metrics could be an article of its own. But I wanted to give you my top 10 run down so that you could get a head start. Numbers are very much a part of the ideation stage itself, and omitting them from your strategy could prove to be a fatal mistake.</p>
<p>I’ll leave you with <a target="_blank" href="https://youtu.be/Pg72m3CjuK4?si=GtIFdvC5WzbKna79">one last video</a> on How to Start a Start Up with Michael Seibel (Reddit, YC, Twitch) that I hope you find valuable. It lays out, in a crash course format, the mindset of a founder who has been there and done that. The fun fact is that a lot of the themes he speaks of tie in to the metrics here, directly or indirectly.</p>
<p>I hope this gives you a perspective of being on the other side, evaluating your hard work and passion, and I hope it sets you up for success in your next Investor Review.</p>
<p>I look forward to your thoughts, comments, and feedback. If this was helpful, engaging, and informative, do share it – you never know who may need it, or could benefit from it. I wish you all the very best in your funding rounds.</p>
<p>Until then, keep learning, unlearning, and relearning, folks.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Top Evaluation Metrics for Regression Problems in Machine Learning ]]>
                </title>
                <description>
                    <![CDATA[ A regression problem is a common type of supervised learning problem in Machine Learning. The end goal is to predict quantitative values – for example, continuous values such as the price of a car, the weight of a dog, and so on. But to be sure that ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/evaluation-metrics-for-regression-problems-machine-learning/</link>
                <guid isPermaLink="false">66d45f359208fb118cc6cfc3</guid>
                
                    <category>
                        <![CDATA[ Machine Learning ]]>
                    </category>
                
                    <category>
                        <![CDATA[ metrics ]]>
                    </category>
                
                    <category>
                        <![CDATA[ #Regression ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Ibrahim Ogunbiyi ]]>
                </dc:creator>
                <pubDate>Mon, 01 Aug 2022 14:37:27 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/07/regression-metrics-image.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>A regression problem is a common type of supervised learning problem in Machine Learning. The end goal is to predict quantitative values – for example, continuous values such as the price of a car, the weight of a dog, and so on.</p>
<p>But to be sure that your model is doing well in its predictions, you need to evaluate the model.</p>
<p>There are some evaluation metrics that can help you determine whether the model’s predictions are accurate to a certain level of performance.</p>
<p>In this tutorial, you will learn the top evaluation metrics for regression problems, as well as when to use each of them. Without further ado let’s get started.</p>
<h2 id="heading-what-are-residuals">What are Residuals?</h2>
<p>Before we get into the top evaluation metrics, you need to understand what "residual" means when you're evaluating a regression model.</p>
<p>It is not ideal or possible for a model to accurately predict the value of a continuous variable in a regression problem. A regression model can only predict values that are lower or higher than the actual value. As a result, the only way to determine the model’s accuracy is through residuals.</p>
<p>Residuals are the difference between the actual and predicted values. You can think of residuals as being a distance. So, the closer the residual is to zero, the better our model performs in making its predictions.</p>
<p>Here's the formula for calculating residuals:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/07/residuals.png" alt="Image" width="600" height="400" loading="lazy"></p>
<pre><code class="lang-javascript">In the above formula:

ei -- stands <span class="hljs-keyword">for</span> the residual value.
yi -- stands <span class="hljs-keyword">for</span> the actual value.
y^i -- stands <span class="hljs-keyword">for</span> the predicted value.

So say, <span class="hljs-keyword">for</span> instance, that the actual value <span class="hljs-keyword">in</span> the dataset is <span class="hljs-number">5</span> and the predicted value is <span class="hljs-number">8.</span> The residual value will be <span class="hljs-number">-3.</span>
</code></pre>
<h2 id="heading-top-evaluation-metrics-for-regression-problems">Top Evaluation Metrics for Regression Problems</h2>
<p>The top evaluation metrics you need to know for regression problems include:</p>
<h3 id="heading-r2-score">R2 Score</h3>
<p>The R2 score (pronounced R-Squared Score) is a statistical measure that tells us how well our model is making all its predictions on a scale of zero to one.</p>
<p>As mentioned above, it's not ideal for a model to predict the actual values in a regression problem (as opposed to a classification problem that has discrete levels of value).</p>
<p>But we can use the R2 score to determine the accuracy of our model in terms of distance or residual. You can calculate the R2 score using the formula below:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/08/image.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h4 id="heading-when-to-use-the-r2-score">When to Use the R2 Score</h4>
<p>You can use the R2 score to get the accuracy of your model on a percentage scale, that is 0–100, just like in a classification model.</p>
<p>Let’s go over how to implement the R2 score in Python. So we have a small dataset that contains the actual values and the predictions.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/07/1_mzvi2wZRSVv5W0pPmod3ag.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>To implement the R2 score in Python we'll leverage the Scikit-Learn evaluation metrics library.</p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> sklearn.metrics <span class="hljs-keyword">import</span> r2_score
score = r2_score(data[<span class="hljs-string">"Actual Value"</span>], data[<span class="hljs-string">"Preds"</span>])
print(<span class="hljs-string">"The accuracy of our model is {}%"</span>.format(round(score, <span class="hljs-number">2</span>) *<span class="hljs-number">100</span>))
</code></pre>
<p>The <code>r2_score</code> requires two parameters – the actual value and the predicted values in which we have passed to it above. The result from the metrics is this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/07/1_0xW0Hg0DXj5vhFJoAGC_nw-1.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>So we can say that our model predicted those values with 82% accuracy.</p>
<h3 id="heading-mean-absolute-error-mae">Mean Absolute Error (MAE)</h3>
<p>The MAE is simply defined as the sum of all the distances/residual s(the difference between the actual and predicted value) divided by the total number of points in the dataset.</p>
<p>It is the absolute average distance of our model prediction.</p>
<p>You can calculate the MAE using the following formula:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/07/1_tu6FSDz_FhQbR3UHQIaZNg.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>We can see that the above formula has two pipelines represented by the absolute symbol. The absolute symbol makes sure that the negative residual (which may be a result where the predicted value is greater than the actual value) is converted to positive so that it doesn’t cancel out other positive residuals.</p>
<h4 id="heading-when-to-use-mae">When to Use MAE</h4>
<p>If you want to know the model’s average absolute distance when making a prediction, you can use MAE. In other words, you want to know how close the predictions are to the actual model on average.</p>
<p>Just keep in mind that low MAE values indicate that the model is correctly predicting. Larger MAE values indicate that the model is poor at prediction.</p>
<p>Let’s now see how to implement MAE in Python. We will be working with the previous dataset we used to find the r2_score.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/07/1_mzvi2wZRSVv5W0pPmod3ag.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>To implement the MAE in Python we'll leverage the Scikit-Learn evaluation metrics library.</p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> sklearn.metrics <span class="hljs-keyword">import</span> mean_absolute_error
score = mean_absolute_error(data[<span class="hljs-string">"Actual Value"</span>], data[<span class="hljs-string">"Preds"</span>])
print(<span class="hljs-string">"The Mean Absolute Error of our Model is {}"</span>.format(round(score, <span class="hljs-number">2</span>)))
</code></pre>
<p>MAE also requires two parameters, the actual value and the predicted value.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/07/1_muu_mmrUYI6YFn2_LnD8Rw.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-root-mean-squared-error-rmse">Root Mean Squared Error (RMSE)</h3>
<p>Another commonly used metric is the root mean squared error, which is the square root of the average squared distance (difference between actual and predicted value).</p>
<p>RMSE is defined as the square root of all the squares of the distance divided by the total number of points.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/07/0_2IuTz3Tr_dYNc6Df.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>RMSE functions similarly to MAE (that is, you use it to determine how close the prediction is to the actual value on average), but with a minor difference.</p>
<p>You use the RMSE to determine whether there are any large errors or distances that could be caused if the model overestimated the prediction (that is the model predicted values that were significantly higher than the actual value) or underestimated the predictions (that is, predicted values less than actual prediction).</p>
<h4 id="heading-when-to-use-rmse">When to Use RMSE</h4>
<p>If you are concerned about large errors, RMSE is a good metric to use. If the model overestimated or underestimated some points in the prediction (because the residual will be square, resulting in a large error), you should use RMSE.</p>
<p>RMSE is a popular evaluation metric for regression problems because it not only calculates how close the prediction is to the actual value on average, but it also indicates the effect of large errors. Large errors will have an impact on the RMSE result.</p>
<p>Let’s take a look at how you can implement RMSE in Python.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/07/1_mzvi2wZRSVv5W0pPmod3ag-2.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>The Scikit-learn evaluation metric library has no RMSE metric, but it does include the mean squared error method. The square root of the mean squared error is referred to as RMSE.</p>
<p>To get the RMSE, we can use the Numpy square root method to find the square root of mean squared error, and the result obtained is our RMSE.</p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> sklearn.metrics <span class="hljs-keyword">import</span> mean_squared_error
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
score = np.sqrt(mean_absolute_error(data[<span class="hljs-string">"Actual Value"</span>], data[<span class="hljs-string">"Preds"</span>]))
print(<span class="hljs-string">"The Mean Absolute Error of our Model is {}"</span>.format(round(score, <span class="hljs-number">2</span>)))
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/07/1_URsnCspxUYxXV5vlacxcew.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>We can see that the RMSE value is larger than the MAE. This is a result of some large errors in the dataset.</p>
<h2 id="heading-conclusion-and-learning-more">Conclusion and Learning More</h2>
<p>In this tutorial you’ve learned some of the top evaluation metrics for regression problems that you will use on a daily basis.</p>
<p>Thank you for reading. Here are some helpful resources I also included below.</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://scikit-learn.org/stable/modules/model_evaluation.html">https://scikit-learn.org/stable/modules/model_evaluation.html</a></div>
<p> </p>
<p><a target="_blank" href="https://medium.com/human-in-a-machine-world/mae-and-rmse-which-metric-is-better-e60ac3bde13d">MAE and RMSE — Which Metric is Better? | by JJ | Human in a Machine World | Medium</a></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Google Search Console Explained: What is GSC and How to Use It ]]>
                </title>
                <description>
                    <![CDATA[ By Adam Naor Google Search Console is a web service by Google that lets you see the indexing and performance of your websites and webpages on Google search. At a high level, the search console is a powerful tool to confirm that your website is rankin... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/google-search-console-explained/</link>
                <guid isPermaLink="false">66d45d663a8352b6c5a2a9f9</guid>
                
                    <category>
                        <![CDATA[ analytics ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Google ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Google Analytics ]]>
                    </category>
                
                    <category>
                        <![CDATA[ metrics ]]>
                    </category>
                
                    <category>
                        <![CDATA[ search ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Tue, 05 Jan 2021 19:01:25 +0000</pubDate>
                <media:content url="https://cdn-media-2.freecodecamp.org/w1280/5ff3f30c7af2371468bb7980.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Adam Naor</p>
<p>Google Search Console is a web service by Google that lets you see the indexing and performance of your websites and webpages on Google search.</p>
<p>At a high level, the search console is a powerful tool to confirm that your website is ranking and that Google can access your website. </p>
<p>You can check and set the crawl rate and view statistics about where your traffic is landing and where you are acquiring traffic from.</p>
<p>The console, like many other web dev tools, is robust and powerful. If you are building your first website you should take time to understand it, play around with it, and learn to leverage it. </p>
<p>This tutorial walks you through the basics of this tool, and can be a useful guide to help you save time when learning which metrics matter for your site’s performance and how you can leverage this data to build better products.</p>
<p>I have lived in the search console for the past six months because I built a website and I care deeply about how people find the content that I write.</p>
<p>Prior to my experience building this site, I was not a regular user of the Search Console. I had to learn about this tool, including what it could do to help me better understand my users and their intent when landing on my website.</p>
<p>I have learned three important lessons about the Search Console’s Performance section and want to pass those lessons on to you.</p>
<h2 id="heading-lesson-1-know-the-source-of-your-traffic-search-vs-discover">Lesson #1: Know the source of your traffic: Search vs Discover</h2>
<p><img src="https://lh3.googleusercontent.com/zMsT6tSzNEUghosvFvS_3MHo0FE0s3GPbI_FnL29FgX-8N1qWgZw5afCRT34mzpvWfIF3owlf_DInR7cnxnxscjGj9pFaIks8F1KSU54s3ZEIkLJrMof-19VBaBmbz8zJseon3ZK" alt="Image" width="554" height="250" loading="lazy"></p>
<p>Google gives you two ways to see how people are reaching your website through Search: via Search results or via Discover.</p>
<p>“Discover” (previously known as Google Feed) is a personalized content feed created by Google that proactively serves relevant content to users. You can’t nominate your content for Discover. If Google thinks that your website is relevant to users, Google will show it to people.</p>
<p>The other type of performance metric, and one that is seemingly far larger, is “Search results”. Search results shows a webmaster four vital pieces of information:</p>
<ol>
<li>Total clicks</li>
<li>Total impressions</li>
<li>Average CTR (Click Thru Rate)</li>
<li>Average Position</li>
</ol>
<p>Discover provides the same information with the exception of Average Position because there are no relative ranking positions within this metric.</p>
<p>When learning to use the Search Console, spend time looking at traffic through the lens of Search and Discover. If you do not see Discover traffic, that means your content has not yet been shown via Discover to users.</p>
<p>When starting a website or blog, you will want users to find your content. Search and discover are the two organic ways that people will do so. Know how many people find you via each.</p>
<h2 id="heading-lesson-2-study-your-average-position">Lesson #2: Study your average position</h2>
<p>When I first started using the Search Console I was amazed (and happy) that I was getting any traffic at all! Over time, your clicks will increase if you are publishing relevant and useful content. </p>
<p>As more people find your website and the site gets more impressions, clicks will go up.</p>
<p>You might be tempted to pat yourself on the back and call it a day. Not so fast!</p>
<p>Each page that you publish on your website is eligible to appear on Google search if you want that page to be crawled and indexed. </p>
<p>Some of your pages will perform very well (that is, they'll land on the first page of Google) and others will land further down (like on the 12th page where nobody will see them).</p>
<p>Over time you will want to monitor and track your average position and find ways to increase your average position by producing higher quality and more relevant content that benefits readers.</p>
<p>Here is a simple strategy to see your average position over time: create articles of similar length, quality, and usefulness to readers. </p>
<p>Then, come back over the ensuing weeks and months and see which ones are starting to rank and what their relative positions are. This strategy is deployed by review sites, thought leadership posts, and even online coding schools.</p>
<p>When I started my first website my average position was around 60. That means that 59 other websites showed up before mine. </p>
<p>Today, that average position is 26.8. Clearly I have a long way to go but it's a step in the right direction. Be aware of this metric and spend time tracking it.</p>
<p><img src="https://lh4.googleusercontent.com/K6rw6C7I7G6D1F5tm9yP7Qu5LHZtdPgmZwv07vW_gfP_3szFEh3SbfhgOTB5E2wQX3JnbIDWy4bRjw3v2h3qJRnHImfP48IaRW9G-j0Boe0P3hohg_dSNCizQrnxP0p8SoZJQcCY" alt="Image" width="909" height="339" loading="lazy">
<em>Source: https://wfhadviser.com/</em></p>
<h2 id="heading-lesson-3-impressions-are-the-top-of-the-funnel">Lesson #3: Impressions are the top of the funnel</h2>
<p>Regardless of the type of website you have - blog, educational, e-commerce, recreational - you will want traffic. </p>
<p>Traffic is just another way of saying unique visitors. Depending on what your website has to offer, you might value certain types of traffic more than others: by region, country, age of users, device operating system, and so on.</p>
<p>But as you focus in on clicks and performance, it all starts with impressions. An impression is counted each time your webpage is shown on a search result page.</p>
<p>In other words, impressions are the top of the funnel. You will need to grow impressions first in order to grow all other metrics.</p>
<p><img src="https://lh6.googleusercontent.com/6K8ZRZ8FiIWGqHYwlCFFMb8auG7lyReNKil79J992RJlyHTpUMsIHR8JQZns6rcK6Y2cebVsubRCZpYIpe5acqK9BIW8Bh6hXm8vdRDNNDdzHE2eJ4-MSou2jUw-I_9H3xqZZa0f" alt="Image" width="906" height="373" loading="lazy"></p>
<p>A word of caution that I have discovered the hard way. If your website is on the lower part of the search results, an impression might count even if the user doesn’t scroll all the way down. </p>
<p>In other words, the way Google counts an impression is seemingly slightly different from how a person might count it. In layperson's terms (that is, not technology) an impression is when you actually see something. </p>
<p>In Google’s terms, an impression is when your website is on a results page and the user sees the results page. In short, scrolling doesn’t seem to impact impression counts.</p>
<h2 id="heading-bringing-it-all-together-know-how-your-users-reach-your-website-to-build-better-products">Bringing It All Together: Know How Your Users Reach Your Website To Build Better Products</h2>
<p>If you want to build a product, you always need to know how your users learned about your product and what they value most. Builders start with the customer and work backwards. </p>
<p>Google’s Search Console is a terrific tool to understand one aspect of the user journey to better align your product, your messaging, and your value-prop with the needs of your clients.</p>
<p>You can use the Performance section of the Search Console to obsess over customers and how they reach you. </p>
<p>Google makes it easy to test this in real time so that your feedback loop is minimal: you can review the crawled page automatically or promagically.</p>
<p><img src="https://lh3.googleusercontent.com/hFhSEp310NkJUuZ09PUzImV9f_eR04Yh6A5JWnNcRiRt_1DW4r6dwQkFGkMSKLPZ5J6ksxmEc3xm2Esi0KxJwEyXmjmsBVPr1TGp1_UjnW6-DzgzCprMwZMBtfVylmWaO0HhqPlU" alt="Image" width="1600" height="792" loading="lazy"></p>
<p>Growing SaaS, a company that notes that SEO is one of the core user acquisition strategies for companies, also convincingly argues that if you don't know where, what, how, or why to measure traffic, you will be missing guidance as to what to build and for whom. </p>
<p>If you build any product - a website, a mobile app, or a tool for Enterprises - you need to know how people hear about your product and reach you.</p>
<p>Imagine if you built a newsletter but had no idea how your email list grew over time or what your subscribers valued most? Sounds crazy, right? That is akin to building a site and not mastering the Search Console.</p>
<p>Certainly this would be a suboptimal situation for any coder or creator.</p>
<p>Builders are never done learning. </p>
<p>The Search Console gives you data and visual guidance on ways to improve your website and customer acquisition. By being curious about new possibilities and acting to explore them, you can do a better job building. </p>
<p>And Google reinforces this by helping guide you along the way. These green circles and checks confirm that the site has live pages and that are properly indexed. It's always a nice plus when the visual design helps the builders :)  </p>
<p><img src="https://lh3.googleusercontent.com/aHwRsAr_vDvLLeV8QXCWqZhKC15ZlgJ82r-xPWCRprJMvxaPzlQxmShrc4nGR-2q93PlyVl3IJKCM5yaeaXDpQkB-bDDSNtclUyfZa5wrHms0GbhXAqRj-ngUb8ll8qE6LaiSx_5" alt="Image" width="1284" height="624" loading="lazy"></p>
<p>Builders not only index on what is going well - and how to improve these trends - but what is not working so that they can course correct. Google’s search console, like other online tools, helps users see broken links and error pages, pages that need improvements, and site speed.</p>
<p>If you were looking at hundreds of pieces of paper in a book - or bulk emails - or thousands of indexed web pages, you need to leverage a tool to understand the data in front of you. </p>
<p>The Search Console is just that.</p>
<p>It is free to use and fast to deploy. It is important to use and critical to master - your product and users will be better served if you leverage it.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Manage Wavefront Resources using Terraform ]]>
                </title>
                <description>
                    <![CDATA[ By Siben Nayak In my previous article, I wrote about metrics and how they help you gain visibility into the operational health of your hardware and software systems. Wavefront is a high-performance streaming analytics platform that supports 3D observ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-manage-wavefront-resources-using-terraform/</link>
                <guid isPermaLink="false">66d46153bd438296f45cd3c4</guid>
                
                    <category>
                        <![CDATA[ Infrastructure as code ]]>
                    </category>
                
                    <category>
                        <![CDATA[ metrics ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Microservices ]]>
                    </category>
                
                    <category>
                        <![CDATA[ performance ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Terraform ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Mon, 04 Jan 2021 16:46:06 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/12/wavefront-terraform.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Siben Nayak</p>
<p>In my previous <a target="_blank" href="https://www.freecodecamp.org/news/microservice-observability-metrics/">article</a>, I wrote about metrics and how they help you gain visibility into the operational health of your hardware and software systems.</p>
<p><strong>Wavefront</strong> is a high-performance streaming analytics platform that supports 3D observability (metrics, histograms, traces/spans). </p>
<p>It can scale to very high data ingestion rates and query loads. You can collect data from many services and sources across your entire application stack, and can look at details for earlier data collected by Wavefront.</p>
<p><strong>Terraform</strong> is an open-source “Infrastructure as Code” tool, created by HashiCorp. </p>
<p>It is a <em>declarative</em> coding tool and enables developers to use a high-level configuration language called HCL (HashiCorp Configuration Language) to describe the desired “end-state” for the infrastructure. </p>
<p>This infrastructure can be on the cloud or on-premises. It then generates a plan for reaching that end-state and executes the plan to create the infrastructure.</p>
<p>In this article, we will take a look at how we can use Terraform to write code that will automatically build dashboards and alarms in Wavefront. This is really helpful in maintaining a DevOps culture in your team, where all the monitoring infrastructure is maintained as code and checked into your version control system such as GitHub.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/01/image-21.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h2 id="heading-how-to-install-terraform">How to Install Terraform</h2>
<p>Depending on your OS, the installation <a target="_blank" href="https://learn.hashicorp.com/tutorials/terraform/install-cli">instructions</a> for Terraform will vary. This article covers the instructions for installing it on macOS.</p>
<p>The recommended approach for installing it on macOS is to use the Homebrew package manager.</p>
<h3 id="heading-install-terraform">Install Terraform</h3>
<p>Verify that you have Homebrew installed, like this:</p>
<pre><code>$ brew --version

Homebrew/homebrew-core (git revision fe68a; last commit <span class="hljs-number">2020</span><span class="hljs-number">-10</span><span class="hljs-number">-15</span>)
Homebrew/homebrew-cask (git revision <span class="hljs-number">4</span>a2c25; last commit <span class="hljs-number">2020</span><span class="hljs-number">-10</span><span class="hljs-number">-15</span>)
</code></pre><p>If not, you can install Homebrew using the following command:</p>
<pre><code>$ /bin/bash -c <span class="hljs-string">"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"</span>
</code></pre><p>Next, install Terraform using the following commands:</p>
<pre><code>$ brew tap hashicorp/tap
$ brew install hashicorp/tap/terraform
</code></pre><h3 id="heading-verify-terraform-installation">Verify Terraform Installation</h3>
<p>To verify that Terraform is properly installed, open another terminal session, and try a Terraform command.</p>
<pre><code>$ terraform --help

<span class="hljs-attr">Usage</span>: terraform [<span class="hljs-built_in">global</span> options] &lt;subcommand&gt; [args]

The available commands <span class="hljs-keyword">for</span> execution are listed below.The primary workflow commands are given first, followed byless common or more advanced commands.
</code></pre><h2 id="heading-how-to-get-an-api-token">How to Get an API Token</h2>
<p>To allow Terraform to access your Wavefront installation, you will need to provide it an access token. This token can be found in the API tokens section of your account.</p>
<p>Go to <em>Gear Icon &gt; Account Name &gt; API Access</em></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/12/Screenshot-2020-12-26-at-12.49.23-PM.png" alt="Image" width="600" height="400" loading="lazy">
<em>Getting your Wavefront API Token</em></p>
<h2 id="heading-how-to-setup-a-terraform-project">How to Setup a Terraform Project</h2>
<p>First, create a new folder for your Terraform project:</p>
<pre><code>$ mkdir wavefront-terraform
</code></pre><p>A usual Terraform project contains 3 major files:</p>
<ol>
<li><strong>versions.tf</strong> — this contains the Terraform provider declaration that specifies the plugin version to be used</li>
<li><strong>variables.tf</strong> — this contains the variables that you can refer to in your main Terraform code</li>
<li><strong>main.tf</strong> — as the name suggests, this contains the actual code required to build the resources</li>
</ol>
<p>Create a <strong>versions.tf</strong> file in the project folder and add the following code:</p>


<p>Next, run the <code>terraform init</code> command to initialize the Wavefront provider:</p>
<pre><code>$ terraform init
</code></pre><p>This downloads the <code>terraform-wavefront-provider-&lt;version&gt;</code> file and puts it inside a<code>.terraform</code> folder in the current project folder.</p>
<p>Next, create a <strong>main.tf</strong> file in the project folder and add the following code:</p>


<p>With the setup completed, we are now ready to create some dashboards and alerts.</p>
<h2 id="heading-how-to-create-wavefront-dashboards">How to Create Wavefront Dashboards</h2>
<p>Before we jump into creating dashboards, let us first understand the anatomy of a Wavefront dashboard.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/12/Wavefront_Dashboard.png" alt="Image" width="600" height="400" loading="lazy">
<em>Anatomy of a Wavefront Dashboard</em></p>
<p>A dashboard in Wavefront consists of 5 types of entities:</p>
<ul>
<li><strong>Dashboard</strong> — This is the main dashboard and contains all other entities.</li>
<li><strong>Section</strong> — A dashboard can contain one or more sections. A section is a logical group of charts. For example you can have one section for displaying charts related to hardware utilization, and another section for displaying charts related to API calls.</li>
<li><strong>Row</strong> — A row is a collection of charts. You can define the number of charts you want to be present in a row. My personal recommendation is to have 3 charts in a row. Anything more than that clutters the dashboard.</li>
<li><strong>Chart</strong> — This is the final chart that displays the metrics on the dashboard. There are various options for creating charts like line charts, bar charts, pie charts, and so on.</li>
<li><strong>Source</strong> — A chart can contain one or more sources. Each source has a query that works on an underlying metric to create a visual representation on the chart.</li>
</ul>
<p>Now we are ready to write some code to create a dashboard. Add the following code to the <strong>main.tf</strong> file:</p>


<p>This creates a dashboard with one section for EC2 Metrics. There is one row in this section with two charts. One chart displays CPU Utilization and the other displays Memory Utilization. Both of them are line charts and show the percentage of usage.</p>
<h2 id="heading-how-to-create-alerts">How to Create Alerts</h2>
<p>The dashboard we created is great to look at the CPU and Memory utilization of our EC2 instances. But if we want to be notified when the CPU or memory utilization increases beyond a certain threshold, we need to set up some alerts.</p>
<p>To create an alert on CPU Utilization, add the following code to the <strong>main.tf</strong> file:</p>


<p>This creates two resources:</p>
<ol>
<li>An alert target that sends an email to the specified address whenever an alert is opened or resolved.</li>
<li>An alert on CPU Utilization that fires when the CPU utilization crosses the given threshold (a WARN alert when it goes over 60% and a SEVERE alert when it goes over 80%).</li>
</ol>
<p>Wavefront continuously monitors the CPU utilization and sends a notification to the email address when the threshold is breached. Similarly, when the utilization becomes normal, it sends another notification indicating that things have recovered.</p>
<h2 id="heading-how-to-generate-resources-in-wavefront">How to Generate Resources in Wavefront</h2>
<p>The code for creating our resources is ready. Now we need to apply them so that the actual resources are created on Wavefront.</p>
<p>To view what changes will be made to Wavefront by our code, run the following command:</p>
<pre><code>$ terraform plan
</code></pre><p>This will verify our code and show the difference between the current setup in Wavefront, and the changes that will happen due to your code.</p>
<p>Finally, to create the resources on Wavefront, run the following command:</p>
<pre><code>$ terraform apply -auto-approve
</code></pre><p>This will upload the configuration to Wavefront and create the actual dashboard and alert. You can now go to Wavefront and verify these resources.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Congratulations! You just created a new Wavefront dashboard and alert through code. </p>
<p>You can now go ahead and make any modifications to your code, and run <code>terraform apply -auto-approve</code> to apply your changes to Wavefront.</p>
<p>Terraform is a great way to maintain your resources in the form of code that can be checked into your version control system. This allows multiple developers to work on your resources while also keeping track of the changes.</p>
<p>The full source code for this tutorial can be found <a target="_blank" href="https://github.com/theawesomenayak/wavefront-terraform">here</a>.</p>
<p>Thank you for staying with me so far. Hope you liked the article. You can connect with me on <a target="_blank" href="https://www.linkedin.com/in/theawesomenayak/">LinkedIn</a> where I regularly discuss technology and life. Also take a look at some of <a target="_blank" href="https://www.freecodecamp.org/news/author/theawesomenayak/">my other articles</a>. Happy reading. 🙂</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Use Metrics to Monitor Your Microservices ]]>
                </title>
                <description>
                    <![CDATA[ By Siben Nayak In my previous article, I talked about the importance of logs and the differences between structured and unstructured logging.  Logs are easy to integrate into your application, and they give you the ability to represent any type of da... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/microservice-observability-metrics/</link>
                <guid isPermaLink="false">66d46157bd438296f45cd3c8</guid>
                
                    <category>
                        <![CDATA[ error handling ]]>
                    </category>
                
                    <category>
                        <![CDATA[ logging ]]>
                    </category>
                
                    <category>
                        <![CDATA[ metrics ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Microservices ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Wed, 30 Dec 2020 16:49:38 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/12/Microservice-Observability---Metrics.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Siben Nayak</p>
<p>In my previous <a target="_blank" href="https://www.freecodecamp.org/news/how-to-handle-logs-in-microservices/">article</a>, I talked about the importance of logs and the differences between structured and unstructured logging. </p>
<p>Logs are easy to integrate into your application, and they give you the ability to represent any type of data in the form of strings.</p>
<p>Metrics, on the other hand, are numerical representations of data. These are often used to count or measure a value and are aggregated over a period of time. </p>
<p>Metrics give us insights into the historical and current state of a system. Since they are just numbers, we can also use them to perform statistical analysis and predictions about the system’s future behaviour. </p>
<p>You can also use metrics to trigger alerts and notify you about issues in the system’s behaviour.</p>
<h1 id="heading-logs-vs-metrics">Logs vs. Metrics</h1>
<h2 id="heading-how-logs-and-metrics-are-formatted">How Logs and Metrics are Formatted</h2>
<p>Logs are represented as strings. They can be simple text, JSON payloads, or key-value pairs (like we discussed in structured logging).</p>
<p>A typical log entry looks like this:</p>
<pre><code>[<span class="hljs-number">2020</span><span class="hljs-number">-09</span><span class="hljs-number">-27</span>T18:<span class="hljs-number">54</span>:<span class="hljs-number">41</span>,<span class="hljs-number">500</span>+<span class="hljs-number">0530</span>]-[ERROR]-[InventoryValidator]-[<span class="hljs-number">13</span>] Exception <span class="hljs-keyword">in</span> fetching product information - Product Not Available
</code></pre><p>Metrics are represented as numbers. They measure something (like CPU usage, number of errors, and so on) and are numeric in nature.</p>
<p>A typical metric looks like this:</p>
<pre><code>{<span class="hljs-class"><span class="hljs-keyword">class</span></span>=InventoryValidator, exception=Product Not Available, timestamp=<span class="hljs-number">1609306200</span>}
</code></pre><h2 id="heading-the-resolution-of-logs-and-metrics">The Resolution of Logs and Metrics</h2>
<p>Logs contain high-resolution data. This includes complete information about an event and can be used to correlate the flow (or path) that the event took through the system. </p>
<p>In case of errors, logs contain the entire stack trace of the exception, which allows us to view and debug issues originating from downstream systems as well. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/12/android-stack-trace-error-2.png" alt="Image" width="600" height="400" loading="lazy">
<em>A log entry showing the stacktrace of an error</em></p>
<p>In short, logs can tell you <em>what happened</em> in the system at a certain time.</p>
<p>Metrics contain low-resolution data. This may include a count of parameters (such as requests, errors, and so on) and measures of resources (such as CPU and memory utilization). </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/12/tracing_aggregated_red_metrics.png" alt="Image" width="600" height="400" loading="lazy">
<em>A Metric showing number of hits to a service</em></p>
<p>In short, metrics can give you <em>a count of something that happened</em> in the system at a certain time.</p>
<h2 id="heading-the-cost-of-logs-and-metrics">The Cost of Logs and Metrics</h2>
<p>Logs are expensive to store. The storage overhead of logs also increases over time and is directly proportional to the increase in traffic.</p>
<p>Metrics have a constant storage overhead. The cost of storage and retrieval of metrics does not increase too much with the increase in traffic. It is, however, dependent on the number of variables we emit with each metric.</p>
<h1 id="heading-cardinality-of-metrics">Cardinality of Metrics</h1>
<p>Metrics are identified by two key pieces of information:</p>
<ul>
<li>A metric name</li>
<li>A set of key-value pairs called tags or labels</li>
</ul>
<p>A permutation of these values provides the metric its cardinality. For example, if we are measuring the CPU utilization of a system with three hosts, the metric has a cardinality value of 3 and can have the following three values:</p>
<pre><code>(name=pod.cpu.utilization, host=A)
(name=pod.cpu.utilization, host=B)
(name=pod.cpu.utilization, host=C)
</code></pre><p>Similarly, if we introduced another tag in the metric that determined the AWS region of the hosts (say, <code>us-west-1</code> and <code>us-west-2</code>), we would now have a metric with a cardinality value of 6.</p>
<h1 id="heading-types-of-metrics">Types of Metrics</h1>
<h2 id="heading-golden-signals">Golden signals</h2>
<p>Golden signals are an effective way of monitoring the overall state of the system and identifying problems.</p>
<ul>
<li><strong>Availability:</strong> State of your system measured from the perspective of clients (for example, the percentage of errors on total requests).</li>
<li><strong>Health:</strong> State of your system measured using periodic pings.</li>
<li><strong>Request Rate:</strong> Rate of incoming requests to the system.</li>
<li><strong>Saturation:</strong> How free or loaded the system is (foe example, the queue depth or available memory).</li>
<li><strong>Utilization:</strong> How busy the system is (for example, CPU load or memory usage). This is represented as a percentage.</li>
<li><strong>Error Rate:</strong> Rate of errors being produced in the system.</li>
<li><strong>Latency:</strong> Response time of the system, usually measured in the 95th or 99th percentile.</li>
</ul>
<h2 id="heading-resource-metrics">Resource metrics</h2>
<p>Resource metrics are almost always made available by default from the infrastructure provider (AWS CloudWatch or Kubernetes metrics) and are used to monitor infrastructure health.</p>
<ul>
<li><strong>CPU/Memory Utilization:</strong> Usage of the system’s core resources.</li>
<li><strong>Host Count:</strong> Number of hosts/pods that are running your system (used to detect availability issues due to pod crashes).</li>
<li><strong>Live Threads:</strong> Threads spawned in your service (used to detect issues in multi-threading).</li>
<li><strong>Heap Usage:</strong> Heap memory usage statistics (can help debug memory leaks).</li>
</ul>
<h2 id="heading-business-metrics">Business metrics</h2>
<p>Business metrics can be used to monitor granular interaction with core APIs or functionality in your services.</p>
<ul>
<li><strong>Request Rate:</strong> Rate of requests to the APIs.</li>
<li><strong>Error Rate:</strong> Rate of errors being thrown by the APIs.</li>
<li><strong>Latency:</strong> Time taken to process requests by the APIs.</li>
</ul>
<h1 id="heading-dashboards-and-alerts-for-metrics">Dashboards and Alerts for Metrics</h1>
<p>Since metrics are stored in a time-series database, it’s more efficient and reliable to run queries against them for measuring the state of the system.</p>
<p>You can use these queries to build dashboards for representing the historical state of the system.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/10/Screenshot-2020-10-03-at-3.20.16-PM.png" alt="Image" width="600" height="400" loading="lazy">
<em>A Wavefront dashboard with some important metrics</em></p>
<p>They can also be used to trigger alerts when there is an issue with the system (like an increase in the number of errors observed or a sudden spike in CPU utilization).</p>
<p>Due to their numeric nature, we can also create complex mathematical queries (such as X% of errors in last Y minutes) to monitor system health.</p>
<p>The biggest challenge, however, in handling metrics is deciding the right amount of cardinality that makes the metric useful while also keeping its costs under control. </p>
<p>Emitting too many metrics, or metrics with too many dimensions, can lead to an increase in storage and processing costs. You need to choose the minimum cardinality that is just enough to give a high level picture about the system.</p>
<h1 id="heading-how-to-use-logs-and-metrics">How to Use Logs and Metrics</h1>
<p>Both logs and metrics have their own pros and cons. However, in any production system, we need to use both logs and metrics together to effectively monitor the system and debug any issues.</p>
<p>Metrics are often the first line of sight into the health of a system. Let's take the example of an e-commerce application like Amazon. The most important metric for such a use-case is the total number of successful and failed orders. </p>
<p>On a normal day, the metric for number of failed orders would remain at zero or some very small number. If there is an issue in the system that causes orders to suddenly start failing, this metric will show an increase in count.</p>
<p>You can create an <em>alert</em> on a combination of two metrics - total orders and failed orders. This will allow you to send a notification when the percentage of failed orders increases beyond a certain threshold (say 5%).</p>
<p>Once you are notified about the failing orders, you can then refer to the logs to find the cause of the failures. The logs would contain the error messages leading to the failure, as well as the detailed stacktrace that can identify the root cause of the failure.</p>
<h1 id="heading-conclusion">Conclusion</h1>
<p>In this article, we saw the differences between metrics and logs, and how metrics can help us monitor the health of our system more efficiently. Metrics can also be used to create dashboards and alerts using monitoring software like Wavefront and Grafana.</p>
<p>It is also necessary to use both metrics and logs in coordination to accurately detect and debug issues.</p>
<p>Thank you for staying with me so far. Hope you liked the article. You can connect with me on <a target="_blank" href="https://www.linkedin.com/in/theawesomenayak/">LinkedIn</a> where I regularly discuss technology and life. Also take a look at some of my other articles on <a target="_blank" href="https://medium.com/@theawesomenayak">Medium</a>. Happy reading 🙂</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Quickly Track PDF Access on a Linux Web Server ]]>
                </title>
                <description>
                    <![CDATA[ Is it possible to track how many times your website's users click to download binary files like PDFs or JPGs? Yes it is possible. Is it easy? I didn't originally think so. I was wrong. The story began while I was optimizing a landing page on my Boots... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/quickly-track-pdf-access-linux-web-server/</link>
                <guid isPermaLink="false">66b9962622379234769e45f1</guid>
                
                    <category>
                        <![CDATA[ analytics ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Google Analytics ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Linux ]]>
                    </category>
                
                    <category>
                        <![CDATA[ metrics ]]>
                    </category>
                
                    <category>
                        <![CDATA[ pdf ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ David Clinton ]]>
                </dc:creator>
                <pubDate>Wed, 02 Dec 2020 17:17:52 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/12/calculator.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Is it possible to track how many times your website's users click to download binary files like PDFs or JPGs? Yes it is possible. Is it easy? I didn't originally think so. I was wrong.</p>
<p>The story began while I was optimizing a landing page on my <a target="_blank" href="https://bootstrap-it.com/davidclinton/keeping-up">Bootstrap IT website</a> for my new book, <em>Keeping Up: Backgrounders to all the big technology trends you can't afford to miss</em>. </p>
<p>I wanted to provide access to the PDF file of a sample chapter from the book. But I also wanted some way to know how many people actually downloaded it.</p>
<p>Now let's take a step back. <a target="_blank" href="https://analytics.google.com/analytics/web/">Google Analytics</a> is a free service that uses code snippets inserted into your HTML files to collect and display data on how often your files were accessed. </p>
<p>The magic - and problem - of Google Analytics is in just how much information about your users can be revealed. I discussed some of the privacy concerns involved with the service in the Keeping Up book. I also mentioned how I feel at least a bit guilty for using the service myself on my own sites.</p>
<p>At any rate, all by itself, Google Analytics isn't able to tell you much about how your web-based PDFs are being used. Of course, there are tricks for getting around the problem. </p>
<p>Traditional approaches include setting up the <a target="_blank" href="https://marketingplatform.google.com/about/tag-manager/">Google Tag Manager</a>, customizing the syntax of the request URLs you use or, if your site uses WordPress software, working with the <a target="_blank" href="https://www.monsterinsights.com/">Monster Insights plugin</a>. Each of those can work, but will require a fairly steep learning curve.</p>
<p>But I'm a Linux sysadmin. And, as I never fail to remind the people around me, the best sysadmins are lazy. Learning curve? That sounds suspiciously like work. Not gonna happen on my watch.</p>
<p>So here's the deal. My web server, obviously, runs Linux. And, under the hood, HTTP traffic is handled by Apache. That means that everything happening to and on my websites is going to be logged by Apache. </p>
<p>Everything. All it'll take to give me what I need to know about what my PDF sample chapter has been up to, is a single line of Bash run from my local workstation:</p>
<pre><code>echo <span class="hljs-string">"cd /var/log/apache2 &amp;&amp; grep -nr KeepingUpSampleChapter"</span> \
   | ssh -i PrivateKey.pem LoginName@bootstrap-it.com
</code></pre><p>Let's break that down. The first of the two commands in quotation marks (<code>cd /var/log/apache2</code>) will move us to the /var/log/apache2/ directory on the Linux server where Apache writes its logs. That's not rocket science.</p>
<p>There are going to be multiple files of interest in that directory. That's because messages relevant to regular access and errors are saved to different files, and because file rotation policies mean that there could be more than one version of either of those files, too. So I'll use <code>grep</code> to search all the uncompressed files for the <code>KeepingUpSampleChapter</code> string. <code>KeepingUpSampleChapter</code> is, of course, part of the filename of the PDF.</p>
<p>I then pipe that command to SSH, which will connect to my remote server and execute the command. Here's what a single entry would look like from a successful run (I've removed the requester's IP address out of privacy concerns):</p>
<pre><code>other_vhosts_access.log<span class="hljs-number">.1</span>:<span class="hljs-number">12200</span>:bootstrap-it.com:<span class="hljs-number">443</span> &lt;requester<span class="hljs-string">'s IP Address&gt; - - [01/Dec/2020:16:39:36 -0500] "GET /davidclinton/KeepingUpSampleChapter.pdf?pdf=SamplePDF HTTP/1.1" 200 65146 "https://bootstrap-it.com/davidclinton/keeping-up/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36"</span>
</code></pre><p>We can see:</p>
<ul>
<li>The log file where the entry appeared (<code>other_vhosts_access.log.1</code>)</li>
<li>The requester's IP address (redacted)</li>
<li>The timestamp telling us exactly when the file was accessed</li>
<li>The relative location of the file on the server file system (<code>/davidclinton/KeepingUpSampleChapter.pdf</code>)</li>
<li>The URL from which the request was made (<code>https://bootstrap-it.com/davidclinton/keeping-up/</code>)</li>
<li>And the browser the user was running</li>
</ul>
<p>That's a lot of information. If we're just curious about how many <em>times</em> the file was downloaded, we can simply pipe the output to the <code>wc</code> command that will tell us three things about the output: the number of lines, words, and characters it contained. That command would look like this:</p>
<pre><code>echo <span class="hljs-string">"cd /var/log/apache2 &amp;&amp; grep -nr KeepingUpSampleChapter | wc"</span> \
   | ssh -i PrivateKey.pem LoginName@bootstrap-it.com
</code></pre><p>There is one possible limitation with this method. If your website is busy, the log files will roll over frequently, often more than once a day. By default, after the first rollover, the files are compressed using the <code>gz</code> algorithm, which can't be read by <code>grep</code>.</p>
<p>The <code>zgrep</code> command won't have any trouble handling such files, but the process could end up taking a very long time. You might consider writing a simple custom script to decompress each <code>gz</code> file and then run regular <code>grep</code> against its contents. That'll be your project.</p>
<p><em>There's much more administration goodness in the form of books, courses, and articles available at my <a target="_blank" href="https://bootstrap-it.com/davidclinton">bootstrap-it.com</a>.</em></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ An Intro to Metrics Driven Development: What Are Metrics and Why Should You Use Them? ]]>
                </title>
                <description>
                    <![CDATA[ By dor sever One of the coolest things I have learned in the last year is how to constantly deliver value into production without causing too much chaos. In this post, I’ll explain the metrics-driven development approach and how it helped me to achie... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/metrics-driven-development/</link>
                <guid isPermaLink="false">66d45e43182810487e0ce151</guid>
                
                    <category>
                        <![CDATA[ Metrics driven development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ agile development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Grafana ]]>
                    </category>
                
                    <category>
                        <![CDATA[ MDD ]]>
                    </category>
                
                    <category>
                        <![CDATA[ metrics ]]>
                    </category>
                
                    <category>
                        <![CDATA[ #prometheus ]]>
                    </category>
                
                    <category>
                        <![CDATA[ TypeScript ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Thu, 12 Mar 2020 16:47:37 +0000</pubDate>
                <media:content url="https://cdn-media-2.freecodecamp.org/w1280/5f9c9c2b740569d1a4ca3062.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By dor sever</p>
<p>One of the coolest things I have learned in the last year is how to constantly deliver value into production without causing <strong>too</strong> much chaos.</p>
<p>In this post, I’ll explain the metrics-driven development approach and how it helped me to achieve that. By the end of the post, you’ll be able to answer the following questions:</p>
<ul>
<li>What are metrics and why should I use them</li>
<li>What are the different types of metrics</li>
<li>What tools could I use to store and display metrics</li>
<li>What is a real-world example of metrics-driven development</li>
</ul>
<h2 id="heading-what-are-metrics-and-why-should-i-use-them">What are metrics and why should I use them?</h2>
<p>Metrics give you the ability to collect information on an actively running system without changing its code.</p>
<p>It allows you to gain valuable data on the behavior of your application while it runs so you can make <strong><a target="_blank" href="https://www.techopedia.com/definition/32877/data-driven-decision-making-dddm">data-driven decisions</a></strong> based on real customer feedback and usage in production.</p>
<h2 id="heading-what-are-the-types-of-metrics-available-to-me">What are the types of metrics available to me?</h2>
<p>These are the most common metrics used today:</p>
<ul>
<li>Counter — Represents a monotonically increasing value.</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/Screen-Shot-5780-06-10-at-12.37.42-PM.png" alt="Image" width="600" height="400" loading="lazy">
<em>Counters are really useful for measuring rates!</em></p>
<p>In this example, a counter metric is used to calculate the rate of events over time, by counting events per second</p>
<ul>
<li>Gauge — Represents a single value that can go up or down.</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/Screen-Shot-5780-06-10-at-12.42.06-PM.png" alt="Image" width="600" height="400" loading="lazy">
<em>Gauges are really useful for measuring CPU usage!</em></p>
<p>In this example, a gauge metric is used to monitor the <a target="_blank" href="https://blog.appsignal.com/2018/03/06/understanding-cpu-statistics.html">user CPU</a> in percentages</p>
<ul>
<li>Histogram — A counting of observations (like request durations or sizes) in configurable buckets.</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/Screen-Shot-5780-06-10-at-12.44.12-PM.png" alt="Image" width="600" height="400" loading="lazy">
<em>Histograms are really useful for measuring request duration!</em></p>
<p>In this example, a histogram metric is used to calculate the 75th and 90th percentiles of an HTTP request duration.</p>
<p>The bits and bytes of the types: counter, histogram, and gauge can be quite confusing. Try reading about it further <a target="_blank" href="https://prometheus.io/docs/concepts/metric_types/">here</a>.</p>
<h2 id="heading-what-tools-can-i-use-to-store-and-display-metrics">What tools can I use to store and display metrics?</h2>
<p>Most monitoring systems consist of a few parts:</p>
<ol>
<li>Time-series database — A database software that optimizes storing and serving <a target="_blank" href="https://en.wikipedia.org/wiki/Time_series">time-series</a> data. Two examples of this kind of database are <a target="_blank" href="https://graphite.readthedocs.io/en/latest/whisper.html">Whisper</a> and <a target="_blank" href="https://prometheus.io/">Prometheus</a>.</li>
<li>Querying engine (with a querying language) — Two examples of common query engines are: <a target="_blank" href="https://graphiteapp.org/">Graphite</a> and <a target="_blank" href="https://prometheus.io/docs/prometheus/latest/querying/basics/">PromQL</a></li>
<li>Alerting system — The mechanism that allows you to configure alerts based on graphs created by the querying language. The system can send these alerts to Mail, Slack, PagerDuty. Two examples of common alerting systems are: <a target="_blank" href="https://grafana.com/">Grafana</a> and <a target="_blank" href="https://prometheus.io/">Prometheus</a>.</li>
<li>UI — Allows you to view the graphs generated by the incoming data and configure queries and alerts. Two examples of common UI systems are: <a target="_blank" href="https://graphiteapp.org/">Graphite</a> and <a target="_blank" href="https://grafana.com/">Grafana</a></li>
</ol>
<p>The setup we are using today in <a target="_blank" href="https://medium.com/@bigpanda_engineering">BigPanda Engineering</a> is</p>
<ul>
<li><a target="_blank" href="https://www.influxdata.com/time-series-platform/telegraf/">Telegraf</a> — used as a StatsD server.</li>
<li><a target="_blank" href="https://prometheus.io/">Prometheus</a> — used as our scrapping engine, Time-series database and querying engine.</li>
<li><a target="_blank" href="https://grafana.com/">Grafana</a> — used for Alerting, and UI</li>
</ul>
<p>And the constraints we had in mind while choosing this stack were:</p>
<ul>
<li>We want scalable and elastic metrics scraping</li>
<li>We want a performant query engine</li>
<li>We want the ability to query our metrics using custom tags(such as service names, hosts, etc.)</li>
</ul>
<h2 id="heading-a-real-world-example-of-metrics-driven-development-of-a-sentiment-analysis-service">A real-world example of Metrics-driven development of a Sentiment Analysis service</h2>
<p>Let’s develop a new pipeline service that calculates sentiments based on textual inputs and does it in a Metrics Driven Development way!</p>
<p>Let’s say I need to develop this pipeline service:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/1_bj6DWm4987CuedEclpyvVw.png" alt="Image" width="600" height="400" loading="lazy">
<em>Sentiment analysis pipeline architecture</em></p>
<p>And this is my usual development process:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/Screen-Shot-5780-06-16-at-7.31.52-AM.png" alt="Image" width="600" height="400" loading="lazy">
<em>Usual development process - Test, code and deploy. Oh my!</em></p>
<p>So I write the following implementation:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">let</span> senService: SentimentAnalysisService = <span class="hljs-keyword">new</span> SentimentAnalysisService();
<span class="hljs-keyword">while</span> (<span class="hljs-literal">true</span>) {
    <span class="hljs-keyword">let</span> tweetInformation = kafkaConsumer.consume()
    <span class="hljs-keyword">let</span> deserializedTweet: { msg: <span class="hljs-built_in">string</span> } = deSerialize(tweetInformation)
    <span class="hljs-keyword">let</span> sentimentResult = senService.calculateSentiment(deserializedTweet.msg)
    <span class="hljs-keyword">let</span> serializedSentimentResult = serialize(sentimentResult)
    sentimentStore.store(sentimentResult);
    kafkaProducer.produce(serializedSentimentResult, <span class="hljs-string">'sentiment_topic'</span>, <span class="hljs-number">0</span>);
}
</code></pre>
<p>The full gist can be found <a target="_blank" href="https://gist.github.com/dorsev/387800acee8d1b8e6af29c86101fedb8">here</a>.</p>
<p><strong>And t</strong>his method works<strong> perfectly </strong>fine<em>**</em>. </p>
<p><strong>But what happens when it doesn’t</strong>?</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/but-.gif" alt="Image" width="600" height="400" loading="lazy"></p>
<p>The reality is that while working (in an agile development process) we make mistakes. That’s a fact of life. </p>
<p>I believe that the real challenge with making mistakes is not to avoid them, but rather to optimize how fast we detect and repair them. So, we need to gain the ability to <strong>quickly</strong> discover our mistakes.  </p>
<p>It's time for the MDD-way.</p>
<h2 id="heading-the-metrics-driven-development-mdd-way">The Metrics Driven Development (MDD) way</h2>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/commandments.gif" alt="Image" width="600" height="400" loading="lazy">
<em>Behold! <strong>The Three Commandments of Production!</strong></em></p>
<p>The MDD approach is heavily inspired by the <strong>Three Commandments of Production</strong> (which I had learned about the hard way).</p>
<p><strong>The</strong> Three <strong>Commandments of Production are:</strong></p>
<ol>
<li>There are mistakes and bugs in the code you write and deploy.</li>
<li>The data flowing in production is unpredictable and <strong>unique!</strong></li>
<li>Perfect your code from <strong>real customer feedback and usage in production</strong>.</li>
</ol>
<p>And since we now know the <strong>Commandments</strong>, it's time to go over the 4 step plan of the Metrics-Driven development process.</p>
<h2 id="heading-the-4-step-plan-for-a-successful-mdd">The 4-step plan for a successful MDD</h2>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/MDD---oh-wow.png" alt="Image" width="600" height="400" loading="lazy">
<em>Metrics-driven development ?Oh wow!</em></p>
<h3 id="heading-develop-code">Develop code </h3>
<p>I write the code, and whenever possible, wrap it with a feature flag that  allows me to gradually open it for users.</p>
<h3 id="heading-metrics">Metrics</h3>
<p>This consists of two parts:</p>
<p><strong>Add metrics on relevant parts</strong></p>
<p>In this part, I ask myself what are the success or failure metrics I can define to make sure my feature works? In this case, does my new pipeline application perform its logic correctly?</p>
<p><strong>Add alerts on top of them so that I’ll be alerted when a bug occurs</strong></p>
<p>In this part, I ask myself What metric could alert me if I forgot something or did not implement it correctly?</p>
<h3 id="heading-deployment">Deployment</h3>
<p>I deploy the code and immediately monitor it to verify that it’s behaving as I have anticipated.</p>
<h3 id="heading-iterate-this-process-to-perfection">Iterate this process to perfection</h3>
<p>And that's it! Now that we have learned the process, let's tackle an important task inside it.</p>
<h2 id="heading-metrics-to-report-what-should-we-monitor">Metrics to Report — what should we monitor?</h2>
<p>One of the toughest questions for me, when I’m doing MDD, is: “what should I monitor”?</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/MALLTHINGZ.jpeg" alt="Image" width="600" height="400" loading="lazy">
<em>That’s a lovely gif. but un-realistic in most cases.</em></p>
<p>In order to answer the question, lets try to zoom out and look at the big picture.<br>All the possible information available to monitor can be divided into two parts:</p>
<ol>
<li><strong>Applicative information</strong> — Information that has an applicative context and meaning. An example of this will be — “How many tweets did we classify as positive in the last hour”?</li>
<li><strong>Operational information</strong> — Information that is related to the infrastructure that surrounds our application — Cloud data, CPU and disk utilization, network usage, etc.</li>
</ol>
<p>Now, since we cannot monitor everything, we need to choose what applicative and operational information we want to monitor.</p>
<ul>
<li>The operational part really depends on your ops stack and has built-in solutions for (almost) all your monitoring needs.</li>
<li>The applicative part is more unique to your needs, and I'll try to explain how I think about it later in this post.</li>
</ul>
<p>After we do that, we can ask ourselves the question: what alerts do we want to set up on top of the metrics we just defined?</p>
<p>The diagram (of information, metrics, alerts) can be drawn like this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/world-of.png" alt="Image" width="600" height="400" loading="lazy">
<em>The world of information, metrics, and alerts.</em></p>
<h3 id="heading-applicative-metrics">Applicative metrics</h3>
<p>I usually add applicative metrics out of two needs:</p>
<h4 id="heading-to-answer-questions">To answer questions</h4>
<p>A question is something like, “When my service misbehaves, what information would be helpful to know about?”</p>
<p>Some answers to that question can be — latencies of all IO calls, processing rate, throughput, etc…</p>
<p>Most of these questions will be helpful while you are searching for the answer. But once you found it, chances are you will not look at it again (since you already know the answer).</p>
<p>These questions are usually driven by RND and are (usually) used to gather information internally.</p>
<h4 id="heading-to-add-alerts">To add Alerts</h4>
<p>This may sound backward, but I usually add applicative metrics in order to define alerts on top of them. Meaning, we define the list of alerts and then deduce from them what are the applicative metrics to report.</p>
<p>These alerts are derived from the SLA of the product and are usually treated with mission-critical importance.</p>
<h2 id="heading-common-types-of-alerts">Common types of alerts</h2>
<p>Alerts can be broken down into three parts:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/alert-types.png" alt="Image" width="600" height="400" loading="lazy">
<em>Alerts types to Metrics list</em></p>
<h3 id="heading-sla-alerts">SLA Alerts</h3>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/sla-breach.jpeg" alt="Image" width="600" height="400" loading="lazy">
<em>SLA alerts in reality</em></p>
<p><a target="_blank" href="https://en.wikipedia.org/wiki/Service-level_agreement">SLA</a> alerts surround the places in our system where an SLA is specified to meet explicit customer or internal requirements (i.e availability, throughput, latency, etc.). SLA breaches involve paging RND and waking people up, so try to keep the alerts in this list to a minimum.</p>
<p>Also, we can define <strong>Degradation</strong> Alerts in addition to SLA Alerts.<br>Degradation alerts are defined with lower thresholds then SLA alerts, and are therefore useful in reducing the amount of SLA breaches — by giving you a proper heads-up before they happen.</p>
<p>An example of an SLA alert would be, “All sentiment requests must finish in under 500ms.”</p>
<p>An example of a Degradation Alert will be: “All sentiment requests must finish in under 400ms”.</p>
<p>These are the alerts I defined:</p>
<ol>
<li>Latency — I expect the 90th percentile of a single request duration not to exceed 300ms.</li>
<li>Success/Failure ratio of requests — I expect the number of failures per second, success per second, to remain under 0.01.</li>
<li>Throughput — I expect that the number of operations per second (ops) that the application handles will be &gt; 200</li>
<li>Data Size — I expect the amount of data that we store in a single day should not exceed 2GB.</li>
</ol>
<blockquote>
<p><em>200 ops <em> 60 bytes(Size of Sentiment Result)</em> 86400 sec in a day = 1GB &lt; 2GB</em></p>
</blockquote>
<h3 id="heading-baseline-breaching-alerts">Baseline Breaching Alerts</h3>
<p>These alerts usually involve measuring and defining a baseline and making sure it doesn’t (dramatically) change over time with alerts.</p>
<p>For example, the 99th processing latency for an event must stay relatively the same across time unless we have made dramatic changes to the logic.</p>
<p>These are the alerts I defined:</p>
<ol>
<li>Amount of Positive or Neutral or Negative Sentiment tweets — If for whatever reason, the sum of Positive tweets has increased or decreased dramatically, I might have a bug somewhere in my application.</li>
<li>All latency \ Success ratio of requests \ Throughput \ Data size must not increase\decrease dramatically over time.</li>
</ol>
<h3 id="heading-runtime-properties-alerts">Runtime Properties Alerts</h3>
<p>I’ve given a talk about <a target="_blank" href="https://www.youtube.com/watch?v=Xtuv_aduYjM">Property-Based Tests</a> and their insane strength. As it turns out, collecting metrics allows us to run property-based tests on our system <strong>in production</strong>!</p>
<p>Some properties of our system:</p>
<ol>
<li>Since we consume messages from a Kafka topic, the handled offset must monotonically increase over time.</li>
<li>1 ≥ sentiment score ≥ 0</li>
<li>A tweet should classify as either Negative \ Positive \ Neutral.</li>
<li>A tweet classification must be unique.</li>
</ol>
<p>These alerts helped me validate that:</p>
<ol>
<li>We are reading with the same group-id. Changing consumer group ids by mistake in deployment is a common mistake when using Kafka. It causes a lot of mayhem in production.</li>
<li>The sentiment score is consistently between 0 and 1.</li>
<li>Tweet category length should always be 1.</li>
</ol>
<p>In order to define these alerts, you need to submit metrics from your application. Go <a target="_blank" href="https://gist.github.com/dorsev/181e84e091ae545cb7825b782faf9d20">here</a> for the complete metrics list.</p>
<p>Using these metrics, I can create <strong>alerts</strong> that will “page” me whenever one of these properties do not hold anymore in production.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/processing-latency-alert.png" alt="Image" width="600" height="400" loading="lazy">
<em>Processing latency breached configured SLA! Oh my! ?</em></p>
<p>Let’s take a look at a possible implementation of all these metrics</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">import</span> SDC = <span class="hljs-built_in">require</span>(<span class="hljs-string">"statsd-client"</span>);
<span class="hljs-keyword">let</span> sdc = <span class="hljs-keyword">new</span> SDC({ host: <span class="hljs-string">'localhost'</span> });
<span class="hljs-keyword">let</span> senService: SentimentAnalysisService; <span class="hljs-comment">//...</span>
<span class="hljs-keyword">while</span> (<span class="hljs-literal">true</span>) {
    <span class="hljs-keyword">let</span> tweetInformation = kafkaConsumer.consume()
    sdc.increment(<span class="hljs-string">'incoming_requests_count'</span>)
    <span class="hljs-keyword">let</span> deserializedTweet: { msg: <span class="hljs-built_in">string</span> } = deSerialize(tweetInformation)
    sdc.histogram(<span class="hljs-string">'request_size_chars'</span>, deserializedTweet.msg.length);
    <span class="hljs-keyword">let</span> sentimentResult = senService.calculateSentiment(deserializedTweet.msg)
    <span class="hljs-keyword">if</span> (sentimentResult !== <span class="hljs-literal">undefined</span>) {
        <span class="hljs-keyword">let</span> serializedSentimentResult = serialize(sentimentResult)
        sdc.histogram(<span class="hljs-string">'outgoing_event_size_chars'</span>, serializedSentimentResult.length);
        sentimentStore.store(sentimentResult)
        kafkaProducer.produce(serializedSentimentResult, <span class="hljs-string">'sentiment_topic'</span>, <span class="hljs-number">0</span>);
    }

}
</code></pre>
<p>The full code can be found <a target="_blank" href="https://gist.github.com/dorsev/d7737ed6a866cf98b026d47f4f7faae8">here</a></p>
<p><strong>A few thoughts on the code example above:</strong></p>
<ol>
<li>There has been a staggering amount of metrics added to this codebase.</li>
<li>Metrics add complexity to the codebase, so, like all good things, add them responsibly and in moderation.</li>
<li>Choosing correct metric names is hard. Take your time selecting proper names. <a target="_blank" href="https://prometheus.io/docs/practices/naming/">Here’s</a> an excellent post about this.</li>
<li>You still need to collect these metrics and display them in a monitoring system (like Grafana), plus add alerts on top of them, but that’s a topic for a different post.</li>
</ol>
<h2 id="heading-did-we-reach-the-initial-goal-of-identifying-issues-and-resolving-them-faster">Did we reach the initial goal of identifying issues and resolving them faster?</h2>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/yes-it-was-.gif" alt="Image" width="600" height="400" loading="lazy">
<em>YESSSS, it was!</em></p>
<p>We can now make sure the application latency and throughput do not degrade over time. Also, adding alerts on these metrics allows for a much faster issue discovery and resolution.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Metrics-driven development goes hand in hand with CI\CD, DevOps, and agile development process. If you are using any of the above keywords, then you are in the right place.</p>
<p>When done right, metrics make you feel more confident in your deployment in the same way that seeing passing unit-tests in your build makes you feel confident in the code you write.</p>
<p>Adding metrics allows you to deploy code and feel confident that your production environment is stable and that your application is behaving as expected over time. So I encourage you to try it out!</p>
<h4 id="heading-some-references">Some references</h4>
<ol>
<li>Here is a <a target="_blank" href="https://github.com/dorsev/MetricsSentimentAnalysis">link</a> to the code shown in this post, and <a target="_blank" href="https://gist.github.com/dorsev/181e84e091ae545cb7825b782faf9d20">here</a> is the full metrics list described.</li>
<li>If you are eager to try writing some metrics and to connect them to a monitoring system, check out <a target="_blank" href="https://prometheus.io/docs/introduction/first_steps/">Prometheus</a>, <a target="_blank" href="https://grafana.com/docs/grafana/latest/guides/getting_started/">Grafana</a> and possibly this <a target="_blank" href="https://dev.to/kirklewis/metrics-with-prometheus-statsd-exporter-and-grafana-5145">post</a></li>
<li>This guy wrote a delightful <a target="_blank" href="https://sookocheff.com/post/mdd/mdd/">post</a> about metrics-driven development. GO read it.</li>
</ol>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
