Think about the overall start and end time of the entire trace, not just individual spans.
Cloud Trace calculates total latency as the difference between the earliest start time and the latest end time of all spans in the trace. Here, the earliest start is 0ms (Span A) and the latest end is 50ms (Span A), so total latency is 50 milliseconds.
Consider how to capture important slow requests without overwhelming data volume.
Sampling only requests that exceed a latency threshold captures relevant latency spikes while reducing cost and data volume compared to sampling all requests.
Least privilege means giving only the permissions needed to perform a task.
roles/cloudtrace.viewer allows read-only access to trace data, limiting exposure. roles/cloudtrace.agent allows writing traces but not necessarily viewing. roles/editor and roles/owner grant broad permissions beyond trace data.
Custom attributes must be added where spans are created.
Custom trace attributes like 'user_region' must be added as labels in the application code when creating or updating spans. Console settings or environment variables do not automatically add attributes to spans.
Think about exporting data to cheaper storage with automatic deletion.
Exporting trace data to Cloud Storage allows applying lifecycle management policies to automatically delete data after 30 days, reducing costs. Keeping data indefinitely or manual deletion is inefficient. Disabling collection stops new data but does not manage existing data.