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
get_single_color_func
Create a color function which returns a single hue and saturation with. different values (HSV). Accepted values are color strings as usable by PIL/Pillow. >>> color_func1 = get_single_color_func('deepskyblue') >>> color_func2 = get_single_color_func('#00b4d2')
wordcloud/wordcloud.py
def get_single_color_func(color): """Create a color function which returns a single hue and saturation with. different values (HSV). Accepted values are color strings as usable by PIL/Pillow. >>> color_func1 = get_single_color_func('deepskyblue') >>> color_func2 = get_single_color_func('#00b4d2') ...
def get_single_color_func(color): """Create a color function which returns a single hue and saturation with. different values (HSV). Accepted values are color strings as usable by PIL/Pillow. >>> color_func1 = get_single_color_func('deepskyblue') >>> color_func2 = get_single_color_func('#00b4d2') ...
[ "Create", "a", "color", "function", "which", "returns", "a", "single", "hue", "and", "saturation", "with", ".", "different", "values", "(", "HSV", ")", ".", "Accepted", "values", "are", "color", "strings", "as", "usable", "by", "PIL", "/", "Pillow", "." ]
amueller/word_cloud
python
https://github.com/amueller/word_cloud/blob/d36f526e3d8346e6d7a2656631f05f68e402517d/wordcloud/wordcloud.py#L113-L147
[ "def", "get_single_color_func", "(", "color", ")", ":", "old_r", ",", "old_g", ",", "old_b", "=", "ImageColor", ".", "getrgb", "(", "color", ")", "rgb_max", "=", "255.", "h", ",", "s", ",", "v", "=", "colorsys", ".", "rgb_to_hsv", "(", "old_r", "/", ...
d36f526e3d8346e6d7a2656631f05f68e402517d
train
WordCloud.generate_from_frequencies
Create a word_cloud from words and frequencies. Parameters ---------- frequencies : dict from string to float A contains words and associated frequency. max_font_size : int Use this font-size instead of self.max_font_size Returns ------- ...
wordcloud/wordcloud.py
def generate_from_frequencies(self, frequencies, max_font_size=None): # noqa: C901 """Create a word_cloud from words and frequencies. Parameters ---------- frequencies : dict from string to float A contains words and associated frequency. max_font_size : int ...
def generate_from_frequencies(self, frequencies, max_font_size=None): # noqa: C901 """Create a word_cloud from words and frequencies. Parameters ---------- frequencies : dict from string to float A contains words and associated frequency. max_font_size : int ...
[ "Create", "a", "word_cloud", "from", "words", "and", "frequencies", "." ]
amueller/word_cloud
python
https://github.com/amueller/word_cloud/blob/d36f526e3d8346e6d7a2656631f05f68e402517d/wordcloud/wordcloud.py#L371-L531
[ "def", "generate_from_frequencies", "(", "self", ",", "frequencies", ",", "max_font_size", "=", "None", ")", ":", "# noqa: C901", "# make sure frequencies are sorted and normalized", "frequencies", "=", "sorted", "(", "frequencies", ".", "items", "(", ")", ",", "key",...
d36f526e3d8346e6d7a2656631f05f68e402517d
train
WordCloud.process_text
Splits a long text into words, eliminates the stopwords. Parameters ---------- text : string The text to be processed. Returns ------- words : dict (string, int) Word tokens with associated frequency. ..versionchanged:: 1.2.2 ...
wordcloud/wordcloud.py
def process_text(self, text): """Splits a long text into words, eliminates the stopwords. Parameters ---------- text : string The text to be processed. Returns ------- words : dict (string, int) Word tokens with associated frequency. ...
def process_text(self, text): """Splits a long text into words, eliminates the stopwords. Parameters ---------- text : string The text to be processed. Returns ------- words : dict (string, int) Word tokens with associated frequency. ...
[ "Splits", "a", "long", "text", "into", "words", "eliminates", "the", "stopwords", "." ]
amueller/word_cloud
python
https://github.com/amueller/word_cloud/blob/d36f526e3d8346e6d7a2656631f05f68e402517d/wordcloud/wordcloud.py#L533-L579
[ "def", "process_text", "(", "self", ",", "text", ")", ":", "stopwords", "=", "set", "(", "[", "i", ".", "lower", "(", ")", "for", "i", "in", "self", ".", "stopwords", "]", ")", "flags", "=", "(", "re", ".", "UNICODE", "if", "sys", ".", "version",...
d36f526e3d8346e6d7a2656631f05f68e402517d
train
WordCloud.generate_from_text
Generate wordcloud from text. The input "text" is expected to be a natural text. If you pass a sorted list of words, words will appear in your output twice. To remove this duplication, set ``collocations=False``. Calls process_text and generate_from_frequencies. ..versionchang...
wordcloud/wordcloud.py
def generate_from_text(self, text): """Generate wordcloud from text. The input "text" is expected to be a natural text. If you pass a sorted list of words, words will appear in your output twice. To remove this duplication, set ``collocations=False``. Calls process_text and gen...
def generate_from_text(self, text): """Generate wordcloud from text. The input "text" is expected to be a natural text. If you pass a sorted list of words, words will appear in your output twice. To remove this duplication, set ``collocations=False``. Calls process_text and gen...
[ "Generate", "wordcloud", "from", "text", "." ]
amueller/word_cloud
python
https://github.com/amueller/word_cloud/blob/d36f526e3d8346e6d7a2656631f05f68e402517d/wordcloud/wordcloud.py#L581-L600
[ "def", "generate_from_text", "(", "self", ",", "text", ")", ":", "words", "=", "self", ".", "process_text", "(", "text", ")", "self", ".", "generate_from_frequencies", "(", "words", ")", "return", "self" ]
d36f526e3d8346e6d7a2656631f05f68e402517d
train
WordCloud.recolor
Recolor existing layout. Applying a new coloring is much faster than generating the whole wordcloud. Parameters ---------- random_state : RandomState, int, or None, default=None If not None, a fixed random state is used. If an int is given, this is used ...
wordcloud/wordcloud.py
def recolor(self, random_state=None, color_func=None, colormap=None): """Recolor existing layout. Applying a new coloring is much faster than generating the whole wordcloud. Parameters ---------- random_state : RandomState, int, or None, default=None If not ...
def recolor(self, random_state=None, color_func=None, colormap=None): """Recolor existing layout. Applying a new coloring is much faster than generating the whole wordcloud. Parameters ---------- random_state : RandomState, int, or None, default=None If not ...
[ "Recolor", "existing", "layout", "." ]
amueller/word_cloud
python
https://github.com/amueller/word_cloud/blob/d36f526e3d8346e6d7a2656631f05f68e402517d/wordcloud/wordcloud.py#L648-L688
[ "def", "recolor", "(", "self", ",", "random_state", "=", "None", ",", "color_func", "=", "None", ",", "colormap", "=", "None", ")", ":", "if", "isinstance", "(", "random_state", ",", "int", ")", ":", "random_state", "=", "Random", "(", "random_state", ")...
d36f526e3d8346e6d7a2656631f05f68e402517d
train
WordCloud.to_file
Export to image file. Parameters ---------- filename : string Location to write to. Returns ------- self
wordcloud/wordcloud.py
def to_file(self, filename): """Export to image file. Parameters ---------- filename : string Location to write to. Returns ------- self """ img = self.to_image() img.save(filename, optimize=True) return self
def to_file(self, filename): """Export to image file. Parameters ---------- filename : string Location to write to. Returns ------- self """ img = self.to_image() img.save(filename, optimize=True) return self
[ "Export", "to", "image", "file", "." ]
amueller/word_cloud
python
https://github.com/amueller/word_cloud/blob/d36f526e3d8346e6d7a2656631f05f68e402517d/wordcloud/wordcloud.py#L690-L705
[ "def", "to_file", "(", "self", ",", "filename", ")", ":", "img", "=", "self", ".", "to_image", "(", ")", "img", ".", "save", "(", "filename", ",", "optimize", "=", "True", ")", "return", "self" ]
d36f526e3d8346e6d7a2656631f05f68e402517d
train
WordCloud._get_bolean_mask
Cast to two dimensional boolean mask.
wordcloud/wordcloud.py
def _get_bolean_mask(self, mask): """Cast to two dimensional boolean mask.""" if mask.dtype.kind == 'f': warnings.warn("mask image should be unsigned byte between 0" " and 255. Got a float array") if mask.ndim == 2: boolean_mask = mask == 255 ...
def _get_bolean_mask(self, mask): """Cast to two dimensional boolean mask.""" if mask.dtype.kind == 'f': warnings.warn("mask image should be unsigned byte between 0" " and 255. Got a float array") if mask.ndim == 2: boolean_mask = mask == 255 ...
[ "Cast", "to", "two", "dimensional", "boolean", "mask", "." ]
amueller/word_cloud
python
https://github.com/amueller/word_cloud/blob/d36f526e3d8346e6d7a2656631f05f68e402517d/wordcloud/wordcloud.py#L730-L742
[ "def", "_get_bolean_mask", "(", "self", ",", "mask", ")", ":", "if", "mask", ".", "dtype", ".", "kind", "==", "'f'", ":", "warnings", ".", "warn", "(", "\"mask image should be unsigned byte between 0\"", "\" and 255. Got a float array\"", ")", "if", "mask", ".", ...
d36f526e3d8346e6d7a2656631f05f68e402517d
train
WordCloud._draw_contour
Draw mask contour on a pillow image.
wordcloud/wordcloud.py
def _draw_contour(self, img): """Draw mask contour on a pillow image.""" if self.mask is None or self.contour_width == 0: return img mask = self._get_bolean_mask(self.mask) * 255 contour = Image.fromarray(mask.astype(np.uint8)) contour = contour.resize(img.size) ...
def _draw_contour(self, img): """Draw mask contour on a pillow image.""" if self.mask is None or self.contour_width == 0: return img mask = self._get_bolean_mask(self.mask) * 255 contour = Image.fromarray(mask.astype(np.uint8)) contour = contour.resize(img.size) ...
[ "Draw", "mask", "contour", "on", "a", "pillow", "image", "." ]
amueller/word_cloud
python
https://github.com/amueller/word_cloud/blob/d36f526e3d8346e6d7a2656631f05f68e402517d/wordcloud/wordcloud.py#L744-L772
[ "def", "_draw_contour", "(", "self", ",", "img", ")", ":", "if", "self", ".", "mask", "is", "None", "or", "self", ".", "contour_width", "==", "0", ":", "return", "img", "mask", "=", "self", ".", "_get_bolean_mask", "(", "self", ".", "mask", ")", "*",...
d36f526e3d8346e6d7a2656631f05f68e402517d
train
KubeLeaderElectionMixin.check_election_status
Retrieves the leader-election annotation from a given object, and submits metrics and a service check. An integration warning is sent if the object is not retrievable, or no record is found. Monitors on the service-check should have no-data alerts enabled to account for this. T...
datadog_checks_base/datadog_checks/base/checks/kube_leader/mixins.py
def check_election_status(self, config): """ Retrieves the leader-election annotation from a given object, and submits metrics and a service check. An integration warning is sent if the object is not retrievable, or no record is found. Monitors on the service-check should have ...
def check_election_status(self, config): """ Retrieves the leader-election annotation from a given object, and submits metrics and a service check. An integration warning is sent if the object is not retrievable, or no record is found. Monitors on the service-check should have ...
[ "Retrieves", "the", "leader", "-", "election", "annotation", "from", "a", "given", "object", "and", "submits", "metrics", "and", "a", "service", "check", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/kube_leader/mixins.py#L26-L51
[ "def", "check_election_status", "(", "self", ",", "config", ")", ":", "try", ":", "record", "=", "self", ".", "_get_record", "(", "config", ".", "get", "(", "\"record_kind\"", ",", "\"\"", ")", ",", "config", ".", "get", "(", "\"record_name\"", ",", "\"\...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
_partition
Python2.4 doesn't have a partition method so we provide our own that mimics str.partition from later releases. Split the string at the first occurrence of sep, and return a 3-tuple containing the part before the separator, the separator itself, and the part after the separator. If the separator is not ...
tokumx/datadog_checks/tokumx/vendor/pymongo/uri_parser.py
def _partition(entity, sep): """Python2.4 doesn't have a partition method so we provide our own that mimics str.partition from later releases. Split the string at the first occurrence of sep, and return a 3-tuple containing the part before the separator, the separator itself, and the part after the...
def _partition(entity, sep): """Python2.4 doesn't have a partition method so we provide our own that mimics str.partition from later releases. Split the string at the first occurrence of sep, and return a 3-tuple containing the part before the separator, the separator itself, and the part after the...
[ "Python2", ".", "4", "doesn", "t", "have", "a", "partition", "method", "so", "we", "provide", "our", "own", "that", "mimics", "str", ".", "partition", "from", "later", "releases", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/uri_parser.py#L36-L50
[ "def", "_partition", "(", "entity", ",", "sep", ")", ":", "parts", "=", "entity", ".", "split", "(", "sep", ",", "1", ")", "if", "len", "(", "parts", ")", "==", "2", ":", "return", "parts", "[", "0", "]", ",", "sep", ",", "parts", "[", "1", "...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
_rpartition
Python2.4 doesn't have an rpartition method so we provide our own that mimics str.rpartition from later releases. Split the string at the last occurrence of sep, and return a 3-tuple containing the part before the separator, the separator itself, and the part after the separator. If the separator is no...
tokumx/datadog_checks/tokumx/vendor/pymongo/uri_parser.py
def _rpartition(entity, sep): """Python2.4 doesn't have an rpartition method so we provide our own that mimics str.rpartition from later releases. Split the string at the last occurrence of sep, and return a 3-tuple containing the part before the separator, the separator itself, and the part after ...
def _rpartition(entity, sep): """Python2.4 doesn't have an rpartition method so we provide our own that mimics str.rpartition from later releases. Split the string at the last occurrence of sep, and return a 3-tuple containing the part before the separator, the separator itself, and the part after ...
[ "Python2", ".", "4", "doesn", "t", "have", "an", "rpartition", "method", "so", "we", "provide", "our", "own", "that", "mimics", "str", ".", "rpartition", "from", "later", "releases", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/uri_parser.py#L53-L66
[ "def", "_rpartition", "(", "entity", ",", "sep", ")", ":", "idx", "=", "entity", ".", "rfind", "(", "sep", ")", "if", "idx", "==", "-", "1", ":", "return", "''", ",", "''", ",", "entity", "return", "entity", "[", ":", "idx", "]", ",", "sep", ",...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
parse_userinfo
Validates the format of user information in a MongoDB URI. Reserved characters like ':', '/', '+' and '@' must be escaped following RFC 3986. Returns a 2-tuple containing the unescaped username followed by the unescaped password. :Paramaters: - `userinfo`: A string of the form <username>:<...
tokumx/datadog_checks/tokumx/vendor/pymongo/uri_parser.py
def parse_userinfo(userinfo): """Validates the format of user information in a MongoDB URI. Reserved characters like ':', '/', '+' and '@' must be escaped following RFC 3986. Returns a 2-tuple containing the unescaped username followed by the unescaped password. :Paramaters: - `userinf...
def parse_userinfo(userinfo): """Validates the format of user information in a MongoDB URI. Reserved characters like ':', '/', '+' and '@' must be escaped following RFC 3986. Returns a 2-tuple containing the unescaped username followed by the unescaped password. :Paramaters: - `userinf...
[ "Validates", "the", "format", "of", "user", "information", "in", "a", "MongoDB", "URI", ".", "Reserved", "characters", "like", ":", "/", "+", "and", "@", "must", "be", "escaped", "following", "RFC", "3986", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/uri_parser.py#L69-L94
[ "def", "parse_userinfo", "(", "userinfo", ")", ":", "if", "'@'", "in", "userinfo", "or", "userinfo", ".", "count", "(", "':'", ")", ">", "1", ":", "if", "PY3", ":", "quote_fn", "=", "\"urllib.parse.quote_plus\"", "else", ":", "quote_fn", "=", "\"urllib.quo...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
parse_ipv6_literal_host
Validates an IPv6 literal host:port string. Returns a 2-tuple of IPv6 literal followed by port where port is default_port if it wasn't specified in entity. :Parameters: - `entity`: A string that represents an IPv6 literal enclosed in braces (e.g. '[::1]' or '[::1]:27017'). ...
tokumx/datadog_checks/tokumx/vendor/pymongo/uri_parser.py
def parse_ipv6_literal_host(entity, default_port): """Validates an IPv6 literal host:port string. Returns a 2-tuple of IPv6 literal followed by port where port is default_port if it wasn't specified in entity. :Parameters: - `entity`: A string that represents an IPv6 literal enclosed ...
def parse_ipv6_literal_host(entity, default_port): """Validates an IPv6 literal host:port string. Returns a 2-tuple of IPv6 literal followed by port where port is default_port if it wasn't specified in entity. :Parameters: - `entity`: A string that represents an IPv6 literal enclosed ...
[ "Validates", "an", "IPv6", "literal", "host", ":", "port", "string", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/uri_parser.py#L97-L116
[ "def", "parse_ipv6_literal_host", "(", "entity", ",", "default_port", ")", ":", "if", "entity", ".", "find", "(", "']'", ")", "==", "-", "1", ":", "raise", "ValueError", "(", "\"an IPv6 address literal must be \"", "\"enclosed in '[' and ']' according \"", "\"to RFC 2...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
parse_host
Validates a host string Returns a 2-tuple of host followed by port where port is default_port if it wasn't specified in the string. :Parameters: - `entity`: A host or host:port string where host could be a hostname or IP address. - `default_port`: The port number to use...
tokumx/datadog_checks/tokumx/vendor/pymongo/uri_parser.py
def parse_host(entity, default_port=DEFAULT_PORT): """Validates a host string Returns a 2-tuple of host followed by port where port is default_port if it wasn't specified in the string. :Parameters: - `entity`: A host or host:port string where host could be a hostname or IP...
def parse_host(entity, default_port=DEFAULT_PORT): """Validates a host string Returns a 2-tuple of host followed by port where port is default_port if it wasn't specified in the string. :Parameters: - `entity`: A host or host:port string where host could be a hostname or IP...
[ "Validates", "a", "host", "string" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/uri_parser.py#L119-L154
[ "def", "parse_host", "(", "entity", ",", "default_port", "=", "DEFAULT_PORT", ")", ":", "host", "=", "entity", "port", "=", "default_port", "if", "entity", "[", "0", "]", "==", "'['", ":", "host", ",", "port", "=", "parse_ipv6_literal_host", "(", "entity",...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
_parse_options
Helper method for split_options which creates the options dict. Also handles the creation of a list for the URI tag_sets/ readpreferencetags portion.
tokumx/datadog_checks/tokumx/vendor/pymongo/uri_parser.py
def _parse_options(opts, delim): """Helper method for split_options which creates the options dict. Also handles the creation of a list for the URI tag_sets/ readpreferencetags portion.""" options = {} for opt in opts.split(delim): key, val = opt.split("=") if key.lower() == 'readpre...
def _parse_options(opts, delim): """Helper method for split_options which creates the options dict. Also handles the creation of a list for the URI tag_sets/ readpreferencetags portion.""" options = {} for opt in opts.split(delim): key, val = opt.split("=") if key.lower() == 'readpre...
[ "Helper", "method", "for", "split_options", "which", "creates", "the", "options", "dict", ".", "Also", "handles", "the", "creation", "of", "a", "list", "for", "the", "URI", "tag_sets", "/", "readpreferencetags", "portion", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/uri_parser.py#L173-L197
[ "def", "_parse_options", "(", "opts", ",", "delim", ")", ":", "options", "=", "{", "}", "for", "opt", "in", "opts", ".", "split", "(", "delim", ")", ":", "key", ",", "val", "=", "opt", ".", "split", "(", "\"=\"", ")", "if", "key", ".", "lower", ...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
split_hosts
Takes a string of the form host1[:port],host2[:port]... and splits it into (host, port) tuples. If [:port] isn't present the default_port is used. Returns a set of 2-tuples containing the host name (or IP) followed by port number. :Parameters: - `hosts`: A string of the form host1[:port],h...
tokumx/datadog_checks/tokumx/vendor/pymongo/uri_parser.py
def split_hosts(hosts, default_port=DEFAULT_PORT): """Takes a string of the form host1[:port],host2[:port]... and splits it into (host, port) tuples. If [:port] isn't present the default_port is used. Returns a set of 2-tuples containing the host name (or IP) followed by port number. :Paramete...
def split_hosts(hosts, default_port=DEFAULT_PORT): """Takes a string of the form host1[:port],host2[:port]... and splits it into (host, port) tuples. If [:port] isn't present the default_port is used. Returns a set of 2-tuples containing the host name (or IP) followed by port number. :Paramete...
[ "Takes", "a", "string", "of", "the", "form", "host1", "[", ":", "port", "]", "host2", "[", ":", "port", "]", "...", "and", "splits", "it", "into", "(", "host", "port", ")", "tuples", ".", "If", "[", ":", "port", "]", "isn", "t", "present", "the",...
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/uri_parser.py#L230-L253
[ "def", "split_hosts", "(", "hosts", ",", "default_port", "=", "DEFAULT_PORT", ")", ":", "nodes", "=", "[", "]", "for", "entity", "in", "hosts", ".", "split", "(", "','", ")", ":", "if", "not", "entity", ":", "raise", "ConfigurationError", "(", "\"Empty h...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
parse_uri
Parse and validate a MongoDB URI. Returns a dict of the form:: { 'nodelist': <list of (host, port) tuples>, 'username': <username> or None, 'password': <password> or None, 'database': <database name> or None, 'collection': <collection name> or No...
tokumx/datadog_checks/tokumx/vendor/pymongo/uri_parser.py
def parse_uri(uri, default_port=DEFAULT_PORT, validate=True, warn=False): """Parse and validate a MongoDB URI. Returns a dict of the form:: { 'nodelist': <list of (host, port) tuples>, 'username': <username> or None, 'password': <password> or None, 'data...
def parse_uri(uri, default_port=DEFAULT_PORT, validate=True, warn=False): """Parse and validate a MongoDB URI. Returns a dict of the form:: { 'nodelist': <list of (host, port) tuples>, 'username': <username> or None, 'password': <password> or None, 'data...
[ "Parse", "and", "validate", "a", "MongoDB", "URI", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/uri_parser.py#L261-L356
[ "def", "parse_uri", "(", "uri", ",", "default_port", "=", "DEFAULT_PORT", ",", "validate", "=", "True", ",", "warn", "=", "False", ")", ":", "if", "not", "uri", ".", "startswith", "(", "SCHEME", ")", ":", "raise", "InvalidURI", "(", "\"Invalid URI scheme: ...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
_with_primary
Apply max_staleness, in seconds, to a Selection with a known primary.
tokumx/datadog_checks/tokumx/vendor/pymongo/max_staleness_selectors.py
def _with_primary(max_staleness, selection): """Apply max_staleness, in seconds, to a Selection with a known primary.""" primary = selection.primary sds = [] for s in selection.server_descriptions: if s.server_type == SERVER_TYPE.RSSecondary: # See max-staleness.rst for explanation ...
def _with_primary(max_staleness, selection): """Apply max_staleness, in seconds, to a Selection with a known primary.""" primary = selection.primary sds = [] for s in selection.server_descriptions: if s.server_type == SERVER_TYPE.RSSecondary: # See max-staleness.rst for explanation ...
[ "Apply", "max_staleness", "in", "seconds", "to", "a", "Selection", "with", "a", "known", "primary", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/max_staleness_selectors.py#L57-L75
[ "def", "_with_primary", "(", "max_staleness", ",", "selection", ")", ":", "primary", "=", "selection", ".", "primary", "sds", "=", "[", "]", "for", "s", "in", "selection", ".", "server_descriptions", ":", "if", "s", ".", "server_type", "==", "SERVER_TYPE", ...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
_no_primary
Apply max_staleness, in seconds, to a Selection with no known primary.
tokumx/datadog_checks/tokumx/vendor/pymongo/max_staleness_selectors.py
def _no_primary(max_staleness, selection): """Apply max_staleness, in seconds, to a Selection with no known primary.""" # Secondary that's replicated the most recent writes. smax = selection.secondary_with_max_last_write_date() if not smax: # No secondaries and no primary, short-circuit out of h...
def _no_primary(max_staleness, selection): """Apply max_staleness, in seconds, to a Selection with no known primary.""" # Secondary that's replicated the most recent writes. smax = selection.secondary_with_max_last_write_date() if not smax: # No secondaries and no primary, short-circuit out of h...
[ "Apply", "max_staleness", "in", "seconds", "to", "a", "Selection", "with", "no", "known", "primary", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/max_staleness_selectors.py#L78-L100
[ "def", "_no_primary", "(", "max_staleness", ",", "selection", ")", ":", "# Secondary that's replicated the most recent writes.", "smax", "=", "selection", ".", "secondary_with_max_last_write_date", "(", ")", "if", "not", "smax", ":", "# No secondaries and no primary, short-ci...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
select
Apply max_staleness, in seconds, to a Selection.
tokumx/datadog_checks/tokumx/vendor/pymongo/max_staleness_selectors.py
def select(max_staleness, selection): """Apply max_staleness, in seconds, to a Selection.""" if max_staleness == -1: return selection # Server Selection Spec: If the TopologyType is ReplicaSetWithPrimary or # ReplicaSetNoPrimary, a client MUST raise an error if maxStaleness < # heartbeatFre...
def select(max_staleness, selection): """Apply max_staleness, in seconds, to a Selection.""" if max_staleness == -1: return selection # Server Selection Spec: If the TopologyType is ReplicaSetWithPrimary or # ReplicaSetNoPrimary, a client MUST raise an error if maxStaleness < # heartbeatFre...
[ "Apply", "max_staleness", "in", "seconds", "to", "a", "Selection", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/max_staleness_selectors.py#L103-L116
[ "def", "select", "(", "max_staleness", ",", "selection", ")", ":", "if", "max_staleness", "==", "-", "1", ":", "return", "selection", "# Server Selection Spec: If the TopologyType is ReplicaSetWithPrimary or", "# ReplicaSetNoPrimary, a client MUST raise an error if maxStaleness <",...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
TokuMX.create_event
Create an event with a message describing the replication state of a mongo node
tokumx/datadog_checks/tokumx/tokumx.py
def create_event(self, state, server, agentConfig): """Create an event with a message describing the replication state of a mongo node""" def get_state_description(state): if state == 0: return 'Starting Up' elif state == 1: return 'Pr...
def create_event(self, state, server, agentConfig): """Create an event with a message describing the replication state of a mongo node""" def get_state_description(state): if state == 0: return 'Starting Up' elif state == 1: return 'Pr...
[ "Create", "an", "event", "with", "a", "message", "describing", "the", "replication", "state", "of", "a", "mongo", "node" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/tokumx.py#L210-L248
[ "def", "create_event", "(", "self", ",", "state", ",", "server", ",", "agentConfig", ")", ":", "def", "get_state_description", "(", "state", ")", ":", "if", "state", "==", "0", ":", "return", "'Starting Up'", "elif", "state", "==", "1", ":", "return", "'...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
timeout
A decorator to timeout a function. Decorated method calls are executed in a separate new thread with a specified timeout. Also check if a thread for the same function already exists before creating a new one. Note: Compatible with Windows (thread based).
datadog_checks_base/datadog_checks/base/utils/timeout.py
def timeout(timeout): """ A decorator to timeout a function. Decorated method calls are executed in a separate new thread with a specified timeout. Also check if a thread for the same function already exists before creating a new one. Note: Compatible with Windows (thread based). """ def de...
def timeout(timeout): """ A decorator to timeout a function. Decorated method calls are executed in a separate new thread with a specified timeout. Also check if a thread for the same function already exists before creating a new one. Note: Compatible with Windows (thread based). """ def de...
[ "A", "decorator", "to", "timeout", "a", "function", ".", "Decorated", "method", "calls", "are", "executed", "in", "a", "separate", "new", "thread", "with", "a", "specified", "timeout", ".", "Also", "check", "if", "a", "thread", "for", "the", "same", "funct...
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/utils/timeout.py#L41-L74
[ "def", "timeout", "(", "timeout", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "key", "=", "\"{0}:{1}:{2}:{3}\"", ".", ...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
ProcessCheck.find_pids
Create a set of pids of selected processes. Search for search_string
process/datadog_checks/process/process.py
def find_pids(self, name, search_string, exact_match, ignore_ad=True): """ Create a set of pids of selected processes. Search for search_string """ if not self.should_refresh_pid_cache(name): return self.pid_cache[name] ad_error_logger = self.log.debug ...
def find_pids(self, name, search_string, exact_match, ignore_ad=True): """ Create a set of pids of selected processes. Search for search_string """ if not self.should_refresh_pid_cache(name): return self.pid_cache[name] ad_error_logger = self.log.debug ...
[ "Create", "a", "set", "of", "pids", "of", "selected", "processes", ".", "Search", "for", "search_string" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/process/datadog_checks/process/process.py#L98-L163
[ "def", "find_pids", "(", "self", ",", "name", ",", "search_string", ",", "exact_match", ",", "ignore_ad", "=", "True", ")", ":", "if", "not", "self", ".", "should_refresh_pid_cache", "(", "name", ")", ":", "return", "self", ".", "pid_cache", "[", "name", ...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
ProcessCheck.psutil_wrapper
A psutil wrapper that is calling * psutil.method(*args, **kwargs) and returns the result OR * psutil.method(*args, **kwargs).accessor[i] for each accessors given in a list, the result being indexed in a dictionary by the accessor name
process/datadog_checks/process/process.py
def psutil_wrapper(self, process, method, accessors, try_sudo, *args, **kwargs): """ A psutil wrapper that is calling * psutil.method(*args, **kwargs) and returns the result OR * psutil.method(*args, **kwargs).accessor[i] for each accessors given in a list, the result bei...
def psutil_wrapper(self, process, method, accessors, try_sudo, *args, **kwargs): """ A psutil wrapper that is calling * psutil.method(*args, **kwargs) and returns the result OR * psutil.method(*args, **kwargs).accessor[i] for each accessors given in a list, the result bei...
[ "A", "psutil", "wrapper", "that", "is", "calling", "*", "psutil", ".", "method", "(", "*", "args", "**", "kwargs", ")", "and", "returns", "the", "result", "OR", "*", "psutil", ".", "method", "(", "*", "args", "**", "kwargs", ")", ".", "accessor", "["...
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/process/datadog_checks/process/process.py#L165-L217
[ "def", "psutil_wrapper", "(", "self", ",", "process", ",", "method", ",", "accessors", ",", "try_sudo", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "accessors", "is", "None", ":", "result", "=", "None", "else", ":", "result", "=", "{",...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
ProcessCheck._process_service_check
Report a service check, for each process in search_string. Report as OK if the process is in the warning thresholds CRITICAL out of the critical thresholds WARNING out of the warning thresholds
process/datadog_checks/process/process.py
def _process_service_check(self, name, nb_procs, bounds, tags): """ Report a service check, for each process in search_string. Report as OK if the process is in the warning thresholds CRITICAL out of the critical thresholds WARNING o...
def _process_service_check(self, name, nb_procs, bounds, tags): """ Report a service check, for each process in search_string. Report as OK if the process is in the warning thresholds CRITICAL out of the critical thresholds WARNING o...
[ "Report", "a", "service", "check", "for", "each", "process", "in", "search_string", ".", "Report", "as", "OK", "if", "the", "process", "is", "in", "the", "warning", "thresholds", "CRITICAL", "out", "of", "the", "critical", "thresholds", "WARNING", "out", "of...
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/process/datadog_checks/process/process.py#L442-L470
[ "def", "_process_service_check", "(", "self", ",", "name", ",", "nb_procs", ",", "bounds", ",", "tags", ")", ":", "# FIXME 8.x remove the `process:name` tag", "service_check_tags", "=", "tags", "+", "[", "\"process:{}\"", ".", "format", "(", "name", ")", "]", "s...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
ProcessCheck._filter_by_user
Filter pids by it's username. :param user: string with name of system user :param pids: set of pids to filter :return: set of filtered pids
process/datadog_checks/process/process.py
def _filter_by_user(self, user, pids): """ Filter pids by it's username. :param user: string with name of system user :param pids: set of pids to filter :return: set of filtered pids """ filtered_pids = set() for pid in pids: try: ...
def _filter_by_user(self, user, pids): """ Filter pids by it's username. :param user: string with name of system user :param pids: set of pids to filter :return: set of filtered pids """ filtered_pids = set() for pid in pids: try: ...
[ "Filter", "pids", "by", "it", "s", "username", ".", ":", "param", "user", ":", "string", "with", "name", "of", "system", "user", ":", "param", "pids", ":", "set", "of", "pids", "to", "filter", ":", "return", ":", "set", "of", "filtered", "pids" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/process/datadog_checks/process/process.py#L472-L491
[ "def", "_filter_by_user", "(", "self", ",", "user", ",", "pids", ")", ":", "filtered_pids", "=", "set", "(", ")", "for", "pid", "in", "pids", ":", "try", ":", "proc", "=", "psutil", ".", "Process", "(", "pid", ")", "if", "proc", ".", "username", "(...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
Win32EventLogWMI._dt_to_wmi
A wrapper around wmi.from_time to get a WMI-formatted time from a time struct.
win32_event_log/datadog_checks/win32_event_log/win32_event_log.py
def _dt_to_wmi(self, dt): ''' A wrapper around wmi.from_time to get a WMI-formatted time from a time struct. ''' return from_time( year=dt.year, month=dt.month, day=dt.day, hours=dt.hour, minutes=dt.minute, secon...
def _dt_to_wmi(self, dt): ''' A wrapper around wmi.from_time to get a WMI-formatted time from a time struct. ''' return from_time( year=dt.year, month=dt.month, day=dt.day, hours=dt.hour, minutes=dt.minute, secon...
[ "A", "wrapper", "around", "wmi", ".", "from_time", "to", "get", "a", "WMI", "-", "formatted", "time", "from", "a", "time", "struct", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/win32_event_log/datadog_checks/win32_event_log/win32_event_log.py#L160-L173
[ "def", "_dt_to_wmi", "(", "self", ",", "dt", ")", ":", "return", "from_time", "(", "year", "=", "dt", ".", "year", ",", "month", "=", "dt", ".", "month", ",", "day", "=", "dt", ".", "day", ",", "hours", "=", "dt", ".", "hour", ",", "minutes", "...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
LogEvent._msg_text
Generate the event's body to send to Datadog. Consider `event_format` parameter: * Only use the specified list of event properties. * If unspecified, default to the EventLog's `Message` or `InsertionStrings`.
win32_event_log/datadog_checks/win32_event_log/win32_event_log.py
def _msg_text(self): """ Generate the event's body to send to Datadog. Consider `event_format` parameter: * Only use the specified list of event properties. * If unspecified, default to the EventLog's `Message` or `InsertionStrings`. """ msg_text = u"" i...
def _msg_text(self): """ Generate the event's body to send to Datadog. Consider `event_format` parameter: * Only use the specified list of event properties. * If unspecified, default to the EventLog's `Message` or `InsertionStrings`. """ msg_text = u"" i...
[ "Generate", "the", "event", "s", "body", "to", "send", "to", "Datadog", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/win32_event_log/datadog_checks/win32_event_log/win32_event_log.py#L192-L229
[ "def", "_msg_text", "(", "self", ")", ":", "msg_text", "=", "u\"\"", "if", "self", ".", "_format", ":", "msg_text_fields", "=", "[", "\"%%%\\n```\"", "]", "for", "event_property", "in", "self", ".", "_format", ":", "property_value", "=", "self", ".", "even...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
LogEvent.is_after
Compare this event's timestamp to a give timestamp.
win32_event_log/datadog_checks/win32_event_log/win32_event_log.py
def is_after(self, ts): ''' Compare this event's timestamp to a give timestamp. ''' if self.timestamp >= int(calendar.timegm(ts.timetuple())): return True return False
def is_after(self, ts): ''' Compare this event's timestamp to a give timestamp. ''' if self.timestamp >= int(calendar.timegm(ts.timetuple())): return True return False
[ "Compare", "this", "event", "s", "timestamp", "to", "a", "give", "timestamp", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/win32_event_log/datadog_checks/win32_event_log/win32_event_log.py#L262-L266
[ "def", "is_after", "(", "self", ",", "ts", ")", ":", "if", "self", ".", "timestamp", ">=", "int", "(", "calendar", ".", "timegm", "(", "ts", ".", "timetuple", "(", ")", ")", ")", ":", "return", "True", "return", "False" ]
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
LogEvent._wmi_to_ts
Convert a wmi formatted timestamp into an epoch.
win32_event_log/datadog_checks/win32_event_log/win32_event_log.py
def _wmi_to_ts(self, wmi_ts): ''' Convert a wmi formatted timestamp into an epoch. ''' year, month, day, hour, minute, second, microsecond, tz = to_time(wmi_ts) tz_delta = timedelta(minutes=int(tz)) if '+' in wmi_ts: tz_delta = -tz_delta dt = ( da...
def _wmi_to_ts(self, wmi_ts): ''' Convert a wmi formatted timestamp into an epoch. ''' year, month, day, hour, minute, second, microsecond, tz = to_time(wmi_ts) tz_delta = timedelta(minutes=int(tz)) if '+' in wmi_ts: tz_delta = -tz_delta dt = ( da...
[ "Convert", "a", "wmi", "formatted", "timestamp", "into", "an", "epoch", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/win32_event_log/datadog_checks/win32_event_log/win32_event_log.py#L268-L280
[ "def", "_wmi_to_ts", "(", "self", ",", "wmi_ts", ")", ":", "year", ",", "month", ",", "day", ",", "hour", ",", "minute", ",", "second", ",", "microsecond", ",", "tz", "=", "to_time", "(", "wmi_ts", ")", "tz_delta", "=", "timedelta", "(", "minutes", "...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
LogEvent._tags
Inject additional tags into the list already supplied to LogEvent.
win32_event_log/datadog_checks/win32_event_log/win32_event_log.py
def _tags(self, tags, event_code): ''' Inject additional tags into the list already supplied to LogEvent. ''' tags_list = [] if tags is not None: tags_list += list(tags) tags_list.append("event_id:{event_id}".format(event_id=event_code)) return tags_list
def _tags(self, tags, event_code): ''' Inject additional tags into the list already supplied to LogEvent. ''' tags_list = [] if tags is not None: tags_list += list(tags) tags_list.append("event_id:{event_id}".format(event_id=event_code)) return tags_list
[ "Inject", "additional", "tags", "into", "the", "list", "already", "supplied", "to", "LogEvent", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/win32_event_log/datadog_checks/win32_event_log/win32_event_log.py#L282-L289
[ "def", "_tags", "(", "self", ",", "tags", ",", "event_code", ")", ":", "tags_list", "=", "[", "]", "if", "tags", "is", "not", "None", ":", "tags_list", "+=", "list", "(", "tags", ")", "tags_list", ".", "append", "(", "\"event_id:{event_id}\"", ".", "fo...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
CursorManager.close
Kill a cursor. Raises TypeError if cursor_id is not an instance of (int, long). :Parameters: - `cursor_id`: cursor id to close - `address`: the cursor's server's (host, port) pair .. versionchanged:: 3.0 Now requires an `address` argument.
tokumx/datadog_checks/tokumx/vendor/pymongo/cursor_manager.py
def close(self, cursor_id, address): """Kill a cursor. Raises TypeError if cursor_id is not an instance of (int, long). :Parameters: - `cursor_id`: cursor id to close - `address`: the cursor's server's (host, port) pair .. versionchanged:: 3.0 Now requir...
def close(self, cursor_id, address): """Kill a cursor. Raises TypeError if cursor_id is not an instance of (int, long). :Parameters: - `cursor_id`: cursor id to close - `address`: the cursor's server's (host, port) pair .. versionchanged:: 3.0 Now requir...
[ "Kill", "a", "cursor", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/cursor_manager.py#L50-L65
[ "def", "close", "(", "self", ",", "cursor_id", ",", "address", ")", ":", "if", "not", "isinstance", "(", "cursor_id", ",", "integer_types", ")", ":", "raise", "TypeError", "(", "\"cursor_id must be an integer\"", ")", "self", ".", "__client", "(", ")", ".", ...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
Etcd._get_health_status
Don't send the "can connect" service check if we have troubles getting the health status
etcd/datadog_checks/etcd/etcd.py
def _get_health_status(self, url, ssl_params, timeout): """ Don't send the "can connect" service check if we have troubles getting the health status """ try: r = self._perform_request(url, "/health", ssl_params, timeout) # we don't use get() here so we can...
def _get_health_status(self, url, ssl_params, timeout): """ Don't send the "can connect" service check if we have troubles getting the health status """ try: r = self._perform_request(url, "/health", ssl_params, timeout) # we don't use get() here so we can...
[ "Don", "t", "send", "the", "can", "connect", "service", "check", "if", "we", "have", "troubles", "getting", "the", "health", "status" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/etcd/datadog_checks/etcd/etcd.py#L270-L280
[ "def", "_get_health_status", "(", "self", ",", "url", ",", "ssl_params", ",", "timeout", ")", ":", "try", ":", "r", "=", "self", ".", "_perform_request", "(", "url", ",", "\"/health\"", ",", "ssl_params", ",", "timeout", ")", "# we don't use get() here so we c...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
stop
Stop environments.
datadog_checks_dev/datadog_checks/dev/tooling/commands/env/stop.py
def stop(check, env): """Stop environments.""" all_checks = check == 'all' checks = get_configured_checks() if all_checks else [check] if all_checks: env_indent = DEFAULT_INDENT status_indent = DEFAULT_INDENT * 2 else: env_indent = None status_indent = DEFAULT_INDENT...
def stop(check, env): """Stop environments.""" all_checks = check == 'all' checks = get_configured_checks() if all_checks else [check] if all_checks: env_indent = DEFAULT_INDENT status_indent = DEFAULT_INDENT * 2 else: env_indent = None status_indent = DEFAULT_INDENT...
[ "Stop", "environments", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_dev/datadog_checks/dev/tooling/commands/env/stop.py#L13-L50
[ "def", "stop", "(", "check", ",", "env", ")", ":", "all_checks", "=", "check", "==", "'all'", "checks", "=", "get_configured_checks", "(", ")", "if", "all_checks", "else", "[", "check", "]", "if", "all_checks", ":", "env_indent", "=", "DEFAULT_INDENT", "st...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
Istio.check
Process both the istio_mesh instance and process_mixer instance associated with this instance
istio/datadog_checks/istio/istio.py
def check(self, instance): """ Process both the istio_mesh instance and process_mixer instance associated with this instance """ # Get the config for the istio_mesh instance istio_mesh_endpoint = instance.get('istio_mesh_endpoint') istio_mesh_config = self.config_map[ist...
def check(self, instance): """ Process both the istio_mesh instance and process_mixer instance associated with this instance """ # Get the config for the istio_mesh instance istio_mesh_endpoint = instance.get('istio_mesh_endpoint') istio_mesh_config = self.config_map[ist...
[ "Process", "both", "the", "istio_mesh", "instance", "and", "process_mixer", "instance", "associated", "with", "this", "instance" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/istio/datadog_checks/istio/istio.py#L26-L43
[ "def", "check", "(", "self", ",", "instance", ")", ":", "# Get the config for the istio_mesh instance", "istio_mesh_endpoint", "=", "instance", ".", "get", "(", "'istio_mesh_endpoint'", ")", "istio_mesh_config", "=", "self", ".", "config_map", "[", "istio_mesh_endpoint"...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
Istio.create_generic_instances
Generalize each (single) Istio instance into two OpenMetricsBaseCheck instances
istio/datadog_checks/istio/istio.py
def create_generic_instances(self, instances): """ Generalize each (single) Istio instance into two OpenMetricsBaseCheck instances """ generic_instances = [] for instance in instances: istio_mesh_instance = self._create_istio_mesh_instance(instance) proce...
def create_generic_instances(self, instances): """ Generalize each (single) Istio instance into two OpenMetricsBaseCheck instances """ generic_instances = [] for instance in instances: istio_mesh_instance = self._create_istio_mesh_instance(instance) proce...
[ "Generalize", "each", "(", "single", ")", "Istio", "instance", "into", "two", "OpenMetricsBaseCheck", "instances" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/istio/datadog_checks/istio/istio.py#L45-L57
[ "def", "create_generic_instances", "(", "self", ",", "instances", ")", ":", "generic_instances", "=", "[", "]", "for", "instance", "in", "instances", ":", "istio_mesh_instance", "=", "self", ".", "_create_istio_mesh_instance", "(", "instance", ")", "process_mixer_in...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
Istio._create_istio_mesh_instance
Grab the istio mesh scraper from the dict and return it if it exists, otherwise create the scraper and add it to the dict
istio/datadog_checks/istio/istio.py
def _create_istio_mesh_instance(self, instance): """ Grab the istio mesh scraper from the dict and return it if it exists, otherwise create the scraper and add it to the dict """ endpoint = instance.get('istio_mesh_endpoint') if endpoint is None: raise CheckE...
def _create_istio_mesh_instance(self, instance): """ Grab the istio mesh scraper from the dict and return it if it exists, otherwise create the scraper and add it to the dict """ endpoint = instance.get('istio_mesh_endpoint') if endpoint is None: raise CheckE...
[ "Grab", "the", "istio", "mesh", "scraper", "from", "the", "dict", "and", "return", "it", "if", "it", "exists", "otherwise", "create", "the", "scraper", "and", "add", "it", "to", "the", "dict" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/istio/datadog_checks/istio/istio.py#L59-L95
[ "def", "_create_istio_mesh_instance", "(", "self", ",", "instance", ")", ":", "endpoint", "=", "instance", ".", "get", "(", "'istio_mesh_endpoint'", ")", "if", "endpoint", "is", "None", ":", "raise", "CheckException", "(", "\"Unable to find istio_mesh_endpoint in conf...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
Istio._create_process_mixer_instance
Grab the mixer scraper from the dict and return it if it exists, otherwise create the scraper and add it to the dict
istio/datadog_checks/istio/istio.py
def _create_process_mixer_instance(self, instance): """ Grab the mixer scraper from the dict and return it if it exists, otherwise create the scraper and add it to the dict """ endpoint = instance.get('mixer_endpoint') if endpoint is None: raise CheckException...
def _create_process_mixer_instance(self, instance): """ Grab the mixer scraper from the dict and return it if it exists, otherwise create the scraper and add it to the dict """ endpoint = instance.get('mixer_endpoint') if endpoint is None: raise CheckException...
[ "Grab", "the", "mixer", "scraper", "from", "the", "dict", "and", "return", "it", "if", "it", "exists", "otherwise", "create", "the", "scraper", "and", "add", "it", "to", "the", "dict" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/istio/datadog_checks/istio/istio.py#L97-L168
[ "def", "_create_process_mixer_instance", "(", "self", ",", "instance", ")", ":", "endpoint", "=", "instance", ".", "get", "(", "'mixer_endpoint'", ")", "if", "endpoint", "is", "None", ":", "raise", "CheckException", "(", "\"Unable to find mixer_endpoint in config file...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
Marathon.get_apps_json
The dictionary containing the apps is cached during collection and reset at every `check()` call.
marathon/datadog_checks/marathon/marathon.py
def get_apps_json(self, url, timeout, auth, acs_url, ssl_verify, tags, group): """ The dictionary containing the apps is cached during collection and reset at every `check()` call. """ if self.apps_response is not None: return self.apps_response # Marathon ap...
def get_apps_json(self, url, timeout, auth, acs_url, ssl_verify, tags, group): """ The dictionary containing the apps is cached during collection and reset at every `check()` call. """ if self.apps_response is not None: return self.apps_response # Marathon ap...
[ "The", "dictionary", "containing", "the", "apps", "is", "cached", "during", "collection", "and", "reset", "at", "every", "check", "()", "call", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/marathon/datadog_checks/marathon/marathon.py#L156-L175
[ "def", "get_apps_json", "(", "self", ",", "url", ",", "timeout", ",", "auth", ",", "acs_url", ",", "ssl_verify", ",", "tags", ",", "group", ")", ":", "if", "self", ".", "apps_response", "is", "not", "None", ":", "return", "self", ".", "apps_response", ...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
Marathon.ensure_queue_count
Ensure `marathon.queue.count` is reported as zero for apps without queued instances.
marathon/datadog_checks/marathon/marathon.py
def ensure_queue_count( self, queued, url, timeout, auth, acs_url, ssl_verify, tags=None, label_tags=None, group=None ): """ Ensure `marathon.queue.count` is reported as zero for apps without queued instances. """ metric_name = '{}.count'.format(self.QUEUE_PREFIX) ap...
def ensure_queue_count( self, queued, url, timeout, auth, acs_url, ssl_verify, tags=None, label_tags=None, group=None ): """ Ensure `marathon.queue.count` is reported as zero for apps without queued instances. """ metric_name = '{}.count'.format(self.QUEUE_PREFIX) ap...
[ "Ensure", "marathon", ".", "queue", ".", "count", "is", "reported", "as", "zero", "for", "apps", "without", "queued", "instances", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/marathon/datadog_checks/marathon/marathon.py#L263-L276
[ "def", "ensure_queue_count", "(", "self", ",", "queued", ",", "url", ",", "timeout", ",", "auth", ",", "acs_url", ",", "ssl_verify", ",", "tags", "=", "None", ",", "label_tags", "=", "None", ",", "group", "=", "None", ")", ":", "metric_name", "=", "'{}...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
py3
Verify if a custom check or integration can run on python 3. CHECK can be an integration name or a valid path to a Python module or package folder.
datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/py3.py
def py3(check): """Verify if a custom check or integration can run on python 3. CHECK can be an integration name or a valid path to a Python module or package folder. """ if check in get_valid_checks(): path_to_module = os.path.dirname(get_version_file(check)) else: path_to_module =...
def py3(check): """Verify if a custom check or integration can run on python 3. CHECK can be an integration name or a valid path to a Python module or package folder. """ if check in get_valid_checks(): path_to_module = os.path.dirname(get_version_file(check)) else: path_to_module =...
[ "Verify", "if", "a", "custom", "check", "or", "integration", "can", "run", "on", "python", "3", ".", "CHECK", "can", "be", "an", "integration", "name", "or", "a", "valid", "path", "to", "a", "Python", "module", "or", "package", "folder", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/py3.py#L18-L50
[ "def", "py3", "(", "check", ")", ":", "if", "check", "in", "get_valid_checks", "(", ")", ":", "path_to_module", "=", "os", ".", "path", ".", "dirname", "(", "get_version_file", "(", "check", ")", ")", "else", ":", "path_to_module", "=", "check", "if", ...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
from_instance
Create a config object from an instance dictionary
http_check/datadog_checks/http_check/config.py
def from_instance(instance, default_ca_certs=None): """ Create a config object from an instance dictionary """ method = instance.get('method', 'get') data = instance.get('data', {}) tags = instance.get('tags', []) ntlm_domain = instance.get('ntlm_domain') username = instance.get('usernam...
def from_instance(instance, default_ca_certs=None): """ Create a config object from an instance dictionary """ method = instance.get('method', 'get') data = instance.get('data', {}) tags = instance.get('tags', []) ntlm_domain = instance.get('ntlm_domain') username = instance.get('usernam...
[ "Create", "a", "config", "object", "from", "an", "instance", "dictionary" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/http_check/datadog_checks/http_check/config.py#L24-L94
[ "def", "from_instance", "(", "instance", ",", "default_ca_certs", "=", "None", ")", ":", "method", "=", "instance", ".", "get", "(", "'method'", ",", "'get'", ")", "data", "=", "instance", ".", "get", "(", "'data'", ",", "{", "}", ")", "tags", "=", "...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
update_version_module
Change the Python code in the __about__.py module so that `__version__` contains the new value.
datadog_checks_dev/datadog_checks/dev/tooling/release.py
def update_version_module(check_name, old_ver, new_ver): """ Change the Python code in the __about__.py module so that `__version__` contains the new value. """ version_file = get_version_file(check_name) contents = read_file(version_file) contents = contents.replace(old_ver, new_ver) w...
def update_version_module(check_name, old_ver, new_ver): """ Change the Python code in the __about__.py module so that `__version__` contains the new value. """ version_file = get_version_file(check_name) contents = read_file(version_file) contents = contents.replace(old_ver, new_ver) w...
[ "Change", "the", "Python", "code", "in", "the", "__about__", ".", "py", "module", "so", "that", "__version__", "contains", "the", "new", "value", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_dev/datadog_checks/dev/tooling/release.py#L25-L34
[ "def", "update_version_module", "(", "check_name", ",", "old_ver", ",", "new_ver", ")", ":", "version_file", "=", "get_version_file", "(", "check_name", ")", "contents", "=", "read_file", "(", "version_file", ")", "contents", "=", "contents", ".", "replace", "("...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
get_agent_requirement_line
Compose a text line to be used in a requirements.txt file to install a check pinned to a specific version.
datadog_checks_dev/datadog_checks/dev/tooling/release.py
def get_agent_requirement_line(check, version): """ Compose a text line to be used in a requirements.txt file to install a check pinned to a specific version. """ package_name = get_package_name(check) # no manifest if check in ('datadog_checks_base', 'datadog_checks_downloader'): r...
def get_agent_requirement_line(check, version): """ Compose a text line to be used in a requirements.txt file to install a check pinned to a specific version. """ package_name = get_package_name(check) # no manifest if check in ('datadog_checks_base', 'datadog_checks_downloader'): r...
[ "Compose", "a", "text", "line", "to", "be", "used", "in", "a", "requirements", ".", "txt", "file", "to", "install", "a", "check", "pinned", "to", "a", "specific", "version", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_dev/datadog_checks/dev/tooling/release.py#L63-L91
[ "def", "get_agent_requirement_line", "(", "check", ",", "version", ")", ":", "package_name", "=", "get_package_name", "(", "check", ")", "# no manifest", "if", "check", "in", "(", "'datadog_checks_base'", ",", "'datadog_checks_downloader'", ")", ":", "return", "'{}=...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
update_agent_requirements
Replace the requirements line for the given check
datadog_checks_dev/datadog_checks/dev/tooling/release.py
def update_agent_requirements(req_file, check, newline): """ Replace the requirements line for the given check """ package_name = get_package_name(check) lines = read_file_lines(req_file) for i, line in enumerate(lines): current_package_name = line.split('==')[0] if current_pac...
def update_agent_requirements(req_file, check, newline): """ Replace the requirements line for the given check """ package_name = get_package_name(check) lines = read_file_lines(req_file) for i, line in enumerate(lines): current_package_name = line.split('==')[0] if current_pac...
[ "Replace", "the", "requirements", "line", "for", "the", "given", "check" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_dev/datadog_checks/dev/tooling/release.py#L94-L108
[ "def", "update_agent_requirements", "(", "req_file", ",", "check", ",", "newline", ")", ":", "package_name", "=", "get_package_name", "(", "check", ")", "lines", "=", "read_file_lines", "(", "req_file", ")", "for", "i", ",", "line", "in", "enumerate", "(", "...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
_walk
Modified version of https://docs.python.org/3/library/os.html#os.scandir that returns https://docs.python.org/3/library/os.html#os.DirEntry for files directly to take advantage of possible cached os.stat calls.
directory/datadog_checks/directory/traverse.py
def _walk(top): """Modified version of https://docs.python.org/3/library/os.html#os.scandir that returns https://docs.python.org/3/library/os.html#os.DirEntry for files directly to take advantage of possible cached os.stat calls. """ dirs = [] nondirs = [] try: scandir_iter = scandi...
def _walk(top): """Modified version of https://docs.python.org/3/library/os.html#os.scandir that returns https://docs.python.org/3/library/os.html#os.DirEntry for files directly to take advantage of possible cached os.stat calls. """ dirs = [] nondirs = [] try: scandir_iter = scandi...
[ "Modified", "version", "of", "https", ":", "//", "docs", ".", "python", ".", "org", "/", "3", "/", "library", "/", "os", ".", "html#os", ".", "scandir", "that", "returns", "https", ":", "//", "docs", ".", "python", ".", "org", "/", "3", "/", "libra...
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/directory/datadog_checks/directory/traverse.py#L11-L49
[ "def", "_walk", "(", "top", ")", ":", "dirs", "=", "[", "]", "nondirs", "=", "[", "]", "try", ":", "scandir_iter", "=", "scandir", "(", "top", ")", "except", "OSError", ":", "return", "# Avoid repeated global lookups.", "get_next", "=", "next", "while", ...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
YarnCheck._yarn_cluster_metrics
Get metrics related to YARN cluster
yarn/datadog_checks/yarn/yarn.py
def _yarn_cluster_metrics(self, rm_address, instance, addl_tags): """ Get metrics related to YARN cluster """ metrics_json = self._rest_request_to_json(rm_address, instance, YARN_CLUSTER_METRICS_PATH, addl_tags) if metrics_json: yarn_metrics = metrics_json[YARN_CLUS...
def _yarn_cluster_metrics(self, rm_address, instance, addl_tags): """ Get metrics related to YARN cluster """ metrics_json = self._rest_request_to_json(rm_address, instance, YARN_CLUSTER_METRICS_PATH, addl_tags) if metrics_json: yarn_metrics = metrics_json[YARN_CLUS...
[ "Get", "metrics", "related", "to", "YARN", "cluster" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/yarn/datadog_checks/yarn/yarn.py#L186-L197
[ "def", "_yarn_cluster_metrics", "(", "self", ",", "rm_address", ",", "instance", ",", "addl_tags", ")", ":", "metrics_json", "=", "self", ".", "_rest_request_to_json", "(", "rm_address", ",", "instance", ",", "YARN_CLUSTER_METRICS_PATH", ",", "addl_tags", ")", "if...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
YarnCheck._yarn_app_metrics
Get metrics for running applications
yarn/datadog_checks/yarn/yarn.py
def _yarn_app_metrics(self, rm_address, instance, app_tags, addl_tags): """ Get metrics for running applications """ metrics_json = self._rest_request_to_json( rm_address, instance, YARN_APPS_PATH, addl_tags, states=YARN_APPLICATION_STATES ) if metrics_json a...
def _yarn_app_metrics(self, rm_address, instance, app_tags, addl_tags): """ Get metrics for running applications """ metrics_json = self._rest_request_to_json( rm_address, instance, YARN_APPS_PATH, addl_tags, states=YARN_APPLICATION_STATES ) if metrics_json a...
[ "Get", "metrics", "for", "running", "applications" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/yarn/datadog_checks/yarn/yarn.py#L199-L222
[ "def", "_yarn_app_metrics", "(", "self", ",", "rm_address", ",", "instance", ",", "app_tags", ",", "addl_tags", ")", ":", "metrics_json", "=", "self", ".", "_rest_request_to_json", "(", "rm_address", ",", "instance", ",", "YARN_APPS_PATH", ",", "addl_tags", ",",...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
YarnCheck._yarn_node_metrics
Get metrics related to YARN nodes
yarn/datadog_checks/yarn/yarn.py
def _yarn_node_metrics(self, rm_address, instance, addl_tags): """ Get metrics related to YARN nodes """ metrics_json = self._rest_request_to_json(rm_address, instance, YARN_NODES_PATH, addl_tags) if metrics_json and metrics_json['nodes'] is not None and metrics_json['nodes']['n...
def _yarn_node_metrics(self, rm_address, instance, addl_tags): """ Get metrics related to YARN nodes """ metrics_json = self._rest_request_to_json(rm_address, instance, YARN_NODES_PATH, addl_tags) if metrics_json and metrics_json['nodes'] is not None and metrics_json['nodes']['n...
[ "Get", "metrics", "related", "to", "YARN", "nodes" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/yarn/datadog_checks/yarn/yarn.py#L224-L238
[ "def", "_yarn_node_metrics", "(", "self", ",", "rm_address", ",", "instance", ",", "addl_tags", ")", ":", "metrics_json", "=", "self", ".", "_rest_request_to_json", "(", "rm_address", ",", "instance", ",", "YARN_NODES_PATH", ",", "addl_tags", ")", "if", "metrics...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
YarnCheck._yarn_scheduler_metrics
Get metrics from YARN scheduler
yarn/datadog_checks/yarn/yarn.py
def _yarn_scheduler_metrics(self, rm_address, instance, addl_tags, queue_blacklist): """ Get metrics from YARN scheduler """ metrics_json = self._rest_request_to_json(rm_address, instance, YARN_SCHEDULER_PATH, addl_tags) try: metrics_json = metrics_json['scheduler'][...
def _yarn_scheduler_metrics(self, rm_address, instance, addl_tags, queue_blacklist): """ Get metrics from YARN scheduler """ metrics_json = self._rest_request_to_json(rm_address, instance, YARN_SCHEDULER_PATH, addl_tags) try: metrics_json = metrics_json['scheduler'][...
[ "Get", "metrics", "from", "YARN", "scheduler" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/yarn/datadog_checks/yarn/yarn.py#L240-L253
[ "def", "_yarn_scheduler_metrics", "(", "self", ",", "rm_address", ",", "instance", ",", "addl_tags", ",", "queue_blacklist", ")", ":", "metrics_json", "=", "self", ".", "_rest_request_to_json", "(", "rm_address", ",", "instance", ",", "YARN_SCHEDULER_PATH", ",", "...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
YarnCheck._yarn_capacity_scheduler_metrics
Get metrics from YARN scheduler if it's type is capacityScheduler
yarn/datadog_checks/yarn/yarn.py
def _yarn_capacity_scheduler_metrics(self, metrics_json, addl_tags, queue_blacklist): """ Get metrics from YARN scheduler if it's type is capacityScheduler """ tags = ['queue_name:{}'.format(metrics_json['queueName'])] tags.extend(addl_tags) self._set_yarn_metrics_from_j...
def _yarn_capacity_scheduler_metrics(self, metrics_json, addl_tags, queue_blacklist): """ Get metrics from YARN scheduler if it's type is capacityScheduler """ tags = ['queue_name:{}'.format(metrics_json['queueName'])] tags.extend(addl_tags) self._set_yarn_metrics_from_j...
[ "Get", "metrics", "from", "YARN", "scheduler", "if", "it", "s", "type", "is", "capacityScheduler" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/yarn/datadog_checks/yarn/yarn.py#L255-L285
[ "def", "_yarn_capacity_scheduler_metrics", "(", "self", ",", "metrics_json", ",", "addl_tags", ",", "queue_blacklist", ")", ":", "tags", "=", "[", "'queue_name:{}'", ".", "format", "(", "metrics_json", "[", "'queueName'", "]", ")", "]", "tags", ".", "extend", ...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
YarnCheck._set_yarn_metrics_from_json
Parse the JSON response and set the metrics
yarn/datadog_checks/yarn/yarn.py
def _set_yarn_metrics_from_json(self, tags, metrics_json, yarn_metrics): """ Parse the JSON response and set the metrics """ for dict_path, metric in iteritems(yarn_metrics): metric_name, metric_type = metric metric_value = self._get_value_from_json(dict_path, me...
def _set_yarn_metrics_from_json(self, tags, metrics_json, yarn_metrics): """ Parse the JSON response and set the metrics """ for dict_path, metric in iteritems(yarn_metrics): metric_name, metric_type = metric metric_value = self._get_value_from_json(dict_path, me...
[ "Parse", "the", "JSON", "response", "and", "set", "the", "metrics" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/yarn/datadog_checks/yarn/yarn.py#L287-L297
[ "def", "_set_yarn_metrics_from_json", "(", "self", ",", "tags", ",", "metrics_json", ",", "yarn_metrics", ")", ":", "for", "dict_path", ",", "metric", "in", "iteritems", "(", "yarn_metrics", ")", ":", "metric_name", ",", "metric_type", "=", "metric", "metric_val...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
YarnCheck._get_value_from_json
Get a value from a dictionary under N keys, represented as str("key1.key2...key{n}")
yarn/datadog_checks/yarn/yarn.py
def _get_value_from_json(self, dict_path, metrics_json): """ Get a value from a dictionary under N keys, represented as str("key1.key2...key{n}") """ for key in dict_path.split('.'): if key in metrics_json: metrics_json = metrics_json.get(key) else...
def _get_value_from_json(self, dict_path, metrics_json): """ Get a value from a dictionary under N keys, represented as str("key1.key2...key{n}") """ for key in dict_path.split('.'): if key in metrics_json: metrics_json = metrics_json.get(key) else...
[ "Get", "a", "value", "from", "a", "dictionary", "under", "N", "keys", "represented", "as", "str", "(", "key1", ".", "key2", "...", "key", "{", "n", "}", ")" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/yarn/datadog_checks/yarn/yarn.py#L299-L308
[ "def", "_get_value_from_json", "(", "self", ",", "dict_path", ",", "metrics_json", ")", ":", "for", "key", "in", "dict_path", ".", "split", "(", "'.'", ")", ":", "if", "key", "in", "metrics_json", ":", "metrics_json", "=", "metrics_json", ".", "get", "(", ...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
YarnCheck._set_metric
Set a metric
yarn/datadog_checks/yarn/yarn.py
def _set_metric(self, metric_name, metric_type, value, tags=None, device_name=None): """ Set a metric """ if metric_type == GAUGE: self.gauge(metric_name, value, tags=tags, device_name=device_name) elif metric_type == INCREMENT: self.increment(metric_name,...
def _set_metric(self, metric_name, metric_type, value, tags=None, device_name=None): """ Set a metric """ if metric_type == GAUGE: self.gauge(metric_name, value, tags=tags, device_name=device_name) elif metric_type == INCREMENT: self.increment(metric_name,...
[ "Set", "a", "metric" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/yarn/datadog_checks/yarn/yarn.py#L310-L319
[ "def", "_set_metric", "(", "self", ",", "metric_name", ",", "metric_type", ",", "value", ",", "tags", "=", "None", ",", "device_name", "=", "None", ")", ":", "if", "metric_type", "==", "GAUGE", ":", "self", ".", "gauge", "(", "metric_name", ",", "value",...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
YarnCheck._rest_request_to_json
Query the given URL and return the JSON response
yarn/datadog_checks/yarn/yarn.py
def _rest_request_to_json(self, url, instance, object_path, tags, *args, **kwargs): """ Query the given URL and return the JSON response """ service_check_tags = ['url:{}'.format(self._get_url_base(url))] + tags service_check_tags = list(set(service_check_tags)) if objec...
def _rest_request_to_json(self, url, instance, object_path, tags, *args, **kwargs): """ Query the given URL and return the JSON response """ service_check_tags = ['url:{}'.format(self._get_url_base(url))] + tags service_check_tags = list(set(service_check_tags)) if objec...
[ "Query", "the", "given", "URL", "and", "return", "the", "JSON", "response" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/yarn/datadog_checks/yarn/yarn.py#L321-L409
[ "def", "_rest_request_to_json", "(", "self", ",", "url", ",", "instance", ",", "object_path", ",", "tags", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "service_check_tags", "=", "[", "'url:{}'", ".", "format", "(", "self", ".", "_get_url_base", ...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
YarnCheck._join_url_dir
Join a URL with multiple directories
yarn/datadog_checks/yarn/yarn.py
def _join_url_dir(self, url, *args): """ Join a URL with multiple directories """ for path in args: url = url.rstrip('/') + '/' url = urljoin(url, path.lstrip('/')) return url
def _join_url_dir(self, url, *args): """ Join a URL with multiple directories """ for path in args: url = url.rstrip('/') + '/' url = urljoin(url, path.lstrip('/')) return url
[ "Join", "a", "URL", "with", "multiple", "directories" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/yarn/datadog_checks/yarn/yarn.py#L411-L419
[ "def", "_join_url_dir", "(", "self", ",", "url", ",", "*", "args", ")", ":", "for", "path", "in", "args", ":", "url", "=", "url", ".", "rstrip", "(", "'/'", ")", "+", "'/'", "url", "=", "urljoin", "(", "url", ",", "path", ".", "lstrip", "(", "'...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
YarnCheck._get_url_base
Return the base of a URL
yarn/datadog_checks/yarn/yarn.py
def _get_url_base(self, url): """ Return the base of a URL """ s = urlsplit(url) return urlunsplit([s.scheme, s.netloc, '', '', ''])
def _get_url_base(self, url): """ Return the base of a URL """ s = urlsplit(url) return urlunsplit([s.scheme, s.netloc, '', '', ''])
[ "Return", "the", "base", "of", "a", "URL" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/yarn/datadog_checks/yarn/yarn.py#L421-L426
[ "def", "_get_url_base", "(", "self", ",", "url", ")", ":", "s", "=", "urlsplit", "(", "url", ")", "return", "urlunsplit", "(", "[", "s", ".", "scheme", ",", "s", ".", "netloc", ",", "''", ",", "''", ",", "''", "]", ")" ]
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
NtpCheck._get_service_port
Get the ntp server port
ntp/datadog_checks/ntp/ntp.py
def _get_service_port(self, instance): """ Get the ntp server port """ host = instance.get('host', DEFAULT_HOST) port = instance.get('port', DEFAULT_PORT) # default port is the name of the service but lookup would fail # if the /etc/services file is missing. In th...
def _get_service_port(self, instance): """ Get the ntp server port """ host = instance.get('host', DEFAULT_HOST) port = instance.get('port', DEFAULT_PORT) # default port is the name of the service but lookup would fail # if the /etc/services file is missing. In th...
[ "Get", "the", "ntp", "server", "port" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/ntp/datadog_checks/ntp/ntp.py#L23-L36
[ "def", "_get_service_port", "(", "self", ",", "instance", ")", ":", "host", "=", "instance", ".", "get", "(", "'host'", ",", "DEFAULT_HOST", ")", "port", "=", "instance", ".", "get", "(", "'port'", ",", "DEFAULT_PORT", ")", "# default port is the name of the s...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
CadvisorPrometheusScraperMixin._create_cadvisor_prometheus_instance
Create a copy of the instance and set default values. This is so the base class can create a scraper_config with the proper values.
kubelet/datadog_checks/kubelet/prometheus.py
def _create_cadvisor_prometheus_instance(self, instance): """ Create a copy of the instance and set default values. This is so the base class can create a scraper_config with the proper values. """ cadvisor_instance = deepcopy(instance) cadvisor_instance.update( ...
def _create_cadvisor_prometheus_instance(self, instance): """ Create a copy of the instance and set default values. This is so the base class can create a scraper_config with the proper values. """ cadvisor_instance = deepcopy(instance) cadvisor_instance.update( ...
[ "Create", "a", "copy", "of", "the", "instance", "and", "set", "default", "values", ".", "This", "is", "so", "the", "base", "class", "can", "create", "a", "scraper_config", "with", "the", "proper", "values", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/kubelet/datadog_checks/kubelet/prometheus.py#L58-L96
[ "def", "_create_cadvisor_prometheus_instance", "(", "self", ",", "instance", ")", ":", "cadvisor_instance", "=", "deepcopy", "(", "instance", ")", "cadvisor_instance", ".", "update", "(", "{", "'namespace'", ":", "self", ".", "NAMESPACE", ",", "# We need to specify ...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
CadvisorPrometheusScraperMixin._is_container_metric
Return whether a metric is about a container or not. It can be about pods, or even higher levels in the cgroup hierarchy and we don't want to report on that. :param metric: :return: bool
kubelet/datadog_checks/kubelet/prometheus.py
def _is_container_metric(labels): """ Return whether a metric is about a container or not. It can be about pods, or even higher levels in the cgroup hierarchy and we don't want to report on that. :param metric: :return: bool """ for lbl in CONTAINER_LABELS...
def _is_container_metric(labels): """ Return whether a metric is about a container or not. It can be about pods, or even higher levels in the cgroup hierarchy and we don't want to report on that. :param metric: :return: bool """ for lbl in CONTAINER_LABELS...
[ "Return", "whether", "a", "metric", "is", "about", "a", "container", "or", "not", ".", "It", "can", "be", "about", "pods", "or", "even", "higher", "levels", "in", "the", "cgroup", "hierarchy", "and", "we", "don", "t", "want", "to", "report", "on", "tha...
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/kubelet/datadog_checks/kubelet/prometheus.py#L99-L114
[ "def", "_is_container_metric", "(", "labels", ")", ":", "for", "lbl", "in", "CONTAINER_LABELS", ":", "if", "lbl", "==", "'container_name'", ":", "if", "lbl", "in", "labels", ":", "if", "labels", "[", "lbl", "]", "==", "''", "or", "labels", "[", "lbl", ...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
CadvisorPrometheusScraperMixin._is_pod_metric
Return whether a metric is about a pod or not. It can be about containers, pods, or higher levels in the cgroup hierarchy and we don't want to report on that. :param metric :return bool
kubelet/datadog_checks/kubelet/prometheus.py
def _is_pod_metric(labels): """ Return whether a metric is about a pod or not. It can be about containers, pods, or higher levels in the cgroup hierarchy and we don't want to report on that. :param metric :return bool """ if 'container_name' in labels: ...
def _is_pod_metric(labels): """ Return whether a metric is about a pod or not. It can be about containers, pods, or higher levels in the cgroup hierarchy and we don't want to report on that. :param metric :return bool """ if 'container_name' in labels: ...
[ "Return", "whether", "a", "metric", "is", "about", "a", "pod", "or", "not", ".", "It", "can", "be", "about", "containers", "pods", "or", "higher", "levels", "in", "the", "cgroup", "hierarchy", "and", "we", "don", "t", "want", "to", "report", "on", "tha...
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/kubelet/datadog_checks/kubelet/prometheus.py#L117-L139
[ "def", "_is_pod_metric", "(", "labels", ")", ":", "if", "'container_name'", "in", "labels", ":", "if", "labels", "[", "'container_name'", "]", "==", "'POD'", ":", "return", "True", "# containerd does not report container_name=\"POD\"", "elif", "labels", "[", "'conta...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
CadvisorPrometheusScraperMixin._get_container_id
Should only be called on a container-scoped metric It gets the container id from the podlist using the metrics labels :param labels :return str or None
kubelet/datadog_checks/kubelet/prometheus.py
def _get_container_id(self, labels): """ Should only be called on a container-scoped metric It gets the container id from the podlist using the metrics labels :param labels :return str or None """ namespace = CadvisorPrometheusScraperMixin._get_container_label(la...
def _get_container_id(self, labels): """ Should only be called on a container-scoped metric It gets the container id from the podlist using the metrics labels :param labels :return str or None """ namespace = CadvisorPrometheusScraperMixin._get_container_label(la...
[ "Should", "only", "be", "called", "on", "a", "container", "-", "scoped", "metric", "It", "gets", "the", "container", "id", "from", "the", "podlist", "using", "the", "metrics", "labels" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/kubelet/datadog_checks/kubelet/prometheus.py#L152-L163
[ "def", "_get_container_id", "(", "self", ",", "labels", ")", ":", "namespace", "=", "CadvisorPrometheusScraperMixin", ".", "_get_container_label", "(", "labels", ",", "\"namespace\"", ")", "pod_name", "=", "CadvisorPrometheusScraperMixin", ".", "_get_container_label", "...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
CadvisorPrometheusScraperMixin._get_entity_id_if_container_metric
Checks the labels indicate a container metric, then extract the container id from them. :param labels :return str or None
kubelet/datadog_checks/kubelet/prometheus.py
def _get_entity_id_if_container_metric(self, labels): """ Checks the labels indicate a container metric, then extract the container id from them. :param labels :return str or None """ if CadvisorPrometheusScraperMixin._is_container_metric(labels): pod...
def _get_entity_id_if_container_metric(self, labels): """ Checks the labels indicate a container metric, then extract the container id from them. :param labels :return str or None """ if CadvisorPrometheusScraperMixin._is_container_metric(labels): pod...
[ "Checks", "the", "labels", "indicate", "a", "container", "metric", "then", "extract", "the", "container", "id", "from", "them", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/kubelet/datadog_checks/kubelet/prometheus.py#L165-L179
[ "def", "_get_entity_id_if_container_metric", "(", "self", ",", "labels", ")", ":", "if", "CadvisorPrometheusScraperMixin", ".", "_is_container_metric", "(", "labels", ")", ":", "pod", "=", "self", ".", "_get_pod_by_metric_label", "(", "labels", ")", "if", "is_static...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
CadvisorPrometheusScraperMixin._get_pod_uid
Return the id of a pod :param labels: :return: str or None
kubelet/datadog_checks/kubelet/prometheus.py
def _get_pod_uid(self, labels): """ Return the id of a pod :param labels: :return: str or None """ namespace = CadvisorPrometheusScraperMixin._get_container_label(labels, "namespace") pod_name = CadvisorPrometheusScraperMixin._get_container_label(labels, "pod_name...
def _get_pod_uid(self, labels): """ Return the id of a pod :param labels: :return: str or None """ namespace = CadvisorPrometheusScraperMixin._get_container_label(labels, "namespace") pod_name = CadvisorPrometheusScraperMixin._get_container_label(labels, "pod_name...
[ "Return", "the", "id", "of", "a", "pod", ":", "param", "labels", ":", ":", "return", ":", "str", "or", "None" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/kubelet/datadog_checks/kubelet/prometheus.py#L181-L189
[ "def", "_get_pod_uid", "(", "self", ",", "labels", ")", ":", "namespace", "=", "CadvisorPrometheusScraperMixin", ".", "_get_container_label", "(", "labels", ",", "\"namespace\"", ")", "pod_name", "=", "CadvisorPrometheusScraperMixin", ".", "_get_container_label", "(", ...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
CadvisorPrometheusScraperMixin._is_pod_host_networked
Return if the pod is on host Network Return False if the Pod isn't in the pod list :param pod_uid: str :return: bool
kubelet/datadog_checks/kubelet/prometheus.py
def _is_pod_host_networked(self, pod_uid): """ Return if the pod is on host Network Return False if the Pod isn't in the pod list :param pod_uid: str :return: bool """ for pod in self.pod_list['items']: if pod.get('metadata', {}).get('uid', '') == pod_...
def _is_pod_host_networked(self, pod_uid): """ Return if the pod is on host Network Return False if the Pod isn't in the pod list :param pod_uid: str :return: bool """ for pod in self.pod_list['items']: if pod.get('metadata', {}).get('uid', '') == pod_...
[ "Return", "if", "the", "pod", "is", "on", "host", "Network", "Return", "False", "if", "the", "Pod", "isn", "t", "in", "the", "pod", "list", ":", "param", "pod_uid", ":", "str", ":", "return", ":", "bool" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/kubelet/datadog_checks/kubelet/prometheus.py#L201-L211
[ "def", "_is_pod_host_networked", "(", "self", ",", "pod_uid", ")", ":", "for", "pod", "in", "self", ".", "pod_list", "[", "'items'", "]", ":", "if", "pod", ".", "get", "(", "'metadata'", ",", "{", "}", ")", ".", "get", "(", "'uid'", ",", "''", ")",...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
CadvisorPrometheusScraperMixin._get_pod_by_metric_label
:param labels: metric labels: iterable :return:
kubelet/datadog_checks/kubelet/prometheus.py
def _get_pod_by_metric_label(self, labels): """ :param labels: metric labels: iterable :return: """ pod_uid = self._get_pod_uid(labels) return get_pod_by_uid(pod_uid, self.pod_list)
def _get_pod_by_metric_label(self, labels): """ :param labels: metric labels: iterable :return: """ pod_uid = self._get_pod_uid(labels) return get_pod_by_uid(pod_uid, self.pod_list)
[ ":", "param", "labels", ":", "metric", "labels", ":", "iterable", ":", "return", ":" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/kubelet/datadog_checks/kubelet/prometheus.py#L213-L219
[ "def", "_get_pod_by_metric_label", "(", "self", ",", "labels", ")", ":", "pod_uid", "=", "self", ".", "_get_pod_uid", "(", "labels", ")", "return", "get_pod_by_uid", "(", "pod_uid", ",", "self", ".", "pod_list", ")" ]
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
CadvisorPrometheusScraperMixin._sum_values_by_context
Iterates over all metrics in a metric and sums the values matching the same uid. Modifies the metric family in place. :param metric: prometheus metric family :param uid_from_labels: function mapping a metric.label to a unique context id :return: dict with uid as keys, metric object refer...
kubelet/datadog_checks/kubelet/prometheus.py
def _sum_values_by_context(metric, uid_from_labels): """ Iterates over all metrics in a metric and sums the values matching the same uid. Modifies the metric family in place. :param metric: prometheus metric family :param uid_from_labels: function mapping a metric.label to a uniq...
def _sum_values_by_context(metric, uid_from_labels): """ Iterates over all metrics in a metric and sums the values matching the same uid. Modifies the metric family in place. :param metric: prometheus metric family :param uid_from_labels: function mapping a metric.label to a uniq...
[ "Iterates", "over", "all", "metrics", "in", "a", "metric", "and", "sums", "the", "values", "matching", "the", "same", "uid", ".", "Modifies", "the", "metric", "family", "in", "place", ".", ":", "param", "metric", ":", "prometheus", "metric", "family", ":",...
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/kubelet/datadog_checks/kubelet/prometheus.py#L238-L265
[ "def", "_sum_values_by_context", "(", "metric", ",", "uid_from_labels", ")", ":", "seen", "=", "{", "}", "for", "sample", "in", "metric", ".", "samples", ":", "uid", "=", "uid_from_labels", "(", "sample", "[", "OpenMetricsBaseCheck", ".", "SAMPLE_LABELS", "]",...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
CadvisorPrometheusScraperMixin._process_container_metric
Takes a simple metric about a container, reports it as a rate or gauge. If several series are found for a given container, values are summed before submission.
kubelet/datadog_checks/kubelet/prometheus.py
def _process_container_metric(self, type, metric_name, metric, scraper_config): """ Takes a simple metric about a container, reports it as a rate or gauge. If several series are found for a given container, values are summed before submission. """ if metric.type not in METRIC_TYP...
def _process_container_metric(self, type, metric_name, metric, scraper_config): """ Takes a simple metric about a container, reports it as a rate or gauge. If several series are found for a given container, values are summed before submission. """ if metric.type not in METRIC_TYP...
[ "Takes", "a", "simple", "metric", "about", "a", "container", "reports", "it", "as", "a", "rate", "or", "gauge", ".", "If", "several", "series", "are", "found", "for", "a", "given", "container", "values", "are", "summed", "before", "submission", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/kubelet/datadog_checks/kubelet/prometheus.py#L267-L298
[ "def", "_process_container_metric", "(", "self", ",", "type", ",", "metric_name", ",", "metric", ",", "scraper_config", ")", ":", "if", "metric", ".", "type", "not", "in", "METRIC_TYPES", ":", "self", ".", "log", ".", "error", "(", "\"Metric type %s unsupporte...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
CadvisorPrometheusScraperMixin._process_pod_rate
Takes a simple metric about a pod, reports it as a rate. If several series are found for a given pod, values are summed before submission.
kubelet/datadog_checks/kubelet/prometheus.py
def _process_pod_rate(self, metric_name, metric, scraper_config): """ Takes a simple metric about a pod, reports it as a rate. If several series are found for a given pod, values are summed before submission. """ if metric.type not in METRIC_TYPES: self.log.error("Met...
def _process_pod_rate(self, metric_name, metric, scraper_config): """ Takes a simple metric about a pod, reports it as a rate. If several series are found for a given pod, values are summed before submission. """ if metric.type not in METRIC_TYPES: self.log.error("Met...
[ "Takes", "a", "simple", "metric", "about", "a", "pod", "reports", "it", "as", "a", "rate", ".", "If", "several", "series", "are", "found", "for", "a", "given", "pod", "values", "are", "summed", "before", "submission", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/kubelet/datadog_checks/kubelet/prometheus.py#L300-L316
[ "def", "_process_pod_rate", "(", "self", ",", "metric_name", ",", "metric", ",", "scraper_config", ")", ":", "if", "metric", ".", "type", "not", "in", "METRIC_TYPES", ":", "self", ".", "log", ".", "error", "(", "\"Metric type %s unsupported for metric %s\"", "%"...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
CadvisorPrometheusScraperMixin._process_usage_metric
Takes a metric object, a metric name, and a cache dict where it will store container_name --> (value, tags) so that _process_limit_metric can compute usage_pct it also submit said value and tags as a gauge.
kubelet/datadog_checks/kubelet/prometheus.py
def _process_usage_metric(self, m_name, metric, cache, scraper_config): """ Takes a metric object, a metric name, and a cache dict where it will store container_name --> (value, tags) so that _process_limit_metric can compute usage_pct it also submit said value and tags as a gauge. ...
def _process_usage_metric(self, m_name, metric, cache, scraper_config): """ Takes a metric object, a metric name, and a cache dict where it will store container_name --> (value, tags) so that _process_limit_metric can compute usage_pct it also submit said value and tags as a gauge. ...
[ "Takes", "a", "metric", "object", "a", "metric", "name", "and", "a", "cache", "dict", "where", "it", "will", "store", "container_name", "--", ">", "(", "value", "tags", ")", "so", "that", "_process_limit_metric", "can", "compute", "usage_pct", "it", "also", ...
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/kubelet/datadog_checks/kubelet/prometheus.py#L318-L355
[ "def", "_process_usage_metric", "(", "self", ",", "m_name", ",", "metric", ",", "cache", ",", "scraper_config", ")", ":", "# track containers that still exist in the cache", "seen_keys", "=", "{", "k", ":", "False", "for", "k", "in", "cache", "}", "samples", "="...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
CadvisorPrometheusScraperMixin._process_limit_metric
Reports limit metrics if m_name is not an empty string, and optionally checks in the given cache if there's a usage for each sample in the metric and reports the usage_pct
kubelet/datadog_checks/kubelet/prometheus.py
def _process_limit_metric(self, m_name, metric, cache, scraper_config, pct_m_name=None): """ Reports limit metrics if m_name is not an empty string, and optionally checks in the given cache if there's a usage for each sample in the metric and reports the usage_pct """ sam...
def _process_limit_metric(self, m_name, metric, cache, scraper_config, pct_m_name=None): """ Reports limit metrics if m_name is not an empty string, and optionally checks in the given cache if there's a usage for each sample in the metric and reports the usage_pct """ sam...
[ "Reports", "limit", "metrics", "if", "m_name", "is", "not", "an", "empty", "string", "and", "optionally", "checks", "in", "the", "given", "cache", "if", "there", "s", "a", "usage", "for", "each", "sample", "in", "the", "metric", "and", "reports", "the", ...
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/kubelet/datadog_checks/kubelet/prometheus.py#L357-L387
[ "def", "_process_limit_metric", "(", "self", ",", "m_name", ",", "metric", ",", "cache", ",", "scraper_config", ",", "pct_m_name", "=", "None", ")", ":", "samples", "=", "self", ".", "_sum_values_by_context", "(", "metric", ",", "self", ".", "_get_entity_id_if...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
CadvisorPrometheusScraperMixin.container_fs_usage_bytes
Number of bytes that are consumed by the container on this filesystem.
kubelet/datadog_checks/kubelet/prometheus.py
def container_fs_usage_bytes(self, metric, scraper_config): """ Number of bytes that are consumed by the container on this filesystem. """ metric_name = scraper_config['namespace'] + '.filesystem.usage' if metric.type not in METRIC_TYPES: self.log.error("Metric type %...
def container_fs_usage_bytes(self, metric, scraper_config): """ Number of bytes that are consumed by the container on this filesystem. """ metric_name = scraper_config['namespace'] + '.filesystem.usage' if metric.type not in METRIC_TYPES: self.log.error("Metric type %...
[ "Number", "of", "bytes", "that", "are", "consumed", "by", "the", "container", "on", "this", "filesystem", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/kubelet/datadog_checks/kubelet/prometheus.py#L453-L461
[ "def", "container_fs_usage_bytes", "(", "self", ",", "metric", ",", "scraper_config", ")", ":", "metric_name", "=", "scraper_config", "[", "'namespace'", "]", "+", "'.filesystem.usage'", "if", "metric", ".", "type", "not", "in", "METRIC_TYPES", ":", "self", ".",...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
CadvisorPrometheusScraperMixin.container_fs_limit_bytes
Number of bytes that can be consumed by the container on this filesystem. This method is used by container_fs_usage_bytes, it doesn't report any metric
kubelet/datadog_checks/kubelet/prometheus.py
def container_fs_limit_bytes(self, metric, scraper_config): """ Number of bytes that can be consumed by the container on this filesystem. This method is used by container_fs_usage_bytes, it doesn't report any metric """ pct_m_name = scraper_config['namespace'] + '.filesystem.usag...
def container_fs_limit_bytes(self, metric, scraper_config): """ Number of bytes that can be consumed by the container on this filesystem. This method is used by container_fs_usage_bytes, it doesn't report any metric """ pct_m_name = scraper_config['namespace'] + '.filesystem.usag...
[ "Number", "of", "bytes", "that", "can", "be", "consumed", "by", "the", "container", "on", "this", "filesystem", ".", "This", "method", "is", "used", "by", "container_fs_usage_bytes", "it", "doesn", "t", "report", "any", "metric" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/kubelet/datadog_checks/kubelet/prometheus.py#L463-L472
[ "def", "container_fs_limit_bytes", "(", "self", ",", "metric", ",", "scraper_config", ")", ":", "pct_m_name", "=", "scraper_config", "[", "'namespace'", "]", "+", "'.filesystem.usage_pct'", "if", "metric", ".", "type", "not", "in", "METRIC_TYPES", ":", "self", "...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
MongoDb._report_replica_set_state
Report the member's replica set state * Submit a service check. * Create an event on state change.
mongo/datadog_checks/mongo/mongo.py
def _report_replica_set_state(self, state, clean_server_name, replset_name): """ Report the member's replica set state * Submit a service check. * Create an event on state change. """ last_state = self._last_state_by_server.get(clean_server_name, -1) self._last_st...
def _report_replica_set_state(self, state, clean_server_name, replset_name): """ Report the member's replica set state * Submit a service check. * Create an event on state change. """ last_state = self._last_state_by_server.get(clean_server_name, -1) self._last_st...
[ "Report", "the", "member", "s", "replica", "set", "state", "*", "Submit", "a", "service", "check", ".", "*", "Create", "an", "event", "on", "state", "change", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/mongo/datadog_checks/mongo/mongo.py#L450-L459
[ "def", "_report_replica_set_state", "(", "self", ",", "state", ",", "clean_server_name", ",", "replset_name", ")", ":", "last_state", "=", "self", ".", "_last_state_by_server", ".", "get", "(", "clean_server_name", ",", "-", "1", ")", "self", ".", "_last_state_b...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
MongoDb.hostname_for_event
Return a reasonable hostname for a replset membership event to mention.
mongo/datadog_checks/mongo/mongo.py
def hostname_for_event(self, clean_server_name): """Return a reasonable hostname for a replset membership event to mention.""" uri = urlsplit(clean_server_name) if '@' in uri.netloc: hostname = uri.netloc.split('@')[1].split(':')[0] else: hostname = uri.netloc.spl...
def hostname_for_event(self, clean_server_name): """Return a reasonable hostname for a replset membership event to mention.""" uri = urlsplit(clean_server_name) if '@' in uri.netloc: hostname = uri.netloc.split('@')[1].split(':')[0] else: hostname = uri.netloc.spl...
[ "Return", "a", "reasonable", "hostname", "for", "a", "replset", "membership", "event", "to", "mention", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/mongo/datadog_checks/mongo/mongo.py#L461-L470
[ "def", "hostname_for_event", "(", "self", ",", "clean_server_name", ")", ":", "uri", "=", "urlsplit", "(", "clean_server_name", ")", "if", "'@'", "in", "uri", ".", "netloc", ":", "hostname", "=", "uri", ".", "netloc", ".", "split", "(", "'@'", ")", "[", ...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
MongoDb.create_event
Create an event with a message describing the replication state of a mongo node
mongo/datadog_checks/mongo/mongo.py
def create_event(self, last_state, state, clean_server_name, replset_name): """Create an event with a message describing the replication state of a mongo node""" status = self.get_state_description(state) short_status = self.get_state_name(state) last_short_status = self.get...
def create_event(self, last_state, state, clean_server_name, replset_name): """Create an event with a message describing the replication state of a mongo node""" status = self.get_state_description(state) short_status = self.get_state_name(state) last_short_status = self.get...
[ "Create", "an", "event", "with", "a", "message", "describing", "the", "replication", "state", "of", "a", "mongo", "node" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/mongo/datadog_checks/mongo/mongo.py#L472-L498
[ "def", "create_event", "(", "self", ",", "last_state", ",", "state", ",", "clean_server_name", ",", "replset_name", ")", ":", "status", "=", "self", ".", "get_state_description", "(", "state", ")", "short_status", "=", "self", ".", "get_state_name", "(", "stat...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
MongoDb._build_metric_list_to_collect
Build the metric list to collect based on the instance preferences.
mongo/datadog_checks/mongo/mongo.py
def _build_metric_list_to_collect(self, additional_metrics): """ Build the metric list to collect based on the instance preferences. """ metrics_to_collect = {} # Defaut metrics for default_metrics in itervalues(self.DEFAULT_METRICS): metrics_to_collect.updat...
def _build_metric_list_to_collect(self, additional_metrics): """ Build the metric list to collect based on the instance preferences. """ metrics_to_collect = {} # Defaut metrics for default_metrics in itervalues(self.DEFAULT_METRICS): metrics_to_collect.updat...
[ "Build", "the", "metric", "list", "to", "collect", "based", "on", "the", "instance", "preferences", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/mongo/datadog_checks/mongo/mongo.py#L500-L527
[ "def", "_build_metric_list_to_collect", "(", "self", ",", "additional_metrics", ")", ":", "metrics_to_collect", "=", "{", "}", "# Defaut metrics", "for", "default_metrics", "in", "itervalues", "(", "self", ".", "DEFAULT_METRICS", ")", ":", "metrics_to_collect", ".", ...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
MongoDb._get_metrics_to_collect
Return and cache the list of metrics to collect.
mongo/datadog_checks/mongo/mongo.py
def _get_metrics_to_collect(self, instance_key, additional_metrics): """ Return and cache the list of metrics to collect. """ if instance_key not in self.metrics_to_collect_by_instance: self.metrics_to_collect_by_instance[instance_key] = self._build_metric_list_to_collect(add...
def _get_metrics_to_collect(self, instance_key, additional_metrics): """ Return and cache the list of metrics to collect. """ if instance_key not in self.metrics_to_collect_by_instance: self.metrics_to_collect_by_instance[instance_key] = self._build_metric_list_to_collect(add...
[ "Return", "and", "cache", "the", "list", "of", "metrics", "to", "collect", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/mongo/datadog_checks/mongo/mongo.py#L529-L535
[ "def", "_get_metrics_to_collect", "(", "self", ",", "instance_key", ",", "additional_metrics", ")", ":", "if", "instance_key", "not", "in", "self", ".", "metrics_to_collect_by_instance", ":", "self", ".", "metrics_to_collect_by_instance", "[", "instance_key", "]", "="...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
MongoDb._resolve_metric
Return the submit method and the metric name to use. The metric name is defined as follow: * If available, the normalized metric name alias * (Or) the normalized original metric name
mongo/datadog_checks/mongo/mongo.py
def _resolve_metric(self, original_metric_name, metrics_to_collect, prefix=""): """ Return the submit method and the metric name to use. The metric name is defined as follow: * If available, the normalized metric name alias * (Or) the normalized original metric name """ ...
def _resolve_metric(self, original_metric_name, metrics_to_collect, prefix=""): """ Return the submit method and the metric name to use. The metric name is defined as follow: * If available, the normalized metric name alias * (Or) the normalized original metric name """ ...
[ "Return", "the", "submit", "method", "and", "the", "metric", "name", "to", "use", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/mongo/datadog_checks/mongo/mongo.py#L537-L557
[ "def", "_resolve_metric", "(", "self", ",", "original_metric_name", ",", "metrics_to_collect", ",", "prefix", "=", "\"\"", ")", ":", "submit_method", "=", "(", "metrics_to_collect", "[", "original_metric_name", "]", "[", "0", "]", "if", "isinstance", "(", "metri...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
MongoDb._normalize
Replace case-sensitive metric name characters, normalize the metric name, prefix and suffix according to its type.
mongo/datadog_checks/mongo/mongo.py
def _normalize(self, metric_name, submit_method, prefix): """ Replace case-sensitive metric name characters, normalize the metric name, prefix and suffix according to its type. """ metric_prefix = "mongodb." if not prefix else "mongodb.{0}.".format(prefix) metric_suffix =...
def _normalize(self, metric_name, submit_method, prefix): """ Replace case-sensitive metric name characters, normalize the metric name, prefix and suffix according to its type. """ metric_prefix = "mongodb." if not prefix else "mongodb.{0}.".format(prefix) metric_suffix =...
[ "Replace", "case", "-", "sensitive", "metric", "name", "characters", "normalize", "the", "metric", "name", "prefix", "and", "suffix", "according", "to", "its", "type", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/mongo/datadog_checks/mongo/mongo.py#L559-L576
[ "def", "_normalize", "(", "self", ",", "metric_name", ",", "submit_method", ",", "prefix", ")", ":", "metric_prefix", "=", "\"mongodb.\"", "if", "not", "prefix", "else", "\"mongodb.{0}.\"", ".", "format", "(", "prefix", ")", "metric_suffix", "=", "\"ps\"", "if...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
MongoDb._authenticate
Authenticate to the database. Available mechanisms: * Username & password * X.509 More information: https://api.mongodb.com/python/current/examples/authentication.html
mongo/datadog_checks/mongo/mongo.py
def _authenticate(self, database, username, password, use_x509, server_name, service_check_tags): """ Authenticate to the database. Available mechanisms: * Username & password * X.509 More information: https://api.mongodb.com/python/current/examples/authenticati...
def _authenticate(self, database, username, password, use_x509, server_name, service_check_tags): """ Authenticate to the database. Available mechanisms: * Username & password * X.509 More information: https://api.mongodb.com/python/current/examples/authenticati...
[ "Authenticate", "to", "the", "database", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/mongo/datadog_checks/mongo/mongo.py#L578-L608
[ "def", "_authenticate", "(", "self", ",", "database", ",", "username", ",", "password", ",", "use_x509", ",", "server_name", ",", "service_check_tags", ")", ":", "authenticated", "=", "False", "try", ":", "# X.509", "if", "use_x509", ":", "self", ".", "log",...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
MongoDb._parse_uri
Parses a MongoDB-formatted URI (e.g. mongodb://user:pass@server/db) and returns parsed elements and a sanitized URI.
mongo/datadog_checks/mongo/mongo.py
def _parse_uri(cls, server, sanitize_username=False): """ Parses a MongoDB-formatted URI (e.g. mongodb://user:pass@server/db) and returns parsed elements and a sanitized URI. """ parsed = pymongo.uri_parser.parse_uri(server) username = parsed.get('username') pass...
def _parse_uri(cls, server, sanitize_username=False): """ Parses a MongoDB-formatted URI (e.g. mongodb://user:pass@server/db) and returns parsed elements and a sanitized URI. """ parsed = pymongo.uri_parser.parse_uri(server) username = parsed.get('username') pass...
[ "Parses", "a", "MongoDB", "-", "formatted", "URI", "(", "e", ".", "g", ".", "mongodb", ":", "//", "user", ":", "pass" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/mongo/datadog_checks/mongo/mongo.py#L611-L634
[ "def", "_parse_uri", "(", "cls", ",", "server", ",", "sanitize_username", "=", "False", ")", ":", "parsed", "=", "pymongo", ".", "uri_parser", ".", "parse_uri", "(", "server", ")", "username", "=", "parsed", ".", "get", "(", "'username'", ")", "password", ...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
MongoDb._collect_indexes_stats
Collect indexes statistics for all collections in the configuration. This use the "$indexStats" command.
mongo/datadog_checks/mongo/mongo.py
def _collect_indexes_stats(self, instance, db, tags): """ Collect indexes statistics for all collections in the configuration. This use the "$indexStats" command. """ for coll_name in instance.get('collections', []): try: for stats in db[coll_name].agg...
def _collect_indexes_stats(self, instance, db, tags): """ Collect indexes statistics for all collections in the configuration. This use the "$indexStats" command. """ for coll_name in instance.get('collections', []): try: for stats in db[coll_name].agg...
[ "Collect", "indexes", "statistics", "for", "all", "collections", "in", "the", "configuration", ".", "This", "use", "the", "$indexStats", "command", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/mongo/datadog_checks/mongo/mongo.py#L636-L651
[ "def", "_collect_indexes_stats", "(", "self", ",", "instance", ",", "db", ",", "tags", ")", ":", "for", "coll_name", "in", "instance", ".", "get", "(", "'collections'", ",", "[", "]", ")", ":", "try", ":", "for", "stats", "in", "db", "[", "coll_name", ...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
MongoDb.check
Returns a dictionary that looks a lot like what's sent back by db.serverStatus()
mongo/datadog_checks/mongo/mongo.py
def check(self, instance): """ Returns a dictionary that looks a lot like what's sent back by db.serverStatus() """ def total_seconds(td): """ Returns total seconds of a timedelta in a way that's safe for Python < 2.7 """ ...
def check(self, instance): """ Returns a dictionary that looks a lot like what's sent back by db.serverStatus() """ def total_seconds(td): """ Returns total seconds of a timedelta in a way that's safe for Python < 2.7 """ ...
[ "Returns", "a", "dictionary", "that", "looks", "a", "lot", "like", "what", "s", "sent", "back", "by", "db", ".", "serverStatus", "()" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/mongo/datadog_checks/mongo/mongo.py#L653-L1045
[ "def", "check", "(", "self", ",", "instance", ")", ":", "def", "total_seconds", "(", "td", ")", ":", "\"\"\"\n Returns total seconds of a timedelta in a way that's safe for\n Python < 2.7\n \"\"\"", "if", "hasattr", "(", "td", ",", "'total_sec...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
get_normal_connection
Get the connection either with a username and password or without
ibm_mq/datadog_checks/ibm_mq/connection.py
def get_normal_connection(config): """ Get the connection either with a username and password or without """ if config.username and config.password: log.debug("connecting with username and password") queue_manager = pymqi.connect( config.queue_manager_name, config.channel, co...
def get_normal_connection(config): """ Get the connection either with a username and password or without """ if config.username and config.password: log.debug("connecting with username and password") queue_manager = pymqi.connect( config.queue_manager_name, config.channel, co...
[ "Get", "the", "connection", "either", "with", "a", "username", "and", "password", "or", "without" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/ibm_mq/datadog_checks/ibm_mq/connection.py#L25-L38
[ "def", "get_normal_connection", "(", "config", ")", ":", "if", "config", ".", "username", "and", "config", ".", "password", ":", "log", ".", "debug", "(", "\"connecting with username and password\"", ")", "queue_manager", "=", "pymqi", ".", "connect", "(", "conf...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
get_ssl_connection
Get the connection with SSL
ibm_mq/datadog_checks/ibm_mq/connection.py
def get_ssl_connection(config): """ Get the connection with SSL """ cd = pymqi.CD() cd.ChannelName = config.channel cd.ConnectionName = config.host_and_port cd.ChannelType = pymqi.CMQC.MQCHT_CLNTCONN cd.TransportType = pymqi.CMQC.MQXPT_TCP cd.SSLCipherSpec = config.ssl_cipher_spec ...
def get_ssl_connection(config): """ Get the connection with SSL """ cd = pymqi.CD() cd.ChannelName = config.channel cd.ConnectionName = config.host_and_port cd.ChannelType = pymqi.CMQC.MQCHT_CLNTCONN cd.TransportType = pymqi.CMQC.MQXPT_TCP cd.SSLCipherSpec = config.ssl_cipher_spec ...
[ "Get", "the", "connection", "with", "SSL" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/ibm_mq/datadog_checks/ibm_mq/connection.py#L41-L58
[ "def", "get_ssl_connection", "(", "config", ")", ":", "cd", "=", "pymqi", ".", "CD", "(", ")", "cd", ".", "ChannelName", "=", "config", ".", "channel", "cd", ".", "ConnectionName", "=", "config", ".", "host_and_port", "cd", ".", "ChannelType", "=", "pymq...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
check_run
Run an Agent check.
datadog_checks_dev/datadog_checks/dev/tooling/commands/env/check.py
def check_run(check, env, rate, times, pause, delay, log_level, as_json, break_point): """Run an Agent check.""" envs = get_configured_envs(check) if not envs: echo_failure('No active environments found for `{}`.'.format(check)) echo_info('See what is available to start via `ddev env ls {}`....
def check_run(check, env, rate, times, pause, delay, log_level, as_json, break_point): """Run an Agent check.""" envs = get_configured_envs(check) if not envs: echo_failure('No active environments found for `{}`.'.format(check)) echo_info('See what is available to start via `ddev env ls {}`....
[ "Run", "an", "Agent", "check", "." ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_dev/datadog_checks/dev/tooling/commands/env/check.py#L33-L60
[ "def", "check_run", "(", "check", ",", "env", ",", "rate", ",", "times", ",", "pause", ",", "delay", ",", "log_level", ",", "as_json", ",", "break_point", ")", ":", "envs", "=", "get_configured_envs", "(", "check", ")", "if", "not", "envs", ":", "echo_...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
OpenStackScope.get_user_identity
Parse user identity out of init_config To guarantee a uniquely identifiable user, expects {"user": {"name": "my_username", "password": "my_password", "domain": {"id": "my_domain_id"} } }
openstack/datadog_checks/openstack/openstack.py
def get_user_identity(cls, instance_config): """ Parse user identity out of init_config To guarantee a uniquely identifiable user, expects {"user": {"name": "my_username", "password": "my_password", "domain": {"id": "my_domain_id"} } } ...
def get_user_identity(cls, instance_config): """ Parse user identity out of init_config To guarantee a uniquely identifiable user, expects {"user": {"name": "my_username", "password": "my_password", "domain": {"id": "my_domain_id"} } } ...
[ "Parse", "user", "identity", "out", "of", "init_config" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/openstack/datadog_checks/openstack/openstack.py#L171-L189
[ "def", "get_user_identity", "(", "cls", ",", "instance_config", ")", ":", "user", "=", "instance_config", ".", "get", "(", "'user'", ")", "if", "not", "(", "user", "and", "user", ".", "get", "(", "'name'", ")", "and", "user", ".", "get", "(", "'passwor...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
OpenStackScope.get_auth_scope
Parse authorization scope out of init_config To guarantee a uniquely identifiable scope, expects either: {'project': {'name': 'my_project', 'domain': {'id': 'my_domain_id'}}} OR {'project': {'id': 'my_project_id'}}
openstack/datadog_checks/openstack/openstack.py
def get_auth_scope(cls, instance_config): """ Parse authorization scope out of init_config To guarantee a uniquely identifiable scope, expects either: {'project': {'name': 'my_project', 'domain': {'id': 'my_domain_id'}}} OR {'project': {'id': 'my_project_id'}} ""...
def get_auth_scope(cls, instance_config): """ Parse authorization scope out of init_config To guarantee a uniquely identifiable scope, expects either: {'project': {'name': 'my_project', 'domain': {'id': 'my_domain_id'}}} OR {'project': {'id': 'my_project_id'}} ""...
[ "Parse", "authorization", "scope", "out", "of", "init_config" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/openstack/datadog_checks/openstack/openstack.py#L192-L217
[ "def", "get_auth_scope", "(", "cls", ",", "instance_config", ")", ":", "auth_scope", "=", "instance_config", ".", "get", "(", "'auth_scope'", ")", "if", "not", "auth_scope", ":", "return", "None", "if", "not", "auth_scope", ".", "get", "(", "'project'", ")",...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
KeystoneCatalog.get_neutron_endpoint
Parse the service catalog returned by the Identity API for an endpoint matching the Neutron service Sends a CRITICAL service check when none are found registered in the Catalog
openstack/datadog_checks/openstack/openstack.py
def get_neutron_endpoint(cls, json_resp): """ Parse the service catalog returned by the Identity API for an endpoint matching the Neutron service Sends a CRITICAL service check when none are found registered in the Catalog """ catalog = json_resp.get('token', {}).get('catalog', [...
def get_neutron_endpoint(cls, json_resp): """ Parse the service catalog returned by the Identity API for an endpoint matching the Neutron service Sends a CRITICAL service check when none are found registered in the Catalog """ catalog = json_resp.get('token', {}).get('catalog', [...
[ "Parse", "the", "service", "catalog", "returned", "by", "the", "Identity", "API", "for", "an", "endpoint", "matching", "the", "Neutron", "service", "Sends", "a", "CRITICAL", "service", "check", "when", "none", "are", "found", "registered", "in", "the", "Catalo...
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/openstack/datadog_checks/openstack/openstack.py#L455-L479
[ "def", "get_neutron_endpoint", "(", "cls", ",", "json_resp", ")", ":", "catalog", "=", "json_resp", ".", "get", "(", "'token'", ",", "{", "}", ")", ".", "get", "(", "'catalog'", ",", "[", "]", ")", "match", "=", "'neutron'", "neutron_endpoint", "=", "N...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
KeystoneCatalog.get_nova_endpoint
Parse the service catalog returned by the Identity API for an endpoint matching the Nova service with the requested version Sends a CRITICAL service check when no viable candidates are found in the Catalog
openstack/datadog_checks/openstack/openstack.py
def get_nova_endpoint(cls, json_resp, nova_api_version=None): """ Parse the service catalog returned by the Identity API for an endpoint matching the Nova service with the requested version Sends a CRITICAL service check when no viable candidates are found in the Catalog """ ...
def get_nova_endpoint(cls, json_resp, nova_api_version=None): """ Parse the service catalog returned by the Identity API for an endpoint matching the Nova service with the requested version Sends a CRITICAL service check when no viable candidates are found in the Catalog """ ...
[ "Parse", "the", "service", "catalog", "returned", "by", "the", "Identity", "API", "for", "an", "endpoint", "matching", "the", "Nova", "service", "with", "the", "requested", "version", "Sends", "a", "CRITICAL", "service", "check", "when", "no", "viable", "candi...
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/openstack/datadog_checks/openstack/openstack.py#L482-L507
[ "def", "get_nova_endpoint", "(", "cls", ",", "json_resp", ",", "nova_api_version", "=", "None", ")", ":", "nova_version", "=", "nova_api_version", "or", "DEFAULT_NOVA_API_VERSION", "catalog", "=", "json_resp", ".", "get", "(", "'token'", ",", "{", "}", ")", "....
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
OpenStackCheck._make_request_with_auth_fallback
Generic request handler for OpenStack API requests Raises specialized Exceptions for commonly encountered error codes
openstack/datadog_checks/openstack/openstack.py
def _make_request_with_auth_fallback(self, url, headers=None, params=None): """ Generic request handler for OpenStack API requests Raises specialized Exceptions for commonly encountered error codes """ self.log.debug("Request URL and Params: %s, %s", url, params) try: ...
def _make_request_with_auth_fallback(self, url, headers=None, params=None): """ Generic request handler for OpenStack API requests Raises specialized Exceptions for commonly encountered error codes """ self.log.debug("Request URL and Params: %s, %s", url, params) try: ...
[ "Generic", "request", "handler", "for", "OpenStack", "API", "requests", "Raises", "specialized", "Exceptions", "for", "commonly", "encountered", "error", "codes" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/openstack/datadog_checks/openstack/openstack.py#L576-L606
[ "def", "_make_request_with_auth_fallback", "(", "self", ",", "url", ",", "headers", "=", "None", ",", "params", "=", "None", ")", ":", "self", ".", "log", ".", "debug", "(", "\"Request URL and Params: %s, %s\"", ",", "url", ",", "params", ")", "try", ":", ...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
OpenStackCheck.get_network_stats
Collect stats for all reachable networks
openstack/datadog_checks/openstack/openstack.py
def get_network_stats(self, tags): """ Collect stats for all reachable networks """ # FIXME: (aaditya) Check all networks defaults to true # until we can reliably assign agents to networks to monitor if is_affirmative(self.init_config.get('check_all_networks', True)): ...
def get_network_stats(self, tags): """ Collect stats for all reachable networks """ # FIXME: (aaditya) Check all networks defaults to true # until we can reliably assign agents to networks to monitor if is_affirmative(self.init_config.get('check_all_networks', True)): ...
[ "Collect", "stats", "for", "all", "reachable", "networks" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/openstack/datadog_checks/openstack/openstack.py#L688-L714
[ "def", "get_network_stats", "(", "self", ",", "tags", ")", ":", "# FIXME: (aaditya) Check all networks defaults to true", "# until we can reliably assign agents to networks to monitor", "if", "is_affirmative", "(", "self", ".", "init_config", ".", "get", "(", "'check_all_networ...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
OpenStackCheck._parse_uptime_string
Parse u' 16:53:48 up 1 day, 21:34, 3 users, load average: 0.04, 0.14, 0.19\n'
openstack/datadog_checks/openstack/openstack.py
def _parse_uptime_string(self, uptime): """ Parse u' 16:53:48 up 1 day, 21:34, 3 users, load average: 0.04, 0.14, 0.19\n' """ uptime = uptime.strip() load_averages = uptime[uptime.find('load average:') :].split(':')[1].split(',') uptime_sec = uptime.split(',')[0] return {'load...
def _parse_uptime_string(self, uptime): """ Parse u' 16:53:48 up 1 day, 21:34, 3 users, load average: 0.04, 0.14, 0.19\n' """ uptime = uptime.strip() load_averages = uptime[uptime.find('load average:') :].split(':')[1].split(',') uptime_sec = uptime.split(',')[0] return {'load...
[ "Parse", "u", "16", ":", "53", ":", "48", "up", "1", "day", "21", ":", "34", "3", "users", "load", "average", ":", "0", ".", "04", "0", ".", "14", "0", ".", "19", "\\", "n" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/openstack/datadog_checks/openstack/openstack.py#L759-L765
[ "def", "_parse_uptime_string", "(", "self", ",", "uptime", ")", ":", "uptime", "=", "uptime", ".", "strip", "(", ")", "load_averages", "=", "uptime", "[", "uptime", ".", "find", "(", "'load average:'", ")", ":", "]", ".", "split", "(", "':'", ")", "[",...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
OpenStackCheck.ensure_auth_scope
Guarantees a valid auth scope for this instance, and returns it Communicates with the identity server and initializes a new scope when one is absent, or has been forcibly removed due to token expiry
openstack/datadog_checks/openstack/openstack.py
def ensure_auth_scope(self, instance): """ Guarantees a valid auth scope for this instance, and returns it Communicates with the identity server and initializes a new scope when one is absent, or has been forcibly removed due to token expiry """ instance_scope = None ...
def ensure_auth_scope(self, instance): """ Guarantees a valid auth scope for this instance, and returns it Communicates with the identity server and initializes a new scope when one is absent, or has been forcibly removed due to token expiry """ instance_scope = None ...
[ "Guarantees", "a", "valid", "auth", "scope", "for", "this", "instance", "and", "returns", "it" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/openstack/datadog_checks/openstack/openstack.py#L1105-L1179
[ "def", "ensure_auth_scope", "(", "self", ",", "instance", ")", ":", "instance_scope", "=", "None", "custom_tags", "=", "instance", ".", "get", "(", "'tags'", ",", "[", "]", ")", "if", "custom_tags", "is", "None", ":", "custom_tags", "=", "[", "]", "try",...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
OpenStackCheck.get_local_hypervisor
Returns the hypervisor running on this host, and assumes a 1-1 between host and hypervisor
openstack/datadog_checks/openstack/openstack.py
def get_local_hypervisor(self): """ Returns the hypervisor running on this host, and assumes a 1-1 between host and hypervisor """ # Look up hypervisors available filtered by my hostname host = self.get_my_hostname() hyp = self.get_all_hypervisor_ids(filter_by_host=host) ...
def get_local_hypervisor(self): """ Returns the hypervisor running on this host, and assumes a 1-1 between host and hypervisor """ # Look up hypervisors available filtered by my hostname host = self.get_my_hostname() hyp = self.get_all_hypervisor_ids(filter_by_host=host) ...
[ "Returns", "the", "hypervisor", "running", "on", "this", "host", "and", "assumes", "a", "1", "-", "1", "between", "host", "and", "hypervisor" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/openstack/datadog_checks/openstack/openstack.py#L1313-L1321
[ "def", "get_local_hypervisor", "(", "self", ")", ":", "# Look up hypervisors available filtered by my hostname", "host", "=", "self", ".", "get_my_hostname", "(", ")", "hyp", "=", "self", ".", "get_all_hypervisor_ids", "(", "filter_by_host", "=", "host", ")", "if", ...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
OpenStackCheck.get_all_projects
Returns all projects in the domain
openstack/datadog_checks/openstack/openstack.py
def get_all_projects(self, scope): """ Returns all projects in the domain """ url = "{0}/{1}/{2}".format(self.keystone_server_url, DEFAULT_KEYSTONE_API_VERSION, "projects") headers = {'X-Auth-Token': scope.auth_token} try: r = self._make_request_with_auth_fall...
def get_all_projects(self, scope): """ Returns all projects in the domain """ url = "{0}/{1}/{2}".format(self.keystone_server_url, DEFAULT_KEYSTONE_API_VERSION, "projects") headers = {'X-Auth-Token': scope.auth_token} try: r = self._make_request_with_auth_fall...
[ "Returns", "all", "projects", "in", "the", "domain" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/openstack/datadog_checks/openstack/openstack.py#L1323-L1337
[ "def", "get_all_projects", "(", "self", ",", "scope", ")", ":", "url", "=", "\"{0}/{1}/{2}\"", ".", "format", "(", "self", ".", "keystone_server_url", ",", "DEFAULT_KEYSTONE_API_VERSION", ",", "\"projects\"", ")", "headers", "=", "{", "'X-Auth-Token'", ":", "sco...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
OpenStackCheck.get_scoped_project
Returns the project that this instance of the check is scoped to
openstack/datadog_checks/openstack/openstack.py
def get_scoped_project(self, project_auth_scope): """ Returns the project that this instance of the check is scoped to """ filter_params = {} url = "{0}/{1}/{2}".format(self.keystone_server_url, DEFAULT_KEYSTONE_API_VERSION, "projects") if project_auth_scope.tenant_id: ...
def get_scoped_project(self, project_auth_scope): """ Returns the project that this instance of the check is scoped to """ filter_params = {} url = "{0}/{1}/{2}".format(self.keystone_server_url, DEFAULT_KEYSTONE_API_VERSION, "projects") if project_auth_scope.tenant_id: ...
[ "Returns", "the", "project", "that", "this", "instance", "of", "the", "check", "is", "scoped", "to" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/openstack/datadog_checks/openstack/openstack.py#L1339-L1372
[ "def", "get_scoped_project", "(", "self", ",", "project_auth_scope", ")", ":", "filter_params", "=", "{", "}", "url", "=", "\"{0}/{1}/{2}\"", ".", "format", "(", "self", ".", "keystone_server_url", ",", "DEFAULT_KEYSTONE_API_VERSION", ",", "\"projects\"", ")", "if...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
OpenStackCheck.get_my_hostname
Returns a best guess for the hostname registered with OpenStack for this host
openstack/datadog_checks/openstack/openstack.py
def get_my_hostname(self, split_hostname_on_first_period=False): """ Returns a best guess for the hostname registered with OpenStack for this host """ hostname = self.init_config.get("os_host") or self.hostname if split_hostname_on_first_period: hostname = hostname.s...
def get_my_hostname(self, split_hostname_on_first_period=False): """ Returns a best guess for the hostname registered with OpenStack for this host """ hostname = self.init_config.get("os_host") or self.hostname if split_hostname_on_first_period: hostname = hostname.s...
[ "Returns", "a", "best", "guess", "for", "the", "hostname", "registered", "with", "OpenStack", "for", "this", "host" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/openstack/datadog_checks/openstack/openstack.py#L1374-L1383
[ "def", "get_my_hostname", "(", "self", ",", "split_hostname_on_first_period", "=", "False", ")", ":", "hostname", "=", "self", ".", "init_config", ".", "get", "(", "\"os_host\"", ")", "or", "self", ".", "hostname", "if", "split_hostname_on_first_period", ":", "h...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd
train
OpenStackCheck.get_external_host_tags
Returns a list of tags for every guest server that is detected by the OpenStack integration. List of pairs (hostname, list_of_tags)
openstack/datadog_checks/openstack/openstack.py
def get_external_host_tags(self): """ Returns a list of tags for every guest server that is detected by the OpenStack integration. List of pairs (hostname, list_of_tags) """ self.log.debug("Collecting external_host_tags now") external_host_tags = [] for k, v in it...
def get_external_host_tags(self): """ Returns a list of tags for every guest server that is detected by the OpenStack integration. List of pairs (hostname, list_of_tags) """ self.log.debug("Collecting external_host_tags now") external_host_tags = [] for k, v in it...
[ "Returns", "a", "list", "of", "tags", "for", "every", "guest", "server", "that", "is", "detected", "by", "the", "OpenStack", "integration", ".", "List", "of", "pairs", "(", "hostname", "list_of_tags", ")" ]
DataDog/integrations-core
python
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/openstack/datadog_checks/openstack/openstack.py#L1416-L1427
[ "def", "get_external_host_tags", "(", "self", ")", ":", "self", ".", "log", ".", "debug", "(", "\"Collecting external_host_tags now\"", ")", "external_host_tags", "=", "[", "]", "for", "k", ",", "v", "in", "iteritems", "(", "self", ".", "external_host_tags", "...
ebd41c873cf9f97a8c51bf9459bc6a7536af8acd