Skip to content

Commit 6c86ea3

Browse files
authored
Merge branch 'yunkim/add-py-312' into munir/fix-telemetry-2.x
2 parents b8e4221 + 44a87f8 commit 6c86ea3

File tree

172 files changed

+2415
-1094
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+2415
-1094
lines changed

.riot/requirements/16b0e2d.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ mock==5.1.0
1515
opentracing==2.4.0
1616
packaging==23.1
1717
pluggy==1.3.0
18-
protobuf==4.23.4
1918
py-cpuinfo==8.0.0
2019
pytest==7.4.0
2120
pytest-asyncio==0.21.1

.riot/requirements/4ec2419.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This file is autogenerated by pip-compile with Python 3.12
33
# by the following command:
44
#
5-
# pip-compile --config=pyproject.toml --no-annotate .riot/requirements/fc4505d.in
5+
# pip-compile --no-annotate .riot/requirements/4ec2419.in
66
#
77
attrs==23.1.0
88
coverage[toml]==7.2.7

.riot/requirements/e70d73c.txt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22
# This file is autogenerated by pip-compile with Python 3.7
33
# by the following command:
44
#
5-
# pip-compile --config=pyproject.toml --no-annotate --resolver=backtracking .riot/requirements/e70d73c.in
5+
# pip-compile --no-annotate --resolver=backtracking .riot/requirements/e70d73c.in
66
#
77
attrs==23.1.0
8-
coverage[toml]==7.2.7
9-
exceptiongroup==1.1.3
8+
coverage[toml]==7.2.5
9+
exceptiongroup==1.1.1
1010
hypothesis==6.45.0
11-
importlib-metadata==6.7.0
11+
importlib-metadata==6.6.0
1212
iniconfig==2.0.0
13-
mock==5.1.0
13+
mock==5.0.2
1414
opentracing==2.4.0
1515
packaging==23.1
16-
pluggy==1.2.0
17-
pytest==7.4.1
18-
pytest-asyncio==0.21.1
19-
pytest-cov==4.1.0
20-
pytest-mock==3.11.1
16+
pluggy==1.0.0
17+
pytest==7.3.1
18+
pytest-asyncio==0.21.0
19+
pytest-cov==4.0.0
20+
pytest-mock==3.10.0
2121
sortedcontainers==2.4.0
2222
tomli==2.0.1
23-
typing-extensions==4.7.1
23+
typing-extensions==4.5.0
2424
zipp==3.15.0

benchmarks/appsec_iast_propagation/scenario.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
import bm
44

5+
from ddtrace.appsec.iast._taint_tracking import OriginType
6+
from ddtrace.appsec.iast._taint_tracking import Source
7+
from ddtrace.appsec.iast._taint_tracking import TaintRange
58
from ddtrace.appsec.iast._taint_tracking import contexts_reset
69
from ddtrace.appsec.iast._taint_tracking import create_context
7-
from ddtrace.appsec.iast._taint_tracking._native.taint_tracking import OriginType
8-
from ddtrace.appsec.iast._taint_tracking._native.taint_tracking import Source
9-
from ddtrace.appsec.iast._taint_tracking._native.taint_tracking import TaintRange
10-
from ddtrace.appsec.iast._taint_tracking._native.taint_tracking import set_ranges
10+
from ddtrace.appsec.iast._taint_tracking import set_ranges
1111
from ddtrace.appsec.iast._taint_tracking.aspects import add_aspect
1212
from ddtrace.appsec.iast._taint_tracking.aspects import join_aspect
1313

benchmarks/sampling_rule_matches/config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,25 @@ high_match:
33
num_iterations: 100
44
num_services: 1
55
num_operations: 1
6+
num_resources: 1
67

78
# Low number of variations, hit rate of about 25%
89
average_match:
910
num_iterations: 100
1011
num_services: 2
1112
num_operations: 2
13+
num_resources: 2
1214

1315
# High number of variations, hit rate of 0% or 1%
1416
low_match:
1517
num_iterations: 100
1618
num_services: 25
1719
num_operations: 25
20+
num_resources: 25
1821

1922
# This variation has performance issues due to the cache max size
2023
very_low_match:
2124
num_iterations: 1000
2225
num_services: 250
2326
num_operations: 100
27+
num_resources: 100

benchmarks/sampling_rule_matches/scenario.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,26 @@ class SamplingRules(bm.Scenario):
2727
num_iterations = bm.var(type=int)
2828
num_services = bm.var(type=int)
2929
num_operations = bm.var(type=int)
30+
num_resources = bm.var(type=int)
3031

3132
def run(self):
3233
# Generate random service and operation names for the counts we requested
3334
services = [rands() for _ in range(self.num_services)]
3435
operation_names = [rands() for _ in range(self.num_operations)]
36+
resource_names = [rands() for _ in range(self.num_resources)]
3537

3638
# Generate all possible permutations of service and operation names
37-
spans = [Span(service=service, name=name) for service, name in itertools.product(services, operation_names)]
39+
spans = [
40+
Span(service=service, name=name, resource=resource)
41+
for service, name, resource in itertools.product(services, operation_names, resource_names)
42+
]
3843

3944
# Create a single rule to use for all matches
4045
# Pick a random service/operation name
4146
rule = SamplingRule(
4247
service=random.choice(services),
4348
name=random.choice(operation_names),
49+
resource=random.choice(resource_names),
4450
sample_rate=1.0,
4551
)
4652

ddtrace/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@
4646
# a global tracer instance with integration settings
4747
tracer = Tracer()
4848

49+
50+
# The telemetry writer is not started until data is queued but this creates a
51+
# problem for CPython 3.12 which disallows thread creation at interpreter
52+
# finalization. In order to support 3.12, we start the writer upon initialization.
53+
# See https://github.com/python/cpython/pull/104826.
54+
if sys.version_info >= (3, 12):
55+
telemetry.telemetry_writer.enable()
56+
57+
4958
__all__ = [
5059
"patch",
5160
"patch_all",

ddtrace/appsec/_api_security/api_manager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class TooLargeSchemaException(Exception):
3737
class APIManager(Service):
3838
COLLECTED = [
3939
("REQUEST_HEADERS_NO_COOKIES", API_SECURITY.REQUEST_HEADERS_NO_COOKIES, dict),
40+
("REQUEST_COOKIES", API_SECURITY.REQUEST_COOKIES, dict),
4041
("REQUEST_QUERY", API_SECURITY.REQUEST_QUERY, dict),
4142
("REQUEST_PATH_PARAMS", API_SECURITY.REQUEST_PATH_PARAMS, dict),
4243
("REQUEST_BODY", API_SECURITY.REQUEST_BODY, None),

ddtrace/appsec/_api_security/preprocessors.json renamed to ddtrace/appsec/_api_security/processors.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
]
2929
}
3030
],
31-
"preprocessors": [
31+
"processors": [
3232
{
3333
"id": "preprocessor-001",
3434
"generator": "extract_schema",
@@ -67,6 +67,14 @@
6767
],
6868
"output": "_dd.appsec.s.req.headers"
6969
},
70+
{
71+
"inputs": [
72+
{
73+
"address": "server.request.cookies"
74+
}
75+
],
76+
"output": "_dd.appsec.s.req.cookies"
77+
},
7078
{
7179
"inputs": [
7280
{

ddtrace/appsec/_asm_request_context.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,13 @@ def __init__(self):
125125
def finalise(self):
126126
if self.active:
127127
env = self.execution_context.get_item("asm_env")
128-
# assert _CONTEXT_ID.get() == self._id
129-
callbacks = GLOBAL_CALLBACKS.get(_CONTEXT_CALL, []) + env.callbacks.get(_CONTEXT_CALL)
130-
if callbacks is not None:
131-
for function in callbacks:
132-
function(env)
128+
callbacks = GLOBAL_CALLBACKS.get(_CONTEXT_CALL, [])
129+
if env is not None and env.callbacks is not None and env.callbacks.get(_CONTEXT_CALL):
130+
callbacks += env.callbacks.get(_CONTEXT_CALL)
131+
if callbacks:
132+
if env is not None:
133+
for function in callbacks:
134+
function(env)
133135
self.execution_context.end()
134136
self.active = False
135137

0 commit comments

Comments
 (0)