Set the stack trace label in the given labels hash. The current call
stack is formatted so the Stackdriver UI will display it.
Parameters
labels (Hash) — The labels hash in which to set the stack trace
label value.
stack_frames (Array<Thread::Backtrace::Location>) (defaults to: nil) — The current
caller stack as returned from ::Kernel.caller_locations. If
not set, ::Kernel.caller_locations is called internally.
skip_frames (Integer) (defaults to: 1) — Passed to the internal invocation of
::Kernel.caller_locations if one is needed.
truncate_stack (Proc) (defaults to: nil) — A procedure that allows skipping of
the "topmost" stack frames. Stack frames, represented by
instances of Thread::Backtrace::Location, are passed to this
proc beginning with the topmost frame. As long as the proc
returns a falsy value, those frames are dropped. Once the proc
returns true for the first time, that frame and all remaining
frames (possibly subject to filter_stack) are used. If not set,
no frames are skipped.
filter_stack (Proc) (defaults to: nil) — A procedure that allows skipping of
stack frames in the middle of the stack trace. After possibly
skipping frames using truncate_stack, all remaining frames are
passed to this proc as Thread::Backtrace::Location objects.
Those for whom the proc returns a falsy value are skipped. If
this parameter is not set, no filtering is done and all frames
are presented in the stack trace.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Cloud Trace API - Module Google::Cloud::Trace::LabelKey (v0.45.0)\n\nVersion latestkeyboard_arrow_down\n\n- [0.45.0 (latest)](/ruby/docs/reference/google-cloud-trace/latest/Google-Cloud-Trace-LabelKey)\n- [0.44.1](/ruby/docs/reference/google-cloud-trace/0.44.1/Google-Cloud-Trace-LabelKey)\n- [0.43.0](/ruby/docs/reference/google-cloud-trace/0.43.0/Google-Cloud-Trace-LabelKey)\n- [0.42.2](/ruby/docs/reference/google-cloud-trace/0.42.2/Google-Cloud-Trace-LabelKey)\n- [0.41.4](/ruby/docs/reference/google-cloud-trace/0.41.4/Google-Cloud-Trace-LabelKey) \nReference documentation and code samples for the Cloud Trace API module Google::Cloud::Trace::LabelKey.\n\nA collection of well-known label keys for trace spans.\n\nMethods\n-------\n\n### .set_stack_trace\n\n def self.set_stack_trace(labels, stack_frames: nil, skip_frames: 1, truncate_stack: nil, filter_stack: nil)\n\nSet the stack trace label in the given labels hash. The current call\nstack is formatted so the Stackdriver UI will display it. \n**Parameters**\n\n- **labels** (Hash) --- The labels hash in which to set the stack trace label value.\n- **stack_frames** (Array\\\u003cThread::Backtrace::Location\\\u003e) *(defaults to: nil)* --- The current caller stack as returned from `::Kernel.caller_locations`. If not set, `::Kernel.caller_locations` is called internally.\n- **skip_frames** (Integer) *(defaults to: 1)* --- Passed to the internal invocation of `::Kernel.caller_locations` if one is needed.\n- **truncate_stack** (Proc) *(defaults to: nil)* --- A procedure that allows skipping of the \"topmost\" stack frames. Stack frames, represented by instances of `Thread::Backtrace::Location`, are passed to this proc beginning with the topmost frame. As long as the proc returns a falsy value, those frames are dropped. Once the proc returns true for the first time, that frame and all remaining frames (possibly subject to `filter_stack`) are used. If not set, no frames are skipped.\n- **filter_stack** (Proc) *(defaults to: nil)* --- A procedure that allows skipping of stack frames in the middle of the stack trace. After possibly skipping frames using `truncate_stack`, all remaining frames are passed to this proc as `Thread::Backtrace::Location` objects. Those for whom the proc returns a falsy value are skipped. If this parameter is not set, no filtering is done and all frames are presented in the stack trace.\n**Example** \n\n```ruby\nrequire \"google/cloud/trace\"\n\ntrace_record = Google::Cloud::Trace::TraceRecord.new \"my-project\"\nspan = trace_record.create_span \"root_span\"\nGoogle::Cloud::Trace::LabelKey.set_stack_trace span.labels\n```\n\nConstants\n---------\n\n### AGENT\n\n**value:**\"/agent\".freeze\n\n### COMPONENT\n\n**value:**\"/component\".freeze\n\n### ERROR_MESSAGE\n\n**value:**\"/error/message\".freeze\n\n### ERROR_NAME\n\n**value:**\"/error/name\".freeze\n\n### HTTP_CLIENT_CITY\n\n**value:**\"/http/client_city\".freeze\n\n### HTTP_CLIENT_COUNTRY\n\n**value:**\"/http/client_country\".freeze\n\n### HTTP_CLIENT_PROTOCOL\n\n**value:**\"/http/client_protocol\".freeze\n\n### HTTP_CLIENT_REGION\n\n**value:**\"/http/client_region\".freeze\n\n### HTTP_HOST\n\n**value:**\"/http/host\".freeze\n\n### HTTP_METHOD\n\n**value:**\"/http/method\".freeze\n\n### HTTP_REDIRECTED_URL\n\n**value:**\"/http/redirected_url\".freeze\n\n### HTTP_REQUEST_SIZE\n\n**value:**\"/http/request/size\".freeze\n\n### HTTP_RESPONSE_SIZE\n\n**value:**\"/http/response/size\".freeze\n\n### HTTP_STATUS_CODE\n\n**value:**\"/http/status_code\".freeze\n\n### HTTP_URL\n\n**value:**\"/http/url\".freeze\n\n### HTTP_USER_AGENT\n\n**value:**\"/http/user_agent\".freeze\n\n### PID\n\n**value:**\"/pid\".freeze\n\n### STACKTRACE\n\n**value:**\"/stacktrace\".freeze\n\n### TID\n\n**value:**\"/tid\".freeze\n\n### GAE_APPLICATION_ERROR\n\n**value:**\"g.co/gae/application_error\".freeze\n\n### GAE_APP_MODULE\n\n**value:**\"g.co/gae/app/module\".freeze\n\n### GAE_APP_MODULE_VERSION\n\n**value:**\"g.co/gae/app/module_version\".freeze\n\n### GAE_APP_VERSION\n\n**value:**\"g.co/gae/app/version\".freeze\n\n### GAE_DATASTORE_COUNT\n\n**value:**\"g.co/gae/datastore/count\".freeze\n\n### GAE_DATASTORE_CURSOR\n\n**value:**\"g.co/gae/datastore/cursor\".freeze\n\n### GAE_DATASTORE_ENTITY_WRITES\n\n**value:**\"g.co/gae/datastore/entity_writes\".freeze\n\n### GAE_DATASTORE_HAS_ANCESTOR\n\n**value:**\"g.co/gae/datastore/has_ancestor\".freeze\n\n### GAE_DATASTORE_HAS_CURSOR\n\n**value:**\"g.co/gae/datastore/has_cursor\".freeze\n\n### GAE_DATASTORE_HAS_TRANSACTION\n\n**value:**\"g.co/gae/datastore/has_transaction\".freeze\n\n### GAE_DATASTORE_INDEX_WRITES\n\n**value:**\"g.co/gae/datastore/index_writes\".freeze\n\n### GAE_DATASTORE_KIND\n\n**value:**\"g.co/gae/datastore/kind\".freeze\n\n### GAE_DATASTORE_LIMIT\n\n**value:**\"g.co/gae/datastore/limit\".freeze\n\n### GAE_DATASTORE_MORE_RESULTS\n\n**value:**\"g.co/gae/datastore/more_results\".freeze\n\n### GAE_DATASTORE_OFFSET\n\n**value:**\"g.co/gae/datastore/offset\".freeze\n\n### GAE_DATASTORE_REQUESTED_ENTITY_DELETES\n\n**value:**\"g.co/gae/datastore/requested_entity_deletes\".freeze\n\n### GAE_DATASTORE_REQUESTED_ENTITY_PUTS\n\n**value:**\"g.co/gae/datastore/requested_entity_puts\".freeze\n\n### GAE_DATASTORE_SIZE\n\n**value:**\"g.co/gae/datastore/size\".freeze\n\n### GAE_DATASTORE_SKIPPED\n\n**value:**\"g.co/gae/datastore/skipped\".freeze\n\n### GAE_DATASTORE_TRANSACTION_HANDLE\n\n**value:**\"g.co/gae/datastore/transaction_handle\".freeze\n\n### GAE_ERROR_MESSAGE\n\n**value:**\"g.co/gae/error_message\".freeze\n\n### GAE_MEMCACHE_COUNT\n\n**value:**\"g.co/gae/memcache/count\".freeze\n\n### GAE_MEMCACHE_SIZE\n\n**value:**\"g.co/gae/memcache/size\".freeze\n\n### GAE_REQUEST_LOG_ID\n\n**value:**\"g.co/gae/request_log_id\".freeze\n\n### RPC_HOST\n\n**value:**\"/rpc/host\".freeze\n\n### RPC_REQUEST_TYPE\n\n**value:**\"/rpc/request/type\".freeze\n\n### RPC_REQUEST_SIZE\n\n**value:**\"/rpc/request/size\".freeze\n\n### RPC_RESPONSE_SIZE\n\n**value:**\"/rpc/response/size\".freeze\n\n### RPC_STATUS_CODE\n\n**value:**\"/rpc/status_code\".freeze"]]