OpenTelemetry

Instrument Your Services for Tracing

The OpenTelemetry project provides a single set of APIs, libraries, agents, and collector services to capture distributed traces, metrics and logs from your application.

By providing a standardized data format for distributed traces, metrics and logs, OpenTelemetry eliminates the need for vendor-specific integrations. Language-specific SDKs and auto-instrumentation for common languages and frameworks make it easier than ever to instrument your code and start capturing observability data.

OpenTelemetry Diagram

In this section of the workshop, we will use OpenTelemetry to instrument a Node.js application and send the tracing data to Cloud Observability. If you would like to learn more about OpenTelemetry, you can view our documentation or visit the project at opentelemetry.io.

There are two ways to instrument your code for tracing:

  1. Auto-instrumentation

  2. Manual instrumentation

Auto-instrumentation uses shims or bytecode instrumentation agents to intercept your code at runtime or at compile-time to add tracing and metrics instrumentation to the libraries and frameworks you depend on.

Manual instrumentation uses an SDK and APIs you call from your services to provide observability into the operations within a service. It requires you to manually add spans, context propagation, attributes, etc. to your application code. It is akin to commenting code or writing tests.

Auto-instrumentation is a quick way to start seeing your telemetry data in Cloud Observability. As a general rule of thumb, it is best to start with auto-instrumentation if it’s available. Once that’s in place, you’ll be able to see where the blind spots are in your system and you can start adding manual instrumentation as needed.

For example, auto-instrumentation doesn’t know your business logic—it only knows about frameworks and languages—in which case you’ll want to manually instrument your business logic, so that you get that additional visibility into the inner workings of your services.

Let’s get started by auto-instrumenting our application

next: Auto Instrumentation