Documentation
¶
Overview ¶
Package config provides the configuration for the logger and the monitoring. The package also provides the Otel convention for root labels.
Index ¶
Constants ¶
const ( SERVICE_NAME = string(semconv.ServiceNameKey) SERVICE_VERSION = string(semconv.ServiceVersionKey) SERVICE_INTANCE_ID = string(semconv.ServiceInstanceIDKey) )
attribute names for the common tags that will be applied to every trace, span and log
const ( FILE_PATH = string(semconv.CodeFilepathKey) LINE_NUMBER = string(semconv.CodeLineNumberKey) FUNCTION_NAME = string(semconv.CodeFunctionKey) FUNCTION_PACKAGE_NAME = string(semconv.CodeNamespaceKey) )
attribute names for the caller tags that will be applied to every trace, span and log
const ( LOG_MESSAGE_KEY = "message" LOG_ERROR_KEY = "error" LOG_METADATA_KEY = "metadata" )
attribute names for the logger
const (
EXPORTER_PROTOCOL = "otel.exporter.protocol"
)
exporter attributes
Variables ¶
This section is empty.
Functions ¶
func ResetMonitoringConfig ¶ added in v1.2.0
func ResetMonitoringConfig()
ResetMonitoringConfig resets the singleton state. This function is primarily intended for testing purposes.
Types ¶
type Logger ¶
type Logger struct {
LogLevelCfg string `env:"LOG_LEVEL" envDefault:"info"`
Monitoring
}
func NewLoggerConfig ¶
LoggerConfig returns the Logger configuration from the environment.
type LoggerConfig ¶
type Monitoring ¶
type Monitoring struct {
// Generic configuration
ServiceCfg string `env:"OTEL_SERVICE_NAME"`
TestExporterCfg bool `env:"OTEL_EXPORTER_OTLP_TEST"` // Specifies whether the OTLP exporter should be used in test mode.
// Exporter configuration
ExporterProtocolCfg string `env:"OTEL_EXPORTER_OTLP_PROTOCOL"` // Specifies the OTLP transport protocol to be used for all telemetry data.
// Traces configuration
ExporterTraceProtocolCfg string `env:"OTEL_EXPORTER_OTLP_TRACES_PROTOCOL"` // Specifies the OTLP transport protocol to be used for trace data.
// Metrics configuration
ExporterMetricsProtocolCfg string `env:"OTEL_EXPORTER_OTLP_METRICS_PROTOCOL"` // Specifies the OTLP transport protocol to be used for metric data.
MetricsIntervalCfg float64 `env:"OTEL_METRICS_INTERVAL_SECONDS"` // Specifies the interval at which metrics are exported.
}
func NewMonitoringConfig ¶
func NewMonitoringConfig(opts ...Option) Monitoring
func (Monitoring) ExporterMetricsProtocol ¶
func (d Monitoring) ExporterMetricsProtocol() string
ExporterMetricsProtocol returns the protocol used by the OTLP Metrics exporter. If both `OTEL_EXPORTER_OTLP_PROTOCOL` and `OTEL_EXPORTER_OTLP_METRICS_PROTOCOL` are present, `OTEL_EXPORTER_OTLP_METRICS_PROTOCOL` takes higher precedence.
func (Monitoring) ExporterTracesProtocol ¶
func (d Monitoring) ExporterTracesProtocol() string
ExporterTracesProtocol returns the protocol used by the OTLP Trace exporter. If both `OTEL_EXPORTER_OTLP_PROTOCOL` and `OTEL_EXPORTER_OTLP_TRACES_PROTOCOL` are present, `OTEL_EXPORTER_OTLP_TRACES_PROTOCOL` takes higher precedence.
func (Monitoring) IsTestExporter ¶
func (d Monitoring) IsTestExporter() bool
IsTestExporter returns whether the OTLP exporter should be used in test mode.
func (Monitoring) MetricsInterval ¶ added in v1.2.0
func (d Monitoring) MetricsInterval() time.Duration
MetricsInterval returns the interval at which metrics are exported. If the metrics interval is not set, it returns the default metrics interval. If the metrics interval is set to a negative value, it returns the default metrics interval.
func (Monitoring) Service ¶
func (d Monitoring) Service() string
Service returns the service name for application tagging.