Skip to contents

Adds a traceparent header to an existing set of HTTP headers using the current active trace and span context.

Usage

inject_headers(headers = list())

Arguments

headers

A named list of HTTP headers. Default list().

Value

The headers list with traceparent added, or unchanged if no active trace/span context exists.

Examples

# Inside an active trace and span
with_trace("http-call", {
  with_span("request", type = "tool", {
    headers <- inject_headers(list("Content-Type" = "application/json"))
    headers$traceparent
  })
})
#> [1] "00-b88c9ae35eb1e9ed1991423dd1445207-7d57df21eebfba76-01"