groupcache_datadog

module
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2025 License: MIT

README

license Go Report Card Go Reference

groupcache_datadog

groupcache_datadog exports groupcache metrics to Datadog.

Usage

See example ./examples/groupcache-datadog-modernprogram/main.go.

Synopsis

import "github.com/udhos/dogstatsdclient/dogstatsdclient"
import "github.com/udhos/groupcache_datadog/exporter"
import "github.com/udhos/groupcache_exporter"
import "github.com/udhos/groupcache_exporter/groupcache/modernprogram"

cache := startGroupcache() // create the groupcache group (*groupcache.Group)

// create Dogstatsd client
client, errClient := dogstatsdclient.New(dogstatsdclient.Options{
    Namespace: "groupcache",
    Debug:     true,
})

// start the exporter
exporter := exporter.New(exporter.Options{
    Client:         client,
    Groups:         []groupcache_exporter.GroupStatistics{modernprogram.New(cache)},
    ExportInterval: 20 * time.Second,
})
defer exporter.Close()

Build example

git clone https://github.com/udhos/groupcache_datadog
cd groupcache_datadog
go install ./...

Running example

By default the example groupcache-datadog-modernprogram sends metrics to localhost:8125.

$ groupcache-datadog-modernprogram
2025/04/09 00:50:34 groupcache ttl: 30s
2025/04/09 00:50:34 groupcache my URL: http://127.0.0.1:5000
2025/04/09 00:50:34 INFO DD_AGENT_HOST=[] using DD_AGENT_HOST=localhost default=localhost
2025/04/09 00:50:34 groupcache server: listening on :5000
2025/04/09 00:50:34 INFO DD_AGENT_PORT=[] using DD_AGENT_PORT=8125 default=8125
2025/04/09 00:50:34 INFO DD_SERVICE=[] using DD_SERVICE=service-unknown default=service-unknown
2025/04/09 00:50:34 INFO DD_TAGS=[] using DD_TAGS= default=
2025/04/09 00:50:34 INFO NewDatadogClient host=localhost:8125 namespace=groupcache service=service-unknown tags=[service:service-unknown]
2025/04/09 00:50:34 getter: loading: key:/etc/passwd, ttl:30s
2025/04/09 00:50:34 INFO cache answer: bytes=2943 elapsed=50.548208ms, sleeping 5s

Datadog Count is a Delta

Definition

The COUNT metric submission type represents the total number of event occurrences in one time interval. A COUNT can be used to track the total number of connections made to a database or the total number of requests to an endpoint. This number of events can accumulate or decrease over time—it is not monotonically increasing.

Example

Suppose you are submitting a COUNT metric, notifications.sent, from a single host running the Datadog Agent. This host emits the following values in a flush time interval: [1,1,1,2,2,2,3,3].

The Agent adds all of the values received in one time interval. Then, it submits the total number, in this case 15, as the COUNT metric’s value.

Source: https://docs.datadoghq.com/metrics/types/?tab=count#definition

Directories

Path Synopsis
examples
groupcache-datadog-google
Package main implements the example.
Package main implements the example.
groupcache-datadog-mailgun
Package main implements the example.
Package main implements the example.
groupcache-datadog-modernprogram
Package main implements the example.
Package main implements the example.
Package exporter implements datadog exporter for groupcache.
Package exporter implements datadog exporter for groupcache.
internal
mock
Package mock mocks dogstatsdclient.
Package mock mocks dogstatsdclient.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL