2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,16 @@ def get_job_name() -> str | None:
28
28
return None
29
29
30
30
31
+ def get_head_ref_name () -> str | None :
32
+ match get_ci_provider ():
33
+ case "github_actions" :
34
+ return os .getenv ("GITHUB_HEAD_REF" ) or os .getenv ("GITHUB_REF" )
35
+ case "circleci" :
36
+ return os .getenv ("CIRCLE_BRANCH" )
37
+ case _:
38
+ return None
39
+
40
+
31
41
def get_github_actions_head_sha () -> str | None :
32
42
if os .getenv ("GITHUB_EVENT_NAME" ) == "pull_request" :
33
43
# NOTE(leo): we want the head sha of pull request
Original file line number Diff line number Diff line change @@ -76,6 +76,9 @@ async def junit_to_spans(
76
76
if (head_revision := (await detector .get_head_sha ())) is not None :
77
77
resource_attributes [vcs_attributes .VCS_REF_HEAD_REVISION ] = head_revision
78
78
79
+ if (head_ref_name := detector .get_head_ref_name ()) is not None :
80
+ resource_attributes [vcs_attributes .VCS_REF_HEAD_NAME ] = head_ref_name
81
+
79
82
if (provider := detector .get_ci_provider ()) is not None :
80
83
resource_attributes ["cicd.provider.name" ] = provider
81
84
0 commit comments