config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2021 License: Apache-2.0 Imports: 15 Imported by: 8

README

Agent Config Go

Agent config holds all the configuration settings for the Hypertrace Go Agent.

Getting Started

// loads the config from the config file tbd.json and env vars
cfg := config.Load()

// overrides statically the service name
cfg.ServiceName = config.String("myservice")
cfg.DataCapture.HTTPHeaders.Request = config.Bool(true)

Values can also be overriden by the environment variables, e.g. HT_DATA_CAPTURE_HTTP_HEADERS_RESPONSE=false. You can check a list of the supported environment variables here

The location for the config file can also be overriden by passing the path in HT_CONFIG_FILE environment variable or you can set the location in code by using

// loads the config from the specified file and env vars
cfg := config.LoadFromFile("path/to/file.yml")
...

Supported formats for config files are YAML and JSON.

Default Values

All default values are defined in the defaults.go, everything else will be default to zero values.

Loading for existing config

Sometimes the user can choose to populate the config object and then load the config values from environment variables. In such case one can run:

cfg := &config.AgentConfig{}
cfg.ServiceName = config.String("myservice")
cfg.DataCapture.HTTPHeaders.Request = config.Bool(true)

cfg.LoadFromEnv()

Generating config structs

When changing the proto definition, the config structs must be regenerated to use the new configuration fields. This can be done by:

cd ../
make generate-config

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PropagationFormat_name = map[int32]string{
		0: "B3",
		1: "TRACECONTEXT",
	}
	PropagationFormat_value = map[string]int32{
		"B3":           0,
		"TRACECONTEXT": 1,
	}
)

Enum value maps for PropagationFormat.

View Source
var (
	TraceReporterType_name = map[int32]string{
		0: "UNSPECIFIED",
		1: "ZIPKIN",
		2: "OTLP",
	}
	TraceReporterType_value = map[string]int32{
		"UNSPECIFIED": 0,
		"ZIPKIN":      1,
		"OTLP":        2,
	}
)

Enum value maps for TraceReporterType.

View Source
var File_config_proto protoreflect.FileDescriptor

Functions

func Bool

func Bool(val bool) *wrapperspb.BoolValue

Bool wraps the scalar value to be used in the AgentConfig object

func Int32 added in v0.3.0

func Int32(val int32) *wrapperspb.Int32Value

func String

func String(val string) *wrapperspb.StringValue

String wraps the scalar value to be used in the AgentConfig object

Types

type AgentConfig

type AgentConfig struct {

	// service_name identifies the service/process running e.g. "my service"
	ServiceName *wrapperspb.StringValue `protobuf:"bytes,1,opt,name=service_name,json=serviceName,proto3" json:"service_name,omitempty"`
	// reporting holds the reporting settings for the agent
	Reporting *Reporting `protobuf:"bytes,2,opt,name=reporting,proto3" json:"reporting,omitempty"`
	// data_capture describes the data being captured by instrumentation
	DataCapture *DataCapture `protobuf:"bytes,3,opt,name=data_capture,json=dataCapture,proto3" json:"data_capture,omitempty"`
	// propagation_formats list the supported propagation formats
	PropagationFormats []PropagationFormat `` /* 174-byte string literal not displayed */
	// when `false`, disables the agent
	Enabled *wrapperspb.BoolValue `protobuf:"bytes,5,opt,name=enabled,proto3" json:"enabled,omitempty"`
	// javaagent has the configs specific to javaagent
	Javaagent *JavaAgent `protobuf:"bytes,6,opt,name=javaagent,proto3" json:"javaagent,omitempty"`
	// resource_attributes map define the static list of resources which is configured on the tracer
	ResourceAttributes map[string]string `` /* 203-byte string literal not displayed */
	// contains filtered or unexported fields
}

AgentConfig covers the config for agents. The config uses wrappers for primitive types to allow nullable values. The nullable values are used for instance to explicitly disable data capture or secure connection. Since the wrappers change structure of the objects the marshalling and unmarshalling have to be done via protobuf marshallers.

func Load

func Load() *AgentConfig

Load loads the configuration from the default values, config file and env vars.

