|
3 | 3 | import typing |
4 | 4 |
|
5 | 5 | import click |
| 6 | +from opentelemetry import trace |
6 | 7 |
|
7 | 8 | from codecov_cli.commands.commit import create_commit |
8 | 9 | from codecov_cli.commands.report import create_report |
9 | 10 | from codecov_cli.commands.upload import do_upload, global_upload_options |
10 | 11 | from codecov_cli.helpers.args import get_cli_args |
11 | 12 | from codecov_cli.helpers.options import global_options |
| 13 | +from codecov_cli.opentelemetry import close_telem |
12 | 14 | from codecov_cli.services.upload_coverage import upload_coverage_logic |
13 | 15 | from codecov_cli.types import CommandContext |
14 | 16 |
|
15 | 17 | logger = logging.getLogger("codecovcli") |
| 18 | +tracer = trace.get_tracer(__name__) |
16 | 19 |
|
17 | 20 |
|
18 | 21 | # These options are the combined options of commit, report and upload commands |
@@ -60,116 +63,118 @@ def upload_coverage( |
60 | 63 | token: typing.Optional[str], |
61 | 64 | use_legacy_uploader: bool, |
62 | 65 | ): |
63 | | - args = get_cli_args(ctx) |
64 | | - logger.debug( |
65 | | - "Starting upload coverage", |
66 | | - extra=dict( |
67 | | - extra_log_attributes=args, |
68 | | - ), |
69 | | - ) |
70 | | - |
71 | | - if not use_legacy_uploader and report_type == "coverage": |
72 | | - versioning_system = ctx.obj["versioning_system"] |
73 | | - codecov_yaml = ctx.obj["codecov_yaml"] or {} |
74 | | - cli_config = codecov_yaml.get("cli", {}) |
75 | | - ci_adapter = ctx.obj.get("ci_adapter") |
76 | | - enterprise_url = ctx.obj.get("enterprise_url") |
| 66 | + with tracer.start_as_current_span("upload_coverage"): |
77 | 67 | args = get_cli_args(ctx) |
78 | | - ctx.invoke( |
79 | | - upload_coverage_logic, |
80 | | - cli_config, |
81 | | - versioning_system, |
82 | | - ci_adapter, |
83 | | - branch=branch, |
84 | | - build_code=build_code, |
85 | | - build_url=build_url, |
86 | | - commit_sha=commit_sha, |
87 | | - disable_file_fixes=disable_file_fixes, |
88 | | - disable_search=disable_search, |
89 | | - dry_run=dry_run, |
90 | | - enterprise_url=enterprise_url, |
91 | | - env_vars=env_vars, |
92 | | - fail_on_error=fail_on_error, |
93 | | - files_search_exclude_folders=files_search_exclude_folders, |
94 | | - files_search_explicitly_listed_files=files_search_explicitly_listed_files, |
95 | | - files_search_root_folder=files_search_root_folder, |
96 | | - flags=flags, |
97 | | - gcov_args=gcov_args, |
98 | | - gcov_executable=gcov_executable, |
99 | | - gcov_ignore=gcov_ignore, |
100 | | - gcov_include=gcov_include, |
101 | | - git_service=git_service, |
102 | | - handle_no_reports_found=handle_no_reports_found, |
103 | | - job_code=job_code, |
104 | | - name=name, |
105 | | - network_filter=network_filter, |
106 | | - network_prefix=network_prefix, |
107 | | - network_root_folder=network_root_folder, |
108 | | - parent_sha=parent_sha, |
109 | | - plugin_names=plugin_names, |
110 | | - pull_request_number=pull_request_number, |
111 | | - report_code=report_code, |
112 | | - slug=slug, |
113 | | - swift_project=swift_project, |
114 | | - token=token, |
115 | | - upload_file_type=report_type, |
116 | | - use_legacy_uploader=use_legacy_uploader, |
117 | | - args=args, |
118 | | - ) |
119 | | - else: |
120 | | - ctx.invoke( |
121 | | - create_commit, |
122 | | - commit_sha=commit_sha, |
123 | | - parent_sha=parent_sha, |
124 | | - pull_request_number=pull_request_number, |
125 | | - branch=branch, |
126 | | - slug=slug, |
127 | | - token=token, |
128 | | - git_service=git_service, |
129 | | - fail_on_error=True, |
| 68 | + logger.debug( |
| 69 | + "Starting upload coverage", |
| 70 | + extra=dict( |
| 71 | + extra_log_attributes=args, |
| 72 | + ), |
130 | 73 | ) |
131 | | - if report_type == "coverage": |
| 74 | + |
| 75 | + if not use_legacy_uploader and report_type == "coverage": |
| 76 | + versioning_system = ctx.obj["versioning_system"] |
| 77 | + codecov_yaml = ctx.obj["codecov_yaml"] or {} |
| 78 | + cli_config = codecov_yaml.get("cli", {}) |
| 79 | + ci_adapter = ctx.obj.get("ci_adapter") |
| 80 | + enterprise_url = ctx.obj.get("enterprise_url") |
| 81 | + args = get_cli_args(ctx) |
132 | 82 | ctx.invoke( |
133 | | - create_report, |
| 83 | + upload_coverage_logic, |
| 84 | + cli_config, |
| 85 | + versioning_system, |
| 86 | + ci_adapter, |
| 87 | + branch=branch, |
| 88 | + build_code=build_code, |
| 89 | + build_url=build_url, |
| 90 | + commit_sha=commit_sha, |
| 91 | + disable_file_fixes=disable_file_fixes, |
| 92 | + disable_search=disable_search, |
| 93 | + dry_run=dry_run, |
| 94 | + enterprise_url=enterprise_url, |
| 95 | + env_vars=env_vars, |
| 96 | + fail_on_error=fail_on_error, |
| 97 | + files_search_exclude_folders=files_search_exclude_folders, |
| 98 | + files_search_explicitly_listed_files=files_search_explicitly_listed_files, |
| 99 | + files_search_root_folder=files_search_root_folder, |
| 100 | + flags=flags, |
| 101 | + gcov_args=gcov_args, |
| 102 | + gcov_executable=gcov_executable, |
| 103 | + gcov_ignore=gcov_ignore, |
| 104 | + gcov_include=gcov_include, |
| 105 | + git_service=git_service, |
| 106 | + handle_no_reports_found=handle_no_reports_found, |
| 107 | + job_code=job_code, |
| 108 | + name=name, |
| 109 | + network_filter=network_filter, |
| 110 | + network_prefix=network_prefix, |
| 111 | + network_root_folder=network_root_folder, |
| 112 | + parent_sha=parent_sha, |
| 113 | + plugin_names=plugin_names, |
| 114 | + pull_request_number=pull_request_number, |
| 115 | + report_code=report_code, |
| 116 | + slug=slug, |
| 117 | + swift_project=swift_project, |
134 | 118 | token=token, |
135 | | - code=report_code, |
136 | | - fail_on_error=True, |
| 119 | + upload_file_type=report_type, |
| 120 | + use_legacy_uploader=use_legacy_uploader, |
| 121 | + args=args, |
| 122 | + ) |
| 123 | + else: |
| 124 | + ctx.invoke( |
| 125 | + create_commit, |
137 | 126 | commit_sha=commit_sha, |
| 127 | + parent_sha=parent_sha, |
| 128 | + pull_request_number=pull_request_number, |
| 129 | + branch=branch, |
138 | 130 | slug=slug, |
| 131 | + token=token, |
139 | 132 | git_service=git_service, |
| 133 | + fail_on_error=True, |
140 | 134 | ) |
141 | | - ctx.invoke( |
142 | | - do_upload, |
143 | | - branch=branch, |
144 | | - build_code=build_code, |
145 | | - build_url=build_url, |
146 | | - commit_sha=commit_sha, |
147 | | - disable_file_fixes=disable_file_fixes, |
148 | | - disable_search=disable_search, |
149 | | - dry_run=dry_run, |
150 | | - env_vars=env_vars, |
151 | | - fail_on_error=fail_on_error, |
152 | | - files_search_exclude_folders=files_search_exclude_folders, |
153 | | - files_search_explicitly_listed_files=files_search_explicitly_listed_files, |
154 | | - files_search_root_folder=files_search_root_folder, |
155 | | - flags=flags, |
156 | | - gcov_args=gcov_args, |
157 | | - gcov_executable=gcov_executable, |
158 | | - gcov_ignore=gcov_ignore, |
159 | | - gcov_include=gcov_include, |
160 | | - git_service=git_service, |
161 | | - handle_no_reports_found=handle_no_reports_found, |
162 | | - job_code=job_code, |
163 | | - name=name, |
164 | | - network_filter=network_filter, |
165 | | - network_prefix=network_prefix, |
166 | | - network_root_folder=network_root_folder, |
167 | | - plugin_names=plugin_names, |
168 | | - pull_request_number=pull_request_number, |
169 | | - report_code=report_code, |
170 | | - report_type=report_type, |
171 | | - slug=slug, |
172 | | - swift_project=swift_project, |
173 | | - token=token, |
174 | | - use_legacy_uploader=use_legacy_uploader, |
175 | | - ) |
| 135 | + if report_type == "coverage": |
| 136 | + ctx.invoke( |
| 137 | + create_report, |
| 138 | + token=token, |
| 139 | + code=report_code, |
| 140 | + fail_on_error=True, |
| 141 | + commit_sha=commit_sha, |
| 142 | + slug=slug, |
| 143 | + git_service=git_service, |
| 144 | + ) |
| 145 | + ctx.invoke( |
| 146 | + do_upload, |
| 147 | + branch=branch, |
| 148 | + build_code=build_code, |
| 149 | + build_url=build_url, |
| 150 | + commit_sha=commit_sha, |
| 151 | + disable_file_fixes=disable_file_fixes, |
| 152 | + disable_search=disable_search, |
| 153 | + dry_run=dry_run, |
| 154 | + env_vars=env_vars, |
| 155 | + fail_on_error=fail_on_error, |
| 156 | + files_search_exclude_folders=files_search_exclude_folders, |
| 157 | + files_search_explicitly_listed_files=files_search_explicitly_listed_files, |
| 158 | + files_search_root_folder=files_search_root_folder, |
| 159 | + flags=flags, |
| 160 | + gcov_args=gcov_args, |
| 161 | + gcov_executable=gcov_executable, |
| 162 | + gcov_ignore=gcov_ignore, |
| 163 | + gcov_include=gcov_include, |
| 164 | + git_service=git_service, |
| 165 | + handle_no_reports_found=handle_no_reports_found, |
| 166 | + job_code=job_code, |
| 167 | + name=name, |
| 168 | + network_filter=network_filter, |
| 169 | + network_prefix=network_prefix, |
| 170 | + network_root_folder=network_root_folder, |
| 171 | + plugin_names=plugin_names, |
| 172 | + pull_request_number=pull_request_number, |
| 173 | + report_code=report_code, |
| 174 | + report_type=report_type, |
| 175 | + slug=slug, |
| 176 | + swift_project=swift_project, |
| 177 | + token=token, |
| 178 | + use_legacy_uploader=use_legacy_uploader, |
| 179 | + ) |
| 180 | + close_telem() |
0 commit comments