DataDogCounters

Performance counters that send their metrics to a DataDog service.

Extends: CachedCounters

Implements: IReferenceable, IOpenable

Description

The DataDogCounters class allows you to create performance counters that send their metrics to a DataDog service.

Configuration parameters

  • connection(s):
    • discovery_key: (optional) key to retrieve the connection from IDiscovery
      • protocol: (optional) connection protocol: http or https (default: https)
      • host: (optional) host name or IP address (default: api.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:
    • retries: number of retries (default: 3)
    • connect_timeout: connection timeout in milliseconds (default: 10 sec)
    • timeout: invocation timeout in milliseconds (default: 10 sec)

References

  • *:logger:*:*:1.0 - (optional) ILogger components to pass log messages
  • *:counters:*:*:1.0 - (optional) ICounters components to pass collected measurements
  • *:discovery:*:*:1.0 - (optional) IDiscovery services to resolve connection

Constructors

Creates a new instance of the class.

public constructor()

Instance methods

close

Closes a component and frees used resources.

DataDogCounters() : super()

configure

Configures a component by passing its configuration parameters.

void configure(ConfigParams config)

  • config: ConfigParams - (optional) Basic implementation of an execution context..

isOpen

Checks if the component is open.

bool isOpen()

  • returns: boolean - true if the component has been opened and false otherwise.

open

Opens the component.

Future open(IContext? context) async

  • context: IContext - (optional) a context to trace execution through a call chain.

save

Saves the current counters' measurements.

void save(List<Counter[]> counters)

  • counters: Counter[] - current counters' measurements to be saved.

setReferences

Sets references to dependent components.

void setReferences(IReferences references)

  • references: IReferences - references to locate the component’s dependencies.

Examples

var counters = new DataDogCounters();
     counters.configure(ConfigParams.fromTuples([
         "credential.access_key", "827349874395872349875493"
     ]));

     await counters.open(Context.fromTraceId("123"));

     counters.increment("mycomponent.mymethod.calls");
     var timing = counters.beginTiming("mycomponent.mymethod.exec_time");
     try {
         ...
     } finally {
         timing.endTiming();
     }

     counters.dump();

See also