func LoadFromFile

func LoadFromFile(configFile string) *AgentConfig

LoadFromFile loads the configuration from the default values, config file and env vars.

func (*AgentConfig) Descriptor deprecated

func (*AgentConfig) Descriptor() ([]byte, []int)

Deprecated: Use AgentConfig.ProtoReflect.Descriptor instead.

func (*AgentConfig) GetDataCapture

func (x *AgentConfig) GetDataCapture() *DataCapture

func (*AgentConfig) GetEnabled

func (x *AgentConfig) GetEnabled() *wrapperspb.BoolValue

func (*AgentConfig) GetJavaagent

func (x *AgentConfig) GetJavaagent() *JavaAgent

func (*AgentConfig) GetPropagationFormats

func (x *AgentConfig) GetPropagationFormats() []PropagationFormat

func (*AgentConfig) GetReporting

func (x *AgentConfig) GetReporting() *Reporting

func (*AgentConfig) GetResourceAttributes

func (x *AgentConfig) GetResourceAttributes() map[string]string

func (*AgentConfig) GetServiceName

func (x *AgentConfig) GetServiceName() *wrapperspb.StringValue

func (*AgentConfig) LoadFromEnv

func (x *AgentConfig) LoadFromEnv()

LoadFromEnv loads env and default values on existing AgentConfig instance where defaults only overrides empty values while env vars can override all of them.

func (*AgentConfig) ProtoMessage

func (*AgentConfig) ProtoMessage()

func (*AgentConfig) ProtoReflect

func (x *AgentConfig) ProtoReflect() protoreflect.Message

func (*AgentConfig) PutResourceAttributes

func (x *AgentConfig) PutResourceAttributes(m map[string]string)

PutResourceAttributes sets values in the ResourceAttributes map.

func (*AgentConfig) Reset

func (x *AgentConfig) Reset()

func (*AgentConfig) String

func (x *AgentConfig) String() string

type DataCapture

type DataCapture struct {

	// http_headers enables/disables the capture of the request/response headers in HTTP
	HttpHeaders *Message `protobuf:"bytes,1,opt,name=http_headers,json=httpHeaders,proto3" json:"http_headers,omitempty"`
	// http_body enables/disables the capture of the request/response body in HTTP
	HttpBody *Message `protobuf:"bytes,2,opt,name=http_body,json=httpBody,proto3" json:"http_body,omitempty"`
	// rpc_metadata enables/disables the capture of the request/response metadata in RPC
	RpcMetadata *Message `protobuf:"bytes,3,opt,name=rpc_metadata,json=rpcMetadata,proto3" json:"rpc_metadata,omitempty"`
	// rpc_body enables/disables the capture of the request/response body in RPC
	RpcBody *Message `protobuf:"bytes,4,opt,name=rpc_body,json=rpcBody,proto3" json:"rpc_body,omitempty"`
	// maximum size of captured body in bytes. Default should be 131_072 (128 KiB).
	BodyMaxSizeBytes *wrapperspb.Int32Value `protobuf:"bytes,5,opt,name=body_max_size_bytes,json=bodyMaxSizeBytes,proto3" json:"body_max_size_bytes,omitempty"`
	// contains filtered or unexported fields
}

DataCapture describes the elements to be captured by the agent instrumentation

func (*DataCapture) Descriptor deprecated

func (*DataCapture) Descriptor() ([]byte, []int)

Deprecated: Use DataCapture.ProtoReflect.Descriptor instead.

func (*DataCapture) GetBodyMaxSizeBytes

func (x *DataCapture) GetBodyMaxSizeBytes() *wrapperspb.Int32Value

func (*DataCapture) GetHttpBody

func (x *DataCapture) GetHttpBody() *Message

func (*DataCapture) GetHttpHeaders

func (x *DataCapture) GetHttpHeaders() *Message

func (*DataCapture) GetRpcBody

func (x *DataCapture) GetRpcBody() *Message

func (*DataCapture) GetRpcMetadata

func (x *DataCapture) GetRpcMetadata() *Message

func (*DataCapture) ProtoMessage

func (*DataCapture) ProtoMessage()

func (*DataCapture) ProtoReflect

func (x *DataCapture) ProtoReflect() protoreflect.Message

func (*DataCapture) Reset

func (x *DataCapture) Reset()

func (*DataCapture) String

func (x *DataCapture) String() string

type JavaAgent

type JavaAgent struct {

	// filter_jar_paths is the list of path to filter jars, separated by `,`
	FilterJarPaths []*wrapperspb.StringValue `protobuf:"bytes,1,rep,name=filter_jar_paths,json=filterJarPaths,proto3" json:"filter_jar_paths,omitempty"`
	// contains filtered or unexported fields
}

JavaAgent has the configs specific to javaagent

func (*JavaAgent) Descriptor deprecated

func (*JavaAgent) Descriptor() ([]byte, []int)

Deprecated: Use JavaAgent.ProtoReflect.Descriptor instead.

func (*JavaAgent) GetFilterJarPaths

func (x *JavaAgent) GetFilterJarPaths() []*wrapperspb.StringValue

func (*JavaAgent) ProtoMessage

func (*JavaAgent) ProtoMessage()

func (*JavaAgent) ProtoReflect

func (x *JavaAgent) ProtoReflect() protoreflect.Message

func (*JavaAgent) Reset

func (x *JavaAgent) Reset()

func (*JavaAgent) String

func (x *JavaAgent) String() string

type Message

type Message struct {

	// when `false` it disables the capture for the request in a client/request operation
	Request *wrapperspb.BoolValue `protobuf:"bytes,1,opt,name=request,proto3" json:"request,omitempty"`
	// when `false` it disables the capture for the response in a client/request operation
	Response *wrapperspb.BoolValue `protobuf:"bytes,2,opt,name=response,proto3" json:"response,omitempty"`
	// contains filtered or unexported fields
}

Message describes what message should be considered for certain DataCapture option

func (*Message) Descriptor deprecated

func (*Message) Descriptor() ([]byte, []int)

Deprecated: Use Message.ProtoReflect.Descriptor instead.

func (*Message) GetRequest

func (x *Message) GetRequest() *wrapperspb.BoolValue

func (*Message) GetResponse

func (x *Message) GetResponse() *wrapperspb.BoolValue

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) ProtoReflect

func (x *Message) ProtoReflect() protoreflect.Message

func (*Message) Reset

func (x *Message) Reset()

func (*Message) String

func (x *Message) String() string

type Opa

type Opa struct {

	// endpoint represents the endpoint for polling OPA config file e.g. http://opa.traceableai:8181/
	Endpoint *wrapperspb.StringValue `protobuf:"bytes,1,opt,name=endpoint,proto3" json:"endpoint,omitempty"`
	// poll period in seconds to query OPA service
	PollPeriodSeconds *wrapperspb.Int32Value `protobuf:"bytes,2,opt,name=poll_period_seconds,json=pollPeriodSeconds,proto3" json:"poll_period_seconds,omitempty"`
	// when `true` Open Policy Agent evaluation is enabled to block request
	Enabled *wrapperspb.BoolValue `protobuf:"bytes,3,opt,name=enabled,proto3" json:"enabled,omitempty"`
	// contains filtered or unexported fields
}

Opa covers the options related to the mechanics for getting Open Policy Agent configuration file. The client should use secure and token option from reporting settings.

func (*Opa) Descriptor deprecated

func (*Opa) Descriptor() ([]byte, []int)

Deprecated: Use Opa.ProtoReflect.Descriptor instead.

func (*Opa) GetEnabled

func (x *Opa) GetEnabled() *wrapperspb.BoolValue

func (*Opa) GetEndpoint

func (x *Opa) GetEndpoint() *wrapperspb.StringValue

func (*Opa) GetPollPeriodSeconds

func (x *Opa) GetPollPeriodSeconds() *wrapperspb.Int32Value

func (*Opa) ProtoMessage

func (*Opa) ProtoMessage()

func (*Opa) ProtoReflect

func (x *Opa) ProtoReflect() protoreflect.Message

func (*Opa) Reset

func (x *Opa) Reset()

