Skip to content

Commit da4f4cc

Browse files
authored
Improve datadog aggregate key for publisher checks (#52)
* Improve datadog aggregate key for publisher checks * Add some comments
1 parent b737cdc commit da4f4cc

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ignore_missing_imports = true
44

55
[tool.poetry]
66
name = "pyth-observer"
7-
version = "0.1.6"
7+
version = "0.1.7"
88
description = "Alerts and stuff"
99
authors = []
1010
readme = "README.md"

pyth_observer/event.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from loguru import logger
1212

1313
from pyth_observer.check import Check
14+
from pyth_observer.check.publisher import PublisherCheck
1415

1516

1617
class Context(TypedDict):
@@ -35,8 +36,17 @@ async def send(self):
3536
# Publisher checks expect the key -> name mapping of publishers when
3637
# generating the error title/message.
3738
text = self.check.error_message()
39+
40+
# An example is: PriceFeedOfflineCheck-Crypto.AAVE/USD
41+
aggregation_key = f"{self.check.__class__.__name__}-{self.check.state().symbol}"
42+
43+
if self.check.__class__.__bases__ == (PublisherCheck,):
44+
# Add publisher key to the aggregation key to separate different faulty publishers
45+
# An example would be: PublisherPriceCheck-Crypto.AAVE/USD-9TvAYCUkGajRXs....
46+
aggregation_key += "-" + self.check.state().public_key
47+
3848
event = DatadogAPIEvent(
39-
aggregation_key=f"{self.check.__class__.__name__}-{self.check.state().symbol}",
49+
aggregation_key=aggregation_key,
4050
title=text.split("\n")[0],
4151
text=text,
4252
tags=[

0 commit comments

Comments
 (0)