googleservicecontrolexporter

package module
v0.0.0-...-e6b28b3 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2025 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Overview

Package client implements client interface for service control API

Index

Constants

View Source
const (
	LogNameAttributeKey = "log_name"
	// TODO: we should evaluate if this is needed; if not, can remove this and
	// let the API generate a UUID - same behavior as the Cloud Logging exporter
	InsertIdAttributeKey = "logging.googleapis.com/insertId"
	// FluentBit exporter uses logging.googleapis.com/* prefix and Cloud Logging
	// exporter uses `gcp.*` prefix
	SourceLocationAttributeKey = "logging.googleapis.com/sourceLocation"
	HTTPRequestAttributeKey    = "httpRequest"
	LogDefaultOperationName    = "log_entry"
)

Variables

This section is empty.

Functions

func BufDialer

func BufDialer(context.Context, string) (net.Conn, error)

func NewFactory

func NewFactory() exporter.Factory

func StartMockServer

func StartMockServer() (*grpc.Server, *mockServiceControllerServer, *bufconn.Listener, error)

func StopMockServer

func StopMockServer(server *grpc.Server, listener *bufconn.Listener)

Types

type Config

type Config struct {
	ServiceName               string `mapstructure:"service_name"`
	ConsumerProject           string `mapstructure:"consumer_project"`
	ServiceControlEndpoint    string `mapstructure:"service_control_endpoint"`
	ServiceConfigID           string `mapstructure:"service_config_id"`
	ImpersonateServiceAccount string `mapstructure:"impersonate_service_account"`
	// Whether to use servicecontrol library or raw sc client.
	// The Client Library's SC client supports authentications using ADC and WIF
	// https://cloud.google.com/kubernetes-engine/fleet-management/docs/use-workload-identity#authenticate_from_your_code
	// Defaults to `true`, so that existing customers are unaffected by changes.
	// See go/agent-gdce
	// TODO(b/400987158): remove the option and migrate all to Client Library.
	UseRawServiceControlClient string `mapstructure:"use_raw_sc_client"`
	EnableDebugHeaders         bool   `mapstructure:"enable_debug_headers"`
	// UseInsecure config the grpc client to use insecure credentials. Originally
	// the `disable_auth` config option in FluentBit.
	UseInsecure bool      `mapstructure:"use_insecure"`
	LogConfig   LogConfig `mapstructure:"log"`

	exporterhelper.TimeoutConfig `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
	configretry.BackOffConfig    `mapstructure:"retry_on_failure"`
	exporterhelper.QueueConfig   `mapstructure:"sending_queue"`
}

Config defines configuration for Service Control Exporter

func (*Config) Validate

func (c *Config) Validate() error

type Exporter

type Exporter struct {
	// contains filtered or unexported fields
}

Exporter is a type that implements MetricsExporter interface for ServiceControl API

func (*Exporter) Capabilities

func (e *Exporter) Capabilities() consumer.Capabilities

Capabilities returns the Capabilities associated with the metrics exporter.

func (*Exporter) Shutdown

func (e *Exporter) Shutdown(_ context.Context) error

Shutdown cancels ongoing requests

func (*Exporter) Start

func (e *Exporter) Start(_ context.Context, host component.Host) error

Start starts Exporter

type HeaderLoggingInterceptor

type HeaderLoggingInterceptor struct {
	// contains filtered or unexported fields
}

func NewHeaderLoggingInterceptor

func NewHeaderLoggingInterceptor(logger *zap.Logger) *HeaderLoggingInterceptor

func (*HeaderLoggingInterceptor) UnaryInterceptor

func (h *HeaderLoggingInterceptor) UnaryInterceptor(
	ctx context.Context,
	method string,
	req interface{},
	reply interface{},
	cc *grpc.ClientConn,
	invoker grpc.UnaryInvoker,
	opts ...grpc.CallOption,
) error

UnaryInterceptor implements grpc.UnaryClientInterceptor interface

type LogConfig

type LogConfig struct {
	// DefaultLogName sets the fallback log name to use when one isn't explicitly set
	// for a log entry. If unset, logs without a log name will raise an error.
	// Corresponding to the plugin `alias` setting in FluentBit exporter
	DefaultLogName string `mapstructure:"default_log_name"`
	// OperationName sets the operation name for Service Control logs. If not
	// set, default to `log_entry`
	OperationName string `mapstructure:"operation_name"`
}

type LogsExporter

type LogsExporter struct {
	*Exporter
	// contains filtered or unexported fields
}

func NewLogsExporter

func NewLogsExporter(config Config, logger *zap.Logger, c ServiceControlClient, tel component.TelemetrySettings) *LogsExporter

NewLogsExporter returns service control logs exporter

func (*LogsExporter) ConsumeLogs

func (e *LogsExporter) ConsumeLogs(ctx context.Context, ld plog.Logs) error

type MetricsExporter

type MetricsExporter struct {
	*Exporter
	// contains filtered or unexported fields
}

TODO(lujieduan): move MetricsExporter specific code to a separate file.

func NewMetricsExporter

func NewMetricsExporter(config Config, logger *zap.Logger, c ServiceControlClient, tel component.TelemetrySettings) *MetricsExporter

NewMetricsExporter returns service control metrics exporter

func (*MetricsExporter) ConsumeMetrics

func (e *MetricsExporter) ConsumeMetrics(ctx context.Context, m pmetric.Metrics) error

ConsumeMetrics creates report requests from provided metrics and sends them to Service Control API. This func is called by several goroutines concurrently.

type ServiceControlClient

type ServiceControlClient interface {
	Report(ctx context.Context, request *scpb.ReportRequest) (*scpb.ReportResponse, error)
	Close() error
}

ServiceControlClient defines a interface of client for service control API

func NewServiceControllerClient

func NewServiceControllerClient(endpoint string, useRawServiceControlClient bool, enableDebugHeaders bool, logger *zap.Logger, opts ...grpc.DialOption) (ServiceControlClient, error)

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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