Skip to content

Commit 74f2159

Browse files
authored
docs: Docs for Pyramid and SQLite3 (open-telemetry#806)
Adding missing documentation for Pyramid and SQLite3
1 parent ca232c9 commit 74f2159

File tree

4 files changed

+36
-14
lines changed

4 files changed

+36
-14
lines changed

docs-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ prometheus_client>=0.5.0,<1.0.0
1616
psycopg2-binary>=2.7.3.1
1717
pymemcache~=1.3
1818
pymongo~=3.1
19+
pyramid>=1.7
1920
redis>=2.6
2021
sqlalchemy>=1.0
2122
thrift>=0.10.0

docs/ext/pyramid/pyramid.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
OpenTelemetry Pyramid Integration
2+
=================================
3+
4+
.. automodule:: opentelemetry.ext.pyramid
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:

docs/ext/sqlite3/sqlite3.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
OpenTelemetry SQLite3 Integration
2+
=================================
3+
4+
.. automodule:: opentelemetry.ext.sqlite3
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:

ext/opentelemetry-ext-pyramid/src/opentelemetry/ext/pyramid/__init__.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@
2020
2121
Usage
2222
-----
23-
There are two methods to instrument Pyramid:
23+
There are two methods to instrument Pyramid:
2424
2525
Method 1 (Instrument all Configurators):
2626
----------------------------------------
27+
2728
.. code:: python
2829
2930
from pyramid.config import Configurator
3031
from opentelemetry.ext.pyramid import PyramidInstrumentor
3132
32-
PyramidInstrumentor.instrument()
33+
PyramidInstrumentor().instrument()
3334
3435
config = Configurator()
3536
@@ -38,6 +39,7 @@
3839
3940
Method 2 (Instrument one Configurator):
4041
---------------------------------------
42+
4143
.. code:: python
4244
4345
from pyramid.config import Configurator
@@ -49,22 +51,30 @@
4951
# use your config as normal
5052
config.add_route('index', '/')
5153
52-
Using ``pyramid.tweens`` settings:
53-
----------------------------------
54-
If you use Method 2 and then set tweens for your application with the ``pyramid.tweens`` setting,
55-
you need to add ``opentelemetry.ext.pyramid.trace_tween_factory`` explicity to the list,
56-
*as well as* instrumenting the config with `PyramidInstrumentor().instrument_config(config)`.
54+
Using ``pyramid.tweens`` setting:
55+
---------------------------------
56+
57+
If you use Method 2 and then set tweens for your application with the ``pyramid.tweens`` setting,
58+
you need to add ``opentelemetry.ext.pyramid.trace_tween_factory`` explicity to the list,
59+
*as well as* instrumenting the config as shown above.
60+
61+
For example:
5762
58-
For example:
5963
.. code:: python
64+
65+
from pyramid.config import Configurator
66+
from opentelemetry.ext.pyramid import PyramidInstrumentor
67+
6068
settings = {
6169
'pyramid.tweens', 'opentelemetry.ext.pyramid.trace_tween_factory\\nyour_tween_no_1\\nyour_tween_no_2',
6270
}
6371
config = Configurator(settings=settings)
64-
PyramidInstrumentor.instrument_config(config)
72+
PyramidInstrumentor().instrument_config(config)
6573
6674
# use your config as normal.
6775
config.add_route('index', '/')
76+
77+
API
6878
---
6979
"""
7080

@@ -87,7 +97,7 @@
8797
from opentelemetry.trace import TracerProvider, get_tracer
8898

8999

90-
def traced_init(wrapped, instance, args, kwargs):
100+
def _traced_init(wrapped, instance, args, kwargs):
91101
settings = kwargs.get("settings", {})
92102
tweens = aslist(settings.get("pyramid.tweens", []))
93103

@@ -119,7 +129,7 @@ def _instrument(self, **kwargs):
119129
"""Integrate with Pyramid Python library.
120130
https://docs.pylonsproject.org/projects/pyramid/en/latest/
121131
"""
122-
_wrap("pyramid.config", "Configurator.__init__", traced_init)
132+
_wrap("pyramid.config", "Configurator.__init__", _traced_init)
123133

124134
def _uninstrument(self, **kwargs):
125135
""""Disable Pyramid instrumentation"""
@@ -131,9 +141,6 @@ def instrument_config(self, config):
131141
132142
Args:
133143
config: The Configurator to instrument.
134-
135-
Returns:
136-
An instrumented Configurator.
137144
"""
138145
config.include("opentelemetry.ext.pyramid.callbacks")
139146

0 commit comments

Comments
 (0)