partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | MySql._get_slave_status | Retrieve the slaves' statuses using:
1. The `performance_schema.threads` table. Non-blocking, requires version > 5.6.0
2. The `information_schema.processlist` table. Blocking | mysql/datadog_checks/mysql/mysql.py | def _get_slave_status(self, db, above_560, nonblocking):
"""
Retrieve the slaves' statuses using:
1. The `performance_schema.threads` table. Non-blocking, requires version > 5.6.0
2. The `information_schema.processlist` table. Blocking
"""
try:
with closing(db... | def _get_slave_status(self, db, above_560, nonblocking):
"""
Retrieve the slaves' statuses using:
1. The `performance_schema.threads` table. Non-blocking, requires version > 5.6.0
2. The `information_schema.processlist` table. Blocking
"""
try:
with closing(db... | [
"Retrieve",
"the",
"slaves",
"statuses",
"using",
":",
"1",
".",
"The",
"performance_schema",
".",
"threads",
"table",
".",
"Non",
"-",
"blocking",
"requires",
"version",
">",
"5",
".",
"6",
".",
"0",
"2",
".",
"The",
"information_schema",
".",
"processlis... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/mysql/datadog_checks/mysql/mysql.py#L914-L937 | [
"def",
"_get_slave_status",
"(",
"self",
",",
"db",
",",
"above_560",
",",
"nonblocking",
")",
":",
"try",
":",
"with",
"closing",
"(",
"db",
".",
"cursor",
"(",
")",
")",
"as",
"cursor",
":",
"if",
"above_560",
"and",
"nonblocking",
":",
"# Query `perfo... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | MapReduceCheck._parse_general_counters | Return a dictionary for each job counter
{
counter_group_name: [
counter_name
]
}
} | mapreduce/datadog_checks/mapreduce/mapreduce.py | def _parse_general_counters(self, init_config):
"""
Return a dictionary for each job counter
{
counter_group_name: [
counter_name
]
}
}
"""
job_counter = {}
if init_config.get('general_counters'):
# Parse... | def _parse_general_counters(self, init_config):
"""
Return a dictionary for each job counter
{
counter_group_name: [
counter_name
]
}
}
"""
job_counter = {}
if init_config.get('general_counters'):
# Parse... | [
"Return",
"a",
"dictionary",
"for",
"each",
"job",
"counter",
"{",
"counter_group_name",
":",
"[",
"counter_name",
"]",
"}",
"}"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/mapreduce/datadog_checks/mapreduce/mapreduce.py#L181-L218 | [
"def",
"_parse_general_counters",
"(",
"self",
",",
"init_config",
")",
":",
"job_counter",
"=",
"{",
"}",
"if",
"init_config",
".",
"get",
"(",
"'general_counters'",
")",
":",
"# Parse the custom metrics",
"for",
"counter_group",
"in",
"init_config",
"[",
"'gener... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | MapReduceCheck._parse_job_specific_counters | Return a dictionary for each job counter
{
job_name: {
counter_group_name: [
counter_name
]
}
}
} | mapreduce/datadog_checks/mapreduce/mapreduce.py | def _parse_job_specific_counters(self, init_config):
"""
Return a dictionary for each job counter
{
job_name: {
counter_group_name: [
counter_name
]
}
}
}
"""
job_counter = {}
if init_confi... | def _parse_job_specific_counters(self, init_config):
"""
Return a dictionary for each job counter
{
job_name: {
counter_group_name: [
counter_name
]
}
}
}
"""
job_counter = {}
if init_confi... | [
"Return",
"a",
"dictionary",
"for",
"each",
"job",
"counter",
"{",
"job_name",
":",
"{",
"counter_group_name",
":",
"[",
"counter_name",
"]",
"}",
"}",
"}"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/mapreduce/datadog_checks/mapreduce/mapreduce.py#L220-L273 | [
"def",
"_parse_job_specific_counters",
"(",
"self",
",",
"init_config",
")",
":",
"job_counter",
"=",
"{",
"}",
"if",
"init_config",
".",
"get",
"(",
"'job_specific_counters'",
")",
":",
"# Parse the custom metrics",
"for",
"job",
"in",
"init_config",
"[",
"'job_s... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | MapReduceCheck._get_running_app_ids | Return a dictionary of {app_id: (app_name, tracking_url)} for the running MapReduce applications | mapreduce/datadog_checks/mapreduce/mapreduce.py | def _get_running_app_ids(self, rm_address, auth, ssl_verify):
"""
Return a dictionary of {app_id: (app_name, tracking_url)} for the running MapReduce applications
"""
metrics_json = self._rest_request_to_json(
rm_address,
auth,
ssl_verify,
... | def _get_running_app_ids(self, rm_address, auth, ssl_verify):
"""
Return a dictionary of {app_id: (app_name, tracking_url)} for the running MapReduce applications
"""
metrics_json = self._rest_request_to_json(
rm_address,
auth,
ssl_verify,
... | [
"Return",
"a",
"dictionary",
"of",
"{",
"app_id",
":",
"(",
"app_name",
"tracking_url",
")",
"}",
"for",
"the",
"running",
"MapReduce",
"applications"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/mapreduce/datadog_checks/mapreduce/mapreduce.py#L275-L302 | [
"def",
"_get_running_app_ids",
"(",
"self",
",",
"rm_address",
",",
"auth",
",",
"ssl_verify",
")",
":",
"metrics_json",
"=",
"self",
".",
"_rest_request_to_json",
"(",
"rm_address",
",",
"auth",
",",
"ssl_verify",
",",
"self",
".",
"YARN_APPS_PATH",
",",
"sel... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | MapReduceCheck._mapreduce_job_metrics | Get metrics for each MapReduce job.
Return a dictionary for each MapReduce job
{
job_id: {
'job_name': job_name,
'app_name': app_name,
'user_name': user_name,
'tracking_url': tracking_url
} | mapreduce/datadog_checks/mapreduce/mapreduce.py | def _mapreduce_job_metrics(self, running_apps, auth, ssl_verify, addl_tags):
"""
Get metrics for each MapReduce job.
Return a dictionary for each MapReduce job
{
job_id: {
'job_name': job_name,
'app_name': app_name,
'user_name': user_name,
... | def _mapreduce_job_metrics(self, running_apps, auth, ssl_verify, addl_tags):
"""
Get metrics for each MapReduce job.
Return a dictionary for each MapReduce job
{
job_id: {
'job_name': job_name,
'app_name': app_name,
'user_name': user_name,
... | [
"Get",
"metrics",
"for",
"each",
"MapReduce",
"job",
".",
"Return",
"a",
"dictionary",
"for",
"each",
"MapReduce",
"job",
"{",
"job_id",
":",
"{",
"job_name",
":",
"job_name",
"app_name",
":",
"app_name",
"user_name",
":",
"user_name",
"tracking_url",
":",
"... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/mapreduce/datadog_checks/mapreduce/mapreduce.py#L304-L352 | [
"def",
"_mapreduce_job_metrics",
"(",
"self",
",",
"running_apps",
",",
"auth",
",",
"ssl_verify",
",",
"addl_tags",
")",
":",
"running_jobs",
"=",
"{",
"}",
"for",
"app_name",
",",
"tracking_url",
"in",
"itervalues",
"(",
"running_apps",
")",
":",
"metrics_js... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | MapReduceCheck._mapreduce_job_counters_metrics | Get custom metrics specified for each counter | mapreduce/datadog_checks/mapreduce/mapreduce.py | def _mapreduce_job_counters_metrics(self, running_jobs, auth, ssl_verify, addl_tags):
"""
Get custom metrics specified for each counter
"""
for job_metrics in itervalues(running_jobs):
job_name = job_metrics['job_name']
# Check if the job_name exist in the custom... | def _mapreduce_job_counters_metrics(self, running_jobs, auth, ssl_verify, addl_tags):
"""
Get custom metrics specified for each counter
"""
for job_metrics in itervalues(running_jobs):
job_name = job_metrics['job_name']
# Check if the job_name exist in the custom... | [
"Get",
"custom",
"metrics",
"specified",
"for",
"each",
"counter"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/mapreduce/datadog_checks/mapreduce/mapreduce.py#L354-L411 | [
"def",
"_mapreduce_job_counters_metrics",
"(",
"self",
",",
"running_jobs",
",",
"auth",
",",
"ssl_verify",
",",
"addl_tags",
")",
":",
"for",
"job_metrics",
"in",
"itervalues",
"(",
"running_jobs",
")",
":",
"job_name",
"=",
"job_metrics",
"[",
"'job_name'",
"]... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | MapReduceCheck._mapreduce_task_metrics | Get metrics for each MapReduce task
Return a dictionary of {task_id: 'tracking_url'} for each MapReduce task | mapreduce/datadog_checks/mapreduce/mapreduce.py | def _mapreduce_task_metrics(self, running_jobs, auth, ssl_verify, addl_tags):
"""
Get metrics for each MapReduce task
Return a dictionary of {task_id: 'tracking_url'} for each MapReduce task
"""
for job_stats in itervalues(running_jobs):
metrics_json = self._rest_req... | def _mapreduce_task_metrics(self, running_jobs, auth, ssl_verify, addl_tags):
"""
Get metrics for each MapReduce task
Return a dictionary of {task_id: 'tracking_url'} for each MapReduce task
"""
for job_stats in itervalues(running_jobs):
metrics_json = self._rest_req... | [
"Get",
"metrics",
"for",
"each",
"MapReduce",
"task",
"Return",
"a",
"dictionary",
"of",
"{",
"task_id",
":",
"tracking_url",
"}",
"for",
"each",
"MapReduce",
"task"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/mapreduce/datadog_checks/mapreduce/mapreduce.py#L413-L444 | [
"def",
"_mapreduce_task_metrics",
"(",
"self",
",",
"running_jobs",
",",
"auth",
",",
"ssl_verify",
",",
"addl_tags",
")",
":",
"for",
"job_stats",
"in",
"itervalues",
"(",
"running_jobs",
")",
":",
"metrics_json",
"=",
"self",
".",
"_rest_request_to_json",
"(",... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | MapReduceCheck._set_metrics_from_json | Parse the JSON response and set the metrics | mapreduce/datadog_checks/mapreduce/mapreduce.py | def _set_metrics_from_json(self, metrics_json, metrics, tags):
"""
Parse the JSON response and set the metrics
"""
for status, (metric_name, metric_type) in iteritems(metrics):
metric_status = metrics_json.get(status)
if metric_status is not None:
... | def _set_metrics_from_json(self, metrics_json, metrics, tags):
"""
Parse the JSON response and set the metrics
"""
for status, (metric_name, metric_type) in iteritems(metrics):
metric_status = metrics_json.get(status)
if metric_status is not None:
... | [
"Parse",
"the",
"JSON",
"response",
"and",
"set",
"the",
"metrics"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/mapreduce/datadog_checks/mapreduce/mapreduce.py#L446-L454 | [
"def",
"_set_metrics_from_json",
"(",
"self",
",",
"metrics_json",
",",
"metrics",
",",
"tags",
")",
":",
"for",
"status",
",",
"(",
"metric_name",
",",
"metric_type",
")",
"in",
"iteritems",
"(",
"metrics",
")",
":",
"metric_status",
"=",
"metrics_json",
".... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | MapReduceCheck._set_metric | Set a metric | mapreduce/datadog_checks/mapreduce/mapreduce.py | def _set_metric(self, metric_name, metric_type, value, tags=None, device_name=None):
"""
Set a metric
"""
if metric_type == self.HISTOGRAM:
self.histogram(metric_name, value, tags=tags, device_name=device_name)
elif metric_type == self.INCREMENT:
self.incr... | def _set_metric(self, metric_name, metric_type, value, tags=None, device_name=None):
"""
Set a metric
"""
if metric_type == self.HISTOGRAM:
self.histogram(metric_name, value, tags=tags, device_name=device_name)
elif metric_type == self.INCREMENT:
self.incr... | [
"Set",
"a",
"metric"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/mapreduce/datadog_checks/mapreduce/mapreduce.py#L456-L465 | [
"def",
"_set_metric",
"(",
"self",
",",
"metric_name",
",",
"metric_type",
",",
"value",
",",
"tags",
"=",
"None",
",",
"device_name",
"=",
"None",
")",
":",
"if",
"metric_type",
"==",
"self",
".",
"HISTOGRAM",
":",
"self",
".",
"histogram",
"(",
"metric... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | MapReduceCheck._rest_request_to_json | Query the given URL and return the JSON response | mapreduce/datadog_checks/mapreduce/mapreduce.py | def _rest_request_to_json(self, address, auth, ssl_verify, object_path, service_name, tags=None, *args, **kwargs):
"""
Query the given URL and return the JSON response
"""
response_json = None
tags = [] if tags is None else tags
service_check_tags = ['url:{}'.format(self... | def _rest_request_to_json(self, address, auth, ssl_verify, object_path, service_name, tags=None, *args, **kwargs):
"""
Query the given URL and return the JSON response
"""
response_json = None
tags = [] if tags is None else tags
service_check_tags = ['url:{}'.format(self... | [
"Query",
"the",
"given",
"URL",
"and",
"return",
"the",
"JSON",
"response"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/mapreduce/datadog_checks/mapreduce/mapreduce.py#L467-L529 | [
"def",
"_rest_request_to_json",
"(",
"self",
",",
"address",
",",
"auth",
",",
"ssl_verify",
",",
"object_path",
",",
"service_name",
",",
"tags",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"response_json",
"=",
"None",
"tags",
"="... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | AgentMetrics._psutil_config_to_stats | Reads `init_config` for `psutil` methods to call on the current process
Calls those methods and stores the raw output
:returns a dictionary of statistic_name: value | agent_metrics/datadog_checks/agent_metrics/agent_metrics.py | def _psutil_config_to_stats(self, instance):
"""
Reads `init_config` for `psutil` methods to call on the current process
Calls those methods and stores the raw output
:returns a dictionary of statistic_name: value
"""
process_metrics = instance.get('process_metrics', sel... | def _psutil_config_to_stats(self, instance):
"""
Reads `init_config` for `psutil` methods to call on the current process
Calls those methods and stores the raw output
:returns a dictionary of statistic_name: value
"""
process_metrics = instance.get('process_metrics', sel... | [
"Reads",
"init_config",
"for",
"psutil",
"methods",
"to",
"call",
"on",
"the",
"current",
"process",
"Calls",
"those",
"methods",
"and",
"stores",
"the",
"raw",
"output"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/agent_metrics/datadog_checks/agent_metrics/agent_metrics.py#L53-L75 | [
"def",
"_psutil_config_to_stats",
"(",
"self",
",",
"instance",
")",
":",
"process_metrics",
"=",
"instance",
".",
"get",
"(",
"'process_metrics'",
",",
"self",
".",
"init_config",
".",
"get",
"(",
"'process_metrics'",
",",
"None",
")",
")",
"if",
"not",
"pr... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | AgentMetrics._register_psutil_metrics | Saves sample metrics from psutil
:param stats: a dictionary that looks like:
{
'memory_info': OrderedDict([('rss', 24395776), ('vms', 144666624)]),
'io_counters': OrderedDict([('read_count', 4536),
('write_count', 100),
... | agent_metrics/datadog_checks/agent_metrics/agent_metrics.py | def _register_psutil_metrics(self, stats, names_to_metric_types, tags=None):
"""
Saves sample metrics from psutil
:param stats: a dictionary that looks like:
{
'memory_info': OrderedDict([('rss', 24395776), ('vms', 144666624)]),
'io_counters': OrderedDict([('read_count... | def _register_psutil_metrics(self, stats, names_to_metric_types, tags=None):
"""
Saves sample metrics from psutil
:param stats: a dictionary that looks like:
{
'memory_info': OrderedDict([('rss', 24395776), ('vms', 144666624)]),
'io_counters': OrderedDict([('read_count... | [
"Saves",
"sample",
"metrics",
"from",
"psutil"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/agent_metrics/datadog_checks/agent_metrics/agent_metrics.py#L87-L117 | [
"def",
"_register_psutil_metrics",
"(",
"self",
",",
"stats",
",",
"names_to_metric_types",
",",
"tags",
"=",
"None",
")",
":",
"if",
"tags",
"is",
"None",
":",
"tags",
"=",
"[",
"]",
"base_metric",
"=",
"'datadog.agent.collector.{0}.{1}'",
"# TODO: May have to ca... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | get_container_ip | Get a Docker container's IP address from its id or name. | datadog_checks_dev/datadog_checks/dev/docker.py | def get_container_ip(container_id_or_name):
"""Get a Docker container's IP address from its id or name."""
command = [
'docker',
'inspect',
'-f',
'{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}',
container_id_or_name,
]
return run_command(command, captu... | def get_container_ip(container_id_or_name):
"""Get a Docker container's IP address from its id or name."""
command = [
'docker',
'inspect',
'-f',
'{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}',
container_id_or_name,
]
return run_command(command, captu... | [
"Get",
"a",
"Docker",
"container",
"s",
"IP",
"address",
"from",
"its",
"id",
"or",
"name",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_dev/datadog_checks/dev/docker.py#L20-L30 | [
"def",
"get_container_ip",
"(",
"container_id_or_name",
")",
":",
"command",
"=",
"[",
"'docker'",
",",
"'inspect'",
",",
"'-f'",
",",
"'{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'",
",",
"container_id_or_name",
",",
"]",
"return",
"run_command",
"(",
"com... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | docker_run | This utility provides a convenient way to safely set up and tear down Docker environments.
:param compose_file: A path to a Docker compose file. A custom tear
down is not required when using this.
:type compose_file: ``str``
:param build: Whether or not to build images for when ``c... | datadog_checks_dev/datadog_checks/dev/docker.py | def docker_run(
compose_file=None,
build=False,
service_name=None,
up=None,
down=None,
sleep=None,
endpoints=None,
log_patterns=None,
conditions=None,
env_vars=None,
wrapper=None,
):
"""This utility provides a convenient way to safely set up and tear down Docker environme... | def docker_run(
compose_file=None,
build=False,
service_name=None,
up=None,
down=None,
sleep=None,
endpoints=None,
log_patterns=None,
conditions=None,
env_vars=None,
wrapper=None,
):
"""This utility provides a convenient way to safely set up and tear down Docker environme... | [
"This",
"utility",
"provides",
"a",
"convenient",
"way",
"to",
"safely",
"set",
"up",
"and",
"tear",
"down",
"Docker",
"environments",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_dev/datadog_checks/dev/docker.py#L45-L124 | [
"def",
"docker_run",
"(",
"compose_file",
"=",
"None",
",",
"build",
"=",
"False",
",",
"service_name",
"=",
"None",
",",
"up",
"=",
"None",
",",
"down",
"=",
"None",
",",
"sleep",
"=",
"None",
",",
"endpoints",
"=",
"None",
",",
"log_patterns",
"=",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | DBRef.as_doc | Get the SON document representation of this DBRef.
Generally not needed by application developers | tokumx/datadog_checks/tokumx/vendor/bson/dbref.py | def as_doc(self):
"""Get the SON document representation of this DBRef.
Generally not needed by application developers
"""
doc = SON([("$ref", self.collection),
("$id", self.id)])
if self.database is not None:
doc["$db"] = self.database
doc... | def as_doc(self):
"""Get the SON document representation of this DBRef.
Generally not needed by application developers
"""
doc = SON([("$ref", self.collection),
("$id", self.id)])
if self.database is not None:
doc["$db"] = self.database
doc... | [
"Get",
"the",
"SON",
"document",
"representation",
"of",
"this",
"DBRef",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/bson/dbref.py#L93-L103 | [
"def",
"as_doc",
"(",
"self",
")",
":",
"doc",
"=",
"SON",
"(",
"[",
"(",
"\"$ref\"",
",",
"self",
".",
"collection",
")",
",",
"(",
"\"$id\"",
",",
"self",
".",
"id",
")",
"]",
")",
"if",
"self",
".",
"database",
"is",
"not",
"None",
":",
"doc... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | CacheConfig.clear | Reset the config object to its initial state | vsphere/datadog_checks/vsphere/cache_config.py | def clear(self):
"""
Reset the config object to its initial state
"""
with self._lock:
self._config = {
CacheConfig.Morlist: {'last': defaultdict(float), 'intl': {}},
CacheConfig.Metadata: {'last': defaultdict(float), 'intl': {}},
} | def clear(self):
"""
Reset the config object to its initial state
"""
with self._lock:
self._config = {
CacheConfig.Morlist: {'last': defaultdict(float), 'intl': {}},
CacheConfig.Metadata: {'last': defaultdict(float), 'intl': {}},
} | [
"Reset",
"the",
"config",
"object",
"to",
"its",
"initial",
"state"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/vsphere/datadog_checks/vsphere/cache_config.py#L29-L37 | [
"def",
"clear",
"(",
"self",
")",
":",
"with",
"self",
".",
"_lock",
":",
"self",
".",
"_config",
"=",
"{",
"CacheConfig",
".",
"Morlist",
":",
"{",
"'last'",
":",
"defaultdict",
"(",
"float",
")",
",",
"'intl'",
":",
"{",
"}",
"}",
",",
"CacheConf... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | CacheConfig.get_last | Notice: this will return the defaultdict default value also for keys
that are not in the configuration, this is a tradeoff to keep the code simple. | vsphere/datadog_checks/vsphere/cache_config.py | def get_last(self, type_, key):
"""
Notice: this will return the defaultdict default value also for keys
that are not in the configuration, this is a tradeoff to keep the code simple.
"""
self._check_type(type_)
with self._lock:
return self._config[type_]['las... | def get_last(self, type_, key):
"""
Notice: this will return the defaultdict default value also for keys
that are not in the configuration, this is a tradeoff to keep the code simple.
"""
self._check_type(type_)
with self._lock:
return self._config[type_]['las... | [
"Notice",
":",
"this",
"will",
"return",
"the",
"defaultdict",
"default",
"value",
"also",
"for",
"keys",
"that",
"are",
"not",
"in",
"the",
"configuration",
"this",
"is",
"a",
"tradeoff",
"to",
"keep",
"the",
"code",
"simple",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/vsphere/datadog_checks/vsphere/cache_config.py#L44-L51 | [
"def",
"get_last",
"(",
"self",
",",
"type_",
",",
"key",
")",
":",
"self",
".",
"_check_type",
"(",
"type_",
")",
"with",
"self",
".",
"_lock",
":",
"return",
"self",
".",
"_config",
"[",
"type_",
"]",
"[",
"'last'",
"]",
"[",
"key",
"]"
] | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | _get_ca_certs_paths | Get a list of possible paths containing certificates
Check is installed via pip to:
* Windows: embedded/lib/site-packages/datadog_checks/http_check
* Linux: embedded/lib/python2.7/site-packages/datadog_checks/http_check
Certificate is installed to:
* embedded/ssl/certs/cacert.pem
walk up t... | http_check/datadog_checks/http_check/utils.py | def _get_ca_certs_paths():
"""
Get a list of possible paths containing certificates
Check is installed via pip to:
* Windows: embedded/lib/site-packages/datadog_checks/http_check
* Linux: embedded/lib/python2.7/site-packages/datadog_checks/http_check
Certificate is installed to:
* embed... | def _get_ca_certs_paths():
"""
Get a list of possible paths containing certificates
Check is installed via pip to:
* Windows: embedded/lib/site-packages/datadog_checks/http_check
* Linux: embedded/lib/python2.7/site-packages/datadog_checks/http_check
Certificate is installed to:
* embed... | [
"Get",
"a",
"list",
"of",
"possible",
"paths",
"containing",
"certificates"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/http_check/datadog_checks/http_check/utils.py#L17-L53 | [
"def",
"_get_ca_certs_paths",
"(",
")",
":",
"ca_certs",
"=",
"[",
"]",
"embedded_root",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"__file__",
")",
")",
"for",
"_",
"in",
"range",
"(",
"10",
")",
":",
"if"... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | logos | Validate logo files. Specifying no check will validate all logos | datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/logos.py | def logos(check):
"""Validate logo files. Specifying no check will validate all logos"""
valid_checks = get_valid_integrations()
if check:
if check in valid_checks:
checks = [check]
else:
echo_info('{} is not an integration.'.format(check))
return
el... | def logos(check):
"""Validate logo files. Specifying no check will validate all logos"""
valid_checks = get_valid_integrations()
if check:
if check in valid_checks:
checks = [check]
else:
echo_info('{} is not an integration.'.format(check))
return
el... | [
"Validate",
"logo",
"files",
".",
"Specifying",
"no",
"check",
"will",
"validate",
"all",
"logos"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/logos.py#L20-L78 | [
"def",
"logos",
"(",
"check",
")",
":",
"valid_checks",
"=",
"get_valid_integrations",
"(",
")",
"if",
"check",
":",
"if",
"check",
"in",
"valid_checks",
":",
"checks",
"=",
"[",
"check",
"]",
"else",
":",
"echo_info",
"(",
"'{} is not an integration.'",
"."... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Varnish._parse_varnishstat | The text option (-1) is not reliable enough when counters get large.
VBE.media_video_prd_services_01(10.93.67.16,,8080).happy18446744073709551615
2 types of data, "a" for counter ("c" in newer versions of varnish), "i" for gauge ("g")
https://github.com/varnish/Varnish-Cache/blob/master/include... | varnish/datadog_checks/varnish/varnish.py | def _parse_varnishstat(self, output, varnishstat_format, tags=None):
"""
The text option (-1) is not reliable enough when counters get large.
VBE.media_video_prd_services_01(10.93.67.16,,8080).happy18446744073709551615
2 types of data, "a" for counter ("c" in newer versions of varnish),... | def _parse_varnishstat(self, output, varnishstat_format, tags=None):
"""
The text option (-1) is not reliable enough when counters get large.
VBE.media_video_prd_services_01(10.93.67.16,,8080).happy18446744073709551615
2 types of data, "a" for counter ("c" in newer versions of varnish),... | [
"The",
"text",
"option",
"(",
"-",
"1",
")",
"is",
"not",
"reliable",
"enough",
"when",
"counters",
"get",
"large",
".",
"VBE",
".",
"media_video_prd_services_01",
"(",
"10",
".",
"93",
".",
"67",
".",
"16",
"8080",
")",
".",
"happy18446744073709551615"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/varnish/datadog_checks/varnish/varnish.py#L199-L254 | [
"def",
"_parse_varnishstat",
"(",
"self",
",",
"output",
",",
"varnishstat_format",
",",
"tags",
"=",
"None",
")",
":",
"tags",
"=",
"tags",
"or",
"[",
"]",
"# FIXME: this check is processing an unbounded amount of data",
"# we should explicitly list the metrics we want to ... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Varnish._parse_varnishadm | Parse out service checks from varnishadm.
Example output:
Backend b0 is Sick
Current states good: 2 threshold: 3 window: 5
Average responsetime of good probes: 0.000000
Oldest Newest
============... | varnish/datadog_checks/varnish/varnish.py | def _parse_varnishadm(self, output, tags):
""" Parse out service checks from varnishadm.
Example output:
Backend b0 is Sick
Current states good: 2 threshold: 3 window: 5
Average responsetime of good probes: 0.000000
Oldest ... | def _parse_varnishadm(self, output, tags):
""" Parse out service checks from varnishadm.
Example output:
Backend b0 is Sick
Current states good: 2 threshold: 3 window: 5
Average responsetime of good probes: 0.000000
Oldest ... | [
"Parse",
"out",
"service",
"checks",
"from",
"varnishadm",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/varnish/datadog_checks/varnish/varnish.py#L256-L333 | [
"def",
"_parse_varnishadm",
"(",
"self",
",",
"output",
",",
"tags",
")",
":",
"# Process status by backend.",
"backends_by_status",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"line",
"in",
"output",
".",
"split",
"(",
"\"\\n\"",
")",
":",
"backend",
",",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | PrometheusScraperMixin.parse_metric_family | Parse the MetricFamily from a valid requests.Response object to provide a MetricFamily object (see [0])
The text format uses iter_lines() generator.
The protobuf format directly parse the response.content property searching for Prometheus messages of type
MetricFamily [0] delimited by a varint... | datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py | def parse_metric_family(self, response):
"""
Parse the MetricFamily from a valid requests.Response object to provide a MetricFamily object (see [0])
The text format uses iter_lines() generator.
The protobuf format directly parse the response.content property searching for Prometheus me... | def parse_metric_family(self, response):
"""
Parse the MetricFamily from a valid requests.Response object to provide a MetricFamily object (see [0])
The text format uses iter_lines() generator.
The protobuf format directly parse the response.content property searching for Prometheus me... | [
"Parse",
"the",
"MetricFamily",
"from",
"a",
"valid",
"requests",
".",
"Response",
"object",
"to",
"provide",
"a",
"MetricFamily",
"object",
"(",
"see",
"[",
"0",
"]",
")"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py#L167-L237 | [
"def",
"parse_metric_family",
"(",
"self",
",",
"response",
")",
":",
"if",
"'application/vnd.google.protobuf'",
"in",
"response",
".",
"headers",
"[",
"'Content-Type'",
"]",
":",
"n",
"=",
"0",
"buf",
"=",
"response",
".",
"content",
"while",
"n",
"<",
"len... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | PrometheusScraperMixin._text_filter_input | Filters out the text input line by line to avoid parsing and processing
metrics we know we don't want to process. This only works on `text/plain`
payloads, and is an INTERNAL FEATURE implemented for the kubelet check
:param input_get: line generator
:output: generator of filtered lines | datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py | def _text_filter_input(self, input_gen):
"""
Filters out the text input line by line to avoid parsing and processing
metrics we know we don't want to process. This only works on `text/plain`
payloads, and is an INTERNAL FEATURE implemented for the kubelet check
:param input_get: ... | def _text_filter_input(self, input_gen):
"""
Filters out the text input line by line to avoid parsing and processing
metrics we know we don't want to process. This only works on `text/plain`
payloads, and is an INTERNAL FEATURE implemented for the kubelet check
:param input_get: ... | [
"Filters",
"out",
"the",
"text",
"input",
"line",
"by",
"line",
"to",
"avoid",
"parsing",
"and",
"processing",
"metrics",
"we",
"know",
"we",
"don",
"t",
"want",
"to",
"process",
".",
"This",
"only",
"works",
"on",
"text",
"/",
"plain",
"payloads",
"and"... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py#L239-L253 | [
"def",
"_text_filter_input",
"(",
"self",
",",
"input_gen",
")",
":",
"for",
"line",
"in",
"input_gen",
":",
"for",
"item",
"in",
"self",
".",
"_text_filter_blacklist",
":",
"if",
"item",
"in",
"line",
":",
"break",
"else",
":",
"# No blacklist matches, passin... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | PrometheusScraperMixin.get_metric_value_by_labels | :param messages: dictionary as metric_name: {labels: {}, value: 10}
:param _metric: dictionary as {labels: {le: '0.001', 'custom': 'value'}}
:param _m: str as metric name
:param metric_suffix: str must be in (count or sum)
:return: value of the metric_name matched by the labels | datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py | def get_metric_value_by_labels(messages, _metric, _m, metric_suffix):
"""
:param messages: dictionary as metric_name: {labels: {}, value: 10}
:param _metric: dictionary as {labels: {le: '0.001', 'custom': 'value'}}
:param _m: str as metric name
:param metric_suffix: str must be i... | def get_metric_value_by_labels(messages, _metric, _m, metric_suffix):
"""
:param messages: dictionary as metric_name: {labels: {}, value: 10}
:param _metric: dictionary as {labels: {le: '0.001', 'custom': 'value'}}
:param _m: str as metric name
:param metric_suffix: str must be i... | [
":",
"param",
"messages",
":",
"dictionary",
"as",
"metric_name",
":",
"{",
"labels",
":",
"{}",
"value",
":",
"10",
"}",
":",
"param",
"_metric",
":",
"dictionary",
"as",
"{",
"labels",
":",
"{",
"le",
":",
"0",
".",
"001",
"custom",
":",
"value",
... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py#L261-L281 | [
"def",
"get_metric_value_by_labels",
"(",
"messages",
",",
"_metric",
",",
"_m",
",",
"metric_suffix",
")",
":",
"metric_name",
"=",
"'{}_{}'",
".",
"format",
"(",
"_m",
",",
"metric_suffix",
")",
"expected_labels",
"=",
"set",
"(",
"[",
"(",
"k",
",",
"v"... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | PrometheusScraperMixin._extract_metric_from_map | Extracts MetricFamily objects from the maps generated by parsing the
strings in _extract_metrics_from_string | datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py | def _extract_metric_from_map(self, _m, messages, obj_map, obj_help):
"""
Extracts MetricFamily objects from the maps generated by parsing the
strings in _extract_metrics_from_string
"""
_obj = metrics_pb2.MetricFamily()
_obj.name = _m
_obj.type = self.METRIC_TYPES... | def _extract_metric_from_map(self, _m, messages, obj_map, obj_help):
"""
Extracts MetricFamily objects from the maps generated by parsing the
strings in _extract_metrics_from_string
"""
_obj = metrics_pb2.MetricFamily()
_obj.name = _m
_obj.type = self.METRIC_TYPES... | [
"Extracts",
"MetricFamily",
"objects",
"from",
"the",
"maps",
"generated",
"by",
"parsing",
"the",
"strings",
"in",
"_extract_metrics_from_string"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py#L283-L356 | [
"def",
"_extract_metric_from_map",
"(",
"self",
",",
"_m",
",",
"messages",
",",
"obj_map",
",",
"obj_help",
")",
":",
"_obj",
"=",
"metrics_pb2",
".",
"MetricFamily",
"(",
")",
"_obj",
".",
"name",
"=",
"_m",
"_obj",
".",
"type",
"=",
"self",
".",
"ME... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | PrometheusScraperMixin.scrape_metrics | Poll the data from prometheus and return the metrics as a generator. | datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py | def scrape_metrics(self, endpoint):
"""
Poll the data from prometheus and return the metrics as a generator.
"""
response = self.poll(endpoint)
try:
# no dry run if no label joins
if not self.label_joins:
self._dry_run = False
e... | def scrape_metrics(self, endpoint):
"""
Poll the data from prometheus and return the metrics as a generator.
"""
response = self.poll(endpoint)
try:
# no dry run if no label joins
if not self.label_joins:
self._dry_run = False
e... | [
"Poll",
"the",
"data",
"from",
"prometheus",
"and",
"return",
"the",
"metrics",
"as",
"a",
"generator",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py#L358-L384 | [
"def",
"scrape_metrics",
"(",
"self",
",",
"endpoint",
")",
":",
"response",
"=",
"self",
".",
"poll",
"(",
"endpoint",
")",
"try",
":",
"# no dry run if no label joins",
"if",
"not",
"self",
".",
"label_joins",
":",
"self",
".",
"_dry_run",
"=",
"False",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | PrometheusScraperMixin.process | Polls the data from prometheus and pushes them as gauges
`endpoint` is the metrics endpoint to use to poll metrics from Prometheus
Note that if the instance has a 'tags' attribute, it will be pushed
automatically as additional custom tags and added to the metrics | datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py | def process(self, endpoint, **kwargs):
"""
Polls the data from prometheus and pushes them as gauges
`endpoint` is the metrics endpoint to use to poll metrics from Prometheus
Note that if the instance has a 'tags' attribute, it will be pushed
automatically as additional custom ta... | def process(self, endpoint, **kwargs):
"""
Polls the data from prometheus and pushes them as gauges
`endpoint` is the metrics endpoint to use to poll metrics from Prometheus
Note that if the instance has a 'tags' attribute, it will be pushed
automatically as additional custom ta... | [
"Polls",
"the",
"data",
"from",
"prometheus",
"and",
"pushes",
"them",
"as",
"gauges",
"endpoint",
"is",
"the",
"metrics",
"endpoint",
"to",
"use",
"to",
"poll",
"metrics",
"from",
"Prometheus"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py#L386-L399 | [
"def",
"process",
"(",
"self",
",",
"endpoint",
",",
"*",
"*",
"kwargs",
")",
":",
"instance",
"=",
"kwargs",
".",
"get",
"(",
"'instance'",
")",
"if",
"instance",
":",
"kwargs",
"[",
"'custom_tags'",
"]",
"=",
"instance",
".",
"get",
"(",
"'tags'",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | PrometheusScraperMixin.process_metric | Handle a prometheus metric message according to the following flow:
- search self.metrics_mapper for a prometheus.metric <--> datadog.metric mapping
- call check method with the same name as the metric
- log some info if none of the above worked
`send_histograms_buckets` is ... | datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py | def process_metric(self, message, **kwargs):
"""
Handle a prometheus metric message according to the following flow:
- search self.metrics_mapper for a prometheus.metric <--> datadog.metric mapping
- call check method with the same name as the metric
- log some info i... | def process_metric(self, message, **kwargs):
"""
Handle a prometheus metric message according to the following flow:
- search self.metrics_mapper for a prometheus.metric <--> datadog.metric mapping
- call check method with the same name as the metric
- log some info i... | [
"Handle",
"a",
"prometheus",
"metric",
"message",
"according",
"to",
"the",
"following",
"flow",
":",
"-",
"search",
"self",
".",
"metrics_mapper",
"for",
"a",
"prometheus",
".",
"metric",
"<",
"--",
">",
"datadog",
".",
"metric",
"mapping",
"-",
"call",
"... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py#L437-L492 | [
"def",
"process_metric",
"(",
"self",
",",
"message",
",",
"*",
"*",
"kwargs",
")",
":",
"# If targeted metric, store labels",
"self",
".",
"store_labels",
"(",
"message",
")",
"if",
"message",
".",
"name",
"in",
"self",
".",
"ignore_metrics",
":",
"return",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | PrometheusScraperMixin.poll | Polls the metrics from the prometheus metrics endpoint provided.
Defaults to the protobuf format, but can use the formats specified by
the PrometheusFormat class.
Custom headers can be added to the default headers.
Returns a valid requests.Response, raise requests.HTTPError if the statu... | datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py | def poll(self, endpoint, pFormat=PrometheusFormat.PROTOBUF, headers=None):
"""
Polls the metrics from the prometheus metrics endpoint provided.
Defaults to the protobuf format, but can use the formats specified by
the PrometheusFormat class.
Custom headers can be added to the def... | def poll(self, endpoint, pFormat=PrometheusFormat.PROTOBUF, headers=None):
"""
Polls the metrics from the prometheus metrics endpoint provided.
Defaults to the protobuf format, but can use the formats specified by
the PrometheusFormat class.
Custom headers can be added to the def... | [
"Polls",
"the",
"metrics",
"from",
"the",
"prometheus",
"metrics",
"endpoint",
"provided",
".",
"Defaults",
"to",
"the",
"protobuf",
"format",
"but",
"can",
"use",
"the",
"formats",
"specified",
"by",
"the",
"PrometheusFormat",
"class",
".",
"Custom",
"headers",... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py#L494-L561 | [
"def",
"poll",
"(",
"self",
",",
"endpoint",
",",
"pFormat",
"=",
"PrometheusFormat",
".",
"PROTOBUF",
",",
"headers",
"=",
"None",
")",
":",
"if",
"headers",
"is",
"None",
":",
"headers",
"=",
"{",
"}",
"if",
"'accept-encoding'",
"not",
"in",
"headers",... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | PrometheusScraperMixin._submit | For each metric in the message, report it as a gauge with all labels as tags
except if a labels dict is passed, in which case keys are label names we'll extract
and corresponding values are tag names we'll use (eg: {'node': 'node'}).
Histograms generate a set of values instead of a unique metri... | datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py | def _submit(
self,
metric_name,
message,
send_histograms_buckets=True,
send_monotonic_counter=False,
custom_tags=None,
hostname=None,
):
"""
For each metric in the message, report it as a gauge with all labels as tags
except if a labels... | def _submit(
self,
metric_name,
message,
send_histograms_buckets=True,
send_monotonic_counter=False,
custom_tags=None,
hostname=None,
):
"""
For each metric in the message, report it as a gauge with all labels as tags
except if a labels... | [
"For",
"each",
"metric",
"in",
"the",
"message",
"report",
"it",
"as",
"a",
"gauge",
"with",
"all",
"labels",
"as",
"tags",
"except",
"if",
"a",
"labels",
"dict",
"is",
"passed",
"in",
"which",
"case",
"keys",
"are",
"label",
"names",
"we",
"ll",
"extr... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py#L563-L613 | [
"def",
"_submit",
"(",
"self",
",",
"metric_name",
",",
"message",
",",
"send_histograms_buckets",
"=",
"True",
",",
"send_monotonic_counter",
"=",
"False",
",",
"custom_tags",
"=",
"None",
",",
"hostname",
"=",
"None",
",",
")",
":",
"if",
"message",
".",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | PrometheusScraperMixin._get_hostname | If hostname is None, look at label_to_hostname setting | datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py | def _get_hostname(self, hostname, metric):
"""
If hostname is None, look at label_to_hostname setting
"""
if hostname is None and self.label_to_hostname is not None:
for label in metric.label:
if label.name == self.label_to_hostname:
return... | def _get_hostname(self, hostname, metric):
"""
If hostname is None, look at label_to_hostname setting
"""
if hostname is None and self.label_to_hostname is not None:
for label in metric.label:
if label.name == self.label_to_hostname:
return... | [
"If",
"hostname",
"is",
"None",
"look",
"at",
"label_to_hostname",
"setting"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py#L615-L624 | [
"def",
"_get_hostname",
"(",
"self",
",",
"hostname",
",",
"metric",
")",
":",
"if",
"hostname",
"is",
"None",
"and",
"self",
".",
"label_to_hostname",
"is",
"not",
"None",
":",
"for",
"label",
"in",
"metric",
".",
"label",
":",
"if",
"label",
".",
"na... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | PrometheusScraperMixin._submit_gauges_from_summary | Extracts metrics from a prometheus summary metric and sends them as gauges | datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py | def _submit_gauges_from_summary(self, name, metric, custom_tags=None, hostname=None):
"""
Extracts metrics from a prometheus summary metric and sends them as gauges
"""
if custom_tags is None:
custom_tags = []
# summaries do not have a value attribute
val = ge... | def _submit_gauges_from_summary(self, name, metric, custom_tags=None, hostname=None):
"""
Extracts metrics from a prometheus summary metric and sends them as gauges
"""
if custom_tags is None:
custom_tags = []
# summaries do not have a value attribute
val = ge... | [
"Extracts",
"metrics",
"from",
"a",
"prometheus",
"summary",
"metric",
"and",
"sends",
"them",
"as",
"gauges"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py#L633-L662 | [
"def",
"_submit_gauges_from_summary",
"(",
"self",
",",
"name",
",",
"metric",
",",
"custom_tags",
"=",
"None",
",",
"hostname",
"=",
"None",
")",
":",
"if",
"custom_tags",
"is",
"None",
":",
"custom_tags",
"=",
"[",
"]",
"# summaries do not have a value attribu... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | PrometheusScraperMixin._submit_gauges_from_histogram | Extracts metrics from a prometheus histogram and sends them as gauges | datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py | def _submit_gauges_from_histogram(
self, name, metric, send_histograms_buckets=True, custom_tags=None, hostname=None
):
"""
Extracts metrics from a prometheus histogram and sends them as gauges
"""
if custom_tags is None:
custom_tags = []
# histograms do n... | def _submit_gauges_from_histogram(
self, name, metric, send_histograms_buckets=True, custom_tags=None, hostname=None
):
"""
Extracts metrics from a prometheus histogram and sends them as gauges
"""
if custom_tags is None:
custom_tags = []
# histograms do n... | [
"Extracts",
"metrics",
"from",
"a",
"prometheus",
"histogram",
"and",
"sends",
"them",
"as",
"gauges"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py#L664-L696 | [
"def",
"_submit_gauges_from_histogram",
"(",
"self",
",",
"name",
",",
"metric",
",",
"send_histograms_buckets",
"=",
"True",
",",
"custom_tags",
"=",
"None",
",",
"hostname",
"=",
"None",
")",
":",
"if",
"custom_tags",
"is",
"None",
":",
"custom_tags",
"=",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | get_auth_info | See if a personal access token was passed | datadog_checks_dev/datadog_checks/dev/tooling/github.py | def get_auth_info(config=None):
"""
See if a personal access token was passed
"""
gh_config = (config or {}).get('github', {})
user = gh_config.get('user') or os.getenv('DD_GITHUB_USER')
token = gh_config.get('token') or os.getenv('DD_GITHUB_TOKEN')
if user and token:
return user, to... | def get_auth_info(config=None):
"""
See if a personal access token was passed
"""
gh_config = (config or {}).get('github', {})
user = gh_config.get('user') or os.getenv('DD_GITHUB_USER')
token = gh_config.get('token') or os.getenv('DD_GITHUB_TOKEN')
if user and token:
return user, to... | [
"See",
"if",
"a",
"personal",
"access",
"token",
"was",
"passed"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_dev/datadog_checks/dev/tooling/github.py#L17-L25 | [
"def",
"get_auth_info",
"(",
"config",
"=",
"None",
")",
":",
"gh_config",
"=",
"(",
"config",
"or",
"{",
"}",
")",
".",
"get",
"(",
"'github'",
",",
"{",
"}",
")",
"user",
"=",
"gh_config",
".",
"get",
"(",
"'user'",
")",
"or",
"os",
".",
"geten... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | get_changelog_types | Fetch the labels from the PR and process the ones related to the changelog. | datadog_checks_dev/datadog_checks/dev/tooling/github.py | def get_changelog_types(pr_payload):
"""
Fetch the labels from the PR and process the ones related to the changelog.
"""
changelog_labels = []
for name in get_pr_labels(pr_payload):
if name.startswith(CHANGELOG_LABEL_PREFIX):
# only add the name, e.g. for `changelog/Added` it's j... | def get_changelog_types(pr_payload):
"""
Fetch the labels from the PR and process the ones related to the changelog.
"""
changelog_labels = []
for name in get_pr_labels(pr_payload):
if name.startswith(CHANGELOG_LABEL_PREFIX):
# only add the name, e.g. for `changelog/Added` it's j... | [
"Fetch",
"the",
"labels",
"from",
"the",
"PR",
"and",
"process",
"the",
"ones",
"related",
"to",
"the",
"changelog",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_dev/datadog_checks/dev/tooling/github.py#L42-L52 | [
"def",
"get_changelog_types",
"(",
"pr_payload",
")",
":",
"changelog_labels",
"=",
"[",
"]",
"for",
"name",
"in",
"get_pr_labels",
"(",
"pr_payload",
")",
":",
"if",
"name",
".",
"startswith",
"(",
"CHANGELOG_LABEL_PREFIX",
")",
":",
"# only add the name, e.g. fo... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | get_pr | Get the payload for the given PR number. Let exceptions bubble up. | datadog_checks_dev/datadog_checks/dev/tooling/github.py | def get_pr(pr_num, config=None, repo=DEFAULT_REPO, raw=False):
"""
Get the payload for the given PR number. Let exceptions bubble up.
"""
response = requests.get(PR_ENDPOINT.format(repo, pr_num), auth=get_auth_info(config))
if raw:
return response
else:
response.raise_for_status... | def get_pr(pr_num, config=None, repo=DEFAULT_REPO, raw=False):
"""
Get the payload for the given PR number. Let exceptions bubble up.
"""
response = requests.get(PR_ENDPOINT.format(repo, pr_num), auth=get_auth_info(config))
if raw:
return response
else:
response.raise_for_status... | [
"Get",
"the",
"payload",
"for",
"the",
"given",
"PR",
"number",
".",
"Let",
"exceptions",
"bubble",
"up",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_dev/datadog_checks/dev/tooling/github.py#L55-L65 | [
"def",
"get_pr",
"(",
"pr_num",
",",
"config",
"=",
"None",
",",
"repo",
"=",
"DEFAULT_REPO",
",",
"raw",
"=",
"False",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"PR_ENDPOINT",
".",
"format",
"(",
"repo",
",",
"pr_num",
")",
",",
"auth"... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | parse_pr_numbers | Parse PR numbers from commit messages. At GitHub those have the format:
`here is the message (#1234)`
being `1234` the PR number. | datadog_checks_dev/datadog_checks/dev/tooling/github.py | def parse_pr_numbers(git_log_lines):
"""
Parse PR numbers from commit messages. At GitHub those have the format:
`here is the message (#1234)`
being `1234` the PR number.
"""
prs = []
for line in git_log_lines:
pr_number = parse_pr_number(line)
if pr_number:
... | def parse_pr_numbers(git_log_lines):
"""
Parse PR numbers from commit messages. At GitHub those have the format:
`here is the message (#1234)`
being `1234` the PR number.
"""
prs = []
for line in git_log_lines:
pr_number = parse_pr_number(line)
if pr_number:
... | [
"Parse",
"PR",
"numbers",
"from",
"commit",
"messages",
".",
"At",
"GitHub",
"those",
"have",
"the",
"format",
":"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_dev/datadog_checks/dev/tooling/github.py#L98-L111 | [
"def",
"parse_pr_numbers",
"(",
"git_log_lines",
")",
":",
"prs",
"=",
"[",
"]",
"for",
"line",
"in",
"git_log_lines",
":",
"pr_number",
"=",
"parse_pr_number",
"(",
"line",
")",
"if",
"pr_number",
":",
"prs",
".",
"append",
"(",
"pr_number",
")",
"return"... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | PeriodicExecutor.open | Start. Multiple calls have no effect.
Not safe to call from multiple threads at once. | tokumx/datadog_checks/tokumx/vendor/pymongo/periodic_executor.py | def open(self):
"""Start. Multiple calls have no effect.
Not safe to call from multiple threads at once.
"""
with self._lock:
if self._thread_will_exit:
# If the background thread has read self._stopped as True
# there is a chance that it has ... | def open(self):
"""Start. Multiple calls have no effect.
Not safe to call from multiple threads at once.
"""
with self._lock:
if self._thread_will_exit:
# If the background thread has read self._stopped as True
# there is a chance that it has ... | [
"Start",
".",
"Multiple",
"calls",
"have",
"no",
"effect",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/periodic_executor.py#L53-L83 | [
"def",
"open",
"(",
"self",
")",
":",
"with",
"self",
".",
"_lock",
":",
"if",
"self",
".",
"_thread_will_exit",
":",
"# If the background thread has read self._stopped as True",
"# there is a chance that it has not yet exited. The call to",
"# join should not block indefinitely ... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | tox_configure | For more info, see: https://tox.readthedocs.io/en/latest/plugins.html
For an example, see: https://github.com/tox-dev/tox-travis | datadog_checks_dev/datadog_checks/dev/plugin/tox.py | def tox_configure(config):
"""
For more info, see: https://tox.readthedocs.io/en/latest/plugins.html
For an example, see: https://github.com/tox-dev/tox-travis
"""
sections = config._cfg.sections
# Cache these
make_envconfig = None
reader = None
# Default to false so:
# 1. we d... | def tox_configure(config):
"""
For more info, see: https://tox.readthedocs.io/en/latest/plugins.html
For an example, see: https://github.com/tox-dev/tox-travis
"""
sections = config._cfg.sections
# Cache these
make_envconfig = None
reader = None
# Default to false so:
# 1. we d... | [
"For",
"more",
"info",
"see",
":",
"https",
":",
"//",
"tox",
".",
"readthedocs",
".",
"io",
"/",
"en",
"/",
"latest",
"/",
"plugins",
".",
"html",
"For",
"an",
"example",
"see",
":",
"https",
":",
"//",
"github",
".",
"com",
"/",
"tox",
"-",
"de... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_dev/datadog_checks/dev/plugin/tox.py#L15-L37 | [
"def",
"tox_configure",
"(",
"config",
")",
":",
"sections",
"=",
"config",
".",
"_cfg",
".",
"sections",
"# Cache these",
"make_envconfig",
"=",
"None",
"reader",
"=",
"None",
"# Default to false so:",
"# 1. we don't affect other projects using tox",
"# 2. check migratio... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Network._is_collect_cx_state_runnable | Determine if collect_connection_state is set and can effectively run.
If self._collect_cx_state is True and a custom proc_location is provided, the system cannot
run `ss` or `netstat` over a custom proc_location
:param proc_location: str
:return: bool | network/datadog_checks/network/network.py | def _is_collect_cx_state_runnable(self, proc_location):
"""
Determine if collect_connection_state is set and can effectively run.
If self._collect_cx_state is True and a custom proc_location is provided, the system cannot
run `ss` or `netstat` over a custom proc_location
:param ... | def _is_collect_cx_state_runnable(self, proc_location):
"""
Determine if collect_connection_state is set and can effectively run.
If self._collect_cx_state is True and a custom proc_location is provided, the system cannot
run `ss` or `netstat` over a custom proc_location
:param ... | [
"Determine",
"if",
"collect_connection_state",
"is",
"set",
"and",
"can",
"effectively",
"run",
".",
"If",
"self",
".",
"_collect_cx_state",
"is",
"True",
"and",
"a",
"custom",
"proc_location",
"is",
"provided",
"the",
"system",
"cannot",
"run",
"ss",
"or",
"n... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/network/datadog_checks/network/network.py#L261-L276 | [
"def",
"_is_collect_cx_state_runnable",
"(",
"self",
",",
"proc_location",
")",
":",
"if",
"self",
".",
"_collect_cx_state",
"is",
"False",
":",
"return",
"False",
"if",
"proc_location",
"!=",
"\"/proc\"",
":",
"self",
".",
"warning",
"(",
"\"Cannot collect connec... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Network._check_linux | _check_linux can be run inside a container and still collects the network metrics from the host
For that procfs_path can be set to something like "/host/proc"
When a custom procfs_path is set, the collect_connection_state option is ignored | network/datadog_checks/network/network.py | def _check_linux(self, instance):
"""
_check_linux can be run inside a container and still collects the network metrics from the host
For that procfs_path can be set to something like "/host/proc"
When a custom procfs_path is set, the collect_connection_state option is ignored
""... | def _check_linux(self, instance):
"""
_check_linux can be run inside a container and still collects the network metrics from the host
For that procfs_path can be set to something like "/host/proc"
When a custom procfs_path is set, the collect_connection_state option is ignored
""... | [
"_check_linux",
"can",
"be",
"run",
"inside",
"a",
"container",
"and",
"still",
"collects",
"the",
"network",
"metrics",
"from",
"the",
"host",
"For",
"that",
"procfs_path",
"can",
"be",
"set",
"to",
"something",
"like",
"/",
"host",
"/",
"proc",
"When",
"... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/network/datadog_checks/network/network.py#L278-L460 | [
"def",
"_check_linux",
"(",
"self",
",",
"instance",
")",
":",
"proc_location",
"=",
"self",
".",
"agentConfig",
".",
"get",
"(",
"'procfs_path'",
",",
"'/proc'",
")",
".",
"rstrip",
"(",
"'/'",
")",
"custom_tags",
"=",
"instance",
".",
"get",
"(",
"'tag... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Network._add_conntrack_stats_metrics | Parse the output of conntrack -S
Add the parsed metrics | network/datadog_checks/network/network.py | def _add_conntrack_stats_metrics(self, conntrack_path, tags):
"""
Parse the output of conntrack -S
Add the parsed metrics
"""
try:
output, _, _ = get_subprocess_output(["sudo", conntrack_path, "-S"], self.log)
# conntrack -S sample:
# cpu=0 fou... | def _add_conntrack_stats_metrics(self, conntrack_path, tags):
"""
Parse the output of conntrack -S
Add the parsed metrics
"""
try:
output, _, _ = get_subprocess_output(["sudo", conntrack_path, "-S"], self.log)
# conntrack -S sample:
# cpu=0 fou... | [
"Parse",
"the",
"output",
"of",
"conntrack",
"-",
"S",
"Add",
"the",
"parsed",
"metrics"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/network/datadog_checks/network/network.py#L462-L487 | [
"def",
"_add_conntrack_stats_metrics",
"(",
"self",
",",
"conntrack_path",
",",
"tags",
")",
":",
"try",
":",
"output",
",",
"_",
",",
"_",
"=",
"get_subprocess_output",
"(",
"[",
"\"sudo\"",
",",
"conntrack_path",
",",
"\"-S\"",
"]",
",",
"self",
".",
"lo... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Network._parse_linux_cx_state | Parse the output of the command that retrieves the connection state (either `ss` or `netstat`)
Returns a dict metric_name -> value | network/datadog_checks/network/network.py | def _parse_linux_cx_state(self, lines, tcp_states, state_col, protocol=None, ip_version=None):
"""
Parse the output of the command that retrieves the connection state (either `ss` or `netstat`)
Returns a dict metric_name -> value
"""
metrics = {}
for _, val in iteritems(s... | def _parse_linux_cx_state(self, lines, tcp_states, state_col, protocol=None, ip_version=None):
"""
Parse the output of the command that retrieves the connection state (either `ss` or `netstat`)
Returns a dict metric_name -> value
"""
metrics = {}
for _, val in iteritems(s... | [
"Parse",
"the",
"output",
"of",
"the",
"command",
"that",
"retrieves",
"the",
"connection",
"state",
"(",
"either",
"ss",
"or",
"netstat",
")",
"Returns",
"a",
"dict",
"metric_name",
"-",
">",
"value"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/network/datadog_checks/network/network.py#L489-L509 | [
"def",
"_parse_linux_cx_state",
"(",
"self",
",",
"lines",
",",
"tcp_states",
",",
"state_col",
",",
"protocol",
"=",
"None",
",",
"ip_version",
"=",
"None",
")",
":",
"metrics",
"=",
"{",
"}",
"for",
"_",
",",
"val",
"in",
"iteritems",
"(",
"self",
".... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Network._parse_solaris_netstat | Return a mapping of network metrics by interface. For example:
{ interface:
{'bytes_sent': 0,
'bytes_rcvd': 0,
'bytes_rcvd': 0,
...
}
} | network/datadog_checks/network/network.py | def _parse_solaris_netstat(self, netstat_output):
"""
Return a mapping of network metrics by interface. For example:
{ interface:
{'bytes_sent': 0,
'bytes_rcvd': 0,
'bytes_rcvd': 0,
...
}
}
... | def _parse_solaris_netstat(self, netstat_output):
"""
Return a mapping of network metrics by interface. For example:
{ interface:
{'bytes_sent': 0,
'bytes_rcvd': 0,
'bytes_rcvd': 0,
...
}
}
... | [
"Return",
"a",
"mapping",
"of",
"network",
"metrics",
"by",
"interface",
".",
"For",
"example",
":",
"{",
"interface",
":",
"{",
"bytes_sent",
":",
"0",
"bytes_rcvd",
":",
"0",
"bytes_rcvd",
":",
"0",
"...",
"}",
"}"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/network/datadog_checks/network/network.py#L637-L731 | [
"def",
"_parse_solaris_netstat",
"(",
"self",
",",
"netstat_output",
")",
":",
"# Here's an example of the netstat output:",
"#",
"# link:0:net0:brdcstrcv 527336",
"# link:0:net0:brdcstxmt 1595",
"# link:0:net0:class net",
"# link:0:net0:collisions 0",
"# link:0:net0:crtime ... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Network._check_psutil | Gather metrics about connections states and interfaces counters
using psutil facilities | network/datadog_checks/network/network.py | def _check_psutil(self, instance):
"""
Gather metrics about connections states and interfaces counters
using psutil facilities
"""
custom_tags = instance.get('tags', [])
if self._collect_cx_state:
self._cx_state_psutil(tags=custom_tags)
self._cx_count... | def _check_psutil(self, instance):
"""
Gather metrics about connections states and interfaces counters
using psutil facilities
"""
custom_tags = instance.get('tags', [])
if self._collect_cx_state:
self._cx_state_psutil(tags=custom_tags)
self._cx_count... | [
"Gather",
"metrics",
"about",
"connections",
"states",
"and",
"interfaces",
"counters",
"using",
"psutil",
"facilities"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/network/datadog_checks/network/network.py#L733-L742 | [
"def",
"_check_psutil",
"(",
"self",
",",
"instance",
")",
":",
"custom_tags",
"=",
"instance",
".",
"get",
"(",
"'tags'",
",",
"[",
"]",
")",
"if",
"self",
".",
"_collect_cx_state",
":",
"self",
".",
"_cx_state_psutil",
"(",
"tags",
"=",
"custom_tags",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Network._cx_state_psutil | Collect metrics about connections state using psutil | network/datadog_checks/network/network.py | def _cx_state_psutil(self, tags=None):
"""
Collect metrics about connections state using psutil
"""
metrics = defaultdict(int)
tags = [] if tags is None else tags
for conn in psutil.net_connections():
protocol = self._parse_protocol_psutil(conn)
st... | def _cx_state_psutil(self, tags=None):
"""
Collect metrics about connections state using psutil
"""
metrics = defaultdict(int)
tags = [] if tags is None else tags
for conn in psutil.net_connections():
protocol = self._parse_protocol_psutil(conn)
st... | [
"Collect",
"metrics",
"about",
"connections",
"state",
"using",
"psutil"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/network/datadog_checks/network/network.py#L744-L760 | [
"def",
"_cx_state_psutil",
"(",
"self",
",",
"tags",
"=",
"None",
")",
":",
"metrics",
"=",
"defaultdict",
"(",
"int",
")",
"tags",
"=",
"[",
"]",
"if",
"tags",
"is",
"None",
"else",
"tags",
"for",
"conn",
"in",
"psutil",
".",
"net_connections",
"(",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Network._cx_counters_psutil | Collect metrics about interfaces counters using psutil | network/datadog_checks/network/network.py | def _cx_counters_psutil(self, tags=None):
"""
Collect metrics about interfaces counters using psutil
"""
tags = [] if tags is None else tags
for iface, counters in iteritems(psutil.net_io_counters(pernic=True)):
metrics = {
'bytes_rcvd': counters.bytes... | def _cx_counters_psutil(self, tags=None):
"""
Collect metrics about interfaces counters using psutil
"""
tags = [] if tags is None else tags
for iface, counters in iteritems(psutil.net_io_counters(pernic=True)):
metrics = {
'bytes_rcvd': counters.bytes... | [
"Collect",
"metrics",
"about",
"interfaces",
"counters",
"using",
"psutil"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/network/datadog_checks/network/network.py#L762-L776 | [
"def",
"_cx_counters_psutil",
"(",
"self",
",",
"tags",
"=",
"None",
")",
":",
"tags",
"=",
"[",
"]",
"if",
"tags",
"is",
"None",
"else",
"tags",
"for",
"iface",
",",
"counters",
"in",
"iteritems",
"(",
"psutil",
".",
"net_io_counters",
"(",
"pernic",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Network._parse_protocol_psutil | Returns a string describing the protocol for the given connection
in the form `tcp4`, 'udp4` as in `self.cx_state_gauge` | network/datadog_checks/network/network.py | def _parse_protocol_psutil(self, conn):
"""
Returns a string describing the protocol for the given connection
in the form `tcp4`, 'udp4` as in `self.cx_state_gauge`
"""
protocol = self.PSUTIL_TYPE_MAPPING.get(conn.type, '')
family = self.PSUTIL_FAMILY_MAPPING.get(conn.fam... | def _parse_protocol_psutil(self, conn):
"""
Returns a string describing the protocol for the given connection
in the form `tcp4`, 'udp4` as in `self.cx_state_gauge`
"""
protocol = self.PSUTIL_TYPE_MAPPING.get(conn.type, '')
family = self.PSUTIL_FAMILY_MAPPING.get(conn.fam... | [
"Returns",
"a",
"string",
"describing",
"the",
"protocol",
"for",
"the",
"given",
"connection",
"in",
"the",
"form",
"tcp4",
"udp4",
"as",
"in",
"self",
".",
"cx_state_gauge"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/network/datadog_checks/network/network.py#L778-L785 | [
"def",
"_parse_protocol_psutil",
"(",
"self",
",",
"conn",
")",
":",
"protocol",
"=",
"self",
".",
"PSUTIL_TYPE_MAPPING",
".",
"get",
"(",
"conn",
".",
"type",
",",
"''",
")",
"family",
"=",
"self",
".",
"PSUTIL_FAMILY_MAPPING",
".",
"get",
"(",
"conn",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | PoolWorker.run | Process the work unit, or wait for sentinel to exit | datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py | def run(self):
"""Process the work unit, or wait for sentinel to exit"""
while True:
self.running = True
workunit = self._workq.get()
if is_sentinel(workunit):
# Got sentinel
break
# Run the job / sequence
worku... | def run(self):
"""Process the work unit, or wait for sentinel to exit"""
while True:
self.running = True
workunit = self._workq.get()
if is_sentinel(workunit):
# Got sentinel
break
# Run the job / sequence
worku... | [
"Process",
"the",
"work",
"unit",
"or",
"wait",
"for",
"sentinel",
"to",
"exit"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py#L56-L67 | [
"def",
"run",
"(",
"self",
")",
":",
"while",
"True",
":",
"self",
".",
"running",
"=",
"True",
"workunit",
"=",
"self",
".",
"_workq",
".",
"get",
"(",
")",
"if",
"is_sentinel",
"(",
"workunit",
")",
":",
"# Got sentinel",
"break",
"# Run the job / sequ... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Pool.apply | Equivalent of the apply() builtin function. It blocks till
the result is ready. | datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py | def apply(self, func, args=(), kwds=dict()):
"""Equivalent of the apply() builtin function. It blocks till
the result is ready."""
return self.apply_async(func, args, kwds).get() | def apply(self, func, args=(), kwds=dict()):
"""Equivalent of the apply() builtin function. It blocks till
the result is ready."""
return self.apply_async(func, args, kwds).get() | [
"Equivalent",
"of",
"the",
"apply",
"()",
"builtin",
"function",
".",
"It",
"blocks",
"till",
"the",
"result",
"is",
"ready",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py#L99-L102 | [
"def",
"apply",
"(",
"self",
",",
"func",
",",
"args",
"=",
"(",
")",
",",
"kwds",
"=",
"dict",
"(",
")",
")",
":",
"return",
"self",
".",
"apply_async",
"(",
"func",
",",
"args",
",",
"kwds",
")",
".",
"get",
"(",
")"
] | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Pool.map | A parallel equivalent of the map() builtin function. It
blocks till the result is ready.
This method chops the iterable into a number of chunks which
it submits to the process pool as separate tasks. The
(approximate) size of these chunks can be specified by setting
chunksize to... | datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py | def map(self, func, iterable, chunksize=None):
"""A parallel equivalent of the map() builtin function. It
blocks till the result is ready.
This method chops the iterable into a number of chunks which
it submits to the process pool as separate tasks. The
(approximate) size of the... | def map(self, func, iterable, chunksize=None):
"""A parallel equivalent of the map() builtin function. It
blocks till the result is ready.
This method chops the iterable into a number of chunks which
it submits to the process pool as separate tasks. The
(approximate) size of the... | [
"A",
"parallel",
"equivalent",
"of",
"the",
"map",
"()",
"builtin",
"function",
".",
"It",
"blocks",
"till",
"the",
"result",
"is",
"ready",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py#L104-L112 | [
"def",
"map",
"(",
"self",
",",
"func",
",",
"iterable",
",",
"chunksize",
"=",
"None",
")",
":",
"return",
"self",
".",
"map_async",
"(",
"func",
",",
"iterable",
",",
"chunksize",
")",
".",
"get",
"(",
")"
] | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Pool.imap | An equivalent of itertools.imap().
The chunksize argument is the same as the one used by the
map() method. For very long iterables using a large value for
chunksize can make make the job complete much faster than
using the default value of 1.
Also if chunksize is 1 then the nex... | datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py | def imap(self, func, iterable, chunksize=1):
"""
An equivalent of itertools.imap().
The chunksize argument is the same as the one used by the
map() method. For very long iterables using a large value for
chunksize can make make the job complete much faster than
using the... | def imap(self, func, iterable, chunksize=1):
"""
An equivalent of itertools.imap().
The chunksize argument is the same as the one used by the
map() method. For very long iterables using a large value for
chunksize can make make the job complete much faster than
using the... | [
"An",
"equivalent",
"of",
"itertools",
".",
"imap",
"()",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py#L114-L130 | [
"def",
"imap",
"(",
"self",
",",
"func",
",",
"iterable",
",",
"chunksize",
"=",
"1",
")",
":",
"collector",
"=",
"OrderedResultCollector",
"(",
"as_iterator",
"=",
"True",
")",
"self",
".",
"_create_sequences",
"(",
"func",
",",
"iterable",
",",
"chunksiz... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Pool.imap_unordered | The same as imap() except that the ordering of the results
from the returned iterator should be considered
arbitrary. (Only when there is only one worker process is the
order guaranteed to be "correct".) | datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py | def imap_unordered(self, func, iterable, chunksize=1):
"""The same as imap() except that the ordering of the results
from the returned iterator should be considered
arbitrary. (Only when there is only one worker process is the
order guaranteed to be "correct".)"""
collector = Uno... | def imap_unordered(self, func, iterable, chunksize=1):
"""The same as imap() except that the ordering of the results
from the returned iterator should be considered
arbitrary. (Only when there is only one worker process is the
order guaranteed to be "correct".)"""
collector = Uno... | [
"The",
"same",
"as",
"imap",
"()",
"except",
"that",
"the",
"ordering",
"of",
"the",
"results",
"from",
"the",
"returned",
"iterator",
"should",
"be",
"considered",
"arbitrary",
".",
"(",
"Only",
"when",
"there",
"is",
"only",
"one",
"worker",
"process",
"... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py#L132-L139 | [
"def",
"imap_unordered",
"(",
"self",
",",
"func",
",",
"iterable",
",",
"chunksize",
"=",
"1",
")",
":",
"collector",
"=",
"UnorderedResultCollector",
"(",
")",
"self",
".",
"_create_sequences",
"(",
"func",
",",
"iterable",
",",
"chunksize",
",",
"collecto... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Pool.apply_async | A variant of the apply() method which returns an
ApplyResult object.
If callback is specified then it should be a callable which
accepts a single argument. When the result becomes ready,
callback is applied to it (unless the call failed). callback
should complete immediately sin... | datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py | def apply_async(self, func, args=(), kwds=dict(), callback=None):
"""A variant of the apply() method which returns an
ApplyResult object.
If callback is specified then it should be a callable which
accepts a single argument. When the result becomes ready,
callback is applied to ... | def apply_async(self, func, args=(), kwds=dict(), callback=None):
"""A variant of the apply() method which returns an
ApplyResult object.
If callback is specified then it should be a callable which
accepts a single argument. When the result becomes ready,
callback is applied to ... | [
"A",
"variant",
"of",
"the",
"apply",
"()",
"method",
"which",
"returns",
"an",
"ApplyResult",
"object",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py#L141-L154 | [
"def",
"apply_async",
"(",
"self",
",",
"func",
",",
"args",
"=",
"(",
")",
",",
"kwds",
"=",
"dict",
"(",
")",
",",
"callback",
"=",
"None",
")",
":",
"assert",
"not",
"self",
".",
"_closed",
"# No lock here. We assume it's atomic...",
"apply_result",
"="... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Pool.map_async | A variant of the map() method which returns a ApplyResult
object.
If callback is specified then it should be a callable which
accepts a single argument. When the result becomes ready
callback is applied to it (unless the call failed). callback
should complete immediately since o... | datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py | def map_async(self, func, iterable, chunksize=None, callback=None):
"""A variant of the map() method which returns a ApplyResult
object.
If callback is specified then it should be a callable which
accepts a single argument. When the result becomes ready
callback is applied to it... | def map_async(self, func, iterable, chunksize=None, callback=None):
"""A variant of the map() method which returns a ApplyResult
object.
If callback is specified then it should be a callable which
accepts a single argument. When the result becomes ready
callback is applied to it... | [
"A",
"variant",
"of",
"the",
"map",
"()",
"method",
"which",
"returns",
"a",
"ApplyResult",
"object",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py#L156-L168 | [
"def",
"map_async",
"(",
"self",
",",
"func",
",",
"iterable",
",",
"chunksize",
"=",
"None",
",",
"callback",
"=",
"None",
")",
":",
"apply_result",
"=",
"ApplyResult",
"(",
"callback",
"=",
"callback",
")",
"collector",
"=",
"OrderedResultCollector",
"(",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Pool.imap_async | A variant of the imap() method which returns an ApplyResult
object that provides an iterator (next method(timeout)
available).
If callback is specified then it should be a callable which
accepts a single argument. When the resulting iterator becomes
ready, callback is applied to... | datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py | def imap_async(self, func, iterable, chunksize=None, callback=None):
"""A variant of the imap() method which returns an ApplyResult
object that provides an iterator (next method(timeout)
available).
If callback is specified then it should be a callable which
accepts a single arg... | def imap_async(self, func, iterable, chunksize=None, callback=None):
"""A variant of the imap() method which returns an ApplyResult
object that provides an iterator (next method(timeout)
available).
If callback is specified then it should be a callable which
accepts a single arg... | [
"A",
"variant",
"of",
"the",
"imap",
"()",
"method",
"which",
"returns",
"an",
"ApplyResult",
"object",
"that",
"provides",
"an",
"iterator",
"(",
"next",
"method",
"(",
"timeout",
")",
"available",
")",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py#L170-L183 | [
"def",
"imap_async",
"(",
"self",
",",
"func",
",",
"iterable",
",",
"chunksize",
"=",
"None",
",",
"callback",
"=",
"None",
")",
":",
"apply_result",
"=",
"ApplyResult",
"(",
"callback",
"=",
"callback",
")",
"collector",
"=",
"OrderedResultCollector",
"(",... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Pool.imap_unordered_async | A variant of the imap_unordered() method which returns an
ApplyResult object that provides an iterator (next
method(timeout) available).
If callback is specified then it should be a callable which
accepts a single argument. When the resulting iterator becomes
ready, callback is ... | datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py | def imap_unordered_async(self, func, iterable, chunksize=None, callback=None):
"""A variant of the imap_unordered() method which returns an
ApplyResult object that provides an iterator (next
method(timeout) available).
If callback is specified then it should be a callable which
... | def imap_unordered_async(self, func, iterable, chunksize=None, callback=None):
"""A variant of the imap_unordered() method which returns an
ApplyResult object that provides an iterator (next
method(timeout) available).
If callback is specified then it should be a callable which
... | [
"A",
"variant",
"of",
"the",
"imap_unordered",
"()",
"method",
"which",
"returns",
"an",
"ApplyResult",
"object",
"that",
"provides",
"an",
"iterator",
"(",
"next",
"method",
"(",
"timeout",
")",
"available",
")",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py#L185-L198 | [
"def",
"imap_unordered_async",
"(",
"self",
",",
"func",
",",
"iterable",
",",
"chunksize",
"=",
"None",
",",
"callback",
"=",
"None",
")",
":",
"apply_result",
"=",
"ApplyResult",
"(",
"callback",
"=",
"callback",
")",
"collector",
"=",
"UnorderedResultCollec... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Pool.terminate | Stops the worker processes immediately without completing
outstanding work. When the pool object is garbage collected
terminate() will be called immediately. | datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py | def terminate(self):
"""Stops the worker processes immediately without completing
outstanding work. When the pool object is garbage collected
terminate() will be called immediately."""
self.close()
# Clearing the job queue
try:
while 1:
self._... | def terminate(self):
"""Stops the worker processes immediately without completing
outstanding work. When the pool object is garbage collected
terminate() will be called immediately."""
self.close()
# Clearing the job queue
try:
while 1:
self._... | [
"Stops",
"the",
"worker",
"processes",
"immediately",
"without",
"completing",
"outstanding",
"work",
".",
"When",
"the",
"pool",
"object",
"is",
"garbage",
"collected",
"terminate",
"()",
"will",
"be",
"called",
"immediately",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py#L207-L223 | [
"def",
"terminate",
"(",
"self",
")",
":",
"self",
".",
"close",
"(",
")",
"# Clearing the job queue",
"try",
":",
"while",
"1",
":",
"self",
".",
"_workq",
".",
"get_nowait",
"(",
")",
"except",
"queue",
".",
"Empty",
":",
"pass",
"# Send one sentinel for... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Pool._create_sequences | Create the WorkUnit objects to process and pushes them on the
work queue. Each work unit is meant to process a slice of
iterable of size chunksize. If collector is specified, then
the ApplyResult objects associated with the jobs will notify
collector when their result becomes ready.
... | datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py | def _create_sequences(self, func, iterable, chunksize, collector=None):
"""
Create the WorkUnit objects to process and pushes them on the
work queue. Each work unit is meant to process a slice of
iterable of size chunksize. If collector is specified, then
the ApplyResult objects ... | def _create_sequences(self, func, iterable, chunksize, collector=None):
"""
Create the WorkUnit objects to process and pushes them on the
work queue. Each work unit is meant to process a slice of
iterable of size chunksize. If collector is specified, then
the ApplyResult objects ... | [
"Create",
"the",
"WorkUnit",
"objects",
"to",
"process",
"and",
"pushes",
"them",
"on",
"the",
"work",
"queue",
".",
"Each",
"work",
"unit",
"is",
"meant",
"to",
"process",
"a",
"slice",
"of",
"iterable",
"of",
"size",
"chunksize",
".",
"If",
"collector",
... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py#L231-L264 | [
"def",
"_create_sequences",
"(",
"self",
",",
"func",
",",
"iterable",
",",
"chunksize",
",",
"collector",
"=",
"None",
")",
":",
"assert",
"not",
"self",
".",
"_closed",
"# No lock here. We assume it's atomic...",
"sequences",
"=",
"[",
"]",
"results",
"=",
"... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Job.process | Call the function with the args/kwds and tell the ApplyResult
that its result is ready. Correctly handles the exceptions
happening during the execution of the function | datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py | def process(self):
"""
Call the function with the args/kwds and tell the ApplyResult
that its result is ready. Correctly handles the exceptions
happening during the execution of the function
"""
try:
result = self._func(*self._args, **self._kwds)
excep... | def process(self):
"""
Call the function with the args/kwds and tell the ApplyResult
that its result is ready. Correctly handles the exceptions
happening during the execution of the function
"""
try:
result = self._func(*self._args, **self._kwds)
excep... | [
"Call",
"the",
"function",
"with",
"the",
"args",
"/",
"kwds",
"and",
"tell",
"the",
"ApplyResult",
"that",
"its",
"result",
"is",
"ready",
".",
"Correctly",
"handles",
"the",
"exceptions",
"happening",
"during",
"the",
"execution",
"of",
"the",
"function"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py#L291-L302 | [
"def",
"process",
"(",
"self",
")",
":",
"try",
":",
"result",
"=",
"self",
".",
"_func",
"(",
"*",
"self",
".",
"_args",
",",
"*",
"*",
"self",
".",
"_kwds",
")",
"except",
":",
"self",
".",
"_result",
".",
"_set_exception",
"(",
")",
"else",
":... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | ApplyResult.get | Returns the result when it arrives. If timeout is not None and
the result does not arrive within timeout seconds then
TimeoutError is raised. If the remote call raised an exception
then that exception will be reraised by get(). | datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py | def get(self, timeout=None):
"""
Returns the result when it arrives. If timeout is not None and
the result does not arrive within timeout seconds then
TimeoutError is raised. If the remote call raised an exception
then that exception will be reraised by get().
"""
... | def get(self, timeout=None):
"""
Returns the result when it arrives. If timeout is not None and
the result does not arrive within timeout seconds then
TimeoutError is raised. If the remote call raised an exception
then that exception will be reraised by get().
"""
... | [
"Returns",
"the",
"result",
"when",
"it",
"arrives",
".",
"If",
"timeout",
"is",
"not",
"None",
"and",
"the",
"result",
"does",
"not",
"arrive",
"within",
"timeout",
"seconds",
"then",
"TimeoutError",
"is",
"raised",
".",
"If",
"the",
"remote",
"call",
"ra... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py#L349-L360 | [
"def",
"get",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"wait",
"(",
"timeout",
")",
":",
"raise",
"TimeoutError",
"(",
"\"Result not available within %fs\"",
"%",
"timeout",
")",
"if",
"self",
".",
"_success",
":",
"r... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | ApplyResult.wait | Waits until the result is available or until timeout
seconds pass. | datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py | def wait(self, timeout=None):
"""Waits until the result is available or until timeout
seconds pass."""
self._event.wait(timeout)
return self._event.isSet() | def wait(self, timeout=None):
"""Waits until the result is available or until timeout
seconds pass."""
self._event.wait(timeout)
return self._event.isSet() | [
"Waits",
"until",
"the",
"result",
"is",
"available",
"or",
"until",
"timeout",
"seconds",
"pass",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py#L362-L366 | [
"def",
"wait",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"self",
".",
"_event",
".",
"wait",
"(",
"timeout",
")",
"return",
"self",
".",
"_event",
".",
"isSet",
"(",
")"
] | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | ApplyResult._set_value | Called by a Job object to tell the result is ready, and
provides the value of this result. The object will become
ready and successful. The collector's notify_ready() method
will be called, and the callback method too | datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py | def _set_value(self, value):
"""Called by a Job object to tell the result is ready, and
provides the value of this result. The object will become
ready and successful. The collector's notify_ready() method
will be called, and the callback method too"""
assert not self.ready()
... | def _set_value(self, value):
"""Called by a Job object to tell the result is ready, and
provides the value of this result. The object will become
ready and successful. The collector's notify_ready() method
will be called, and the callback method too"""
assert not self.ready()
... | [
"Called",
"by",
"a",
"Job",
"object",
"to",
"tell",
"the",
"result",
"is",
"ready",
"and",
"provides",
"the",
"value",
"of",
"this",
"result",
".",
"The",
"object",
"will",
"become",
"ready",
"and",
"successful",
".",
"The",
"collector",
"s",
"notify_ready... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py#L379-L394 | [
"def",
"_set_value",
"(",
"self",
",",
"value",
")",
":",
"assert",
"not",
"self",
".",
"ready",
"(",
")",
"self",
".",
"_data",
"=",
"value",
"self",
".",
"_success",
"=",
"True",
"self",
".",
"_event",
".",
"set",
"(",
")",
"if",
"self",
".",
"... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | ApplyResult._set_exception | Called by a Job object to tell that an exception occured
during the processing of the function. The object will become
ready but not successful. The collector's notify_ready()
method will be called, but NOT the callback method | datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py | def _set_exception(self):
"""Called by a Job object to tell that an exception occured
during the processing of the function. The object will become
ready but not successful. The collector's notify_ready()
method will be called, but NOT the callback method"""
assert not self.ready... | def _set_exception(self):
"""Called by a Job object to tell that an exception occured
during the processing of the function. The object will become
ready but not successful. The collector's notify_ready()
method will be called, but NOT the callback method"""
assert not self.ready... | [
"Called",
"by",
"a",
"Job",
"object",
"to",
"tell",
"that",
"an",
"exception",
"occured",
"during",
"the",
"processing",
"of",
"the",
"function",
".",
"The",
"object",
"will",
"become",
"ready",
"but",
"not",
"successful",
".",
"The",
"collector",
"s",
"no... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py#L396-L406 | [
"def",
"_set_exception",
"(",
"self",
")",
":",
"assert",
"not",
"self",
".",
"ready",
"(",
")",
"self",
".",
"_data",
"=",
"sys",
".",
"exc_info",
"(",
")",
"self",
".",
"_success",
"=",
"False",
"self",
".",
"_event",
".",
"set",
"(",
")",
"if",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | CollectorIterator.next | Return the next result value in the sequence. Raise
StopIteration at the end. Can raise the exception raised by
the Job | datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py | def next(self, timeout=None):
"""Return the next result value in the sequence. Raise
StopIteration at the end. Can raise the exception raised by
the Job"""
try:
apply_result = self._collector._get_result(self._idx, timeout)
except IndexError:
# Reset for n... | def next(self, timeout=None):
"""Return the next result value in the sequence. Raise
StopIteration at the end. Can raise the exception raised by
the Job"""
try:
apply_result = self._collector._get_result(self._idx, timeout)
except IndexError:
# Reset for n... | [
"Return",
"the",
"next",
"result",
"value",
"in",
"the",
"sequence",
".",
"Raise",
"StopIteration",
"at",
"the",
"end",
".",
"Can",
"raise",
"the",
"exception",
"raised",
"by",
"the",
"Job"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py#L471-L486 | [
"def",
"next",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"try",
":",
"apply_result",
"=",
"self",
".",
"_collector",
".",
"_get_result",
"(",
"self",
".",
"_idx",
",",
"timeout",
")",
"except",
"IndexError",
":",
"# Reset for next time",
"self",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | UnorderedResultCollector._get_result | Called by the CollectorIterator object to retrieve the
result's values one after another, in the order the results have
become available.
\param idx The index of the result we want, wrt collector's order
\param timeout integer telling how long to wait (in seconds)
for the result ... | datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py | def _get_result(self, idx, timeout=None):
"""Called by the CollectorIterator object to retrieve the
result's values one after another, in the order the results have
become available.
\param idx The index of the result we want, wrt collector's order
\param timeout integer telling ... | def _get_result(self, idx, timeout=None):
"""Called by the CollectorIterator object to retrieve the
result's values one after another, in the order the results have
become available.
\param idx The index of the result we want, wrt collector's order
\param timeout integer telling ... | [
"Called",
"by",
"the",
"CollectorIterator",
"object",
"to",
"retrieve",
"the",
"result",
"s",
"values",
"one",
"after",
"another",
"in",
"the",
"order",
"the",
"results",
"have",
"become",
"available",
".",
"\\",
"param",
"idx",
"The",
"index",
"of",
"the",
... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py#L514-L540 | [
"def",
"_get_result",
"(",
"self",
",",
"idx",
",",
"timeout",
"=",
"None",
")",
":",
"self",
".",
"_cond",
".",
"acquire",
"(",
")",
"try",
":",
"if",
"idx",
">=",
"self",
".",
"_expected",
":",
"raise",
"IndexError",
"elif",
"idx",
"<",
"len",
"(... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | UnorderedResultCollector.notify_ready | Called by the ApplyResult object (already registered via
register_result()) that it is now ready (ie. the Job's result
is available or an exception has been raised).
\param apply_result ApplyResult object telling us that the job
has been processed | datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py | def notify_ready(self, apply_result):
"""Called by the ApplyResult object (already registered via
register_result()) that it is now ready (ie. the Job's result
is available or an exception has been raised).
\param apply_result ApplyResult object telling us that the job
has been p... | def notify_ready(self, apply_result):
"""Called by the ApplyResult object (already registered via
register_result()) that it is now ready (ie. the Job's result
is available or an exception has been raised).
\param apply_result ApplyResult object telling us that the job
has been p... | [
"Called",
"by",
"the",
"ApplyResult",
"object",
"(",
"already",
"registered",
"via",
"register_result",
"()",
")",
"that",
"it",
"is",
"now",
"ready",
"(",
"ie",
".",
"the",
"Job",
"s",
"result",
"is",
"available",
"or",
"an",
"exception",
"has",
"been",
... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py#L542-L560 | [
"def",
"notify_ready",
"(",
"self",
",",
"apply_result",
")",
":",
"first_item",
"=",
"False",
"self",
".",
"_cond",
".",
"acquire",
"(",
")",
"try",
":",
"self",
".",
"_collection",
".",
"append",
"(",
"apply_result",
")",
"first_item",
"=",
"len",
"(",... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | OrderedResultCollector._get_result | Called by the CollectorIterator object to retrieve the
result's values one after another (order defined by the
implementation)
\param idx The index of the result we want, wrt collector's order
\param timeout integer telling how long to wait (in seconds)
for the result at index id... | datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py | def _get_result(self, idx, timeout=None):
"""Called by the CollectorIterator object to retrieve the
result's values one after another (order defined by the
implementation)
\param idx The index of the result we want, wrt collector's order
\param timeout integer telling how long to... | def _get_result(self, idx, timeout=None):
"""Called by the CollectorIterator object to retrieve the
result's values one after another (order defined by the
implementation)
\param idx The index of the result we want, wrt collector's order
\param timeout integer telling how long to... | [
"Called",
"by",
"the",
"CollectorIterator",
"object",
"to",
"retrieve",
"the",
"result",
"s",
"values",
"one",
"after",
"another",
"(",
"order",
"defined",
"by",
"the",
"implementation",
")",
"\\",
"param",
"idx",
"The",
"index",
"of",
"the",
"result",
"we",... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py#L594-L605 | [
"def",
"_get_result",
"(",
"self",
",",
"idx",
",",
"timeout",
"=",
"None",
")",
":",
"res",
"=",
"self",
".",
"_results",
"[",
"idx",
"]",
"res",
".",
"wait",
"(",
"timeout",
")",
"return",
"res"
] | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | OrderedResultCollector.notify_ready | Called by the ApplyResult object (already registered via
register_result()) that it is now ready (ie. the Job's result
is available or an exception has been raised).
\param apply_result ApplyResult object telling us that the job
has been processed | datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py | def notify_ready(self, apply_result):
"""Called by the ApplyResult object (already registered via
register_result()) that it is now ready (ie. the Job's result
is available or an exception has been raised).
\param apply_result ApplyResult object telling us that the job
has been p... | def notify_ready(self, apply_result):
"""Called by the ApplyResult object (already registered via
register_result()) that it is now ready (ie. the Job's result
is available or an exception has been raised).
\param apply_result ApplyResult object telling us that the job
has been p... | [
"Called",
"by",
"the",
"ApplyResult",
"object",
"(",
"already",
"registered",
"via",
"register_result",
"()",
")",
"that",
"it",
"is",
"now",
"ready",
"(",
"ie",
".",
"the",
"Job",
"s",
"result",
"is",
"available",
"or",
"an",
"exception",
"has",
"been",
... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/libs/thread_pool.py#L607-L634 | [
"def",
"notify_ready",
"(",
"self",
",",
"apply_result",
")",
":",
"got_first",
"=",
"False",
"got_last",
"=",
"False",
"self",
".",
"_lock",
".",
"acquire",
"(",
")",
"try",
":",
"assert",
"self",
".",
"_remaining",
">",
"0",
"got_first",
"=",
"len",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | command | Execute a command over the socket, or raise socket.error.
:Parameters:
- `sock`: a raw socket instance
- `dbname`: name of the database on which to run the command
- `spec`: a command document as a dict, SON, or mapping object
- `slave_ok`: whether to set the SlaveOkay wire protocol bit
... | tokumx/datadog_checks/tokumx/vendor/pymongo/network.py | def command(sock, dbname, spec, slave_ok, is_mongos,
read_preference, codec_options, check=True,
allowable_errors=None, address=None,
check_keys=False, listeners=None, max_bson_size=None,
read_concern=DEFAULT_READ_CONCERN,
parse_write_concern_error=False,
... | def command(sock, dbname, spec, slave_ok, is_mongos,
read_preference, codec_options, check=True,
allowable_errors=None, address=None,
check_keys=False, listeners=None, max_bson_size=None,
read_concern=DEFAULT_READ_CONCERN,
parse_write_concern_error=False,
... | [
"Execute",
"a",
"command",
"over",
"the",
"socket",
"or",
"raise",
"socket",
".",
"error",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/network.py#L48-L131 | [
"def",
"command",
"(",
"sock",
",",
"dbname",
",",
"spec",
",",
"slave_ok",
",",
"is_mongos",
",",
"read_preference",
",",
"codec_options",
",",
"check",
"=",
"True",
",",
"allowable_errors",
"=",
"None",
",",
"address",
"=",
"None",
",",
"check_keys",
"="... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | receive_message | Receive a raw BSON message or raise socket.error. | tokumx/datadog_checks/tokumx/vendor/pymongo/network.py | def receive_message(
sock, operation, request_id, max_message_size=MAX_MESSAGE_SIZE):
"""Receive a raw BSON message or raise socket.error."""
header = _receive_data_on_socket(sock, 16)
length = _UNPACK_INT(header[:4])[0]
actual_op = _UNPACK_INT(header[12:])[0]
if operation != actual_op:
... | def receive_message(
sock, operation, request_id, max_message_size=MAX_MESSAGE_SIZE):
"""Receive a raw BSON message or raise socket.error."""
header = _receive_data_on_socket(sock, 16)
length = _UNPACK_INT(header[:4])[0]
actual_op = _UNPACK_INT(header[12:])[0]
if operation != actual_op:
... | [
"Receive",
"a",
"raw",
"BSON",
"message",
"or",
"raise",
"socket",
".",
"error",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/network.py#L134-L157 | [
"def",
"receive_message",
"(",
"sock",
",",
"operation",
",",
"request_id",
",",
"max_message_size",
"=",
"MAX_MESSAGE_SIZE",
")",
":",
"header",
"=",
"_receive_data_on_socket",
"(",
"sock",
",",
"16",
")",
"length",
"=",
"_UNPACK_INT",
"(",
"header",
"[",
":"... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | TLSCheck.create_connection | See: https://github.com/python/cpython/blob/40ee9a3640d702bce127e9877c82a99ce817f0d1/Lib/socket.py#L691 | tls/datadog_checks/tls/tls.py | def create_connection(self):
"""See: https://github.com/python/cpython/blob/40ee9a3640d702bce127e9877c82a99ce817f0d1/Lib/socket.py#L691"""
err = None
try:
for res in socket.getaddrinfo(self._server, self._port, 0, self._sock_type):
af, socktype, proto, canonname, sa =... | def create_connection(self):
"""See: https://github.com/python/cpython/blob/40ee9a3640d702bce127e9877c82a99ce817f0d1/Lib/socket.py#L691"""
err = None
try:
for res in socket.getaddrinfo(self._server, self._port, 0, self._sock_type):
af, socktype, proto, canonname, sa =... | [
"See",
":",
"https",
":",
"//",
"github",
".",
"com",
"/",
"python",
"/",
"cpython",
"/",
"blob",
"/",
"40ee9a3640d702bce127e9877c82a99ce817f0d1",
"/",
"Lib",
"/",
"socket",
".",
"py#L691"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tls/datadog_checks/tls/tls.py#L270-L299 | [
"def",
"create_connection",
"(",
"self",
")",
":",
"err",
"=",
"None",
"try",
":",
"for",
"res",
"in",
"socket",
".",
"getaddrinfo",
"(",
"self",
".",
"_server",
",",
"self",
".",
"_port",
",",
"0",
",",
"self",
".",
"_sock_type",
")",
":",
"af",
"... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | dumps | Helper function that wraps :func:`json.dumps`.
Recursive function that handles all BSON types including
:class:`~bson.binary.Binary` and :class:`~bson.code.Code`.
:Parameters:
- `json_options`: A :class:`JSONOptions` instance used to modify the
encoding of MongoDB Extended JSON types. Defaul... | tokumx/datadog_checks/tokumx/vendor/bson/json_util.py | def dumps(obj, *args, **kwargs):
"""Helper function that wraps :func:`json.dumps`.
Recursive function that handles all BSON types including
:class:`~bson.binary.Binary` and :class:`~bson.code.Code`.
:Parameters:
- `json_options`: A :class:`JSONOptions` instance used to modify the
encodin... | def dumps(obj, *args, **kwargs):
"""Helper function that wraps :func:`json.dumps`.
Recursive function that handles all BSON types including
:class:`~bson.binary.Binary` and :class:`~bson.code.Code`.
:Parameters:
- `json_options`: A :class:`JSONOptions` instance used to modify the
encodin... | [
"Helper",
"function",
"that",
"wraps",
":",
"func",
":",
"json",
".",
"dumps",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/bson/json_util.py#L384-L403 | [
"def",
"dumps",
"(",
"obj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"json_options",
"=",
"kwargs",
".",
"pop",
"(",
"\"json_options\"",
",",
"DEFAULT_JSON_OPTIONS",
")",
"return",
"json",
".",
"dumps",
"(",
"_json_convert",
"(",
"obj",
",",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | loads | Helper function that wraps :func:`json.loads`.
Automatically passes the object_hook for BSON type conversion.
Raises ``TypeError``, ``ValueError``, ``KeyError``, or
:exc:`~bson.errors.InvalidId` on invalid MongoDB Extended JSON.
:Parameters:
- `json_options`: A :class:`JSONOptions` instance use... | tokumx/datadog_checks/tokumx/vendor/bson/json_util.py | def loads(s, *args, **kwargs):
"""Helper function that wraps :func:`json.loads`.
Automatically passes the object_hook for BSON type conversion.
Raises ``TypeError``, ``ValueError``, ``KeyError``, or
:exc:`~bson.errors.InvalidId` on invalid MongoDB Extended JSON.
:Parameters:
- `json_options... | def loads(s, *args, **kwargs):
"""Helper function that wraps :func:`json.loads`.
Automatically passes the object_hook for BSON type conversion.
Raises ``TypeError``, ``ValueError``, ``KeyError``, or
:exc:`~bson.errors.InvalidId` on invalid MongoDB Extended JSON.
:Parameters:
- `json_options... | [
"Helper",
"function",
"that",
"wraps",
":",
"func",
":",
"json",
".",
"loads",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/bson/json_util.py#L406-L433 | [
"def",
"loads",
"(",
"s",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"json_options",
"=",
"kwargs",
".",
"pop",
"(",
"\"json_options\"",
",",
"DEFAULT_JSON_OPTIONS",
")",
"if",
"_HAS_OBJECT_PAIRS_HOOK",
":",
"kwargs",
"[",
"\"object_pairs_hook\"",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | _json_convert | Recursive helper method that converts BSON types so they can be
converted into json. | tokumx/datadog_checks/tokumx/vendor/bson/json_util.py | def _json_convert(obj, json_options=DEFAULT_JSON_OPTIONS):
"""Recursive helper method that converts BSON types so they can be
converted into json.
"""
if hasattr(obj, 'iteritems') or hasattr(obj, 'items'): # PY3 support
return SON(((k, _json_convert(v, json_options))
for k, ... | def _json_convert(obj, json_options=DEFAULT_JSON_OPTIONS):
"""Recursive helper method that converts BSON types so they can be
converted into json.
"""
if hasattr(obj, 'iteritems') or hasattr(obj, 'items'): # PY3 support
return SON(((k, _json_convert(v, json_options))
for k, ... | [
"Recursive",
"helper",
"method",
"that",
"converts",
"BSON",
"types",
"so",
"they",
"can",
"be",
"converted",
"into",
"json",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/bson/json_util.py#L436-L448 | [
"def",
"_json_convert",
"(",
"obj",
",",
"json_options",
"=",
"DEFAULT_JSON_OPTIONS",
")",
":",
"if",
"hasattr",
"(",
"obj",
",",
"'iteritems'",
")",
"or",
"hasattr",
"(",
"obj",
",",
"'items'",
")",
":",
"# PY3 support",
"return",
"SON",
"(",
"(",
"(",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | _parse_canonical_datetime | Decode a JSON datetime to python datetime.datetime. | tokumx/datadog_checks/tokumx/vendor/bson/json_util.py | def _parse_canonical_datetime(doc, json_options):
"""Decode a JSON datetime to python datetime.datetime."""
dtm = doc["$date"]
if len(doc) != 1:
raise TypeError('Bad $date, extra field(s): %s' % (doc,))
# mongoexport 2.6 and newer
if isinstance(dtm, string_type):
# Parse offset
... | def _parse_canonical_datetime(doc, json_options):
"""Decode a JSON datetime to python datetime.datetime."""
dtm = doc["$date"]
if len(doc) != 1:
raise TypeError('Bad $date, extra field(s): %s' % (doc,))
# mongoexport 2.6 and newer
if isinstance(dtm, string_type):
# Parse offset
... | [
"Decode",
"a",
"JSON",
"datetime",
"to",
"python",
"datetime",
".",
"datetime",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/bson/json_util.py#L560-L616 | [
"def",
"_parse_canonical_datetime",
"(",
"doc",
",",
"json_options",
")",
":",
"dtm",
"=",
"doc",
"[",
"\"$date\"",
"]",
"if",
"len",
"(",
"doc",
")",
"!=",
"1",
":",
"raise",
"TypeError",
"(",
"'Bad $date, extra field(s): %s'",
"%",
"(",
"doc",
",",
")",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | _parse_canonical_symbol | Decode a JSON symbol to Python string. | tokumx/datadog_checks/tokumx/vendor/bson/json_util.py | def _parse_canonical_symbol(doc):
"""Decode a JSON symbol to Python string."""
symbol = doc['$symbol']
if len(doc) != 1:
raise TypeError('Bad $symbol, extra field(s): %s' % (doc,))
return text_type(symbol) | def _parse_canonical_symbol(doc):
"""Decode a JSON symbol to Python string."""
symbol = doc['$symbol']
if len(doc) != 1:
raise TypeError('Bad $symbol, extra field(s): %s' % (doc,))
return text_type(symbol) | [
"Decode",
"a",
"JSON",
"symbol",
"to",
"Python",
"string",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/bson/json_util.py#L626-L631 | [
"def",
"_parse_canonical_symbol",
"(",
"doc",
")",
":",
"symbol",
"=",
"doc",
"[",
"'$symbol'",
"]",
"if",
"len",
"(",
"doc",
")",
"!=",
"1",
":",
"raise",
"TypeError",
"(",
"'Bad $symbol, extra field(s): %s'",
"%",
"(",
"doc",
",",
")",
")",
"return",
"... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | _parse_canonical_code | Decode a JSON code to bson.code.Code. | tokumx/datadog_checks/tokumx/vendor/bson/json_util.py | def _parse_canonical_code(doc):
"""Decode a JSON code to bson.code.Code."""
for key in doc:
if key not in ('$code', '$scope'):
raise TypeError('Bad $code, extra field(s): %s' % (doc,))
return Code(doc['$code'], scope=doc.get('$scope')) | def _parse_canonical_code(doc):
"""Decode a JSON code to bson.code.Code."""
for key in doc:
if key not in ('$code', '$scope'):
raise TypeError('Bad $code, extra field(s): %s' % (doc,))
return Code(doc['$code'], scope=doc.get('$scope')) | [
"Decode",
"a",
"JSON",
"code",
"to",
"bson",
".",
"code",
".",
"Code",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/bson/json_util.py#L634-L639 | [
"def",
"_parse_canonical_code",
"(",
"doc",
")",
":",
"for",
"key",
"in",
"doc",
":",
"if",
"key",
"not",
"in",
"(",
"'$code'",
",",
"'$scope'",
")",
":",
"raise",
"TypeError",
"(",
"'Bad $code, extra field(s): %s'",
"%",
"(",
"doc",
",",
")",
")",
"retu... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | _parse_canonical_regex | Decode a JSON regex to bson.regex.Regex. | tokumx/datadog_checks/tokumx/vendor/bson/json_util.py | def _parse_canonical_regex(doc):
"""Decode a JSON regex to bson.regex.Regex."""
regex = doc['$regularExpression']
if len(doc) != 1:
raise TypeError('Bad $regularExpression, extra field(s): %s' % (doc,))
if len(regex) != 2:
raise TypeError('Bad $regularExpression must include only "patter... | def _parse_canonical_regex(doc):
"""Decode a JSON regex to bson.regex.Regex."""
regex = doc['$regularExpression']
if len(doc) != 1:
raise TypeError('Bad $regularExpression, extra field(s): %s' % (doc,))
if len(regex) != 2:
raise TypeError('Bad $regularExpression must include only "patter... | [
"Decode",
"a",
"JSON",
"regex",
"to",
"bson",
".",
"regex",
".",
"Regex",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/bson/json_util.py#L642-L650 | [
"def",
"_parse_canonical_regex",
"(",
"doc",
")",
":",
"regex",
"=",
"doc",
"[",
"'$regularExpression'",
"]",
"if",
"len",
"(",
"doc",
")",
"!=",
"1",
":",
"raise",
"TypeError",
"(",
"'Bad $regularExpression, extra field(s): %s'",
"%",
"(",
"doc",
",",
")",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | _parse_canonical_dbref | Decode a JSON DBRef to bson.dbref.DBRef. | tokumx/datadog_checks/tokumx/vendor/bson/json_util.py | def _parse_canonical_dbref(doc):
"""Decode a JSON DBRef to bson.dbref.DBRef."""
for key in doc:
if key.startswith('$') and key not in _DBREF_KEYS:
# Other keys start with $, so dct cannot be parsed as a DBRef.
return doc
return DBRef(doc.pop('$ref'), doc.pop('$id'),
... | def _parse_canonical_dbref(doc):
"""Decode a JSON DBRef to bson.dbref.DBRef."""
for key in doc:
if key.startswith('$') and key not in _DBREF_KEYS:
# Other keys start with $, so dct cannot be parsed as a DBRef.
return doc
return DBRef(doc.pop('$ref'), doc.pop('$id'),
... | [
"Decode",
"a",
"JSON",
"DBRef",
"to",
"bson",
".",
"dbref",
".",
"DBRef",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/bson/json_util.py#L653-L660 | [
"def",
"_parse_canonical_dbref",
"(",
"doc",
")",
":",
"for",
"key",
"in",
"doc",
":",
"if",
"key",
".",
"startswith",
"(",
"'$'",
")",
"and",
"key",
"not",
"in",
"_DBREF_KEYS",
":",
"# Other keys start with $, so dct cannot be parsed as a DBRef.",
"return",
"doc"... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | _parse_canonical_dbpointer | Decode a JSON (deprecated) DBPointer to bson.dbref.DBRef. | tokumx/datadog_checks/tokumx/vendor/bson/json_util.py | def _parse_canonical_dbpointer(doc):
"""Decode a JSON (deprecated) DBPointer to bson.dbref.DBRef."""
dbref = doc['$dbPointer']
if len(doc) != 1:
raise TypeError('Bad $dbPointer, extra field(s): %s' % (doc,))
if isinstance(dbref, DBRef):
dbref_doc = dbref.as_doc()
# DBPointer must... | def _parse_canonical_dbpointer(doc):
"""Decode a JSON (deprecated) DBPointer to bson.dbref.DBRef."""
dbref = doc['$dbPointer']
if len(doc) != 1:
raise TypeError('Bad $dbPointer, extra field(s): %s' % (doc,))
if isinstance(dbref, DBRef):
dbref_doc = dbref.as_doc()
# DBPointer must... | [
"Decode",
"a",
"JSON",
"(",
"deprecated",
")",
"DBPointer",
"to",
"bson",
".",
"dbref",
".",
"DBRef",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/bson/json_util.py#L663-L682 | [
"def",
"_parse_canonical_dbpointer",
"(",
"doc",
")",
":",
"dbref",
"=",
"doc",
"[",
"'$dbPointer'",
"]",
"if",
"len",
"(",
"doc",
")",
"!=",
"1",
":",
"raise",
"TypeError",
"(",
"'Bad $dbPointer, extra field(s): %s'",
"%",
"(",
"doc",
",",
")",
")",
"if",... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | _parse_canonical_int32 | Decode a JSON int32 to python int. | tokumx/datadog_checks/tokumx/vendor/bson/json_util.py | def _parse_canonical_int32(doc):
"""Decode a JSON int32 to python int."""
i_str = doc['$numberInt']
if len(doc) != 1:
raise TypeError('Bad $numberInt, extra field(s): %s' % (doc,))
if not isinstance(i_str, string_type):
raise TypeError('$numberInt must be string: %s' % (doc,))
return... | def _parse_canonical_int32(doc):
"""Decode a JSON int32 to python int."""
i_str = doc['$numberInt']
if len(doc) != 1:
raise TypeError('Bad $numberInt, extra field(s): %s' % (doc,))
if not isinstance(i_str, string_type):
raise TypeError('$numberInt must be string: %s' % (doc,))
return... | [
"Decode",
"a",
"JSON",
"int32",
"to",
"python",
"int",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/bson/json_util.py#L685-L692 | [
"def",
"_parse_canonical_int32",
"(",
"doc",
")",
":",
"i_str",
"=",
"doc",
"[",
"'$numberInt'",
"]",
"if",
"len",
"(",
"doc",
")",
"!=",
"1",
":",
"raise",
"TypeError",
"(",
"'Bad $numberInt, extra field(s): %s'",
"%",
"(",
"doc",
",",
")",
")",
"if",
"... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | _parse_canonical_int64 | Decode a JSON int64 to bson.int64.Int64. | tokumx/datadog_checks/tokumx/vendor/bson/json_util.py | def _parse_canonical_int64(doc):
"""Decode a JSON int64 to bson.int64.Int64."""
l_str = doc['$numberLong']
if len(doc) != 1:
raise TypeError('Bad $numberLong, extra field(s): %s' % (doc,))
return Int64(l_str) | def _parse_canonical_int64(doc):
"""Decode a JSON int64 to bson.int64.Int64."""
l_str = doc['$numberLong']
if len(doc) != 1:
raise TypeError('Bad $numberLong, extra field(s): %s' % (doc,))
return Int64(l_str) | [
"Decode",
"a",
"JSON",
"int64",
"to",
"bson",
".",
"int64",
".",
"Int64",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/bson/json_util.py#L695-L700 | [
"def",
"_parse_canonical_int64",
"(",
"doc",
")",
":",
"l_str",
"=",
"doc",
"[",
"'$numberLong'",
"]",
"if",
"len",
"(",
"doc",
")",
"!=",
"1",
":",
"raise",
"TypeError",
"(",
"'Bad $numberLong, extra field(s): %s'",
"%",
"(",
"doc",
",",
")",
")",
"return... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | _parse_canonical_double | Decode a JSON double to python float. | tokumx/datadog_checks/tokumx/vendor/bson/json_util.py | def _parse_canonical_double(doc):
"""Decode a JSON double to python float."""
d_str = doc['$numberDouble']
if len(doc) != 1:
raise TypeError('Bad $numberDouble, extra field(s): %s' % (doc,))
if not isinstance(d_str, string_type):
raise TypeError('$numberDouble must be string: %s' % (doc,... | def _parse_canonical_double(doc):
"""Decode a JSON double to python float."""
d_str = doc['$numberDouble']
if len(doc) != 1:
raise TypeError('Bad $numberDouble, extra field(s): %s' % (doc,))
if not isinstance(d_str, string_type):
raise TypeError('$numberDouble must be string: %s' % (doc,... | [
"Decode",
"a",
"JSON",
"double",
"to",
"python",
"float",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/bson/json_util.py#L703-L710 | [
"def",
"_parse_canonical_double",
"(",
"doc",
")",
":",
"d_str",
"=",
"doc",
"[",
"'$numberDouble'",
"]",
"if",
"len",
"(",
"doc",
")",
"!=",
"1",
":",
"raise",
"TypeError",
"(",
"'Bad $numberDouble, extra field(s): %s'",
"%",
"(",
"doc",
",",
")",
")",
"i... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | _parse_canonical_decimal128 | Decode a JSON decimal128 to bson.decimal128.Decimal128. | tokumx/datadog_checks/tokumx/vendor/bson/json_util.py | def _parse_canonical_decimal128(doc):
"""Decode a JSON decimal128 to bson.decimal128.Decimal128."""
d_str = doc['$numberDecimal']
if len(doc) != 1:
raise TypeError('Bad $numberDecimal, extra field(s): %s' % (doc,))
if not isinstance(d_str, string_type):
raise TypeError('$numberDecimal mu... | def _parse_canonical_decimal128(doc):
"""Decode a JSON decimal128 to bson.decimal128.Decimal128."""
d_str = doc['$numberDecimal']
if len(doc) != 1:
raise TypeError('Bad $numberDecimal, extra field(s): %s' % (doc,))
if not isinstance(d_str, string_type):
raise TypeError('$numberDecimal mu... | [
"Decode",
"a",
"JSON",
"decimal128",
"to",
"bson",
".",
"decimal128",
".",
"Decimal128",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/bson/json_util.py#L713-L720 | [
"def",
"_parse_canonical_decimal128",
"(",
"doc",
")",
":",
"d_str",
"=",
"doc",
"[",
"'$numberDecimal'",
"]",
"if",
"len",
"(",
"doc",
")",
"!=",
"1",
":",
"raise",
"TypeError",
"(",
"'Bad $numberDecimal, extra field(s): %s'",
"%",
"(",
"doc",
",",
")",
")"... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | _parse_canonical_minkey | Decode a JSON MinKey to bson.min_key.MinKey. | tokumx/datadog_checks/tokumx/vendor/bson/json_util.py | def _parse_canonical_minkey(doc):
"""Decode a JSON MinKey to bson.min_key.MinKey."""
if doc['$minKey'] is not 1:
raise TypeError('$minKey value must be 1: %s' % (doc,))
if len(doc) != 1:
raise TypeError('Bad $minKey, extra field(s): %s' % (doc,))
return MinKey() | def _parse_canonical_minkey(doc):
"""Decode a JSON MinKey to bson.min_key.MinKey."""
if doc['$minKey'] is not 1:
raise TypeError('$minKey value must be 1: %s' % (doc,))
if len(doc) != 1:
raise TypeError('Bad $minKey, extra field(s): %s' % (doc,))
return MinKey() | [
"Decode",
"a",
"JSON",
"MinKey",
"to",
"bson",
".",
"min_key",
".",
"MinKey",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/bson/json_util.py#L723-L729 | [
"def",
"_parse_canonical_minkey",
"(",
"doc",
")",
":",
"if",
"doc",
"[",
"'$minKey'",
"]",
"is",
"not",
"1",
":",
"raise",
"TypeError",
"(",
"'$minKey value must be 1: %s'",
"%",
"(",
"doc",
",",
")",
")",
"if",
"len",
"(",
"doc",
")",
"!=",
"1",
":",... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | _parse_canonical_maxkey | Decode a JSON MaxKey to bson.max_key.MaxKey. | tokumx/datadog_checks/tokumx/vendor/bson/json_util.py | def _parse_canonical_maxkey(doc):
"""Decode a JSON MaxKey to bson.max_key.MaxKey."""
if doc['$maxKey'] is not 1:
raise TypeError('$maxKey value must be 1: %s', (doc,))
if len(doc) != 1:
raise TypeError('Bad $minKey, extra field(s): %s' % (doc,))
return MaxKey() | def _parse_canonical_maxkey(doc):
"""Decode a JSON MaxKey to bson.max_key.MaxKey."""
if doc['$maxKey'] is not 1:
raise TypeError('$maxKey value must be 1: %s', (doc,))
if len(doc) != 1:
raise TypeError('Bad $minKey, extra field(s): %s' % (doc,))
return MaxKey() | [
"Decode",
"a",
"JSON",
"MaxKey",
"to",
"bson",
".",
"max_key",
".",
"MaxKey",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/bson/json_util.py#L732-L738 | [
"def",
"_parse_canonical_maxkey",
"(",
"doc",
")",
":",
"if",
"doc",
"[",
"'$maxKey'",
"]",
"is",
"not",
"1",
":",
"raise",
"TypeError",
"(",
"'$maxKey value must be 1: %s'",
",",
"(",
"doc",
",",
")",
")",
"if",
"len",
"(",
"doc",
")",
"!=",
"1",
":",... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | _parse_credentials | Parse authentication credentials. | tokumx/datadog_checks/tokumx/vendor/pymongo/client_options.py | def _parse_credentials(username, password, database, options):
"""Parse authentication credentials."""
mechanism = options.get('authmechanism', 'DEFAULT')
if username is None and mechanism != 'MONGODB-X509':
return None
source = options.get('authsource', database or 'admin')
return _build_cr... | def _parse_credentials(username, password, database, options):
"""Parse authentication credentials."""
mechanism = options.get('authmechanism', 'DEFAULT')
if username is None and mechanism != 'MONGODB-X509':
return None
source = options.get('authsource', database or 'admin')
return _build_cr... | [
"Parse",
"authentication",
"credentials",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/client_options.py#L31-L38 | [
"def",
"_parse_credentials",
"(",
"username",
",",
"password",
",",
"database",
",",
"options",
")",
":",
"mechanism",
"=",
"options",
".",
"get",
"(",
"'authmechanism'",
",",
"'DEFAULT'",
")",
"if",
"username",
"is",
"None",
"and",
"mechanism",
"!=",
"'MONG... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | _parse_read_preference | Parse read preference options. | tokumx/datadog_checks/tokumx/vendor/pymongo/client_options.py | def _parse_read_preference(options):
"""Parse read preference options."""
if 'read_preference' in options:
return options['read_preference']
name = options.get('readpreference', 'primary')
mode = read_pref_mode_from_name(name)
tags = options.get('readpreferencetags')
max_staleness = opt... | def _parse_read_preference(options):
"""Parse read preference options."""
if 'read_preference' in options:
return options['read_preference']
name = options.get('readpreference', 'primary')
mode = read_pref_mode_from_name(name)
tags = options.get('readpreferencetags')
max_staleness = opt... | [
"Parse",
"read",
"preference",
"options",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/client_options.py#L41-L50 | [
"def",
"_parse_read_preference",
"(",
"options",
")",
":",
"if",
"'read_preference'",
"in",
"options",
":",
"return",
"options",
"[",
"'read_preference'",
"]",
"name",
"=",
"options",
".",
"get",
"(",
"'readpreference'",
",",
"'primary'",
")",
"mode",
"=",
"re... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | _parse_pool_options | Parse connection pool options. | tokumx/datadog_checks/tokumx/vendor/pymongo/client_options.py | def _parse_pool_options(options):
"""Parse connection pool options."""
max_pool_size = options.get('maxpoolsize', common.MAX_POOL_SIZE)
min_pool_size = options.get('minpoolsize', common.MIN_POOL_SIZE)
max_idle_time_ms = options.get('maxidletimems', common.MAX_IDLE_TIME_MS)
if max_pool_size is not No... | def _parse_pool_options(options):
"""Parse connection pool options."""
max_pool_size = options.get('maxpoolsize', common.MAX_POOL_SIZE)
min_pool_size = options.get('minpoolsize', common.MIN_POOL_SIZE)
max_idle_time_ms = options.get('maxidletimems', common.MAX_IDLE_TIME_MS)
if max_pool_size is not No... | [
"Parse",
"connection",
"pool",
"options",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/client_options.py#L101-L123 | [
"def",
"_parse_pool_options",
"(",
"options",
")",
":",
"max_pool_size",
"=",
"options",
".",
"get",
"(",
"'maxpoolsize'",
",",
"common",
".",
"MAX_POOL_SIZE",
")",
"min_pool_size",
"=",
"options",
".",
"get",
"(",
"'minpoolsize'",
",",
"common",
".",
"MIN_POO... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | service_checks | Validate all `service_checks.json` files. | datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/service_checks.py | def service_checks():
"""Validate all `service_checks.json` files."""
root = get_root()
echo_info("Validating all service_checks.json files...")
failed_checks = 0
ok_checks = 0
for check_name in sorted(os.listdir(root)):
service_checks_file = os.path.join(root, check_name, 'service_check... | def service_checks():
"""Validate all `service_checks.json` files."""
root = get_root()
echo_info("Validating all service_checks.json files...")
failed_checks = 0
ok_checks = 0
for check_name in sorted(os.listdir(root)):
service_checks_file = os.path.join(root, check_name, 'service_check... | [
"Validate",
"all",
"service_checks",
".",
"json",
"files",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/service_checks.py#L21-L130 | [
"def",
"service_checks",
"(",
")",
":",
"root",
"=",
"get_root",
"(",
")",
"echo_info",
"(",
"\"Validating all service_checks.json files...\"",
")",
"failed_checks",
"=",
"0",
"ok_checks",
"=",
"0",
"for",
"check_name",
"in",
"sorted",
"(",
"os",
".",
"listdir",... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | from_time | Convenience wrapper to take a series of date/time elements and return a WMI time
of the form `yyyymmddHHMMSS.mmmmmm+UUU`. All elements may be int, string or
omitted altogether. If omitted, they will be replaced in the output string
by a series of stars of the appropriate length.
:param year: The year el... | datadog_checks_base/datadog_checks/base/checks/win/wmi/__init__.py | def from_time(
year=None, month=None, day=None, hours=None, minutes=None, seconds=None, microseconds=None, timezone=None
):
"""Convenience wrapper to take a series of date/time elements and return a WMI time
of the form `yyyymmddHHMMSS.mmmmmm+UUU`. All elements may be int, string or
omitted altogether. ... | def from_time(
year=None, month=None, day=None, hours=None, minutes=None, seconds=None, microseconds=None, timezone=None
):
"""Convenience wrapper to take a series of date/time elements and return a WMI time
of the form `yyyymmddHHMMSS.mmmmmm+UUU`. All elements may be int, string or
omitted altogether. ... | [
"Convenience",
"wrapper",
"to",
"take",
"a",
"series",
"of",
"date",
"/",
"time",
"elements",
"and",
"return",
"a",
"WMI",
"time",
"of",
"the",
"form",
"yyyymmddHHMMSS",
".",
"mmmmmm",
"+",
"UUU",
".",
"All",
"elements",
"may",
"be",
"int",
"string",
"or... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/win/wmi/__init__.py#L263-L311 | [
"def",
"from_time",
"(",
"year",
"=",
"None",
",",
"month",
"=",
"None",
",",
"day",
"=",
"None",
",",
"hours",
"=",
"None",
",",
"minutes",
"=",
"None",
",",
"seconds",
"=",
"None",
",",
"microseconds",
"=",
"None",
",",
"timezone",
"=",
"None",
"... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | to_time | Convenience wrapper to take a WMI datetime string of the form
yyyymmddHHMMSS.mmmmmm+UUU and return a 9-tuple containing the
individual elements, or None where string contains placeholder
stars.
:param wmi_time: The WMI datetime string in `yyyymmddHHMMSS.mmmmmm+UUU` format
:returns: A 9-tuple of (y... | datadog_checks_base/datadog_checks/base/checks/win/wmi/__init__.py | def to_time(wmi_time):
"""Convenience wrapper to take a WMI datetime string of the form
yyyymmddHHMMSS.mmmmmm+UUU and return a 9-tuple containing the
individual elements, or None where string contains placeholder
stars.
:param wmi_time: The WMI datetime string in `yyyymmddHHMMSS.mmmmmm+UUU` format
... | def to_time(wmi_time):
"""Convenience wrapper to take a WMI datetime string of the form
yyyymmddHHMMSS.mmmmmm+UUU and return a 9-tuple containing the
individual elements, or None where string contains placeholder
stars.
:param wmi_time: The WMI datetime string in `yyyymmddHHMMSS.mmmmmm+UUU` format
... | [
"Convenience",
"wrapper",
"to",
"take",
"a",
"WMI",
"datetime",
"string",
"of",
"the",
"form",
"yyyymmddHHMMSS",
".",
"mmmmmm",
"+",
"UUU",
"and",
"return",
"a",
"9",
"-",
"tuple",
"containing",
"the",
"individual",
"elements",
"or",
"None",
"where",
"string... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/win/wmi/__init__.py#L314-L343 | [
"def",
"to_time",
"(",
"wmi_time",
")",
":",
"def",
"int_or_none",
"(",
"s",
",",
"start",
",",
"end",
")",
":",
"try",
":",
"return",
"int",
"(",
"s",
"[",
"start",
":",
"end",
"]",
")",
"except",
"ValueError",
":",
"return",
"None",
"year",
"=",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | WinWMICheck._format_tag_query | Format `tag_query` or raise on incorrect parameters. | datadog_checks_base/datadog_checks/base/checks/win/wmi/__init__.py | def _format_tag_query(self, sampler, wmi_obj, tag_query):
"""
Format `tag_query` or raise on incorrect parameters.
"""
try:
link_source_property = int(wmi_obj[tag_query[0]])
target_class = tag_query[1]
link_target_class_property = tag_query[2]
... | def _format_tag_query(self, sampler, wmi_obj, tag_query):
"""
Format `tag_query` or raise on incorrect parameters.
"""
try:
link_source_property = int(wmi_obj[tag_query[0]])
target_class = tag_query[1]
link_target_class_property = tag_query[2]
... | [
"Format",
"tag_query",
"or",
"raise",
"on",
"incorrect",
"parameters",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/win/wmi/__init__.py#L50-L73 | [
"def",
"_format_tag_query",
"(",
"self",
",",
"sampler",
",",
"wmi_obj",
",",
"tag_query",
")",
":",
"try",
":",
"link_source_property",
"=",
"int",
"(",
"wmi_obj",
"[",
"tag_query",
"[",
"0",
"]",
"]",
")",
"target_class",
"=",
"tag_query",
"[",
"1",
"]... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | WinWMICheck._get_tag_query_tag | Design a query based on the given WMIObject to extract a tag.
Returns: tag or TagQueryUniquenessFailure exception. | datadog_checks_base/datadog_checks/base/checks/win/wmi/__init__.py | def _get_tag_query_tag(self, sampler, wmi_obj, tag_query):
"""
Design a query based on the given WMIObject to extract a tag.
Returns: tag or TagQueryUniquenessFailure exception.
"""
self.log.debug(
u"`tag_queries` parameter found."
" wmi_object={wmi_obj} ... | def _get_tag_query_tag(self, sampler, wmi_obj, tag_query):
"""
Design a query based on the given WMIObject to extract a tag.
Returns: tag or TagQueryUniquenessFailure exception.
"""
self.log.debug(
u"`tag_queries` parameter found."
" wmi_object={wmi_obj} ... | [
"Design",
"a",
"query",
"based",
"on",
"the",
"given",
"WMIObject",
"to",
"extract",
"a",
"tag",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/win/wmi/__init__.py#L100-L127 | [
"def",
"_get_tag_query_tag",
"(",
"self",
",",
"sampler",
",",
"wmi_obj",
",",
"tag_query",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"u\"`tag_queries` parameter found.\"",
"\" wmi_object={wmi_obj} - query={tag_query}\"",
".",
"format",
"(",
"wmi_obj",
"=",
"... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | WinWMICheck._extract_metrics | Extract and tag metrics from the WMISampler.
Raise when multiple WMIObject were returned by the sampler with no `tag_by` specified.
Returns: List of WMIMetric
```
[
WMIMetric("freemegabytes", 19742, ["name:_total"]),
WMIMetric("avgdiskbytesperwrite", 1536, ["nam... | datadog_checks_base/datadog_checks/base/checks/win/wmi/__init__.py | def _extract_metrics(self, wmi_sampler, tag_by, tag_queries, constant_tags):
"""
Extract and tag metrics from the WMISampler.
Raise when multiple WMIObject were returned by the sampler with no `tag_by` specified.
Returns: List of WMIMetric
```
[
WMIMetric("f... | def _extract_metrics(self, wmi_sampler, tag_by, tag_queries, constant_tags):
"""
Extract and tag metrics from the WMISampler.
Raise when multiple WMIObject were returned by the sampler with no `tag_by` specified.
Returns: List of WMIMetric
```
[
WMIMetric("f... | [
"Extract",
"and",
"tag",
"metrics",
"from",
"the",
"WMISampler",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/win/wmi/__init__.py#L129-L197 | [
"def",
"_extract_metrics",
"(",
"self",
",",
"wmi_sampler",
",",
"tag_by",
",",
"tag_queries",
",",
"constant_tags",
")",
":",
"if",
"len",
"(",
"wmi_sampler",
")",
">",
"1",
"and",
"not",
"tag_by",
":",
"raise",
"MissingTagBy",
"(",
"u\"WMI query returned mul... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | WinWMICheck._submit_metrics | Resolve metric names and types and submit it. | datadog_checks_base/datadog_checks/base/checks/win/wmi/__init__.py | def _submit_metrics(self, metrics, metric_name_and_type_by_property):
"""
Resolve metric names and types and submit it.
"""
for metric in metrics:
if (
metric.name not in metric_name_and_type_by_property
and metric.name.lower() not in metric_na... | def _submit_metrics(self, metrics, metric_name_and_type_by_property):
"""
Resolve metric names and types and submit it.
"""
for metric in metrics:
if (
metric.name not in metric_name_and_type_by_property
and metric.name.lower() not in metric_na... | [
"Resolve",
"metric",
"names",
"and",
"types",
"and",
"submit",
"it",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/win/wmi/__init__.py#L199-L224 | [
"def",
"_submit_metrics",
"(",
"self",
",",
"metrics",
",",
"metric_name_and_type_by_property",
")",
":",
"for",
"metric",
"in",
"metrics",
":",
"if",
"(",
"metric",
".",
"name",
"not",
"in",
"metric_name_and_type_by_property",
"and",
"metric",
".",
"name",
".",... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | WinWMICheck._get_instance_key | Return an index key for a given instance. Useful for caching. | datadog_checks_base/datadog_checks/base/checks/win/wmi/__init__.py | def _get_instance_key(self, host, namespace, wmi_class, other=None):
"""
Return an index key for a given instance. Useful for caching.
"""
if other:
return "{host}:{namespace}:{wmi_class}-{other}".format(
host=host, namespace=namespace, wmi_class=wmi_class, ot... | def _get_instance_key(self, host, namespace, wmi_class, other=None):
"""
Return an index key for a given instance. Useful for caching.
"""
if other:
return "{host}:{namespace}:{wmi_class}-{other}".format(
host=host, namespace=namespace, wmi_class=wmi_class, ot... | [
"Return",
"an",
"index",
"key",
"for",
"a",
"given",
"instance",
".",
"Useful",
"for",
"caching",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/win/wmi/__init__.py#L226-L235 | [
"def",
"_get_instance_key",
"(",
"self",
",",
"host",
",",
"namespace",
",",
"wmi_class",
",",
"other",
"=",
"None",
")",
":",
"if",
"other",
":",
"return",
"\"{host}:{namespace}:{wmi_class}-{other}\"",
".",
"format",
"(",
"host",
"=",
"host",
",",
"namespace"... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | WinWMICheck._get_wmi_sampler | Create and cache a WMISampler for the given (class, properties) | datadog_checks_base/datadog_checks/base/checks/win/wmi/__init__.py | def _get_wmi_sampler(self, instance_key, wmi_class, properties, tag_by="", **kwargs):
"""
Create and cache a WMISampler for the given (class, properties)
"""
properties = list(properties) + [tag_by] if tag_by else list(properties)
if instance_key not in self.wmi_samplers:
... | def _get_wmi_sampler(self, instance_key, wmi_class, properties, tag_by="", **kwargs):
"""
Create and cache a WMISampler for the given (class, properties)
"""
properties = list(properties) + [tag_by] if tag_by else list(properties)
if instance_key not in self.wmi_samplers:
... | [
"Create",
"and",
"cache",
"a",
"WMISampler",
"for",
"the",
"given",
"(",
"class",
"properties",
")"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/win/wmi/__init__.py#L237-L247 | [
"def",
"_get_wmi_sampler",
"(",
"self",
",",
"instance_key",
",",
"wmi_class",
",",
"properties",
",",
"tag_by",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"properties",
"=",
"list",
"(",
"properties",
")",
"+",
"[",
"tag_by",
"]",
"if",
"tag_by",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | WinWMICheck._get_wmi_properties | Create and cache a (metric name, metric type) by WMI property map and a property list. | datadog_checks_base/datadog_checks/base/checks/win/wmi/__init__.py | def _get_wmi_properties(self, instance_key, metrics, tag_queries):
"""
Create and cache a (metric name, metric type) by WMI property map and a property list.
"""
if instance_key not in self.wmi_props:
metric_name_by_property = dict(
(wmi_property.lower(), (met... | def _get_wmi_properties(self, instance_key, metrics, tag_queries):
"""
Create and cache a (metric name, metric type) by WMI property map and a property list.
"""
if instance_key not in self.wmi_props:
metric_name_by_property = dict(
(wmi_property.lower(), (met... | [
"Create",
"and",
"cache",
"a",
"(",
"metric",
"name",
"metric",
"type",
")",
"by",
"WMI",
"property",
"map",
"and",
"a",
"property",
"list",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/win/wmi/__init__.py#L249-L260 | [
"def",
"_get_wmi_properties",
"(",
"self",
",",
"instance_key",
",",
"metrics",
",",
"tag_queries",
")",
":",
"if",
"instance_key",
"not",
"in",
"self",
".",
"wmi_props",
":",
"metric_name_by_property",
"=",
"dict",
"(",
"(",
"wmi_property",
".",
"lower",
"(",... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.