Skip to content

Commit

Permalink
chore(symdb): upload compressed symbol payloads
Browse files Browse the repository at this point in the history
We add support for compressed symbol database payloads.
  • Loading branch information
P403n1x87 committed Nov 14, 2024
1 parent 9a8f171 commit 1e05b69
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 5 additions & 3 deletions ddtrace/internal/symbol_db/symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from dataclasses import field
import dis
from enum import Enum
import gzip
from http.client import HTTPResponse
from inspect import CO_VARARGS
from inspect import CO_VARKEYWORDS
Expand Down Expand Up @@ -484,9 +485,10 @@ def upload(self) -> HTTPResponse:
),
FormData(
name="file",
filename="symdb_export.json",
data=json.dumps(self.to_json()),
filename="symdb_export.gz",
data=gzip.compress(json.dumps(self.to_json()).encode()),
content_type="json",
content_encoding="gzip",
),
]
)
Expand Down Expand Up @@ -527,7 +529,7 @@ def is_module_included(module: ModuleType) -> bool:


class SymbolDatabaseUploader(BaseModuleWatchdog):
__scope_limit__ = 100
__scope_limit__ = 400

def __init__(self) -> None:
super().__init__()
Expand Down
5 changes: 4 additions & 1 deletion ddtrace/internal/utils/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,9 @@ def parse_message(msg):
class FormData:
name: str
filename: str
data: str
data: Union[str, bytes]
content_type: str
content_encoding: Optional[str] = None


def multipart(parts: List[FormData]) -> Tuple[bytes, dict]:
Expand All @@ -433,6 +434,8 @@ def multipart(parts: List[FormData]) -> Tuple[bytes, dict]:
for part in parts:
app = MIMEApplication(part.data, part.content_type, lambda _: _)
app.add_header("Content-Disposition", "form-data", name=part.name, filename=part.filename)
if part.content_encoding:
app.add_header("Content-Encoding", part.content_encoding)
del app["MIME-Version"]
msg.attach(app)

Expand Down

0 comments on commit 1e05b69

Please sign in to comment.