Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 71 additions & 7 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# Migration Guide

This guide provides instructions on how to migrate from the custom exporters in this repository to the standard OpenTelemetry OTLP exporters.
This guide provides instructions on how to migrate from the custom exporters and propagators in this repository to the standard OpenTelemetry OTLP exporters and W3C Trace Context propagator.

## Overview

Google Cloud supports native OTLP (OpenTelemetry Protocol) ingestion for Cloud Trace, Cloud Monitoring, and Cloud Logging via the [Telemetry API](https://docs.cloud.google.com/stackdriver/docs/reference/telemetry/overview). This allows you to use standard OpenTelemetry OTLP exporters for sending telemetry data to Google Cloud.

## Deprecation Notice

All exporters in this repository (`opentelemetry-exporter-gcp-trace`, `opentelemetry-exporter-gcp-monitoring`, and `opentelemetry-exporter-gcp-logging`) are deprecated. Please migrate to standard OTLP exporters using standard OpenTelemetry libraries.
Google Cloud supports native OTLP (OpenTelemetry Protocol) ingestion for Cloud Trace, Cloud Monitoring, and Cloud Logging via the [Telemetry API](https://docs.cloud.google.com/stackdriver/docs/reference/telemetry/overview). This allows you to use standard OpenTelemetry OTLP exporters for sending telemetry data to Google Cloud. In addition, Google Cloud infrastructure natively supports standard W3C Trace Context headers (`traceparent` and `tracestate`), allowing you to use standard OpenTelemetry context propagation without proprietary headers.

---

Expand All @@ -25,7 +21,7 @@ pip install opentelemetry-resourcedetector-gcp
### Usage & Configuration

* **Manual SDK Setup (In Code):** When manually setting up the SDK in Python (e.g., instantiating `TracerProvider()`, `MeterProvider()`, or `LoggerProvider()`), the GCP resource detector is **automatically discovered and applied** simply by installing `opentelemetry-resourcedetector-gcp`. No additional code changes or environment variables are required.
* **Autoconfiguration / Zero-Code Instrumentation:** When using OpenTelemetry autoconfiguration (`opentelemetry-sdk-extension-autoconfigure` or `opentelemetry-instrument`), enable the GCP resource detector via the `OTEL_EXPERIMENTAL_RESOURCE_DETECTORS` environment variable:
* **Auto-Instrumentation / Zero-Code:** When using OpenTelemetry auto-instrumentation (`opentelemetry-instrument`), enable the GCP resource detector via the `OTEL_EXPERIMENTAL_RESOURCE_DETECTORS` environment variable:

```bash
export OTEL_EXPERIMENTAL_RESOURCE_DETECTORS="gcp"
Expand Down Expand Up @@ -479,3 +475,71 @@ logger_provider.add_log_record_processor(
* **Log Names & Resources:** The OTLP endpoint maps log names from resource attributes (e.g. `gcp.log_name` or defaults to `projects/<project>/logs/otel`).
* **Query Impact:** If your existing Cloud Logging log queries filter by specific `logName` values (such as python logger names mapped by `CloudLoggingExporter`), you may need to update your Cloud Logging query filters to match the OTLP log names and attributes.
* **GCP Monitored Resource Association:** Installing `opentelemetry-resourcedetector-gcp` ensures log records contain appropriate GCP resource attributes, allowing Cloud Logging to associate logs with standard monitored resources (GCE instances, GKE pods, Cloud Run services, etc.).

---

## Migrate from X-Cloud-Trace-Context Propagator to W3C Trace Context Propagator

Google Cloud infrastructure now natively supports standard W3C Trace Context headers (`traceparent` and `tracestate`). The `opentelemetry-propagator-gcp` package is deprecated and will be archived after October 30th, 2026. You should migrate to standard OpenTelemetry W3C Trace Context propagation.

### Why Migrate?

* **Standardization:** W3C Trace Context is the industry standard for distributed tracing context propagation and is natively supported across cloud providers, libraries, and frameworks.
* **Native GCP Support:** Google Cloud services (such as Cloud Run, Cloud Functions, App Engine, Google Kubernetes Engine, Cloud Trace, and Google Cloud Load Balancers) natively support W3C Trace Context headers without requiring proprietary headers.
* **Built-in OpenTelemetry Support:** W3C Trace Context propagation is built into the core `opentelemetry-api` package and is enabled by default in OpenTelemetry Python.

---

### Migration Steps

#### 1. Remove Legacy Dependency

Remove the `opentelemetry-propagator-gcp` dependency from your project (`requirements.txt`, `pyproject.toml`, etc.):

```bash
pip uninstall opentelemetry-propagator-gcp
```

The standard W3C Trace Context propagator is included automatically with `opentelemetry-api`.

#### 2. Update Configuration (Auto-Instrumentation / CLI)

Unless overriden with `set_global_textmap()`, W3C Trace Context (`tracecontext`) and Baggage (`baggage`) are used by default (`OTEL_PROPAGATORS="tracecontext,baggage"`) in OpenTelemetry Python, regardless of if you're using auto-instrumentation or manual.

If you use the `opentelemetry-instrument` CLI for auto-instrumentation, remove the `--propagator gcp_trace` flag:

```bash
# Before
opentelemetry-instrument --propagator gcp_trace python main.py

# After (uses default W3C Trace Context and Baggage propagators)
opentelemetry-instrument python main.py
```

#### 3. Remove Manual Configuration in Code

If you manually registered `CloudTraceFormatPropagator` or `CloudTraceOneWayPropagator` in your application code, simply remove the propagator import and `set_global_textmap` registration.

OpenTelemetry automatically uses standard W3C Trace Context propagation by default—no manual `set_global_textmap` call is necessary.

##### Before (Legacy GCP Propagator)

```python
from opentelemetry.propagate import set_global_textmap
from opentelemetry.propagators.cloud_trace_propagator import (
CloudTraceFormatPropagator,
)

# Sets the X-Cloud-Trace-Context header propagator
set_global_textmap(CloudTraceFormatPropagator())
```

##### After

```python
# Simply remove the GCP propagator import and set_global_textmap call.
# OpenTelemetry automatically defaults to standard W3C Trace Context propagation.
```

> [!NOTE]
> Standard W3C Trace Context propagation is built into `opentelemetry-api` and enabled by default. You do not need to call `set_global_textmap` unless you are configuring non-default custom propagators.
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,15 @@
[![Documentation Status](https://readthedocs.org/projects/google-cloud-opentelemetry/badge/?version=latest)](https://google-cloud-opentelemetry.readthedocs.io/en/latest/?badge=latest)
<!-- todo add pypi badges here -->

> [!WARNING]
> **DEPRECATION NOTICE**: This repository and all of its contents are deprecated and will be archived on October 30th, 2026. Please refer to the [Migration Guide](MIGRATION.md) for detailed instructions on migrating your application to standard OpenTelemetry OTLP exporters and W3C Trace Context propagation.

This repo provides OpenTelemetry Python exporters, propagators, and resource detectors
for Google Cloud Platform.

To get started with instrumentation in Google Cloud, see [Generate traces and metrics with
Python](https://cloud.google.com/stackdriver/docs/instrumentation/setup/python).

## ⚠️ Deprecation Notice

**All custom Google Cloud exporters in this repository (`opentelemetry-exporter-gcp-trace`, `opentelemetry-exporter-gcp-monitoring`, and `opentelemetry-exporter-gcp-logging`) are deprecated.**

Google Cloud supports native OpenTelemetry Protocol (OTLP) ingestion for Cloud Trace, Cloud Monitoring, and Cloud Logging via the [Telemetry API](https://docs.cloud.google.com/stackdriver/docs/reference/telemetry/overview).

Please refer to the [Migration Guide](MIGRATION.md) for detailed instructions on migrating your application to standard OpenTelemetry OTLP exporters.

## Google Cloud Resource Detector

The OpenTelemetry Google Cloud Resource Detector (`opentelemetry-resourcedetector-gcp`) has moved to the [opentelemetry-python-contrib](https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/resource/opentelemetry-resourcedetector-gcp) repository:
Expand Down
9 changes: 9 additions & 0 deletions opentelemetry-propagator-gcp/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ OpenTelemetry Google Cloud Propagator
:target: https://google-cloud-opentelemetry.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status


.. admonition:: Warning - Deprecated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look like PyPI has special render for this pypi/warehouse#8300

@psx95 psx95 Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was from https://docs.open-mpi.org/en/v5.0.x/developers/rst-for-markdown-expats.html#brightly-colored-boxes - I'm thinking it will at least render properly in the markdown file.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like that doc is specifically talking about sphinx

not sure what you mean by markdown file, but it doesn't work right on github or apparently PyPI
Screenshot 2026-09-01 at 5 10 33 PM

Just letting you know if you're happy with that rendering SGTM, but you might be better off making it bold or something

:class: warning

This package is deprecated and will be archived after October 30th, 2026.
Google Cloud infrastructure now natively supports standard W3C Trace Context
headers. Please use standard W3C Trace Context propagation instead.
See the `Migration Guide <https://github.com/GoogleCloudPlatform/opentelemetry-operations-python/blob/main/MIGRATION.md>`_ for details.

This library provides support for propagating trace context in the Google
Cloud ``X-Cloud-Trace-Context`` format.

Expand Down
Loading