1414# See the License for the specific language governing permissions and
1515# limitations under the License.
1616#
17-
17+ import inspect
1818import os
1919import uuid
20- from typing import List
20+ from typing import TYPE_CHECKING
21+
22+ if TYPE_CHECKING :
23+ from typing import List
2124
2225service_name = os .getenv ('SW_AGENT_NAME' ) or 'Python Service Name' # type: str
2326service_instance = os .getenv ('SW_AGENT_INSTANCE' ) or str (uuid .uuid1 ()).replace ('-' , '' ) # type: str
3538ignore_suffix = os .getenv ('SW_IGNORE_SUFFIX' ) or '.jpg,.jpeg,.js,.css,.png,.bmp,.gif,.ico,.mp3,' \
3639 '.mp4,.html,.svg ' # type: str
3740flask_collect_http_params = True if os .getenv ('SW_FLASK_COLLECT_HTTP_PARAMS' ) and \
38- os .getenv ('SW_FLASK_COLLECT_HTTP_PARAMS' ) == 'True' else False # type: bool
41+ os .getenv ('SW_FLASK_COLLECT_HTTP_PARAMS' ) == 'True' else False # type: bool
3942http_params_length_threshold = int (os .getenv ('SW_HTTP_PARAMS_LENGTH_THRESHOLD' ) or '1024' ) # type: int
4043django_collect_http_params = True if os .getenv ('SW_DJANGO_COLLECT_HTTP_PARAMS' ) and \
41- os .getenv ('SW_DJANGO_COLLECT_HTTP_PARAMS' ) == 'True' else False # type: bool
44+ os .getenv ('SW_DJANGO_COLLECT_HTTP_PARAMS' ) == 'True' else False # type: bool
4245correlation_element_max_number = int (os .getenv ('SW_CORRELATION_ELEMENT_MAX_NUMBER' ) or '3' ) # type: int
4346correlation_value_max_length = int (os .getenv ('SW_CORRELATION_VALUE_MAX_LENGTH' ) or '128' ) # type: int
4447trace_ignore = True if os .getenv ('SW_TRACE_IGNORE' ) and \
45- os .getenv ('SW_TRACE_IGNORE' ) == 'True' else False # type: bool
48+ os .getenv ('SW_TRACE_IGNORE' ) == 'True' else False # type: bool
4649trace_ignore_path = (os .getenv ('SW_TRACE_IGNORE_PATH' ) or '' ).split (',' ) # type: List[str]
4750elasticsearch_trace_dsl = True if os .getenv ('SW_ELASTICSEARCH_TRACE_DSL' ) and \
48- os .getenv ('SW_ELASTICSEARCH_TRACE_DSL' ) == 'True' else False # type: bool
51+ os .getenv ('SW_ELASTICSEARCH_TRACE_DSL' ) == 'True' else False # type: bool
4952
5053
5154def init (
@@ -69,3 +72,23 @@ def init(
6972
7073 global authentication
7174 authentication = token or authentication
75+
76+
77+ def serialize ():
78+ from skywalking import config
79+ return {
80+ key : value for key , value in config .__dict__ .items () if not (
81+ key .startswith ('_' ) or key == 'TYPE_CHECKING'
82+ or inspect .isfunction (value )
83+ or inspect .ismodule (value )
84+ or inspect .isbuiltin (value )
85+ or inspect .isclass (value )
86+ )
87+ }
88+
89+
90+ def deserialize (data ):
91+ from skywalking import config
92+ for key , value in data .items ():
93+ if key in config .__dict__ :
94+ config .__dict__ [key ] = value
0 commit comments