@@ -42,12 +42,14 @@ def providers
4242
4343 def static_credentials ( options )
4444 if options [ :config ]
45- Credentials . new (
45+ creds = Credentials . new (
4646 options [ :config ] . access_key_id ,
4747 options [ :config ] . secret_access_key ,
4848 options [ :config ] . session_token ,
4949 account_id : options [ :config ] . account_id
5050 )
51+ creds . metrics = [ 'CREDENTIALS_PROFILE' ]
52+ creds
5153 end
5254 end
5355
@@ -76,7 +78,9 @@ def static_profile_assume_role_credentials(options)
7678
7779 def static_profile_credentials ( options )
7880 if options [ :config ] && options [ :config ] . profile
79- SharedCredentials . new ( profile_name : options [ :config ] . profile )
81+ creds = SharedCredentials . new ( profile_name : options [ :config ] . profile )
82+ creds . metrics = [ 'CREDENTIALS_PROFILE' ]
83+ creds
8084 end
8185 rescue Errors ::NoSuchProfileError
8286 nil
@@ -85,7 +89,11 @@ def static_profile_credentials(options)
8589 def static_profile_process_credentials ( options )
8690 if Aws . shared_config . config_enabled? && options [ :config ] && options [ :config ] . profile
8791 process_provider = Aws . shared_config . credential_process ( profile : options [ :config ] . profile )
88- ProcessCredentials . new ( [ process_provider ] ) if process_provider
92+ if process_provider
93+ creds = ProcessCredentials . new ( [ process_provider ] )
94+ creds . metrics << 'CREDENTIALS_PROFILE_PROCESS'
95+ creds
96+ end
8997 end
9098 rescue Errors ::NoSuchProfileError
9199 nil
@@ -96,12 +104,14 @@ def env_credentials(_options)
96104 secret = %w[ AWS_SECRET_ACCESS_KEY AMAZON_SECRET_ACCESS_KEY AWS_SECRET_KEY ]
97105 token = %w[ AWS_SESSION_TOKEN AMAZON_SESSION_TOKEN ]
98106 account_id = %w[ AWS_ACCOUNT_ID ]
99- Credentials . new (
107+ creds = Credentials . new (
100108 envar ( key ) ,
101109 envar ( secret ) ,
102110 envar ( token ) ,
103111 account_id : envar ( account_id )
104112 )
113+ creds . metrics = [ 'CREDENTIALS_ENV_VARS' ]
114+ creds
105115 end
106116
107117 def envar ( keys )
@@ -117,7 +127,9 @@ def determine_profile_name(options)
117127
118128 def shared_credentials ( options )
119129 profile_name = determine_profile_name ( options )
120- SharedCredentials . new ( profile_name : profile_name )
130+ creds = SharedCredentials . new ( profile_name : profile_name )
131+ creds . metrics = [ 'CREDENTIALS_PROFILE' ]
132+ creds
121133 rescue Errors ::NoSuchProfileError
122134 nil
123135 end
@@ -126,7 +138,11 @@ def process_credentials(options)
126138 profile_name = determine_profile_name ( options )
127139 if Aws . shared_config . config_enabled?
128140 process_provider = Aws . shared_config . credential_process ( profile : profile_name )
129- ProcessCredentials . new ( [ process_provider ] ) if process_provider
141+ if process_provider
142+ creds = ProcessCredentials . new ( [ process_provider ] )
143+ creds . metrics << 'CREDENTIALS_PROFILE_PROCESS'
144+ creds
145+ end
130146 end
131147 rescue Errors ::NoSuchProfileError
132148 nil
@@ -156,7 +172,11 @@ def assume_role_web_identity_credentials(options)
156172 role_session_name : ENV [ 'AWS_ROLE_SESSION_NAME' ]
157173 }
158174 cfg [ :region ] = region if region
159- AssumeRoleWebIdentityCredentials . new ( cfg )
175+ Aws ::Plugins ::UserAgent . metric ( 'CREDENTIALS_ENV_VARS_STS_WEB_ID_TOKEN' ) do
176+ creds = AssumeRoleWebIdentityCredentials . new ( cfg )
177+ creds . metrics << 'CREDENTIALS_ENV_VARS_STS_WEB_ID_TOKEN'
178+ creds
179+ end
160180 elsif Aws . shared_config . config_enabled?
161181 profile = options [ :config ] . profile if options [ :config ]
162182 Aws . shared_config . assume_role_web_identity_credentials_from_config (
0 commit comments