Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit a25e7bc

Browse files
authored
Update SDK metrics with client configuration options
Merge pull request #61 from howardlopez/csm_config_changes
2 parents 209bef7 + 506a699 commit a25e7bc

File tree

1 file changed

+100
-9
lines changed

1 file changed

+100
-9
lines changed

doc_source/guide_sdk-metrics-configure.rst

Lines changed: 100 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,83 @@ By default, |SDKM| is turned off, host is set to '127.0.0.1' and the port is set
5858
5959
Enabling |SDKM| is independent of configuring your credentials to use an AWS service.
6060

61-
You can enable |SDKM| by setting environment variables or by using the AWS Shared config file.
61+
You can enable |SDKM| by passing in a client configuration option, setting environment variables, or by using the AWS Shared config file.
6262

63-
Option 1: Set Environment Variables
63+
**Order of Precedence**
64+
65+
The order of precedence is as follows (1 overrides 2-3, etc.):
66+
67+
1. Client configuration option
68+
2. Environment variables
69+
3. AWS Shared config file
70+
71+
Option 1: Client Configuration Option
72+
-------------------------------------
73+
74+
You can pass in a :code:`csm` option to your client constructor to enable and set the configuration options.
75+
This option can be an associative array, an instance of :code:`\Aws\ClientSideMonitoring\ConfigurationInterface`,
76+
a callable that provides an instance of :code:`\Aws\ClientSideMonitoring\ConfigurationInterface`,
77+
or the boolean value of :code:`false`.
78+
79+
**Associative array:**
80+
81+
.. code-block:: php
82+
83+
$client = new \Aws\S3\S3Client([
84+
'region' => 'your-region',
85+
'version' => 'latest',
86+
'csm' => [
87+
'enabled' => true,
88+
'host' => 'my.host',
89+
'port' => 1234,
90+
'client_id' => 'My Application'
91+
]
92+
]);
93+
94+
**Instance of \\Aws\\ClientSideMonitoring\\ConfigurationInterface:**
95+
96+
.. code-block:: php
97+
98+
$client = new \Aws\S3\S3Client([
99+
'region' => 'your-region',
100+
'version' => 'latest',
101+
'csm' => new \Aws\ClientSideMonitoring\Configuration(
102+
true,
103+
'my.host',
104+
1234,
105+
'My Application'
106+
)
107+
]);
108+
109+
**Callable:**
110+
111+
.. code-block:: php
112+
113+
$client = new \Aws\S3\S3Client([
114+
'region' => 'your-region',
115+
'version' => 'latest',
116+
'csm' => function() {
117+
return new \Aws\ClientSideMonitoring\Configuration(
118+
true,
119+
'127.0.0.1',
120+
1234,
121+
'My Application'
122+
);
123+
}
124+
]);
125+
126+
**Boolean `false`:**
127+
128+
.. code-block:: php
129+
130+
$client = new \Aws\S3\S3Client([
131+
'region' => 'your-region',
132+
'version' => 'latest',
133+
'csm' => false
134+
]);
135+
136+
137+
Option 2: Set Environment Variables
64138
-----------------------------------
65139

66140
The SDK first checks the profile specified in the environment variable under :code:`AWS_PROFILE` to determine if |SDKM| is enabled.
@@ -78,7 +152,7 @@ To turn on |SDKM|, add the following to your environmental variables.
78152
Enabling |SDKM| does not configure your credentials to use an AWS service.
79153
To do that, see :doc:`Credentials for the AWS SDK for PHP Version 3<guide_credentials>`.
80154

81-
Option 2: AWS Shared Config File
155+
Option 3: AWS Shared Config File
82156
--------------------------------
83157

84158
If no CSM configuration is found in the environment variables, the SDK looks for your default AWS profile field. If :code:`AWS_DEFAULT_PROFILE` is set to something other than default, update that profile. To enable SDK Metrics, add :code:`csm_enabled` to the shared config file located at :file:`~/.aws/config`.
@@ -105,7 +179,14 @@ Update a |CW| Agent
105179

106180
To make changes to the host or port ID, you need to set the values and then restart any AWS jobs that are currently active.
107181

108-
Option 1: Set Environment Variables
182+
Option 1: Client Configuration Option
183+
-------------------------------------
184+
185+
See Option 1 above under "Enable |SDKM| for the |sdk-php|" for examples of how to set the
186+
client configuration :code:`csm` option to modify CSM settings.
187+
188+
189+
Option 2: Set Environment Variables
109190
-----------------------------------
110191

111192
Most AWS services use the default port. But if the service you want |SDKM| to monitor uses a unique port, add `AWS_CSM_PORT=[port_number]`, to the host's environment variables.
@@ -118,7 +199,7 @@ Additionally, a different host can be specified using the `AWS_CSM_HOST` environ
118199
export AWS_CSM_HOST=192.168.0.1
119200
120201
121-
Option 2: AWS Shared Config File
202+
Option 3: AWS Shared Config File
122203
--------------------------------
123204

124205
Most services use the default port. But if your service requires a
@@ -159,16 +240,26 @@ Then restart your |CW| agent so that the changes can take effect.
159240
Set csm_enabled to false
160241
------------------------
161242

162-
**Option 1: Environment Variables**
243+
.. note:: Note the order of precedence listed above. For example, if |SDKM| is enabled in the environment variables but disabled in the config file, the |SDKM| remains enabled.
244+
245+
**Option 1: Client configuration**
246+
247+
.. code-block:: php
248+
249+
$client = new \Aws\S3\S3Client([
250+
'region' => 'your-region',
251+
'version' => 'latest',
252+
'csm' => false
253+
]);
254+
255+
**Option 2: Environment Variables**
163256

164257
.. code-block:: ini
165258
166259
export AWS_CSM_ENABLED=false
167260
168261
169-
**Option 2: AWS Shared Config File**
170-
171-
.. note:: Environment variables override the AWS Shared config file. If |SDKM| is enabled in the environment variables, the |SDKM| remains enabled.
262+
**Option 3: AWS Shared Config File**
172263

173264
.. code-block:: ini
174265

0 commit comments

Comments
 (0)