24
24
25
25
26
26
class BaseInstrumentor (ABC ):
27
- """An ABC for instrumentors"""
27
+ """An ABC for instrumentors
28
+
29
+ Child classes of this ABC should instrument specific third
30
+ party libraries or frameworks either by using the
31
+ ``opentelemetry-auto-instrumentation`` command or by calling their methods
32
+ directly.
33
+
34
+ Since every third party library or framework is different and has different
35
+ instrumentation needs, more methods can be added to the child classes as
36
+ needed to provide practical instrumentation to the end user.
37
+ """
28
38
29
39
_instance = None
30
40
_is_instrumented = False
@@ -38,14 +48,30 @@ def __new__(cls):
38
48
39
49
@abstractmethod
40
50
def _instrument (self , ** kwargs ):
41
- """Instrument"""
51
+ """Instrument the library """
42
52
43
53
@abstractmethod
44
54
def _uninstrument (self , ** kwargs ):
45
- """Uninstrument"""
55
+ """Uninstrument the library """
46
56
47
57
def instrument (self , ** kwargs ):
48
- """Instrument"""
58
+ """Instrument the library
59
+
60
+ This method will be called without any optional arguments by the
61
+ ``opentelemetry-auto-instrumentation`` command. The configuration of
62
+ the instrumentation when done in this way should be done by previously
63
+ setting the configuration (using environment variables or any other
64
+ mechanism) that will be used later by the code in the ``instrument``
65
+ implementation via the global ``Configuration`` object.
66
+
67
+ The ``instrument`` methods ``kwargs`` should default to values from the
68
+ ``Configuration`` object.
69
+
70
+ This means that calling this method directly without passing any
71
+ optional values should do the very same thing that the
72
+ ``opentelemetry-auto-instrumentation`` command does. This approach is
73
+ followed because the ``Configuration`` object is immutable.
74
+ """
49
75
50
76
if not self ._is_instrumented :
51
77
result = self ._instrument (** kwargs )
@@ -57,7 +83,11 @@ def instrument(self, **kwargs):
57
83
return None
58
84
59
85
def uninstrument (self , ** kwargs ):
60
- """Uninstrument"""
86
+ """Uninstrument the library
87
+
88
+ See ``BaseInstrumentor.instrument`` for more information regarding the
89
+ usage of ``kwargs``.
90
+ """
61
91
62
92
if self ._is_instrumented :
63
93
result = self ._uninstrument (** kwargs )
0 commit comments