liveBook · Manning

Debugging

As explained in Developer Experience on Kubernetes

Debugging is the systematic process of finding and correcting the cause of unexpected software behavior.

Debugging is the systematic process of finding and correcting unexpected software behavior. In a cloud-native inner loop, friction increases when the application runs in containers and logs, traces, or diagnostic tools are difficult to access. section 1.3.6 section 2.3.3

A practical debugging workflow combines:

  • Run existing tests first to detect regressions, then add tests for the new acceptance criteria. section 2.3.3
  • Use test output, logs, and traces to narrow the cause when behavior differs from expectations. section 1.3.6
  • Attach the editor or IDE debugger to the application, including when it runs inside a container. section 2.3.3
  • Add profiling or network inspection when performance bottlenecks or communication failures remain unexplained. section 1.3.6

Validating an appointment change

Start the PostgreSQL dependency, run the existing tests, and add an integration test for creating an appointment with a category. The test sends a request to the appointments endpoint and checks the response. If it fails, use the output to identify a regression or bug, then connect Visual Studio Code's debugger to the Go or Java application—even inside its container. section 2.3.3 section 2.4.5

Listing 2.10 Validate new feature with an integration test.
func Test_API(t *testing.T) {
    ...
    t.Run("It should return 200 when a POST request is made to '/appointments' with category", func(t *testing.T) {
        // prepare
        req, _ := http.NewRequest(http.MethodDelete, fmt.Sprintf("%s/appointments", ts.URL), nil)
 
        client := &http.Client{}
        _, err := client.Do(req)
 
        assert.NoError(t, err)
 
        // arrange
        appointment := appointmentWithCategoryFake()
 
        appointmentAsBytes, _ := appointment.MarshalBinary()
 
        // act
        _, err = http.Post(fmt.Sprintf("%s/appointments", ts.URL), "application/json", bytes.NewBuffer(appointmentAsBytes))
 
        // assert
        assert.NoError(t, err)
 
        // get
        resp, err := http.Get(fmt.Sprintf("%s/appointments", ts.URL))
        // assert
        assert.NoError(t, err)
 
        defer resp.Body.Close()
 
        var appointments []Appointment
        json.NewDecoder(resp.Body).Decode(&appointments)
 
        // assert
        assert.Equal(t, http.StatusOK, resp.StatusCode)
        assert.Equal(t, len(appointments), 1)
        assert.NotEmpty(t, appointments[0].Id)
        assert.Equal(t, appointments[0].PatientId, appointment.PatientId)
        assert.Equal(t, appointments[0].Category, appointment.Category)
    })
 
}
 
func appointmentWithCategoryFake() Appointment {
    return Appointment{
        PatientId:       "test-patient",
        Category:        "checkup",
        AppointmentDate: time.Now(),
    }
}

Inspect a concrete integration-test pattern for validating the new appointment behavior. section 2.3.3

How Developer Experience on Kubernetes covers it

How deep it goes
Traces testing and IDE attachment, while deferring distributed tracing and profiling to more advanced scenarios.
Examples
Uses Go and Java appointment integration tests, PostgreSQL, Visual Studio Code, logs, traces, profiling, and network inspection.
What it assumes
Assumes acceptance criteria, an IDE, tests, and a development environment, while demonstrating container debugging directly.
What you can do after
Diagnose/debug with tests, IDE debuggers, logs, traces, profiling, and network inspection.
How it connects
Connects testing, behavior-driven development, containers, observability, profiling, and network traffic inspection.

Also explained in

Compare how 20 books explain debugging →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Developer Experience on Kubernetes. The section links point to the parts of the book it draws on.