Adding upstream version 1.34.4.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
e393c3af3f
commit
4978089aab
4963 changed files with 677545 additions and 0 deletions
31
plugins/aggregators/starlark/testdata/merge.star
vendored
Normal file
31
plugins/aggregators/starlark/testdata/merge.star
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
# Example of a merge aggregator implemented with a starlark script.
|
||||
load('time.star', 'time')
|
||||
state = {}
|
||||
def add(metric):
|
||||
metrics = state.get("metrics")
|
||||
if metrics == None:
|
||||
metrics = {}
|
||||
state["metrics"] = metrics
|
||||
state["ordered"] = []
|
||||
gId = groupID(metric)
|
||||
m = metrics.get(gId)
|
||||
if m == None:
|
||||
m = deepcopy(metric)
|
||||
metrics[gId] = m
|
||||
state["ordered"].append(m)
|
||||
else:
|
||||
for k, v in metric.fields.items():
|
||||
m.fields[k] = v
|
||||
|
||||
def push():
|
||||
return state.get("ordered")
|
||||
|
||||
def reset():
|
||||
state.clear()
|
||||
|
||||
def groupID(metric):
|
||||
key = metric.name + "-"
|
||||
for k, v in metric.tags.items():
|
||||
key = key + k + "-" + v + "-"
|
||||
key = key + "-" + str(metric.time)
|
||||
return hash(key)
|
Loading…
Add table
Add a link
Reference in a new issue