Skip to content

fix(ops): group OpenTelemetry module upgrades and sync semconv imports in Go files - #2015

Merged
bwplotka merged 8 commits into
mainfrom
gmpctl-otel-fix
Aug 6, 2026
Merged

fix(ops): group OpenTelemetry module upgrades and sync semconv imports in Go files#2015
bwplotka merged 8 commits into
mainfrom
gmpctl-otel-fix

Conversation

@bwplotka

@bwplotka bwplotka commented Jul 25, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR fixes vulnerability updates for OpenTelemetry modules in gmpctl:

  1. Simultaneous Module Upgrades Across Dependency Tree: Uses go list -m all to discover all direct and indirect go.opentelemetry.io/otel* modules (such as otel/trace, otel/sdk, otel/metric, etc.) and upgrades them simultaneously to avoid version drift and partial module upgrades.
  2. Dynamic semconv Import Synchronization: Dynamically queries the exact semconv package version imported by go.opentelemetry.io/otel/sdk/resource and updates hardcoded semconv imports in .go files. This prevents conflicting Schema URL errors during tracer provider initialization (e.g. failed to install a new tracer provider: error detecting resource: conflicting Schema URL: https://opentelemetry.io/schemas/1.40.0 and https://opentelemetry.io/schemas/1.41.0).

Signed-off-by: bwplotka bwplotka@google.com

Comment thread ops/gmpctl/lib.sh Outdated

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request updates the vulnerability fixing logic in ops/gmpctl/lib.sh to use go get for updating modules instead of direct sed replacements in go.mod. It also introduces special handling for OpenTelemetry modules to upgrade them simultaneously and align semconv imports to prevent conflicting Schema URL errors. The review feedback highlights potential script crashes due to the use of grep in pipelines under set -o pipefail and set -o errexit when no matches are found, and suggests using awk to safely handle these cases.

Comment thread ops/gmpctl/lib.sh Outdated
Comment thread ops/gmpctl/lib.sh Outdated
Comment thread ops/gmpctl/lib.sh Outdated
echo "🔄 Updating OpenTelemetry modules simultaneously:${otel_args}..."
go get ${otel_args}

# OpenTelemetry SDK resource detectors (e.g. WithProcessRuntimeDescription, WithTelemetrySDK)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I am assuming we can equally in our fork remove the explicit schema at this point? 🤔

Image

https://github.com/GoogleCloudPlatform/prometheus/blob/a24099b1f7e42d86bae4e911d245fdcf932f7cff/tracing/tracing.go#L146

@bwplotka bwplotka Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@bwplotka
bwplotka force-pushed the gmpctl-otel-fix branch 3 times, most recently from 6763f5e to 6bca81e Compare July 25, 2026 17:01
…s in Go files

- Uses `go list -m all` to include direct and indirect `go.opentelemetry.io/otel*` modules (such as `otel/trace`, `otel/sdk`, `otel/metric`) in simultaneous upgrades.
- Dynamically queries the exact `semconv` package version imported by `go.opentelemetry.io/otel/sdk/resource` and updates hardcoded `semconv` imports across Go files to match.

Signed-off-by: bwplotka <bwplotka@google.com>
Comment thread ops/gmpctl/lib.sh
Comment thread ops/gmpctl/lib.sh Outdated
Comment thread ops/gmpctl/lib.sh Outdated
Signed-off-by: bwplotka <bwplotka@google.com>
…to prevent pipefail exit

Signed-off-by: bwplotka <bwplotka@google.com>
Signed-off-by: bwplotka <bwplotka@google.com>
Signed-off-by: bwplotka <bwplotka@google.com>
Comment thread ops/gmpctl/lib.sh Outdated
Comment thread ops/gmpctl/lib.sh Outdated
Comment thread ops/gmpctl/lib.sh
Signed-off-by: bwplotka <bwplotka@google.com>
…ulnfix

Signed-off-by: bwplotka <bwplotka@google.com>
…ution fails

Signed-off-by: bwplotka <bwplotka@google.com>
Comment thread ops/gmpctl/lib.sh
done
if [[ -n "${otel_args// /}" ]]; then
echo "🔄 Updating OpenTelemetry modules simultaneously:${otel_args}..."
go get ${otel_args}

@bwplotka bwplotka Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

BTW: sed was on purpose here -- it limits the chained updates related to this dep. go mod tidy after sed-ing scopes updates only to things that truly are needed.

e.g. client_golang update does not need latest 0.x common, and breaking changes on those occur.

${SED} -i "s|\(	${mod_path} \).*|\1${desired_version}|" "${dir}/go.mod"

Something to keep in mind, but we could try with this, especially AI is forcing this all the time ;p

@bwplotka
bwplotka merged commit df1523b into main Aug 6, 2026
43 checks passed
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.

2 participants