Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lustre/changelog.d/20857.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix typo in OSS parameter
2 changes: 1 addition & 1 deletion lustre/datadog_checks/lustre/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ class LustreParam:
fixture='mds_mgs_export_stats.txt',
),
# OSS (Object Storage Server) params
LustreParam(regex='ost.OSS.oss.stats', node_types=('oss',), prefix='oss', fixture='oss_ost_stats.txt'),
LustreParam(regex='ost.OSS.ost.stats', node_types=('oss',), prefix='oss', fixture='oss_ost_stats.txt'),
LustreParam(
regex='osc.*.stats',
node_types=('client',),
Expand Down
7 changes: 5 additions & 2 deletions proxmox/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@
},
"metrics": {
"prefix": "proxmox.",
"check": "proxmox.api.up",
"check": [
"proxmox.api.up",
"proxmox.cpu"
],
"metadata_path": "metadata.csv"
},
"process_signatures": [
Expand Down Expand Up @@ -64,4 +67,4 @@
"homepage": "https://www.datadoghq.com",
"sales_email": "info@datadoghq.com"
}
}
}
1 change: 1 addition & 0 deletions tibco_ems/changelog.d/20859.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix leak of tags across check runs.
14 changes: 9 additions & 5 deletions tibco_ems/datadog_checks/tibco_ems/tibco_ems.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def __init__(self, name, init_config, instances):
script_path = self.instance.get('script_path')
server_string = CONNECTION_STRING.format(host, port)
self.tags = self.instance.get('tags', [])
self.parsed_data = {}

self.cmd = tibemsadmin_cmd + [
'-server',
Expand All @@ -55,18 +54,20 @@ def check(self, _):
sections = self._section_output(cleaned_data)

# Parse the output
parsed_data = {}
for command, section in sections.items():
pattern = SHOW_METRIC_DATA[command]['regex']
if command == 'show server':
self.parsed_data[command] = self._parse_show_server(section, pattern)
parsed_data[command] = self._parse_show_server(section, pattern)
else:
try:
self.parsed_data[command] = self._parse_factory(section, pattern)
parsed_data[command] = self._parse_factory(section, pattern)
except Exception as e:
self.log.error('Error parsing command %s: %s', command, e)
continue

for command, metric_info in self.parsed_data.items():
for command, metric_info in parsed_data.items():
self.log.debug("Processing output from %s command", command)
metric_keys = SHOW_METRIC_DATA[command]['metric_keys']
tag_keys = SHOW_METRIC_DATA[command]['tags']
metric_prefix = SHOW_METRIC_DATA[command]['metric_prefix']
Expand Down Expand Up @@ -205,11 +206,14 @@ def sanitize_name(name):
return data

def _submit_metrics_factory(self, prefix, metric_data, metric_names, tag_keys):
self.log.debug("Submitting %s metrics (%s tags) for %s", len(metric_names), len(tag_keys), prefix)
tags = []
for key in tag_keys:
if prefix == 'server':
# Add server tags to all metrics
self.tags.append(f"server_{key}:{metric_data[key]}")
server_tag = f"server_{key}:{metric_data[key]}"
if server_tag not in self.tags:
self.tags.append(server_tag)
else:
if metric_data.get(key):
tags.append(f"{key}:{metric_data[key]}")
Expand Down
17 changes: 14 additions & 3 deletions tibco_ems/tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)

from typing import Any, Callable, Dict # noqa: F401
from unittest.mock import MagicMock

import pytest

from datadog_checks.base import AgentCheck # noqa: F401
from datadog_checks.base.stubs.aggregator import AggregatorStub # noqa: F401
from datadog_checks.dev.utils import get_metadata_metrics
from datadog_checks.tibco_ems import TibcoEMSCheck

Expand Down Expand Up @@ -152,3 +149,17 @@ def test_parse_factory(data, regex, expected_result):
result = check._parse_factory(data.decode('utf-8'), regex)

assert result == expected_result


def test_base_tags(dd_run_check, instance):
check = TibcoEMSCheck('tibco_ems', {}, [instance])
check.run_tibco_command = MagicMock(return_value=mock_output('show_all'))
dd_run_check(check)
assert len(check.tags) == 3

dd_run_check(check)
dd_run_check(check)
dd_run_check(check)

# assert the lenght of tags does not grow indefinitely
assert len(check.tags) == 3
Loading