---
title: "Instrumenting my espresso machine with OpenTelemetry"
description: "A Gaggia espresso machine running the GaggiMate ESP32 controller is instrumented with OpenTelemetry and shipped to ClickHouse Cloud via ClickStack, modelling each shot as a trace with phase child spans and fast-moving sensor state as gauge metrics."
url: "https://swe.quest/articles/instrumenting-my-espresso-machine-with-opentelemetry-d67ba22f350cd82b"
canonical: "https://clickhouse.com/blog/espresso-machine-observability-with-otel"
source: "ClickHouse"
published: "2026-07-29"
difficulty: "medium"
kind: "Case study"
reading_minutes: 18
tags: ["observability","hardware","c-cpp","concurrency","analytics"]
---

# Instrumenting my espresso machine with OpenTelemetry

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2026-07-29, 18 min read, Case study. Original: [https://clickhouse.com/blog/espresso-machine-observability-with-otel](https://clickhouse.com/blog/espresso-machine-observability-with-otel)

## Summary

A Gaggia espresso machine running the GaggiMate ESP32 controller is instrumented with OpenTelemetry and shipped to ClickHouse Cloud via ClickStack, modelling each shot as a trace with phase child spans and fast-moving sensor state as gauge metrics. The embedded engineering is the core. A flattened OTLP protobuf subset preserves upstream field numbers to fit nanopb limits. A FreeRTOS export task is pinned to core 1 and uses a snapshot-under-mutex pattern so TLS never blocks the 50ms brew loop. Exports are held until NTP sets the clock, and protobuf message concatenation lets a 500ms-sampled ring buffer ship within size limits. Channeling is detected on-device via a constant-memory coefficient of variation, and per-shot IDs stored as Map attributes avoid the cardinality explosion a label-based TSDB would suffer.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Observability](https://swe.quest/tags/observability.md) (Reliability & operations)
- [Hardware](https://swe.quest/tags/hardware.md) (Infrastructure)
- [C & C++](https://swe.quest/tags/c-cpp.md) (Languages)
- [Concurrency](https://swe.quest/tags/concurrency.md) (Compilers & runtimes)
- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)

## Prerequisites

- OpenTelemetry basics ([easy posts on Observability](https://swe.quest/tags/observability.md?difficulty=easy))
- protobuf wire format ([easy posts on RPC & gRPC](https://swe.quest/tags/rpc.md?difficulty=easy))
- embedded C++ and FreeRTOS ([easy posts on C & C++](https://swe.quest/tags/c-cpp.md?difficulty=easy))
- mutexes and threading

## Keywords

OpenTelemetry, OTLP, ClickStack, ClickHouse, ESP32, nanopb, FreeRTOS, GaggiMate

## Related posts

- [Making Rust observability reliable at scale with OpenTelemetry](https://swe.quest/articles/making-rust-observability-reliable-at-scale-with-opentelemetry-93edfa18e478ae5a.md): Datadog Engineering · 2026-09-01 · Medium · 10 min read · Observability, Rust, Open source
  Datadog built dd-trace-rs, an opinionated Rust tracer on top of the OpenTelemetry Rust SDK, to fix fragmented traces, inconsistent sampling and context loss across Rust services.
- [IBM Instana’s solution for monitoring ClickHouse performance](https://swe.quest/articles/ibm-instana-s-solution-for-monitoring-clickhouse-performance-2d8ea3511eb7a606.md): ClickHouse · 2025-01-17 · Easy · 4 min read · Observability, Analytics & OLAP, Databases
  IBM Instana, which stores its telemetry in ClickHouse, built a custom span exporter to trace ClickHouse's own query execution without adding load or invasive changes to customer systems.
- [LLM observability with ClickStack, OpenTelemetry, and MCP](https://swe.quest/articles/llm-observability-with-clickstack-opentelemetry-and-mcp-0444a970ae228536.md): ClickHouse · 2025-07-15 · Medium · 13 min read · Observability, LLMs, AI agents
  LibreChat (Node.js) and the Python ClickHouse MCP server can be instrumented with OpenTelemetry and shipped to ClickStack (HyperDX UI, OTel collector, ClickHouse) to observe LLM interactions, MCP tool calls and token usage with minimal code changes.
- [Observability as a superpower](https://swe.quest/articles/observability-as-a-superpower-5609b41c95a2309f.md): incident.io · 2024-11-04 · Medium · 8 min read · Observability, Go, Debugging, Incidents & postmortems
  Distributed tracing with OpenTelemetry lets incident.io engineers spot bugs before customers report them, by showing each request's route as a tree of timed spans that exposes slow steps, N+1 queries and duplicate calls.
- [Building an Observability Solution with ClickHouse - Part 2 - Traces](https://swe.quest/articles/building-an-observability-solution-with-clickhouse-part-2-traces-1a2db2608573ffa7.md): ClickHouse · 2023-03-29 · Medium · 29 min read · Observability, Analytics & OLAP, Microservices
  Trace data from OpenTelemetry-instrumented services can be stored and queried in ClickHouse, treating spans as rows in a single analytics table and visualizing them in Grafana.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
