Skip to content

Add support for aiohttp client and server#659

Merged
beniwohli merged 21 commits intoelastic:masterfrom
beniwohli:aiohttp-instrumentation
Dec 16, 2019
Merged

Add support for aiohttp client and server#659
beniwohli merged 21 commits intoelastic:masterfrom
beniwohli:aiohttp-instrumentation

Conversation

@beniwohli
Copy link
Contributor

@beniwohli beniwohli commented Nov 30, 2019

What does this pull request do?

This PR adds integration for the aiohttp web framework, as well as the aiohttp
HTTP client library.

Why is it important?

Adding support for more asyncio frameworks and libraries is part of the roadmap. BECAUSE ASYNC ALL THE THINGS! (edited for excitement by @basepi)

@beniwohli beniwohli marked this pull request as ready for review December 2, 2019 16:54
Copy link
Contributor

@basepi basepi left a comment

Choose a reason for hiding this comment

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

This is excellent work! And will be incredibly useful to me as I dive into Tornado. 👍

(One small note that you can ignore or take, but this is approved either way.)

app = aioeapm.app
client = await aiohttp_client(app)
elasticapm_client = aioeapm.client
resp = await client.get(
Copy link
Contributor

Choose a reason for hiding this comment

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

Unused variable

(I happened to open this in my editor and pylint was complaining)

Suggested change
resp = await client.get(
await client.get(

Copy link
Contributor

@basepi basepi left a comment

Choose a reason for hiding this comment

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

Still LGTM! 👍

Comment on lines +79 to +85
def _set_disttracing_headers(self, headers, trace_parent, transaction):
trace_parent_str = trace_parent.to_string()
headers[constants.TRACEPARENT_HEADER_NAME] = trace_parent_str
if transaction.tracer.config.use_elastic_traceparent_header:
headers[constants.TRACEPARENT_LEGACY_HEADER_NAME] = trace_parent_str
if trace_parent.tracestate:
headers[constants.TRACESTATE_HEADER_NAME] = trace_parent.tracestate
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll probably want to keep an eye on these types of functions as we go along. Has potential to become a maintenance problem if this behavior changes over time. Though I guess searching for the constants.TRACEPARENT will probably be sufficient for any number of uses.

Copy link
Contributor

@basepi basepi left a comment

Choose a reason for hiding this comment

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

One small copy-pasta in the docs. Look excellent.

==== Usage

Once you have configured the agent,
it will automatically track transactions and capture uncaught exceptions within Flask.
Copy link
Contributor

Choose a reason for hiding this comment

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

Flask

copy pasta?

# Conflicts:
#	.ci/.jenkins_exclude.yml
#	.ci/.jenkins_framework.yml
#	.ci/.jenkins_framework_full.yml
#	elasticapm/instrumentation/register.py
#	setup.cfg
@beniwohli beniwohli merged commit 6598165 into elastic:master Dec 16, 2019
@beniwohli beniwohli deleted the aiohttp-instrumentation branch December 16, 2019 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants