traceable-agent 1.2.3__tar.gz → 1.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {traceable-agent-1.2.3/src/traceable_agent.egg-info → traceable-agent-1.3.1}/PKG-INFO +9 -5
- {traceable-agent-1.2.3 → traceable-agent-1.3.1}/README.md +3 -3
- {traceable-agent-1.2.3 → traceable-agent-1.3.1}/setup.py +2 -2
- {traceable-agent-1.2.3 → traceable-agent-1.3.1/src/traceable_agent.egg-info}/PKG-INFO +9 -5
- {traceable-agent-1.2.3 → traceable-agent-1.3.1}/src/traceable_agent.egg-info/requires.txt +1 -1
- {traceable-agent-1.2.3 → traceable-agent-1.3.1}/src/traceableai/config/config.py +11 -1
- {traceable-agent-1.2.3 → traceable-agent-1.3.1}/src/traceableai/config/default.py +9 -8
- {traceable-agent-1.2.3 → traceable-agent-1.3.1}/src/traceableai/config/environment.py +17 -7
- {traceable-agent-1.2.3 → traceable-agent-1.3.1}/src/traceableai/config/traceable_config_pb2.py +170 -14
- {traceable-agent-1.2.3 → traceable-agent-1.3.1}/src/traceableai/config_wrapper.py +15 -11
- {traceable-agent-1.2.3 → traceable-agent-1.3.1}/src/traceableai/filter/traceable.py +88 -66
- {traceable-agent-1.2.3 → traceable-agent-1.3.1}/src/traceableai/version.py +1 -1
- {traceable-agent-1.2.3 → traceable-agent-1.3.1}/MANIFEST.in +0 -0
- {traceable-agent-1.2.3 → traceable-agent-1.3.1}/pyproject.toml +0 -0
- {traceable-agent-1.2.3 → traceable-agent-1.3.1}/setup.cfg +0 -0
- {traceable-agent-1.2.3 → traceable-agent-1.3.1}/src/traceable_agent.egg-info/SOURCES.txt +0 -0
- {traceable-agent-1.2.3 → traceable-agent-1.3.1}/src/traceable_agent.egg-info/dependency_links.txt +0 -0
- {traceable-agent-1.2.3 → traceable-agent-1.3.1}/src/traceable_agent.egg-info/entry_points.txt +0 -0
- {traceable-agent-1.2.3 → traceable-agent-1.3.1}/src/traceable_agent.egg-info/top_level.txt +0 -0
- {traceable-agent-1.2.3 → traceable-agent-1.3.1}/src/traceableai/__init__.py +0 -0
- {traceable-agent-1.2.3 → traceable-agent-1.3.1}/src/traceableai/agent.py +0 -0
- {traceable-agent-1.2.3 → traceable-agent-1.3.1}/src/traceableai/autoinstrumentation/__init__.py +0 -0
- {traceable-agent-1.2.3 → traceable-agent-1.3.1}/src/traceableai/autoinstrumentation/sitecustomize.py +0 -0
- {traceable-agent-1.2.3 → traceable-agent-1.3.1}/src/traceableai/autoinstrumentation/wrapper.py +0 -0
- {traceable-agent-1.2.3 → traceable-agent-1.3.1}/src/traceableai/config/__init__.py +0 -0
- {traceable-agent-1.2.3 → traceable-agent-1.3.1}/src/traceableai/filter/__init__.py +0 -0
- {traceable-agent-1.2.3 → traceable-agent-1.3.1}/src/traceableai/hypertrace_env_override.py +0 -0
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: traceable-agent
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.1
|
|
4
4
|
Summary: Traceable.ai Python Agent
|
|
5
5
|
Home-page: https://traceable.ai
|
|
6
6
|
Author: Traceable.ai
|
|
7
7
|
Classifier: Programming Language :: Python :: 3
|
|
8
8
|
Classifier: Operating System :: OS Independent
|
|
9
|
-
Requires-Python: >=3.
|
|
9
|
+
Requires-Python: >=3.7
|
|
10
10
|
Description-Content-Type: text/markdown
|
|
11
|
+
Requires-Dist: hypertrace-agent==0.15.1
|
|
12
|
+
Requires-Dist: psutil
|
|
13
|
+
Requires-Dist: distro==1.6.0
|
|
14
|
+
Requires-Dist: cffi
|
|
11
15
|
|
|
12
16
|
# Python Agent
|
|
13
17
|
|
|
14
18
|
### Usage
|
|
15
|
-
Python traceable agent requires Python >= 3.
|
|
19
|
+
Python traceable agent requires Python >= 3.7
|
|
16
20
|
|
|
17
21
|
Additionally, to use the traceable filter, you must be on a supported OS.
|
|
18
22
|
- Ubuntu 18.04+
|
|
@@ -46,7 +50,7 @@ agent.add_traceable_filter() # add the traceable filter to enable blocking
|
|
|
46
50
|
# Create a virtual env & install dependencies
|
|
47
51
|
python3 -m venv venv
|
|
48
52
|
source venv/bin/activate
|
|
49
|
-
pip install -r requirements.txt -r dev-requirements
|
|
53
|
+
pip install -r requirements.txt -r dev-requirements.txt
|
|
50
54
|
```
|
|
51
55
|
|
|
52
56
|
_Note: if you run into an error installing grpc:_
|
|
@@ -86,7 +90,7 @@ git submodule update --init --recursive
|
|
|
86
90
|
```
|
|
87
91
|
1. Build and run test in docker.
|
|
88
92
|
```
|
|
89
|
-
docker build
|
|
93
|
+
docker build -f docker/test_apps/unittest.Dockerfile -t pythonunittest .
|
|
90
94
|
docker run --rm pythonunittest
|
|
91
95
|
```
|
|
92
96
|
- Test applications
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Python Agent
|
|
2
2
|
|
|
3
3
|
### Usage
|
|
4
|
-
Python traceable agent requires Python >= 3.
|
|
4
|
+
Python traceable agent requires Python >= 3.7
|
|
5
5
|
|
|
6
6
|
Additionally, to use the traceable filter, you must be on a supported OS.
|
|
7
7
|
- Ubuntu 18.04+
|
|
@@ -35,7 +35,7 @@ agent.add_traceable_filter() # add the traceable filter to enable blocking
|
|
|
35
35
|
# Create a virtual env & install dependencies
|
|
36
36
|
python3 -m venv venv
|
|
37
37
|
source venv/bin/activate
|
|
38
|
-
pip install -r requirements.txt -r dev-requirements
|
|
38
|
+
pip install -r requirements.txt -r dev-requirements.txt
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
_Note: if you run into an error installing grpc:_
|
|
@@ -75,7 +75,7 @@ git submodule update --init --recursive
|
|
|
75
75
|
```
|
|
76
76
|
1. Build and run test in docker.
|
|
77
77
|
```
|
|
78
|
-
docker build
|
|
78
|
+
docker build -f docker/test_apps/unittest.Dockerfile -t pythonunittest .
|
|
79
79
|
docker run --rm pythonunittest
|
|
80
80
|
```
|
|
81
81
|
- Test applications
|
|
@@ -20,7 +20,7 @@ setup(
|
|
|
20
20
|
package_dir={"": "src"},
|
|
21
21
|
packages=find_packages(where="src"),
|
|
22
22
|
include_package_data=True,
|
|
23
|
-
python_requires=">=3.
|
|
23
|
+
python_requires=">=3.7",
|
|
24
24
|
ext_modules=[ # this option will let wheel builder know to package c extensions when ran from CI. No effect for source tar installs
|
|
25
25
|
Extension(
|
|
26
26
|
name='traceableai.filter._libtraceable',
|
|
@@ -29,7 +29,7 @@ setup(
|
|
|
29
29
|
)
|
|
30
30
|
],
|
|
31
31
|
install_requires=[
|
|
32
|
-
"hypertrace-agent==0.
|
|
32
|
+
"hypertrace-agent==0.15.1",
|
|
33
33
|
"psutil",
|
|
34
34
|
"distro==1.6.0",
|
|
35
35
|
"cffi",
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: traceable-agent
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.1
|
|
4
4
|
Summary: Traceable.ai Python Agent
|
|
5
5
|
Home-page: https://traceable.ai
|
|
6
6
|
Author: Traceable.ai
|
|
7
7
|
Classifier: Programming Language :: Python :: 3
|
|
8
8
|
Classifier: Operating System :: OS Independent
|
|
9
|
-
Requires-Python: >=3.
|
|
9
|
+
Requires-Python: >=3.7
|
|
10
10
|
Description-Content-Type: text/markdown
|
|
11
|
+
Requires-Dist: hypertrace-agent==0.15.1
|
|
12
|
+
Requires-Dist: psutil
|
|
13
|
+
Requires-Dist: distro==1.6.0
|
|
14
|
+
Requires-Dist: cffi
|
|
11
15
|
|
|
12
16
|
# Python Agent
|
|
13
17
|
|
|
14
18
|
### Usage
|
|
15
|
-
Python traceable agent requires Python >= 3.
|
|
19
|
+
Python traceable agent requires Python >= 3.7
|
|
16
20
|
|
|
17
21
|
Additionally, to use the traceable filter, you must be on a supported OS.
|
|
18
22
|
- Ubuntu 18.04+
|
|
@@ -46,7 +50,7 @@ agent.add_traceable_filter() # add the traceable filter to enable blocking
|
|
|
46
50
|
# Create a virtual env & install dependencies
|
|
47
51
|
python3 -m venv venv
|
|
48
52
|
source venv/bin/activate
|
|
49
|
-
pip install -r requirements.txt -r dev-requirements
|
|
53
|
+
pip install -r requirements.txt -r dev-requirements.txt
|
|
50
54
|
```
|
|
51
55
|
|
|
52
56
|
_Note: if you run into an error installing grpc:_
|
|
@@ -86,7 +90,7 @@ git submodule update --init --recursive
|
|
|
86
90
|
```
|
|
87
91
|
1. Build and run test in docker.
|
|
88
92
|
```
|
|
89
|
-
docker build
|
|
93
|
+
docker build -f docker/test_apps/unittest.Dockerfile -t pythonunittest .
|
|
90
94
|
docker run --rm pythonunittest
|
|
91
95
|
```
|
|
92
96
|
- Test applications
|
|
@@ -13,6 +13,9 @@ from traceableai.config.default import DEFAULT
|
|
|
13
13
|
from traceableai.config.environment import overwrite_with_environment
|
|
14
14
|
logger = logging.getLogger(__name__)
|
|
15
15
|
|
|
16
|
+
REMOTE_CONFIG_KEY = 'remote_config'
|
|
17
|
+
BLOCKING_CONFIG_KEY = 'blocking_config'
|
|
18
|
+
|
|
16
19
|
class Config(): # pylint:disable=R0903
|
|
17
20
|
def __new__(cls):
|
|
18
21
|
if not hasattr(cls, 'instance'):
|
|
@@ -61,7 +64,14 @@ def read_from_file():
|
|
|
61
64
|
|
|
62
65
|
with open(config_path, 'r') as config_file:
|
|
63
66
|
try:
|
|
64
|
-
|
|
67
|
+
file_dict = yaml.safe_load(config_file)
|
|
68
|
+
# setting the new remote config with deprecated one if the new one doesn't exist
|
|
69
|
+
if REMOTE_CONFIG_KEY not in file_dict and BLOCKING_CONFIG_KEY in file_dict and \
|
|
70
|
+
REMOTE_CONFIG_KEY in file_dict[BLOCKING_CONFIG_KEY]:
|
|
71
|
+
file_dict[REMOTE_CONFIG_KEY] = file_dict[BLOCKING_CONFIG_KEY][REMOTE_CONFIG_KEY]
|
|
72
|
+
del file_dict[BLOCKING_CONFIG_KEY][REMOTE_CONFIG_KEY]
|
|
73
|
+
|
|
74
|
+
return file_dict
|
|
65
75
|
except yaml.YAMLError as exc:
|
|
66
76
|
logger.debug(exc)
|
|
67
77
|
return None
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
DEFAULT = {
|
|
2
2
|
'opa': {
|
|
3
|
-
'enabled':
|
|
3
|
+
'enabled': False,
|
|
4
4
|
'endpoint': 'http://localhost:8181',
|
|
5
|
-
'poll_period_seconds': 30
|
|
5
|
+
'poll_period_seconds': 30,
|
|
6
6
|
},
|
|
7
7
|
'blocking_config': {
|
|
8
|
-
'enabled':
|
|
8
|
+
'enabled': True,
|
|
9
9
|
'debug_log': False,
|
|
10
10
|
'evaluate_body': True,
|
|
11
11
|
'modsecurity': {
|
|
@@ -15,10 +15,11 @@ DEFAULT = {
|
|
|
15
15
|
'regionBlocking': {
|
|
16
16
|
'enabled': True
|
|
17
17
|
},
|
|
18
|
-
'
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
'max_recursion_depth': 20
|
|
19
|
+
},
|
|
20
|
+
'remote_config': {
|
|
21
|
+
'enabled': True,
|
|
22
|
+
'endpoint': 'localhost:5441',
|
|
23
|
+
'poll_period_seconds': 30,
|
|
23
24
|
}
|
|
24
25
|
}
|
|
@@ -5,7 +5,7 @@ def _is_true(env_key):
|
|
|
5
5
|
return value.lower() == 'true'
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
def overwrite_with_environment(config):
|
|
8
|
+
def overwrite_with_environment(config): # pylint: disable=R0912,too-many-branches
|
|
9
9
|
if "TA_BLOCKING_CONFIG_ENABLED" in os.environ:
|
|
10
10
|
config.blocking_config.enabled.value = _is_true("TA_BLOCKING_CONFIG_ENABLED")
|
|
11
11
|
|
|
@@ -21,14 +21,24 @@ def overwrite_with_environment(config):
|
|
|
21
21
|
if "TA_BLOCKING_CONFIG_REGION_BLOCKING_ENABLED" in os.environ:
|
|
22
22
|
config.blocking_config.region_blocking.enabled.value = _is_true("TA_BLOCKING_CONFIG_REGION_BLOCKING_ENABLED")
|
|
23
23
|
|
|
24
|
-
if "
|
|
25
|
-
config.blocking_config.
|
|
24
|
+
if "TA_BLOCKING_CONFIG_MAX_RECURSION_DEPTH" in os.environ:
|
|
25
|
+
config.blocking_config.max_recursion_depth.value = int(os.environ["TA_BLOCKING_CONFIG_MAX_RECURSION_DEPTH"])
|
|
26
26
|
|
|
27
|
-
if "
|
|
28
|
-
config.
|
|
27
|
+
if "TA_REMOTE_CONFIG_ENABLED" in os.environ:
|
|
28
|
+
config.remote_config.enabled.value = _is_true("TA_REMOTE_CONFIG_ENABLED")
|
|
29
|
+
elif "TA_BLOCKING_CONFIG_REMOTE_CONFIG_ENABLED" in os.environ:
|
|
30
|
+
config.remote_config.enabled.value = _is_true("TA_BLOCKING_CONFIG_REMOTE_CONFIG_ENABLED")
|
|
29
31
|
|
|
30
|
-
if "
|
|
31
|
-
config.
|
|
32
|
+
if "TA_REMOTE_CONFIG_ENDPOINT" in os.environ:
|
|
33
|
+
config.remote_config.endpoint.value = os.environ["TA_REMOTE_CONFIG_ENDPOINT"]
|
|
34
|
+
elif "TA_BLOCKING_CONFIG_REMOTE_CONFIG_ENDPOINT" in os.environ:
|
|
35
|
+
config.remote_config.endpoint.value = os.environ["TA_BLOCKING_CONFIG_REMOTE_CONFIG_ENDPOINT"]
|
|
36
|
+
|
|
37
|
+
if "TA_REMOTE_CONFIG_POLL_PERIOD_SECONDS" in os.environ:
|
|
38
|
+
config.remote_config.poll_period_seconds.value = \
|
|
39
|
+
int(os.environ["TA_REMOTE_CONFIG_POLL_PERIOD_SECONDS"])
|
|
40
|
+
elif "TA_BLOCKING_CONFIG_REMOTE_CONFIG_POLL_PERIOD_SECONDS" in os.environ:
|
|
41
|
+
config.remote_config.poll_period_seconds.value = \
|
|
32
42
|
int(os.environ["TA_BLOCKING_CONFIG_REMOTE_CONFIG_POLL_PERIOD_SECONDS"])
|
|
33
43
|
|
|
34
44
|
if "TA_BLOCKING_CONFIG_SKIP_INTERNAL_REQUEST" in os.environ:
|
{traceable-agent-1.2.3 → traceable-agent-1.3.1}/src/traceableai/config/traceable_config_pb2.py
RENAMED
|
@@ -20,7 +20,7 @@ DESCRIPTOR = _descriptor.FileDescriptor(
|
|
|
20
20
|
syntax='proto3',
|
|
21
21
|
serialized_options=b'Z-github.com/Traceableai/agent-config/gen/go/v1',
|
|
22
22
|
create_key=_descriptor._internal_create_key,
|
|
23
|
-
serialized_pb=b'\n\x16traceable_config.proto\x12\x1c\x61i.traceable.agent.config.v1\x1a\x1egoogle/protobuf/wrappers.proto\"\
|
|
23
|
+
serialized_pb=b'\n\x16traceable_config.proto\x12\x1c\x61i.traceable.agent.config.v1\x1a\x1egoogle/protobuf/wrappers.proto\"\xff\x02\n\x0b\x41gentConfig\x12.\n\x03opa\x18\x01 \x01(\x0b\x32!.ai.traceable.agent.config.v1.Opa\x12\x45\n\x0f\x62locking_config\x18\x02 \x01(\x0b\x32,.ai.traceable.agent.config.v1.BlockingConfig\x12-\n\tdebug_log\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.BoolValue\x12\x41\n\rremote_config\x18\x04 \x01(\x0b\x32*.ai.traceable.agent.config.v1.RemoteConfig\x12G\n\rapi_discovery\x18\x05 \x01(\x0b\x32\x30.ai.traceable.agent.config.v1.ApiDiscoveryConfig\x12>\n\x08sampling\x18\x06 \x01(\x0b\x32,.ai.traceable.agent.config.v1.SamplingConfig\"\x88\x02\n\x03Opa\x12+\n\x07\x65nabled\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.BoolValue\x12.\n\x08\x65ndpoint\x18\x02 \x01(\x0b\x32\x1c.google.protobuf.StringValue\x12\x38\n\x13poll_period_seconds\x18\x03 \x01(\x0b\x32\x1b.google.protobuf.Int32Value\x12/\n\tcert_file\x18\x04 \x01(\x0b\x32\x1c.google.protobuf.StringValue\x12\x39\n\x15use_secure_connection\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.BoolValue\"\xad\x04\n\x0e\x42lockingConfig\x12+\n\x07\x65nabled\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.BoolValue\x12\x31\n\tdebug_log\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.BoolValueB\x02\x18\x01\x12\x44\n\x0bmodsecurity\x18\x03 \x01(\x0b\x32/.ai.traceable.agent.config.v1.ModsecurityConfig\x12\x31\n\revaluate_body\x18\x04 \x01(\x0b\x32\x1a.google.protobuf.BoolValue\x12K\n\x0fregion_blocking\x18\x05 \x01(\x0b\x32\x32.ai.traceable.agent.config.v1.RegionBlockingConfig\x12\x45\n\rremote_config\x18\x06 \x01(\x0b\x32*.ai.traceable.agent.config.v1.RemoteConfigB\x02\x18\x01\x12\x39\n\x15skip_internal_request\x18\x07 \x01(\x0b\x32\x1a.google.protobuf.BoolValue\x12\x39\n\x14response_status_code\x18\x08 \x01(\x0b\x32\x1b.google.protobuf.Int32Value\x12\x38\n\x13max_recursion_depth\x18\t \x01(\x0b\x32\x1b.google.protobuf.Int32Value\"@\n\x11ModsecurityConfig\x12+\n\x07\x65nabled\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.BoolValue\"C\n\x14RegionBlockingConfig\x12+\n\x07\x65nabled\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.BoolValue\"\xd3\x02\n\x0cRemoteConfig\x12+\n\x07\x65nabled\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.BoolValue\x12.\n\x08\x65ndpoint\x18\x02 \x01(\x0b\x32\x1c.google.protobuf.StringValue\x12\x38\n\x13poll_period_seconds\x18\x03 \x01(\x0b\x32\x1b.google.protobuf.Int32Value\x12/\n\tcert_file\x18\x04 \x01(\x0b\x32\x1c.google.protobuf.StringValue\x12@\n\x1bgrpc_max_call_recv_msg_size\x18\x05 \x01(\x0b\x32\x1b.google.protobuf.Int32Value\x12\x39\n\x15use_secure_connection\x18\x06 \x01(\x0b\x32\x1a.google.protobuf.BoolValue\"A\n\x12\x41piDiscoveryConfig\x12+\n\x07\x65nabled\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.BoolValue\"=\n\x0eSamplingConfig\x12+\n\x07\x65nabled\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.BoolValueB/Z-github.com/Traceableai/agent-config/gen/go/v1b\x06proto3'
|
|
24
24
|
,
|
|
25
25
|
dependencies=[google_dot_protobuf_dot_wrappers__pb2.DESCRIPTOR,])
|
|
26
26
|
|
|
@@ -49,6 +49,34 @@ _AGENTCONFIG = _descriptor.Descriptor(
|
|
|
49
49
|
message_type=None, enum_type=None, containing_type=None,
|
|
50
50
|
is_extension=False, extension_scope=None,
|
|
51
51
|
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
|
52
|
+
_descriptor.FieldDescriptor(
|
|
53
|
+
name='debug_log', full_name='ai.traceable.agent.config.v1.AgentConfig.debug_log', index=2,
|
|
54
|
+
number=3, type=11, cpp_type=10, label=1,
|
|
55
|
+
has_default_value=False, default_value=None,
|
|
56
|
+
message_type=None, enum_type=None, containing_type=None,
|
|
57
|
+
is_extension=False, extension_scope=None,
|
|
58
|
+
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
|
59
|
+
_descriptor.FieldDescriptor(
|
|
60
|
+
name='remote_config', full_name='ai.traceable.agent.config.v1.AgentConfig.remote_config', index=3,
|
|
61
|
+
number=4, type=11, cpp_type=10, label=1,
|
|
62
|
+
has_default_value=False, default_value=None,
|
|
63
|
+
message_type=None, enum_type=None, containing_type=None,
|
|
64
|
+
is_extension=False, extension_scope=None,
|
|
65
|
+
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
|
66
|
+
_descriptor.FieldDescriptor(
|
|
67
|
+
name='api_discovery', full_name='ai.traceable.agent.config.v1.AgentConfig.api_discovery', index=4,
|
|
68
|
+
number=5, type=11, cpp_type=10, label=1,
|
|
69
|
+
has_default_value=False, default_value=None,
|
|
70
|
+
message_type=None, enum_type=None, containing_type=None,
|
|
71
|
+
is_extension=False, extension_scope=None,
|
|
72
|
+
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
|
73
|
+
_descriptor.FieldDescriptor(
|
|
74
|
+
name='sampling', full_name='ai.traceable.agent.config.v1.AgentConfig.sampling', index=5,
|
|
75
|
+
number=6, type=11, cpp_type=10, label=1,
|
|
76
|
+
has_default_value=False, default_value=None,
|
|
77
|
+
message_type=None, enum_type=None, containing_type=None,
|
|
78
|
+
is_extension=False, extension_scope=None,
|
|
79
|
+
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
|
52
80
|
],
|
|
53
81
|
extensions=[
|
|
54
82
|
],
|
|
@@ -62,7 +90,7 @@ _AGENTCONFIG = _descriptor.Descriptor(
|
|
|
62
90
|
oneofs=[
|
|
63
91
|
],
|
|
64
92
|
serialized_start=89,
|
|
65
|
-
serialized_end=
|
|
93
|
+
serialized_end=472,
|
|
66
94
|
)
|
|
67
95
|
|
|
68
96
|
|
|
@@ -102,6 +130,13 @@ _OPA = _descriptor.Descriptor(
|
|
|
102
130
|
message_type=None, enum_type=None, containing_type=None,
|
|
103
131
|
is_extension=False, extension_scope=None,
|
|
104
132
|
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
|
133
|
+
_descriptor.FieldDescriptor(
|
|
134
|
+
name='use_secure_connection', full_name='ai.traceable.agent.config.v1.Opa.use_secure_connection', index=4,
|
|
135
|
+
number=5, type=11, cpp_type=10, label=1,
|
|
136
|
+
has_default_value=False, default_value=None,
|
|
137
|
+
message_type=None, enum_type=None, containing_type=None,
|
|
138
|
+
is_extension=False, extension_scope=None,
|
|
139
|
+
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
|
105
140
|
],
|
|
106
141
|
extensions=[
|
|
107
142
|
],
|
|
@@ -114,8 +149,8 @@ _OPA = _descriptor.Descriptor(
|
|
|
114
149
|
extension_ranges=[],
|
|
115
150
|
oneofs=[
|
|
116
151
|
],
|
|
117
|
-
serialized_start=
|
|
118
|
-
serialized_end=
|
|
152
|
+
serialized_start=475,
|
|
153
|
+
serialized_end=739,
|
|
119
154
|
)
|
|
120
155
|
|
|
121
156
|
|
|
@@ -140,7 +175,7 @@ _BLOCKINGCONFIG = _descriptor.Descriptor(
|
|
|
140
175
|
has_default_value=False, default_value=None,
|
|
141
176
|
message_type=None, enum_type=None, containing_type=None,
|
|
142
177
|
is_extension=False, extension_scope=None,
|
|
143
|
-
serialized_options=
|
|
178
|
+
serialized_options=b'\030\001', file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
|
144
179
|
_descriptor.FieldDescriptor(
|
|
145
180
|
name='modsecurity', full_name='ai.traceable.agent.config.v1.BlockingConfig.modsecurity', index=2,
|
|
146
181
|
number=3, type=11, cpp_type=10, label=1,
|
|
@@ -168,7 +203,7 @@ _BLOCKINGCONFIG = _descriptor.Descriptor(
|
|
|
168
203
|
has_default_value=False, default_value=None,
|
|
169
204
|
message_type=None, enum_type=None, containing_type=None,
|
|
170
205
|
is_extension=False, extension_scope=None,
|
|
171
|
-
serialized_options=
|
|
206
|
+
serialized_options=b'\030\001', file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
|
172
207
|
_descriptor.FieldDescriptor(
|
|
173
208
|
name='skip_internal_request', full_name='ai.traceable.agent.config.v1.BlockingConfig.skip_internal_request', index=6,
|
|
174
209
|
number=7, type=11, cpp_type=10, label=1,
|
|
@@ -176,6 +211,20 @@ _BLOCKINGCONFIG = _descriptor.Descriptor(
|
|
|
176
211
|
message_type=None, enum_type=None, containing_type=None,
|
|
177
212
|
is_extension=False, extension_scope=None,
|
|
178
213
|
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
|
214
|
+
_descriptor.FieldDescriptor(
|
|
215
|
+
name='response_status_code', full_name='ai.traceable.agent.config.v1.BlockingConfig.response_status_code', index=7,
|
|
216
|
+
number=8, type=11, cpp_type=10, label=1,
|
|
217
|
+
has_default_value=False, default_value=None,
|
|
218
|
+
message_type=None, enum_type=None, containing_type=None,
|
|
219
|
+
is_extension=False, extension_scope=None,
|
|
220
|
+
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
|
221
|
+
_descriptor.FieldDescriptor(
|
|
222
|
+
name='max_recursion_depth', full_name='ai.traceable.agent.config.v1.BlockingConfig.max_recursion_depth', index=8,
|
|
223
|
+
number=9, type=11, cpp_type=10, label=1,
|
|
224
|
+
has_default_value=False, default_value=None,
|
|
225
|
+
message_type=None, enum_type=None, containing_type=None,
|
|
226
|
+
is_extension=False, extension_scope=None,
|
|
227
|
+
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
|
179
228
|
],
|
|
180
229
|
extensions=[
|
|
181
230
|
],
|
|
@@ -188,8 +237,8 @@ _BLOCKINGCONFIG = _descriptor.Descriptor(
|
|
|
188
237
|
extension_ranges=[],
|
|
189
238
|
oneofs=[
|
|
190
239
|
],
|
|
191
|
-
serialized_start=
|
|
192
|
-
serialized_end=
|
|
240
|
+
serialized_start=742,
|
|
241
|
+
serialized_end=1299,
|
|
193
242
|
)
|
|
194
243
|
|
|
195
244
|
|
|
@@ -220,8 +269,8 @@ _MODSECURITYCONFIG = _descriptor.Descriptor(
|
|
|
220
269
|
extension_ranges=[],
|
|
221
270
|
oneofs=[
|
|
222
271
|
],
|
|
223
|
-
serialized_start=
|
|
224
|
-
serialized_end=
|
|
272
|
+
serialized_start=1301,
|
|
273
|
+
serialized_end=1365,
|
|
225
274
|
)
|
|
226
275
|
|
|
227
276
|
|
|
@@ -252,8 +301,8 @@ _REGIONBLOCKINGCONFIG = _descriptor.Descriptor(
|
|
|
252
301
|
extension_ranges=[],
|
|
253
302
|
oneofs=[
|
|
254
303
|
],
|
|
255
|
-
serialized_start=
|
|
256
|
-
serialized_end=
|
|
304
|
+
serialized_start=1367,
|
|
305
|
+
serialized_end=1434,
|
|
257
306
|
)
|
|
258
307
|
|
|
259
308
|
|
|
@@ -293,6 +342,84 @@ _REMOTECONFIG = _descriptor.Descriptor(
|
|
|
293
342
|
message_type=None, enum_type=None, containing_type=None,
|
|
294
343
|
is_extension=False, extension_scope=None,
|
|
295
344
|
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
|
345
|
+
_descriptor.FieldDescriptor(
|
|
346
|
+
name='grpc_max_call_recv_msg_size', full_name='ai.traceable.agent.config.v1.RemoteConfig.grpc_max_call_recv_msg_size', index=4,
|
|
347
|
+
number=5, type=11, cpp_type=10, label=1,
|
|
348
|
+
has_default_value=False, default_value=None,
|
|
349
|
+
message_type=None, enum_type=None, containing_type=None,
|
|
350
|
+
is_extension=False, extension_scope=None,
|
|
351
|
+
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
|
352
|
+
_descriptor.FieldDescriptor(
|
|
353
|
+
name='use_secure_connection', full_name='ai.traceable.agent.config.v1.RemoteConfig.use_secure_connection', index=5,
|
|
354
|
+
number=6, type=11, cpp_type=10, label=1,
|
|
355
|
+
has_default_value=False, default_value=None,
|
|
356
|
+
message_type=None, enum_type=None, containing_type=None,
|
|
357
|
+
is_extension=False, extension_scope=None,
|
|
358
|
+
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
|
359
|
+
],
|
|
360
|
+
extensions=[
|
|
361
|
+
],
|
|
362
|
+
nested_types=[],
|
|
363
|
+
enum_types=[
|
|
364
|
+
],
|
|
365
|
+
serialized_options=None,
|
|
366
|
+
is_extendable=False,
|
|
367
|
+
syntax='proto3',
|
|
368
|
+
extension_ranges=[],
|
|
369
|
+
oneofs=[
|
|
370
|
+
],
|
|
371
|
+
serialized_start=1437,
|
|
372
|
+
serialized_end=1776,
|
|
373
|
+
)
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
_APIDISCOVERYCONFIG = _descriptor.Descriptor(
|
|
377
|
+
name='ApiDiscoveryConfig',
|
|
378
|
+
full_name='ai.traceable.agent.config.v1.ApiDiscoveryConfig',
|
|
379
|
+
filename=None,
|
|
380
|
+
file=DESCRIPTOR,
|
|
381
|
+
containing_type=None,
|
|
382
|
+
create_key=_descriptor._internal_create_key,
|
|
383
|
+
fields=[
|
|
384
|
+
_descriptor.FieldDescriptor(
|
|
385
|
+
name='enabled', full_name='ai.traceable.agent.config.v1.ApiDiscoveryConfig.enabled', index=0,
|
|
386
|
+
number=1, type=11, cpp_type=10, label=1,
|
|
387
|
+
has_default_value=False, default_value=None,
|
|
388
|
+
message_type=None, enum_type=None, containing_type=None,
|
|
389
|
+
is_extension=False, extension_scope=None,
|
|
390
|
+
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
|
391
|
+
],
|
|
392
|
+
extensions=[
|
|
393
|
+
],
|
|
394
|
+
nested_types=[],
|
|
395
|
+
enum_types=[
|
|
396
|
+
],
|
|
397
|
+
serialized_options=None,
|
|
398
|
+
is_extendable=False,
|
|
399
|
+
syntax='proto3',
|
|
400
|
+
extension_ranges=[],
|
|
401
|
+
oneofs=[
|
|
402
|
+
],
|
|
403
|
+
serialized_start=1778,
|
|
404
|
+
serialized_end=1843,
|
|
405
|
+
)
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
_SAMPLINGCONFIG = _descriptor.Descriptor(
|
|
409
|
+
name='SamplingConfig',
|
|
410
|
+
full_name='ai.traceable.agent.config.v1.SamplingConfig',
|
|
411
|
+
filename=None,
|
|
412
|
+
file=DESCRIPTOR,
|
|
413
|
+
containing_type=None,
|
|
414
|
+
create_key=_descriptor._internal_create_key,
|
|
415
|
+
fields=[
|
|
416
|
+
_descriptor.FieldDescriptor(
|
|
417
|
+
name='enabled', full_name='ai.traceable.agent.config.v1.SamplingConfig.enabled', index=0,
|
|
418
|
+
number=1, type=11, cpp_type=10, label=1,
|
|
419
|
+
has_default_value=False, default_value=None,
|
|
420
|
+
message_type=None, enum_type=None, containing_type=None,
|
|
421
|
+
is_extension=False, extension_scope=None,
|
|
422
|
+
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
|
296
423
|
],
|
|
297
424
|
extensions=[
|
|
298
425
|
],
|
|
@@ -305,16 +432,21 @@ _REMOTECONFIG = _descriptor.Descriptor(
|
|
|
305
432
|
extension_ranges=[],
|
|
306
433
|
oneofs=[
|
|
307
434
|
],
|
|
308
|
-
serialized_start=
|
|
309
|
-
serialized_end=
|
|
435
|
+
serialized_start=1845,
|
|
436
|
+
serialized_end=1906,
|
|
310
437
|
)
|
|
311
438
|
|
|
312
439
|
_AGENTCONFIG.fields_by_name['opa'].message_type = _OPA
|
|
313
440
|
_AGENTCONFIG.fields_by_name['blocking_config'].message_type = _BLOCKINGCONFIG
|
|
441
|
+
_AGENTCONFIG.fields_by_name['debug_log'].message_type = google_dot_protobuf_dot_wrappers__pb2._BOOLVALUE
|
|
442
|
+
_AGENTCONFIG.fields_by_name['remote_config'].message_type = _REMOTECONFIG
|
|
443
|
+
_AGENTCONFIG.fields_by_name['api_discovery'].message_type = _APIDISCOVERYCONFIG
|
|
444
|
+
_AGENTCONFIG.fields_by_name['sampling'].message_type = _SAMPLINGCONFIG
|
|
314
445
|
_OPA.fields_by_name['enabled'].message_type = google_dot_protobuf_dot_wrappers__pb2._BOOLVALUE
|
|
315
446
|
_OPA.fields_by_name['endpoint'].message_type = google_dot_protobuf_dot_wrappers__pb2._STRINGVALUE
|
|
316
447
|
_OPA.fields_by_name['poll_period_seconds'].message_type = google_dot_protobuf_dot_wrappers__pb2._INT32VALUE
|
|
317
448
|
_OPA.fields_by_name['cert_file'].message_type = google_dot_protobuf_dot_wrappers__pb2._STRINGVALUE
|
|
449
|
+
_OPA.fields_by_name['use_secure_connection'].message_type = google_dot_protobuf_dot_wrappers__pb2._BOOLVALUE
|
|
318
450
|
_BLOCKINGCONFIG.fields_by_name['enabled'].message_type = google_dot_protobuf_dot_wrappers__pb2._BOOLVALUE
|
|
319
451
|
_BLOCKINGCONFIG.fields_by_name['debug_log'].message_type = google_dot_protobuf_dot_wrappers__pb2._BOOLVALUE
|
|
320
452
|
_BLOCKINGCONFIG.fields_by_name['modsecurity'].message_type = _MODSECURITYCONFIG
|
|
@@ -322,18 +454,26 @@ _BLOCKINGCONFIG.fields_by_name['evaluate_body'].message_type = google_dot_protob
|
|
|
322
454
|
_BLOCKINGCONFIG.fields_by_name['region_blocking'].message_type = _REGIONBLOCKINGCONFIG
|
|
323
455
|
_BLOCKINGCONFIG.fields_by_name['remote_config'].message_type = _REMOTECONFIG
|
|
324
456
|
_BLOCKINGCONFIG.fields_by_name['skip_internal_request'].message_type = google_dot_protobuf_dot_wrappers__pb2._BOOLVALUE
|
|
457
|
+
_BLOCKINGCONFIG.fields_by_name['response_status_code'].message_type = google_dot_protobuf_dot_wrappers__pb2._INT32VALUE
|
|
458
|
+
_BLOCKINGCONFIG.fields_by_name['max_recursion_depth'].message_type = google_dot_protobuf_dot_wrappers__pb2._INT32VALUE
|
|
325
459
|
_MODSECURITYCONFIG.fields_by_name['enabled'].message_type = google_dot_protobuf_dot_wrappers__pb2._BOOLVALUE
|
|
326
460
|
_REGIONBLOCKINGCONFIG.fields_by_name['enabled'].message_type = google_dot_protobuf_dot_wrappers__pb2._BOOLVALUE
|
|
327
461
|
_REMOTECONFIG.fields_by_name['enabled'].message_type = google_dot_protobuf_dot_wrappers__pb2._BOOLVALUE
|
|
328
462
|
_REMOTECONFIG.fields_by_name['endpoint'].message_type = google_dot_protobuf_dot_wrappers__pb2._STRINGVALUE
|
|
329
463
|
_REMOTECONFIG.fields_by_name['poll_period_seconds'].message_type = google_dot_protobuf_dot_wrappers__pb2._INT32VALUE
|
|
330
464
|
_REMOTECONFIG.fields_by_name['cert_file'].message_type = google_dot_protobuf_dot_wrappers__pb2._STRINGVALUE
|
|
465
|
+
_REMOTECONFIG.fields_by_name['grpc_max_call_recv_msg_size'].message_type = google_dot_protobuf_dot_wrappers__pb2._INT32VALUE
|
|
466
|
+
_REMOTECONFIG.fields_by_name['use_secure_connection'].message_type = google_dot_protobuf_dot_wrappers__pb2._BOOLVALUE
|
|
467
|
+
_APIDISCOVERYCONFIG.fields_by_name['enabled'].message_type = google_dot_protobuf_dot_wrappers__pb2._BOOLVALUE
|
|
468
|
+
_SAMPLINGCONFIG.fields_by_name['enabled'].message_type = google_dot_protobuf_dot_wrappers__pb2._BOOLVALUE
|
|
331
469
|
DESCRIPTOR.message_types_by_name['AgentConfig'] = _AGENTCONFIG
|
|
332
470
|
DESCRIPTOR.message_types_by_name['Opa'] = _OPA
|
|
333
471
|
DESCRIPTOR.message_types_by_name['BlockingConfig'] = _BLOCKINGCONFIG
|
|
334
472
|
DESCRIPTOR.message_types_by_name['ModsecurityConfig'] = _MODSECURITYCONFIG
|
|
335
473
|
DESCRIPTOR.message_types_by_name['RegionBlockingConfig'] = _REGIONBLOCKINGCONFIG
|
|
336
474
|
DESCRIPTOR.message_types_by_name['RemoteConfig'] = _REMOTECONFIG
|
|
475
|
+
DESCRIPTOR.message_types_by_name['ApiDiscoveryConfig'] = _APIDISCOVERYCONFIG
|
|
476
|
+
DESCRIPTOR.message_types_by_name['SamplingConfig'] = _SAMPLINGCONFIG
|
|
337
477
|
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
|
|
338
478
|
|
|
339
479
|
AgentConfig = _reflection.GeneratedProtocolMessageType('AgentConfig', (_message.Message,), {
|
|
@@ -378,6 +518,22 @@ RemoteConfig = _reflection.GeneratedProtocolMessageType('RemoteConfig', (_messag
|
|
|
378
518
|
})
|
|
379
519
|
_sym_db.RegisterMessage(RemoteConfig)
|
|
380
520
|
|
|
521
|
+
ApiDiscoveryConfig = _reflection.GeneratedProtocolMessageType('ApiDiscoveryConfig', (_message.Message,), {
|
|
522
|
+
'DESCRIPTOR' : _APIDISCOVERYCONFIG,
|
|
523
|
+
'__module__' : 'traceable_config_pb2'
|
|
524
|
+
# @@protoc_insertion_point(class_scope:ai.traceable.agent.config.v1.ApiDiscoveryConfig)
|
|
525
|
+
})
|
|
526
|
+
_sym_db.RegisterMessage(ApiDiscoveryConfig)
|
|
527
|
+
|
|
528
|
+
SamplingConfig = _reflection.GeneratedProtocolMessageType('SamplingConfig', (_message.Message,), {
|
|
529
|
+
'DESCRIPTOR' : _SAMPLINGCONFIG,
|
|
530
|
+
'__module__' : 'traceable_config_pb2'
|
|
531
|
+
# @@protoc_insertion_point(class_scope:ai.traceable.agent.config.v1.SamplingConfig)
|
|
532
|
+
})
|
|
533
|
+
_sym_db.RegisterMessage(SamplingConfig)
|
|
534
|
+
|
|
381
535
|
|
|
382
536
|
DESCRIPTOR._options = None
|
|
537
|
+
_BLOCKINGCONFIG.fields_by_name['debug_log']._options = None
|
|
538
|
+
_BLOCKINGCONFIG.fields_by_name['remote_config']._options = None
|
|
383
539
|
# @@protoc_insertion_point(module_scope)
|
|
@@ -22,12 +22,15 @@ class ConfigWrapper: # pylint:disable=R0903
|
|
|
22
22
|
modified_config_dict["blocking_config"]["skip_internal_request"]
|
|
23
23
|
self.traceable.blocking_config.region_blocking.enabled.value = \
|
|
24
24
|
modified_config_dict["blocking_config"]["region_blocking"]["enabled"]
|
|
25
|
-
self.traceable.blocking_config.
|
|
26
|
-
modified_config_dict["blocking_config"]["
|
|
27
|
-
self.traceable.
|
|
28
|
-
modified_config_dict["
|
|
29
|
-
self.traceable.
|
|
30
|
-
modified_config_dict["
|
|
25
|
+
self.traceable.blocking_config.max_recursion_depth.value = \
|
|
26
|
+
modified_config_dict["blocking_config"]["max_recursion_depth"]
|
|
27
|
+
self.traceable.remote_config.enabled.value = \
|
|
28
|
+
modified_config_dict["remote_config"]["enabled"]
|
|
29
|
+
self.traceable.remote_config.endpoint.value =\
|
|
30
|
+
modified_config_dict["remote_config"]["endpoint"]
|
|
31
|
+
self.traceable.remote_config.poll_period_seconds.value = \
|
|
32
|
+
modified_config_dict["remote_config"]["poll_period_seconds"]
|
|
33
|
+
|
|
31
34
|
# opa
|
|
32
35
|
self.traceable.opa.enabled.value = modified_config_dict["opa"]["enabled"]
|
|
33
36
|
self.traceable.opa.endpoint.value = modified_config_dict["opa"]["endpoint"]
|
|
@@ -111,14 +114,15 @@ class ConfigWrapper: # pylint:disable=R0903
|
|
|
111
114
|
'modsecurity': {
|
|
112
115
|
'enabled': self.traceable.blocking_config.modsecurity.enabled.value,
|
|
113
116
|
},
|
|
117
|
+
'max_recursion_depth': self.traceable.blocking_config.max_recursion_depth.value,
|
|
114
118
|
'skip_internal_request': self.traceable.blocking_config.skip_internal_request.value,
|
|
115
119
|
'region_blocking': {
|
|
116
120
|
'enabled': self.traceable.blocking_config.region_blocking.enabled.value,
|
|
117
121
|
},
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
122
|
+
},
|
|
123
|
+
'remote_config': {
|
|
124
|
+
'enabled': self.traceable.remote_config.enabled.value,
|
|
125
|
+
'endpoint': self.traceable.remote_config.endpoint.value,
|
|
126
|
+
'poll_period_seconds': self.traceable.remote_config.poll_period_seconds.value,
|
|
123
127
|
}
|
|
124
128
|
}
|
|
@@ -6,6 +6,8 @@ from hypertrace.agent.filter.registry import TYPE_HTTP, TYPE_RPC
|
|
|
6
6
|
from opentelemetry.trace import Span
|
|
7
7
|
from traceableai.config.config import Config
|
|
8
8
|
from hypertrace.agent.custom_logger import get_custom_logger # pylint:disable=C0413,C0411,C0412
|
|
9
|
+
from hypertrace import agent # pylint:disable=C0413,C0411,C0412
|
|
10
|
+
|
|
9
11
|
|
|
10
12
|
logger = get_custom_logger(__name__)
|
|
11
13
|
|
|
@@ -23,7 +25,6 @@ except Exception as error: # pylint: disable=broad-except
|
|
|
23
25
|
logger.warning(
|
|
24
26
|
"error loading traceable extension - libtraceable filter disabled")
|
|
25
27
|
|
|
26
|
-
|
|
27
28
|
_HEADER_PREFIXES = {
|
|
28
29
|
TYPE_HTTP: 'http.request.header',
|
|
29
30
|
TYPE_RPC: 'rpc.request.metadata'
|
|
@@ -34,15 +35,83 @@ _BODY_PREFIXES = {
|
|
|
34
35
|
TYPE_RPC: 'rpc.request.body'
|
|
35
36
|
}
|
|
36
37
|
|
|
38
|
+
_URL_HEADERS = ['http.scheme', 'http.target', 'net.host.port', 'http.url']
|
|
39
|
+
|
|
40
|
+
|
|
37
41
|
|
|
38
42
|
class Traceable(hypertrace.agent.filter.Filter):
|
|
39
43
|
|
|
40
|
-
def __init__(self):
|
|
44
|
+
def __init__(self): # pylint:disable=R0914,R0915
|
|
41
45
|
if _LIBTRACEABLE_AVAILABLE:
|
|
42
|
-
|
|
46
|
+
agent_config = Config()
|
|
47
|
+
traceable_config = agent_config.config
|
|
48
|
+
should_debug = 0
|
|
49
|
+
if os.environ.get("TA_LOG_LEVEL", "").upper() == "DEBUG":
|
|
50
|
+
should_debug = 1
|
|
51
|
+
if traceable_config.blocking_config.debug_log.value is True:
|
|
52
|
+
should_debug = 1
|
|
53
|
+
|
|
54
|
+
libtraceable_config = _libtraceable.lib.init_libtraceable_config()
|
|
55
|
+
|
|
56
|
+
libtraceable_config.log_config.mode = should_debug
|
|
57
|
+
|
|
58
|
+
# If blocking is disabled we will never attempt to initialize the traceable filter
|
|
59
|
+
# so we can safely set to 1 here
|
|
60
|
+
libtraceable_config.blocking_config.enabled = 1
|
|
61
|
+
|
|
62
|
+
traceable_opa = traceable_config.opa
|
|
63
|
+
|
|
64
|
+
opa_server_url = _libtraceable.ffi.new(
|
|
65
|
+
"char[]", f"{traceable_opa.endpoint.value}".encode('ascii'))
|
|
66
|
+
opa_enabled = (0 if not traceable_opa.enabled.value is True else 1)
|
|
67
|
+
libtraceable_config.blocking_config.opa_config.enabled = opa_enabled
|
|
68
|
+
libtraceable_config.blocking_config.opa_config.opa_server_url = opa_server_url
|
|
69
|
+
libtraceable_config.blocking_config.opa_config.log_to_console = 1
|
|
70
|
+
libtraceable_config.blocking_config.opa_config.debug_log = should_debug
|
|
71
|
+
libtraceable_config.blocking_config.opa_config.min_delay = traceable_opa.poll_period_seconds.value
|
|
72
|
+
libtraceable_config.blocking_config.opa_config.max_delay = traceable_opa.poll_period_seconds.value
|
|
73
|
+
|
|
74
|
+
modsecurity_enabled = (
|
|
75
|
+
1 if traceable_config.blocking_config.modsecurity.enabled.value is True else 0)
|
|
76
|
+
|
|
77
|
+
libtraceable_config.blocking_config.modsecurity_config.enabled = modsecurity_enabled
|
|
78
|
+
|
|
79
|
+
rb_enabled = 1 if traceable_config.blocking_config.region_blocking.enabled.value is True else 0
|
|
80
|
+
libtraceable_config.blocking_config.rb_config.enabled = rb_enabled
|
|
81
|
+
|
|
82
|
+
libtraceable_config.blocking_config.evaluate_body = (
|
|
83
|
+
1 if traceable_config.blocking_config.evaluate_body.value is True else 0)
|
|
84
|
+
libtraceable_config.blocking_config.skip_internal_request = (
|
|
85
|
+
1 if traceable_config.blocking_config.skip_internal_request.value is True else 0) # pylint:disable=C0301
|
|
86
|
+
libtraceable_config.blocking_config.max_recursion_depth = \
|
|
87
|
+
traceable_config.blocking_config.max_recursion_depth.value
|
|
88
|
+
|
|
89
|
+
remote_config_enabled = (
|
|
90
|
+
1 if traceable_config.remote_config.enabled.value is True else 0)
|
|
91
|
+
libtraceable_config.remote_config.enabled = remote_config_enabled
|
|
92
|
+
|
|
93
|
+
cert_file = _libtraceable.ffi.new("char[]", "".encode('ascii'))
|
|
94
|
+
libtraceable_config.remote_config.cert_file = cert_file
|
|
95
|
+
|
|
96
|
+
remote_config_endpoint = (
|
|
97
|
+
traceable_config.remote_config.endpoint.value)
|
|
98
|
+
remote_url = _libtraceable.ffi.new(
|
|
99
|
+
"char[]", f"{remote_config_endpoint}".encode('ascii'))
|
|
100
|
+
libtraceable_config.remote_config.remote_endpoint = remote_url
|
|
101
|
+
|
|
102
|
+
remote_poll_period_seconds = (
|
|
103
|
+
traceable_config.remote_config.poll_period_seconds.value)
|
|
104
|
+
libtraceable_config.remote_config.poll_period_sec = remote_poll_period_seconds
|
|
105
|
+
|
|
106
|
+
ht_service_name = agent.Agent()._config.agent_config.service_name # pylint:disable=W0212
|
|
107
|
+
service_name = _libtraceable.ffi.new("char[]", f"{ht_service_name}".encode('ascii'))
|
|
108
|
+
libtraceable_config.agent_config.service_name = service_name
|
|
109
|
+
|
|
110
|
+
self.libtraceable_config = libtraceable_config
|
|
111
|
+
|
|
43
112
|
p_libtraceable = _libtraceable.ffi.new("traceable_libtraceable*")
|
|
44
113
|
result_code = _libtraceable.lib.traceable_new_libtraceable(
|
|
45
|
-
|
|
114
|
+
libtraceable_config, p_libtraceable)
|
|
46
115
|
self.libtraceable_available = (
|
|
47
116
|
result_code == _libtraceable.lib.TRACEABLE_SUCCESS)
|
|
48
117
|
if self.libtraceable_available:
|
|
@@ -151,7 +220,8 @@ def _add_span_attributes(span: Span, process_request_result):
|
|
|
151
220
|
|
|
152
221
|
def _add_header_and_span_attributes(span: Span, headers: dict, request_type) -> []:
|
|
153
222
|
pairs = []
|
|
154
|
-
|
|
223
|
+
attributes = span._readable_span().attributes # pylint:disable=W0212
|
|
224
|
+
ip_address = attributes.get('net.peer.ip')
|
|
155
225
|
if ip_address:
|
|
156
226
|
pairs.append((_libtraceable.ffi.new("char[]", b"net.peer.ip"),
|
|
157
227
|
_libtraceable.ffi.new("char[]", f"{ip_address}".encode('ascii'))))
|
|
@@ -161,67 +231,19 @@ def _add_header_and_span_attributes(span: Span, headers: dict, request_type) ->
|
|
|
161
231
|
pairs.append((_libtraceable.ffi.new("char[]", f"{header_prefix}.{header_key}".lower().encode('ascii')),
|
|
162
232
|
_libtraceable.ffi.new("char[]", f"{header_value}".encode('ascii'))))
|
|
163
233
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
if os.environ.get("TA_LOG_LEVEL", "").upper() == "DEBUG":
|
|
171
|
-
should_debug = 1
|
|
172
|
-
if traceable_config.blocking_config.debug_log.value is True:
|
|
173
|
-
should_debug = 1
|
|
174
|
-
|
|
175
|
-
libtraceable_config = _libtraceable.lib.init_libtraceable_config()
|
|
176
|
-
|
|
177
|
-
libtraceable_config.log_config.mode = should_debug
|
|
178
|
-
|
|
179
|
-
# If blocking is disabled we will never attempt to initialize the traceable filter
|
|
180
|
-
# so we can safely set to 1 here
|
|
181
|
-
libtraceable_config.blocking_config.enabled = 1
|
|
182
|
-
|
|
183
|
-
traceable_opa = traceable_config.opa
|
|
184
|
-
opa_server_url = _libtraceable.ffi.new(
|
|
185
|
-
"char[]", f"{traceable_opa.endpoint.value}".encode('ascii'))
|
|
234
|
+
# add url attributes so that libtraceable can construct the url if needed
|
|
235
|
+
for key in _URL_HEADERS:
|
|
236
|
+
value = attributes.get(key)
|
|
237
|
+
if value:
|
|
238
|
+
pairs.append((_libtraceable.ffi.new("char[]", f"{key}".encode('ascii')),
|
|
239
|
+
_libtraceable.ffi.new("char[]", f"{value}".encode('ascii'))))
|
|
186
240
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
libtraceable_config.blocking_config.opa_config.log_to_console = 1
|
|
191
|
-
libtraceable_config.blocking_config.opa_config.debug_log = should_debug
|
|
192
|
-
libtraceable_config.blocking_config.opa_config.min_delay = traceable_opa.poll_period_seconds.value
|
|
193
|
-
libtraceable_config.blocking_config.opa_config.max_delay = traceable_opa.poll_period_seconds.value
|
|
241
|
+
host = attributes.get('net.host.name')
|
|
242
|
+
if not host and 'host' in headers:
|
|
243
|
+
host = headers['host']
|
|
194
244
|
|
|
195
|
-
|
|
196
|
-
|
|
245
|
+
if host:
|
|
246
|
+
pairs.append((_libtraceable.ffi.new("char[]", b"net.host.name"),
|
|
247
|
+
_libtraceable.ffi.new("char[]", f"{host}".encode('ascii'))))
|
|
197
248
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
rb_enabled = 1 if traceable_config.blocking_config.region_blocking.enabled.value is True else 0
|
|
201
|
-
libtraceable_config.blocking_config.rb_config.enabled = rb_enabled
|
|
202
|
-
|
|
203
|
-
libtraceable_config.blocking_config.evaluate_body = (
|
|
204
|
-
1 if traceable_config.blocking_config.evaluate_body.value is True else 0)
|
|
205
|
-
libtraceable_config.blocking_config.skip_internal_request = (
|
|
206
|
-
1 if traceable_config.blocking_config.skip_internal_request.value is True else 0) # pylint:disable=C0301
|
|
207
|
-
|
|
208
|
-
remote_config_enabled = (
|
|
209
|
-
1 if traceable_config.blocking_config.remote_config.enabled.value is True else 0)
|
|
210
|
-
libtraceable_config.remote_config.enabled = remote_config_enabled
|
|
211
|
-
|
|
212
|
-
cert_file = _libtraceable.ffi.new("char[]", "".encode('ascii'))
|
|
213
|
-
libtraceable_config.remote_config.cert_file = cert_file
|
|
214
|
-
|
|
215
|
-
remote_config_endpoint = (
|
|
216
|
-
traceable_config.blocking_config.remote_config.endpoint.value)
|
|
217
|
-
remote_url = _libtraceable.ffi.new(
|
|
218
|
-
"char[]", f"{remote_config_endpoint}".encode('ascii'))
|
|
219
|
-
libtraceable_config.remote_config.remote_endpoint = remote_url
|
|
220
|
-
|
|
221
|
-
remote_poll_period_seconds = (
|
|
222
|
-
traceable_config.blocking_config.remote_config.poll_period_seconds.value)
|
|
223
|
-
libtraceable_config.remote_config.poll_period_sec = remote_poll_period_seconds
|
|
224
|
-
|
|
225
|
-
service_name = _libtraceable.ffi.new( "char[]", "".encode('ascii'))
|
|
226
|
-
libtraceable_config.agent_config.service_name = service_name
|
|
227
|
-
return libtraceable_config
|
|
249
|
+
return pairs
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{traceable-agent-1.2.3 → traceable-agent-1.3.1}/src/traceable_agent.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{traceable-agent-1.2.3 → traceable-agent-1.3.1}/src/traceable_agent.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{traceable-agent-1.2.3 → traceable-agent-1.3.1}/src/traceableai/autoinstrumentation/__init__.py
RENAMED
|
File without changes
|
{traceable-agent-1.2.3 → traceable-agent-1.3.1}/src/traceableai/autoinstrumentation/sitecustomize.py
RENAMED
|
File without changes
|
{traceable-agent-1.2.3 → traceable-agent-1.3.1}/src/traceableai/autoinstrumentation/wrapper.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|