Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
Type: Package
Package: httpuv
Title: HTTP and WebSocket Server Library
Version: 1.6.16.9000
Version: 1.6.16.9002
Authors@R: c(
person("Joe", "Cheng", , "joe@posit.co", role = "aut"),
person("Winston", "Chang", , "winston@posit.co", role = c("aut", "cre")),
person("Winston", "Chang", , "winston@posit.co", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-1576-2126")),
person("Barret", "Schloerke", , "barret@posit.co", role = "aut",
comment = c(ORCID = "0000-0001-9986-114X")),
person("Posit, PBC", role = c("cph", "fnd"),
comment = c(ROR = "03wc8by49")),
person("Hector", "Corrada Bravo", role = "ctb"),
Expand Down Expand Up @@ -58,6 +61,7 @@ Depends:
R (>= 2.15.1)
Imports:
later (>= 0.8.0),
otel,
promises,
R6,
Rcpp (>= 1.0.7),
Expand All @@ -66,11 +70,15 @@ Suggests:
callr,
curl,
jsonlite,
otelsdk,
testthat (>= 3.0.0),
websocket
LinkingTo:
later,
Rcpp
Remotes:
r-lib/otel,
r-lib/otelsdk
Config/Needs/website: tidyverse/tidytemplate
Config/testthat/edition: 3
Config/usethis/last-upkeep: 2025-07-01
Expand All @@ -82,6 +90,8 @@ Collate:
'RcppExports.R'
'httpuv-package.R'
'httpuv.R'
'import-standalone-defer.R'
'otel.R'
'random_port.R'
'server.R'
'staticServer.R'
Expand Down
3 changes: 3 additions & 0 deletions R/httpuv-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@
#' @importFrom R6 R6Class
## usethis namespace: end
NULL


otel_tracer_name <- "io.github.rstudio/httpuv"
13 changes: 12 additions & 1 deletion R/httpuv.R
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ AppWrapper <- R6Class(
if (!private$supportsOnHeaders) {
return(NULL)
}

rookCall(private$app$onHeaders, req)
},
onBodyData = function(req, bytes) {
Expand All @@ -226,6 +225,15 @@ AppWrapper <- R6Class(
# The cpp_callback is an external pointer to a C++ function that writes
# the response.

otel_is_tracing <- otel::is_tracing()

if (otel_is_tracing) {
otel_active_span_for_call <- otel_start_active_call_span(req)
local_otel_active_span_promise_domain(otel_active_span_for_call)

# promises:::local_otel_active_span_promise_domain(otel_active_span_for_call)
}

resp <- if (is.null(private$app$call)) {
list(
status = 404L,
Expand All @@ -244,6 +252,9 @@ AppWrapper <- R6Class(
if (!is.null(req$.bodyData)) {
close(req$.bodyData)
}
if (otel_is_tracing) {
otel_span_for_call$end()
}
req$.bodyData <- NULL
}

Expand Down
35 changes: 35 additions & 0 deletions R/import-standalone-defer.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Standalone file: do not edit by hand
# Source: https://github.com/r-lib/withr/blob/HEAD/R/standalone-defer.R
# Generated by: usethis::use_standalone("r-lib/withr", "defer")
# ----------------------------------------------------------------------
#
# ---
# repo: r-lib/withr
# file: standalone-defer.R
# last-updated: 2024-01-15
# license: https://unlicense.org
# ---
#
# `defer()` is similar to `on.exit()` but with a better default for
# `add` (hardcoded to `TRUE`) and `after` (`FALSE` by default).
# It also supports adding handlers to other frames which is useful
# to implement `local_` functions.
#
#
# ## Changelog
#
# 2024-01-15:
# * Rewritten to be pure base R.
#
# nocov start

defer <- function(expr, envir = parent.frame(), after = FALSE) {
thunk <- as.call(list(function() expr))
do.call(
on.exit,
list(thunk, add = TRUE, after = after),
envir = envir
)
}

# nocov end
Loading
Loading