public sealed class TraceSpan : IMessage<TraceSpan>, IEquatable<TraceSpan>, IDeepCloneable<TraceSpan>, IBufferMessage, IMessage
Reference documentation and code samples for the Google Cloud Trace v1 API class TraceSpan.
A span represents a single timed event within a trace. Spans can be nested
and form a trace tree. Often, a trace contains a root span that describes the
end-to-end latency of an operation and, optionally, one or more subspans for
its suboperations. Spans do not need to be contiguous. There may be gaps
between spans in a trace.
public TraceSpan.Types.SpanKind Kind { get; set; }
Distinguishes between spans generated in a particular context. For example,
two spans with the same name may be distinguished using RPC_CLIENT
and RPC_SERVER to identify queueing latency associated with the span.
Collection of labels associated with the span. Label keys must be less than
128 bytes. Label values must be less than 16 kilobytes (10MB for
/stacktrace values).
Some predefined label keys exist, or you may create your own. When creating
your own, we recommend the following formats:
/category/product/key for agents of well-known products (e.g.
/db/mongodb/read_size).
short_host/path/key for domain-specific keys (e.g.
foo.com/myproduct/bar)
Name of the span. Must be less than 128 bytes. The span name is sanitized
and displayed in the Stackdriver Trace tool in the
Google Cloud Platform Console.
The name may be a method name or some other per-call site name.
For the same executable and the same call point, a best practice is
to use a consistent name, which makes it easier to correlate
cross-trace spans.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eTraceSpan\u003c/code\u003e class represents a single, timed event within a trace, and can be nested to form a trace tree, useful for describing the latency of operations and suboperations.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eTraceSpan\u003c/code\u003e is implemented with several interfaces including \u003ccode\u003eIMessage\u003c/code\u003e, \u003ccode\u003eIEquatable\u003c/code\u003e, \u003ccode\u003eIDeepCloneable\u003c/code\u003e, and \u003ccode\u003eIBufferMessage\u003c/code\u003e, and inherits from the \u003ccode\u003eobject\u003c/code\u003e class.\u003c/p\u003e\n"],["\u003cp\u003eKey properties of \u003ccode\u003eTraceSpan\u003c/code\u003e include \u003ccode\u003eStartTime\u003c/code\u003e and \u003ccode\u003eEndTime\u003c/code\u003e to define the duration, \u003ccode\u003eSpanId\u003c/code\u003e to uniquely identify it within a trace, and \u003ccode\u003eParentSpanId\u003c/code\u003e to define its position within the trace tree.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eLabels\u003c/code\u003e property of \u003ccode\u003eTraceSpan\u003c/code\u003e is a \u003ccode\u003eMapField\u003c/code\u003e that allows associating custom labels with the span, using predefined keys or creating new keys for specific needs, such as \u003ccode\u003e/http/status_code\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe available versions for the \u003ccode\u003eTraceSpan\u003c/code\u003e are listed from the latest version, 3.4.0, down to version 2.2.0, each with unique endpoints.\u003c/p\u003e\n"]]],[],null,["# Google Cloud Trace v1 API - Class TraceSpan (3.4.0)\n\nVersion latestkeyboard_arrow_down\n\n- [3.4.0 (latest)](/dotnet/docs/reference/Google.Cloud.Trace.V1/latest/Google.Cloud.Trace.V1.TraceSpan)\n- [3.3.0](/dotnet/docs/reference/Google.Cloud.Trace.V1/3.3.0/Google.Cloud.Trace.V1.TraceSpan)\n- [3.2.0](/dotnet/docs/reference/Google.Cloud.Trace.V1/3.2.0/Google.Cloud.Trace.V1.TraceSpan)\n- [3.1.0](/dotnet/docs/reference/Google.Cloud.Trace.V1/3.1.0/Google.Cloud.Trace.V1.TraceSpan)\n- [3.0.0](/dotnet/docs/reference/Google.Cloud.Trace.V1/3.0.0/Google.Cloud.Trace.V1.TraceSpan)\n- [2.3.0](/dotnet/docs/reference/Google.Cloud.Trace.V1/2.3.0/Google.Cloud.Trace.V1.TraceSpan)\n- [2.2.0](/dotnet/docs/reference/Google.Cloud.Trace.V1/2.2.0/Google.Cloud.Trace.V1.TraceSpan) \n\n public sealed class TraceSpan : IMessage\u003cTraceSpan\u003e, IEquatable\u003cTraceSpan\u003e, IDeepCloneable\u003cTraceSpan\u003e, IBufferMessage, IMessage\n\nReference documentation and code samples for the Google Cloud Trace v1 API class TraceSpan.\n\nA span represents a single timed event within a trace. Spans can be nested\nand form a trace tree. Often, a trace contains a root span that describes the\nend-to-end latency of an operation and, optionally, one or more subspans for\nits suboperations. Spans do not need to be contiguous. There may be gaps\nbetween spans in a trace. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e TraceSpan \n\nImplements\n----------\n\n[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[TraceSpan](/dotnet/docs/reference/Google.Cloud.Trace.V1/latest/Google.Cloud.Trace.V1.TraceSpan), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[TraceSpan](/dotnet/docs/reference/Google.Cloud.Trace.V1/latest/Google.Cloud.Trace.V1.TraceSpan), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[TraceSpan](/dotnet/docs/reference/Google.Cloud.Trace.V1/latest/Google.Cloud.Trace.V1.TraceSpan), [IBufferMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage.html), [IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage.html) \n\nInherited Members\n-----------------\n\n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Google.Cloud.Trace.V1](/dotnet/docs/reference/Google.Cloud.Trace.V1/latest/Google.Cloud.Trace.V1)\n\nAssembly\n--------\n\nGoogle.Cloud.Trace.V1.dll\n\nConstructors\n------------\n\n### TraceSpan()\n\n public TraceSpan()\n\n### TraceSpan(TraceSpan)\n\n public TraceSpan(TraceSpan other)\n\nProperties\n----------\n\n### EndTime\n\n public Timestamp EndTime { get; set; }\n\nEnd time of the span in nanoseconds from the UNIX epoch.\n\n### Kind\n\n public TraceSpan.Types.SpanKind Kind { get; set; }\n\nDistinguishes between spans generated in a particular context. For example,\ntwo spans with the same name may be distinguished using `RPC_CLIENT`\nand `RPC_SERVER` to identify queueing latency associated with the span.\n\n### Labels\n\n public MapField\u003cstring, string\u003e Labels { get; }\n\nCollection of labels associated with the span. Label keys must be less than\n128 bytes. Label values must be less than 16 kilobytes (10MB for\n`/stacktrace` values).\n\nSome predefined label keys exist, or you may create your own. When creating\nyour own, we recommend the following formats:\n\n- `/category/product/key` for agents of well-known products (e.g. `/db/mongodb/read_size`).\n- `short_host/path/key` for domain-specific keys (e.g. `foo.com/myproduct/bar`)\n\nPredefined labels include:\n\n- `/agent`\n- `/component`\n- `/error/message`\n- `/error/name`\n- `/http/client_city`\n- `/http/client_country`\n- `/http/client_protocol`\n- `/http/client_region`\n- `/http/host`\n- `/http/method`\n- `/http/path`\n- `/http/redirected_url`\n- `/http/request/size`\n- `/http/response/size`\n- `/http/route`\n- `/http/status_code`\n- `/http/url`\n- `/http/user_agent`\n- `/pid`\n- `/stacktrace`\n- `/tid`\n\n### Name\n\n public string Name { get; set; }\n\nName of the span. Must be less than 128 bytes. The span name is sanitized\nand displayed in the Stackdriver Trace tool in the\nGoogle Cloud Platform Console.\nThe name may be a method name or some other per-call site name.\nFor the same executable and the same call point, a best practice is\nto use a consistent name, which makes it easier to correlate\ncross-trace spans.\n\n### ParentSpanId\n\n public ulong ParentSpanId { get; set; }\n\nOptional. ID of the parent span, if any.\n\n### SpanId\n\n public ulong SpanId { get; set; }\n\nIdentifier for the span. Must be a 64-bit integer other than 0 and\nunique within a trace. For example, `2205310701640571284`.\n\n### StartTime\n\n public Timestamp StartTime { get; set; }\n\nStart time of the span in nanoseconds from the UNIX epoch."]]