Compare commits

...

7 Commits

Author SHA1 Message Date
M. Mert Yıldıran
bbb44dae79 Fix the unit tests of protocol extensions (#982) 2022-04-09 06:56:09 -07:00
M. Mert Yıldıran
72a1aba3e5 TRA-4410 Display namespace field in the UI (#974) 2022-04-08 21:16:25 +03:00
RoyUP9
d8fb8ff710 Fix for OAS reset not working (#978) 2022-04-07 18:14:03 +03:00
Nimrod Gilboa Markevich
f344bd2633 Make minor changes to OasGenerator (#977)
* Added log message
* Remove Reset function from OasGenerator interface, use Stop+Start instead
* SetEntriesQuery returns a bool stating whether the query changed
2022-04-07 10:46:30 +03:00
M. Mert Yıldıran
6575495fa5 Remove gRPC related modifications (#958)
* Remove gRPC related modifications

* Remove gRPC status text related modifications as well

* Fixing gRPC vertical image

detect grpc when content type is 'application/grpc' as well  (and not only from the grpc-status)

Co-authored-by: gadotroee <55343099+gadotroee@users.noreply.github.com>
2022-04-06 18:50:36 +03:00
RoyUP9
cf5c03d45c Fixed service map returning nil values (#975) 2022-04-06 13:12:38 +03:00
Nimrod Gilboa Markevich
491da24c63 Add ability to set query in OAS Generator (#964) 2022-04-06 11:54:55 +03:00
17 changed files with 129 additions and 87 deletions

View File

@@ -199,7 +199,7 @@ func runInHarReaderMode() {
func enableExpFeatureIfNeeded() { func enableExpFeatureIfNeeded() {
if config.Config.OAS { if config.Config.OAS {
oasGenerator := dependency.GetInstance(dependency.OasGeneratorDependency).(oas.OasGenerator) oasGenerator := dependency.GetInstance(dependency.OasGeneratorDependency).(oas.OasGenerator)
oasGenerator.Start() oasGenerator.Start(nil)
} }
if config.Config.ServiceMap { if config.Config.ServiceMap {
serviceMapGenerator := dependency.GetInstance(dependency.ServiceMapGeneratorDependency).(servicemap.ServiceMap) serviceMapGenerator := dependency.GetInstance(dependency.ServiceMapGeneratorDependency).(servicemap.ServiceMap)
@@ -371,7 +371,7 @@ func handleIncomingMessageAsTapper(socketConnection *websocket.Conn) {
func initializeDependencies() { func initializeDependencies() {
dependency.RegisterGenerator(dependency.ServiceMapGeneratorDependency, func() interface{} { return servicemap.GetDefaultServiceMapInstance() }) dependency.RegisterGenerator(dependency.ServiceMapGeneratorDependency, func() interface{} { return servicemap.GetDefaultServiceMapInstance() })
dependency.RegisterGenerator(dependency.OasGeneratorDependency, func() interface{} { return oas.GetDefaultOasGeneratorInstance(nil) }) dependency.RegisterGenerator(dependency.OasGeneratorDependency, func() interface{} { return oas.GetDefaultOasGeneratorInstance() })
dependency.RegisterGenerator(dependency.EntriesProvider, func() interface{} { return &entries.BasenineEntriesProvider{} }) dependency.RegisterGenerator(dependency.EntriesProvider, func() interface{} { return &entries.BasenineEntriesProvider{} })
dependency.RegisterGenerator(dependency.EntriesSocketStreamer, func() interface{} { return &api.BasenineEntryStreamer{} }) dependency.RegisterGenerator(dependency.EntriesSocketStreamer, func() interface{} { return &api.BasenineEntryStreamer{} })
dependency.RegisterGenerator(dependency.EntryStreamerSocketConnector, func() interface{} { return &api.DefaultEntryStreamerSocketConnector{} }) dependency.RegisterGenerator(dependency.EntryStreamerSocketConnector, func() interface{} { return &api.DefaultEntryStreamerSocketConnector{} })

View File

@@ -58,12 +58,12 @@ func getRecorderAndContext() (*httptest.ResponseRecorder, *gin.Context) {
receiveBuffer: bytes.NewBufferString("\n"), receiveBuffer: bytes.NewBufferString("\n"),
} }
dependency.RegisterGenerator(dependency.OasGeneratorDependency, func() interface{} { dependency.RegisterGenerator(dependency.OasGeneratorDependency, func() interface{} {
return oas.GetDefaultOasGeneratorInstance(dummyConn) return oas.GetDefaultOasGeneratorInstance()
}) })
recorder := httptest.NewRecorder() recorder := httptest.NewRecorder()
c, _ := gin.CreateTestContext(recorder) c, _ := gin.CreateTestContext(recorder)
oas.GetDefaultOasGeneratorInstance(dummyConn).Start() oas.GetDefaultOasGeneratorInstance().Start(dummyConn)
oas.GetDefaultOasGeneratorInstance(dummyConn).GetServiceSpecs().Store("some", oas.NewGen("some")) oas.GetDefaultOasGeneratorInstance().GetServiceSpecs().Store("some", oas.NewGen("some"))
return recorder, c return recorder, c
} }

View File

@@ -19,46 +19,57 @@ var (
) )
type OasGenerator interface { type OasGenerator interface {
Start() Start(conn *basenine.Connection)
Stop() Stop()
IsStarted() bool IsStarted() bool
Reset()
GetServiceSpecs() *sync.Map GetServiceSpecs() *sync.Map
SetEntriesQuery(query string) bool
} }
type defaultOasGenerator struct { type defaultOasGenerator struct {
started bool started bool
ctx context.Context ctx context.Context
cancel context.CancelFunc cancel context.CancelFunc
serviceSpecs *sync.Map serviceSpecs *sync.Map
dbConn *basenine.Connection dbConn *basenine.Connection
entriesQuery string
} }
func GetDefaultOasGeneratorInstance(conn *basenine.Connection) *defaultOasGenerator { func GetDefaultOasGeneratorInstance() *defaultOasGenerator {
syncOnce.Do(func() { syncOnce.Do(func() {
if conn == nil { instance = NewDefaultOasGenerator()
c, err := basenine.NewConnection(shared.BasenineHost, shared.BaseninePort)
if err != nil {
panic(err)
}
conn = c
}
instance = NewDefaultOasGenerator(conn)
logger.Log.Debug("OAS Generator Initialized") logger.Log.Debug("OAS Generator Initialized")
}) })
return instance return instance
} }
func (g *defaultOasGenerator) Start() { func (g *defaultOasGenerator) Start(conn *basenine.Connection) {
if g.started { if g.started {
return return
} }
if g.dbConn == nil {
if conn == nil {
logger.Log.Infof("Creating new DB connection for OAS generator to address %s:%s", shared.BasenineHost, shared.BaseninePort)
newConn, err := basenine.NewConnection(shared.BasenineHost, shared.BaseninePort)
if err != nil {
logger.Log.Error("Error connecting to DB for OAS generator, err: %v", err)
return
}
conn = newConn
}
g.dbConn = conn
}
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
g.cancel = cancel g.cancel = cancel
g.ctx = ctx g.ctx = ctx
g.serviceSpecs = &sync.Map{} g.serviceSpecs = &sync.Map{}
g.started = true g.started = true
go g.runGenerator() go g.runGenerator()
} }
@@ -66,8 +77,15 @@ func (g *defaultOasGenerator) Stop() {
if !g.started { if !g.started {
return return
} }
if g.dbConn != nil {
g.dbConn.Close()
g.dbConn = nil
}
g.cancel() g.cancel()
g.Reset() g.reset()
g.started = false g.started = false
} }
@@ -76,16 +94,19 @@ func (g *defaultOasGenerator) IsStarted() bool {
} }
func (g *defaultOasGenerator) runGenerator() { func (g *defaultOasGenerator) runGenerator() {
// Make []byte channels to recieve the data and the meta // Make []byte channels to receive the data and the meta
dataChan := make(chan []byte) dataChan := make(chan []byte)
metaChan := make(chan []byte) metaChan := make(chan []byte)
g.dbConn.Query("", dataChan, metaChan) logger.Log.Infof("Querying DB for OAS generator with query '%s'", g.entriesQuery)
g.dbConn.Query(g.entriesQuery, dataChan, metaChan)
for { for {
select { select {
case <-g.ctx.Done(): case <-g.ctx.Done():
logger.Log.Infof("OAS Generator was canceled") logger.Log.Infof("OAS Generator was canceled")
close(dataChan)
close(metaChan)
return return
case metaBytes, ok := <-metaChan: case metaBytes, ok := <-metaChan:
@@ -173,7 +194,7 @@ func (g *defaultOasGenerator) getGen(dest string, urlStr string) *SpecGen {
return gen return gen
} }
func (g *defaultOasGenerator) Reset() { func (g *defaultOasGenerator) reset() {
g.serviceSpecs = &sync.Map{} g.serviceSpecs = &sync.Map{}
} }
@@ -181,12 +202,18 @@ func (g *defaultOasGenerator) GetServiceSpecs() *sync.Map {
return g.serviceSpecs return g.serviceSpecs
} }
func NewDefaultOasGenerator(c *basenine.Connection) *defaultOasGenerator { func (g *defaultOasGenerator) SetEntriesQuery(query string) bool {
changed := g.entriesQuery != query
g.entriesQuery = query
return changed
}
func NewDefaultOasGenerator() *defaultOasGenerator {
return &defaultOasGenerator{ return &defaultOasGenerator{
started: false, started: false,
ctx: nil, ctx: nil,
cancel: nil, cancel: nil,
serviceSpecs: nil, serviceSpecs: nil,
dbConn: c, dbConn: nil,
} }
} }

View File

@@ -3,13 +3,11 @@ package oas
import ( import (
"encoding/json" "encoding/json"
"github.com/up9inc/mizu/agent/pkg/har" "github.com/up9inc/mizu/agent/pkg/har"
"sync"
"testing" "testing"
) )
func TestOASGen(t *testing.T) { func TestOASGen(t *testing.T) {
gen := new(defaultOasGenerator) gen := new(defaultOasGenerator)
gen.serviceSpecs = &sync.Map{}
e := new(har.Entry) e := new(har.Entry)
err := json.Unmarshal([]byte(`{"startedDateTime": "20000101","request": {"url": "https://host/path", "method": "GET"}, "response": {"status": 200}}`), e) err := json.Unmarshal([]byte(`{"startedDateTime": "20000101","request": {"url": "https://host/path", "method": "GET"}, "response": {"status": 200}}`), e)
@@ -21,6 +19,9 @@ func TestOASGen(t *testing.T) {
Destination: "some", Destination: "some",
Entry: *e, Entry: *e,
} }
dummyConn := GetFakeDBConn(`{"startedDateTime": "20000101","request": {"url": "https://host/path", "method": "GET"}, "response": {"status": 200}}`)
gen.Start(dummyConn)
gen.handleHARWithSource(ews) gen.handleHARWithSource(ews)
g, ok := gen.serviceSpecs.Load("some") g, ok := gen.serviceSpecs.Load("some")
if !ok { if !ok {
@@ -33,4 +34,9 @@ func TestOASGen(t *testing.T) {
} }
specText, _ := json.Marshal(spec) specText, _ := json.Marshal(spec)
t.Log(string(specText)) t.Log(string(specText))
if !gen.IsStarted() {
t.Errorf("Should be started")
}
gen.Stop()
} }

View File

@@ -1,8 +1,10 @@
package oas package oas
import ( import (
"bytes"
"encoding/json" "encoding/json"
"io/ioutil" "io/ioutil"
"net"
"os" "os"
"regexp" "regexp"
"strings" "strings"
@@ -11,13 +13,22 @@ import (
"time" "time"
"github.com/chanced/openapi" "github.com/chanced/openapi"
"github.com/op/go-logging"
"github.com/up9inc/mizu/shared/logger" "github.com/up9inc/mizu/shared/logger"
"github.com/wI2L/jsondiff" "github.com/wI2L/jsondiff"
basenine "github.com/up9inc/basenine/client/go"
"github.com/up9inc/mizu/agent/pkg/har" "github.com/up9inc/mizu/agent/pkg/har"
) )
func GetFakeDBConn(send string) *basenine.Connection {
dummyConn := new(basenine.Connection)
dummyConn.Conn = FakeConn{
sendBuffer: bytes.NewBufferString(send),
receiveBuffer: bytes.NewBufferString(""),
}
return dummyConn
}
// if started via env, write file into subdir // if started via env, write file into subdir
func outputSpec(label string, spec *openapi.OpenAPI, t *testing.T) string { func outputSpec(label string, spec *openapi.OpenAPI, t *testing.T) string {
content, err := json.MarshalIndent(spec, "", " ") content, err := json.MarshalIndent(spec, "", " ")
@@ -43,14 +54,14 @@ func outputSpec(label string, spec *openapi.OpenAPI, t *testing.T) string {
} }
func TestEntries(t *testing.T) { func TestEntries(t *testing.T) {
logger.InitLoggerStd(logging.INFO) //logger.InitLoggerStd(logging.INFO) causes race condition
files, err := getFiles("./test_artifacts/") files, err := getFiles("./test_artifacts/")
if err != nil { if err != nil {
t.Log(err) t.Log(err)
t.FailNow() t.FailNow()
} }
gen := NewDefaultOasGenerator(nil) gen := NewDefaultOasGenerator()
gen.serviceSpecs = new(sync.Map) gen.serviceSpecs = new(sync.Map)
loadStartingOAS("test_artifacts/catalogue.json", "catalogue", gen.serviceSpecs) loadStartingOAS("test_artifacts/catalogue.json", "catalogue", gen.serviceSpecs)
loadStartingOAS("test_artifacts/trcc.json", "trcc-api-service", gen.serviceSpecs) loadStartingOAS("test_artifacts/trcc.json", "trcc-api-service", gen.serviceSpecs)
@@ -124,7 +135,7 @@ func TestEntries(t *testing.T) {
} }
func TestFileSingle(t *testing.T) { func TestFileSingle(t *testing.T) {
gen := NewDefaultOasGenerator(nil) gen := NewDefaultOasGenerator()
gen.serviceSpecs = new(sync.Map) gen.serviceSpecs = new(sync.Map)
// loadStartingOAS() // loadStartingOAS()
file := "test_artifacts/params.har" file := "test_artifacts/params.har"
@@ -214,7 +225,7 @@ func loadStartingOAS(file string, label string, specs *sync.Map) {
} }
func TestEntriesNegative(t *testing.T) { func TestEntriesNegative(t *testing.T) {
gen := NewDefaultOasGenerator(nil) gen := NewDefaultOasGenerator()
gen.serviceSpecs = new(sync.Map) gen.serviceSpecs = new(sync.Map)
files := []string{"invalid"} files := []string{"invalid"}
_, err := feedEntries(files, false, gen) _, err := feedEntries(files, false, gen)
@@ -225,7 +236,7 @@ func TestEntriesNegative(t *testing.T) {
} }
func TestEntriesPositive(t *testing.T) { func TestEntriesPositive(t *testing.T) {
gen := NewDefaultOasGenerator(nil) gen := NewDefaultOasGenerator()
gen.serviceSpecs = new(sync.Map) gen.serviceSpecs = new(sync.Map)
files := []string{"test_artifacts/params.har"} files := []string{"test_artifacts/params.har"}
_, err := feedEntries(files, false, gen) _, err := feedEntries(files, false, gen)
@@ -267,3 +278,17 @@ func TestLoadValid3_1(t *testing.T) {
t.FailNow() t.FailNow()
} }
} }
type FakeConn struct {
sendBuffer *bytes.Buffer
receiveBuffer *bytes.Buffer
}
func (f FakeConn) Read(p []byte) (int, error) { return f.sendBuffer.Read(p) }
func (f FakeConn) Write(p []byte) (int, error) { return f.receiveBuffer.Write(p) }
func (FakeConn) Close() error { return nil }
func (FakeConn) LocalAddr() net.Addr { return nil }
func (FakeConn) RemoteAddr() net.Addr { return nil }
func (FakeConn) SetDeadline(t time.Time) error { return nil }
func (FakeConn) SetReadDeadline(t time.Time) error { return nil }
func (FakeConn) SetWriteDeadline(t time.Time) error { return nil }

View File

@@ -224,7 +224,8 @@ func (s *defaultServiceMap) GetStatus() ServiceMapStatus {
} }
func (s *defaultServiceMap) GetNodes() []ServiceMapNode { func (s *defaultServiceMap) GetNodes() []ServiceMapNode {
var nodes []ServiceMapNode nodes := []ServiceMapNode{}
for i, n := range s.graph.Nodes { for i, n := range s.graph.Nodes {
nodes = append(nodes, ServiceMapNode{ nodes = append(nodes, ServiceMapNode{
Id: n.id, Id: n.id,
@@ -234,11 +235,13 @@ func (s *defaultServiceMap) GetNodes() []ServiceMapNode {
Count: n.count, Count: n.count,
}) })
} }
return nodes return nodes
} }
func (s *defaultServiceMap) GetEdges() []ServiceMapEdge { func (s *defaultServiceMap) GetEdges() []ServiceMapEdge {
var edges []ServiceMapEdge edges := []ServiceMapEdge{}
for u, m := range s.graph.Edges { for u, m := range s.graph.Edges {
for v := range m { for v := range m {
for _, p := range s.graph.Edges[u][v].data { for _, p := range s.graph.Edges[u][v].data {
@@ -263,6 +266,7 @@ func (s *defaultServiceMap) GetEdges() []ServiceMapEdge {
} }
} }
} }
return edges return edges
} }

View File

@@ -403,10 +403,10 @@ func (s *ServiceMapEnabledSuite) TestServiceMap() {
assert.Equal(0, status.EdgeCount) assert.Equal(0, status.EdgeCount)
// Nodes after reset // Nodes after reset
assert.Equal([]ServiceMapNode(nil), nodes) assert.Equal([]ServiceMapNode{}, nodes)
// Edges after reset // Edges after reset
assert.Equal([]ServiceMapEdge(nil), edges) assert.Equal([]ServiceMapEdge{}, edges)
} }
func TestServiceMapSuite(t *testing.T) { func TestServiceMapSuite(t *testing.T) {

View File

@@ -161,7 +161,7 @@ type Entry struct {
Capture Capture `json:"capture"` Capture Capture `json:"capture"`
Source *TCP `json:"src"` Source *TCP `json:"src"`
Destination *TCP `json:"dst"` Destination *TCP `json:"dst"`
Namespace string `json:"namespace,omitempty"` Namespace string `json:"namespace"`
Outgoing bool `json:"outgoing"` Outgoing bool `json:"outgoing"`
Timestamp int64 `json:"timestamp"` Timestamp int64 `json:"timestamp"`
StartTime time.Time `json:"startTime"` StartTime time.Time `json:"startTime"`

View File

@@ -13,4 +13,4 @@ test-pull-bin:
test-pull-expect: test-pull-expect:
@mkdir -p expect @mkdir -p expect
@[ "${skipexpect}" ] && echo "Skipping downloading expected JSONs" || gsutil -o 'GSUtil:parallel_process_count=5' -o 'GSUtil:parallel_thread_count=5' -m cp -r gs://static.up9.io/mizu/test-pcap/expect5/amqp/\* expect @[ "${skipexpect}" ] && echo "Skipping downloading expected JSONs" || gsutil -o 'GSUtil:parallel_process_count=5' -o 'GSUtil:parallel_thread_count=5' -m cp -r gs://static.up9.io/mizu/test-pcap/expect6/amqp/\* expect

View File

@@ -13,4 +13,4 @@ test-pull-bin:
test-pull-expect: test-pull-expect:
@mkdir -p expect @mkdir -p expect
@[ "${skipexpect}" ] && echo "Skipping downloading expected JSONs" || gsutil -o 'GSUtil:parallel_process_count=5' -o 'GSUtil:parallel_thread_count=5' -m cp -r gs://static.up9.io/mizu/test-pcap/expect5/http/\* expect @[ "${skipexpect}" ] && echo "Skipping downloading expected JSONs" || gsutil -o 'GSUtil:parallel_process_count=5' -o 'GSUtil:parallel_thread_count=5' -m cp -r gs://static.up9.io/mizu/test-pcap/expect6/http/\* expect

View File

@@ -28,26 +28,6 @@ const protoMinorHTTP2 = 0
var maxHTTP2DataLen = 1 * 1024 * 1024 // 1MB var maxHTTP2DataLen = 1 * 1024 * 1024 // 1MB
var grpcStatusCodes = []string{
"OK",
"CANCELLED",
"UNKNOWN",
"INVALID_ARGUMENT",
"DEADLINE_EXCEEDED",
"NOT_FOUND",
"ALREADY_EXISTS",
"PERMISSION_DENIED",
"RESOURCE_EXHAUSTED",
"FAILED_PRECONDITION",
"ABORTED",
"OUT_OF_RANGE",
"UNIMPLEMENTED",
"INTERNAL",
"UNAVAILABLE",
"DATA_LOSS",
"UNAUTHENTICATED",
}
type messageFragment struct { type messageFragment struct {
headers []hpack.HeaderField headers []hpack.HeaderField
data []byte data []byte
@@ -142,18 +122,8 @@ func (ga *Http2Assembler) readMessage() (streamID uint32, messageHTTP1 interface
// gRPC detection // gRPC detection
grpcStatus := headersHTTP1.Get("Grpc-Status") grpcStatus := headersHTTP1.Get("Grpc-Status")
if grpcStatus != "" { if grpcStatus != "" || strings.Contains(headersHTTP1.Get("Content-Type"), "application/grpc") {
isGrpc = true isGrpc = true
status = grpcStatus
}
if strings.Contains(headersHTTP1.Get("Content-Type"), "application/grpc") {
isGrpc = true
grpcPath := headersHTTP1.Get(":path")
pathSegments := strings.Split(grpcPath, "/")
if len(pathSegments) > 0 {
method = pathSegments[len(pathSegments)-1]
}
} }
if method != "" { if method != "" {

View File

@@ -248,11 +248,6 @@ func (d dissecting) Analyze(item *api.OutputChannelItem, resolvedSource string,
reqDetails["_queryStringMerged"] = mapSliceMergeRepeatedKeys(reqDetails["_queryString"].([]interface{})) reqDetails["_queryStringMerged"] = mapSliceMergeRepeatedKeys(reqDetails["_queryString"].([]interface{}))
reqDetails["queryString"] = mapSliceRebuildAsMap(reqDetails["_queryStringMerged"].([]interface{})) reqDetails["queryString"] = mapSliceRebuildAsMap(reqDetails["_queryStringMerged"].([]interface{}))
statusCode := int(resDetails["status"].(float64))
if item.Protocol.Abbreviation == "gRPC" {
resDetails["statusText"] = grpcStatusCodes[statusCode]
}
elapsedTime := item.Pair.Response.CaptureTime.Sub(item.Pair.Request.CaptureTime).Round(time.Millisecond).Milliseconds() elapsedTime := item.Pair.Response.CaptureTime.Sub(item.Pair.Request.CaptureTime).Round(time.Millisecond).Milliseconds()
if elapsedTime < 0 { if elapsedTime < 0 {
elapsedTime = 0 elapsedTime = 0

View File

@@ -13,4 +13,4 @@ test-pull-bin:
test-pull-expect: test-pull-expect:
@mkdir -p expect @mkdir -p expect
@[ "${skipexpect}" ] && echo "Skipping downloading expected JSONs" || gsutil -o 'GSUtil:parallel_process_count=5' -o 'GSUtil:parallel_thread_count=5' -m cp -r gs://static.up9.io/mizu/test-pcap/expect5/kafka/\* expect @[ "${skipexpect}" ] && echo "Skipping downloading expected JSONs" || gsutil -o 'GSUtil:parallel_process_count=5' -o 'GSUtil:parallel_thread_count=5' -m cp -r gs://static.up9.io/mizu/test-pcap/expect6/kafka/\* expect

View File

@@ -13,4 +13,4 @@ test-pull-bin:
test-pull-expect: test-pull-expect:
@mkdir -p expect @mkdir -p expect
@[ "${skipexpect}" ] && echo "Skipping downloading expected JSONs" || gsutil -o 'GSUtil:parallel_process_count=5' -o 'GSUtil:parallel_thread_count=5' -m cp -r gs://static.up9.io/mizu/test-pcap/expect5/redis/\* expect @[ "${skipexpect}" ] && echo "Skipping downloading expected JSONs" || gsutil -o 'GSUtil:parallel_process_count=5' -o 'GSUtil:parallel_thread_count=5' -m cp -r gs://static.up9.io/mizu/test-pcap/expect6/redis/\* expect

View File

@@ -89,12 +89,13 @@ const EntryTitle: React.FC<any> = ({ protocol, data, elapsedTime }) => {
</div>; </div>;
}; };
const EntrySummary: React.FC<any> = ({ entry }) => { const EntrySummary: React.FC<any> = ({ entry, namespace }) => {
return <EntryItem return <EntryItem
key={`entry-${entry.id}`} key={`entry-${entry.id}`}
entry={entry} entry={entry}
style={{}} style={{}}
headingMode={true} headingMode={true}
namespace={namespace}
/>; />;
}; };
@@ -140,7 +141,7 @@ export const EntryDetailed = () => {
data={entryData.data} data={entryData.data}
elapsedTime={entryData.data.elapsedTime} elapsedTime={entryData.data.elapsedTime}
/>} />}
{!isLoading && entryData && <EntrySummary entry={entryData.base} />} {!isLoading && entryData && <EntrySummary entry={entryData.base} namespace={entryData.data.namespace} />}
<React.Fragment> <React.Fragment>
{!isLoading && entryData && <EntryViewer {!isLoading && entryData && <EntryViewer
representation={entryData.representation} representation={entryData.representation}

View File

@@ -52,6 +52,7 @@ interface EntryProps {
entry: Entry; entry: Entry;
style: object; style: object;
headingMode: boolean; headingMode: boolean;
namespace?: string;
} }
enum CaptureTypes { enum CaptureTypes {
@@ -62,7 +63,7 @@ enum CaptureTypes {
Ebpf = "ebpf", Ebpf = "ebpf",
} }
export const EntryItem: React.FC<EntryProps> = ({entry, style, headingMode}) => { export const EntryItem: React.FC<EntryProps> = ({entry, style, headingMode, namespace}) => {
const [focusedEntryId, setFocusedEntryId] = useRecoilState(focusedEntryIdAtom); const [focusedEntryId, setFocusedEntryId] = useRecoilState(focusedEntryIdAtom);
const [queryState, setQuery] = useRecoilState(queryAtom); const [queryState, setQuery] = useRecoilState(queryAtom);
@@ -224,6 +225,19 @@ export const EntryItem: React.FC<EntryProps> = ({entry, style, headingMode}) =>
: "" : ""
} }
<div className={styles.separatorRight}> <div className={styles.separatorRight}>
{headingMode ? <Queryable
query={`namespace == "${namespace}"`}
displayIconOnMouseOver={true}
flipped={true}
iconStyle={{marginRight: "16px"}}
>
<span
className={`${styles.tcpInfo} ${styles.ip}`}
title="Namespace"
>
{namespace}
</span>
</Queryable> : null}
<Queryable <Queryable
query={`src.ip == "${entry.src.ip}"`} query={`src.ip == "${entry.src.ip}"`}
displayIconOnMouseOver={true} displayIconOnMouseOver={true}

View File

@@ -37,9 +37,9 @@ export function getClassification(statusCode: number): string {
// 1 - 16 HTTP/2 (gRPC) status codes // 1 - 16 HTTP/2 (gRPC) status codes
// 2xx - 5xx HTTP/1.x status codes // 2xx - 5xx HTTP/1.x status codes
if ((statusCode >= 200 && statusCode <= 399) || statusCode === 0) { if (statusCode >= 200 && statusCode <= 399) {
classification = StatusCodeClassification.SUCCESS; classification = StatusCodeClassification.SUCCESS;
} else if (statusCode >= 400 || (statusCode >= 1 && statusCode <= 16)) { } else if (statusCode >= 400) {
classification = StatusCodeClassification.FAILURE; classification = StatusCodeClassification.FAILURE;
} }