Repository navigation
Expand file tree
/
Copy pathdocs.R
More file actions
181 lines (170 loc) · 6.19 KB
/
Copy pathdocs.R
File metadata and controls
181 lines (170 loc) · 6.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#' @name Getting Started
#' @title Getting Started
#' @rdname gettingstarted
#' @aliases gettingstarted
#' @description
#' This page is about instrumenting you R package or project for
#' OpenTelemetry. If you want to start collecting OpenTelemetry data
#' for instrumented packages, see \link[otelsdk:Collecting Telemetry Data]{
#' Collecting Telemetry Data} in the otelsdk package.
#'
#' @details
#' ```{r child = "tools/dox/gettingstarted.Rmd"}
#' ```
#'
#' @examples
#' # See above
NULL
doc_evs_exporter <- function() {
c(
default_traces_exporter_envvar,
default_traces_exporter_envvar_r,
default_logs_exporter_envvar,
default_logs_exporter_envvar_r,
default_metrics_exporter_envvar,
default_metrics_exporter_envvar_r
)
}
doc_evs_suppress <- function() {
c(
otel_emit_scopes_envvar,
otel_suppress_scopes_envvar
)
}
doc_evs <- function() {
paste(
collapse = " ",
c(
doc_evs_exporter(),
doc_evs_suppress()
)
)
}
#' Environment variables to configure otel
#' @name Environment Variables
#' @rdname environmentvariables
#' @eval paste("@aliases", "OTEL_ENV", doc_evs())
#'
#' @description
#' This manual page contains the environment variables you can use to
#' configure the otel package.
#'
#' See also the \link[otelsdk:Environment Variables]{Environment Variables}
#' in the otelsdk package, which is charge of the data collection
#' configuration.
#'
#' You need set these environment variables when configuring the
#' collection of telemetry data, unless noted otherwise.
#'
#' # Production or Development Environment
#'
#' * `OTEL_ENV`
#'
#' By default otel runs in production mode. In production mode otel
#' functions never error. Errors in the telemetry code will not stop
#' the monitored application.
#'
#' This behavior is not ideal for development, where one would prefer
#' to catch errors early. Set
#' ```
#' OTEL_ENV=dev
#' ```
#' to run otel in development mode, where otel functions fail on error,
#' make it easier to fix errors.
#'
#' ```{r child = system.file(package = "otel", "dox/ev-exporters.Rmd")}
#' ```
#'
#' ```{r child = system.file(package = "otel", "dox/ev-suppress.Rmd")}
#' ```
#'
#' ```{r child = system.file(package = "otel", "dox/ev-zci.Rmd")}
#' ```
#'
#' ```{r child = system.file(package = "otel", "dox/ev-others.Rmd")}
#' ```
#'
#' @return Not applicable.
#' @seealso \link[otelsdk:Environment Variables]{Environment Variables} in
#' otelsdk
#' @examples
#' # To start an R session using the OTLP exporter:
#' # OTEL_TRACES_EXPORTER=http R -q -f script.R
NULL
#' Zero Code Instrumentation
#'
#' otel supports zero-code instrumentation (ZCI) via the
#' `OTEL_INSTRUMENT_R_PKGS` environment variable. Set this to a comma
#' separated list of package names, the packages that you want to
#' instrument. Then otel will hook up [base::trace()] to produce
#' OpenTelemetry output from every function of these packages.
#'
#' By default all functions of the listed packages are instrumented. To
#' instrument a subset of all functions set the
#' `OTEL_INSTRUMENT_R_PKGS_<PKG>_INCLUDE` environment variable to a list of
#' glob expressions. `<PKG>` is the package name in all capital letters.
#' Only functions that match to at least one glob expression will be
#' instrumented.
#'
#' To exclude functions from instrumentation, set the
#' `OTEL_INSTRUMENT_R_PKGS_<PKG>_EXCLUDE` environment variable to a list of
#' glob expressions. `<PKG>` is the package name in all capital letters.
#' Functions that match to at least one glob expression will not be
#' instrumented. Inclusion globs are applied before exclusion globs.
#'
#' ## Caveats
#'
#' If the user calls [base::trace()] on an instrumented function, that
#' deletes the instrumentation, since the second [base::trace()] call
#' overwrites the first.
#'
#' @name Zero Code Instrumentation
#' @rdname zci
#' @family OpenTelemetry trace API
#' @seealso '[Environment Variables]' needed to enable OpenTelemetry recording.
#' @return Not applicable.
#' @aliases OTEL_R_INSTRUMENT_PKGS
#' @examples
#' # To run an R script with ZCI:
#' # OTEL_TRACES_EXPORTER=http OTEL_INSTRUMENT_R_PKGS=dplyr,tidyr R -q -f script.R
NULL
doc_arg <- function() {
list(
"span-name" = "Name of the span. If not specified it will be `\"<NA>\"`.",
"span-name-default" = "Name of the span. If not specified, and
tracing is enabled, then otel uses the name of the calling function
as the span name, and also sets the `code.function.name` attribute
to the function name, unless it is already set. otel prefixes this
attribute with the package name, if the function is in a package.
If otel cannot find the name of the calling function, e.g. at the
top level, or for anonymous functions, the span name will be
`\"<NA>\"`.",
links = "A named list of links to other spans. Every link must be an
OpenTelemetry span ([otel_span]) object, or a list with a span
object as the first element and named span attributes as the rest.",
attributes = glue::glue(
trim = FALSE,
"Span attributes. OpenTelemetry supports the following
R types as attributes: `{paste0(otel_attr_types, collapse = \", \")}.
You may use [as_attributes()] to convert other R types to
OpenTelemetry attributes."
),
# need to use \itemize, markdown does not put this list under the other
# one for otel_tracer method arguments
"span-options" = glue::glue(
trim = FALSE,
"A named list of span options. May include: \\itemize{{
\\item `start_system_time`: Start time in system time.
\\item `start_steady_time`: Start time using a steady clock.
\\item `parent`: A parent span or span context. If it is `NA`, then the
span has no parent and it will be a root span. If it is `NULL`, then
the current context is used, i.e. the active span, if any.
\\item `kind`: Span kind, one of [span_kinds]:
{paste(dQuote(span_kinds, q = FALSE), collapse = ', ')}.}}"
),
"unit" = "Optional measurement unit. If specified, it should use
units from [Unified Code for Units of Measure](https://ucum.org/),
according to the [OpenTelemetry semantic conventions](
https://opentelemetry.io/docs/specs/semconv/general/metrics/#instrument-units)."
)
}