Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions hack/update-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,39 @@ set -o pipefail
source $(dirname "$0")/../vendor/knative.dev/hack/library.sh

go_update_deps "$@"

# Update semconv import versions to match the go.opentelemetry.io/otel version
# This prevents schema conflict errors when OpenTelemetry dependencies are bumped
log.step "Syncing semconv imports"
OTEL_VERSION=$(go list -m go.opentelemetry.io/otel 2>/dev/null | awk '{print $NF}')
if [ -n "$OTEL_VERSION" ]; then
group "Detected go.opentelemetry.io/otel ${OTEL_VERSION}"

# Check known mappings first (fast path)
case "$OTEL_VERSION" in
v1.45.*) SEMCONV_VERSION="v1.43.0" ;;
v1.44.*) SEMCONV_VERSION="v1.41.0" ;;
esac

# If no mapping found, fetch from OTEL's go.mod
if [ -z "$SEMCONV_VERSION" ]; then
group "No known mapping, fetching semconv version from OTEL go.mod"
SEMCONV_VERSION=$(curl -s "https://raw.githubusercontent.com/open-telemetry/opentelemetry-go/${OTEL_VERSION}/go.mod" 2>/dev/null | \
grep "go.opentelemetry.io/otel/semconv/v" | head -1 | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' || echo "")
fi

if [ -n "$SEMCONV_VERSION" ]; then
group "Updating semconv imports to ${SEMCONV_VERSION}"
# Find Go files under observability/ that use a versioned semconv import and
# update them. Match only the version segment so subpackage imports
# (e.g. .../v1.41.0/httpconv) are updated too, preserving what follows it.
find observability -type f -name "*.go" -exec \
grep -lE "go.opentelemetry.io/otel/semconv/v[0-9]+\.[0-9]+\.[0-9]+" {} + | \
while IFS= read -r file; do
group " ${file}"
sed -i -E "s|(go.opentelemetry.io/otel/semconv/)v[0-9]+\.[0-9]+\.[0-9]+|\1$SEMCONV_VERSION|g" "$file"
done
else
group "Could not determine semconv version, skipping"
fi
fi
Loading