Skip to content

Commit 9c9e2d1

Browse files
edferron-ddclaude
andcommitted
Address review: connectivity metric, deps, secret flag, tests
- check.py: report connectivity as the genesys_mos.can_connect gauge (1/0) instead of a service check; add it to metadata.csv and empty service_checks.json - README: add a manual step to install the PureCloudPlatformClientV2 dependency into the Agent's embedded env (the wheel install does not pull deps); document can_connect under Service checks and Troubleshooting - spec.yaml: mark client_secret as secret so it is hidden from Agent output - tests: assert the can_connect metric and validate metrics against metadata.csv via assert_metrics_using_metadata(get_metadata_metrics()) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 842f705 commit 9c9e2d1

7 files changed

Lines changed: 32 additions & 29 deletions

File tree

genesys_mos/README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,15 @@ versions of the Agent.
3030
datadog-agent integration install -w /path/to/genesys_mos/dist/datadog_genesys_mos-1.0.0-py3-none-any.whl
3131
```
3232

33-
This also installs the check's dependency, the Genesys Cloud Python SDK
34-
(`PureCloudPlatformClientV2`), into the Agent's embedded environment.
33+
2. This command does not install the check's third-party dependency, so install the Genesys
34+
Cloud Python SDK (`PureCloudPlatformClientV2`) into the Agent's embedded environment
35+
manually:
3536

36-
2. Configure your integration similar to core [integrations][5].
37+
```shell
38+
sudo -u dd-agent /opt/datadog-agent/embedded/bin/pip install "PureCloudPlatformClientV2==261.0.0"
39+
```
40+
41+
3. Configure your integration similar to core [integrations][5].
3742

3843
### Configuration
3944

@@ -119,15 +124,18 @@ See [metadata.csv][10] for a list of metrics provided by this integration.
119124

120125
### Service checks
121126

122-
See [service_checks.json][11] for a list of service checks provided by this integration.
127+
The Genesys Cloud MOS integration does not include any service checks. Connectivity is
128+
reported through the `genesys_mos.can_connect` metric, which is `1` when the check can
129+
authenticate against the Genesys Cloud API and run the analytics conversation query, and
130+
`0` otherwise.
123131

124132
### Events
125133

126134
The Genesys Cloud MOS integration does not include any events.
127135

128136
## Troubleshooting
129137

130-
- `genesys_mos.can_connect` reports `CRITICAL`: verify the `region`, `client_id`, and
138+
- `genesys_mos.can_connect` is `0`: verify the `region`, `client_id`, and
131139
`client_secret`, and confirm the OAuth client's role has the
132140
**Analytics > Conversation Detail > View** permission.
133141
- No conversations reported: MOS is only present on conversations that used media with
@@ -151,6 +159,5 @@ requests, contact the maintainer at ed.ferron@datadoghq.com or open an issue in
151159
[8]: https://docs.datadoghq.com/agent/guide/agent-commands/#start-stop-and-restart-the-agent
152160
[9]: https://docs.datadoghq.com/agent/guide/agent-commands/#agent-status-and-information
153161
[10]: https://github.com/DataDog/integrations-extras/blob/master/genesys_mos/metadata.csv
154-
[11]: https://github.com/DataDog/integrations-extras/blob/master/genesys_mos/assets/service_checks.json
155162
[12]: https://github.com/DataDog/integrations-extras/issues
156163
[13]: https://docs.datadoghq.com/agent/configuration/secrets-management/

genesys_mos/assets/configuration/spec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ files:
2525
- name: client_secret
2626
description: The Client Secret for the OAuth client above.
2727
required: true
28+
secret: true
2829
value:
2930
type: string
3031
- name: mos_threshold
Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1 @@
1-
[
2-
{
3-
"agent_version": "7.0.0",
4-
"integration": "Genesys Cloud MOS",
5-
"check": "genesys_mos.can_connect",
6-
"statuses": ["ok", "critical"],
7-
"groups": ["region"],
8-
"name": "Genesys Cloud MOS: can connect",
9-
"description": "Returns `OK` if the Agent can authenticate against the Genesys Cloud API and run the analytics conversation query, otherwise `CRITICAL`."
10-
}
11-
]
1+
[]

genesys_mos/datadog_checks/genesys_mos/check.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
class GenesysMosCheck(AgentCheck):
2424
__NAMESPACE__ = "genesys_mos"
2525

26-
SERVICE_CHECK_CONNECT = "can_connect"
26+
CAN_CONNECT_METRIC = "can_connect"
2727

2828
def __init__(self, name, init_config, instances):
2929
super(GenesysMosCheck, self).__init__(name, init_config, instances)
@@ -50,12 +50,13 @@ def check(self, _):
5050
try:
5151
analytics_api = self._authenticate()
5252
conversations = self._collect_conversations(analytics_api, interval)
53-
except Exception as e:
54-
self.service_check(self.SERVICE_CHECK_CONNECT, AgentCheck.CRITICAL, tags=self.base_tags, message=str(e))
53+
except Exception:
54+
# Report connectivity as a 0/1 gauge rather than a service check.
55+
self.gauge(self.CAN_CONNECT_METRIC, 0, tags=self.base_tags)
5556
self.log.exception("Genesys Cloud MOS collection failed")
5657
raise
5758

58-
self.service_check(self.SERVICE_CHECK_CONNECT, AgentCheck.OK, tags=self.base_tags)
59+
self.gauge(self.CAN_CONNECT_METRIC, 1, tags=self.base_tags)
5960
self._submit_metrics(conversations)
6061

6162
def _query_interval(self):

genesys_mos/metadata.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ genesys_mos.conversation.mos.avg,gauge,,,,Average of the per-conversation minimu
33
genesys_mos.conversation.mos.min,gauge,,,,Worst (lowest) per-conversation minimum MOS observed across ended conversations in the query window.,1,genesys_cloud_mos,min mos,,region
44
genesys_mos.conversation.count,gauge,,,,Number of ended conversations with a MOS value in the query window.,0,genesys_cloud_mos,conversation count,,region
55
genesys_mos.conversation.below_threshold.count,gauge,,,,Number of conversations with MOS at or below the configured quality threshold.,-1,genesys_cloud_mos,below threshold count,,region
6+
genesys_mos.can_connect,gauge,,,,1 if the check can authenticate against the Genesys Cloud API and run the analytics conversation query else 0.,0,genesys_cloud_mos,can connect,,region

genesys_mos/tests/test_integration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def test_documented_pagination_dedupe_and_metrics(aggregator, instance):
9696
aggregator.assert_metric("genesys_mos.conversation.mos.min", value=3.61, tags=EXPECTED_TAGS)
9797
# threshold 4.2 -> 4.05 and 3.61 are at/below.
9898
aggregator.assert_metric("genesys_mos.conversation.below_threshold.count", value=2, tags=EXPECTED_TAGS)
99-
aggregator.assert_service_check("genesys_mos.can_connect", status=GenesysMosCheck.OK, tags=EXPECTED_TAGS)
99+
aggregator.assert_metric("genesys_mos.can_connect", value=1, tags=EXPECTED_TAGS)
100100
aggregator.assert_all_metrics_covered()
101101

102102
# Paged until an empty page was returned (3 requests: page 1, 2, and the empty page 3).
@@ -149,4 +149,4 @@ def test_conversation_without_mos_is_skipped(aggregator, instance):
149149
aggregator.assert_metric("genesys_mos.conversation.mos.avg", value=4.30, tags=EXPECTED_TAGS)
150150
aggregator.assert_metric("genesys_mos.conversation.mos.min", value=4.30, tags=EXPECTED_TAGS)
151151
aggregator.assert_metric("genesys_mos.conversation.below_threshold.count", value=0, tags=EXPECTED_TAGS)
152-
aggregator.assert_service_check("genesys_mos.can_connect", status=GenesysMosCheck.OK, tags=EXPECTED_TAGS)
152+
aggregator.assert_metric("genesys_mos.can_connect", value=1, tags=EXPECTED_TAGS)

genesys_mos/tests/test_unit.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import pytest
77
from mock import MagicMock, patch
88

9-
from datadog_checks.base import AgentCheck, ConfigurationError
9+
from datadog_checks.base import ConfigurationError
10+
from datadog_checks.dev.utils import get_metadata_metrics
1011
from datadog_checks.genesys_mos import GenesysMosCheck
1112

1213
pytestmark = pytest.mark.unit
@@ -54,7 +55,7 @@ def test_query_interval_is_rfc3339_range(instance):
5455
assert start < end
5556

5657

57-
def test_emits_distribution_gauges_and_ok_service_check(aggregator, instance):
58+
def test_emits_distribution_gauges_and_can_connect(aggregator, instance):
5859
check = _check(instance)
5960
conversations = {"c1": 4.8, "c2": 4.1, "c3": 3.5}
6061

@@ -70,8 +71,10 @@ def test_emits_distribution_gauges_and_ok_service_check(aggregator, instance):
7071
aggregator.assert_metric("genesys_mos.conversation.mos.min", value=3.5, tags=tags)
7172
# threshold 4.2 -> 4.1 and 3.5 are at/below
7273
aggregator.assert_metric("genesys_mos.conversation.below_threshold.count", value=2, tags=tags)
73-
aggregator.assert_service_check("genesys_mos.can_connect", status=AgentCheck.OK, tags=tags)
74+
# Connectivity is reported as a 0/1 gauge, not a service check.
75+
aggregator.assert_metric("genesys_mos.can_connect", value=1, tags=tags)
7476
aggregator.assert_all_metrics_covered()
77+
aggregator.assert_metrics_using_metadata(get_metadata_metrics())
7578

7679

7780
def test_no_conversations_reports_zero(aggregator, instance):
@@ -88,16 +91,16 @@ def test_no_conversations_reports_zero(aggregator, instance):
8891
# No quality gauges when there is no data.
8992
aggregator.assert_metric("genesys_mos.conversation.mos.avg", count=0)
9093
aggregator.assert_metric("genesys_mos.conversation.mos.min", count=0)
91-
aggregator.assert_service_check("genesys_mos.can_connect", status=AgentCheck.OK)
94+
aggregator.assert_metric("genesys_mos.can_connect", value=1)
9295

9396

94-
def test_auth_failure_reports_critical_and_raises(aggregator, instance):
97+
def test_auth_failure_reports_can_connect_zero_and_raises(aggregator, instance):
9598
check = _check(instance)
9699
with patch.object(check, "_authenticate", side_effect=RuntimeError("bad secret")):
97100
with pytest.raises(RuntimeError, match="bad secret"):
98101
check.check(None)
99102

100-
aggregator.assert_service_check("genesys_mos.can_connect", status=AgentCheck.CRITICAL)
103+
aggregator.assert_metric("genesys_mos.can_connect", value=0)
101104
aggregator.assert_metric("genesys_mos.conversation.count", count=0)
102105

103106

0 commit comments

Comments
 (0)