Skip to content

builder: add use_relative_replace_paths#15098

Open
braydonk wants to merge 6 commits intoopen-telemetry:mainfrom
braydonk:ocb_relative_replace_paths
Open

builder: add use_relative_replace_paths#15098
braydonk wants to merge 6 commits intoopen-telemetry:mainfrom
braydonk:ocb_relative_replace_paths

Conversation

@braydonk
Copy link
Copy Markdown
Contributor

@braydonk braydonk commented Apr 10, 2026

Description

When users want to track their generated OCB directory in source control, absolute paths don't work because the go replace statements need to resolve on any machine. This PR adds the
dist::use_relative_replace_paths feature so that path values in modules are not forcibly resolved to absolute paths and instead calculated as relative paths to the output directory.

Link to tracking issue

Fixes #15097

Testing

I installed the tool locally and used it in our setup. When I had this module:

exporters:
- gomod: github.com/GoogleCloudPlatform/opentelemetry-operations-collector/components/google-built-opentelemetry-collector/exporter/googleservicecontrolexporter v0.148.0
  path: ../components/google-built-opentelemetry-collector/exporter/googleservicecontrolexporter

I got the following replacement:

replace github.com/GoogleCloudPlatform/opentelemetry-operations-collector/components/google-built-opentelemetry-collector/exporter/googleservicecontrolexporter v0.148.0 => ../../components/google-built-opentelemetry-collector/exporter/googleservicecontrolexporter

I was able to build successfully.

Documentation

Added to the config docs in README.

AI Usage Disclosure

The code changes in this PR were created with AI assistance via Gemini/Antigravity.

When users want to track their generated OCB directory in source
control, absolute paths don't work because the `go replace` statements
need to resolve on any machine. This PR adds the
`dist::use_relative_replace_paths` feature so that `path` values in
modules are not forcibly resolved to absolute paths and instead
calculated as relative paths to the output directory.
@braydonk braydonk requested review from a team, ArthurSens and dmathieu as code owners April 10, 2026 23:45
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 10, 2026

Codecov Report

❌ Patch coverage is 78.26087% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.24%. Comparing base (67a8d34) to head (a3284cd).

Files with missing lines Patch % Lines
cmd/builder/internal/builder/config.go 78.26% 3 Missing and 2 partials ⚠️

❌ Your patch check has failed because the patch coverage (78.26%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15098      +/-   ##
==========================================
- Coverage   91.26%   91.24%   -0.03%     
==========================================
  Files         699      699              
  Lines       44766    44776      +10     
==========================================
  Hits        40855    40855              
- Misses       2769     2775       +6     
- Partials     1142     1146       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dmathieu
Copy link
Copy Markdown
Member

I wonder if anyone would actually explicitly want to keep paths absolute, and not have them made relative.
Since the package is unstable, it may make sense to simplify things and avoid the flag?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ocb: Allow relative paths for modules in resulting generated go.mod

2 participants