liveBook · Manning

OpenTelemetry

As explained in gRPC Microservices in Go

OpenTelemetry is an open-source observability framework for instrumenting applications and collecting, processing, and exporting traces, metrics, and logs.

OpenTelemetry is a collection of APIs and SDKs for generating, collecting, and exporting metrics, traces, and logs. In a microservice system, it provides visibility into requests that cross service boundaries. The Go implementation can instrument a gRPC application and send telemetry to a collector for inspection. section 9.2 section 9.0

Choose instrumentation points along the request path:

  • Instrument gRPC client connections and server calls to observe communication between services. section 9.2.1
  • Instrument database operations when they matter to the request; an OpenTelemetry GORM extension is available for that purpose. section 9.2.1
  • Configure trace propagation so downstream services receive the existing trace context rather than appearing as isolated requests. section 9.2.1 section 9.3.5

For a Go gRPC server, configure a tracing provider at service startup, then attach an OpenTelemetry server interceptor. The provider uses a Jaeger exporter pointed at the collector endpoint and batches exports. Resource attributes identify the service and environment; those attributes can be searched in Jaeger. Set a text-map propagator to carry trace context across calls. section 9.3.5 section 9.3.4

import (
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
)
...
grpcServer := grpc.NewServer(
        grpc.UnaryInterceptor(otelgrpc.UnaryServerInterceptor()),
    )
...

The Order service attaches otelgrpc.UnaryServerInterceptor() when constructing its gRPC server, making server-side calls an instrumentation point. section 9.3.5

Follow an order across services

When the Order service calls the Payment service to charge a customer, propagated trace metadata lets the Jaeger UI display the wider request flow. Jaeger also provides service-latency views and trace queries by service name; its performance monitoring uses time-series data in Prometheus. section 9.3.5 section 9.2.4

How gRPC Microservices in Go covers it

How deep it goes
Works through Go tracing-provider configuration and a gRPC server interceptor, without detailing implementation of log collection.
Examples
Shows an Order-service gRPC interceptor and an Order-to-Payment trace, with Jaeger queries for request flow and latency.
What it assumes
Assumes an existing Go microservice application and introduces where to add instrumentation and how to configure its tracing provider.
What you can do after
Operate/configure it in a Go gRPC service to export traces to a Jaeger collector and inspect cross-service request flow.
How it connects
Connects distributed tracing and context propagation with gRPC, GORM, the OpenTelemetry Collector, Jaeger, and Prometheus.

Also explained in

Compare how 7 books explain OpenTelemetry →

Related concepts

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