Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
271cc670
Unverified
Commit
271cc670
authored
Jun 24, 2020
by
Zoltán Bedi
Committed by
GitHub
Jun 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Data: Prefix trace types in data package (#25810)
parent
615b000a
Hide whitespace changes
Inline
Side-by-side
Showing
35 changed files
with
167 additions
and
164 deletions
+167
-164
packages/grafana-data/src/types/trace.ts
+20
-20
packages/jaeger-ui-components/src/ScrollManager.tsx
+11
-11
packages/jaeger-ui-components/src/TracePageHeader/SpanGraph/index.tsx
+2
-2
packages/jaeger-ui-components/src/TraceTimelineViewer/ReferencesButton.tsx
+3
-3
packages/jaeger-ui-components/src/TraceTimelineViewer/SpanBar.tsx
+2
-2
packages/jaeger-ui-components/src/TraceTimelineViewer/SpanBarRow.tsx
+2
-2
packages/jaeger-ui-components/src/TraceTimelineViewer/SpanDetail/AccordianKeyValues.tsx
+4
-4
packages/jaeger-ui-components/src/TraceTimelineViewer/SpanDetail/AccordianLogs.tsx
+5
-5
packages/jaeger-ui-components/src/TraceTimelineViewer/SpanDetail/AccordianReferences.tsx
+3
-3
packages/jaeger-ui-components/src/TraceTimelineViewer/SpanDetail/DetailState.tsx
+3
-3
packages/jaeger-ui-components/src/TraceTimelineViewer/SpanDetail/KeyValuesTable.tsx
+4
-4
packages/jaeger-ui-components/src/TraceTimelineViewer/SpanDetail/index.tsx
+4
-4
packages/jaeger-ui-components/src/TraceTimelineViewer/SpanDetailRow.tsx
+5
-5
packages/jaeger-ui-components/src/TraceTimelineViewer/SpanTreeOffset.tsx
+2
-2
packages/jaeger-ui-components/src/TraceTimelineViewer/VirtualizedTraceView.tsx
+7
-7
packages/jaeger-ui-components/src/TraceTimelineViewer/index.tsx
+6
-6
packages/jaeger-ui-components/src/TraceTimelineViewer/utils.tsx
+6
-6
packages/jaeger-ui-components/src/model/link-patterns.tsx
+8
-8
packages/jaeger-ui-components/src/model/span.tsx
+4
-4
packages/jaeger-ui-components/src/model/trace-viewer.ts
+2
-2
packages/jaeger-ui-components/src/model/transform-trace-data.tsx
+11
-11
packages/jaeger-ui-components/src/url/ReferenceLink.tsx
+2
-2
packages/jaeger-ui-components/src/utils/filter-spans.tsx
+5
-5
packages/jaeger-ui-components/src/utils/span-ancestor-ids.tsx
+3
-3
public/app/features/explore/TraceView/TraceView.test.tsx
+2
-2
public/app/features/explore/TraceView/TraceView.tsx
+6
-3
public/app/features/explore/TraceView/useChildrenState.test.ts
+5
-5
public/app/features/explore/TraceView/useChildrenState.ts
+6
-6
public/app/features/explore/TraceView/useDetailState.test.ts
+2
-2
public/app/features/explore/TraceView/useDetailState.ts
+2
-2
public/app/features/explore/TraceView/useSearch.test.ts
+3
-3
public/app/features/explore/TraceView/useSearch.ts
+2
-2
public/app/plugins/datasource/jaeger/QueryField.tsx
+3
-3
public/app/plugins/datasource/zipkin/utils/testData.ts
+2
-2
public/app/plugins/datasource/zipkin/utils/transforms.ts
+10
-10
No files found.
packages/grafana-data/src/types/trace.ts
View file @
271cc670
...
...
@@ -17,62 +17,62 @@
*/
// TODO: Everett Tech Debt: Fix KeyValuePair types
export
type
KeyValuePair
=
{
export
type
Trace
KeyValuePair
=
{
key
:
string
;
type
?:
string
;
value
:
any
;
};
export
type
Link
=
{
export
type
Trace
Link
=
{
url
:
string
;
text
:
string
;
};
export
type
Log
=
{
export
type
Trace
Log
=
{
timestamp
:
number
;
fields
:
KeyValuePair
[];
fields
:
Trace
KeyValuePair
[];
};
export
type
Process
=
{
export
type
Trace
Process
=
{
serviceName
:
string
;
tags
:
KeyValuePair
[];
tags
:
Trace
KeyValuePair
[];
};
export
type
SpanReference
=
{
export
type
Trace
SpanReference
=
{
refType
:
'CHILD_OF'
|
'FOLLOWS_FROM'
;
// eslint-disable-next-line no-use-before-define
span
?:
Span
|
null
|
undefined
;
span
?:
Trace
Span
|
null
|
undefined
;
spanID
:
string
;
traceID
:
string
;
};
export
type
SpanData
=
{
export
type
Trace
SpanData
=
{
spanID
:
string
;
traceID
:
string
;
processID
:
string
;
operationName
:
string
;
startTime
:
number
;
duration
:
number
;
logs
:
Log
[];
tags
?:
KeyValuePair
[];
references
?:
SpanReference
[];
logs
:
Trace
Log
[];
tags
?:
Trace
KeyValuePair
[];
references
?:
Trace
SpanReference
[];
warnings
?:
string
[]
|
null
;
flags
:
number
;
};
export
type
Span
=
SpanData
&
{
export
type
TraceSpan
=
Trace
SpanData
&
{
depth
:
number
;
hasChildren
:
boolean
;
process
:
Process
;
process
:
Trace
Process
;
relativeStartTime
:
number
;
tags
:
NonNullable
<
SpanData
[
'tags'
]
>
;
references
:
NonNullable
<
SpanData
[
'references'
]
>
;
warnings
:
NonNullable
<
SpanData
[
'warnings'
]
>
;
subsidiarilyReferencedBy
:
SpanReference
[];
tags
:
NonNullable
<
Trace
SpanData
[
'tags'
]
>
;
references
:
NonNullable
<
Trace
SpanData
[
'references'
]
>
;
warnings
:
NonNullable
<
Trace
SpanData
[
'warnings'
]
>
;
subsidiarilyReferencedBy
:
Trace
SpanReference
[];
};
export
type
TraceData
=
{
processes
:
Record
<
string
,
Process
>
;
processes
:
Record
<
string
,
Trace
Process
>
;
traceID
:
string
;
warnings
?:
string
[]
|
null
;
};
...
...
@@ -80,7 +80,7 @@ export type TraceData = {
export
type
Trace
=
TraceData
&
{
duration
:
number
;
endTime
:
number
;
spans
:
Span
[];
spans
:
Trace
Span
[];
startTime
:
number
;
traceName
:
string
;
services
:
Array
<
{
name
:
string
;
numberOfSpans
:
number
}
>
;
...
...
packages/jaeger-ui-components/src/ScrollManager.tsx
View file @
271cc670
...
...
@@ -13,7 +13,7 @@
// limitations under the License.
import
{
TNil
}
from
'./types'
;
import
{
Span
,
SpanReference
,
Trace
}
from
'@grafana/data'
;
import
{
TraceSpan
,
Trace
SpanReference
,
Trace
}
from
'@grafana/data'
;
/**
* `Accessors` is necessary because `ScrollManager` needs to be created by
...
...
@@ -37,7 +37,7 @@ export type Accessors = {
mapSpanIndexToRowIndex
:
(
spanIndex
:
number
)
=>
number
;
};
interface
I
Scroller
{
interface
Scroller
{
scrollTo
:
(
rowIndex
:
number
)
=>
void
;
// TODO arg names throughout
scrollBy
:
(
rowIndex
:
number
,
opt
?:
boolean
)
=>
void
;
...
...
@@ -47,18 +47,18 @@ interface IScroller {
* Returns `{ isHidden: true, ... }` if one of the parents of `span` is
* collapsed, e.g. has children hidden.
*
* @param {Span} span The Span to check for.
* @param {
Trace
Span} span The Span to check for.
* @param {Set<string>} childrenAreHidden The set of Spans known to have hidden
* children, either because it is
* collapsed or has a collapsed parent.
* @param {Map<string, Span | TNil} spansMap Mapping from spanID to Span.
* @param {Map<string,
Trace
Span | TNil} spansMap Mapping from spanID to Span.
* @returns {{ isHidden: boolean, parentIds: Set<string> }}
*/
function
isSpanHidden
(
span
:
Span
,
childrenAreHidden
:
Set
<
string
>
,
spansMap
:
Map
<
string
,
Span
|
TNil
>
)
{
function
isSpanHidden
(
span
:
TraceSpan
,
childrenAreHidden
:
Set
<
string
>
,
spansMap
:
Map
<
string
,
Trace
Span
|
TNil
>
)
{
const
parentIDs
=
new
Set
<
string
>
();
let
{
references
}:
{
references
:
SpanReference
[]
|
TNil
}
=
span
;
let
{
references
}:
{
references
:
Trace
SpanReference
[]
|
TNil
}
=
span
;
let
parentID
:
undefined
|
string
;
const
checkRef
=
(
ref
:
SpanReference
)
=>
{
const
checkRef
=
(
ref
:
Trace
SpanReference
)
=>
{
if
(
ref
.
refType
===
'CHILD_OF'
||
ref
.
refType
===
'FOLLOWS_FROM'
)
{
parentID
=
ref
.
spanID
;
parentIDs
.
add
(
parentID
);
...
...
@@ -87,10 +87,10 @@ function isSpanHidden(span: Span, childrenAreHidden: Set<string>, spansMap: Map<
*/
export
default
class
ScrollManager
{
_trace
:
Trace
|
TNil
;
_scroller
:
I
Scroller
;
_scroller
:
Scroller
;
_accessors
:
Accessors
|
TNil
;
constructor
(
trace
:
Trace
|
TNil
,
scroller
:
I
Scroller
)
{
constructor
(
trace
:
Trace
|
TNil
,
scroller
:
Scroller
)
{
this
.
_trace
=
trace
;
this
.
_scroller
=
scroller
;
this
.
_accessors
=
undefined
;
...
...
@@ -157,8 +157,8 @@ export default class ScrollManager {
const
_collapsed
=
xrs
.
getCollapsedChildren
();
const
childrenAreHidden
=
_collapsed
?
new
Set
(
_collapsed
)
:
null
;
// use empty Map as fallback to make flow happy
const
spansMap
:
Map
<
string
,
Span
>
=
childrenAreHidden
?
new
Map
(
spans
.
map
(
s
=>
[
s
.
spanID
,
s
]
as
[
string
,
Span
]))
const
spansMap
:
Map
<
string
,
Trace
Span
>
=
childrenAreHidden
?
new
Map
(
spans
.
map
(
s
=>
[
s
.
spanID
,
s
]
as
[
string
,
Trace
Span
]))
:
new
Map
();
const
boundary
=
direction
<
0
?
-
1
:
spans
.
length
;
let
nextSpanIndex
:
number
|
undefined
;
...
...
packages/jaeger-ui-components/src/TracePageHeader/SpanGraph/index.tsx
View file @
271cc670
...
...
@@ -19,7 +19,7 @@ import CanvasSpanGraph from './CanvasSpanGraph';
import
TickLabels
from
'./TickLabels'
;
import
ViewingLayer
from
'./ViewingLayer'
;
import
{
TUpdateViewRangeTimeFunction
,
ViewRange
,
ViewRangeTimeUpdate
}
from
'../..'
;
import
{
Span
,
Trace
}
from
'@grafana/data'
;
import
{
Trace
Span
,
Trace
}
from
'@grafana/data'
;
import
{
ubPb2
,
ubPx2
,
ubRelative
}
from
'../../uberUtilityStyles'
;
const
DEFAULT_HEIGHT
=
60
;
...
...
@@ -45,7 +45,7 @@ type SpanGraphState = {
}
>
;
};
function
getItem
(
span
:
Span
)
{
function
getItem
(
span
:
Trace
Span
)
{
return
{
valueOffset
:
span
.
relativeStartTime
,
valueWidth
:
span
.
duration
,
...
...
packages/jaeger-ui-components/src/TraceTimelineViewer/ReferencesButton.tsx
View file @
271cc670
...
...
@@ -15,7 +15,7 @@
import
React
from
'react'
;
import
{
css
}
from
'emotion'
;
import
NewWindowIcon
from
'../common/NewWindowIcon'
;
import
{
SpanReference
}
from
'@grafana/data'
;
import
{
Trace
SpanReference
}
from
'@grafana/data'
;
import
{
UITooltip
,
UIDropdown
,
UIMenuItem
,
UIMenu
,
TooltipPlacement
}
from
'../uiElementsContext'
;
import
ReferenceLink
from
'../url/ReferenceLink'
;
...
...
@@ -44,14 +44,14 @@ export const getStyles = createStyle(() => {
});
type
TReferencesButtonProps
=
{
references
:
SpanReference
[];
references
:
Trace
SpanReference
[];
children
:
React
.
ReactNode
;
tooltipText
:
string
;
focusSpan
:
(
spanID
:
string
)
=>
void
;
};
export
default
class
ReferencesButton
extends
React
.
PureComponent
<
TReferencesButtonProps
>
{
referencesList
=
(
references
:
SpanReference
[])
=>
{
referencesList
=
(
references
:
Trace
SpanReference
[])
=>
{
const
styles
=
getStyles
();
return
(
<
UIMenu
>
...
...
packages/jaeger-ui-components/src/TraceTimelineViewer/SpanBar.tsx
View file @
271cc670
...
...
@@ -22,7 +22,7 @@ import AccordianLogs from './SpanDetail/AccordianLogs';
import
{
ViewedBoundsFunctionType
}
from
'./utils'
;
import
{
TNil
}
from
'../types'
;
import
{
Span
}
from
'@grafana/data'
;
import
{
Trace
Span
}
from
'@grafana/data'
;
import
{
UIPopover
}
from
'../uiElementsContext'
;
import
{
createStyle
}
from
'../Theme'
;
...
...
@@ -113,7 +113,7 @@ type TCommonProps = {
}
|
TNil
;
traceStartTime
:
number
;
span
:
Span
;
span
:
Trace
Span
;
className
?:
string
;
labelClassName
?:
string
;
};
...
...
packages/jaeger-ui-components/src/TraceTimelineViewer/SpanBarRow.tsx
View file @
271cc670
...
...
@@ -28,7 +28,7 @@ import SpanBar from './SpanBar';
import
Ticks
from
'./Ticks'
;
import
{
TNil
}
from
'../types'
;
import
{
Span
}
from
'@grafana/data'
;
import
{
Trace
Span
}
from
'@grafana/data'
;
import
{
autoColor
,
createStyle
,
Theme
,
withTheme
}
from
'../Theme'
;
const
getStyles
=
createStyle
((
theme
:
Theme
)
=>
{
...
...
@@ -304,7 +304,7 @@ type SpanBarRowProps = {
showErrorIcon
:
boolean
;
getViewedBounds
:
ViewedBoundsFunctionType
;
traceStartTime
:
number
;
span
:
Span
;
span
:
Trace
Span
;
focusSpan
:
(
spanID
:
string
)
=>
void
;
hoverIndentGuideIds
:
Set
<
string
>
;
addHoverIndentGuideId
:
(
spanID
:
string
)
=>
void
;
...
...
packages/jaeger-ui-components/src/TraceTimelineViewer/SpanDetail/AccordianKeyValues.tsx
View file @
271cc670
...
...
@@ -21,7 +21,7 @@ import cx from 'classnames';
import
*
as
markers
from
'./AccordianKeyValues.markers'
;
import
KeyValuesTable
from
'./KeyValuesTable'
;
import
{
TNil
}
from
'../../types'
;
import
{
KeyValuePair
,
Link
}
from
'@grafana/data'
;
import
{
TraceKeyValuePair
,
Trace
Link
}
from
'@grafana/data'
;
import
{
autoColor
,
createStyle
,
Theme
,
useTheme
}
from
'../../Theme'
;
import
{
uAlignIcon
,
uTxEllipsis
}
from
'../../uberUtilityStyles'
;
...
...
@@ -84,17 +84,17 @@ export const getStyles = createStyle((theme: Theme) => {
type
AccordianKeyValuesProps
=
{
className
?:
string
|
TNil
;
data
:
KeyValuePair
[];
data
:
Trace
KeyValuePair
[];
highContrast
?:
boolean
;
interactive
?:
boolean
;
isOpen
:
boolean
;
label
:
string
;
linksGetter
:
((
pairs
:
KeyValuePair
[],
index
:
number
)
=>
Link
[])
|
TNil
;
linksGetter
:
((
pairs
:
TraceKeyValuePair
[],
index
:
number
)
=>
Trace
Link
[])
|
TNil
;
onToggle
?:
null
|
(()
=>
void
);
};
// export for tests
export
function
KeyValuesSummary
(
props
:
{
data
?:
KeyValuePair
[]
})
{
export
function
KeyValuesSummary
(
props
:
{
data
?:
Trace
KeyValuePair
[]
})
{
const
{
data
}
=
props
;
if
(
!
Array
.
isArray
(
data
)
||
!
data
.
length
)
{
return
null
;
...
...
packages/jaeger-ui-components/src/TraceTimelineViewer/SpanDetail/AccordianLogs.tsx
View file @
271cc670
...
...
@@ -21,7 +21,7 @@ import { css } from 'emotion';
import
AccordianKeyValues
from
'./AccordianKeyValues'
;
import
{
formatDuration
}
from
'../utils'
;
import
{
TNil
}
from
'../../types'
;
import
{
Log
,
KeyValuePair
,
Link
}
from
'@grafana/data'
;
import
{
TraceLog
,
TraceKeyValuePair
,
Trace
Link
}
from
'@grafana/data'
;
import
{
autoColor
,
createStyle
,
Theme
,
useTheme
}
from
'../../Theme'
;
import
{
uAlignIcon
,
ubMb1
}
from
'../../uberUtilityStyles'
;
...
...
@@ -59,11 +59,11 @@ const getStyles = createStyle((theme: Theme) => {
type
AccordianLogsProps
=
{
interactive
?:
boolean
;
isOpen
:
boolean
;
linksGetter
:
((
pairs
:
KeyValuePair
[],
index
:
number
)
=>
Link
[])
|
TNil
;
logs
:
Log
[];
onItemToggle
?:
(
log
:
Log
)
=>
void
;
linksGetter
:
((
pairs
:
TraceKeyValuePair
[],
index
:
number
)
=>
Trace
Link
[])
|
TNil
;
logs
:
Trace
Log
[];
onItemToggle
?:
(
log
:
Trace
Log
)
=>
void
;
onToggle
?:
()
=>
void
;
openedItems
?:
Set
<
Log
>
;
openedItems
?:
Set
<
Trace
Log
>
;
timestamp
:
number
;
};
...
...
packages/jaeger-ui-components/src/TraceTimelineViewer/SpanDetail/AccordianReferences.tsx
View file @
271cc670
...
...
@@ -18,7 +18,7 @@ import cx from 'classnames';
import
IoIosArrowDown
from
'react-icons/lib/io/ios-arrow-down'
;
import
IoIosArrowRight
from
'react-icons/lib/io/ios-arrow-right'
;
import
{
SpanReference
}
from
'@grafana/data'
;
import
{
Trace
SpanReference
}
from
'@grafana/data'
;
import
ReferenceLink
from
'../../url/ReferenceLink'
;
import
{
createStyle
}
from
'../../Theme'
;
...
...
@@ -66,7 +66,7 @@ const getStyles = createStyle(() => {
});
type
AccordianReferencesProps
=
{
data
:
SpanReference
[];
data
:
Trace
SpanReference
[];
highContrast
?:
boolean
;
interactive
?:
boolean
;
isOpen
:
boolean
;
...
...
@@ -75,7 +75,7 @@ type AccordianReferencesProps = {
};
type
ReferenceItemProps
=
{
data
:
SpanReference
[];
data
:
Trace
SpanReference
[];
focusSpan
:
(
uiFind
:
string
)
=>
void
;
};
...
...
packages/jaeger-ui-components/src/TraceTimelineViewer/SpanDetail/DetailState.tsx
View file @
271cc670
...
...
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import
{
Log
}
from
'@grafana/data'
;
import
{
Trace
Log
}
from
'@grafana/data'
;
/**
* Which items of a {@link SpanDetail} component are expanded.
...
...
@@ -20,7 +20,7 @@ import { Log } from '@grafana/data';
export
default
class
DetailState
{
isTagsOpen
:
boolean
;
isProcessOpen
:
boolean
;
logs
:
{
isOpen
:
boolean
;
openedItems
:
Set
<
Log
>
};
logs
:
{
isOpen
:
boolean
;
openedItems
:
Set
<
Trace
Log
>
};
isWarningsOpen
:
boolean
;
isReferencesOpen
:
boolean
;
...
...
@@ -72,7 +72,7 @@ export default class DetailState {
return
next
;
}
toggleLogItem
(
logItem
:
Log
)
{
toggleLogItem
(
logItem
:
Trace
Log
)
{
const
next
=
new
DetailState
(
this
);
if
(
next
.
logs
.
openedItems
.
has
(
logItem
))
{
next
.
logs
.
openedItems
.
delete
(
logItem
);
...
...
packages/jaeger-ui-components/src/TraceTimelineViewer/SpanDetail/KeyValuesTable.tsx
View file @
271cc670
...
...
@@ -20,7 +20,7 @@ import cx from 'classnames';
import
CopyIcon
from
'../../common/CopyIcon'
;
import
{
TNil
}
from
'../../types'
;
import
{
KeyValuePair
,
Link
}
from
'@grafana/data'
;
import
{
TraceKeyValuePair
,
Trace
Link
}
from
'@grafana/data'
;
import
{
UIDropdown
,
UIIcon
,
UIMenu
,
UIMenuItem
}
from
'../../uiElementsContext'
;
import
{
autoColor
,
createStyle
,
Theme
,
useTheme
}
from
'../../Theme'
;
import
{
ubInlineBlock
,
uWidth100
}
from
'../../uberUtilityStyles'
;
...
...
@@ -102,7 +102,7 @@ LinkValue.defaultProps = {
title
:
''
,
};
const
linkValueList
=
(
links
:
Link
[])
=>
(
const
linkValueList
=
(
links
:
Trace
Link
[])
=>
(
<
UIMenu
>
{
links
.
map
(({
text
,
url
},
index
)
=>
(
// `index` is necessary in the key because url can repeat
...
...
@@ -114,8 +114,8 @@ const linkValueList = (links: Link[]) => (
);
type
KeyValuesTableProps
=
{
data
:
KeyValuePair
[];
linksGetter
:
((
pairs
:
KeyValuePair
[],
index
:
number
)
=>
Link
[])
|
TNil
;
data
:
Trace
KeyValuePair
[];
linksGetter
:
((
pairs
:
TraceKeyValuePair
[],
index
:
number
)
=>
Trace
Link
[])
|
TNil
;
};
export
default
function
KeyValuesTable
(
props
:
KeyValuesTableProps
)
{
...
...
packages/jaeger-ui-components/src/TraceTimelineViewer/SpanDetail/index.tsx
View file @
271cc670
...
...
@@ -25,7 +25,7 @@ import CopyIcon from '../../common/CopyIcon';
import
LabeledList
from
'../../common/LabeledList'
;
import
{
TNil
}
from
'../../types'
;
import
{
KeyValuePair
,
Link
,
Log
,
Span
}
from
'@grafana/data'
;
import
{
TraceKeyValuePair
,
TraceLink
,
TraceLog
,
Trace
Span
}
from
'@grafana/data'
;
import
AccordianReferences
from
'./AccordianReferences'
;
import
{
autoColor
,
createStyle
,
Theme
,
useTheme
}
from
'../../Theme'
;
import
{
UIDivider
}
from
'../../uiElementsContext'
;
...
...
@@ -99,11 +99,11 @@ const getStyles = createStyle((theme: Theme) => {
type
SpanDetailProps
=
{
detailState
:
DetailState
;
linksGetter
:
((
links
:
KeyValuePair
[],
index
:
number
)
=>
Link
[])
|
TNil
;
logItemToggle
:
(
spanID
:
string
,
log
:
Log
)
=>
void
;
linksGetter
:
((
links
:
TraceKeyValuePair
[],
index
:
number
)
=>
Trace
Link
[])
|
TNil
;
logItemToggle
:
(
spanID
:
string
,
log
:
Trace
Log
)
=>
void
;
logsToggle
:
(
spanID
:
string
)
=>
void
;
processToggle
:
(
spanID
:
string
)
=>
void
;
span
:
Span
;
span
:
Trace
Span
;
tagsToggle
:
(
spanID
:
string
)
=>
void
;
traceStartTime
:
number
;
warningsToggle
:
(
spanID
:
string
)
=>
void
;
...
...
packages/jaeger-ui-components/src/TraceTimelineViewer/SpanDetailRow.tsx
View file @
271cc670
...
...
@@ -21,7 +21,7 @@ import SpanTreeOffset from './SpanTreeOffset';
import
TimelineRow
from
'./TimelineRow'
;
import
{
autoColor
,
createStyle
,
Theme
,
withTheme
}
from
'../Theme'
;
import
{
Log
,
Span
,
KeyValuePair
,
Link
}
from
'@grafana/data'
;
import
{
TraceLog
,
TraceSpan
,
TraceKeyValuePair
,
Trace
Link
}
from
'@grafana/data'
;
const
getStyles
=
createStyle
((
theme
:
Theme
)
=>
{
return
{
...
...
@@ -70,13 +70,13 @@ type SpanDetailRowProps = {
columnDivision
:
number
;
detailState
:
DetailState
;
onDetailToggled
:
(
spanID
:
string
)
=>
void
;
linksGetter
:
(
span
:
Span
,
links
:
KeyValuePair
[],
index
:
number
)
=>
Link
[];
logItemToggle
:
(
spanID
:
string
,
log
:
Log
)
=>
void
;
linksGetter
:
(
span
:
TraceSpan
,
links
:
TraceKeyValuePair
[],
index
:
number
)
=>
Trace
Link
[];
logItemToggle
:
(
spanID
:
string
,
log
:
Trace
Log
)
=>
void
;
logsToggle
:
(
spanID
:
string
)
=>
void
;
processToggle
:
(
spanID
:
string
)
=>
void
;
referencesToggle
:
(
spanID
:
string
)
=>
void
;
warningsToggle
:
(
spanID
:
string
)
=>
void
;
span
:
Span
;
span
:
Trace
Span
;
tagsToggle
:
(
spanID
:
string
)
=>
void
;
traceStartTime
:
number
;
focusSpan
:
(
uiFind
:
string
)
=>
void
;
...
...
@@ -91,7 +91,7 @@ export class UnthemedSpanDetailRow extends React.PureComponent<SpanDetailRowProp
this
.
props
.
onDetailToggled
(
this
.
props
.
span
.
spanID
);
};
_linksGetter
=
(
items
:
KeyValuePair
[],
itemIndex
:
number
)
=>
{
_linksGetter
=
(
items
:
Trace
KeyValuePair
[],
itemIndex
:
number
)
=>
{
const
{
linksGetter
,
span
}
=
this
.
props
;
return
linksGetter
(
span
,
items
,
itemIndex
);
};
...
...
packages/jaeger-ui-components/src/TraceTimelineViewer/SpanTreeOffset.tsx
View file @
271cc670
...
...
@@ -19,7 +19,7 @@ import IoIosArrowDown from 'react-icons/lib/io/ios-arrow-down';
import
{
css
}
from
'emotion'
;
import
cx
from
'classnames'
;
import
{
Span
}
from
'@grafana/data'
;
import
{
Trace
Span
}
from
'@grafana/data'
;
import
spanAncestorIds
from
'../utils/span-ancestor-ids'
;
import
{
autoColor
,
createStyle
,
Theme
,
withTheme
}
from
'../Theme'
;
...
...
@@ -72,7 +72,7 @@ export const getStyles = createStyle((theme: Theme) => {
type
TProps
=
{
childrenVisible
?:
boolean
;
onClick
?:
()
=>
void
;
span
:
Span
;
span
:
Trace
Span
;
showChildrenIcon
?:
boolean
;
hoverIndentGuideIds
:
Set
<
string
>
;
...
...
packages/jaeger-ui-components/src/TraceTimelineViewer/VirtualizedTraceView.tsx
View file @
271cc670
...
...
@@ -29,7 +29,7 @@ import {
import
{
Accessors
}
from
'../ScrollManager'
;
import
{
getColorByKey
}
from
'../utils/color-generator'
;
import
{
TNil
}
from
'../types'
;
import
{
Log
,
Span
,
Trace
,
KeyValuePair
,
Link
}
from
'@grafana/data'
;
import
{
TraceLog
,
TraceSpan
,
Trace
,
TraceKeyValuePair
,
Trace
Link
}
from
'@grafana/data'
;
import
TTraceTimeline
from
'../types/TTraceTimeline'
;
import
{
createStyle
,
Theme
,
withTheme
}
from
'../Theme'
;
...
...
@@ -51,7 +51,7 @@ const getStyles = createStyle(() => {
type
RowState
=
{
isDetail
:
boolean
;
span
:
Span
;
span
:
Trace
Span
;
spanIndex
:
number
;
};
...
...
@@ -62,10 +62,10 @@ type TVirtualizedTraceViewOwnProps = {
registerAccessors
:
(
accesors
:
Accessors
)
=>
void
;
trace
:
Trace
;
focusSpan
:
(
uiFind
:
string
)
=>
void
;
linksGetter
:
(
span
:
Span
,
items
:
KeyValuePair
[],
itemIndex
:
number
)
=>
Link
[];
linksGetter
:
(
span
:
TraceSpan
,
items
:
TraceKeyValuePair
[],
itemIndex
:
number
)
=>
Trace
Link
[];
childrenToggle
:
(
spanID
:
string
)
=>
void
;
clearShouldScrollToFirstUiFindMatch
:
()
=>
void
;
detailLogItemToggle
:
(
spanID
:
string
,
log
:
Log
)
=>
void
;
detailLogItemToggle
:
(
spanID
:
string
,
log
:
Trace
Log
)
=>
void
;
detailLogsToggle
:
(
spanID
:
string
)
=>
void
;
detailWarningsToggle
:
(
spanID
:
string
)
=>
void
;
detailReferencesToggle
:
(
spanID
:
string
)
=>
void
;
...
...
@@ -92,7 +92,7 @@ export const DEFAULT_HEIGHTS = {
const
NUM_TICKS
=
5
;
function
generateRowStates
(
spans
:
Span
[]
|
TNil
,
spans
:
Trace
Span
[]
|
TNil
,
childrenHiddenIDs
:
Set
<
string
>
,
detailStates
:
Map
<
string
,
DetailState
|
TNil
>
):
RowState
[]
{
...
...
@@ -313,7 +313,7 @@ export class UnthemedVirtualizedTraceView extends React.Component<VirtualizedTra
:
this
.
renderSpanBarRow
(
span
,
spanIndex
,
key
,
style
,
attrs
);
};
renderSpanBarRow
(
span
:
Span
,
spanIndex
:
number
,
key
:
string
,
style
:
React
.
CSSProperties
,
attrs
:
{})
{
renderSpanBarRow
(
span
:
Trace
Span
,
spanIndex
:
number
,
key
:
string
,
style
:
React
.
CSSProperties
,
attrs
:
{})
{
const
{
spanID
}
=
span
;
const
{
serviceName
}
=
span
.
process
;
const
{
...
...
@@ -383,7 +383,7 @@ export class UnthemedVirtualizedTraceView extends React.Component<VirtualizedTra
);
}
renderSpanDetailRow
(
span
:
Span
,
key
:
string
,
style
:
React
.
CSSProperties
,
attrs
:
{})
{
renderSpanDetailRow
(
span
:
Trace
Span
,
key
:
string
,
style
:
React
.
CSSProperties
,
attrs
:
{})
{
const
{
spanID
}
=
span
;
const
{
serviceName
}
=
span
.
process
;
const
{
...
...
packages/jaeger-ui-components/src/TraceTimelineViewer/index.tsx
View file @
271cc670
...
...
@@ -21,7 +21,7 @@ import { merge as mergeShortcuts } from '../keyboard-shortcuts';
import
{
Accessors
}
from
'../ScrollManager'
;
import
{
TUpdateViewRangeTimeFunction
,
ViewRange
,
ViewRangeTimeUpdate
}
from
'./types'
;
import
{
TNil
}
from
'../types'
;
import
{
Span
,
Trace
,
Log
,
KeyValuePair
,
Link
}
from
'@grafana/data'
;
import
{
TraceSpan
,
Trace
,
TraceLog
,
TraceKeyValuePair
,
Trace
Link
}
from
'@grafana/data'
;
import
TTraceTimeline
from
'../types/TTraceTimeline'
;
import
{
autoColor
,
createStyle
,
Theme
,
withTheme
}
from
'../Theme'
;
import
ExternalLinkContext
from
'../url/externalLinkContext'
;
...
...
@@ -79,14 +79,14 @@ type TProps = TExtractUiFindFromStateReturn & {
createLinkToExternalSpan
:
(
traceID
:
string
,
spanID
:
string
)
=>
string
;
setSpanNameColumnWidth
:
(
width
:
number
)
=>
void
;
collapseAll
:
(
spans
:
Span
[])
=>
void
;
collapseOne
:
(
spans
:
Span
[])
=>
void
;
collapseAll
:
(
spans
:
Trace
Span
[])
=>
void
;
collapseOne
:
(
spans
:
Trace
Span
[])
=>
void
;
expandAll
:
()
=>
void
;
expandOne
:
(
spans
:
Span
[])
=>
void
;
expandOne
:
(
spans
:
Trace
Span
[])
=>
void
;
childrenToggle
:
(
spanID
:
string
)
=>
void
;
clearShouldScrollToFirstUiFindMatch
:
()
=>
void
;
detailLogItemToggle
:
(
spanID
:
string
,
log
:
Log
)
=>
void
;
detailLogItemToggle
:
(
spanID
:
string
,
log
:
Trace
Log
)
=>
void
;
detailLogsToggle
:
(
spanID
:
string
)
=>
void
;
detailWarningsToggle
:
(
spanID
:
string
)
=>
void
;
detailReferencesToggle
:
(
spanID
:
string
)
=>
void
;
...
...
@@ -96,7 +96,7 @@ type TProps = TExtractUiFindFromStateReturn & {
setTrace
:
(
trace
:
Trace
|
TNil
,
uiFind
:
string
|
TNil
)
=>
void
;
addHoverIndentGuideId
:
(
spanID
:
string
)
=>
void
;
removeHoverIndentGuideId
:
(
spanID
:
string
)
=>
void
;
linksGetter
:
(
span
:
Span
,
items
:
KeyValuePair
[],
itemIndex
:
number
)
=>
Link
[];
linksGetter
:
(
span
:
TraceSpan
,
items
:
TraceKeyValuePair
[],
itemIndex
:
number
)
=>
Trace
Link
[];
theme
:
Theme
;
};
...
...
packages/jaeger-ui-components/src/TraceTimelineViewer/utils.tsx
View file @
271cc670
...
...
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import
{
Span
}
from
'@grafana/data'
;
import
{
Trace
Span
}
from
'@grafana/data'
;
export
type
ViewedBoundsFunctionType
=
(
start
:
number
,
end
:
number
)
=>
{
start
:
number
;
end
:
number
};
/**
...
...
@@ -57,7 +57,7 @@ export function createViewedBoundsFunc(viewRange: { min: number; max: number; vi
* items.
* @return {boolean} True if a match was found.
*/
export
function
spanHasTag
(
key
:
string
,
value
:
any
,
span
:
Span
)
{
export
function
spanHasTag
(
key
:
string
,
value
:
any
,
span
:
Trace
Span
)
{
if
(
!
Array
.
isArray
(
span
.
tags
)
||
!
span
.
tags
.
length
)
{
return
false
;
}
...
...
@@ -69,20 +69,20 @@ export const isServerSpan = spanHasTag.bind(null, 'span.kind', 'server');
const
isErrorBool
=
spanHasTag
.
bind
(
null
,
'error'
,
true
);
const
isErrorStr
=
spanHasTag
.
bind
(
null
,
'error'
,
'true'
);
export
const
isErrorSpan
=
(
span
:
Span
)
=>
isErrorBool
(
span
)
||
isErrorStr
(
span
);
export
const
isErrorSpan
=
(
span
:
Trace
Span
)
=>
isErrorBool
(
span
)
||
isErrorStr
(
span
);
/**
* Returns `true` if at least one of the descendants of the `parentSpanIndex`
* span contains an error tag.
*
* @param {Span[]} spans The spans for a trace - should be
* @param {
Trace
Span[]} spans The spans for a trace - should be
* sorted with children following parents.
* @param {number} parentSpanIndex The index of the parent span - only
* subsequent spans with depth less than
* the parent span will be checked.
* @return {boolean} Returns `true` if a descendant contains an error tag.
*/
export
function
spanContainsErredSpan
(
spans
:
Span
[],
parentSpanIndex
:
number
)
{
export
function
spanContainsErredSpan
(
spans
:
Trace
Span
[],
parentSpanIndex
:
number
)
{
const
{
depth
}
=
spans
[
parentSpanIndex
];
let
i
=
parentSpanIndex
+
1
;
for
(;
i
<
spans
.
length
&&
spans
[
i
].
depth
>
depth
;
i
++
)
{
...
...
@@ -96,7 +96,7 @@ export function spanContainsErredSpan(spans: Span[], parentSpanIndex: number) {
/**
* Expects the first span to be the parent span.
*/
export
function
findServerChildSpan
(
spans
:
Span
[])
{
export
function
findServerChildSpan
(
spans
:
Trace
Span
[])
{
if
(
spans
.
length
<=
1
||
!
isClientSpan
(
spans
[
0
]))
{
return
false
;
}
...
...
packages/jaeger-ui-components/src/model/link-patterns.tsx
View file @
271cc670
...
...
@@ -17,7 +17,7 @@ import memoize from 'lru-memoize';
import
{
getConfigValue
}
from
'../utils/config/get-config'
;
import
{
getParent
}
from
'./span'
;
import
{
TNil
}
from
'../types'
;
import
{
Span
,
Link
,
KeyValuePair
,
Trace
}
from
'@grafana/data'
;
import
{
TraceSpan
,
TraceLink
,
Trace
KeyValuePair
,
Trace
}
from
'@grafana/data'
;
const
parameterRegExp
=
/#
\{([^
{}
]
*
)\}
/g
;
...
...
@@ -118,15 +118,15 @@ export function processLinkPattern(pattern: any): ProcessedLinkPattern | TNil {
}
}
export
function
getParameterInArray
(
name
:
string
,
array
:
KeyValuePair
[])
{
export
function
getParameterInArray
(
name
:
string
,
array
:
Trace
KeyValuePair
[])
{
if
(
array
)
{
return
array
.
find
(
entry
=>
entry
.
key
===
name
);
}
return
undefined
;
}
export
function
getParameterInAncestor
(
name
:
string
,
span
:
Span
)
{
let
currentSpan
:
Span
|
TNil
=
span
;
export
function
getParameterInAncestor
(
name
:
string
,
span
:
Trace
Span
)
{
let
currentSpan
:
Trace
Span
|
TNil
=
span
;
while
(
currentSpan
)
{
const
result
=
getParameterInArray
(
name
,
currentSpan
.
tags
)
||
getParameterInArray
(
name
,
currentSpan
.
process
.
tags
);
if
(
result
)
{
...
...
@@ -174,8 +174,8 @@ export function computeTraceLink(linkPatterns: ProcessedLinkPattern[], trace: Tr
export
function
computeLinks
(
linkPatterns
:
ProcessedLinkPattern
[],
span
:
Span
,
items
:
KeyValuePair
[],
span
:
Trace
Span
,
items
:
Trace
KeyValuePair
[],
itemIndex
:
number
)
{
const
item
=
items
[
itemIndex
];
...
...
@@ -221,8 +221,8 @@ export function computeLinks(
return
result
;
}
export
function
createGetLinks
(
linkPatterns
:
ProcessedLinkPattern
[],
cache
:
WeakMap
<
KeyValuePair
,
Link
[]
>
)
{
return
(
span
:
Span
,
items
:
KeyValuePair
[],
itemIndex
:
number
)
=>
{
export
function
createGetLinks
(
linkPatterns
:
ProcessedLinkPattern
[],
cache
:
WeakMap
<
TraceKeyValuePair
,
Trace
Link
[]
>
)
{
return
(
span
:
TraceSpan
,
items
:
Trace
KeyValuePair
[],
itemIndex
:
number
)
=>
{
if
(
linkPatterns
.
length
===
0
)
{
return
[];
}
...
...
packages/jaeger-ui-components/src/model/span.tsx
View file @
271cc670
...
...
@@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import
{
Span
}
from
'@grafana/data'
;
import
{
Trace
Span
}
from
'@grafana/data'
;
/**
* Searches the span.references to find 'CHILD_OF' reference type or returns null.
* @param {Span} span The span whose parent is to be returned.
* @return {Span|null} The parent span if there is one, null otherwise.
* @param {
Trace
Span} span The span whose parent is to be returned.
* @return {
Trace
Span|null} The parent span if there is one, null otherwise.
*/
export
function
getParent
(
span
:
Span
)
{
export
function
getParent
(
span
:
Trace
Span
)
{
const
parentRef
=
span
.
references
?
span
.
references
.
find
(
ref
=>
ref
.
refType
===
'CHILD_OF'
)
:
null
;
return
parentRef
?
parentRef
.
span
:
null
;
}
packages/jaeger-ui-components/src/model/trace-viewer.ts
View file @
271cc670
...
...
@@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import
{
Span
}
from
'@grafana/data'
;
import
{
Trace
Span
}
from
'@grafana/data'
;
export
function
getTraceName
(
spans
:
Span
[]):
string
{
export
function
getTraceName
(
spans
:
Trace
Span
[]):
string
{
const
span
=
spans
.
filter
(
sp
=>
!
sp
.
references
||
!
sp
.
references
.
length
)[
0
];
return
span
?
`
${
span
.
process
.
serviceName
}
:
${
span
.
operationName
}
`
:
''
;
}
packages/jaeger-ui-components/src/model/transform-trace-data.tsx
View file @
271cc670
...
...
@@ -17,14 +17,14 @@ import _isEqual from 'lodash/isEqual';
// @ts-ignore
import
{
getTraceSpanIdsAsTree
}
from
'../selectors/trace'
;
import
{
getConfigValue
}
from
'../utils/config/get-config'
;
import
{
KeyValuePair
,
Span
,
SpanData
,
Trace
,
TraceData
}
from
'@grafana/data'
;
import
{
TraceKeyValuePair
,
TraceSpan
,
Trace
SpanData
,
Trace
,
TraceData
}
from
'@grafana/data'
;
// @ts-ignore
import
TreeNode
from
'../utils/TreeNode'
;
// exported for tests
export
function
deduplicateTags
(
spanTags
:
KeyValuePair
[])
{
export
function
deduplicateTags
(
spanTags
:
Trace
KeyValuePair
[])
{
const
warningsHash
:
Map
<
string
,
string
>
=
new
Map
<
string
,
string
>
();
const
tags
:
KeyValuePair
[]
=
spanTags
.
reduce
<
KeyValuePair
[]
>
((
uniqueTags
,
tag
)
=>
{
const
tags
:
TraceKeyValuePair
[]
=
spanTags
.
reduce
<
Trace
KeyValuePair
[]
>
((
uniqueTags
,
tag
)
=>
{
if
(
!
uniqueTags
.
some
(
t
=>
t
.
key
===
tag
.
key
&&
t
.
value
===
tag
.
value
))
{
uniqueTags
.
push
(
tag
);
}
else
{
...
...
@@ -37,8 +37,8 @@ export function deduplicateTags(spanTags: KeyValuePair[]) {
}
// exported for tests
export
function
orderTags
(
spanTags
:
KeyValuePair
[],
topPrefixes
?:
string
[])
{
const
orderedTags
:
KeyValuePair
[]
=
spanTags
.
slice
();
export
function
orderTags
(
spanTags
:
Trace
KeyValuePair
[],
topPrefixes
?:
string
[])
{
const
orderedTags
:
Trace
KeyValuePair
[]
=
spanTags
.
slice
();
const
tp
=
(
topPrefixes
||
[]).
map
((
p
:
string
)
=>
p
.
toLowerCase
());
orderedTags
.
sort
((
a
,
b
)
=>
{
...
...
@@ -71,7 +71,7 @@ export function orderTags(spanTags: KeyValuePair[], topPrefixes?: string[]) {
* NOTE: Mutates `data` - Transform the HTTP response data into the form the app
* generally requires.
*/
export
default
function
transformTraceData
(
data
:
TraceData
&
{
spans
:
SpanData
[]
}):
Trace
|
null
{
export
default
function
transformTraceData
(
data
:
TraceData
&
{
spans
:
Trace
SpanData
[]
}):
Trace
|
null
{
let
{
traceID
}
=
data
;
if
(
!
traceID
)
{
return
null
;
...
...
@@ -81,14 +81,14 @@ export default function transformTraceData(data: TraceData & { spans: SpanData[]
let
traceEndTime
=
0
;
let
traceStartTime
=
Number
.
MAX_SAFE_INTEGER
;
const
spanIdCounts
=
new
Map
();
const
spanMap
=
new
Map
<
string
,
Span
>
();
const
spanMap
=
new
Map
<
string
,
Trace
Span
>
();
// filter out spans with empty start times
// eslint-disable-next-line no-param-reassign
data
.
spans
=
data
.
spans
.
filter
(
span
=>
Boolean
(
span
.
startTime
));
const
max
=
data
.
spans
.
length
;
for
(
let
i
=
0
;
i
<
max
;
i
++
)
{
const
span
:
Span
=
data
.
spans
[
i
]
as
Span
;
const
span
:
TraceSpan
=
data
.
spans
[
i
]
as
Trace
Span
;
const
{
startTime
,
duration
,
processID
}
=
span
;
//
let
spanID
=
span
.
spanID
;
...
...
@@ -120,7 +120,7 @@ export default function transformTraceData(data: TraceData & { spans: SpanData[]
// tree is necessary to sort the spans, so children follow parents, and
// siblings are sorted by start time
const
tree
=
getTraceSpanIdsAsTree
(
data
);
const
spans
:
Span
[]
=
[];
const
spans
:
Trace
Span
[]
=
[];
const
svcCounts
:
Record
<
string
,
number
>
=
{};
let
traceName
=
''
;
...
...
@@ -130,7 +130,7 @@ export default function transformTraceData(data: TraceData & { spans: SpanData[]
if
(
spanID
===
'__root__'
)
{
return
;
}
const
span
=
spanMap
.
get
(
spanID
)
as
Span
;
const
span
=
spanMap
.
get
(
spanID
)
as
Trace
Span
;
if
(
!
span
)
{
return
;
}
...
...
@@ -149,7 +149,7 @@ export default function transformTraceData(data: TraceData & { spans: SpanData[]
span
.
tags
=
orderTags
(
tagsInfo
.
tags
,
getConfigValue
(
'topTagPrefixes'
));
span
.
warnings
=
span
.
warnings
.
concat
(
tagsInfo
.
warnings
);
span
.
references
.
forEach
((
ref
,
index
)
=>
{
const
refSpan
=
spanMap
.
get
(
ref
.
spanID
)
as
Span
;
const
refSpan
=
spanMap
.
get
(
ref
.
spanID
)
as
Trace
Span
;
if
(
refSpan
)
{
// eslint-disable-next-line no-param-reassign
ref
.
span
=
refSpan
;
...
...
packages/jaeger-ui-components/src/url/ReferenceLink.tsx
View file @
271cc670
...
...
@@ -13,11 +13,11 @@
// limitations under the License.
import
React
from
'react'
;
import
{
SpanReference
}
from
'@grafana/data'
;
import
{
Trace
SpanReference
}
from
'@grafana/data'
;
import
ExternalLinkContext
from
'./externalLinkContext'
;
type
ReferenceLinkProps
=
{
reference
:
SpanReference
;
reference
:
Trace
SpanReference
;
children
:
React
.
ReactNode
;
className
?:
string
;
focusSpan
:
(
spanID
:
string
)
=>
void
;
...
...
packages/jaeger-ui-components/src/utils/filter-spans.tsx
View file @
271cc670
...
...
@@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import
{
KeyValuePair
,
Span
}
from
'@grafana/data'
;
import
{
TraceKeyValuePair
,
Trace
Span
}
from
'@grafana/data'
;
import
{
TNil
}
from
'../types'
;
export
default
function
filterSpans
(
textFilter
:
string
,
spans
:
Span
[]
|
TNil
)
{
export
default
function
filterSpans
(
textFilter
:
string
,
spans
:
Trace
Span
[]
|
TNil
)
{
if
(
!
spans
)
{
return
null
;
}
...
...
@@ -41,7 +41,7 @@ export default function filterSpans(textFilter: string, spans: Span[] | TNil) {
const
isTextInFilters
=
(
filters
:
string
[],
text
:
string
)
=>
filters
.
some
(
filter
=>
text
.
toLowerCase
().
includes
(
filter
));
const
isTextInKeyValues
=
(
kvs
:
KeyValuePair
[])
=>
const
isTextInKeyValues
=
(
kvs
:
Trace
KeyValuePair
[])
=>
kvs
?
kvs
.
some
(
kv
=>
{
// ignore checking key and value for a match if key is in excludeKeys
...
...
@@ -53,7 +53,7 @@ export default function filterSpans(textFilter: string, spans: Span[] | TNil) {
})
:
false
;
const
isSpanAMatch
=
(
span
:
Span
)
=>
const
isSpanAMatch
=
(
span
:
Trace
Span
)
=>
isTextInFilters
(
includeFilters
,
span
.
operationName
)
||
isTextInFilters
(
includeFilters
,
span
.
process
.
serviceName
)
||
isTextInKeyValues
(
span
.
tags
)
||
...
...
@@ -62,6 +62,6 @@ export default function filterSpans(textFilter: string, spans: Span[] | TNil) {
includeFilters
.
some
(
filter
=>
filter
===
span
.
spanID
);
// declare as const because need to disambiguate the type
const
rv
:
Set
<
string
>
=
new
Set
(
spans
.
filter
(
isSpanAMatch
).
map
((
span
:
Span
)
=>
span
.
spanID
));
const
rv
:
Set
<
string
>
=
new
Set
(
spans
.
filter
(
isSpanAMatch
).
map
((
span
:
Trace
Span
)
=>
span
.
spanID
));
return
rv
;
}
packages/jaeger-ui-components/src/utils/span-ancestor-ids.tsx
View file @
271cc670
...
...
@@ -16,9 +16,9 @@ import _find from 'lodash/find';
import
_get
from
'lodash/get'
;
import
{
TNil
}
from
'../types'
;
import
{
Span
}
from
'@grafana/data'
;
import
{
Trace
Span
}
from
'@grafana/data'
;
function
getFirstAncestor
(
span
:
Span
):
Span
|
TNil
{
function
getFirstAncestor
(
span
:
TraceSpan
):
Trace
Span
|
TNil
{
return
_get
(
_find
(
span
.
references
,
...
...
@@ -28,7 +28,7 @@ function getFirstAncestor(span: Span): Span | TNil {
);
}
export
default
function
spanAncestorIds
(
span
:
Span
|
TNil
):
string
[]
{
export
default
function
spanAncestorIds
(
span
:
Trace
Span
|
TNil
):
string
[]
{
const
ancestorIDs
:
string
[]
=
[];
if
(
!
span
)
{
return
ancestorIDs
;
...
...
public/app/features/explore/TraceView/TraceView.test.tsx
View file @
271cc670
...
...
@@ -2,7 +2,7 @@ import React from 'react';
import
{
shallow
}
from
'enzyme'
;
import
{
TraceView
}
from
'./TraceView'
;
import
{
TracePageHeader
,
TraceTimelineViewer
}
from
'@jaegertracing/jaeger-ui-components'
;
import
{
SpanData
,
TraceData
}
from
'@grafana/data'
;
import
{
Trace
SpanData
,
TraceData
}
from
'@grafana/data'
;
function
renderTraceView
()
{
const
wrapper
=
shallow
(<
TraceView
trace=
{
response
}
/>);
...
...
@@ -123,7 +123,7 @@ describe('TraceView', () => {
});
});
const
response
:
TraceData
&
{
spans
:
SpanData
[]
}
=
{
const
response
:
TraceData
&
{
spans
:
Trace
SpanData
[]
}
=
{
traceID
:
'1ed38015486087ca'
,
spans
:
[
{
...
...
public/app/features/explore/TraceView/TraceView.tsx
View file @
271cc670
...
...
@@ -16,10 +16,10 @@ import { useChildrenState } from './useChildrenState';
import
{
useDetailState
}
from
'./useDetailState'
;
import
{
useHoverIndentGuide
}
from
'./useHoverIndentGuide'
;
import
{
colors
,
useTheme
}
from
'@grafana/ui'
;
import
{
TraceData
,
SpanData
,
Trace
,
Span
,
KeyValuePair
,
Link
}
from
'@grafana/data'
;
import
{
TraceData
,
TraceSpanData
,
Trace
,
TraceSpan
,
TraceKeyValuePair
,
Trace
Link
}
from
'@grafana/data'
;
type
Props
=
{
trace
:
TraceData
&
{
spans
:
SpanData
[]
};
trace
:
TraceData
&
{
spans
:
Trace
SpanData
[]
};
};
export
function
TraceView
(
props
:
Props
)
{
...
...
@@ -128,7 +128,10 @@ export function TraceView(props: Props) {
setTrace=
{
useCallback
((
trace
:
Trace
|
null
,
uiFind
:
string
|
null
)
=>
{},
[])
}
addHoverIndentGuideId=
{
addHoverIndentGuideId
}
removeHoverIndentGuideId=
{
removeHoverIndentGuideId
}
linksGetter=
{
useCallback
((
span
:
Span
,
items
:
KeyValuePair
[],
itemIndex
:
number
)
=>
[]
as
Link
[],
[])
}
linksGetter=
{
useCallback
(
(
span
:
TraceSpan
,
items
:
TraceKeyValuePair
[],
itemIndex
:
number
)
=>
[]
as
TraceLink
[],
[]
)
}
uiFind=
{
search
}
/>
</
UIElementsContext
.
Provider
>
...
...
public/app/features/explore/TraceView/useChildrenState.test.ts
View file @
271cc670
import
{
renderHook
,
act
}
from
'@testing-library/react-hooks'
;
import
{
useChildrenState
}
from
'./useChildrenState'
;
import
{
Span
}
from
'@grafana/data'
;
import
{
Trace
Span
}
from
'@grafana/data'
;
describe
(
'useChildrenState'
,
()
=>
{
describe
(
'childrenToggle'
,
()
=>
{
...
...
@@ -37,8 +37,8 @@ describe('useChildrenState', () => {
const
{
result
}
=
renderHook
(()
=>
useChildrenState
());
act
(()
=>
result
.
current
.
collapseAll
([
{
spanID
:
'span1'
,
hasChildren
:
true
}
as
Span
,
{
spanID
:
'span2'
,
hasChildren
:
false
}
as
Span
,
{
spanID
:
'span1'
,
hasChildren
:
true
}
as
Trace
Span
,
{
spanID
:
'span2'
,
hasChildren
:
false
}
as
Trace
Span
,
])
);
...
...
@@ -51,8 +51,8 @@ describe('useChildrenState', () => {
act
(()
=>
result
.
current
.
childrenToggle
(
'span1'
));
act
(()
=>
result
.
current
.
collapseAll
([
{
spanID
:
'span1'
,
hasChildren
:
true
}
as
Span
,
{
spanID
:
'span2'
,
hasChildren
:
false
}
as
Span
,
{
spanID
:
'span1'
,
hasChildren
:
true
}
as
Trace
Span
,
{
spanID
:
'span2'
,
hasChildren
:
false
}
as
Trace
Span
,
])
);
...
...
public/app/features/explore/TraceView/useChildrenState.ts
View file @
271cc670
import
{
useCallback
,
useState
}
from
'react'
;
import
{
Span
}
from
'@grafana/data'
;
import
{
Trace
Span
}
from
'@grafana/data'
;
/**
* Children state means whether spans are collapsed or not. Also provides some functions to manipulate that state.
...
...
@@ -8,7 +8,7 @@ export function useChildrenState() {
const
[
childrenHiddenIDs
,
setChildrenHiddenIDs
]
=
useState
(
new
Set
<
string
>
());
const
expandOne
=
useCallback
(
function
expandOne
(
spans
:
Span
[])
{
function
expandOne
(
spans
:
Trace
Span
[])
{
if
(
childrenHiddenIDs
.
size
===
0
)
{
return
;
}
...
...
@@ -31,11 +31,11 @@ export function useChildrenState() {
);
const
collapseOne
=
useCallback
(
function
collapseOne
(
spans
:
Span
[])
{
function
collapseOne
(
spans
:
Trace
Span
[])
{
if
(
shouldDisableCollapse
(
spans
,
childrenHiddenIDs
))
{
return
;
}
let
nearestCollapsedAncestor
:
Span
|
undefined
;
let
nearestCollapsedAncestor
:
Trace
Span
|
undefined
;
const
newChildrenHiddenIDs
=
spans
.
reduce
((
res
,
curSpan
)
=>
{
if
(
nearestCollapsedAncestor
&&
curSpan
.
depth
<=
nearestCollapsedAncestor
.
depth
)
{
res
.
add
(
nearestCollapsedAncestor
.
spanID
);
...
...
@@ -61,7 +61,7 @@ export function useChildrenState() {
},
[]);
const
collapseAll
=
useCallback
(
function
collapseAll
(
spans
:
Span
[])
{
function
collapseAll
(
spans
:
Trace
Span
[])
{
if
(
shouldDisableCollapse
(
spans
,
childrenHiddenIDs
))
{
return
;
}
...
...
@@ -100,7 +100,7 @@ export function useChildrenState() {
};
}
function
shouldDisableCollapse
(
allSpans
:
Span
[],
hiddenSpansIds
:
Set
<
string
>
)
{
function
shouldDisableCollapse
(
allSpans
:
Trace
Span
[],
hiddenSpansIds
:
Set
<
string
>
)
{
const
allParentSpans
=
allSpans
.
filter
(
s
=>
s
.
hasChildren
);
return
allParentSpans
.
length
===
hiddenSpansIds
.
size
;
}
public/app/features/explore/TraceView/useDetailState.test.ts
View file @
271cc670
import
{
act
,
renderHook
}
from
'@testing-library/react-hooks'
;
import
{
Log
}
from
'@grafana/data'
;
import
{
Trace
Log
}
from
'@grafana/data'
;
import
{
useDetailState
}
from
'./useDetailState'
;
describe
(
'useDetailState'
,
()
=>
{
...
...
@@ -21,7 +21,7 @@ describe('useDetailState', () => {
act
(()
=>
result
.
current
.
detailLogsToggle
(
'span1'
));
expect
(
result
.
current
.
detailStates
.
get
(
'span1'
)?.
logs
.
isOpen
).
toBe
(
true
);
const
log
=
{
timestamp
:
1
}
as
Log
;
const
log
=
{
timestamp
:
1
}
as
Trace
Log
;
act
(()
=>
result
.
current
.
detailLogItemToggle
(
'span1'
,
log
));
expect
(
result
.
current
.
detailStates
.
get
(
'span1'
)?.
logs
.
openedItems
.
has
(
log
)).
toBe
(
true
);
});
...
...
public/app/features/explore/TraceView/useDetailState.ts
View file @
271cc670
import
{
useCallback
,
useState
}
from
'react'
;
import
{
DetailState
}
from
'@jaegertracing/jaeger-ui-components'
;
import
{
Log
}
from
'@grafana/data'
;
import
{
Trace
Log
}
from
'@grafana/data'
;
/**
* Keeps state of the span detail. This means whether span details are open but also state of each detail subitem
...
...
@@ -23,7 +23,7 @@ export function useDetailState() {
);
const
detailLogItemToggle
=
useCallback
(
function
detailLogItemToggle
(
spanID
:
string
,
log
:
Log
)
{
function
detailLogItemToggle
(
spanID
:
string
,
log
:
Trace
Log
)
{
const
old
=
detailStates
.
get
(
spanID
);
if
(
!
old
)
{
return
;
...
...
public/app/features/explore/TraceView/useSearch.test.ts
View file @
271cc670
import
{
act
,
renderHook
}
from
'@testing-library/react-hooks'
;
import
{
useSearch
}
from
'./useSearch'
;
import
{
Span
}
from
'@grafana/data'
;
import
{
Trace
Span
}
from
'@grafana/data'
;
describe
(
'useSearch'
,
()
=>
{
it
(
'returns matching span IDs'
,
async
()
=>
{
...
...
@@ -15,7 +15,7 @@ describe('useSearch', () => {
},
tags
:
[],
logs
:
[],
}
as
unknown
)
as
Span
,
}
as
unknown
)
as
Trace
Span
,
({
spanID
:
'span2'
,
...
...
@@ -26,7 +26,7 @@ describe('useSearch', () => {
},
tags
:
[],
logs
:
[],
}
as
unknown
)
as
Span
,
}
as
unknown
)
as
Trace
Span
,
])
);
...
...
public/app/features/explore/TraceView/useSearch.ts
View file @
271cc670
import
{
useMemo
,
useState
}
from
'react'
;
import
{
filterSpans
}
from
'@jaegertracing/jaeger-ui-components'
;
import
{
Span
}
from
'@grafana/data'
;
import
{
Trace
Span
}
from
'@grafana/data'
;
/**
* Controls the state of search input that highlights spans if they match the search string.
* @param spans
*/
export
function
useSearch
(
spans
?:
Span
[])
{
export
function
useSearch
(
spans
?:
Trace
Span
[])
{
const
[
search
,
setSearch
]
=
useState
(
''
);
const
spanFindMatches
:
Set
<
string
>
|
undefined
=
useMemo
(()
=>
{
return
search
&&
spans
?
filterSpans
(
search
,
spans
)
:
undefined
;
...
...
public/app/plugins/datasource/jaeger/QueryField.tsx
View file @
271cc670
...
...
@@ -2,7 +2,7 @@ import React from 'react';
import
{
JaegerDatasource
,
JaegerQuery
}
from
'./datasource'
;
import
{
ButtonCascader
,
CascaderOption
}
from
'@grafana/ui'
;
import
{
AppEvents
,
ExploreQueryFieldProps
,
Span
,
TraceData
}
from
'@grafana/data'
;
import
{
AppEvents
,
ExploreQueryFieldProps
,
Trace
Span
,
TraceData
}
from
'@grafana/data'
;
import
{
appEvents
}
from
'../../../core/core'
;
const
ALL_OPERATIONS_KEY
=
'__ALL__'
;
...
...
@@ -13,11 +13,11 @@ interface State {
serviceOptions
:
CascaderOption
[];
}
function
findRootSpan
(
spans
:
Span
[]):
Span
|
undefined
{
function
findRootSpan
(
spans
:
TraceSpan
[]):
Trace
Span
|
undefined
{
return
spans
.
find
(
s
=>
!
s
.
references
?.
length
);
}
function
getLabelFromTrace
(
trace
:
TraceData
&
{
spans
:
Span
[]
}):
string
{
function
getLabelFromTrace
(
trace
:
TraceData
&
{
spans
:
Trace
Span
[]
}):
string
{
const
rootSpan
=
findRootSpan
(
trace
.
spans
);
if
(
rootSpan
)
{
return
`
${
rootSpan
.
operationName
}
[
${
rootSpan
.
duration
/
1000
}
ms]`
;
...
...
public/app/plugins/datasource/zipkin/utils/testData.ts
View file @
271cc670
import
{
SpanData
,
TraceData
}
from
'@grafana/data'
;
import
{
Trace
SpanData
,
TraceData
}
from
'@grafana/data'
;
import
{
ZipkinSpan
}
from
'../types'
;
export
const
zipkinResponse
:
ZipkinSpan
[]
=
[
...
...
@@ -59,7 +59,7 @@ export const zipkinResponse: ZipkinSpan[] = [
},
];
export
const
jaegerTrace
:
TraceData
&
{
spans
:
SpanData
[]
}
=
{
export
const
jaegerTrace
:
TraceData
&
{
spans
:
Trace
SpanData
[]
}
=
{
processes
:
{
'service 1'
:
{
serviceName
:
'service 1'
,
...
...
public/app/plugins/datasource/zipkin/utils/transforms.ts
View file @
271cc670
import
{
identity
}
from
'lodash'
;
import
{
keyBy
}
from
'lodash'
;
import
{
ZipkinAnnotation
,
ZipkinEndpoint
,
ZipkinSpan
}
from
'../types'
;
import
{
KeyValuePair
,
Log
,
Process
,
SpanData
,
TraceData
}
from
'@grafana/data'
;
import
{
TraceKeyValuePair
,
TraceLog
,
TraceProcess
,
Trace
SpanData
,
TraceData
}
from
'@grafana/data'
;
/**
* Transforms response to format similar to Jaegers as we use Jaeger ui on the frontend.
*/
export
function
transformResponse
(
zSpans
:
ZipkinSpan
[]):
TraceData
&
{
spans
:
SpanData
[]
}
{
export
function
transformResponse
(
zSpans
:
ZipkinSpan
[]):
TraceData
&
{
spans
:
Trace
SpanData
[]
}
{
return
{
processes
:
gatherProcesses
(
zSpans
),
traceID
:
zSpans
[
0
].
traceId
,
...
...
@@ -15,8 +15,8 @@ export function transformResponse(zSpans: ZipkinSpan[]): TraceData & { spans: Sp
};
}
function
transformSpan
(
span
:
ZipkinSpan
):
SpanData
{
const
jaegerSpan
:
SpanData
=
{
function
transformSpan
(
span
:
ZipkinSpan
):
Trace
SpanData
{
const
jaegerSpan
:
Trace
SpanData
=
{
duration
:
span
.
duration
,
// TODO: not sure what this is
flags
:
1
,
...
...
@@ -63,7 +63,7 @@ function transformSpan(span: ZipkinSpan): SpanData {
* Maps annotations as a Jaeger log as that seems to be the closest thing.
* See https://zipkin.io/zipkin-api/#/default/get_trace__traceId_
*/
function
transformAnnotation
(
annotation
:
ZipkinAnnotation
):
Log
{
function
transformAnnotation
(
annotation
:
ZipkinAnnotation
):
Trace
Log
{
return
{
timestamp
:
annotation
.
timestamp
,
fields
:
[
...
...
@@ -76,7 +76,7 @@ function transformAnnotation(annotation: ZipkinAnnotation): Log {
};
}
function
gatherProcesses
(
zSpans
:
ZipkinSpan
[]):
Record
<
string
,
Process
>
{
function
gatherProcesses
(
zSpans
:
ZipkinSpan
[]):
Record
<
string
,
Trace
Process
>
{
const
processes
=
zSpans
.
reduce
((
acc
,
span
)
=>
{
if
(
span
.
localEndpoint
)
{
acc
.
push
(
endpointToProcess
(
span
.
localEndpoint
));
...
...
@@ -85,22 +85,22 @@ function gatherProcesses(zSpans: ZipkinSpan[]): Record<string, Process> {
acc
.
push
(
endpointToProcess
(
span
.
remoteEndpoint
));
}
return
acc
;
},
[]
as
Process
[]);
},
[]
as
Trace
Process
[]);
return
keyBy
(
processes
,
'serviceName'
);
}
function
endpointToProcess
(
endpoint
:
ZipkinEndpoint
):
Process
{
function
endpointToProcess
(
endpoint
:
ZipkinEndpoint
):
Trace
Process
{
return
{
serviceName
:
endpoint
.
serviceName
,
tags
:
[
valueToTag
(
'ipv4'
,
endpoint
.
ipv4
,
'string'
),
valueToTag
(
'ipv6'
,
endpoint
.
ipv6
,
'string'
),
valueToTag
(
'port'
,
endpoint
.
port
,
'number'
),
].
filter
(
identity
)
as
KeyValuePair
[],
].
filter
(
identity
)
as
Trace
KeyValuePair
[],
};
}
function
valueToTag
(
key
:
string
,
value
:
string
|
number
|
undefined
,
type
:
string
):
KeyValuePair
|
undefined
{
function
valueToTag
(
key
:
string
,
value
:
string
|
number
|
undefined
,
type
:
string
):
Trace
KeyValuePair
|
undefined
{
if
(
!
value
)
{
return
undefined
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment