Skip to content
This repository was archived by the owner on May 14, 2026. It is now read-only.

feat(observability): introduce minimal tracing implementation#4105

Merged
diegomarquezp merged 42 commits into
mainfrom
observability/initial-tracing-impl
Feb 17, 2026
Merged

feat(observability): introduce minimal tracing implementation#4105
diegomarquezp merged 42 commits into
mainfrom
observability/initial-tracing-impl

Conversation

@diegomarquezp
Copy link
Copy Markdown
Contributor

@diegomarquezp diegomarquezp commented Feb 5, 2026

Summary

This PR introduces a new tracing mechanism in GAX that allows recording traces using OpenTelemetry. It provides a way of recording spans and attributes, following the existing ApiTracer class pattern with a few tracing-specific additions. The implementation is meant to be extensible to support other implementations.

New Classes

  • TraceManager: An interface for managing spans and attributes; can be implemented by observability frameworks.
  • OpenTelemetryTraceManager: An implementation of TraceManager that uses the OpenTelemetry API.
  • AppCentricTracer: An ApiTracer implementation that delegates span management to a TraceManager.
  • AppCentricTracerFactory: A factory for creating AppCentricTracer instances.
  • ApiTracerContext: A context object that carries information (like EndpointContext's server address property) used to infer common attributes for all tracers.
  • Span: A handle returned by TraceManager to manage the lifecycle of a specific span (ending it, recording errors, or setting attributes).

Approach

Connecting Tracer with Manager

The implementation aims to decouple AppCentricTracer from TraceManager. When a tracer starts an operation or an attempt, it requests a Span from the recorder. This handle allows the tracer to update the span (e.g., adding attributes or recording errors) to keep AppCentricTracer separated from specific recorder implementations (like OpenTelemetry's Span object).

Attribute Inference via ApiTracerContext

To provide a source of Span Attributes that are common to all operations, we introduced ApiTracerContext. This context is passed to ApiTracerFactory and contains information such as serverAddress (provided by EndpointContext). It is operated by ClientContext.
Initially, only serverAddress is contained in this class and it's meant to obtain the server.address attribute.
The class is ultimately operated by AppCentricTracer to extract the necessary attributes.

Integration Tests

A new integration test, ITOtelTracing, was added to the java-showcase module:

  • It validates that the expected spans (operation and attempt spans) are recorded with the correct names, parent-child relationships, and attributes (including server.address and gcp.client.language).

Note on java-bigtable downstream check

Since SkipTrailersTest mocks the tracer factory, the EndpointContext call to apiTracerFactory.withContext() returns a null factory, causing a null pointer exception when building the client context.
We expect the test to be adjusted with this change with the next release.

Confirmation in Cloud Trace

image

Loading
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants