1515"""
1616
1717import atexit
18- import os
1918
2019from .aggregator import Aggregator
2120from .database import ApiForgeDatabase
@@ -39,9 +38,8 @@ class ApiForgeMiddleware(_Base):
3938 api_key: Cloud mode: project API key starting with 'af_'.
4039 db_path: Local mode: SQLite file path. Default: '.apiforge.db'.
4140 dashboard_port: Local mode: dashboard port. 0 = disabled. Default: 4242.
42- flush_interval: Aggregation flush interval in ms. Default: 60 000.
43- env: Environment label. Default: ENV env var or 'production'.
44- release: Release tag. Default: APP_VERSION env var.
41+ env: Environment label. Default: 'production'.
42+ release: Release tag. Default: None.
4543 service: Service name. Default: 'default'.
4644 sampling: Sample rate 0.0–1.0. Default: 1.0.
4745 ignore_paths: Paths to exclude. Default: ['/favicon.ico'].
@@ -55,12 +53,12 @@ def __init__(
5553 api_key : str | None = None ,
5654 db_path : str = ".apiforge.db" ,
5755 dashboard_port : int = 4242 ,
58- flush_interval : int = 60_000 ,
5956 env : str | None = None ,
6057 release : str | None = None ,
6158 service : str = "default" ,
6259 sampling : float = 1.0 ,
6360 ignore_paths : list [str ] = None ,
61+ _flush_interval : int = 60_000 , # internal — not part of the public API
6462 ):
6563 is_cloud = bool (cloud_url and api_key )
6664
@@ -69,8 +67,8 @@ def __init__(
6967
7068 config = {
7169 "mode" : "cloud" if is_cloud else "local" ,
72- "env" : env or os . environ . get ( "ENV" , " production") ,
73- "release" : release or os . environ . get ( "APP_VERSION" ) ,
70+ "env" : env or " production" ,
71+ "release" : release ,
7472 "service" : service ,
7573 "sampling" : sampling ,
7674 "ignore_paths" : ignore_paths or ["/favicon.ico" ],
@@ -88,7 +86,7 @@ def __init__(
8886 transport = LocalTransport (self ._db )
8987 config ["store_routes" ] = self ._db .upsert_known_routes
9088
91- aggregator = Aggregator (transport , flush_interval )
89+ aggregator = Aggregator (transport , _flush_interval )
9290 aggregator .start ()
9391
9492 if not is_cloud and dashboard_port :
0 commit comments