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

Add instrumentation for aiobotocore #1520

Merged
merged 6 commits into from Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .ci/.jenkins_framework.yml
Expand Up @@ -52,3 +52,4 @@ FRAMEWORK:
- prometheus_client-newest
- sanic-newest
- aiomysql-newest
- aiobotocore-newest
5 changes: 5 additions & 0 deletions CHANGELOG.asciidoc
Expand Up @@ -33,6 +33,11 @@ endif::[]
[[release-notes-6.x]]
=== Python Agent version 6.x

[float]
===== Features

* Add instrumentation for https://github.com/aio-libs/aiobotocore[`aiobotocore`] {pull}xxx[#xxx]

[[release-notes-6.9.1]]
==== 6.9.1 - 2022-03-30

Expand Down
18 changes: 18 additions & 0 deletions docs/supported-technologies.asciidoc
Expand Up @@ -570,6 +570,24 @@ Collected trace data for all services:

Additionally, some services collect more specific data

[float]
[[automatic-instrumentation-aiobotocore]]
==== AWS Aiobotocore

Library: `aiobotocore` (`>=2.2.0`)

Instrumented methods:

* `aiobotocore.client.BaseClient._make_api_call`

Collected trace data for all services:

* AWS region (e.g. `eu-central-1`)
* AWS service name (e.g. `s3`)
* operation name (e.g. `ListBuckets`)

Additionally, some services collect more specific data

[float]
[[automatic-instrumentation-s3]]
===== S3
Expand Down
40 changes: 40 additions & 0 deletions elasticapm/instrumentation/packages/asyncio/aiobotocore.py
@@ -0,0 +1,40 @@
# BSD 3-Clause License
#
# Copyright (c) 2019, Elasticsearch BV
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from elasticapm.contrib.asyncio.traces import async_capture_span
from elasticapm.instrumentation.packages.botocore import BotocoreInstrumentation


class AioBotocoreInstrumentation(BotocoreInstrumentation):
name = "aiobotocore"

instrument_list = [("aiobotocore.client", "AioBaseClient._make_api_call")]

capture_span_ctx = async_capture_span
4 changes: 3 additions & 1 deletion elasticapm/instrumentation/packages/botocore.py
Expand Up @@ -52,6 +52,8 @@ class BotocoreInstrumentation(AbstractInstrumentedModule):

instrument_list = [("botocore.client", "BaseClient._make_api_call")]

capture_span_ctx = capture_span

def call(self, module, method, wrapped, instance, args, kwargs):
if "operation_name" in kwargs:
operation_name = kwargs["operation_name"]
Expand Down Expand Up @@ -81,7 +83,7 @@ def call(self, module, method, wrapped, instance, args, kwargs):
if not handler_info:
handler_info = handle_default(operation_name, service, instance, args, kwargs, context)

with capture_span(
with self.capture_span_ctx(
handler_info.signature,
span_type=handler_info.span_type,
leaf=True,
Expand Down
1 change: 1 addition & 0 deletions elasticapm/instrumentation/register.py
Expand Up @@ -86,6 +86,7 @@
"elasticapm.instrumentation.packages.asyncio.aioredis.RedisPipelineInstrumentation",
"elasticapm.instrumentation.packages.asyncio.aioredis.RedisConnectionInstrumentation",
"elasticapm.instrumentation.packages.asyncio.aiomysql.AioMySQLInstrumentation",
"elasticapm.instrumentation.packages.asyncio.aiobotocore.AioBotocoreInstrumentation",
]
)

Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Expand Up @@ -162,6 +162,7 @@ markers =
prometheus_client
sanic
jinja2
aiobotocore

[isort]
line_length=120
Expand Down