Cloud Trace and Cloud Profiler are GCP's APM (Application Performance Monitoring) components. Trace provides distributed request tracing, while Profiler provides function-level profiling. OpenTelemetry integration lets you instrument your code with the industry standard.
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.exporter.cloud_trace import CloudTraceSpanExporter
trace.set_tracer_provider(TracerProvider())
trace.get_tracer_provider().add_span_processor(
BatchSpanProcessor(CloudTraceSpanExporter())
)
tracer = trace.get_tracer(__name__)
@app.route('/order')
def create_order():
with tracer.start_as_current_span("validate_order"):
validate()
with tracer.start_as_current_span("save_to_db"):
save()
with tracer.start_as_current_span("send_notification"):
notify()
return {"status": "ok"}# pip install google-cloud-profiler
import googlecloudprofiler
googlecloudprofiler.start(
service='my-api',
service_version='1.0.0',
verbose=3, # 0=quiet, 4=verbose
)| Service | Pricing |
|---|---|
| Cloud Trace | $0.20 per 1M spans (beyond free tier) |
| Cloud Trace free tier | 2.5M spans/month |
| Cloud Profiler | Completely free |
| Error Reporting | Completely free |
| Endpoint Type | Recommended Sample Rate |
|---|---|
| Critical API (payments, etc.) | 1.0 (100%) |
| Standard API | 0.1 (10%) |
| Health Check | 0.0 (excluded) |
| On error | 1.0 (Always sample on error) |
| Capability | Trace + Profiler | AWS X-Ray | Datadog APM | New Relic APM |
|---|---|---|---|---|
| Distributed tracing | Excellent | Excellent | Excellent | Excellent |
| Profiler | Excellent | — | Good | Good |
| OpenTelemetry | Excellent | Good | Excellent | Excellent |
| Pricing | Very cheap | Cheap | Expensive | Mid-range |
| UI | Simple | Standard | Feature-rich | Feature-rich |
What is the difference between Cloud Trace and Cloud Profiler?
Trace = distributed request tracing (where time is being spent), Profiler = function-level CPU / memory usage (why it is slow). Use both together for full APM coverage.
Is OpenTelemetry supported?
Both have native support. Instrument with the OpenTelemetry SDK → send via the OTel Collector or directly. The standard approach for avoiding vendor lock-in.
What is the pricing model?
Trace: 2.5M spans/month free, $0.20 per 1M spans beyond that. Profiler: free. Extremely cheap, so always-on across all environments is the standard practice.
What is the Cloud Trace retention period?
30 days. Export to BigQuery if you need longer-term analysis.
How does it differ from Error Reporting?
Error Reporting = automatic grouping of application errors plus notifications. It is a separate APM component from Trace / Profiler.
How does it compare to AWS X-Ray / Datadog APM?
Functionality is roughly equivalent. The Trace + Profiler combination delivers Datadog APM-equivalent coverage at low cost. X-Ray has strong Lambda integration.
How should sampling be configured?
Default is 0.1 QPS. In production, adaptive sampling is recommended. Use 1.0 (always sample) for critical endpoints and 0 (exclude) for health checks.
Which languages are supported?
Java / Python / Go / Node.js / Ruby / PHP / .NET. Any language is supported via the OpenTelemetry SDK.
Related Articles: APM / Observability
Professional Cloud Developer (PCD): Complete Guide (2026)
Pass the PCD exam — Cloud Run, GKE, App Engine, Cloud SQL/Spanner. The developer-focused Professional cert.
Cloud Build Complete Guide: Triggers, Steps, Substitutions (2026)
Cloud Build — triggers, build steps, common CI patterns. The build engine of choice on GCP.
Cloud Deploy Complete Guide: GitOps for GKE (2026)
Cloud Deploy — delivery pipelines, targets, rollouts. The progressive delivery service for GKE.
Cloud Monitoring Complete Guide (2026)
Cloud Monitoring features — metrics, alerting, dashboards, uptime checks. The observability service for GCP.
Google Cloud is a trademark of Google LLC. For the latest information, see the official Cloud Trace docs.
Practice with certification-focused question sets
View GCP exam prepNicheeLab Editorial Team
NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.
Google Cloud Certification Roadmap (2026)
Choose your GCP certification path — Foundational, Associate...
CDL Cloud Digital Leader: Complete Exam Guide (2026)
Pass the Cloud Digital Leader exam — cloud business value, G...
GAIL Generative AI Leader: Complete Exam Guide (2026)
Pass the Generative AI Leader exam — Gemini, Vertex AI, Work...
Vertex AI Fundamentals for GCP Certs (2026)
Vertex AI basics every cert candidate needs — Workbench, Pip...
Associate Cloud Engineer (ACE): Complete Guide (2026)
Pass the Associate Cloud Engineer exam — Console, gcloud, pr...