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: swap out deprecated datetime's utcnow and utcfromtimestamp #11850

Merged
merged 11 commits into from
Jan 9, 2025
4 changes: 2 additions & 2 deletions ddtrace/internal/debug.py
Original file line number Diff line number Diff line change
@@ -117,8 +117,8 @@ def collect(tracer):
from ddtrace._trace.tracer import log

return dict(
# Timestamp UTC ISO 8601
date=datetime.datetime.utcnow().isoformat(),
# Timestamp UTC ISO 8601 with the trailing +00:00 removed
date=datetime.datetime.now(datetime.timezone.utc).isoformat()[0:-6],
# eg. "Linux", "Darwin"
os_name=platform.system(),
# eg. 12.5.0
14 changes: 12 additions & 2 deletions ddtrace/profiling/exporter/http.py
Original file line number Diff line number Diff line change
@@ -220,8 +220,18 @@ def export(
"family": "python",
"attachments": [item["filename"].decode("utf-8") for item in data],
"tags_profiler": self._get_tags(service),
"start": (datetime.datetime.utcfromtimestamp(start_time_ns / 1e9).replace(microsecond=0).isoformat() + "Z"),
"end": (datetime.datetime.utcfromtimestamp(end_time_ns / 1e9).replace(microsecond=0).isoformat() + "Z"),
"start": (
datetime.datetime.fromtimestamp(start_time_ns / 1e9, tz=datetime.timezone.utc)
.replace(microsecond=0)
.isoformat()[0:-6] # removes the trailing +00:00 portion of the time
+ "Z"
),
"end": (
datetime.datetime.fromtimestamp(end_time_ns / 1e9, tz=datetime.timezone.utc)
.replace(microsecond=0)
.isoformat()[0:-6] # removes the trailing +00:00 portion of the time
+ "Z"
),
} # type: Dict[str, Any]

if self.endpoint_call_counter_span_processor is not None:
6 changes: 5 additions & 1 deletion tests/appsec/iast_packages/packages/pkg_pyjwt.py
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@

https://pypi.org/project/PyJWT/
"""

import datetime

from flask import Blueprint
@@ -25,7 +26,10 @@ def pkg_pyjwt_view():
secret_key = "your-256-bit-secret"
user_payload = request.args.get("package_param", "default-user")

payload = {"user": user_payload, "exp": datetime.datetime.utcnow() + datetime.timedelta(seconds=30)}
payload = {
"user": user_payload,
"exp": datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(seconds=30),
}

try:
# Encode the payload to create a JWT