Skip to content

chore(tracing): urllib3 events api migration#17226

Draft
wconti27 wants to merge 3 commits intomainfrom
apm-ai-toolkit/execute/urllib3/20260331-154248
Draft

chore(tracing): urllib3 events api migration#17226
wconti27 wants to merge 3 commits intomainfrom
apm-ai-toolkit/execute/urllib3/20260331-154248

Conversation

@wconti27
Copy link
Copy Markdown
Contributor

Description

Migrates Urllib3 to Events API

Testing

Risks

Additional Notes

@wconti27 wconti27 requested review from a team as code owners March 31, 2026 16:58
@wconti27 wconti27 added the ai-generated PR created with AI assistance label Mar 31, 2026
@wconti27 wconti27 changed the title urllib3 events api migration chore(tracing): urllib3 events api migration Mar 31, 2026
@wconti27 wconti27 requested a review from a team as a code owner March 31, 2026 23:33
@cit-pr-commenter-54b7da
Copy link
Copy Markdown

Codeowners resolved as

releasenotes/notes/aiohttp-events-api-migration-9ff29d6c995d42ce.yaml   @DataDog/apm-python

:param kwargs: Keyword arguments from the target function
:return: The ``HTTPResponse`` from the target function
"""
if not tracer.enabled and not asm_config._apm_opt_out:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we probably don't want this?

since we want to create instrumentation hook points in the integration no matter what, they will just be no-op if tracing/asm/ aren't doing anything.

baking the logic for all possible products which may need this information into each integration is a coupling we likely want to avoid.

),
)
# Set integration_config in context data so _start_span and _finish_span can find it.
# This is needed because getattr(event, "config", None) may return None on Python 3.9
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

config.urllib3 is already attached to the event... so... why is this needed at all? seems like a waste

) -> None:
event: HttpClientRequestEvent = ctx.event
# Prefer event.config, fall back to context data for Python 3.9 compatibility
integration_config = getattr(event, "config", None) or ctx.get_item("integration_config")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given we always set integration_config right now, then why even have event.config?

also, we are typed as HttpClientRequestEvent, so we know the config attribute exists? so why the getattr at all?

@brettlangdon
Copy link
Copy Markdown
Member

if we are going to do some decent sized refactors of integration, we should also enable type checking for them

dd-trace-py/mypy.ini

Lines 54 to 55 in 5a86489

[mypy-ddtrace.contrib.*]
ignore_errors = true

@wconti27 wconti27 marked this pull request as draft March 31, 2026 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated PR created with AI assistance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants