terraform/internal
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
..
addrs Add input validation into the 'checks' outputs and tracking (#33481) 2023-07-10 11:33:45 +01:00
backend [testing framework] implement expect_failures functionality (#33443) 2023-07-10 11:30:44 +01:00
builtin builtin/providers/terraform: terraform_data "id" is guaranteed non-null 2023-05-24 13:44:08 -07:00
checks Add input validation into the 'checks' outputs and tracking (#33481) 2023-07-10 11:33:45 +01:00
cloud s/Schemas/ProviderSchema/ 2023-07-06 10:37:35 -04:00
command command: Start of propagating OpenTelemetry context 2023-07-14 10:24:10 -07:00
communicator [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
configs [testing framework] allow tests to define and override providers (#33466) 2023-07-10 14:33:15 +01:00
copy [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
dag [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
depsfile [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
didyoumean [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
e2e [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
experiments [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
genconfig fix static check errors 2023-05-30 18:00:41 -07:00
getmodules [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
getproviders upgrade golang.org/x/crypto/openpgp to github.com/ProtoMail/go-crypto (#33406) 2023-06-22 08:32:12 +02:00
grpcwrap [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
helper/slowmessage [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
httpclient [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
initwd [Testing Framework] Add module block to test run blocks (#33456) 2023-07-10 11:42:05 +01:00
instances [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
ipaddr [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
lang s/Schemas/ProviderSchema/ 2023-07-06 10:37:35 -04:00
legacy [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
logging [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
modsdir [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
moduledeps [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
moduletest testing framework: introduce interrupts for stopping tests (#33477) 2023-07-10 14:53:13 +01:00
plans main: Optionally configure an OpenTelemetry OTLP exporter 2023-07-14 10:24:10 -07:00
plugin disable cache for now 2023-07-06 10:45:57 -04:00
plugin6 disable cache for now 2023-07-06 10:45:57 -04:00
provider-simple [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
provider-simple-v6 [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
provider-terraform/main [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
providercache [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
providers additional schema handling comment 2023-07-06 15:53:08 -04:00
provisioner-local-exec/main [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
provisioners [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
refactoring [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
registry [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
repl [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
replacefile [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
states Add input validation into the 'checks' outputs and tracking (#33481) 2023-07-10 11:33:45 +01:00
terminal [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
terraform Add input validation into the 'checks' outputs and tracking (#33481) 2023-07-10 11:33:45 +01:00
tfdiags [testing framework] implement expect_failures functionality (#33443) 2023-07-10 11:30:44 +01:00
tfplugin5 main: Optionally configure an OpenTelemetry OTLP exporter 2023-07-14 10:24:10 -07:00
tfplugin6 main: Optionally configure an OpenTelemetry OTLP exporter 2023-07-14 10:24:10 -07:00