opentelemetry-python-contrib-external-valkey 0.59b0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- opentelemetry_python_contrib_external_valkey-0.59b0/LICENSE +201 -0
- opentelemetry_python_contrib_external_valkey-0.59b0/PKG-INFO +54 -0
- opentelemetry_python_contrib_external_valkey-0.59b0/README.md +39 -0
- opentelemetry_python_contrib_external_valkey-0.59b0/pyproject.toml +46 -0
- opentelemetry_python_contrib_external_valkey-0.59b0/src/opentelemetry/instrumentation/valkey/__init__.py +662 -0
- opentelemetry_python_contrib_external_valkey-0.59b0/src/opentelemetry/instrumentation/valkey/custom_types.py +49 -0
- opentelemetry_python_contrib_external_valkey-0.59b0/src/opentelemetry/instrumentation/valkey/package.py +16 -0
- opentelemetry_python_contrib_external_valkey-0.59b0/src/opentelemetry/instrumentation/valkey/py.typed +0 -0
- opentelemetry_python_contrib_external_valkey-0.59b0/src/opentelemetry/instrumentation/valkey/util.py +211 -0
- opentelemetry_python_contrib_external_valkey-0.59b0/src/opentelemetry/instrumentation/valkey/version.py +16 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: opentelemetry-python-contrib-external-valkey
|
|
3
|
+
Version: 0.59b0
|
|
4
|
+
Summary: OpenTelemetry Valkey instrumentation
|
|
5
|
+
Author: Philip Meier
|
|
6
|
+
Author-email: Philip Meier <github.pmeier@posteo.de>
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: opentelemetry-api~=1.12
|
|
10
|
+
Requires-Dist: opentelemetry-instrumentation==0.59b0
|
|
11
|
+
Requires-Dist: opentelemetry-semantic-conventions==0.59b0
|
|
12
|
+
Requires-Dist: wrapt>=1.12.1
|
|
13
|
+
Requires-Python: >=3.9
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# opentelemetry-python-contrib-external-valkey
|
|
17
|
+
|
|
18
|
+
[OpenTelemetry](https://opentelemetry.io/) instrumentation for the [Valkey Python Client](https://github.com/valkey-io/valkey-py).
|
|
19
|
+
|
|
20
|
+
## How do I install it?
|
|
21
|
+
|
|
22
|
+
`opentelemetry-python-contrib-external-valkey` is available on [PyPI](). You can install it with
|
|
23
|
+
|
|
24
|
+
```shell
|
|
25
|
+
pip install opentelemetry-python-contrib-external-valkey
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
or
|
|
29
|
+
|
|
30
|
+
```shell
|
|
31
|
+
uv add opentelemetry-python-contrib-external-valkey
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
or something equivalent.
|
|
35
|
+
|
|
36
|
+
## How do I use it?
|
|
37
|
+
|
|
38
|
+
For global instrumentation of the [Valkey Python client](https://github.com/valkey-io/valkey-py) you can do
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from opentelemetry.instrumentation.valkey import ValkeyInstrumentor
|
|
42
|
+
|
|
43
|
+
ValkeyInstrumentor().instrument()
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
For more detailed documentation please have a look at the [`opentelemetry-instrumentation-redis` documentation](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/redis/redis.html) and just replace `[rR]edis` with `[vV]alkey`.
|
|
47
|
+
|
|
48
|
+
## Why is this needed?
|
|
49
|
+
|
|
50
|
+
`opentelemetry-instrumentation-redis` instruments the `redis` module and has multiple `isinstance` checks for classes from it. Since the [Valkey Python Client] is a fork of the [Redis Python Client](https://github.com/redis/redis-py), any instrumentation through `opentelemetry-instrumentation-redis` has no effect on the `valkey` module or any of its classes. `opentelemetry-python-contrib-external-valkey` fills this gap until Valkey is [officially supported](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3478) and gives Valkey users the same user experience for instrumentation as Redis users.
|
|
51
|
+
|
|
52
|
+
## How does it work?
|
|
53
|
+
|
|
54
|
+
This repository is a fork of [opentelemetry-python-contrib](https://github.com/open-telemetry/opentelemetry-python-contrib) and specifically the [instrumentation/opentelemetry-instrumentation-redis](https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation/opentelemetry-instrumentation-redis) folder. 95% and more of the changes in the [`src`](./src) and [`tests`](./tests) folders are just replacing the strings `redis` and `Redis` with `valkey` and `Valkey` respectively.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# opentelemetry-python-contrib-external-valkey
|
|
2
|
+
|
|
3
|
+
[OpenTelemetry](https://opentelemetry.io/) instrumentation for the [Valkey Python Client](https://github.com/valkey-io/valkey-py).
|
|
4
|
+
|
|
5
|
+
## How do I install it?
|
|
6
|
+
|
|
7
|
+
`opentelemetry-python-contrib-external-valkey` is available on [PyPI](). You can install it with
|
|
8
|
+
|
|
9
|
+
```shell
|
|
10
|
+
pip install opentelemetry-python-contrib-external-valkey
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
or
|
|
14
|
+
|
|
15
|
+
```shell
|
|
16
|
+
uv add opentelemetry-python-contrib-external-valkey
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
or something equivalent.
|
|
20
|
+
|
|
21
|
+
## How do I use it?
|
|
22
|
+
|
|
23
|
+
For global instrumentation of the [Valkey Python client](https://github.com/valkey-io/valkey-py) you can do
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from opentelemetry.instrumentation.valkey import ValkeyInstrumentor
|
|
27
|
+
|
|
28
|
+
ValkeyInstrumentor().instrument()
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
For more detailed documentation please have a look at the [`opentelemetry-instrumentation-redis` documentation](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/redis/redis.html) and just replace `[rR]edis` with `[vV]alkey`.
|
|
32
|
+
|
|
33
|
+
## Why is this needed?
|
|
34
|
+
|
|
35
|
+
`opentelemetry-instrumentation-redis` instruments the `redis` module and has multiple `isinstance` checks for classes from it. Since the [Valkey Python Client] is a fork of the [Redis Python Client](https://github.com/redis/redis-py), any instrumentation through `opentelemetry-instrumentation-redis` has no effect on the `valkey` module or any of its classes. `opentelemetry-python-contrib-external-valkey` fills this gap until Valkey is [officially supported](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3478) and gives Valkey users the same user experience for instrumentation as Redis users.
|
|
36
|
+
|
|
37
|
+
## How does it work?
|
|
38
|
+
|
|
39
|
+
This repository is a fork of [opentelemetry-python-contrib](https://github.com/open-telemetry/opentelemetry-python-contrib) and specifically the [instrumentation/opentelemetry-instrumentation-redis](https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation/opentelemetry-instrumentation-redis) folder. 95% and more of the changes in the [`src`](./src) and [`tests`](./tests) folders are just replacing the strings `redis` and `Redis` with `valkey` and `Valkey` respectively.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "opentelemetry-python-contrib-external-valkey"
|
|
3
|
+
description = "OpenTelemetry Valkey instrumentation"
|
|
4
|
+
license = "Apache-2.0"
|
|
5
|
+
license-files = ["LICENSE"]
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "Philip Meier", email = "github.pmeier@posteo.de" },
|
|
8
|
+
]
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
version = "0.59b0"
|
|
12
|
+
|
|
13
|
+
dependencies = [
|
|
14
|
+
"opentelemetry-api~=1.12",
|
|
15
|
+
"opentelemetry-instrumentation==0.59b0",
|
|
16
|
+
"opentelemetry-semantic-conventions==0.59b0",
|
|
17
|
+
"wrapt>=1.12.1",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[dependency-groups]
|
|
21
|
+
instruments = ["valkey>=6.1.0"]
|
|
22
|
+
dev = [
|
|
23
|
+
{include-group = "instruments"},
|
|
24
|
+
"fakeredis>=2.25",
|
|
25
|
+
"opentelemetry-test-utils==0.59b0",
|
|
26
|
+
"pytest>=7.4.4",
|
|
27
|
+
"pytest-asyncio>=1.2.0",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
[project.entry-points.opentelemetry_instrumentor]
|
|
32
|
+
redis = "opentelemetry.instrumentation.valkey:ValkeyInstrumentor"
|
|
33
|
+
|
|
34
|
+
[build-system]
|
|
35
|
+
requires = ["uv_build>=0.9.11,<0.10.0"]
|
|
36
|
+
build-backend = "uv_build"
|
|
37
|
+
|
|
38
|
+
[tool.uv.build-backend]
|
|
39
|
+
module-name = "opentelemetry.instrumentation.valkey"
|
|
40
|
+
|
|
41
|
+
[tool.pytest.ini_options]
|
|
42
|
+
minversion = "6.0"
|
|
43
|
+
addopts = "-ra --tb=short"
|
|
44
|
+
testpaths = [
|
|
45
|
+
"tests",
|
|
46
|
+
]
|
|
@@ -0,0 +1,662 @@
|
|
|
1
|
+
# Copyright The OpenTelemetry Authors
|
|
2
|
+
# Copyright 2025 Philip Meier
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
|
|
16
|
+
"""
|
|
17
|
+
Instrument `valkey`_ to report Valkey queries.
|
|
18
|
+
|
|
19
|
+
.. _valkey: https://pypi.org/project/valkey/
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
Instrument All Clients
|
|
23
|
+
----------------------
|
|
24
|
+
|
|
25
|
+
The easiest way to instrument all valkey client instances is by
|
|
26
|
+
``ValkeyInstrumentor().instrument()``:
|
|
27
|
+
|
|
28
|
+
.. code:: python
|
|
29
|
+
|
|
30
|
+
from opentelemetry.instrumentation.valkey import ValkeyInstrumentor
|
|
31
|
+
import valkey
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
# Instrument valkey
|
|
35
|
+
ValkeyInstrumentor().instrument()
|
|
36
|
+
|
|
37
|
+
# This will report a span with the default settings
|
|
38
|
+
client = valkey.StrictValkey(host="localhost", port=6379)
|
|
39
|
+
client.get("my-key")
|
|
40
|
+
|
|
41
|
+
Async Valkey clients (i.e. ``valkey.asyncio.Valkey``) are also instrumented in the same way:
|
|
42
|
+
|
|
43
|
+
.. code:: python
|
|
44
|
+
|
|
45
|
+
from opentelemetry.instrumentation.valkey import ValkeyInstrumentor
|
|
46
|
+
import valkey.asyncio
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# Instrument valkey
|
|
50
|
+
ValkeyInstrumentor().instrument()
|
|
51
|
+
|
|
52
|
+
# This will report a span with the default settings
|
|
53
|
+
async def valkey_get():
|
|
54
|
+
client = valkey.asyncio.Valkey(host="localhost", port=6379)
|
|
55
|
+
await client.get("my-key")
|
|
56
|
+
|
|
57
|
+
.. note::
|
|
58
|
+
Calling the ``instrument`` method will instrument the client classes, so any client
|
|
59
|
+
created after the ``instrument`` call will be instrumented. To instrument only a
|
|
60
|
+
single client, use :func:`ValkeyInstrumentor.instrument_client` method.
|
|
61
|
+
|
|
62
|
+
Instrument Single Client
|
|
63
|
+
------------------------
|
|
64
|
+
|
|
65
|
+
The :func:`ValkeyInstrumentor.instrument_client` can instrument a connection instance. This is useful when there are multiple clients with a different valkey database index.
|
|
66
|
+
Or, you might have a different connection pool used for an application function you
|
|
67
|
+
don't want instrumented.
|
|
68
|
+
|
|
69
|
+
.. code:: python
|
|
70
|
+
|
|
71
|
+
from opentelemetry.instrumentation.valkey import ValkeyInstrumentor
|
|
72
|
+
import valkey
|
|
73
|
+
|
|
74
|
+
instrumented_client = valkey.Valkey()
|
|
75
|
+
not_instrumented_client = valkey.Valkey()
|
|
76
|
+
|
|
77
|
+
# Instrument valkey
|
|
78
|
+
ValkeyInstrumentor.instrument_client(client=instrumented_client)
|
|
79
|
+
|
|
80
|
+
# This will report a span with the default settings
|
|
81
|
+
instrumented_client.get("my-key")
|
|
82
|
+
|
|
83
|
+
# This will not have a span
|
|
84
|
+
not_instrumented_client.get("my-key")
|
|
85
|
+
|
|
86
|
+
.. warning::
|
|
87
|
+
All client instances created after calling ``ValkeyInstrumentor().instrument`` will
|
|
88
|
+
be instrumented. To avoid instrumenting all clients, use
|
|
89
|
+
:func:`ValkeyInstrumentor.instrument_client` .
|
|
90
|
+
|
|
91
|
+
Request/Response Hooks
|
|
92
|
+
----------------------
|
|
93
|
+
|
|
94
|
+
.. code:: python
|
|
95
|
+
|
|
96
|
+
from opentelemetry.instrumentation.valkey import ValkeyInstrumentor
|
|
97
|
+
import valkey
|
|
98
|
+
|
|
99
|
+
def request_hook(span, instance, args, kwargs):
|
|
100
|
+
if span and span.is_recording():
|
|
101
|
+
span.set_attribute("custom_user_attribute_from_request_hook", "some-value")
|
|
102
|
+
|
|
103
|
+
def response_hook(span, instance, response):
|
|
104
|
+
if span and span.is_recording():
|
|
105
|
+
span.set_attribute("custom_user_attribute_from_response_hook", "some-value")
|
|
106
|
+
|
|
107
|
+
# Instrument valkey with hooks
|
|
108
|
+
ValkeyInstrumentor().instrument(request_hook=request_hook, response_hook=response_hook)
|
|
109
|
+
|
|
110
|
+
# This will report a span with the default settings and the custom attributes added from the hooks
|
|
111
|
+
client = valkey.StrictValkey(host="localhost", port=6379)
|
|
112
|
+
client.get("my-key")
|
|
113
|
+
|
|
114
|
+
API
|
|
115
|
+
---
|
|
116
|
+
"""
|
|
117
|
+
|
|
118
|
+
from __future__ import annotations
|
|
119
|
+
|
|
120
|
+
import logging
|
|
121
|
+
from typing import TYPE_CHECKING, Any, Callable, Collection
|
|
122
|
+
|
|
123
|
+
import valkey
|
|
124
|
+
from wrapt import wrap_function_wrapper
|
|
125
|
+
|
|
126
|
+
from opentelemetry import trace
|
|
127
|
+
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
|
128
|
+
from opentelemetry.instrumentation.valkey.package import _instruments
|
|
129
|
+
from opentelemetry.instrumentation.valkey.util import (
|
|
130
|
+
_add_create_attributes,
|
|
131
|
+
_add_search_attributes,
|
|
132
|
+
_build_span_meta_data_for_pipeline,
|
|
133
|
+
_build_span_name,
|
|
134
|
+
_format_command_args,
|
|
135
|
+
_set_connection_attributes,
|
|
136
|
+
)
|
|
137
|
+
from opentelemetry.instrumentation.valkey.version import __version__
|
|
138
|
+
from opentelemetry.instrumentation.utils import unwrap
|
|
139
|
+
from opentelemetry.semconv._incubating.attributes.db_attributes import (
|
|
140
|
+
DB_STATEMENT,
|
|
141
|
+
)
|
|
142
|
+
from opentelemetry.trace import (
|
|
143
|
+
StatusCode,
|
|
144
|
+
Tracer,
|
|
145
|
+
TracerProvider,
|
|
146
|
+
get_tracer,
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
if TYPE_CHECKING:
|
|
150
|
+
from typing import Awaitable
|
|
151
|
+
|
|
152
|
+
import valkey.asyncio.client
|
|
153
|
+
import valkey.asyncio.cluster
|
|
154
|
+
import valkey.client
|
|
155
|
+
import valkey.cluster
|
|
156
|
+
import valkey.connection
|
|
157
|
+
|
|
158
|
+
from opentelemetry.instrumentation.valkey.custom_types import (
|
|
159
|
+
AsyncPipelineInstance,
|
|
160
|
+
AsyncValkeyInstance,
|
|
161
|
+
PipelineInstance,
|
|
162
|
+
R,
|
|
163
|
+
ValkeyInstance,
|
|
164
|
+
RequestHook,
|
|
165
|
+
ResponseHook,
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
_logger = logging.getLogger(__name__)
|
|
170
|
+
|
|
171
|
+
_REDIS_ASYNCIO_VERSION = (4, 2, 0)
|
|
172
|
+
_REDIS_CLUSTER_VERSION = (4, 1, 0)
|
|
173
|
+
_REDIS_ASYNCIO_CLUSTER_VERSION = (4, 3, 2)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
_CLIENT_ASYNCIO_SUPPORT = valkey.VERSION >= _REDIS_ASYNCIO_VERSION
|
|
177
|
+
_CLIENT_ASYNCIO_CLUSTER_SUPPORT = (
|
|
178
|
+
valkey.VERSION >= _REDIS_ASYNCIO_CLUSTER_VERSION
|
|
179
|
+
)
|
|
180
|
+
_CLIENT_CLUSTER_SUPPORT = valkey.VERSION >= _REDIS_CLUSTER_VERSION
|
|
181
|
+
_CLIENT_BEFORE_V3 = valkey.VERSION < (3, 0, 0)
|
|
182
|
+
|
|
183
|
+
if _CLIENT_ASYNCIO_SUPPORT:
|
|
184
|
+
import valkey.asyncio
|
|
185
|
+
|
|
186
|
+
_INSTRUMENTATION_ATTR = "_is_instrumented_by_opentelemetry"
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def _traced_execute_factory(
|
|
190
|
+
tracer: Tracer,
|
|
191
|
+
request_hook: RequestHook | None = None,
|
|
192
|
+
response_hook: ResponseHook | None = None,
|
|
193
|
+
):
|
|
194
|
+
def _traced_execute_command(
|
|
195
|
+
func: Callable[..., R],
|
|
196
|
+
instance: ValkeyInstance,
|
|
197
|
+
args: tuple[Any, ...],
|
|
198
|
+
kwargs: dict[str, Any],
|
|
199
|
+
) -> R:
|
|
200
|
+
query = _format_command_args(args)
|
|
201
|
+
name = _build_span_name(instance, args)
|
|
202
|
+
with tracer.start_as_current_span(
|
|
203
|
+
name, kind=trace.SpanKind.CLIENT
|
|
204
|
+
) as span:
|
|
205
|
+
if span.is_recording():
|
|
206
|
+
span.set_attribute(DB_STATEMENT, query)
|
|
207
|
+
_set_connection_attributes(span, instance)
|
|
208
|
+
span.set_attribute("db.valkey.args_length", len(args))
|
|
209
|
+
if span.name == "valkey.create_index":
|
|
210
|
+
_add_create_attributes(span, args)
|
|
211
|
+
if callable(request_hook):
|
|
212
|
+
request_hook(span, instance, args, kwargs)
|
|
213
|
+
response = func(*args, **kwargs)
|
|
214
|
+
if span.is_recording():
|
|
215
|
+
if span.name == "valkey.search":
|
|
216
|
+
_add_search_attributes(span, response, args)
|
|
217
|
+
if callable(response_hook):
|
|
218
|
+
response_hook(span, instance, response)
|
|
219
|
+
return response
|
|
220
|
+
|
|
221
|
+
return _traced_execute_command
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
def _traced_execute_pipeline_factory(
|
|
225
|
+
tracer: Tracer,
|
|
226
|
+
request_hook: RequestHook | None = None,
|
|
227
|
+
response_hook: ResponseHook | None = None,
|
|
228
|
+
):
|
|
229
|
+
def _traced_execute_pipeline(
|
|
230
|
+
func: Callable[..., R],
|
|
231
|
+
instance: PipelineInstance,
|
|
232
|
+
args: tuple[Any, ...],
|
|
233
|
+
kwargs: dict[str, Any],
|
|
234
|
+
) -> R:
|
|
235
|
+
(
|
|
236
|
+
command_stack,
|
|
237
|
+
resource,
|
|
238
|
+
span_name,
|
|
239
|
+
) = _build_span_meta_data_for_pipeline(instance)
|
|
240
|
+
exception = None
|
|
241
|
+
with tracer.start_as_current_span(
|
|
242
|
+
span_name, kind=trace.SpanKind.CLIENT
|
|
243
|
+
) as span:
|
|
244
|
+
if span.is_recording():
|
|
245
|
+
span.set_attribute(DB_STATEMENT, resource)
|
|
246
|
+
_set_connection_attributes(span, instance)
|
|
247
|
+
span.set_attribute(
|
|
248
|
+
"db.valkey.pipeline_length", len(command_stack)
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
response = None
|
|
252
|
+
try:
|
|
253
|
+
response = func(*args, **kwargs)
|
|
254
|
+
except valkey.WatchError as watch_exception:
|
|
255
|
+
span.set_status(StatusCode.UNSET)
|
|
256
|
+
exception = watch_exception
|
|
257
|
+
|
|
258
|
+
if callable(response_hook):
|
|
259
|
+
response_hook(span, instance, response)
|
|
260
|
+
|
|
261
|
+
if exception:
|
|
262
|
+
raise exception
|
|
263
|
+
|
|
264
|
+
return response
|
|
265
|
+
|
|
266
|
+
return _traced_execute_pipeline
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
def _async_traced_execute_factory(
|
|
270
|
+
tracer: Tracer,
|
|
271
|
+
request_hook: RequestHook | None = None,
|
|
272
|
+
response_hook: ResponseHook | None = None,
|
|
273
|
+
):
|
|
274
|
+
async def _async_traced_execute_command(
|
|
275
|
+
func: Callable[..., Awaitable[R]],
|
|
276
|
+
instance: AsyncValkeyInstance,
|
|
277
|
+
args: tuple[Any, ...],
|
|
278
|
+
kwargs: dict[str, Any],
|
|
279
|
+
) -> Awaitable[R]:
|
|
280
|
+
query = _format_command_args(args)
|
|
281
|
+
name = _build_span_name(instance, args)
|
|
282
|
+
|
|
283
|
+
with tracer.start_as_current_span(
|
|
284
|
+
name, kind=trace.SpanKind.CLIENT
|
|
285
|
+
) as span:
|
|
286
|
+
if span.is_recording():
|
|
287
|
+
span.set_attribute(DB_STATEMENT, query)
|
|
288
|
+
_set_connection_attributes(span, instance)
|
|
289
|
+
span.set_attribute("db.valkey.args_length", len(args))
|
|
290
|
+
if callable(request_hook):
|
|
291
|
+
request_hook(span, instance, args, kwargs)
|
|
292
|
+
response = await func(*args, **kwargs)
|
|
293
|
+
if callable(response_hook):
|
|
294
|
+
response_hook(span, instance, response)
|
|
295
|
+
return response
|
|
296
|
+
|
|
297
|
+
return _async_traced_execute_command
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
def _async_traced_execute_pipeline_factory(
|
|
301
|
+
tracer: Tracer,
|
|
302
|
+
request_hook: RequestHook | None = None,
|
|
303
|
+
response_hook: ResponseHook | None = None,
|
|
304
|
+
):
|
|
305
|
+
async def _async_traced_execute_pipeline(
|
|
306
|
+
func: Callable[..., Awaitable[R]],
|
|
307
|
+
instance: AsyncPipelineInstance,
|
|
308
|
+
args: tuple[Any, ...],
|
|
309
|
+
kwargs: dict[str, Any],
|
|
310
|
+
) -> Awaitable[R]:
|
|
311
|
+
(
|
|
312
|
+
command_stack,
|
|
313
|
+
resource,
|
|
314
|
+
span_name,
|
|
315
|
+
) = _build_span_meta_data_for_pipeline(instance)
|
|
316
|
+
|
|
317
|
+
exception = None
|
|
318
|
+
|
|
319
|
+
with tracer.start_as_current_span(
|
|
320
|
+
span_name, kind=trace.SpanKind.CLIENT
|
|
321
|
+
) as span:
|
|
322
|
+
if span.is_recording():
|
|
323
|
+
span.set_attribute(DB_STATEMENT, resource)
|
|
324
|
+
_set_connection_attributes(span, instance)
|
|
325
|
+
span.set_attribute(
|
|
326
|
+
"db.valkey.pipeline_length", len(command_stack)
|
|
327
|
+
)
|
|
328
|
+
|
|
329
|
+
response = None
|
|
330
|
+
try:
|
|
331
|
+
response = await func(*args, **kwargs)
|
|
332
|
+
except valkey.WatchError as watch_exception:
|
|
333
|
+
span.set_status(StatusCode.UNSET)
|
|
334
|
+
exception = watch_exception
|
|
335
|
+
|
|
336
|
+
if callable(response_hook):
|
|
337
|
+
response_hook(span, instance, response)
|
|
338
|
+
|
|
339
|
+
if exception:
|
|
340
|
+
raise exception
|
|
341
|
+
|
|
342
|
+
return response
|
|
343
|
+
|
|
344
|
+
return _async_traced_execute_pipeline
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
# pylint: disable=R0915
|
|
348
|
+
def _instrument(
|
|
349
|
+
tracer: Tracer,
|
|
350
|
+
request_hook: RequestHook | None = None,
|
|
351
|
+
response_hook: ResponseHook | None = None,
|
|
352
|
+
):
|
|
353
|
+
_traced_execute_command = _traced_execute_factory(
|
|
354
|
+
tracer, request_hook, response_hook
|
|
355
|
+
)
|
|
356
|
+
_traced_execute_pipeline = _traced_execute_pipeline_factory(
|
|
357
|
+
tracer, request_hook, response_hook
|
|
358
|
+
)
|
|
359
|
+
pipeline_class = "BasePipeline" if _CLIENT_BEFORE_V3 else "Pipeline"
|
|
360
|
+
valkey_class = "StrictValkey" if _CLIENT_BEFORE_V3 else "Valkey"
|
|
361
|
+
|
|
362
|
+
wrap_function_wrapper(
|
|
363
|
+
"valkey", f"{valkey_class}.execute_command", _traced_execute_command
|
|
364
|
+
)
|
|
365
|
+
wrap_function_wrapper(
|
|
366
|
+
"valkey.client",
|
|
367
|
+
f"{pipeline_class}.execute",
|
|
368
|
+
_traced_execute_pipeline,
|
|
369
|
+
)
|
|
370
|
+
wrap_function_wrapper(
|
|
371
|
+
"valkey.client",
|
|
372
|
+
f"{pipeline_class}.immediate_execute_command",
|
|
373
|
+
_traced_execute_command,
|
|
374
|
+
)
|
|
375
|
+
if _CLIENT_CLUSTER_SUPPORT:
|
|
376
|
+
wrap_function_wrapper(
|
|
377
|
+
"valkey.cluster",
|
|
378
|
+
"ValkeyCluster.execute_command",
|
|
379
|
+
_traced_execute_command,
|
|
380
|
+
)
|
|
381
|
+
wrap_function_wrapper(
|
|
382
|
+
"valkey.cluster",
|
|
383
|
+
"ClusterPipeline.execute",
|
|
384
|
+
_traced_execute_pipeline,
|
|
385
|
+
)
|
|
386
|
+
|
|
387
|
+
_async_traced_execute_command = _async_traced_execute_factory(
|
|
388
|
+
tracer, request_hook, response_hook
|
|
389
|
+
)
|
|
390
|
+
_async_traced_execute_pipeline = _async_traced_execute_pipeline_factory(
|
|
391
|
+
tracer, request_hook, response_hook
|
|
392
|
+
)
|
|
393
|
+
if _CLIENT_ASYNCIO_SUPPORT:
|
|
394
|
+
wrap_function_wrapper(
|
|
395
|
+
"valkey.asyncio",
|
|
396
|
+
f"{valkey_class}.execute_command",
|
|
397
|
+
_async_traced_execute_command,
|
|
398
|
+
)
|
|
399
|
+
wrap_function_wrapper(
|
|
400
|
+
"valkey.asyncio.client",
|
|
401
|
+
f"{pipeline_class}.execute",
|
|
402
|
+
_async_traced_execute_pipeline,
|
|
403
|
+
)
|
|
404
|
+
wrap_function_wrapper(
|
|
405
|
+
"valkey.asyncio.client",
|
|
406
|
+
f"{pipeline_class}.immediate_execute_command",
|
|
407
|
+
_async_traced_execute_command,
|
|
408
|
+
)
|
|
409
|
+
if _CLIENT_ASYNCIO_CLUSTER_SUPPORT:
|
|
410
|
+
wrap_function_wrapper(
|
|
411
|
+
"valkey.asyncio.cluster",
|
|
412
|
+
"ValkeyCluster.execute_command",
|
|
413
|
+
_async_traced_execute_command,
|
|
414
|
+
)
|
|
415
|
+
wrap_function_wrapper(
|
|
416
|
+
"valkey.asyncio.cluster",
|
|
417
|
+
"ClusterPipeline.execute",
|
|
418
|
+
_async_traced_execute_pipeline,
|
|
419
|
+
)
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
def _instrument_client(
|
|
423
|
+
client,
|
|
424
|
+
tracer: Tracer,
|
|
425
|
+
request_hook: RequestHook | None = None,
|
|
426
|
+
response_hook: ResponseHook | None = None,
|
|
427
|
+
):
|
|
428
|
+
# first, handle async clients and cluster clients
|
|
429
|
+
_async_traced_execute = _async_traced_execute_factory(
|
|
430
|
+
tracer, request_hook, response_hook
|
|
431
|
+
)
|
|
432
|
+
_async_traced_execute_pipeline = _async_traced_execute_pipeline_factory(
|
|
433
|
+
tracer, request_hook, response_hook
|
|
434
|
+
)
|
|
435
|
+
|
|
436
|
+
if _CLIENT_ASYNCIO_SUPPORT and isinstance(client, valkey.asyncio.Valkey):
|
|
437
|
+
|
|
438
|
+
def _async_pipeline_wrapper(func, instance, args, kwargs):
|
|
439
|
+
result = func(*args, **kwargs)
|
|
440
|
+
wrap_function_wrapper(
|
|
441
|
+
result, "execute", _async_traced_execute_pipeline
|
|
442
|
+
)
|
|
443
|
+
wrap_function_wrapper(
|
|
444
|
+
result, "immediate_execute_command", _async_traced_execute
|
|
445
|
+
)
|
|
446
|
+
return result
|
|
447
|
+
|
|
448
|
+
wrap_function_wrapper(client, "execute_command", _async_traced_execute)
|
|
449
|
+
wrap_function_wrapper(client, "pipeline", _async_pipeline_wrapper)
|
|
450
|
+
return
|
|
451
|
+
|
|
452
|
+
if _CLIENT_ASYNCIO_CLUSTER_SUPPORT and isinstance(
|
|
453
|
+
client, valkey.asyncio.ValkeyCluster
|
|
454
|
+
):
|
|
455
|
+
|
|
456
|
+
def _async_cluster_pipeline_wrapper(func, instance, args, kwargs):
|
|
457
|
+
result = func(*args, **kwargs)
|
|
458
|
+
wrap_function_wrapper(
|
|
459
|
+
result, "execute", _async_traced_execute_pipeline
|
|
460
|
+
)
|
|
461
|
+
return result
|
|
462
|
+
|
|
463
|
+
wrap_function_wrapper(client, "execute_command", _async_traced_execute)
|
|
464
|
+
wrap_function_wrapper(
|
|
465
|
+
client, "pipeline", _async_cluster_pipeline_wrapper
|
|
466
|
+
)
|
|
467
|
+
return
|
|
468
|
+
# for valkey.client.Valkey, valkey.Cluster and v3.0.0 valkey.client.StrictValkey
|
|
469
|
+
# the wrappers are the same
|
|
470
|
+
_traced_execute = _traced_execute_factory(
|
|
471
|
+
tracer, request_hook, response_hook
|
|
472
|
+
)
|
|
473
|
+
_traced_execute_pipeline = _traced_execute_pipeline_factory(
|
|
474
|
+
tracer, request_hook, response_hook
|
|
475
|
+
)
|
|
476
|
+
|
|
477
|
+
def _pipeline_wrapper(func, instance, args, kwargs):
|
|
478
|
+
result = func(*args, **kwargs)
|
|
479
|
+
wrap_function_wrapper(result, "execute", _traced_execute_pipeline)
|
|
480
|
+
wrap_function_wrapper(
|
|
481
|
+
result, "immediate_execute_command", _traced_execute
|
|
482
|
+
)
|
|
483
|
+
return result
|
|
484
|
+
|
|
485
|
+
wrap_function_wrapper(
|
|
486
|
+
client,
|
|
487
|
+
"execute_command",
|
|
488
|
+
_traced_execute,
|
|
489
|
+
)
|
|
490
|
+
wrap_function_wrapper(
|
|
491
|
+
client,
|
|
492
|
+
"pipeline",
|
|
493
|
+
_pipeline_wrapper,
|
|
494
|
+
)
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
class ValkeyInstrumentor(BaseInstrumentor):
|
|
498
|
+
@staticmethod
|
|
499
|
+
def _get_tracer(**kwargs):
|
|
500
|
+
tracer_provider = kwargs.get("tracer_provider")
|
|
501
|
+
return get_tracer(
|
|
502
|
+
__name__,
|
|
503
|
+
__version__,
|
|
504
|
+
tracer_provider=tracer_provider,
|
|
505
|
+
schema_url="https://opentelemetry.io/schemas/1.11.0",
|
|
506
|
+
)
|
|
507
|
+
|
|
508
|
+
def instrument(
|
|
509
|
+
self,
|
|
510
|
+
tracer_provider: TracerProvider | None = None,
|
|
511
|
+
request_hook: RequestHook | None = None,
|
|
512
|
+
response_hook: ResponseHook | None = None,
|
|
513
|
+
**kwargs,
|
|
514
|
+
):
|
|
515
|
+
"""Instruments all Valkey/StrictValkey/ValkeyCluster and async client instances.
|
|
516
|
+
|
|
517
|
+
Args:
|
|
518
|
+
tracer_provider: A TracerProvider, defaults to global.
|
|
519
|
+
request_hook:
|
|
520
|
+
a function with extra user-defined logic to run before performing the request.
|
|
521
|
+
|
|
522
|
+
The ``args`` is a tuple, where items are
|
|
523
|
+
command arguments. For example ``client.set("mykey", "value", ex=5)`` would
|
|
524
|
+
have ``args`` as ``('SET', 'mykey', 'value', 'EX', 5)``.
|
|
525
|
+
|
|
526
|
+
The ``kwargs`` represents occasional ``options`` passed by valkey. For example,
|
|
527
|
+
if you use ``client.set("mykey", "value", get=True)``, the ``kwargs`` would be
|
|
528
|
+
``{'get': True}``.
|
|
529
|
+
response_hook:
|
|
530
|
+
a function with extra user-defined logic to run after the request is complete.
|
|
531
|
+
|
|
532
|
+
The ``args`` represents the response.
|
|
533
|
+
"""
|
|
534
|
+
super().instrument(
|
|
535
|
+
tracer_provider=tracer_provider,
|
|
536
|
+
request_hook=request_hook,
|
|
537
|
+
response_hook=response_hook,
|
|
538
|
+
**kwargs,
|
|
539
|
+
)
|
|
540
|
+
|
|
541
|
+
def _instrument(self, **kwargs: Any):
|
|
542
|
+
"""Instruments the valkey module
|
|
543
|
+
|
|
544
|
+
Args:
|
|
545
|
+
**kwargs: Optional arguments
|
|
546
|
+
``tracer_provider``: a TracerProvider, defaults to global.
|
|
547
|
+
``request_hook``: An optional callback that is invoked right after a span is created.
|
|
548
|
+
``response_hook``: An optional callback which is invoked right before the span is finished processing a response.
|
|
549
|
+
"""
|
|
550
|
+
_instrument(
|
|
551
|
+
self._get_tracer(**kwargs),
|
|
552
|
+
request_hook=kwargs.get("request_hook"),
|
|
553
|
+
response_hook=kwargs.get("response_hook"),
|
|
554
|
+
)
|
|
555
|
+
|
|
556
|
+
def _uninstrument(self, **kwargs: Any):
|
|
557
|
+
if _CLIENT_BEFORE_V3:
|
|
558
|
+
unwrap(valkey.StrictValkey, "execute_command")
|
|
559
|
+
unwrap(valkey.StrictValkey, "pipeline")
|
|
560
|
+
unwrap(valkey.Valkey, "pipeline")
|
|
561
|
+
unwrap(
|
|
562
|
+
valkey.client.BasePipeline, # pylint:disable=no-member
|
|
563
|
+
"execute",
|
|
564
|
+
)
|
|
565
|
+
unwrap(
|
|
566
|
+
valkey.client.BasePipeline, # pylint:disable=no-member
|
|
567
|
+
"immediate_execute_command",
|
|
568
|
+
)
|
|
569
|
+
else:
|
|
570
|
+
unwrap(valkey.Valkey, "execute_command")
|
|
571
|
+
unwrap(valkey.Valkey, "pipeline")
|
|
572
|
+
unwrap(valkey.client.Pipeline, "execute")
|
|
573
|
+
unwrap(valkey.client.Pipeline, "immediate_execute_command")
|
|
574
|
+
if _CLIENT_CLUSTER_SUPPORT:
|
|
575
|
+
unwrap(valkey.cluster.ValkeyCluster, "execute_command")
|
|
576
|
+
unwrap(valkey.cluster.ClusterPipeline, "execute")
|
|
577
|
+
if _CLIENT_ASYNCIO_SUPPORT:
|
|
578
|
+
unwrap(valkey.asyncio.Valkey, "execute_command")
|
|
579
|
+
unwrap(valkey.asyncio.Valkey, "pipeline")
|
|
580
|
+
unwrap(valkey.asyncio.client.Pipeline, "execute")
|
|
581
|
+
unwrap(valkey.asyncio.client.Pipeline, "immediate_execute_command")
|
|
582
|
+
if _CLIENT_ASYNCIO_CLUSTER_SUPPORT:
|
|
583
|
+
unwrap(valkey.asyncio.cluster.ValkeyCluster, "execute_command")
|
|
584
|
+
unwrap(valkey.asyncio.cluster.ClusterPipeline, "execute")
|
|
585
|
+
|
|
586
|
+
@staticmethod
|
|
587
|
+
def instrument_client(
|
|
588
|
+
client: valkey.StrictValkey
|
|
589
|
+
| valkey.Valkey
|
|
590
|
+
| valkey.asyncio.Valkey
|
|
591
|
+
| valkey.cluster.ValkeyCluster
|
|
592
|
+
| valkey.asyncio.cluster.ValkeyCluster,
|
|
593
|
+
tracer_provider: TracerProvider | None = None,
|
|
594
|
+
request_hook: RequestHook | None = None,
|
|
595
|
+
response_hook: ResponseHook | None = None,
|
|
596
|
+
):
|
|
597
|
+
"""Instrument the provided Valkey Client. The client can be sync or async.
|
|
598
|
+
Cluster client is also supported.
|
|
599
|
+
|
|
600
|
+
Args:
|
|
601
|
+
client: The valkey client.
|
|
602
|
+
tracer_provider: A TracerProvider, defaults to global.
|
|
603
|
+
request_hook: a function with extra user-defined logic to run before
|
|
604
|
+
performing the request.
|
|
605
|
+
|
|
606
|
+
The ``args`` is a tuple, where items are
|
|
607
|
+
command arguments. For example ``client.set("mykey", "value", ex=5)`` would
|
|
608
|
+
have ``args`` as ``('SET', 'mykey', 'value', 'EX', 5)``.
|
|
609
|
+
|
|
610
|
+
The ``kwargs`` represents occasional ``options`` passed by valkey. For example,
|
|
611
|
+
if you use ``client.set("mykey", "value", get=True)``, the ``kwargs`` would be
|
|
612
|
+
``{'get': True}``.
|
|
613
|
+
|
|
614
|
+
response_hook: a function with extra user-defined logic to run after
|
|
615
|
+
the request is complete.
|
|
616
|
+
|
|
617
|
+
The ``args`` represents the response.
|
|
618
|
+
"""
|
|
619
|
+
if not hasattr(client, _INSTRUMENTATION_ATTR):
|
|
620
|
+
setattr(client, _INSTRUMENTATION_ATTR, False)
|
|
621
|
+
if not getattr(client, _INSTRUMENTATION_ATTR):
|
|
622
|
+
_instrument_client(
|
|
623
|
+
client,
|
|
624
|
+
ValkeyInstrumentor._get_tracer(tracer_provider=tracer_provider),
|
|
625
|
+
request_hook=request_hook,
|
|
626
|
+
response_hook=response_hook,
|
|
627
|
+
)
|
|
628
|
+
setattr(client, _INSTRUMENTATION_ATTR, True)
|
|
629
|
+
else:
|
|
630
|
+
_logger.warning(
|
|
631
|
+
"Attempting to instrument Valkey connection while already instrumented"
|
|
632
|
+
)
|
|
633
|
+
|
|
634
|
+
@staticmethod
|
|
635
|
+
def uninstrument_client(
|
|
636
|
+
client: valkey.StrictValkey
|
|
637
|
+
| valkey.Valkey
|
|
638
|
+
| valkey.asyncio.Valkey
|
|
639
|
+
| valkey.cluster.ValkeyCluster
|
|
640
|
+
| valkey.asyncio.cluster.ValkeyCluster,
|
|
641
|
+
):
|
|
642
|
+
"""Disables instrumentation for the given client instance
|
|
643
|
+
|
|
644
|
+
Args:
|
|
645
|
+
client: The valkey client
|
|
646
|
+
"""
|
|
647
|
+
if getattr(client, _INSTRUMENTATION_ATTR):
|
|
648
|
+
# for all clients we need to unwrap execute_command and pipeline functions
|
|
649
|
+
unwrap(client, "execute_command")
|
|
650
|
+
# the method was creating a pipeline and wrapping the functions of the
|
|
651
|
+
# created instance. any pipelines created before un-instrumenting will
|
|
652
|
+
# remain instrumented (pipelines should usually have a short span)
|
|
653
|
+
unwrap(client, "pipeline")
|
|
654
|
+
else:
|
|
655
|
+
_logger.warning(
|
|
656
|
+
"Attempting to un-instrument Valkey connection that wasn't instrumented"
|
|
657
|
+
)
|
|
658
|
+
return
|
|
659
|
+
|
|
660
|
+
def instrumentation_dependencies(self) -> Collection[str]:
|
|
661
|
+
"""Return a list of python packages with versions that the will be instrumented."""
|
|
662
|
+
return _instruments
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Copyright The OpenTelemetry Authors
|
|
2
|
+
# Copyright 2025 Philip Meier
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
from typing import Any, Callable, TypeVar
|
|
19
|
+
|
|
20
|
+
import valkey.asyncio.client
|
|
21
|
+
import valkey.asyncio.cluster
|
|
22
|
+
import valkey.client
|
|
23
|
+
import valkey.cluster
|
|
24
|
+
import valkey.connection
|
|
25
|
+
|
|
26
|
+
from opentelemetry.trace import Span
|
|
27
|
+
|
|
28
|
+
RequestHook = Callable[
|
|
29
|
+
[Span, valkey.connection.Connection, list[Any], dict[str, Any]], None
|
|
30
|
+
]
|
|
31
|
+
ResponseHook = Callable[[Span, valkey.connection.Connection, Any], None]
|
|
32
|
+
|
|
33
|
+
AsyncPipelineInstance = TypeVar(
|
|
34
|
+
"AsyncPipelineInstance",
|
|
35
|
+
valkey.asyncio.client.Pipeline,
|
|
36
|
+
valkey.asyncio.cluster.ClusterPipeline,
|
|
37
|
+
)
|
|
38
|
+
AsyncValkeyInstance = TypeVar(
|
|
39
|
+
"AsyncValkeyInstance", valkey.asyncio.Valkey, valkey.asyncio.ValkeyCluster
|
|
40
|
+
)
|
|
41
|
+
PipelineInstance = TypeVar(
|
|
42
|
+
"PipelineInstance",
|
|
43
|
+
valkey.client.Pipeline,
|
|
44
|
+
valkey.cluster.ClusterPipeline,
|
|
45
|
+
)
|
|
46
|
+
ValkeyInstance = TypeVar(
|
|
47
|
+
"ValkeyInstance", valkey.client.Valkey, valkey.cluster.ValkeyCluster
|
|
48
|
+
)
|
|
49
|
+
R = TypeVar("R")
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Copyright The OpenTelemetry Authors
|
|
2
|
+
# Copyright 2025 Philip Meier
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
|
|
16
|
+
_instruments = ("valkey >= 6.1.0",)
|
|
File without changes
|
opentelemetry_python_contrib_external_valkey-0.59b0/src/opentelemetry/instrumentation/valkey/util.py
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# Copyright The OpenTelemetry Authors
|
|
2
|
+
# Copyright 2025 Philip Meier
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
|
|
16
|
+
"""
|
|
17
|
+
Some utils used by the valkey integration
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
from typing import TYPE_CHECKING, Any
|
|
23
|
+
|
|
24
|
+
from opentelemetry.semconv._incubating.attributes.db_attributes import (
|
|
25
|
+
DB_REDIS_DATABASE_INDEX,
|
|
26
|
+
DB_SYSTEM,
|
|
27
|
+
)
|
|
28
|
+
from opentelemetry.semconv._incubating.attributes.net_attributes import (
|
|
29
|
+
NET_PEER_NAME,
|
|
30
|
+
NET_PEER_PORT,
|
|
31
|
+
NET_TRANSPORT,
|
|
32
|
+
)
|
|
33
|
+
from opentelemetry.semconv.trace import (
|
|
34
|
+
DbSystemValues,
|
|
35
|
+
NetTransportValues,
|
|
36
|
+
)
|
|
37
|
+
from opentelemetry.trace import Span
|
|
38
|
+
|
|
39
|
+
if TYPE_CHECKING:
|
|
40
|
+
from opentelemetry.instrumentation.valkey.custom_types import (
|
|
41
|
+
AsyncPipelineInstance,
|
|
42
|
+
AsyncValkeyInstance,
|
|
43
|
+
PipelineInstance,
|
|
44
|
+
ValkeyInstance,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
_FIELD_TYPES = ["NUMERIC", "TEXT", "GEO", "TAG", "VECTOR"]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _extract_conn_attributes(conn_kwargs):
|
|
51
|
+
"""Transform valkey conn info into dict"""
|
|
52
|
+
attributes = {
|
|
53
|
+
DB_SYSTEM: DbSystemValues.REDIS.value,
|
|
54
|
+
}
|
|
55
|
+
db = conn_kwargs.get("db", 0)
|
|
56
|
+
attributes[DB_REDIS_DATABASE_INDEX] = db
|
|
57
|
+
if "path" in conn_kwargs:
|
|
58
|
+
attributes[NET_PEER_NAME] = conn_kwargs.get("path", "")
|
|
59
|
+
attributes[NET_TRANSPORT] = NetTransportValues.OTHER.value
|
|
60
|
+
else:
|
|
61
|
+
attributes[NET_PEER_NAME] = conn_kwargs.get("host", "localhost")
|
|
62
|
+
attributes[NET_PEER_PORT] = conn_kwargs.get("port", 6379)
|
|
63
|
+
attributes[NET_TRANSPORT] = NetTransportValues.IP_TCP.value
|
|
64
|
+
|
|
65
|
+
return attributes
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def _format_command_args(args: list[str]):
|
|
69
|
+
"""Format and sanitize command arguments, and trim them as needed"""
|
|
70
|
+
cmd_max_len = 1000
|
|
71
|
+
value_too_long_mark = "..."
|
|
72
|
+
|
|
73
|
+
# Sanitized query format: "COMMAND ? ?"
|
|
74
|
+
args_length = len(args)
|
|
75
|
+
if args_length > 0:
|
|
76
|
+
out = [str(args[0])] + ["?"] * (args_length - 1)
|
|
77
|
+
out_str = " ".join(out)
|
|
78
|
+
|
|
79
|
+
if len(out_str) > cmd_max_len:
|
|
80
|
+
out_str = (
|
|
81
|
+
out_str[: cmd_max_len - len(value_too_long_mark)]
|
|
82
|
+
+ value_too_long_mark
|
|
83
|
+
)
|
|
84
|
+
else:
|
|
85
|
+
out_str = ""
|
|
86
|
+
|
|
87
|
+
return out_str
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def _set_span_attribute_if_value(span, name, value):
|
|
91
|
+
if value is not None and value != "":
|
|
92
|
+
span.set_attribute(name, value)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def _value_or_none(values, n):
|
|
96
|
+
try:
|
|
97
|
+
return values[n]
|
|
98
|
+
except IndexError:
|
|
99
|
+
return None
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def _set_connection_attributes(
|
|
103
|
+
span: Span, conn: ValkeyInstance | AsyncValkeyInstance
|
|
104
|
+
) -> None:
|
|
105
|
+
if not span.is_recording() or not hasattr(conn, "connection_pool"):
|
|
106
|
+
return
|
|
107
|
+
for key, value in _extract_conn_attributes(
|
|
108
|
+
conn.connection_pool.connection_kwargs
|
|
109
|
+
).items():
|
|
110
|
+
span.set_attribute(key, value)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def _build_span_name(
|
|
114
|
+
instance: ValkeyInstance | AsyncValkeyInstance, cmd_args: tuple[Any, ...]
|
|
115
|
+
) -> str:
|
|
116
|
+
if len(cmd_args) > 0 and cmd_args[0]:
|
|
117
|
+
if cmd_args[0] == "FT.SEARCH":
|
|
118
|
+
name = "valkey.search"
|
|
119
|
+
elif cmd_args[0] == "FT.CREATE":
|
|
120
|
+
name = "valkey.create_index"
|
|
121
|
+
else:
|
|
122
|
+
name = cmd_args[0]
|
|
123
|
+
else:
|
|
124
|
+
name = instance.connection_pool.connection_kwargs.get("db", 0)
|
|
125
|
+
return name
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def _add_create_attributes(span: Span, args: tuple[Any, ...]):
|
|
129
|
+
_set_span_attribute_if_value(
|
|
130
|
+
span, "valkey.create_index.index", _value_or_none(args, 1)
|
|
131
|
+
)
|
|
132
|
+
# According to: https://github.com/valkey/valkey-py/blob/master/valkey/commands/search/commands.py#L155 schema is last argument for execute command
|
|
133
|
+
try:
|
|
134
|
+
schema_index = args.index("SCHEMA")
|
|
135
|
+
except ValueError:
|
|
136
|
+
return
|
|
137
|
+
schema = args[schema_index:]
|
|
138
|
+
field_attribute = ""
|
|
139
|
+
# Schema in format:
|
|
140
|
+
# [first_field_name, first_field_type, first_field_some_attribute1, first_field_some_attribute2, second_field_name, ...]
|
|
141
|
+
field_attribute = "".join(
|
|
142
|
+
f"Field(name: {schema[index - 1]}, type: {schema[index]});"
|
|
143
|
+
for index in range(1, len(schema))
|
|
144
|
+
if schema[index] in _FIELD_TYPES
|
|
145
|
+
)
|
|
146
|
+
_set_span_attribute_if_value(
|
|
147
|
+
span,
|
|
148
|
+
"valkey.create_index.fields",
|
|
149
|
+
field_attribute,
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def _add_search_attributes(span: Span, response, args):
|
|
154
|
+
_set_span_attribute_if_value(
|
|
155
|
+
span, "valkey.search.index", _value_or_none(args, 1)
|
|
156
|
+
)
|
|
157
|
+
_set_span_attribute_if_value(
|
|
158
|
+
span, "valkey.search.query", _value_or_none(args, 2)
|
|
159
|
+
)
|
|
160
|
+
# Parse response from search
|
|
161
|
+
# https://valkey.io/docs/latest/commands/ft.search/
|
|
162
|
+
# Response in format:
|
|
163
|
+
# [number_of_returned_documents, index_of_first_returned_doc, first_doc(as a list), index_of_second_returned_doc, second_doc(as a list) ...]
|
|
164
|
+
# Returned documents in array format:
|
|
165
|
+
# [first_field_name, first_field_value, second_field_name, second_field_value ...]
|
|
166
|
+
number_of_returned_documents = _value_or_none(response, 0)
|
|
167
|
+
_set_span_attribute_if_value(
|
|
168
|
+
span, "valkey.search.total", number_of_returned_documents
|
|
169
|
+
)
|
|
170
|
+
if "NOCONTENT" in args or not number_of_returned_documents:
|
|
171
|
+
return
|
|
172
|
+
for document_number in range(number_of_returned_documents):
|
|
173
|
+
document_index = _value_or_none(response, 1 + 2 * document_number)
|
|
174
|
+
if document_index:
|
|
175
|
+
document = response[2 + 2 * document_number]
|
|
176
|
+
for attribute_name_index in range(0, len(document), 2):
|
|
177
|
+
_set_span_attribute_if_value(
|
|
178
|
+
span,
|
|
179
|
+
f"valkey.search.xdoc_{document_index}.{document[attribute_name_index]}",
|
|
180
|
+
document[attribute_name_index + 1],
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def _build_span_meta_data_for_pipeline(
|
|
185
|
+
instance: PipelineInstance | AsyncPipelineInstance,
|
|
186
|
+
) -> tuple[list[Any], str, str]:
|
|
187
|
+
try:
|
|
188
|
+
command_stack = (
|
|
189
|
+
instance.command_stack
|
|
190
|
+
if hasattr(instance, "command_stack")
|
|
191
|
+
else instance._command_stack
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
cmds = [
|
|
195
|
+
_format_command_args(c.args if hasattr(c, "args") else c[0])
|
|
196
|
+
for c in command_stack
|
|
197
|
+
]
|
|
198
|
+
resource = "\n".join(cmds)
|
|
199
|
+
|
|
200
|
+
span_name = " ".join(
|
|
201
|
+
[
|
|
202
|
+
(c.args[0] if hasattr(c, "args") else c[0][0])
|
|
203
|
+
for c in command_stack
|
|
204
|
+
]
|
|
205
|
+
)
|
|
206
|
+
except (AttributeError, IndexError):
|
|
207
|
+
command_stack = []
|
|
208
|
+
resource = ""
|
|
209
|
+
span_name = ""
|
|
210
|
+
|
|
211
|
+
return command_stack, resource, span_name
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Copyright The OpenTelemetry Authors
|
|
2
|
+
# Copyright 2025 Philip Meier
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
|
|
16
|
+
__version__ = "0.59b0"
|