Skip to content

Commit 8a7a3f1

Browse files
oxeye-nikolaysrikanthccvocelotl
authored
Feature/add boto3 sqs instrumentation (#1081)
* Add Boto3SQS Instrumentation * Add basic tests * Add context setting list * Fix linting * CR and lint fixes * Add newline * Run tox generate * Change the dependency version * Fix linting * PR fixes. Remove walrus operator and use the `start_as_current_span` * Run lint and generate Co-authored-by: Srikanth Chekuri <[email protected]> Co-authored-by: Diego Hurtado <[email protected]>
1 parent a5ec3f7 commit 8a7a3f1

File tree

13 files changed

+802
-0
lines changed

13 files changed

+802
-0
lines changed

.github/component_owners.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ components:
77
- oxeye-nikolay
88
- nikosokolik
99

10+
instrumentation/opentelemetry-instrumentation-boto3sqs:
11+
- oxeye-nikolay
12+
- nikosokolik
13+
1014
propagator/opentelemetry-propagator-aws-xray:
1115
- NathanielRN
1216

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2828
([#1065](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1065))
2929
- `opentelemetry-instrumentation-redis` now instruments asynchronous Redis clients, if the installed redis-py includes async support (>=4.2.0).
3030
([#1076](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1076))
31+
- `opentelemetry-instrumentation-boto3sqs` added AWS's SQS instrumentation.
32+
([#1081](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1081))
3133

3234
## [1.11.1-0.30b1](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.11.1-0.30b1) - 2022-04-21
3335

instrumentation/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
| [opentelemetry-instrumentation-asyncpg](./opentelemetry-instrumentation-asyncpg) | asyncpg >= 0.12.0 |
88
| [opentelemetry-instrumentation-aws-lambda](./opentelemetry-instrumentation-aws-lambda) | aws_lambda |
99
| [opentelemetry-instrumentation-boto](./opentelemetry-instrumentation-boto) | boto~=2.0 |
10+
| [opentelemetry-instrumentation-boto3sqs](./opentelemetry-instrumentation-boto3sqs) | boto3 ~= 1.0 |
1011
| [opentelemetry-instrumentation-botocore](./opentelemetry-instrumentation-botocore) | botocore ~= 1.0 |
1112
| [opentelemetry-instrumentation-celery](./opentelemetry-instrumentation-celery) | celery >= 4.0, < 6.0 |
1213
| [opentelemetry-instrumentation-dbapi](./opentelemetry-instrumentation-dbapi) | dbapi |
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
OpenTelemetry Boto3 SQS Instrumentation
2+
=======================================
3+
4+
|pypi|
5+
6+
.. |pypi| image:: https://badge.fury.io/py/opentelemetry-instrumentation-boto3sqs.svg
7+
:target: https://pypi.org/project/opentelemetry-instrumentation-boto3sqs/
8+
9+
This library allows tracing requests made by the Boto3 library to the SQS service.
10+
11+
Installation
12+
------------
13+
14+
::
15+
16+
pip install opentelemetry-instrumentation-boto3sqs
17+
18+
19+
References
20+
----------
21+
22+
* `OpenTelemetry boto3sqs/ Tracing <https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/boto3sqs/boto3sqs.html>`_
23+
* `OpenTelemetry Project <https://opentelemetry.io/>`_
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Copyright The OpenTelemetry Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
[metadata]
16+
# opentelemetry-instrumentation plus the name of the library being instrument e.g
17+
# name = opentelemetry-instrumentation-sqlalchemy
18+
name = opentelemetry-instrumentation-boto3sqs
19+
# a description of the instrumentation e.g
20+
# description = SQLAlchemy tracing for OpenTelemetry
21+
description = Boto3 SQS service tracing for OpenTelemetry
22+
long_description = file: README.rst
23+
long_description_content_type = text/x-rst
24+
author = OpenTelemetry Authors
25+
author_email = [email protected]
26+
# url of the instrumentation e.g
27+
url = https://github.com/open-telemetry/opentelemetry-python-contrib/instrumentation/opentelemetry-instrumentation-boto3sqs
28+
platforms = any
29+
license = Apache-2.0
30+
classifiers =
31+
Development Status :: 4 - Beta
32+
Intended Audience :: Developers
33+
License :: OSI Approved :: Apache Software License
34+
Programming Language :: Python
35+
Programming Language :: Python :: 3
36+
Programming Language :: Python :: 3.6
37+
Programming Language :: Python :: 3.7
38+
Programming Language :: Python :: 3.8
39+
Programming Language :: Python :: 3.9
40+
Programming Language :: Python :: 3.10
41+
42+
[options]
43+
python_requires = >=3.6
44+
package_dir=
45+
=src
46+
packages=find_namespace:
47+
install_requires =
48+
opentelemetry-api ~= 1.3
49+
wrapt >= 1.0.0, < 2.0.0
50+
51+
[options.extras_require]
52+
test =
53+
54+
[options.packages.find]
55+
where = src
56+
57+
[options.entry_points]
58+
opentelemetry_instrumentor =
59+
boto3sqs = opentelemetry.instrumentation.boto3sqs:Boto3SQSInstrumentation
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Copyright The OpenTelemetry Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
16+
# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt.
17+
# RUN `python scripts/generate_setup.py` TO REGENERATE.
18+
19+
20+
import distutils.cmd
21+
import json
22+
import os
23+
from configparser import ConfigParser
24+
25+
import setuptools
26+
27+
config = ConfigParser()
28+
config.read("setup.cfg")
29+
30+
# We provide extras_require parameter to setuptools.setup later which
31+
# overwrites the extras_require section from setup.cfg. To support extras_require
32+
# section in setup.cfg, we load it here and merge it with the extras_require param.
33+
extras_require = {}
34+
if "options.extras_require" in config:
35+
for key, value in config["options.extras_require"].items():
36+
extras_require[key] = [v for v in value.split("\n") if v.strip()]
37+
38+
BASE_DIR = os.path.dirname(__file__)
39+
PACKAGE_INFO = {}
40+
41+
VERSION_FILENAME = os.path.join(
42+
BASE_DIR,
43+
"src",
44+
"opentelemetry",
45+
"instrumentation",
46+
"boto3sqs",
47+
"version.py",
48+
)
49+
with open(VERSION_FILENAME, encoding="utf-8") as f:
50+
exec(f.read(), PACKAGE_INFO)
51+
52+
PACKAGE_FILENAME = os.path.join(
53+
BASE_DIR,
54+
"src",
55+
"opentelemetry",
56+
"instrumentation",
57+
"boto3sqs",
58+
"package.py",
59+
)
60+
with open(PACKAGE_FILENAME, encoding="utf-8") as f:
61+
exec(f.read(), PACKAGE_INFO)
62+
63+
# Mark any instruments/runtime dependencies as test dependencies as well.
64+
extras_require["instruments"] = PACKAGE_INFO["_instruments"]
65+
test_deps = extras_require.get("test", [])
66+
for dep in extras_require["instruments"]:
67+
test_deps.append(dep)
68+
69+
extras_require["test"] = test_deps
70+
71+
72+
class JSONMetadataCommand(distutils.cmd.Command):
73+
74+
description = (
75+
"print out package metadata as JSON. This is used by OpenTelemetry dev scripts to ",
76+
"auto-generate code in other places",
77+
)
78+
user_options = []
79+
80+
def initialize_options(self):
81+
pass
82+
83+
def finalize_options(self):
84+
pass
85+
86+
def run(self):
87+
metadata = {
88+
"name": config["metadata"]["name"],
89+
"version": PACKAGE_INFO["__version__"],
90+
"instruments": PACKAGE_INFO["_instruments"],
91+
}
92+
print(json.dumps(metadata))
93+
94+
95+
setuptools.setup(
96+
cmdclass={"meta": JSONMetadataCommand},
97+
version=PACKAGE_INFO["__version__"],
98+
extras_require=extras_require,
99+
)

0 commit comments

Comments
 (0)