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
- Variables
- func AddOutgoingEdgeToMetadata(sourceMetadata, edgeMetadata Metadata)
- func AddToMetadata(protocol string, val float64, code, flags, host string, ...)
- func AggregateEdgeTraffic(edge, aggregateEdge *Edge)
- func AggregateID(namespace, aggregate, aggregateVal, svcName string) (id string)
- func AggregateNodeTraffic(node, aggregateNode *Node)
- func BadRequest(message string)
- func CheckError(err error)
- func Error(message string)
- func Forbidden(message string)
- func Id(...) (id, nodeType string)
- func IsGRPCErr(code string) bool
- func IsHTTPErr(code string) bool
- func IsOK(telemetryVal string) bool
- func ResetOutgoingMetadata(sourceMetadata Metadata)
- type Appender
- type AppenderGlobalInfo
- type AppenderNamespaceInfo
- type AppenderVendorInfo
- type CommonOptions
- type ConfigOptions
- type ConfigVendor
- type DestServicesMetadata
- type Edge
- type Metadata
- type MetadataKey
- type NamespaceInfo
- type NamespaceInfoMap
- type Node
- func NewAggregateNode(namespace, aggregate, aggregateValue, svcName, app string) Node
- func NewAggregateNodeExplicit(id, namespace, aggregate, aggregateValue, svcName, app string) Node
- func NewNode(...) Node
- func NewNodeExplicit(id, namespace, workload, app, version, service, nodeType, graphType string) Node
- type NodeOptions
- type Options
- type Protocol
- type Rate
- type RequestedAppenders
- type Response
- type ResponseDetail
- type ResponseFlags
- type ResponseHosts
- type Responses
- type ServiceName
- type TelemetryOptions
- type TelemetryVendor
- type TrafficMap
Constants ¶
const ( VendorCytoscape string = "cytoscape" VendorIstio string = "istio" )
The supported vendors
const ( GroupByApp string = "app" GroupByNone string = "none" GroupByVersion string = "version" NamespaceIstio string = "istio-system" )
const ( GraphTypeApp string = "app" GraphTypeService string = "service" // Treated as graphType Workload, with service injection, and then condensed GraphTypeVersionedApp string = "versionedApp" GraphTypeWorkload string = "workload" NodeTypeAggregate string = "aggregate" // The special "aggregate" traffic node 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 ¶
var GRPC = Protocol{ Name: grpc, EdgeRates: []Rate{ {Name: grpc, IsTotal: true, Precision: 2}, {Name: grpcNoResponse, IsErr: true, Precision: 2}, {Name: grpcErr, IsErr: true, Precision: 2}, {Name: grpcPercentErr, IsPercentErr: true, Precision: 1}, {Name: grpcPercentReq, IsPercentReq: true, Precision: 1}, }, EdgeResponses: grpcResponses, NodeRates: []Rate{ {Name: grpcIn, IsIn: true, Precision: 2}, {Name: grpcInNoResponse, IsErr: true, Precision: 2}, {Name: grpcInErr, IsErr: true, Precision: 2}, {Name: grpcOut, IsOut: true, Precision: 2}, }, Unit: requestsPerSecond, UnitShort: rps, }
GRPC Protocol
var HTTP = Protocol{ Name: http, EdgeRates: []Rate{ {Name: http, IsTotal: true, Precision: 2}, {Name: httpNoResponse, IsErr: true, Precision: 2}, {Name: http3xx, Precision: 2}, {Name: http4xx, IsErr: true, Precision: 2}, {Name: http5xx, IsErr: true, Precision: 2}, {Name: httpPercentErr, IsPercentErr: true, Precision: 1}, {Name: httpPercentReq, IsPercentReq: true, Precision: 1}, }, EdgeResponses: httpResponses, NodeRates: []Rate{ {Name: httpIn, IsIn: true, Precision: 2}, {Name: httpInNoResponse, IsErr: true, Precision: 2}, {Name: httpIn3xx, Precision: 2}, {Name: httpIn4xx, IsErr: true, Precision: 2}, {Name: httpIn5xx, IsErr: true, Precision: 2}, {Name: httpOut, IsOut: true, Precision: 2}, }, Unit: requestsPerSecond, UnitShort: rps, }
HTTP Protocol
var Protocols = []Protocol{GRPC, HTTP, TCP}
Protocols defines the supported protocols to be handled by the vendor code.
var TCP = Protocol{ Name: tcp, EdgeRates: []Rate{ {Name: tcp, IsTotal: true, Precision: 2}, }, EdgeResponses: tcpResponses, NodeRates: []Rate{ {Name: tcpIn, IsIn: true, Precision: 2}, {Name: tcpOut, IsOut: true, Precision: 2}, }, Unit: bytesPerSecond, UnitShort: bps, }
TCP Protocol
Functions ¶
func AddOutgoingEdgeToMetadata ¶ added in v0.14.0
func AddOutgoingEdgeToMetadata(sourceMetadata, edgeMetadata Metadata)
AddOutgoingEdgeToMetadata updates the source node's outgoing traffic with the outgoing edge traffic value
func AddToMetadata ¶ added in v0.14.0
func AddToMetadata(protocol string, val float64, code, flags, host string, sourceMetadata, destMetadata, edgeMetadata Metadata)
AddToMetadata takes a single traffic value and adds it appropriately as source, dest and edge traffic
func AggregateEdgeTraffic ¶ added in v1.0.0
func AggregateEdgeTraffic(edge, aggregateEdge *Edge)
AggregateEdgeTraffic is for aggregating edge traffic when reducing multiple edges into one edge (e.g. when generating service graph from workload graph, or aggregating serviceEntry nodes).
func AggregateID ¶ added in v1.21.0
AggregateID returns the unique node ID
func AggregateNodeTraffic ¶ added in v1.0.0
func AggregateNodeTraffic(node, aggregateNode *Node)
AggregateNodeTraffic adds all <nodeMetadata> values (for all protocols) into aggregateNodeMetadata.
func BadRequest ¶ added in v0.12.0
func BadRequest(message string)
BadRequest panics with BadRequest and the provided message
func CheckError ¶ added in v0.12.0
func CheckError(err error)
CheckError panics with the supplied error if it is non-nil
func Error ¶ added in v0.12.0
func Error(message string)
Error panics with InternalServerError and the provided message
func Forbidden ¶ added in v0.12.0
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)
Id returns the unique node ID
func IsOK ¶ added in v0.12.0
IsOK just validates that a telemetry label value is not empty or unknown
func ResetOutgoingMetadata ¶ added in v1.12.6
func ResetOutgoingMetadata(sourceMetadata Metadata)
ResetOutgoingMetadata sets outgoing traffic to zero. This is useful for some graph type manipulations.
Types ¶
type Appender ¶ added in v0.21.0
type Appender interface { // AppendGraph performs the appender work on the provided traffic map. The map // may be initially empty. An appender is allowed to add or remove map entries. AppendGraph(trafficMap TrafficMap, globalInfo *AppenderGlobalInfo, namespaceInfo *AppenderNamespaceInfo) // Name returns a unique appender name and which is the name used to identify the appender (e.g in 'appenders' query param) Name() string }
Appender is implemented by any code offering to append a service graph with supplemental information. On error the appender should panic and it will be handled as an error response.
type AppenderGlobalInfo ¶ added in v0.21.0
type AppenderGlobalInfo struct { Business *business.Layer PromClient *prometheus.Client Vendor AppenderVendorInfo // telemetry vendor's global info }
AppenderGlobalInfo caches information relevant to a single graph. It allows an appender to populate the cache and then it, or another appender can re-use the information. A new instance is generated for graph and is initially empty.
func NewAppenderGlobalInfo ¶ added in v0.21.0
func NewAppenderGlobalInfo() *AppenderGlobalInfo
type AppenderNamespaceInfo ¶ added in v0.21.0
type AppenderNamespaceInfo struct { Namespace string // always provided Vendor AppenderVendorInfo // telemetry vendor's namespace info }
AppenderNamespaceInfo caches information relevant to a single namespace. It allows one appender to populate the cache and another to then re-use the information. A new instance is generated for each namespace of a single graph and is initially seeded with only Namespace.
func NewAppenderNamespaceInfo ¶ added in v0.21.0
func NewAppenderNamespaceInfo(namespace string) *AppenderNamespaceInfo
type AppenderVendorInfo ¶ added in v0.21.0
type AppenderVendorInfo map[string]interface{}
func NewAppenderVendorInfo ¶ added in v0.21.0
func NewAppenderVendorInfo() AppenderVendorInfo
type CommonOptions ¶ added in v0.21.0
type CommonOptions struct { Duration time.Duration GraphType string Params url.Values // make available the raw query params for vendor-specific handling QueryTime int64 // unix time in seconds }
CommonOptions are those supplied to Telemetry and Config Vendors
type ConfigOptions ¶ added in v0.21.0
type ConfigOptions struct { GroupBy string CommonOptions }
ConfigOptions are those supplied to Config Vendors
type ConfigVendor ¶ added in v0.21.0
type ConfigVendor interface { // NewConfig is required by the ConfigVendor interface. It must produce a valid // Config for the provided TrafficMap, It is recommended to use the graph/util.go // definitions for error handling. Refer to the Cytoscape implementation as an example. NewConfig(trafficMap TrafficMap, o ConfigOptions) interface{} }
ConfigVendor is an interface that must be satisfied for each config vendor implementation.
type DestServicesMetadata ¶ added in v1.0.0
type DestServicesMetadata map[string]ServiceName
DestServicesMetadata key=Service.Key()
func NewDestServicesMetadata ¶ added in v1.0.0
func NewDestServicesMetadata() DestServicesMetadata
NewDestServicesMetadata returns an empty DestServicesMetadata map
func (DestServicesMetadata) Add ¶ added in v1.0.0
func (dsm DestServicesMetadata) Add(key string, service ServiceName) DestServicesMetadata
Add adds or replaces a destService
type Metadata ¶ added in v0.21.0
type Metadata map[MetadataKey]interface{}
Metadata is a map for storing node and edge metadata values reported by the vendors
func NewMetadata ¶ added in v0.21.0
func NewMetadata() Metadata
NewMetadata returns an empty Metadata map
type MetadataKey ¶ added in v0.21.0
type MetadataKey string
MetadataKey is a mnemonic type name for string
const ( Aggregate MetadataKey = "aggregate" // the prom attribute used for aggregation AggregateValue MetadataKey = "aggregateValue" DestPrincipal MetadataKey = "destPrincipal" DestServices MetadataKey = "destServices" HasCB MetadataKey = "hasCB" HasMissingSC MetadataKey = "hasMissingSC" HasVS MetadataKey = "hasVS" IsDead MetadataKey = "isDead" IsEgressCluster MetadataKey = "isEgressCluster" // PassthroughCluster or BlackHoleCluster IsInaccessible MetadataKey = "isInaccessible" IsMisconfigured MetadataKey = "isMisconfigured" IsMTLS MetadataKey = "isMTLS" IsOutside MetadataKey = "isOutside" IsRoot MetadataKey = "isRoot" IsServiceEntry MetadataKey = "isServiceEntry" IsUnused MetadataKey = "isUnused" ProtocolKey MetadataKey = "protocol" ResponseTime MetadataKey = "responseTime" SourcePrincipal MetadataKey = "sourcePrincipal" )
Metadata keys to be used instead of literal strings
type NamespaceInfo ¶ added in v0.9.1
type NamespaceInfoMap ¶ added in v1.4.0
type NamespaceInfoMap map[string]NamespaceInfo
func NewNamespaceInfoMap ¶ added in v1.4.0
func NewNamespaceInfoMap() NamespaceInfoMap
type Node ¶ added in v0.6.0
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 Metadata // app-specific data }
func NewAggregateNode ¶ added in v1.21.0
NewAggregateNode constructor, set svcName and app to "" when not service-specific aggregate
func NewAggregateNodeExplicit ¶ added in v1.21.0
NewAggregateNodeExplicit constructor assigns the specified ID, , set svcName and app to "" when not service-specific aggregate
func NewNode ¶ added in v0.6.0
func NewNode(serviceNamespace, service, workloadNamespace, workload, app, version, graphType string) Node
NewNode constructor
func NewNodeExplicit ¶ added in v0.6.0
func NewNodeExplicit(id, namespace, workload, app, version, service, nodeType, graphType string) Node
NewNodeExplicit constructor assigns the specified ID
type NodeOptions ¶ added in v0.21.0
type NodeOptions struct { Aggregate string AggregateValue string App string Namespace string Service string Version string Workload string }
NodeOptions are those that apply only to node-detail graphs
type Options ¶ added in v0.21.0
type Options struct { ConfigVendor string TelemetryVendor string ConfigOptions TelemetryOptions }
Options comprises all available options
func NewOptions ¶ added in v0.21.0
type Protocol ¶ added in v0.14.0
type Protocol struct { Name string EdgeRates []Rate EdgeResponses MetadataKey NodeRates []Rate Unit string UnitShort string }
Protocol describes a supported protocol and the rates it provides
type Rate ¶ added in v0.14.0
type Rate struct { Name MetadataKey IsErr bool IsIn bool IsOut bool IsPercentErr bool IsPercentReq bool IsTotal bool Precision int }
Rate describes one rate provided by a protocol
type RequestedAppenders ¶ added in v0.21.0
type ResponseDetail ¶ added in v1.6.0
type ResponseDetail struct { Flags ResponseFlags Hosts ResponseHosts }
ResponseDetail consolidates response detail for a response code
type ResponseFlags ¶ added in v0.17.0
ResponseFlags maps flags to request percentage
type ResponseHosts ¶ added in v1.6.0
ResponseHosts maps hosts to request percentage
type Responses ¶ added in v0.17.0
type Responses map[string]*ResponseDetail
Responses maps codes to ResponseDetail
type ServiceName ¶ added in v1.4.0
func (*ServiceName) Key ¶ added in v1.4.0
func (s *ServiceName) Key() string
type TelemetryOptions ¶ added in v0.21.0
type TelemetryOptions struct { AccessibleNamespaces map[string]time.Time Appenders RequestedAppenders // requested appenders, nil if param not supplied InjectServiceNodes bool // inject destination service nodes between source and destination nodes. Namespaces NamespaceInfoMap CommonOptions NodeOptions }
TelemetryOptions are those supplied to Telemetry Vendors
func (*TelemetryOptions) GetGraphKind ¶ added in v0.21.0
func (o *TelemetryOptions) GetGraphKind() string
GetGraphKind will return the kind of graph represented by the options.
type TelemetryVendor ¶ added in v0.21.0
type TelemetryVendor interface { // BuildNamespaceTrafficMap is required by the TelemetryVendor interface. It must produce a valid // TrafficMap for the requested namespaces, It is recommended to use the graph/util.go definitions for // error handling. It should be modeled after the Istio implementation. BuildNamespacesTrafficMap(o TelemetryOptions, client *prometheus.Client, globalInfo *AppenderGlobalInfo) TrafficMap // BuildNodeTrafficMap is required by the TelemetryVendor interface. It must produce a valid // TrafficMap for the requested node, It is recommended to use the graph/util.go definitions for // error handling. It should be modeled after the Istio implementation. BuildNodeTrafficMap(o TelemetryOptions, client *prometheus.Client, globalInfo *AppenderGlobalInfo) TrafficMap }
TelemetryVendor is an interface that must be satisfied for each telemetry implementation.
type TrafficMap ¶
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.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
config
|
|
cytoscape
Package cytoscape provides conversion from our graph to the CystoscapeJS configuration json model.
|
Package cytoscape provides conversion from our graph to the CystoscapeJS configuration json model. |
Package telemtry contains telemetry provider implementations as well as common code that can be shared by each telemetry vendor.
|
Package telemtry contains telemetry provider implementations as well as common code that can be shared by each telemetry vendor. |
istio
Package istio provides the Istio implementation of graph/TelemetryProvider.
|
Package istio provides the Istio implementation of graph/TelemetryProvider. |