Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(symdb): upload compressed symbol payloads #11404

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading