Skip to content

Commit dc0f879

Browse files
authored
fix: add osplatform telemetry (aws#8279)
* fix: add osplatform telemetry * update event test * update integration test
1 parent e319d46 commit dc0f879

File tree

4 files changed

+9
-0
lines changed

4 files changed

+9
-0
lines changed

samcli/lib/telemetry/metric.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ def _add_common_metric_attributes(self):
442442
self._data["ci"] = bool(self._cicd_detector.platform())
443443
self._data["pyversion"] = platform.python_version()
444444
self._data["samcliVersion"] = samcli_version
445+
self._data["osPlatform"] = platform.system()
445446

446447
user_agent = get_user_agent_string()
447448
if user_agent:

tests/integration/telemetry/test_experimental_metric.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def test_must_send_experimental_metrics_if_experimental_command(self):
5454
"ci": ANY,
5555
"pyversion": ANY,
5656
"samcliVersion": SAM_CLI_VERSION,
57+
"osPlatform": ANY,
5758
"awsProfileProvided": ANY,
5859
"debugFlagProvided": ANY,
5960
"region": ANY,
@@ -112,6 +113,7 @@ def test_must_send_experimental_metrics_if_experimental_option(self):
112113
"ci": ANY,
113114
"pyversion": ANY,
114115
"samcliVersion": SAM_CLI_VERSION,
116+
"osPlatform": ANY,
115117
"awsProfileProvided": ANY,
116118
"debugFlagProvided": ANY,
117119
"region": ANY,
@@ -180,6 +182,7 @@ def test_must_send_cdk_project_type_metrics(self):
180182
"ci": ANY,
181183
"pyversion": ANY,
182184
"samcliVersion": SAM_CLI_VERSION,
185+
"osPlatform": ANY,
183186
"awsProfileProvided": ANY,
184187
"debugFlagProvided": ANY,
185188
"region": ANY,
@@ -236,6 +239,7 @@ def test_must_send_not_experimental_metrics_if_not_experimental(self):
236239
"ci": ANY,
237240
"pyversion": ANY,
238241
"samcliVersion": SAM_CLI_VERSION,
242+
"osPlatform": ANY,
239243
"awsProfileProvided": ANY,
240244
"debugFlagProvided": ANY,
241245
"region": ANY,

tests/unit/lib/telemetry/test_event.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ def test_events_get_sent(self, telemetry_mock):
166166
"ci": ANY,
167167
"pyversion": ANY,
168168
"samcliVersion": ANY,
169+
"osPlatform": ANY,
169170
"commandName": ANY,
170171
"metricSpecificAttributes": {
171172
"containerEngine": ANY,

tests/unit/lib/telemetry/test_metric.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,7 @@ def test_must_add_common_attributes(
561561
installation_id = gc_mock.return_value.installation_id = "fake installation id"
562562
session_id = context_mock.get_current_context.return_value.session_id = "fake installation id"
563563
python_version = platform_mock.python_version.return_value = "8.8.0"
564+
os_platform = platform_mock.system.return_value = "Linux"
564565
cicd_platform_mock.return_value = cicd_platform
565566
get_user_agent_mock.return_value = user_agent
566567

@@ -575,6 +576,7 @@ def test_must_add_common_attributes(
575576
assert metric.get_data()["userAgent"] == user_agent
576577
assert metric.get_data()["pyversion"] == python_version
577578
assert metric.get_data()["samcliVersion"] == samcli.__version__
579+
assert metric.get_data()["osPlatform"] == os_platform
578580

579581

580582
def _ignore_common_attributes(data):
@@ -585,6 +587,7 @@ def _ignore_common_attributes(data):
585587
"executionEnvironment",
586588
"pyversion",
587589
"samcliVersion",
590+
"osPlatform",
588591
]
589592
for a in common_attrs:
590593
if a not in data:

0 commit comments

Comments
 (0)