func (*Opa) String

func (x *Opa) String() string

type PropagationFormat

type PropagationFormat int32

PropagationFormat represents the propagation formats supported by agents

const (
	// B3 propagation format, agents should support both multi and single value formats
	// see https://github.com/openzipkin/b3-propagation
	PropagationFormat_B3 PropagationFormat = 0
	// W3C Propagation format
	// see https://www.w3.org/TR/trace-context/
	PropagationFormat_TRACECONTEXT PropagationFormat = 1
)

func (PropagationFormat) Descriptor

func (PropagationFormat) Enum

func (PropagationFormat) EnumDescriptor deprecated

func (PropagationFormat) EnumDescriptor() ([]byte, []int)

Deprecated: Use PropagationFormat.Descriptor instead.

func (PropagationFormat) Number

func (PropagationFormat) String

func (x PropagationFormat) String() string

func (PropagationFormat) Type

type Reporting

type Reporting struct {

	// endpoint represents the endpoint for reporting the traces
	// For ZIPKIN reporter type use http://api.traceable.ai:9411/api/v2/spans
	// For OTLP reporter type use http://api.traceable.ai:4317
	Endpoint *wrapperspb.StringValue `protobuf:"bytes,1,opt,name=endpoint,proto3" json:"endpoint,omitempty"`
	// when `true`, connects to endpoints over TLS.
	Secure *wrapperspb.BoolValue `protobuf:"bytes,2,opt,name=secure,proto3" json:"secure,omitempty"`
	// user specific token to access Traceable API
	Token *wrapperspb.StringValue `protobuf:"bytes,3,opt,name=token,proto3" json:"token,omitempty"`
	// opa describes the setting related to the Open Policy Agent
	Opa *Opa `protobuf:"bytes,4,opt,name=opa,proto3" json:"opa,omitempty"`
	// reporter type for traces.
	TraceReporterType TraceReporterType `` /* 166-byte string literal not displayed */
	// contains filtered or unexported fields
}

Reporting covers the options related to the mechanics for sending data to the tracing server o collector.

func (*Reporting) Descriptor deprecated

func (*Reporting) Descriptor() ([]byte, []int)

Deprecated: Use Reporting.ProtoReflect.Descriptor instead.

func (*Reporting) GetEndpoint

func (x *Reporting) GetEndpoint() *wrapperspb.StringValue

func (*Reporting) GetOpa

func (x *Reporting) GetOpa() *Opa

func (*Reporting) GetSecure

func (x *Reporting) GetSecure() *wrapperspb.BoolValue

func (*Reporting) GetToken

func (x *Reporting) GetToken() *wrapperspb.StringValue

func (*Reporting) GetTraceReporterType

func (x *Reporting) GetTraceReporterType() TraceReporterType

func (*Reporting) ProtoMessage

func (*Reporting) ProtoMessage()

func (*Reporting) ProtoReflect

func (x *Reporting) ProtoReflect() protoreflect.Message

func (*Reporting) Reset

func (x *Reporting) Reset()

func (*Reporting) String

func (x *Reporting) String() string

type TraceReporterType

type TraceReporterType int32

TraceReporterType represents the reporting format for trace data.

const (
	// Default to none. Agent will use it's default reporting type
	TraceReporterType_UNSPECIFIED TraceReporterType = 0
	// Zipkin protobuf reporting format.
	// see https://github.com/openzipkin/zipkin-api
	TraceReporterType_ZIPKIN TraceReporterType = 1
	// OpenTelemetry protobuf reporting format.
	// see https://github.com/open-telemetry/opentelemetry-proto
	TraceReporterType_OTLP TraceReporterType = 2
)

func (TraceReporterType) Descriptor

func (TraceReporterType) Enum

func (TraceReporterType) EnumDescriptor deprecated

func (TraceReporterType) EnumDescriptor() ([]byte, []int)

Deprecated: Use TraceReporterType.Descriptor instead.

func (TraceReporterType) Number

func (TraceReporterType) String

func (x TraceReporterType) String() string

func (TraceReporterType) Type

Jump to

Keyboard shortcuts

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