forked from instana/python-sensor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsensor.py
More file actions
42 lines (33 loc) · 926 Bytes
/
Copy pathsensor.py
File metadata and controls
42 lines (33 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from __future__ import absolute_import
from . import log
from .agent import Agent
from .meter import Meter
from .options import Options
class Sensor(object):
options = None
meter = None
agent = None
def __init__(self, options):
self.set_options(options)
log.init(options.log_level)
self.agent = Agent(self)
self.meter = Meter(self)
log.debug("initialized sensor")
def set_options(self, options):
self.options = options
if not self.options:
self.options = Options()
def handle_fork(self):
self.agent = Agent(self)
self.meter = Meter(self)
def get_sensor():
return global_sensor
# For any given Python process, we only want one sensor as multiple would
# collect/report metrics in duplicate, triplicate etc..
#
# Usage example:
#
# import instana
# instana.global_sensor
#
global_sensor = Sensor(Options())