config

package
v2.51.3 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: Apache-2.0 Imports: 9 Imported by: 3

Documentation

Overview

Package config provides cross-cutting configuration support for the newrelic-client-go project.

Package config provides a configuration surface area for configuring the underlying client.

Authentication

You will need a valid Personal API key to communicate with the backend New Relic APIs that power the client. See the API key documentation below for more information on how to locate this key:

https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys

Index

Constants

This section is empty.

Variables

View Source
var Compression = struct {
	None CompressionType
	Gzip CompressionType
}{
	None: "",
	Gzip: "gzip",
}

Compression is an Enum of compression types available

Functions

This section is empty.

Types

type CompressionType

type CompressionType string

CompressionType to use during transport.

func ParseCompression

func ParseCompression(name string) CompressionType

ParseCompression takes a named compression and returns the Type

func (CompressionType) String

func (c CompressionType) String() string

String returns the name of the compression type

type Config

type Config struct {
	// LicenseKey to authenticate Log API requests
	// see: https://docs.newrelic.com/docs/accounts/accounts-billing/account-setup/new-relic-license-key
	LicenseKey string

	// PersonalAPIKey to authenticate API requests
	// see: https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#personal-api-key
	PersonalAPIKey string

	// AdminAPIKey to authenticate API requests
	// Deprecated.  Use a Personal API key for authentication.
	// see: https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#admin
	AdminAPIKey string

	// InsightsInsertKey to send custom events to Insights
	InsightsInsertKey string

	// Timeout is the client timeout for HTTP requests.
	Timeout *time.Duration

	// HTTPTransport allows customization of the client's underlying transport.
	HTTPTransport http.RoundTripper

	// Compression used in sending data in HTTP requests.
	Compression CompressionType

	// UserAgent updates the default user agent string used by the client.
	UserAgent string

	// ServiceName is for New Relic internal use only.
	ServiceName string

	// LogLevel can be one of the following values:
	// "panic", "fatal", "error", "warn", "info", "debug", "trace"
	LogLevel string

	// LogJSON toggles formatting of log entries in JSON format.
	LogJSON bool

	// Logger allows customization of the client's underlying logger.
	Logger logging.Logger
	// contains filtered or unexported fields
}

Config contains all the configuration data for the API Client.

func New

func New() Config

New creates a default configuration and returns it

func (*Config) GetLogger

func (c *Config) GetLogger() logging.Logger

GetLogger returns a logger instance based on the config values.

func (*Config) Init added in v2.22.2

func (cfg *Config) Init(opts []ConfigOption) error

func (*Config) Region

func (c *Config) Region() *region.Region

Region returns the region configuration struct if one has not been set, use the default region

func (*Config) SetRegion

func (c *Config) SetRegion(reg *region.Region) error

SetRegion configures the region

func (*Config) SetServiceName added in v2.12.0

func (c *Config) SetServiceName(serviceName string) error

type ConfigOption added in v2.22.2

type ConfigOption func(*Config) error

ConfigOption configures the Config when provided to NewApplication. https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys

func ConfigAdminAPIKey added in v2.22.2

func ConfigAdminAPIKey(adminAPIKey string) ConfigOption

ConfigAdminAPIKey sets the New Relic Admin API key this client will use. Deprecated. Use a personal API key for authentication. https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys

func ConfigBaseURL added in v2.22.2

func ConfigBaseURL(url string) ConfigOption

ConfigBaseURL sets the base URL used to make requests to the REST API V2.

func ConfigHTTPTimeout added in v2.22.2

func ConfigHTTPTimeout(t time.Duration) ConfigOption

ConfigHTTPTimeout sets the timeout for HTTP requests.

func ConfigHTTPTransport added in v2.22.2

func ConfigHTTPTransport(transport http.RoundTripper) ConfigOption

ConfigHTTPTransport sets the HTTP Transporter.

func ConfigInfrastructureBaseURL added in v2.22.2

func ConfigInfrastructureBaseURL(url string) ConfigOption

ConfigInfrastructureBaseURL sets the base URL used to make requests to the Infrastructure API.

func ConfigInsightsInsertKey added in v2.22.2

func ConfigInsightsInsertKey(insightsInsertKey string) ConfigOption

ConfigInsightsInsertKey sets the New Relic Insights insert key this client will use. https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys

func ConfigLogJSON added in v2.22.2

func ConfigLogJSON(logJSON bool) ConfigOption

ConfigLogJSON toggles JSON formatting on for the logger if set to true.

func ConfigLogLevel added in v2.22.2

func ConfigLogLevel(logLevel string) ConfigOption

ConfigLogLevel sets the log level for the client.

func ConfigLogger added in v2.22.2

func ConfigLogger(logger logging.Logger) ConfigOption

ConfigLogger can be used to customize the client's logger. Custom loggers must conform to the logging.Logger interface.

func ConfigNerdGraphBaseURL added in v2.22.2

func ConfigNerdGraphBaseURL(url string) ConfigOption

ConfigNerdGraphBaseURL sets the base URL used to make requests to the NerdGraph API.

func ConfigPersonalAPIKey added in v2.22.2

func ConfigPersonalAPIKey(apiKey string) ConfigOption

ConfigPersonalAPIKey sets the New Relic Admin API key this client will use. This key should be used to create a client instance. https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys

func ConfigRegion added in v2.22.2

func ConfigRegion(r string) ConfigOption

ConfigRegion sets the New Relic Region this client will use.

func ConfigServiceName added in v2.22.2

func ConfigServiceName(name string) ConfigOption

ConfigServiceName sets the service name logged

func ConfigSyntheticsBaseURL added in v2.22.2

func ConfigSyntheticsBaseURL(url string) ConfigOption

ConfigSyntheticsBaseURL sets the base URL used to make requests to the Synthetics API.

func ConfigUserAgent added in v2.22.2

func ConfigUserAgent(ua string) ConfigOption

ConfigUserAgent sets the HTTP UserAgent for API requests.

Jump to

Keyboard shortcuts

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