打点监控初始化 Args: influxdb_host: influxdb_port: influxdb_udp_port: influxdb_database: influxdb_user: influxdb_password: influxdb_measurement: 存储的表,也可以在打点的时候指定 retention_policy: 保留策略 retention_policy_duration: 保留策略过期时间
(
*,
influxdb_host=None,
influxdb_port=None,
influxdb_udp_port=None,
influxdb_database=None,
influxdb_user=None,
influxdb_password=None,
influxdb_measurement=None,
retention_policy=None,
retention_policy_duration="180d",
emit_interval=60,
batch_size=100,
debug=False,
use_udp=False,
timeout=22,
ssl=False,
retention_policy_replication: str = "1",
set_retention_policy_default=True,
**kwargs,
)
| 303 | |
| 304 | |
| 305 | def init( |
| 306 | *, |
| 307 | influxdb_host=None, |
| 308 | influxdb_port=None, |
| 309 | influxdb_udp_port=None, |
| 310 | influxdb_database=None, |
| 311 | influxdb_user=None, |
| 312 | influxdb_password=None, |
| 313 | influxdb_measurement=None, |
| 314 | retention_policy=None, |
| 315 | retention_policy_duration="180d", |
| 316 | emit_interval=60, |
| 317 | batch_size=100, |
| 318 | debug=False, |
| 319 | use_udp=False, |
| 320 | timeout=22, |
| 321 | ssl=False, |
| 322 | retention_policy_replication: str = "1", |
| 323 | set_retention_policy_default=True, |
| 324 | **kwargs, |
| 325 | ): |
| 326 | """ |
| 327 | 打点监控初始化 |
| 328 | Args: |
| 329 | influxdb_host: |
| 330 | influxdb_port: |
| 331 | influxdb_udp_port: |
| 332 | influxdb_database: |
| 333 | influxdb_user: |
| 334 | influxdb_password: |
| 335 | influxdb_measurement: 存储的表,也可以在打点的时候指定 |
| 336 | retention_policy: 保留策略 |
| 337 | retention_policy_duration: 保留策略过期时间 |
| 338 | emit_interval: 打点最大间隔 |
| 339 | batch_size: 打点的批次大小 |
| 340 | debug: 是否开启调试 |
| 341 | use_udp: 是否使用udp协议打点 |
| 342 | timeout: 与influxdb建立连接时的超时时间 |
| 343 | ssl: 是否使用https协议 |
| 344 | retention_policy_replication: 保留策略的副本数, 确保数据的可靠性和高可用性。如果一个节点发生故障,其他节点可以继续提供服务,从而避免数据丢失和服务不可用的情况 |
| 345 | set_retention_policy_default: 是否设置为默认的保留策略,当retention_policy初次创建时有效 |
| 346 | **kwargs: 可传递MetricsEmitter类的参数 |
| 347 | |
| 348 | Returns: |
| 349 | |
| 350 | """ |
| 351 | global _inited_pid, _emitter, _measurement |
| 352 | if _inited_pid == os.getpid(): |
| 353 | return |
| 354 | |
| 355 | influxdb_host = influxdb_host or setting.INFLUXDB_HOST |
| 356 | influxdb_port = influxdb_port or setting.INFLUXDB_PORT |
| 357 | influxdb_udp_port = influxdb_udp_port or setting.INFLUXDB_UDP_PORT |
| 358 | influxdb_database = influxdb_database or setting.INFLUXDB_DATABASE |
| 359 | influxdb_user = influxdb_user or setting.INFLUXDB_USER |
| 360 | influxdb_password = influxdb_password or setting.INFLUXDB_PASSWORD |
| 361 | _measurement = influxdb_measurement or setting.INFLUXDB_MEASUREMENT |
| 362 | retention_policy = ( |
nothing calls this directly
no test coverage detected