forked from bizon-data/bizon-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fea: add datadog monitoring * chore: remove prometheus and otel * chore: handle no datadog * chore: lint
- Loading branch information
1 parent
9438223
commit a47c4e0
Showing
19 changed files
with
194 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,4 +68,4 @@ profile_default/ | |
ipython_config.py | ||
|
||
hubspot_credentials.json | ||
test-pipeline.yml | ||
test-pipeline*.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from enum import Enum | ||
from typing import Optional | ||
|
||
from pydantic import BaseModel | ||
|
||
|
||
class MonitorType(str, Enum): | ||
DATADOG = "datadog" | ||
|
||
|
||
class DatadogConfig(BaseModel): | ||
datadog_agent_host: str | ||
datadog_agent_port: int = 8125 | ||
|
||
|
||
class MonitoringConfig(BaseModel): | ||
type: MonitorType | ||
config: Optional[DatadogConfig] = None |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from datadog import initialize, statsd | ||
from loguru import logger | ||
|
||
from bizon.common.models import BizonConfig | ||
from bizon.engine.pipeline.models import PipelineReturnStatus | ||
from bizon.monitoring.monitor import AbstractMonitor | ||
|
||
|
||
class DatadogMonitor(AbstractMonitor): | ||
def __init__(self, pipeline_config: BizonConfig): | ||
super().__init__(pipeline_config) | ||
|
||
# In Kubernetes, set the host dynamically | ||
try: | ||
initialize( | ||
statsd_host=pipeline_config.monitoring.config.datadog_agent_host, | ||
statsd_port=pipeline_config.monitoring.config.datadog_agent_port, | ||
) | ||
except Exception as e: | ||
logger.info(f"Failed to initialize Datadog agent: {e}") | ||
|
||
self.pipeline_monitor_status = "bizon_pipeline.status" | ||
self.tags = [ | ||
f"name:{self.pipeline_config.name}", | ||
f"stream:{self.pipeline_config.source.stream}", | ||
f"source:{self.pipeline_config.source.name}", | ||
f"destination:{self.pipeline_config.destination.name}", | ||
] | ||
|
||
self.pipeline_active_pipelines = "bizon_pipeline.active_pipelines" | ||
|
||
def track_pipeline_status(self, pipeline_status: PipelineReturnStatus) -> None: | ||
""" | ||
Track the status of the pipeline. | ||
Args: | ||
status (str): The current status of the pipeline (e.g., 'running', 'failed', 'completed'). | ||
""" | ||
|
||
statsd.increment( | ||
self.pipeline_monitor_status, | ||
tags=self.tags + [f"status:{pipeline_status}"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from abc import ABC, abstractmethod | ||
|
||
from bizon.common.models import BizonConfig | ||
from bizon.engine.pipeline.models import PipelineReturnStatus | ||
from bizon.monitoring.config import MonitorType | ||
|
||
|
||
class AbstractMonitor(ABC): | ||
def __init__(self, pipeline_config: BizonConfig): | ||
self.pipeline_config = pipeline_config | ||
# Initialize the monitor | ||
|
||
@abstractmethod | ||
def track_pipeline_status(self, pipeline_status: PipelineReturnStatus) -> None: | ||
""" | ||
Track the status of the pipeline. | ||
Args: | ||
status (str): The current status of the pipeline (e.g., 'running', 'failed', 'completed'). | ||
""" | ||
pass | ||
|
||
|
||
class MonitorFactory: | ||
@staticmethod | ||
def get_monitor(pipeline_config: BizonConfig) -> AbstractMonitor: | ||
if pipeline_config.monitoring is None: | ||
from bizon.monitoring.noop.monitor import NoOpMonitor | ||
|
||
return NoOpMonitor(pipeline_config) | ||
|
||
if pipeline_config.monitoring.type == MonitorType.DATADOG: | ||
from bizon.monitoring.datadog.monitor import DatadogMonitor | ||
|
||
return DatadogMonitor(pipeline_config) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from bizon.common.models import BizonConfig | ||
from bizon.engine.pipeline.models import PipelineReturnStatus | ||
from bizon.monitoring.monitor import AbstractMonitor | ||
|
||
|
||
class NoOpMonitor(AbstractMonitor): | ||
def __init__(self, pipeline_config: BizonConfig): | ||
super().__init__(pipeline_config) | ||
|
||
def track_pipeline_status(self, pipeline_status: PipelineReturnStatus) -> None: | ||
pass |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.