pip_services3_datadog.log package

Submodules

Module contents

class pip_services3_datadog.log.DataDogLogger

Bases: pip_services3_components.log.CachedLogger.CachedLogger, pip_services3_commons.refer.IReferenceable.IReferenceable, pip_services3_commons.run.IOpenable.IOpenable

Logger that dumps execution logs to DataDog service.

DataDog is a popular monitoring SaaS service. It collects logs, metrics, events from infrastructure and applications and analyze them in a single place.

### Configuration parameters ###
  • level: maximum log level to capture

  • source: source (context) name

  • connection:
    • discovery_key: (optional) a key to retrieve the connection from IDiscovery

    • protocol: (optional) connection protocol: http or https (default: https)

    • host: (optional) host name or IP address (default: http-intake.logs.datadoghq.com)

    • port: (optional) port number (default: 443)

    • uri: (optional) resource URI or connection string with all parameters in it

  • credential:
    • access_key: DataDog client api key

  • options:
    • interval: interval in milliseconds to save log messages (default: 10 seconds)

    • max_cache_size: maximum number of messages stored in this cache (default: 100)

    • reconnect: reconnect timeout in milliseconds (default: 60 sec)

    • timeout: invocation timeout in milliseconds (default: 30 sec)

    • max_retries: maximum number of retries (default: 3)

### References ###
  • *:context-info:*:*:1.0 (optional) ContextInfo to detect the context id and specify counters source

  • *:discovery:*:*:1.0 (optional) IDiscovery services to resolve connection

Example:

counters = DataDogLogger()
counters.configure(ConfigParams.from_tuples(
   "credential.access_key", "827349874395872349875493"
))

logger.open('123')

logger.error("123", ex, "Error occured: %s", ex.message)
logger.debug("123", "Everything is OK.")
close(correlation_id: Optional[str])

Closes component and frees used resources.

Parameters

correlation_id – (optional) transaction id to trace execution through call chain.

configure(config: pip_services3_commons.config.ConfigParams.ConfigParams)

Configures component by passing configuration parameters.

Parameters

config – configuration parameters to be set.

is_open() bool

Checks if the component is opened.

Returns

true if the component has been opened and false otherwise.

open(correlation_id: Optional[str])

Opens the component.

Parameters

correlation_id – (optional) transaction id to trace execution through call chain.

set_references(references: pip_services3_commons.refer.IReferences.IReferences)

Sets references to dependent components.

Parameters

references – references to locate the component dependencies.