File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 1+ import os
12import json
23import logging
34
45
56# check msgpack CPP implementation; if the import fails, we're using the
67# pure Python implementation that is really slow, so the ``Encoder`` should use
7- # a different encoding format
8+ # a different encoding format. To enable msgpack encoding, you should set
9+ # the ``DD_MSGPACK_ENCODING=1`` environment variable otherwise, the ``JSONEncoder``
10+ # will be used as a default.
811try :
912 import msgpack
1013 from msgpack ._packer import Packer # noqa
1114 from msgpack ._unpacker import unpack , unpackb , Unpacker # noqa
12- MSGPACK_CPP = True
15+ MSGPACK_ENCODING = os . getenv ( 'DD_MSGPACK_ENCODING' ) == '1' # shortcut to accept only '1'
1316except ImportError :
14- MSGPACK_CPP = False
17+ MSGPACK_ENCODING = False
1518
1619log = logging .getLogger (__name__ )
1720
@@ -82,7 +85,7 @@ def get_encoder():
8285 The default behavior is to use Msgpack if we have a CPP implementation
8386 installed, falling back to the Python built-in JSON encoder.
8487 """
85- if MSGPACK_CPP :
88+ if MSGPACK_ENCODING :
8689 return MsgpackEncoder ()
8790 else :
8891 return JSONEncoder ()
You can’t perform that action at this time.
0 commit comments