{"title":"Traces","description":"Send OpenTelemetry traces to Altertable through the OTLP HTTP traces endpoint and analyze spans with SQL workflows.","order":300,"askSuggestions":["How do I find the slowest spans for a service?","How do I see the logs for a trace?","Should I use time-prefixed trace IDs?"],"navigation":true,"body":{"code":"var Component=(()=>{var u=Object.create;var o=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var f=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty;var x=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),w=(n,e)=>{for(var s in e)o(n,s,{get:e[s],enumerable:!0})},c=(n,e,s,a)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let r of y(e))!g.call(n,r)&&r!==s&&o(n,r,{get:()=>e[r],enumerable:!(a=m(e,r))||a.enumerable});return n};var D=(n,e,s)=>(s=n!=null?u(f(n)):{},c(e||!n||!n.__esModule?o(s,\"default\",{value:n,enumerable:!0}):s,n)),b=n=>c(o({},\"__esModule\",{value:!0}),n);var l=x((T,d)=>{d.exports=_jsx_runtime});var I={};w(I,{default:()=>p,frontmatter:()=>S});var t=D(l()),S={title:\"Traces\",description:\"Send OpenTelemetry traces to Altertable through the OTLP HTTP traces endpoint and analyze spans with SQL workflows.\",order:300,askSuggestions:[\"How do I find the slowest spans for a service?\",\"How do I see the logs for a trace?\",\"Should I use time-prefixed trace IDs?\"]};function h(n){let e={a:\"a\",code:\"code\",h1:\"h1\",h2:\"h2\",li:\"li\",p:\"p\",pre:\"pre\",strong:\"strong\",ul:\"ul\",...n.components},{DocsCallout:s,DocsPreviewDocument:a,DocsPreviewSection:r}=e;return s||i(\"DocsCallout\",!0),a||i(\"DocsPreviewDocument\",!0),r||i(\"DocsPreviewSection\",!0),(0,t.jsxs)(a,{anchors:\"traces sdk-and-collector-setup query-traces inspect-a-trace-in-the-app advanced-trace-id-locality\",children:[(0,t.jsxs)(r,{sectionId:\"traces\",anchors:\"\",ancestors:\"\",index:\"0\",children:[(0,t.jsx)(e.h1,{id:\"traces\",children:\"Traces\"}),`\n`,(0,t.jsx)(e.p,{children:\"Send OpenTelemetry traces to Altertable when you want spans, service timing, status, attributes, events, and links to be queryable beside product, operational, and business data.\"}),`\n`,(0,t.jsxs)(e.p,{children:[\"Accepted spans are written to \",(0,t.jsx)(e.code,{children:\"opentelemetry.main.spans\"}),\".\"]}),`\n`]}),(0,t.jsxs)(r,{sectionId:\"sdk-and-collector-setup\",anchors:\"\",ancestors:\"\",index:\"1\",children:[(0,t.jsx)(e.h2,{id:\"sdk-and-collector-setup\",children:\"SDK and collector setup\"}),`\n`,(0,t.jsxs)(e.p,{children:[\"Follow \",(0,t.jsx)(e.a,{href:\"/docs/opentelemetry/setup\",children:\"Configure an exporter\"}),\" for instrumentation, authentication, and OTLP/HTTP setup. See \",(0,t.jsx)(e.a,{href:\"/docs/api-references/opentelemetry#post-v1-traces\",children:(0,t.jsx)(e.code,{children:\"POST /v1/traces\"})}),\" for the request body and responses.\"]}),`\n`]}),(0,t.jsxs)(r,{sectionId:\"query-traces\",anchors:\"\",ancestors:\"\",index:\"2\",children:[(0,t.jsx)(e.h2,{id:\"query-traces\",children:\"Query traces\"}),`\n`,(0,t.jsx)(e.p,{children:\"Spans are normal SQL rows once they are ingested:\"}),`\n`,(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:\"language-sql\",children:`SELECT\n  trace_id,\n  span_id,\n  service_name,\n  name,\n  start_time,\n  duration_ns / 1e6 AS duration_ms,\n  status_code\nFROM opentelemetry.main.spans\nORDER BY start_time DESC\nLIMIT 100;\n`})}),`\n`,(0,t.jsx)(e.p,{children:\"You can also explore traces in the Altertable Explore tab with Lucene-syntax search.\"}),`\n`]}),(0,t.jsxs)(r,{sectionId:\"inspect-a-trace-in-the-app\",anchors:\"\",ancestors:\"\",index:\"3\",children:[(0,t.jsx)(e.h2,{id:\"inspect-a-trace-in-the-app\",children:\"Inspect a trace in the app\"}),`\n`,(0,t.jsx)(e.p,{children:\"Open a trace to inspect its spans in the grouped list or interactive flame graph. Use the graph to locate slow spans and their position in the request, then inspect the span's attributes and related logs. Search and filters help narrow the trace list before opening a large trace.\"}),`\n`]}),(0,t.jsxs)(r,{sectionId:\"advanced-trace-id-locality\",anchors:\"\",ancestors:\"\",index:\"4\",children:[(0,t.jsx)(e.h2,{id:\"advanced-trace-id-locality\",children:\"Advanced: trace ID locality\"}),`\n`,(0,t.jsxs)(s,{title:\"Time-prefixed trace IDs\",children:[(0,t.jsx)(e.p,{children:\"Keep your SDK\\u2019s default ID generator for initial setup. When tuning large trace datasets, consider time-prefixed IDs (AWS X-Ray style):\"}),(0,t.jsxs)(e.ul,{children:[`\n`,(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.strong,{children:\"Trace ID\"}),\" (16 bytes): 4-byte unix seconds prefix + 12 random bytes\"]}),`\n`,(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.strong,{children:\"Span ID\"}),\" (8 bytes): 4-byte unix seconds prefix + 4 random bytes\"]}),`\n`]}),(0,t.jsxs)(e.p,{children:[\"That trades a little entropy for time locality. Spans created in the same second share an ID prefix, so co-ingested rows cluster together and lakehouse \",(0,t.jsx)(e.a,{href:\"/docs/lakehouse/features/sorted-tables\",children:\"sorted tables\"}),\" get tighter locality and better metadata pruning.\"]}),(0,t.jsx)(e.p,{children:\"Register a custom ID generator in your OpenTelemetry SDK when your language supports it.\"})]}),`\n`,(0,t.jsxs)(e.p,{children:[\"Continue with \",(0,t.jsx)(e.a,{href:\"/docs/opentelemetry/query\",children:\"Query telemetry\"}),\" to investigate and correlate signals.\"]})]})]})}function p(n={}){let{wrapper:e}=n.components||{};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(h,{...n})}):h(n)}function i(n,e){throw new Error(\"Expected \"+(e?\"component\":\"object\")+\" `\"+n+\"` to be defined: you likely forgot to import, pass, or provide it.\")}return b(I);})();\n;return Component;"},"_id":"docs/opentelemetry/traces.mdx","_raw":{"sourceFilePath":"docs/opentelemetry/traces.mdx","sourceFileName":"traces.mdx","sourceFileDir":"docs/opentelemetry","contentType":"mdx","flattenedPath":"docs/opentelemetry/traces"},"type":"Docs","path":"/opentelemetry/traces","level":2,"parent":"opentelemetry"}