Running Traces
tabular_tracing.py
handles all tracing capabilities in your model.
It also includes some pre built traces to make life easier. Feel free to build your own.
Example
import pytabular as p
import logging as l
model = p.Tabular(CONNECTION_STR)
query_trace = p.QueryMonitor(model)
query_trace.start() # (1)
###
p.logger.setLevel(l.DEBUG) # (2)
###
query_trace.stop()
query_trace.drop() # (3)
- You will now start to see query traces on your model get outputed to your console.
- If you want to see the FULL query then set logging to DEBUG.
- You can drop on your own, or will get dropped on script exit.
BaseTrace
Generates trace to be run on Server.
This is the base class to customize the type of Trace you are looking for. It's recommended to use the out of the box traces built. It's on the roadmap to have an intuitive way to build traces for users.
Source code in pytabular/tabular_tracing.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
|
__init__(tabular_class, trace_events, trace_event_columns, handler)
This will build()
, add()
, and update()
the trace to model.
It will also register the dropping on the trace on exiting python.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tabular_class |
Tabular
|
The model you want the trace for. |
required |
trace_events |
List[TraceEvent]
|
The TraceEvents you want have in your trace. From Microsoft.AnalysisServices.TraceEventClass. |
required |
trace_event_columns |
List[TraceColumn]
|
The trace event columns you want in your trace. From Microsoft.AnalysisServices.TraceColumn. |
required |
handler |
Callable
|
The |
required |
Source code in pytabular/tabular_tracing.py
build()
Run on init.
This will take the inputed arguments for the class and attempt to build the Trace.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if successful |
Source code in pytabular/tabular_tracing.py
add()
Runs on init. Adds built trace to the Server.
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
Return int of placement in Server.Traces.get_Item(int). |
Source code in pytabular/tabular_tracing.py
update()
Runs on init. Syncs with Server.
Returns:
Name | Type | Description |
---|---|---|
None |
None
|
Returns None. Unless unsuccessful then it will return the error from Server. |
Source code in pytabular/tabular_tracing.py
start()
Call when you want to start the trace.
Returns:
Name | Type | Description |
---|---|---|
None |
None
|
Returns None. Unless unsuccessful then it will return the error from Server. |
Source code in pytabular/tabular_tracing.py
stop()
Call when you want to stop the trace.
Returns:
Name | Type | Description |
---|---|---|
None |
None
|
Returns None. Unless unsuccessful then it will return the error from Server. |
Source code in pytabular/tabular_tracing.py
drop()
Call when you want to drop the trace.
Returns:
Name | Type | Description |
---|---|---|
None |
None
|
Returns None. Unless unsuccessful, then it will return the error from Server. |
Source code in pytabular/tabular_tracing.py
RefreshTrace
Bases: BaseTrace
Subclass of BaseTrace()
. Usefull for monitoring refreshes.
This is the default trace that is run on refreshes.
It will output all the various details into logger()
.
See _refresh_handler()
for more details on what gets
put into logger()
.
Source code in pytabular/tabular_tracing.py
__init__(tabular_class, trace_events=[TraceEventClass.ProgressReportBegin, TraceEventClass.ProgressReportCurrent, TraceEventClass.ProgressReportEnd, TraceEventClass.ProgressReportError], trace_event_columns=[TraceColumn.EventSubclass, TraceColumn.CurrentTime, TraceColumn.ObjectName, TraceColumn.ObjectPath, TraceColumn.DatabaseName, TraceColumn.SessionID, TraceColumn.TextData, TraceColumn.EventClass, TraceColumn.ProgressTotal], handler=_refresh_handler)
Init will extend through BaseTrace()
. But pass through specific params.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tabular_class |
Tabular
|
This is your |
required |
trace_events |
List[TraceEvent]
|
Defaults to [ TraceEventClass.ProgressReportBegin, TraceEventClass.ProgressReportCurrent, TraceEventClass.ProgressReportEnd, TraceEventClass.ProgressReportError, ]. |
[ProgressReportBegin, ProgressReportCurrent, ProgressReportEnd, ProgressReportError]
|
trace_event_columns |
List[TraceColumn]
|
Defaults to [ TraceColumn.EventSubclass, TraceColumn.CurrentTime, TraceColumn.ObjectName, TraceColumn.ObjectPath, TraceColumn.DatabaseName, TraceColumn.SessionID, TraceColumn.TextData, TraceColumn.EventClass, TraceColumn.ProgressTotal, ]. |
[EventSubclass, CurrentTime, ObjectName, ObjectPath, DatabaseName, SessionID, TextData, EventClass, ProgressTotal]
|
handler |
Callable
|
description. Defaults to _refresh_handler. |
_refresh_handler
|
Source code in pytabular/tabular_tracing.py
QueryMonitor
Bases: BaseTrace
Subclass of BaseTrace()
. Usefull for monitoring queries.
The default handler for QueryMonitor()
shows full query in logger.debug()
.
So you will need to set your logger to debug()
if you would like to see them.
Otherwise, will show basic info on who/what is querying.
Source code in pytabular/tabular_tracing.py
__init__(tabular_class, trace_events=[TraceEventClass.QueryEnd], trace_event_columns=[TraceColumn.EventSubclass, TraceColumn.StartTime, TraceColumn.EndTime, TraceColumn.Duration, TraceColumn.Severity, TraceColumn.Error, TraceColumn.NTUserName, TraceColumn.DatabaseName, TraceColumn.ApplicationName, TraceColumn.TextData], handler=_query_monitor_handler)
Init will extend through to BaseTrace, but pass through specific params.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tabular_class |
Tabular
|
This is your |
required |
trace_events |
List[TraceEvent]
|
Defaults to [TraceEventClass.QueryEnd]. |
[QueryEnd]
|
trace_event_columns |
List[TraceColumn]
|
Defaults to [ TraceColumn.EventSubclass, TraceColumn.StartTime, TraceColumn.EndTime, TraceColumn.Duration, TraceColumn.Severity, TraceColumn.Error, TraceColumn.NTUserName, TraceColumn.DatabaseName, TraceColumn.ApplicationName, TraceColumn.TextData, ]. |
[EventSubclass, StartTime, EndTime, Duration, Severity, Error, NTUserName, DatabaseName, ApplicationName, TextData]
|
handler |
Callable
|
Defaults to |
_query_monitor_handler
|