1
1
import React from 'react' ;
2
+ import styled from 'react-emotion' ;
2
3
import get from 'lodash/get' ;
3
4
4
5
import { Event } from 'app/types' ;
@@ -7,11 +8,15 @@ import {
7
8
SpanEntry ,
8
9
SpanType ,
9
10
} from 'app/components/events/interfaces/spans/types' ;
11
+ import { pickSpanBarColour } from 'app/components/events/interfaces/spans/utils' ;
10
12
import { TraceContextType } from 'app/components/events/interfaces/spans/traceView' ;
13
+ import { t } from 'app/locale' ;
14
+ import space from 'app/styles/space' ;
15
+ import { SectionHeading } from '../../styles' ;
11
16
12
17
type OpStats = { percentage : number ; totalDuration : number } ;
13
18
14
- const TOP_N_SPANS = 3 ;
19
+ const TOP_N_SPANS = 4 ;
15
20
16
21
type EventBreakdownType = {
17
22
// top TOP_N_SPANS spans
@@ -157,11 +162,68 @@ class EventBreakdown extends React.Component<Props> {
157
162
return null ;
158
163
}
159
164
160
- // TODO: Dora to take over
161
- // const results = this.generateCounts();
162
-
163
- return null ;
165
+ const results = this . generateStats ( ) ;
166
+
167
+ return (
168
+ < StyledBreakdown >
169
+ < SectionHeading > { t ( 'Ops Breakdown' ) } </ SectionHeading >
170
+ { results . ops . map ( currOp => {
171
+ const { name, percentage, totalDuration} = currOp ;
172
+ const durLabel = Math . round ( totalDuration * 1000 * 100 ) / 100 ;
173
+ const pctLabel = Math . round ( percentage * 100 ) ;
174
+ const opsColor : string = pickSpanBarColour ( name ) ;
175
+
176
+ return (
177
+ < OpsLine key = { name } >
178
+ < OpsContent >
179
+ < OpsDot style = { { backgroundColor : opsColor } } />
180
+ < div > { name } </ div >
181
+ </ OpsContent >
182
+ < OpsContent >
183
+ < Dur > { durLabel } ms</ Dur >
184
+ < Pct > { pctLabel } %</ Pct >
185
+ </ OpsContent >
186
+ </ OpsLine >
187
+ ) ;
188
+ } ) }
189
+ </ StyledBreakdown >
190
+ ) ;
164
191
}
165
192
}
166
193
194
+ const StyledBreakdown = styled ( 'div' ) `
195
+ color: ${ p => p . theme . gray3 } ;
196
+ font-size: ${ p => p . theme . fontSizeMedium } ;
197
+ margin-bottom: ${ space ( 4 ) } ;
198
+ ` ;
199
+
200
+ const OpsLine = styled ( 'div' ) `
201
+ display: flex;
202
+ justify-content: space-between;
203
+ margin-bottom: ${ space ( 0.5 ) } ;
204
+ ` ;
205
+
206
+ const OpsDot = styled ( 'div' ) `
207
+ content: '';
208
+ display: block;
209
+ width: 8px;
210
+ height: 8px;
211
+ margin-right: ${ space ( 1 ) } ;
212
+ border-radius: 100%;
213
+ ` ;
214
+
215
+ const OpsContent = styled ( 'div' ) `
216
+ display: flex;
217
+ align-items: center;
218
+ ` ;
219
+
220
+ const Dur = styled ( 'div' ) `
221
+ color: ${ p => p . theme . gray2 } ;
222
+ ` ;
223
+
224
+ const Pct = styled ( 'div' ) `
225
+ min-width: 40px;
226
+ text-align: right;
227
+ ` ;
228
+
167
229
export default EventBreakdown ;
0 commit comments