Skip to content

Commit a9d2b62

Browse files
Sushant Khannasushantkhanna
authored andcommitted
Add -m option when it is used to user agent to track usage
1 parent e5a7d2c commit a9d2b62

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

gslib/tests/test_user_agent_helper.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ def testCp(self, mock_invoked):
5252
self.assertRegex(GetUserAgent(['cp', '-r', '-Z', '1.txt', 'gs://dst']),
5353
r"command/cp$")
5454

55+
@mock.patch.object(system_util, 'InvokedViaCloudSdk')
56+
def testCpWithMultiprocessing(self, mock_invoked):
57+
mock_invoked.return_value = False
58+
self.assertRegex(GetUserAgent(['cp', '-m', '1.txt', 'gs://dst']),
59+
r"command/cp-m$")
60+
5561
@mock.patch.object(system_util, 'InvokedViaCloudSdk')
5662
def testCpNotEnoughArgs(self, mock_invoked):
5763
mock_invoked.return_value = False
@@ -96,6 +102,11 @@ def testCpDaisyChain(self):
96102
self.assertRegex(GetUserAgent(['rsync', '-r', 'gs://src', 's3://dst']),
97103
r"command/rsync-DaisyChain")
98104

105+
def testCpDaisyChainWithMultiprocessing(self):
106+
self.assertRegex(
107+
GetUserAgent(['cp', '-r', '-Z', '-m', 'gs://src', 's3://dst']),
108+
r"command/cp-DaisyChain-m")
109+
99110
@mock.patch.object(system_util, 'InvokedViaCloudSdk')
100111
def testPassOnInvalidUrlError(self, mock_invoked):
101112
mock_invoked.return_value = False

gslib/utils/user_agent_helper.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ def GetUserAgent(args, metrics_off=True):
6262
# Rewrite storage class.
6363
user_agent += '-s'
6464

65+
if '-m' in args:
66+
# Use of multi processing
67+
user_agent += '-m'
68+
6569
if system_util.InvokedViaCloudSdk():
6670
user_agent += ' google-cloud-sdk'
6771
if system_util.CloudSdkVersion():

0 commit comments

Comments
 (0)