Cloud Trace と Cloud Profiler は GCP の APM (Application Performance Monitoring) コンポーネントで、 Trace は「リクエストの分散トレース」、Profiler は「関数レベルのプロファイル」を提供します。OpenTelemetry 統合により業界標準で計装可能です。
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
)| サービス | 料金 |
|---|---|
| Cloud Trace | $0.20/100 万 Span (超過分) |
| Cloud Trace 無料枠 | 月 250 万 Span |
| Cloud Profiler | 完全無料 |
| Error Reporting | 完全無料 |
| エンドポイント種別 | 推奨サンプル率 |
|---|---|
| Critical API (決済等) | 1.0 (100%) |
| 標準 API | 0.1 (10%) |
| Health Check | 0.0 (除外) |
| エラー時 | 1.0 (Always sample on error) |
| 項目 | Trace + Profiler | AWS X-Ray | Datadog APM | New Relic APM |
|---|---|---|---|---|
| 分散トレース | ◎ | ◎ | ◎ | ◎ |
| Profiler | ◎ | — | ○ | ○ |
| OpenTelemetry | ◎ | ○ | ◎ | ◎ |
| 料金 | 極めて安価 | 安め | 高め | 中 |
| UI | シンプル | 標準 | 豊富 | 豊富 |
Cloud Trace と Cloud Profiler の違いは?
Trace = リクエスト分散トレース (どこで時間がかかったか)、Profiler = 関数レベル CPU / メモリ使用率 (なぜ遅いか)。両方併用で完全な APM。
OpenTelemetry 対応は?
両方ともネイティブ対応。OpenTelemetry SDK で計装 → OTel Collector / 直接送信。Vendor lock-in 回避の標準アプローチ。
料金体系は?
Trace: 月 250 万 Span 無料、超過分 $0.20/100 万 Span。Profiler: 無料。極めて安価で全環境で常時有効化が標準。
Cloud Trace の保持期間は?
30 日。長期分析が必要な場合は BigQuery エクスポート。
Error Reporting との違いは?
Error Reporting = アプリエラーの自動グルーピング + 通知。Trace / Profiler とは独立した APM コンポーネント。
AWS X-Ray / Datadog APM との比較は?
機能は概ね同等。Trace + Profiler セットで Datadog APM 相当を低コストで実現可能。X-Ray は Lambda 統合が強い。
サンプリングはどう設定する?
デフォルト 0.1 QPS。本番では Adaptive Sampling 推奨。Critical エンドポイントは 1.0 で常時、Health Check は 0 で除外。
対応言語は?
Java / Python / Go / Node.js / Ruby / PHP / .NET。OpenTelemetry SDK 経由で任意言語対応。
関連記事・APM / 可観測性
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 は Google LLC の商標です。最新情報は Cloud Trace 公式 をご確認ください。
NicheeLab編集部
データエンジニアリング・クラウド資格の専門家。Databricks・Snowflake等の認定資格を保有し、実務経験に基づいた問題作成・解説を行っています。NicheeLab運営。
Google Cloud (GCP) 認定資格ロードマップ 2026 完全版|全 15 試験を体系化
Google Cloud 認定資格 全 15 試験 (Foundational 2 + Associate 3 + Pr...
Cloud Digital Leader (CDL) 完全ガイド|出題範囲・学習リソース・合格戦略
Google Cloud Cloud Digital Leader (CDL) の完全ガイド。6 ドメイン 92 bul...
Generative AI Leader (GAIL) 完全ガイド|Google Cloud 生成 AI 認定
Google Cloud Generative AI Leader (GAIL、2025-05-14 リリース) の完全...
Vertex AI 入門|Google Cloud 統合 ML プラットフォームの全機能
Google Cloud Vertex AI の入門解説。Vertex AI Studio / Agent Builde...
GCP Associate Cloud Engineer (ACE) 完全ガイド|試験範囲・受験料・学習ロードマップ
Google Cloud Associate Cloud Engineer (ACE) の試験範囲・受験料 125 US...