Skip to content

Commit

Permalink
make metrics from carbon-cache go via relay config
Browse files Browse the repository at this point in the history
  • Loading branch information
bucko909 committed Aug 21, 2024
1 parent 52b40b2 commit 82fcf32
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/carbon/instrumentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def cache_record(metric, value):
else:
fullMetric = '%s.agents.%s-%s.%s' % (prefix, HOSTNAME, settings.instance, metric)
datapoint = (time.time(), value)
cache.MetricCache().store(fullMetric, datapoint)
state.client_manager.sendDatapoint(fullMetric, datapoint)


def relay_record(metric, value):
Expand Down
23 changes: 23 additions & 0 deletions lib/carbon/routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,29 @@ def getDestinations(self, key):
raise NotImplementedError()


class ConstantRouter(DatapointRouter):
plugin_name = 'constant'

def __init__(self, settings):
self.destinations = set()

def addDestination(self, destination):
self.destinations.add(destination)

def removeDestination(self, destination):
self.destinations.discard(destination)

def hasDestination(self, destination):
return destination in self.destinations

def countDestinations(self):
return len(self.destinations)

def getDestinations(self, key):
for destination in self.destinations:
yield destination


class RelayRulesRouter(DatapointRouter):
plugin_name = 'rules'

Expand Down
1 change: 1 addition & 0 deletions lib/carbon/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def setupPipeline(pipeline, root_service, settings):
setupRelayProcessor(root_service, settings)
elif processor == 'write':
setupWriterProcessor(root_service, settings)
setupRelayProcessor(root_service, settings)
else:
raise ValueError("Invalid pipeline processor '%s'" % processor)

Expand Down

0 comments on commit 82fcf32

Please sign in to comment.