Export to BigQuery Stay organized with collections Save and categorize content based on your preferences.
Caution: As ofFebruary 18, 2026, the export of span data to BigQuery by using Cloud Tracesinks isdeprecated. Sinks used to export spans toBigQuery will be removed on or after February 18, 2027. For information abouthow to view your span data in BigQuery, seeMigrate to Log Analytics.
Beta
This product or feature is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of theService Specific Terms. Pre-GA products and features are available "as is" and might have limited support. For more information, see thelaunch stage descriptions.
This document describes some attributes of the BigQuery dataset that iscreated when a sink exports traces from Cloud Trace to BigQuery.
Schema
The schema for your table that stores trace data is determined by theTrace V2 API definition ofSpan.
Trace keeps track of your table columns and patches the tablewhen a new span contains fields that can't be stored in the existing table.A patch operation is required when an arriving span contains entries notpreviously seen. For example, if an arriving span contains a newAttribute, the table is patched.
Data retention
You configure the data retention policies of your BigQuery tables.For information about managing tables and table data, seeWorking with tables.
Table type
If you configure a sink to export traces to BigQuery,Trace configures aningestion-time partitioned table.For detailed information on partitioned tables, including how to create,managed, query, and delete these tables, seeWorking with partitioned tables.
Sample queries
In the following queries,DATASET is the name of theBigQuery dataset, andMY_TABLE is the name of a tablein that dataset.
To display all columns in the table for the date ofNovember 20, 2019 while limiting the result to 10 rows, run the query:
SELECT*FROM`DATASET.MY_TABLE`WHEREDATE(_PARTITIONTIME)="2019-11-20"LIMIT10
To display all of the partitions available in the table, run thequery:
SELECT_PARTITIONTIMEasptFROM`DATASET.MY_TABLE`GROUPBY1
HipsterShop query
HipsterShop is a demo application available onGitHub.
The following is a sample query that illustrates how you can useBigQuery queries to gather information that isn't readilyavailable using the Trace interface.
The inner query finds all spans that match the specified regular expressionthat were received on December 2, 2019.The outer query selects for display the following:
- name
- number of spans that match
- number of distinct trace IDs
- 50th, 90th, and 99th quantiles
- HTTP path
- Error message
and displays the results sorted by the trace counts:
SELECTt0.span.displayName.value,count(t0.span.spanId)asspanCount,count(distincttraceId)astraceCount,APPROX_QUANTILES(milliseconds,100)[OFFSET(50)]asp50,APPROX_QUANTILES(milliseconds,100)[OFFSET(95)]asp95,APPROX_QUANTILES(milliseconds,100)[OFFSET(99)]asp99,t0.span.attributes.attributeMap._http_path,t0.span.attributes.attributeMap._error_messageFROM(SELECT*,REGEXP_EXTRACT(span.name,r"./traces/([a-f0-9]+).")astraceId,TIMESTAMP_DIFF(span.endTime,span.startTime,MILLISECOND)asmillisecondsFROM`hipstershop-demo.Hipstershop_trace_export.cloud_trace`WHEREDATE(_PARTITIONTIME)="2019-12-02")ASt0WHEREt0.span.parentSpanIdisNULLGROUPbyt0.span.displayName.value,t0.span.attributes.attributeMap._http_path,t0.span.attributes.attributeMap._error_messageORDERBYtraceCountDESCLIMIT1000
For one particular installation of this application, the query resultis as shown:

View trace data
To view your trace data by using theBigQuery interface,select the table with your exported traces.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-18 UTC.