Skip to content

Commit 01d39ac

Browse files
committed
bundles: add region tracing
Add 'TraceLogger.Region()' invocations to all public methods of the 'BundleProvider' struct, except for 'CreateInitialBundle()' and 'CreateSingletonBundle()' (due to the relative brevity of those functions). Note that static check suppressions are added to two of the 'Region()' calls to allow overriding the 'ctx' despite it not being used later in the function. This helps future-proof against the easy-to-miss bug where a call is added to the function that uses 'ctx', but because 'ctx' is not overridden with the value from 'Region()', the ctx doesn't include the appropriate region information. Signed-off-by: Victoria Dye <[email protected]>
1 parent bef6c4a commit 01d39ac

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

internal/bundles/bundles.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ func (b *bundleProvider) CreateSingletonList(ctx context.Context, bundle Bundle)
118118

119119
// Given a BundleList
120120
func (b *bundleProvider) WriteBundleList(ctx context.Context, list *BundleList, repo *core.Repository) error {
121+
//lint:ignore SA4006 always override the ctx with the result from 'Region()'
122+
ctx, exitRegion := b.logger.Region(ctx, "bundles", "write_bundle_list")
123+
defer exitRegion()
124+
121125
listFile := repo.WebDir + "/bundle-list"
122126
jsonFile := repo.RepoDir + "/bundle-list.json"
123127

@@ -179,6 +183,10 @@ func (b *bundleProvider) WriteBundleList(ctx context.Context, list *BundleList,
179183
}
180184

181185
func (b *bundleProvider) GetBundleList(ctx context.Context, repo *core.Repository) (*BundleList, error) {
186+
//lint:ignore SA4006 always override the ctx with the result from 'Region()'
187+
ctx, exitRegion := b.logger.Region(ctx, "bundles", "get_bundle_list")
188+
defer exitRegion()
189+
182190
jsonFile := repo.RepoDir + "/bundle-list.json"
183191

184192
reader, err := os.Open(jsonFile)
@@ -283,6 +291,9 @@ func (b *bundleProvider) getAllPrereqsForIncrementalBundle(list *BundleList) ([]
283291
}
284292

285293
func (b *bundleProvider) CreateIncrementalBundle(ctx context.Context, repo *core.Repository, list *BundleList) (*Bundle, error) {
294+
ctx, exitRegion := b.logger.Region(ctx, "bundles", "create_incremental_bundle")
295+
defer exitRegion()
296+
286297
bundle := b.createDistinctBundle(repo, list)
287298

288299
lines, err := b.getAllPrereqsForIncrementalBundle(list)
@@ -303,6 +314,9 @@ func (b *bundleProvider) CreateIncrementalBundle(ctx context.Context, repo *core
303314
}
304315

305316
func (b *bundleProvider) CollapseList(ctx context.Context, repo *core.Repository, list *BundleList) error {
317+
ctx, exitRegion := b.logger.Region(ctx, "bundles", "collapse_list")
318+
defer exitRegion()
319+
306320
maxBundles := 5
307321

308322
if len(list.Bundles) <= maxBundles {

0 commit comments

Comments
 (0)