Skip to content

feat: add more detailed init timings in build timeline - #20503

Merged
Emyrk merged 13 commits into
mainfrom
stevenmasley/build_timeline_init
Oct 28, 2025
Merged

Emyrk merged 13 commits into
mainfrom
stevenmasley/build_timeline_init

Conversation

@Emyrk

@Emyrk Emyrk commented Oct 27, 2025 •

Copy link
Copy Markdown
Member

What this does

This uses the terraform init -json logs to add more visibility into the init phase of plan. The init logs omit ms precision, so we have to use time.Now() 😢

Open TF PR: hashicorp/terraform#37818

Screencast.From.2025-10-27.12-38-33.webm

Follow up will be to add more details to modules and providers to single out each module/provider loaded.

@Emyrk Emyrk changed the title feat: more detailed init timings in build timeline feat: add more detailed init timings in build timeline Oct 27, 2025
@Emyrk
Emyrk marked this pull request as ready for review October 28, 2025 15:08
Comment thread provisioner/terraform/inittimings.go Outdated
// resourceName maps init message codes to human-readable resource names.
// This is purely for better readability in the timing spans.
resourceName = map[initMessageCode]string{
initInitializingBackendMessage: "Backend",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you stick to the existing naming convention which is all lowercase?
Also I think we need to be more explicit about the stages. What does "Backend" mean?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made it lowercase 👍

I agree backend is an unfortunate name, but it is the proper TF term.

https://developer.hashicorp.com/terraform/language/backend

For Coder, backend means the tfstate file. That is it.
This timing would likely be longer if you were using an aws s3 backend for instance.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

We should maybe try add a help section explaining what it is.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to spend time on the build timeline in the UI more. I would like it to also go 1 more hierarchical depth.

Will defer to future work on that though

Comment thread provisioner/terraform/inittimings.go Resolved
// The combination of resource and provider names MUST be unique across entries.
func (e *timingSpan) hashByState(state proto.TimingState) uint64 {
id := fmt.Sprintf("%s:%s:%s:%s:%s", e.kind.Category(), state.String(), e.action, e.resource, e.provider)
if e.messageCode != "" {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: we probably need to make this a slice and join with the delimiter.

Comment thread provisioner/terraform/executor.go Resolved
Comment thread provisioner/terraform/executor.go Resolved
@Emyrk
Emyrk merged commit 924afb7 into main Oct 28, 2025
43 of 46 checks passed
@Emyrk
Emyrk deleted the stevenmasley/build_timeline_init branch October 28, 2025 20:47
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 28, 2025
Comment on lines +31 to +34
var (
version170 = version.Must(version.NewVersion("1.7.0"))
version190 = version.Must(version.NewVersion("1.9.0"))
)

@matifali matifali Oct 29, 2025 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Terraform versions below 1.12 are already EOL. We also bundle Terraform in the official image. We may not need to worry about supporting older versions.
https://endoflife.date/terraform

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should update our minimum supported then.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will make a PR

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants