Documentation ¶
Overview ¶
Package common contains all of logic that is shared between trace and logs packages. The main concern of this package is to format Hubble flow data using OpenTelemetry structures. A few different formats are implemented to make it easier to optimise the data for different OpenTelemetry backends, e.g. some backends accept arbitrarily nested data, while others only handle flat maps. This package also implements conversion of label and HTTP headers to maps, which makes it easier to query data by label or by header in most of the backends.
Index ¶
- Constants
- func EncodingFormatsForLogs() []string
- func EncodingFormatsForTraces() []string
- func GetAllResourceAttributes(flow *flowV1.Flow, fallbackServiceNamePrefix string) (resourceAttributes []*commonV1.KeyValue)
- func GetHTTPAttributes(l7 *flowV1.Layer7) []*commonV1.KeyValue
- func GetKubernetesAttributes(flow *flowV1.Flow) []*commonV1.KeyValue
- func GetServiceAttributes(flow *flowV1.Flow, fallbackServiceNamePrefix string) []*commonV1.KeyValue
- func MarshalJSON(m proto.Message) ([]byte, error)
- func NewStringAttributes(attributes map[string]string) []*commonV1.KeyValue
- func NormaliseHeaderKey(k string) string
- func RunConverter(ctx context.Context, hubbleConn *grpc.ClientConn, c Converter, ...)
- func RunExporter(ctx context.Context, log *logrus.Logger, s Exporter, ...)
- type Converter
- type EncodingOptions
- func (o *EncodingOptions) EncodingFormat() string
- func (o *EncodingOptions) String() string
- func (o *EncodingOptions) ValidForLogs() error
- func (o *EncodingOptions) ValidForTraces() error
- func (o *EncodingOptions) WithHeadersAsMaps() bool
- func (o *EncodingOptions) WithLabelsAsMaps() bool
- func (o *EncodingOptions) WithLogPayloadAsBody() bool
- func (o *EncodingOptions) WithTopLevelKeys() bool
- type Exporter
- type FlowEncoder
- type IncludeFlowTypes
- type NullExporter
Constants ¶
View Source
const ( OTelAttrHTTPMethod = "http.method" OTelAttrHTTPURL = "http.url" OTelAttrHTTPFlavor = "http.flavor" OTelAttrHTTPHost = "http.host" OTelAttrHTTPUserAgent = "http.user_agent" OTelAttrHTTPStatusCode = "http.status_code" OTelAttrHTTPRequestHeader = "http.request.header." OTelAttrHTTPResponseHeader = "http.response.header." )
View Source
const ( OTelAttrK8sNodeName = "k8s.node.name" OTelAttrK8sNamespaceName = "k8s.namespace.name" OTelAttrK8sPodName = "k8s.pod.name" )
View Source
const ( OTelAttrServiceName = "service.name" OTelAttrServiceNamespace = "service.namespace" OTelAttrServiceNameDefaultPrefix = "hubble-otel-unknown" )
View Source
const ( AttributeEventKindVersion = keyNamespaceCilium + "event_kind" AttributeEventEncoding = keyNamespaceCilium + "event_encoding" AttributeEventEncodingOptions = keyNamespaceCilium + "event_encoding_options" AttributeEventKindVersionFlowV1alpha1 = "flow/v1alpha2" // in order to comply with the spec, cilium.flow_event is used with flat maps, // and cilium.event_object is used to hold JSON-encoded or nested payloads, // so that namespace and standalone key collision is avoided AttributeFlowEventNamespace = keyNamespaceCilium + "flow_event" AttributeEventObject = keyNamespaceCilium + "event_object" AttributeEventDescription = keyNamespaceCilium + "event_description" DefaultLogEncoding = EncodingTypedMap DefaultTraceEncoding = EncodingFlatStringMap EncodingJSON = "JSON" EncodingJSONBASE64 = "JSON+base64" EncodingFlatStringMap = "FlatStringMap" EncodingSemiFlatTypedMap = "SemiFlatTypedMap" EncodingTypedMap = "TypedMap" )
Variables ¶
This section is empty.
Functions ¶
func EncodingFormatsForLogs ¶
func EncodingFormatsForLogs() []string
func EncodingFormatsForTraces ¶
func EncodingFormatsForTraces() []string
func GetServiceAttributes ¶
func NewStringAttributes ¶
func NormaliseHeaderKey ¶
func RunConverter ¶
func RunConverter(ctx context.Context, hubbleConn *grpc.ClientConn, c Converter, flows chan<- protoreflect.Message, errs chan<- error, opts ...grpc.CallOption)
func RunExporter ¶
Types ¶
type Converter ¶
type Converter interface { Convert(*observer.GetFlowsResponse) (protoreflect.Message, error) InclusionFilter() []*flowV1.FlowFilter }
type EncodingOptions ¶
type EncodingOptions struct { Encoding *string `mapstructure:"encoding"` TopLevelKeys *bool `mapstructure:"top_level_keys"` LabelsAsMaps *bool `mapstructure:"labels_as_maps"` HeadersAsMaps *bool `mapstructure:"headers_as_maps"` LogPayloadAsBody *bool `mapstructure:"log_payload_as_body"` }
func (*EncodingOptions) EncodingFormat ¶
func (o *EncodingOptions) EncodingFormat() string
func (*EncodingOptions) String ¶
func (o *EncodingOptions) String() string
func (*EncodingOptions) ValidForLogs ¶
func (o *EncodingOptions) ValidForLogs() error
func (*EncodingOptions) ValidForTraces ¶
func (o *EncodingOptions) ValidForTraces() error
func (*EncodingOptions) WithHeadersAsMaps ¶
func (o *EncodingOptions) WithHeadersAsMaps() bool
func (*EncodingOptions) WithLabelsAsMaps ¶
func (o *EncodingOptions) WithLabelsAsMaps() bool
func (*EncodingOptions) WithLogPayloadAsBody ¶
func (o *EncodingOptions) WithLogPayloadAsBody() bool
func (*EncodingOptions) WithTopLevelKeys ¶
func (o *EncodingOptions) WithTopLevelKeys() bool
type Exporter ¶
type Exporter interface {
Export(context.Context, <-chan protoreflect.Message) error
}
type FlowEncoder ¶
type FlowEncoder struct { *EncodingOptions *IncludeFlowTypes Logger *logrus.Logger }
func (*FlowEncoder) InclusionFilter ¶
func (fe *FlowEncoder) InclusionFilter() []*flowV1.FlowFilter
func (*FlowEncoder) ToValue ¶
func (c *FlowEncoder) ToValue(hubbleResp *observer.GetFlowsResponse) (*commonV1.AnyValue, error)
type IncludeFlowTypes ¶
type IncludeFlowTypes []string
func (IncludeFlowTypes) MakeFilters ¶
func (it IncludeFlowTypes) MakeFilters() []*flowV1.FlowFilter
func (IncludeFlowTypes) Validate ¶
func (it IncludeFlowTypes) Validate() error
type NullExporter ¶
type NullExporter struct{}
func (*NullExporter) Export ¶
func (s *NullExporter) Export(ctx context.Context, flows <-chan protoreflect.Message) error
Click to show internal directories.
Click to hide internal directories.