provider

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2021 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Shutdown

func Shutdown(c *Config)

Shutdown 优雅关闭,将OpenTelemetry SDK内存中的数据发送到服务端

func Start

func Start(c *Config) error

Start 初始化OpenTelemetry SDK,需要把 ${endpoint} 替换为实际的地址 如果填写为stdout则为调试默认,数据将打印到标准输出

Types

type Config

type Config struct {
	TraceExporterEndpoint          string `env:"SLS_OTEL_TRACE_ENDPOINT,default=stdout"`
	TraceExporterEndpointInsecure  bool   `env:"SLS_OTEL_TRACE_INSECURE,default=false"`
	MetricExporterEndpoint         string `env:"SLS_OTEL_METRIC_ENDPOINT,default=stdout"`
	MetricExporterEndpointInsecure bool   `env:"SLS_OTEL_METRIC_INSECURE,default=false"`
	MetricReportingPeriod          string `env:"SLS_OTEL_METRIC_EXPORT_PERIOD,default=30s"`
	ServiceName                    string `env:"SLS_OTEL_SERVICE_NAME"`
	ServiceVersion                 string `env:"SLS_OTEL_SERVICE_VERSION,default=v0.1.0"`
	Project                        string `env:"SLS_OTEL_PROJECT"`
	InstanceID                     string `env:"SLS_OTEL_INSTANCE_ID"`
	AccessKeyID                    string `env:"SLS_OTEL_ACCESS_KEY_ID"`
	AccessKeySecret                string `env:"SLS_OTEL_ACCESS_KEY_SECRET"`
	AttributesEnvKeys              string `env:"SLS_OTEL_ATTRIBUTES_ENV_KEYS"`

	Resource *resource.Resource
	// contains filtered or unexported fields
}

Config configure for sls otel

func NewConfig

func NewConfig(opts ...Option) (*Config, error)

NewConfig create a config

func (*Config) IsValid

func (c *Config) IsValid() error

IsValid check config and return error if config invalid

type Option

type Option func(*Config)

Option configures the sls otel provider

func WithErrorHandler

func WithErrorHandler(handler otel.ErrorHandler) Option

WithErrorHandler Configures a global error handler to be used throughout an OpenTelemetry instrumented project. See "go.opentelemetry.io/otel" 配置OpenTelemetry错误处理函数

func WithMetricExporterEndpoint

func WithMetricExporterEndpoint(url string) Option

WithMetricExporterEndpoint configures the endpoint for sending metrics via OTLP 配置Metric的输出地址,如果配置为空则禁用Metric功能,配置为stdout则打印到标准输出用于测试

func WithMetricExporterInsecure

func WithMetricExporterInsecure(insecure bool) Option

WithMetricExporterInsecure permits connecting to the metric endpoint without a certificate 配置是否禁用SSL,如果输出到SLS,则必须打开SLS

func WithMetricReportingPeriod

func WithMetricReportingPeriod(p time.Duration) Option

WithMetricReportingPeriod configures the metric reporting period, how often the controller collects and exports metric data. 配置Metric导出间隔,默认为30s

func WithResource

func WithResource(resource *resource.Resource) Option

WithResource configures attributes on the resource 配置上传附加的一些tag信息,例如环境、可用区等

func WithResourceAttributes

func WithResourceAttributes(attributes map[string]string) Option

WithResourceAttributes configures attributes on the resource 配置上传附加的一些tag信息,例如环境、可用区等

func WithSLSConfig

func WithSLSConfig(project, instanceID, accessKeyID, accessKeySecret string) Option

WithSLSConfig configures sls project, instanceID, accessKeyID, accessKeySecret to send data to sls directly 配置输出到SLS的信息,包括 project, instanceID, accessKeyID, accessKeySecret

func WithServiceName

func WithServiceName(name string) Option

WithServiceName configures a "service.name" resource label 配置服务名称

func WithServiceVersion

func WithServiceVersion(version string) Option

WithServiceVersion configures a "service.version" resource label 配置版本号

func WithTraceExporterEndpoint

func WithTraceExporterEndpoint(url string) Option

WithTraceExporterEndpoint configures the endpoint for sending traces via OTLP 配置Trace的输出地址,如果配置为空则禁用Trace功能,配置为stdout则打印到标准输出用于测试

func WithTraceExporterInsecure

func WithTraceExporterInsecure(insecure bool) Option

WithTraceExporterInsecure permits connecting to the trace endpoint without a certificate 配置是否禁用SSL,如果输出到SLS,则必须打开SLS

Jump to

Keyboard shortcuts

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