graph

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Graph package provides support for the graph handlers such as supported path variables and query params, as well as types for graph processing.

Index

Constants

View Source
const (
	GraphTypeApp          string = "app"
	GraphTypeService      string = "service" // Treated as graphType Workload, with service injection, and then condensed
	GraphTypeVersionedApp string = "versionedApp"
	GraphTypeWorkload     string = "workload"
	NodeTypeApp           string = "app"
	NodeTypeService       string = "service"
	NodeTypeUnknown       string = "unknown" // The special "unknown" traffic gen node
	NodeTypeWorkload      string = "workload"
	TF                    string = "2006-01-02 15:04:05" // TF is the TimeFormat for timestamps
	Unknown               string = "unknown"             // Istio unknown label value
)

Variables

View Source
var Protocols []Protocol = []Protocol{GRPC, HTTP, TCP}

Functions

func AddOutgoingEdgeToMetadata

func AddOutgoingEdgeToMetadata(sourceMetadata, edgeMetadata map[string]interface{})

func AddServiceGraphTraffic

func AddServiceGraphTraffic(toEdge, fromEdge *Edge)

func AddToMetadata

func AddToMetadata(protocol string, val float64, code, flags string, sourceMetadata, destMetadata, edgeMetadata map[string]interface{})

func BadRequest

func BadRequest(message string)

BadRequest panics with BadRequest and the provided message

func CheckError

func CheckError(err error)

CheckError panics with the supplied error if it is non-nil

func Error

func Error(message string)

Error panics with InternalServerError and the provided message

func Forbidden

func Forbidden(message string)

Forbidden panics with Forbidden and the provided message

func Id

func Id(serviceNamespace, service, workloadNamespace, workload, app, version, graphType string) (id, nodeType string)

func IsOK

func IsOK(telemetryVal string) bool

IsOK just validates that a telemetry label value is not empty or unknown

Types

type Edge

type Edge struct {
	Source   *Node
	Dest     *Node
	Metadata map[string]interface{} // app-specific data
}

func NewEdge

func NewEdge(source, dest *Node) Edge

type NamespaceInfo

type NamespaceInfo struct {
	Name     string
	Duration time.Duration
}

type Node

type Node struct {
	ID        string                 // unique identifier for the node
	NodeType  string                 // Node type
	Namespace string                 // Namespace
	Workload  string                 // Workload (deployment) name
	App       string                 // Workload app label value
	Version   string                 // Workload version label value
	Service   string                 // Service name
	Edges     []*Edge                // child nodes
	Metadata  map[string]interface{} // app-specific data
}

func NewNode

func NewNode(serviceNamespace, service, workloadNamespace, workload, app, version, graphType string) Node

func NewNodeExplicit

func NewNodeExplicit(id, namespace, workload, app, version, service, nodeType, graphType string) Node

func (*Node) AddEdge

func (s *Node) AddEdge(dest *Node) *Edge

type Protocol

type Protocol struct {
	Name          string
	EdgeRates     []Rate
	EdgeResponses string
	NodeRates     []Rate
	Unit          string
	UnitShort     string
}
var GRPC Protocol = Protocol{
	Name: grpc,
	EdgeRates: []Rate{
		Rate{Name: grpc, IsTotal: true, Precision: 2},
		Rate{Name: grpcErr, IsErr: true, Precision: 2},
		Rate{Name: grpcPercentErr, IsPercentErr: true, Precision: 1},
		Rate{Name: grpcPercentReq, IsPercentReq: true, Precision: 1},
	},
	EdgeResponses: grpcResponses,
	NodeRates: []Rate{
		Rate{Name: grpcIn, IsIn: true, Precision: 2},
		Rate{Name: grpcInErr, IsErr: true, Precision: 2},
		Rate{Name: grpcOut, IsOut: true, Precision: 2},
	},
	Unit:      requestsPerSecond,
	UnitShort: rps,
}
var HTTP Protocol = Protocol{
	Name: http,
	EdgeRates: []Rate{
		Rate{Name: http, IsTotal: true, Precision: 2},
		Rate{Name: http3xx, Precision: 2},
		Rate{Name: http4xx, IsErr: true, Precision: 2},
		Rate{Name: http5xx, IsErr: true, Precision: 2},
		Rate{Name: httpPercentErr, IsPercentErr: true, Precision: 1},
		Rate{Name: httpPercentReq, IsPercentReq: true, Precision: 1},
	},
	EdgeResponses: httpResponses,
	NodeRates: []Rate{
		Rate{Name: httpIn, IsIn: true, Precision: 2},
		Rate{Name: httpIn3xx, Precision: 2},
		Rate{Name: httpIn4xx, IsErr: true, Precision: 2},
		Rate{Name: httpIn5xx, IsErr: true, Precision: 2},
		Rate{Name: httpOut, IsOut: true, Precision: 2},
	},
	Unit:      requestsPerSecond,
	UnitShort: rps,
}
var TCP Protocol = Protocol{
	Name: tcp,
	EdgeRates: []Rate{
		Rate{Name: tcp, IsTotal: true, Precision: 2},
	},
	EdgeResponses: tcpResponses,
	NodeRates: []Rate{
		Rate{Name: tcpIn, IsIn: true, Precision: 2},
		Rate{Name: tcpOut, IsOut: true, Precision: 2},
	},
	Unit:      bytesPerSecond,
	UnitShort: bps,
}

type Rate

type Rate struct {
	Name         string
	IsErr        bool
	IsIn         bool
	IsOut        bool
	IsPercentErr bool
	IsPercentReq bool
	IsTotal      bool
	Precision    int
}

type Response

type Response struct {
	Message string
	Code    int
}

func Panic

func Panic(message string, code int) Response

Panic panics with the provided HTTP response code and message

type ResponseFlags added in v0.17.0

type ResponseFlags map[string]float64

type Responses added in v0.17.0

type Responses map[string]ResponseFlags

type Service

type Service struct {
	Namespace string `json:"namespace"`
	Name      string `json:"name"`
}

func (*Service) Key

func (s *Service) Key() string

type TrafficMap

type TrafficMap map[string]*Node

TrafficMap is a map of app Nodes, each optionally holding Edge data. Metadata is a general purpose map for holding any desired node or edge information. Each app node should have a unique namespace+workload. Note that it is feasible but likely unusual to have two nodes with the same name+version in the same namespace.

func NewTrafficMap

func NewTrafficMap() TrafficMap

Directories

Path Synopsis
Cytoscape package provides conversion from our graph to the CystoscapeJS configuration json model.
Cytoscape package provides conversion from our graph to the CystoscapeJS configuration json model.
Package options holds the option settings for a single graph generation.
Package options holds the option settings for a single graph generation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL