opentofu/internal/command
Martin Atkins 7bee77bdd3 command: Start of propagating OpenTelemetry context
Several times over the years we've considered adding tracing
instrumentation to Terraform, since even when running in isolation as a
CLI program it has a "distributed system-like" structure, with lots of
concurrent internal work and also some work delegated to provider plugins
that are essentially temporarily-running microservices.

However, it's always felt a bit overwhelming to do it because much of
Terraform predates the Go context.Context idiom and so it's tough to get
a clean chain of context.Context values all the way down the stack without
disturbing a lot of existing APIs.

This commit aims to just get that process started by establishing how a
context can propagate from "package main" into the command package,
focusing initially on "terraform init" and some other commands that share
some underlying functions with that command.

OpenTelemetry has emerged as a de-facto industry standard and so this uses
its API directly, without any attempt to hide it behind an abstraction.
The OpenTelemetry API is itself already an adapter layer, so we should be
able to swap in any backend that uses comparable concepts. For now we just
discard the tracing reports by default, and allow users to opt in to
delivering traces over OTLP by setting an environment variable when
running Terraform (the environment variable was established in an earlier
commit, so this commit builds on that.)

When tracing collection is enabled, every Terraform CLI run will generate
at least one overall span representing the command that was run. Some
commands might also create child spans, but most currently do not.
2023-07-14 10:24:10 -07:00
..
arguments Remove old implementation of terraform test command 2023-06-12 11:17:42 +02:00
cliconfig [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
clistate [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
e2etest [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
format [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
jsonchecks Add input validation into the 'checks' outputs and tracking (#33481) 2023-07-10 11:33:45 +01:00
jsonconfig Introduce separate testing scope for reference validation (#33339) 2023-06-28 09:47:24 +02:00
jsonformat s/Schemas/ProviderSchema/ 2023-07-06 10:37:35 -04:00
jsonfunction [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
jsonplan s/Schemas/ProviderSchema/ 2023-07-06 10:37:35 -04:00
jsonprovider s/Schemas/ProviderSchema/ 2023-07-06 10:37:35 -04:00
jsonstate s/Schemas/ProviderSchema/ 2023-07-06 10:37:35 -04:00
testdata testing framework: introduce interrupts for stopping tests (#33477) 2023-07-10 14:53:13 +01:00
testing testing framework: introduce interrupts for stopping tests (#33477) 2023-07-10 14:53:13 +01:00
views testing framework: introduce interrupts for stopping tests (#33477) 2023-07-10 14:53:13 +01:00
webbrowser [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
workdir [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
apply_destroy_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
apply_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
apply.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
autocomplete_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
autocomplete.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
cli_ui_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
cli_ui.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
command_test.go plannable import: write generated config to out flag (#33186) 2023-05-12 23:05:00 +01:00
command.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
console_interactive_solaris.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
console_interactive.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
console_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
console.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
flag_kv_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
flag_kv.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
fmt_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
fmt.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
get_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
get.go command: Start of propagating OpenTelemetry context 2023-07-14 10:24:10 -07:00
graph_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
graph.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
helper.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
hook_module_install.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
import_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
import.go Plannable import: Generate config for imported resources during the plan. (#33153) 2023-05-11 08:38:37 +02:00
init_test.go [testing framework] allow tests to define and override providers (#33466) 2023-07-10 14:33:15 +01:00
init.go command: Start of propagating OpenTelemetry context 2023-07-14 10:24:10 -07:00
login_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
login.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
logout_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
logout.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
meta_backend_migrate_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
meta_backend_migrate.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
meta_backend_test.go command: Start of propagating OpenTelemetry context 2023-07-14 10:24:10 -07:00
meta_backend.go command: Start of propagating OpenTelemetry context 2023-07-14 10:24:10 -07:00
meta_config.go command: Start of propagating OpenTelemetry context 2023-07-14 10:24:10 -07:00
meta_dependencies.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
meta_new.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
meta_providers.go Add basic global schema cache 2023-07-06 10:37:35 -04:00
meta_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
meta_vars.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
meta.go command: Start of propagating OpenTelemetry context 2023-07-14 10:24:10 -07:00
metadata_command.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
metadata_functions_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
metadata_functions.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
output_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
output.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
plan_test.go command: test plan -refresh= arg ordering (#33483) 2023-07-06 19:28:09 +01:00
plan.go command: help text for generate-config-out (#33279) 2023-05-31 20:42:41 +01:00
plugins_lock_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
plugins_lock.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
plugins_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
plugins.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
providers_lock_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
providers_lock.go command: Start of propagating OpenTelemetry context 2023-07-14 10:24:10 -07:00
providers_mirror_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
providers_mirror.go command: Start of propagating OpenTelemetry context 2023-07-14 10:24:10 -07:00
providers_schema_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
providers_schema.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
providers_test.go [testing framework] allow tests to define and override providers (#33466) 2023-07-10 14:33:15 +01:00
providers.go [testing framework] allow tests to define and override providers (#33466) 2023-07-10 14:33:15 +01:00
push.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
refresh_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
refresh.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
show_test.go terraform show -json: Add Errored field to output for plan (#33372) 2023-06-19 11:16:41 +01:00
show.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
state_command.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
state_list_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
state_list.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
state_meta.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
state_mv_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
state_mv.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
state_pull_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
state_pull.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
state_push_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
state_push.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
state_replace_provider_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
state_replace_provider.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
state_rm_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
state_rm.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
state_show_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
state_show.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
state_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
taint_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
taint.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
telemetry.go command: Start of propagating OpenTelemetry context 2023-07-14 10:24:10 -07:00
test_test.go Make flaky 'TestTest_DoubleInterrupt' test more robust (#33503) 2023-07-11 10:35:26 +01:00
test.go testing framework: introduce interrupts for stopping tests (#33477) 2023-07-10 14:53:13 +01:00
ui_input_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
ui_input.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
unlock_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
unlock.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
untaint_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
untaint.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
validate_test.go configs: remove import block duplicate id check (#33434) 2023-06-27 19:25:36 +01:00
validate.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
version_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
version.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
workspace_command_test.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
workspace_command.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
workspace_delete.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
workspace_list.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
workspace_new.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
workspace_select.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
workspace_show.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00