liveBook · Manning

Go

As explained in Cloud Observability in Action

Go is a statically typed compiled programming language designed for efficient systems and network software development.

Go is a statically typed, compiled language used here to build HTTP services and expose application behavior for observability. section 2.1 section 9.1.1

The examples use Go to:

  • Build and run an echo service that listens on port 4242 and sometimes returns an internal server error. section 2.1
  • Generate request load with curl so logs, metrics, and traces can be inspected using Grafana, Prometheus, and Jaeger. section 2.1
  • Expose runtime profiles through net/http/pprof and inspect goroutines, heap allocations, and CPU usage. section 9.1.1

Instrumentable echo service

A small Go program registers an /echo handler, reads a message query parameter, writes the response, and serves HTTP on localhost:4242. Building it uses go build -o echosvc ., while repeated curl requests create activity for observability tools. section 2.1

Listing 2.1 Example Go program to be instrumented
package main
 
import (
    "fmt"
    "log"
    "math/rand"
    "net/http"
    "time"
)
 
func handleEcho(w http.ResponseWriter, r *http.Request) {
    message := r.URL.Query().Get("message")                   #1
    if rand.Intn(100) > 90 {                                  #2
        w.WriteHeader(http.StatusInternalServerError)
        return
    }
    fmt.Fprintf(w, message)                                   #3
}
 
func main() {
    rand.Seed(time.Now().UnixNano())
    http.HandleFunc("/echo", handleEcho)                      #4
    log.Fatal(http.ListenAndServe(":4242", nil))              #5
}

Inspect the complete Go echo service, including its handler, randomized failure path, route registration, and HTTP server. section 2.1

How Cloud Observability in Action covers it

How deep it goes
Demonstrates runnable services and profiling commands but stops short of explaining Go language semantics.
Examples
Uses an echo service, curl load generation, and a pprof-enabled program with quickTask and slowTask functions.
What it assumes
Assumes basic command-line use and HTTP familiarity while demonstrating service construction and profiling setup.
What you can do after
Build and operate small Go HTTP services, then inspect their runtime behavior with pprof and observability tools.
How it connects
Connects Go with HTTP services, observability, profiling, pprof, Grafana, Prometheus, and Jaeger.

Also explained in

Compare how 11 books explain Go →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Cloud Observability in Action. The section links point to the parts of the book it draws on.