66import re
77import sys
88
9- # Dependencies that use the instrumentation version
10- INSTRUMENTATION_DEPS = [
11- "io.opentelemetry.javaagent:opentelemetry-javaagent" ,
12- ]
13-
14- # Dependencies that use the contrib version
15- CONTRIB_DEPS = [
16- "io.opentelemetry.contrib:opentelemetry-aws-xray" ,
17- "io.opentelemetry.contrib:opentelemetry-aws-resources" ,
18- ]
19-
20- # Other OpenTelemetry dependencies with independent versioning
21- OTHER_OTEL_DEPS = [
22- "io.opentelemetry:opentelemetry-extension-aws" ,
23- "io.opentelemetry.proto:opentelemetry-proto" ,
24- ]
25-
269def update_file_dependencies (file_path , otel_instrumentation_version , otel_contrib_version ):
2710 """Update all OpenTelemetry dependencies in a given file"""
2811 try :
@@ -33,13 +16,14 @@ def update_file_dependencies(file_path, otel_instrumentation_version, otel_contr
3316
3417 # Update otelVersion variable
3518 otel_version_pattern = r'val otelVersion = "[^"]*"'
36- otel_version_replacement = f'val otelVersion = "{ otel_instrumentation_version } "'
19+ otel_version_with_suffix = f"{ otel_instrumentation_version } -adot1"
20+ otel_version_replacement = f'val otelVersion = "{ otel_version_with_suffix } "'
3721 if re .search (otel_version_pattern , content ):
3822 new_content = re .sub (otel_version_pattern , otel_version_replacement , content )
3923 if new_content != content :
4024 content = new_content
4125 updated = True
42- print (f"Updated otelVersion to { otel_instrumentation_version } " )
26+ print (f"Updated otelVersion to { otel_version_with_suffix } " )
4327
4428 # Update otelSnapshotVersion (typically next minor version)
4529 version_parts = otel_instrumentation_version .split ("." )
@@ -54,16 +38,49 @@ def update_file_dependencies(file_path, otel_instrumentation_version, otel_contr
5438 updated = True
5539 print (f"Updated otelSnapshotVersion to { next_minor } " )
5640
57- # Update contrib dependencies
58- for dep in CONTRIB_DEPS :
59- pattern = rf'"{ re .escape (dep )} :[^"]*"'
60- replacement = f'"{ dep } :{ otel_contrib_version } "'
61- if re .search (pattern , content ):
62- new_content = re .sub (pattern , replacement , content )
41+ # Update opentelemetry-aws-xray with -adot1 suffix
42+ xray_pattern = r'"io\.opentelemetry\.contrib:opentelemetry-aws-xray:[^"]*"'
43+ xray_version = f"{ otel_contrib_version } -adot1"
44+ xray_replacement = f'"io.opentelemetry.contrib:opentelemetry-aws-xray:{ xray_version } "'
45+ if re .search (xray_pattern , content ):
46+ new_content = re .sub (xray_pattern , xray_replacement , content )
47+ if new_content != content :
48+ content = new_content
49+ updated = True
50+ print (f"Updated opentelemetry-aws-xray to { xray_version } " )
51+
52+ # Update opentelemetry-aws-resources with -alpha suffix
53+ resources_pattern = r'"io\.opentelemetry\.contrib:opentelemetry-aws-resources:[^"]*"'
54+ resources_version = f"{ otel_contrib_version } -alpha"
55+ resources_replacement = f'"io.opentelemetry.contrib:opentelemetry-aws-resources:{ resources_version } "'
56+ if re .search (resources_pattern , content ):
57+ new_content = re .sub (resources_pattern , resources_replacement , content )
58+ if new_content != content :
59+ content = new_content
60+ updated = True
61+ print (f"Updated opentelemetry-aws-resources to { resources_version } " )
62+
63+ # Update .github/patches/versions file
64+ if file_path == ".github/patches/versions" :
65+ # Update OTEL_JAVA_INSTRUMENTATION_VERSION
66+ instrumentation_pattern = r'OTEL_JAVA_INSTRUMENTATION_VERSION=v[^\n]*'
67+ instrumentation_replacement = f'OTEL_JAVA_INSTRUMENTATION_VERSION=v{ otel_instrumentation_version } '
68+ if re .search (instrumentation_pattern , content ):
69+ new_content = re .sub (instrumentation_pattern , instrumentation_replacement , content )
70+ if new_content != content :
71+ content = new_content
72+ updated = True
73+ print (f"Updated OTEL_JAVA_INSTRUMENTATION_VERSION to v{ otel_instrumentation_version } " )
74+
75+ # Update OTEL_JAVA_CONTRIB_VERSION
76+ contrib_pattern = r'OTEL_JAVA_CONTRIB_VERSION=v[^\n]*'
77+ contrib_replacement = f'OTEL_JAVA_CONTRIB_VERSION=v{ otel_contrib_version } '
78+ if re .search (contrib_pattern , content ):
79+ new_content = re .sub (contrib_pattern , contrib_replacement , content )
6380 if new_content != content :
6481 content = new_content
6582 updated = True
66- print (f"Updated { dep } to { otel_contrib_version } " )
83+ print (f"Updated OTEL_JAVA_CONTRIB_VERSION to v { otel_contrib_version } " )
6784
6885 if updated :
6986 with open (file_path , "w" , encoding = "utf-8" ) as output_file :
@@ -86,6 +103,7 @@ def main():
86103 # Files to update
87104 files_to_update = [
88105 "dependencyManagement/build.gradle.kts" ,
106+ ".github/patches/versions" ,
89107 ]
90108
91109 any_updated = False
@@ -94,7 +112,7 @@ def main():
94112 any_updated = True
95113
96114 if any_updated :
97- print (f"Dependencies updated to Instrumentation { otel_instrumentation_version } / Contrib { otel_contrib_version } " )
115+ print (f"Dependencies updated to Instrumentation { otel_instrumentation_version } -adot1 / Contrib { otel_contrib_version } (with appropriate suffixes) " )
98116 else :
99117 print ("No OpenTelemetry dependencies found to update" )
100118
0 commit comments