@@ -26,15 +26,15 @@ def get_github_actions_head_sha() -> str | None:
26
26
return os .getenv ("GITHUB_SHA" )
27
27
28
28
OPENTELEMETRY_GHA_MAPPING = {
29
- cicd_attributes .CICD_PIPELINE_NAME : "GITHUB_JOB" ,
30
- cicd_attributes .CICD_PIPELINE_RUN_ID : "GITHUB_RUN_ID" ,
31
- "cicd.pipeline.run.attempt" : "GITHUB_RUN_ATTEMPT" ,
32
- cicd_attributes .CICD_PIPELINE_TASK_NAME : "GITHUB_ACTION" ,
33
- vcs_attributes .VCS_REF_HEAD_NAME : "GITHUB_REF_NAME" ,
34
- vcs_attributes .VCS_REF_HEAD_TYPE : "GITHUB_REF_TYPE" ,
35
- vcs_attributes .VCS_REF_BASE_NAME : "GITHUB_BASE_REF" ,
36
- "vcs.repository.name" : "GITHUB_REPOSITORY" ,
37
- "vcs.repository.id" : "GITHUB_REPOSITORY_ID" ,
29
+ cicd_attributes .CICD_PIPELINE_NAME : ( str , "GITHUB_JOB" ) ,
30
+ cicd_attributes .CICD_PIPELINE_RUN_ID : ( int , "GITHUB_RUN_ID" ) ,
31
+ "cicd.pipeline.run.attempt" : ( int , "GITHUB_RUN_ATTEMPT" ) ,
32
+ cicd_attributes .CICD_PIPELINE_TASK_NAME : ( str , "GITHUB_ACTION" ) ,
33
+ vcs_attributes .VCS_REF_HEAD_NAME : ( str , "GITHUB_REF_NAME" ) ,
34
+ vcs_attributes .VCS_REF_HEAD_TYPE : ( str , "GITHUB_REF_TYPE" ) ,
35
+ vcs_attributes .VCS_REF_BASE_NAME : ( str , "GITHUB_BASE_REF" ) ,
36
+ "vcs.repository.name" : ( str , "GITHUB_REPOSITORY" ) ,
37
+ "vcs.repository.id" : ( int , "GITHUB_REPOSITORY_ID" ) ,
38
38
}
39
39
40
40
def detect (self ) -> Resource :
@@ -52,8 +52,8 @@ def detect(self) -> Resource:
52
52
if head_sha is not None :
53
53
attributes [vcs_attributes .VCS_REF_HEAD_REVISION ] = head_sha
54
54
55
- for attribute_name , envvar in self .OPENTELEMETRY_GHA_MAPPING .items ():
55
+ for attribute_name , ( type_ , envvar ) in self .OPENTELEMETRY_GHA_MAPPING .items ():
56
56
if envvar in os .environ :
57
- attributes [attribute_name ] = os .environ [envvar ]
57
+ attributes [attribute_name ] = type_ ( os .environ [envvar ])
58
58
59
59
return Resource (attributes )
0 commit comments