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
GCP Professional Cloud Developer (PCD) 完全ガイド|Cloud Run・GKE・CI/CD・APM
Google Cloud Professional Cloud Developer の試験範囲、Cloud Run / GKE / Cloud Build / Cloud Trace、AWS DVA / Azure AZ-204 比較、学習ロードマップを徹底解説。
Cloud Build 完全ガイド|CI/CD・cloudbuild.yaml・Private Pool・GitHub 連携 (GCP)
Google Cloud Cloud Build の全機能解説。cloudbuild.yaml、トリガー設定、Private Pool、Workload Identity、Build Approvals、Cloud Deploy 連携、AWS CodeBuild / Azure DevOps 比較を網羅。
Cloud Deploy 完全ガイド|Canary・Blue-Green・GKE/Cloud Run プログレッシブデプロイ (GCP)
Google Cloud Cloud Deploy の全機能解説。Delivery Pipeline、Canary / Blue-Green、Approval Gate、Verify、Skaffold 統合、GKE / Cloud Run / Anthos 対応、AWS CodeDeploy / ArgoCD 比較を網羅。
Cloud Monitoring 完全ガイド|SLO・Prometheus・Grafana・Datadog 比較 (GCP)
Google Cloud Monitoring の全機能解説。SLO 機能、Managed Service for Prometheus、Grafana 統合、アラート、ダッシュボード、Uptime Check、料金、Datadog / New Relic 比較を網羅。
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...