Skip to content

Commit

Permalink
Improve datadog aggregate key for publisher checks (#52)
Browse files Browse the repository at this point in the history
* Improve datadog aggregate key for publisher checks

* Add some comments
  • Loading branch information
ali-bahjati authored Feb 2, 2023
1 parent b737cdc commit da4f4cc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ignore_missing_imports = true

[tool.poetry]
name = "pyth-observer"
version = "0.1.6"
version = "0.1.7"
description = "Alerts and stuff"
authors = []
readme = "README.md"
Expand Down
12 changes: 11 additions & 1 deletion pyth_observer/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from loguru import logger

from pyth_observer.check import Check
from pyth_observer.check.publisher import PublisherCheck


class Context(TypedDict):
Expand All @@ -35,8 +36,17 @@ async def send(self):
# Publisher checks expect the key -> name mapping of publishers when
# generating the error title/message.
text = self.check.error_message()

# An example is: PriceFeedOfflineCheck-Crypto.AAVE/USD
aggregation_key = f"{self.check.__class__.__name__}-{self.check.state().symbol}"

if self.check.__class__.__bases__ == (PublisherCheck,):
# Add publisher key to the aggregation key to separate different faulty publishers
# An example would be: PublisherPriceCheck-Crypto.AAVE/USD-9TvAYCUkGajRXs....
aggregation_key += "-" + self.check.state().public_key

event = DatadogAPIEvent(
aggregation_key=f"{self.check.__class__.__name__}-{self.check.state().symbol}",
aggregation_key=aggregation_key,
title=text.split("\n")[0],
text=text,
tags=[
Expand Down

0 comments on commit da4f4cc

Please sign in to comment.