이 문서에서는 싱크가 Cloud Trace에서 BigQuery로 trace를 내보낼 때 생성되는 BigQuery 데이터 세트의 몇 가지 속성을 설명합니다.
스키마
trace 데이터를 저장하는 테이블의 스키마는 스팬의 Trace V2 API 정의에 따라 결정됩니다.
Trace는 테이블 스팬을 열을 추적하고 새 스팬에 기존 테이블에 저장할 수 없는 필드가 포함되면 테이블을 패치합니다.
수신되는 스팬에 이전에 보지 못했던 항목이 포함된 경우 패치 작업이 필요합니다. 예를 들어 수신되는 스팬에 새 속성이 포함되어 있으면 테이블에 패치가 적용됩니다.
데이터 보관
BigQuery 테이블의 데이터 보관 정책을 구성합니다.
테이블 및 테이블 데이터 관리에 대한 자세한 내용은 테이블 작업을 참조하세요.
테이블 유형
trace를 BigQuery로 내보내도록 싱크를 구성하면 Trace에서 수집 시간으로 파티션을 나눈 테이블을 구성합니다.
이러한 테이블을 생성, 관리, 쿼리, 삭제하는 방법을 포함하여 파티션을 나눈 테이블에 대한 자세한 내용은 파티션을 나눈 테이블 작업을 참조하세요.
샘플 쿼리
다음 쿼리에서 DATASET은 BigQuery 데이터 세트의 이름이고 MY_TABLE은 해당 데이터 세트의 테이블 이름입니다.
결과를 10개 행으로 제한하면서 2019년 11월 20일의 테이블에 있는 모든 열을 표시하려면 쿼리를 실행합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[],[],null,["# Export to BigQuery\n\n| **Beta**\n|\n|\n| This product or feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products and features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nThis document describes some attributes of the BigQuery dataset that is\ncreated when a sink exports traces from Cloud Trace to BigQuery.\n\nSchema\n------\n\nThe schema for your table that stores trace data is determined by the\nTrace V2 API definition of\n[Span](/trace/docs/reference/v2/rest/v2/projects.traces/batchWrite#Span).\n\nTrace keeps track of your table columns and patches the table\nwhen a new span contains fields that can't be stored in the existing table.\nA patch operation is required when an arriving span contains entries not\npreviously seen. For example, if an arriving span contains a new\n[Attribute](/trace/docs/reference/v2/rest/v2/Attributes), the table is patched.\n\nData retention\n--------------\n\nYou configure the data retention policies of your BigQuery tables.\nFor information about managing tables and table data, see\n[Working with tables](/bigquery/docs/tables-intro).\n\nTable type\n----------\n\nIf you configure a sink to export traces to BigQuery,\nTrace configures an\n[ingestion-time partitioned table](/bigquery/docs/creating-partitioned-tables).\nFor detailed information on partitioned tables, including how to create,\nmanaged, query, and delete these tables, see\n[Working with partitioned tables](/bigquery/docs/managing-partitioned-tables).\n\n### Sample queries\n\nIn the following queries, \u003cvar translate=\"no\"\u003eDATASET\u003c/var\u003e is the name of the\nBigQuery dataset, and \u003cvar translate=\"no\"\u003eMY_TABLE\u003c/var\u003e is the name of a table\nin that dataset.\n\n- To display all columns in the table for the date of\n November 20, 2019 while limiting the result to 10 rows, run the query:\n\n ```sql\n SELECT\n *\n FROM\n `DATASET.MY_TABLE`\n WHERE\n DATE(_PARTITIONTIME) = \"2019-11-20\" LIMIT 10\n ```\n- To display all of the partitions available in the table, run the\n query:\n\n ```sql\n SELECT\n _PARTITIONTIME as pt\n FROM\n `DATASET.MY_TABLE`\n GROUP BY 1\n ```\n\n### HipsterShop query\n\nHipsterShop is a demo application available on\n[GitHub](https://github.com/GoogleCloudPlatform/microservices-demo).\n\nThe following is a sample query that illustrates how you can use\nBigQuery queries to gather information that isn't readily\navailable using the Trace interface.\n\nThe inner query finds all spans that match the specified regular expression\nthat were received on December 2, 2019.\nThe outer query selects for display the following:\n\n- name\n- number of spans that match\n- number of distinct trace IDs\n- 50th, 90th, and 99th quantiles\n- HTTP path\n- Error message\n\nand displays the results sorted by the trace counts: \n\n```sql\nSELECT t0.span.displayName.value, count(t0.span.spanId) as spanCount, count(distinct traceId) as traceCount,\nAPPROX_QUANTILES(milliseconds, 100)[OFFSET(50)] as p50,\nAPPROX_QUANTILES(milliseconds, 100)[OFFSET(95)] as p95,\nAPPROX_QUANTILES(milliseconds, 100)[OFFSET(99)] as p99,\nt0.span.attributes.attributeMap._http_path,\nt0.span.attributes.attributeMap._error_message\nFROM (\nSELECT *,\nREGEXP_EXTRACT(span.name, r\"./traces/([a-f0-9]+).\") as traceId,\nTIMESTAMP_DIFF(span.endTime,span.startTime, MILLISECOND) as milliseconds\nFROM `hipstershop-demo.Hipstershop_trace_export.cloud_trace`\nWHERE DATE(_PARTITIONTIME) = \"2019-12-02\") AS t0\nWHERE t0.span.parentSpanId is NULL\nGROUP by t0.span.displayName.value, t0.span.attributes.attributeMap._http_path,t0.span.attributes.attributeMap._error_message\nORDER BY traceCount DESC\nLIMIT 1000\n \n```\n\nFor one particular installation of this application, the query result\nis as shown:\n\nView trace data\n---------------\n\nTo view your trace data by using the\n[BigQuery interface](/bigquery/docs/bigquery-web-ui),\nselect the table with your exported traces."]]