OpenTelemetry logs and traces

Overview

shinyOAuth exports diagnostic logs and traces through OpenTelemetry (OTel), using the otel R package. Logs record events such as a failed token exchange. Traces group related operations into spans, which record their duration and outcome. This allows authentication diagnostics to be collected alongside other application telemetry.

An exporter sends the records to a console, file, or monitoring service. The otel package is a dependency of shinyOAuth; install otelsdk for its exporters. For R callbacks that receive events directly, see Audit logging and hooks.

Exporter configuration

Install otelsdk, then set these variables in a fresh R session before loading shinyOAuth or starting the app:

# install.packages("otelsdk")
Sys.setenv(
  OTEL_TRACES_EXPORTER = "console",
  OTEL_LOGS_EXPORTER = "console",
  OTEL_LOG_LEVEL = "debug"
)
library(shinyOAuth)

Authenticate with the example Shiny app. The console exporter prints the emitted records. To send them to a monitoring service instead, follow the otelsdk exporter setup and your service’s endpoint and credential instructions.

If nothing appears, check that an exporter is configured before the package first creates a logger or tracer, and that the logging and tracing options below are enabled. Restart R after changing exporter configuration.

Traces and event correlation

Filter by instrumentation scope io.github.lukakoning.shinyOAuth in your monitoring system. Start with shinyOAuth.login.request and shinyOAuth.callback, then inspect token exchange or userinfo spans to see where time was spent. The package’s shinyoauth.trace_id attribute also connects related logs and spans; it is separate from OTel’s own trace/span IDs.

The logs come from the same events as the audit hook. See the audit event catalog for their meaning. The span catalog below lists names and attributes for detailed lookup.

Logging and tracing options

Both options default to TRUE; an exporter is still needed to collect the data. Disable either signal without changing your app’s other telemetry:

options(
  shinyOAuth.otel_logging_enabled = FALSE,
  shinyOAuth.otel_tracing_enabled = FALSE
)

Asynchronous workers

For async work managed by shinyOAuth, exporter environment settings (OTEL_* and OTEL_R_*), logging and tracing options, and trace context are propagated to workers. SDK setup performed through R code is not replayed automatically; run that setup in each worker or recreate workers after changing it.

Error attributes and redaction

Authorization metadata privacy

Scope names, claim target names, and ACR values are omitted by default. The corresponding counts remain available, including oauth.claims.targets_count and oauth.scopes.granted_count. To include names in a controlled environment:

options(shinyOAuth.otel_include_authorization_details = TRUE)

This option enables oauth.scopes.requested, oauth.scopes.granted, oauth.claims.targets, and oauth.required_acr_values in the catalog below. It is propagated to asynchronous workers. These names can reveal tenants, privileges, sensitive data categories, or authentication strength, and can create high-cardinality telemetry. Restrict exporter and dashboard access, set a short retention period appropriate to the diagnostic need, and avoid indexing these fields unless needed. Keep shinyOAuth.expose_error_body disabled in production; the authorization-details option does not enable it.

Span catalog

Use this as a reference for a span you see in your tracing system. Attributes are included when relevant and available; their presence can differ between main-process and worker spans.

Span: shinyOAuth.module.init

Span: shinyOAuth.login.request

Span: shinyOAuth.login.par

Span: shinyOAuth.login.par.http

Span: shinyOAuth.callback

Span: shinyOAuth.form_post

Span: shinyOAuth.form_post.bridge

Span: shinyOAuth.callback.validate

Span: shinyOAuth.callback.worker

Span: shinyOAuth.token.exchange

Span: shinyOAuth.token.exchange.http

Span: shinyOAuth.token.verify

Span: shinyOAuth.userinfo

Span: shinyOAuth.userinfo.http

Span: shinyOAuth.refresh

Span: shinyOAuth.refresh.worker

Span: shinyOAuth.logout

Span: shinyOAuth.session.end.revoke

Span: shinyOAuth.token.revoke

Span: shinyOAuth.token.revoke.http

Span: shinyOAuth.token.revoke.worker

Span: shinyOAuth.token.introspect

Span: shinyOAuth.token.introspect.http

Span: shinyOAuth.token.introspect.worker