-
Notifications
You must be signed in to change notification settings - Fork 0
/
stats.lua
176 lines (139 loc) · 4.13 KB
/
stats.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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
--[[
Copyright © 2015 Dynatrace LLC.
All rights reserved.
Unpublished rights reserved under the Copyright Laws of the United States.
U.S. GOVERNMENT RIGHTS-Use, duplication, or disclosure by the U.S. Government is
subject to restrictions as set forth in Dynatrace LLC license agreement and as
provided in DFARS 227.7202-1(a) and 227.7202-3(a) (1995), DFARS
252.227-7013(c)(1)(ii) (OCT 1988), FAR 12.212 (a) (1995), FAR 52.227-19,
or FAR 52.227-14 (ALT III), as applicable.
This product contains confidential information and trade secrets of Dynatrace LLC.
Disclosure is prohibited without the prior express written permission of Dynatrace LLC.
Use of this product is subject to the terms and conditions of the user's License Agreement with Dynatrace LLC.
See the license agreement text online at https://community.dynatrace.com/community/download/attachments/5144912/dynaTraceBSD.txt?version=3&modificationDate=1441261477160&api=v2
--]]
--[[
This is mock class that pretends IPayloadParserResult interface.
It is used in parser tests written in Lua.
--]]
local Stats = {}
Stats.__index = Stats
setmetatable(Stats, {
__call = function (cls, ...)
return cls.new(...)
end,
})
function Stats.new()
local self = setmetatable({}, Stats)
self.operation_name = nil
self.parameters = {}
self.appl_errors = {}
self.metrics = {}
self.corr_id = nil
self.username = nil
self.os_name = nil
self.hardware = nil
self.browser = nil
self.browser_version = nil
self.bucket_id = nil
self.isFirstTransHit = true
self.isLastTransHit = true
self.isMonitor = true
return self
end
-- operation name ------------------------------------
function Stats:getOperationName()
return self.operation_name
end
function Stats:setOperationName(name, len)
if len == nil then
error("'len' parameter is obligatory")
end
self.operation_name = name:sub(1, len)
end
-- parameters ----------------------------------------
function Stats:getParameter(id)
return self.parameters[id]
end
function Stats:setParameter(id, value)
self.parameters[id] = value
end
-- attributes ----------------------------------------
function Stats:getAttribute(id)
return self.appl_errors[id]
end
function Stats:setAttribute(id, value)
self.appl_errors[id] = value
end
-- metrics -------------------------------------------
function Stats:getMetric(id)
return self.metrics[id]
end
function Stats:setMetric(id, value)
self.metrics[id] = value
end
-- browser / os / hardware ---------------------------
function Stats:getBrowser()
return self.browser
end
function Stats:getBrowserVersion()
return self.browser_version
end
function Stats:getOs()
return self.os_name
end
function Stats:getHardware()
return self.hardware
end
function Stats:setBrowserOsHardware(browserName, browserVersion, osName, hardwareName)
self.hardware = hardwareName
self.os_name = osName
self.browser_version = browserVersion
self.browser = browserName
end
-- user name -----------------------------------------
function Stats:getUserName()
return self.username
end
function Stats:setUserName(name)
self.username = name
end
-- correlation id ------------------------------------
function Stats:getCorrelationId()
return self.corr_id
end
function Stats:setCorrelationId(id)
self.corr_id = id
end
-- transport error -----------------------------------
function Stats:getTransportError()
return self.bucket_id
end
function Stats:setTransportError(bucket_id)
self.bucket_id = bucket_id
end
-- dictionary ----------------------------------------
function Stats:getDictText(text, len)
return {false, nil, nil}
end
-- hits -> transactions flags ------------------------
function Stats:isFirstTransHit()
return self.isFirstTransHit
end
function Stats:setFirstTransHit(isFirstTransHit)
self.first_hit = isFirstTransHit
end
function Stats:isLastTransHit()
return self.isLastTransHit
end
function Stats:setLastTransHit(isLastTransHit)
self.last_hit = isLastTransHit
end
-- per operation reporting and auto-learning ---------
function Stats:isMonitored()
return self.isMonitor
end
function Stats:setMonitored(flag)
self.isMonitor = flag
end
return Stats