Monitor gRPC with OpenTelemetry

gRPC is a cross-platform open source high performance Remote Procedure Call (RPC) framework by Google. gRPC is ideal for lightweight microservices where efficiency is critical.

This article explains how you can monitor and optimize gRPC performance using OpenTelemetry observability framework.

What is OpenTelemetry?

OpenTelemetry is a vendor-neutral standard on how to collect telemetry data for applications and their supporting infrastructures. OpenTelemetry was created via the merger of OpenCensus and OpenTracing projects.

OpenTelemetry aims to standardize how you collect and send telemetry data to backend platforms: tracesopen in new window, metricsopen in new window, and logsopen in new window.


To install gRPC OpenTelemetry instrumentation:

go get


To instrument gRPC client:

import (

conn, err := grpc.Dial(target,

To instrument gRPC server:

import (

server := grpc.NewServer(

Metadata and baggage

On the client side, you can use gRPC metadata as a baggage:

import ""

md := metadata.Pairs(
	"key1", "value1",
	"key2", "value2",
ctx := metadata.NewOutgoingContext(context.Background(), md)

On the server side, you can use gRPC metadata from an incoming request:

import ""

md, ok := metadata.FromIncomingContext(ctx); ok {

Or use OpenTelemetry baggage API:

import ""

baggage := baggage.FromContext(ctx)

What is Uptrace?

Uptrace is an open source APMopen in new window for OpenTelemetry that helps developers pinpoint failures and find performance bottlenecks. Uptrace can process billions of spans on a single server and allows to monitor your software at 10x lower cost.

You can get startedopen in new window with Uptrace by downloading a DEB/RPM package or a pre-compiled Go binary.

What's next?

Next, instrument more operations, for example, database queries, errors, and logs. You can also learn about OpenTelemetry Go Tracing API to create your own instrumentations.

Popular instrumentations:

Last Updated: