@@ -23,6 +23,7 @@ from ..constants import _ORIGIN_KEY as ORIGIN_KEY
23
23
from .constants import SPAN_LINKS_KEY
24
24
from .constants import SPAN_EVENTS_KEY
25
25
from .constants import MAX_UINT_64BITS
26
+ from .._trace._limits import MAX_SPAN_META_VALUE_LEN
26
27
from ..settings._agent import config as agent_config
27
28
28
29
@@ -135,7 +136,7 @@ cdef inline int pack_text(msgpack_packer *pk, object text) except? -1:
135
136
136
137
if PyBytesLike_Check(text):
137
138
L = len (text)
138
- if L > ITEM_LIMIT :
139
+ if L > MAX_SPAN_META_VALUE_LEN :
139
140
PyErr_Format(ValueError , b" %.200s object is too large" , Py_TYPE(text).tp_name)
140
141
ret = msgpack_pack_raw(pk, L)
141
142
if ret == 0 :
@@ -144,13 +145,13 @@ cdef inline int pack_text(msgpack_packer *pk, object text) except? -1:
144
145
145
146
if PyUnicode_Check(text):
146
147
IF PY_MAJOR_VERSION >= 3 :
147
- ret = msgpack_pack_unicode(pk, text, ITEM_LIMIT )
148
+ ret = msgpack_pack_unicode(pk, text, MAX_SPAN_META_VALUE_LEN )
148
149
if ret == - 2 :
149
150
raise ValueError (" unicode string is too large" )
150
151
ELSE :
151
152
text = PyUnicode_AsEncodedString(text, " utf-8" , NULL )
152
153
L = len (text)
153
- if L > ITEM_LIMIT :
154
+ if L > MAX_SPAN_META_VALUE_LEN :
154
155
raise ValueError (" unicode string is too large" )
155
156
ret = msgpack_pack_raw(pk, L)
156
157
if ret == 0 :
@@ -226,7 +227,6 @@ cdef class ListStringTable(StringTable):
226
227
cdef class MsgpackStringTable(StringTable):
227
228
cdef msgpack_packer pk
228
229
cdef int max_size
229
- cdef int _max_string_length
230
230
cdef int _sp_len
231
231
cdef stdint.uint32_t _sp_id
232
232
cdef object _lock
@@ -238,7 +238,6 @@ cdef class MsgpackStringTable(StringTable):
238
238
if self .pk.buf == NULL :
239
239
raise MemoryError (" Unable to allocate internal buffer." )
240
240
self .max_size = max_size
241
- self ._max_string_length = int (0.1 * max_size)
242
241
self .pk.length = MSGPACK_STRING_TABLE_LENGTH_PREFIX_SIZE
243
242
self ._sp_len = 0
244
243
self ._lock = threading.RLock()
@@ -254,9 +253,9 @@ cdef class MsgpackStringTable(StringTable):
254
253
cdef insert(self , object string):
255
254
cdef int ret
256
255
257
- if len (string) > self ._max_string_length :
256
+ if len (string) > self .MAX_SPAN_META_VALUE_LEN :
258
257
string = " <dropped string of length %d because it's too long (max allowed length %d )>" % (
259
- len (string), self ._max_string_length
258
+ len (string), self .MAX_SPAN_META_VALUE_LEN
260
259
)
261
260
262
261
if self .pk.length + len (string) > self .max_size:
0 commit comments