File tree 6 files changed +29
-15
lines changed
airflow_prometheus_exporter
6 files changed +29
-15
lines changed Original file line number Diff line number Diff line change
1
+ include README.md
2
+ include MANIFEST.in
3
+ include setup.cfg
4
+ include setup.py
5
+ recursive-include airflow_prometheus_exporter/ *
6
+
7
+ recursive-exclude * __pycache__
8
+ recursive-exclude * *.py[co]
9
+ recursive-exclude * .*.sw[a-z]
Original file line number Diff line number Diff line change @@ -51,8 +51,9 @@ value of configurable parameter in xcom table
51
51
52
52
xcom fields is deserialized as a dictionary and if key is found for a paticular task-id, the value is reported as a guage
53
53
54
- add task / key combinations in config.yaml:
55
- ```
54
+ Add task / key combinations in config.yaml:
55
+
56
+ ``` bash
56
57
xcom_params:
57
58
-
58
59
task_id: abc
File renamed without changes.
Original file line number Diff line number Diff line change 1
1
"""Prometheus exporter for Airflow."""
2
-
2
+ import json
3
+ import pickle
3
4
from contextlib import contextmanager
4
5
5
6
from airflow .configuration import conf
8
9
from airflow .settings import Session
9
10
from airflow .utils .state import State
10
11
from airflow .utils .log .logging_mixin import LoggingMixin
11
- from airflow_prometheus_exporter .xcom_config import xcom_config
12
12
from flask import Response
13
13
from flask_admin import BaseView , expose
14
- import json
15
- import pickle
16
14
from prometheus_client import generate_latest , REGISTRY
17
15
from prometheus_client .core import GaugeMetricFamily
18
16
from sqlalchemy import and_ , func
19
17
18
+ from airflow_prometheus_exporter .xcom_config import load_xcom_config
20
19
21
20
CANARY_DAG = "canary_dag"
22
21
@@ -439,7 +438,8 @@ def collect(self):
439
438
labels = ["dag_id" , "task_id" ],
440
439
)
441
440
442
- for tasks in xcom_config ["xcom_params" ]:
441
+ xcom_config = load_xcom_config ()
442
+ for tasks in xcom_config .get ("xcom_params" , []):
443
443
for param in get_xcom_params (tasks ["task_id" ]):
444
444
xcom_value = extract_xcom_parameter (param .value )
445
445
Original file line number Diff line number Diff line change 1
1
import yaml
2
- import os
2
+ from pathlib import Path
3
3
4
- dir = os .path .dirname (__file__ )
5
- filename = os .path .join (dir , "../config.yaml" )
4
+ CONFIG_FILE = Path .cwd () / "config.yaml"
6
5
7
6
8
- xcom_config = {}
9
- with open (filename ) as file :
10
- # The FullLoader parameter handles the conversion from YAML
11
- # scalar values to Python the dictionary format
12
- xcom_config = yaml .load (file , Loader = yaml .FullLoader )
7
+ def load_xcom_config ():
8
+ """Loads the XCom config if present."""
9
+ try :
10
+ with open (CONFIG_FILE ) as file :
11
+ # The FullLoader parameter handles the conversion from YAML
12
+ # scalar values to Python the dictionary format
13
+ return yaml .load (file , Loader = yaml .FullLoader )
14
+ except FileNotFoundError :
15
+ return {}
Original file line number Diff line number Diff line change 41
41
keywords = 'airflow_prometheus_exporter' ,
42
42
name = 'airflow_prometheus_exporter' ,
43
43
packages = find_packages (include = ['airflow_prometheus_exporter' ]),
44
+ include_package_data = True ,
44
45
url = 'https://github.com/robinhood/airflow_prometheus_exporter' ,
45
46
version = '1.0.5' ,
46
47
entry_points = {
You can’t perform that action at this time.
0 commit comments