Collector

简要概述

说明 OpenTelemetry Collector 组件安装部署。

简单部署

预先编译安装包

https://opentelemetry.io/docs/collector/getting-started/#linux-packaging

源码包编译安装

export GOOS=linux
export GOARCH=amd64

git clone https://github.com/open-telemetry/opentelemetry-collector.git
cd opentelemetry-collector

make install-tools
make otelcorecol
./bin/otelcorecol_* --config ./examples/local/otel-config.yaml

配置示列

TODO;

配置结构

Config

github.com/open-telemetry/opentelemetry-collector/otelcol/config.go

// Config defines the configuration for the various elements of collector or agent.
type Config struct {
    // Receivers is a map of ComponentID to Receivers.
    Receivers map[component.ID]component.Config

    // Exporters is a map of ComponentID to Exporters.
    Exporters map[component.ID]component.Config

    // Processors is a map of ComponentID to Processors.
    Processors map[component.ID]component.Config

    // Connectors is a map of ComponentID to connectors.
    Connectors map[component.ID]component.Config

    // Extensions is a map of ComponentID to extensions.
    Extensions map[component.ID]component.Config

    Service service.Config
}

Receivers

github.com/open-telemetry/opentelemetry-collector/receiver

receivers:
  ${component.ID}:
    ${component.Config}
  ......

默认主代码仓库仅支持 otlp 数据源,其他均在扩展仓库 opentelemetry-collector-contrib 根据实际情况在编译时引入。

  • otlp

github.com/open-telemetry/opentelemetry-collector/receiver/otlpreceiver

receivers:
  otlp:
    protocols:
      grpc:
        # <configgrpc.GRPCServerSettings>
      http:
        # <confighttp.HTTPServerSettings>
// Protocols is the configuration for the supported protocols.
type Protocols struct {
    GRPC *configgrpc.GRPCServerSettings `mapstructure:"grpc"`
    HTTP *confighttp.HTTPServerSettings `mapstructure:"http"`
}

// Config defines configuration for OTLP receiver.
type Config struct {
    // Protocols is the configuration for the supported protocols, currently gRPC and HTTP (Proto and JSON).
    Protocols `mapstructure:"protocols"`
}

Exporters

github.com/open-telemetry/opentelemetry-collector/exporter

根据 Config 转换 yaml 配置如下:

exporters:
  ${component.ID}:
    ${component.Config}
  ......

存在以下几个内置的 exporter

exporter/debugexporter
exporter/loggingexporter
exporter/otlpexporter
exporter/otlphttpexporter

还有大量第三方组件见 opentelemetry-collector-contrib 仓库。

  • 类型 otlpexporter 配置

配置代码见 exporter/otlpexporter/config.go

// Config defines configuration for OTLP exporter.
type Config struct {
    exporterhelper.TimeoutSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
    exporterhelper.QueueSettings   `mapstructure:"sending_queue"`
    exporterhelper.RetrySettings   `mapstructure:"retry_on_failure"`

    configgrpc.GRPCClientSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
}
  • 类型 otlphttpexporter 配置

配置代码见 exporter/otlphttpexporter/config.go

// Config defines configuration for OTLP/HTTP exporter.
type Config struct {
    confighttp.HTTPClientSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
    exporterhelper.QueueSettings  `mapstructure:"sending_queue"`
    exporterhelper.RetrySettings  `mapstructure:"retry_on_failure"`

    // The URL to send traces to. If omitted the Endpoint + "/v1/traces" will be used.
    TracesEndpoint string `mapstructure:"traces_endpoint"`

    // The URL to send metrics to. If omitted the Endpoint + "/v1/metrics" will be used.
    MetricsEndpoint string `mapstructure:"metrics_endpoint"`

    // The URL to send logs to. If omitted the Endpoint + "/v1/logs" will be used.
    LogsEndpoint string `mapstructure:"logs_endpoint"`
}

Processors

github.com/open-telemetry/opentelemetry-collector/processor

用于在组件 Receivers 接收数据和 Exporters 导出数据之间运行,该部分是可选的,但建议根据实际情况使用一些。

同样的仅在这里配置是不会启用它,也需要在 Service 中配置 pipelines 来启用。

存在以下几个内置的 processor

processor/batchprocessor
processor/memorylimiterprocessor

还有大量第三方组件见 opentelemetry-collector-contrib 仓库。

根据 Config 转换 yaml 配置如下:

processors:
  ${component.ID}:
    ${component.Config}
  ......

启用 memory_limiter 与 batch 组件示例:

processors:
  batch:
  memory_limiter:
    # 75% of maximum memory up to 4G
    limit_mib: 1536
    # 25% of limit up to 2G
    spike_limit_mib: 512
    check_interval: 5s

service:
  pipelines:
    traces:
      processors: [memory_limiter, batch]
    metrics:
      processors: [memory_limiter, batch]
  • 组件 batch 配置
// Config defines configuration for batch processor.
type Config struct {
    // Timeout sets the time after which a batch will be sent regardless of size.
    // When this is set to zero, batched data will be sent immediately.
    Timeout time.Duration `mapstructure:"timeout"`

    // SendBatchSize is the size of a batch which after hit, will trigger it to be sent.
    // When this is set to zero, the batch size is ignored and data will be sent immediately
    // subject to only send_batch_max_size.
    SendBatchSize uint32 `mapstructure:"send_batch_size"`

    // SendBatchMaxSize is the maximum size of a batch. It must be larger than SendBatchSize.
    // Larger batches are split into smaller units.
    // Default value is 0, that means no maximum size.
    SendBatchMaxSize uint32 `mapstructure:"send_batch_max_size"`

    // MetadataKeys is a list of client.Metadata keys that will be
    // used to form distinct batchers.  If this setting is empty,
    // a single batcher instance will be used.  When this setting
    // is not empty, one batcher will be used per distinct
    // combination of values for the listed metadata keys.
    //
    // Empty value and unset metadata are treated as distinct cases.
    //
    // Entries are case-insensitive.  Duplicated entries will
    // trigger a validation error.
    MetadataKeys []string `mapstructure:"metadata_keys"`

    // MetadataCardinalityLimit indicates the maximum number of
    // batcher instances that will be created through a distinct
    // combination of MetadataKeys.
    MetadataCardinalityLimit uint32 `mapstructure:"metadata_cardinality_limit"`
}
  • 组件 memorylimiter 配置
// Config defines configuration for memory memoryLimiter processor.
type Config struct {
    // CheckInterval is the time between measurements of memory usage for the
    // purposes of avoiding going over the limits. Defaults to zero, so no
    // checks will be performed.
    CheckInterval time.Duration `mapstructure:"check_interval"`

    // MemoryLimitMiB is the maximum amount of memory, in MiB, targeted to be
    // allocated by the process.
    MemoryLimitMiB uint32 `mapstructure:"limit_mib"`

    // MemorySpikeLimitMiB is the maximum, in MiB, spike expected between the
    // measurements of memory usage.
    MemorySpikeLimitMiB uint32 `mapstructure:"spike_limit_mib"`

    // MemoryLimitPercentage is the maximum amount of memory, in %, targeted to be
    // allocated by the process. The fixed memory settings MemoryLimitMiB has a higher precedence.
    MemoryLimitPercentage uint32 `mapstructure:"limit_percentage"`

    // MemorySpikePercentage is the maximum, in percents against the total memory,
    // spike expected between the measurements of memory usage.
    MemorySpikePercentage uint32 `mapstructure:"spike_limit_percentage"`
}

Connectors

github.com/open-telemetry/opentelemetry-collector/connector

用于连接 ReceiversExporters 两个组件且作为其中的管道,起点用于接收 Receivers 数据,终点用于 Exporters 导出数据。

它可以消费和发出相同数据类型或不同数据类型的数据,连接器可以生成并发送数据来汇总消耗的数据,也可以简单地复制或路由数据。

根据 Config 转换 yaml 配置如下:

connectors:
  ${component.ID}:
    ${component.Config}
  ......

还有大量第三方组件见 opentelemetry-collector-contrib 仓库。

存在以下几个内置的 connector

connector/forwardconnector
  • 组件 forward 配置
connectors:
  forward:

TODO;

Extensions

可选部分,主要用于不涉及处理遥测数据的任务,如:运行状况监视、服务发现和数据转发等。

同样的仅在这里配置是不会启用它,也需要在 Service 中配置 pipelines 来启用。

根据 Config 转换 yaml 配置如下:

extensions:
  ${component.ID}:
    ${component.Config}
  ......

存在以下几个内置的 processor

extension/ballastextension
extension/zpagesextension

还有大量第三方组件见 opentelemetry-collector-contrib 仓库。

  • 组件 ballast 配置
// Config has the configuration for the ballast extension.
type Config struct {
    // SizeMiB is the size, in MiB, of the memory ballast
    // to be created for this process.
    SizeMiB uint64 `mapstructure:"size_mib"`

    // SizeInPercentage is the maximum amount of memory ballast, in %, targeted to be
    // allocated. The fixed memory settings SizeMiB has a higher precedence.
    SizeInPercentage uint64 `mapstructure:"size_in_percentage"`
}
  • 组件 zpages 配置
// Config has the configuration for the extension enabling the zPages extension.
type Config struct {
    // TCPAddr is the address and port in which the zPages will be listening to.
    // Use localhost:<port> to make it available only locally, or ":<port>" to
    // make it available on all network interfaces.
    TCPAddr confignet.TCPAddr `mapstructure:",squash"`
}

Service

由 telemetry、extensions、pipelines 三部分组成。

其中 telemetry 用于自身进程的遥感配置,而 extensions、pipelines 用于根据 ReceiversProcessorsExportersExtensions 部分中的配置启用的组件,如果组件已配置,但未在这里定义,则不会启用该组件。

配置示例:

service:
  telemetry:
    logs:
      level: debug
      initial_fields:
        service: my-instance
    metrics:
      level: detailed
      address: 0.0.0.0:8888

  extensions: [health_check, pprof]

  pipelines:
    traces:
      receivers: [otlp]
      exporters: [otlp]

数据结构

component.ID

go.opentelemetry.io/collector/component.ID

// ID represents the identity for a component. It combines two values:
// * type - the Type of the component.
// * name - the name of that component.
// The component ID (combination type + name) is unique for a given component.Kind.
type ID struct {
    typeVal Type   `mapstructure:"-"`
    nameVal string `mapstructure:"-"`
}

component.Config

go.opentelemetry.io/collector/component.Config

// Config defines the configuration for a component.Component.
//
// Implementations and/or any sub-configs (other types embedded or included in the Config implementation)
// MUST implement the ConfigValidator if any validation is required for that part of the configuration
// (e.g. check if a required field is present).
//
// A valid implementation MUST pass the check componenttest.CheckConfigStruct (return nil error).
type Config any

builtin/builtin.go

// any is an alias for interface{} and is equivalent to interface{} in all ways.
type any = interface{}

在 go1.18 新增了 any 类型,为 interface{} 的别名。

service.Config

github.com/open-telemetry/opentelemetry-collector/service/config.go

// Config defines the configurable components of the Service.
type Config struct {
    // Telemetry is the configuration for collector's own telemetry.
    Telemetry telemetry.Config `mapstructure:"telemetry"`

    // Extensions are the ordered list of extensions configured for the service.
    Extensions extensions.Config `mapstructure:"extensions"`

    // Pipelines are the set of data pipelines configured for the service.
    Pipelines pipelines.Config `mapstructure:"pipelines"`
}

configgrpc.GRPCClientSettings

github.com/open-telemetry/opentelemetry-collector/config/configgrpc

// GRPCClientSettings defines common settings for a gRPC client configuration.
type GRPCClientSettings struct {
    // The target to which the exporter is going to send traces or metrics,
    // using the gRPC protocol. The valid syntax is described at
    // https://github.com/grpc/grpc/blob/master/doc/naming.md.
    Endpoint string `mapstructure:"endpoint"`

    // The compression key for supported compression types within collector.
    Compression configcompression.CompressionType `mapstructure:"compression"`

    // TLSSetting struct exposes TLS client configuration.
    TLSSetting configtls.TLSClientSetting `mapstructure:"tls"`

    // The keepalive parameters for gRPC client. See grpc.WithKeepaliveParams.
    // (https://godoc.org/google.golang.org/grpc#WithKeepaliveParams).
    Keepalive *KeepaliveClientConfig `mapstructure:"keepalive"`

    // ReadBufferSize for gRPC client. See grpc.WithReadBufferSize.
    // (https://godoc.org/google.golang.org/grpc#WithReadBufferSize).
    ReadBufferSize int `mapstructure:"read_buffer_size"`

    // WriteBufferSize for gRPC gRPC. See grpc.WithWriteBufferSize.
    // (https://godoc.org/google.golang.org/grpc#WithWriteBufferSize).
    WriteBufferSize int `mapstructure:"write_buffer_size"`

    // WaitForReady parameter configures client to wait for ready state before sending data.
    // (https://github.com/grpc/grpc/blob/master/doc/wait-for-ready.md)
    WaitForReady bool `mapstructure:"wait_for_ready"`

    // The headers associated with gRPC requests.
    Headers map[string]configopaque.String `mapstructure:"headers"`

    // Sets the balancer in grpclb_policy to discover the servers. Default is pick_first.
    // https://github.com/grpc/grpc-go/blob/master/examples/features/load_balancing/README.md
    BalancerName string `mapstructure:"balancer_name"`

    // WithAuthority parameter configures client to rewrite ":authority" header
    // (godoc.org/google.golang.org/grpc#WithAuthority)
    Authority string `mapstructure:"authority"`

    // Auth configuration for outgoing RPCs.
    Auth *configauth.Authentication `mapstructure:"auth"`
}

configgrpc.GRPCServerSettings

github.com/open-telemetry/opentelemetry-collector/config/configgrpc

// GRPCServerSettings defines common settings for a gRPC server configuration.
type GRPCServerSettings struct {
    // Server net.Addr config. For transport only "tcp" and "unix" are valid options.
    NetAddr confignet.NetAddr `mapstructure:",squash"`

    // Configures the protocol to use TLS.
    // The default value is nil, which will cause the protocol to not use TLS.
    TLSSetting *configtls.TLSServerSetting `mapstructure:"tls"`

    // MaxRecvMsgSizeMiB sets the maximum size (in MiB) of messages accepted by the server.
    MaxRecvMsgSizeMiB uint64 `mapstructure:"max_recv_msg_size_mib"`

    // MaxConcurrentStreams sets the limit on the number of concurrent streams to each ServerTransport.
    // It has effect only for streaming RPCs.
    MaxConcurrentStreams uint32 `mapstructure:"max_concurrent_streams"`

    // ReadBufferSize for gRPC server. See grpc.ReadBufferSize.
    // (https://godoc.org/google.golang.org/grpc#ReadBufferSize).
    ReadBufferSize int `mapstructure:"read_buffer_size"`

    // WriteBufferSize for gRPC server. See grpc.WriteBufferSize.
    // (https://godoc.org/google.golang.org/grpc#WriteBufferSize).
    WriteBufferSize int `mapstructure:"write_buffer_size"`

    // Keepalive anchor for all the settings related to keepalive.
    Keepalive *KeepaliveServerConfig `mapstructure:"keepalive"`

    // Auth for this receiver
    Auth *configauth.Authentication `mapstructure:"auth"`

    // Include propagates the incoming connection's metadata to downstream consumers.
    // Experimental: *NOTE* this option is subject to change or removal in the future.
    IncludeMetadata bool `mapstructure:"include_metadata"`
}

confighttp.HTTPClientSettings

github.com/open-telemetry/opentelemetry-collector/config/confighttp/confighttp.go

// HTTPClientSettings defines settings for creating an HTTP client.
type HTTPClientSettings struct {
    // The target URL to send data to (e.g.: http://some.url:9411/v1/traces).
    Endpoint string `mapstructure:"endpoint"`

    // TLSSetting struct exposes TLS client configuration.
    TLSSetting configtls.TLSClientSetting `mapstructure:"tls"`

    // ReadBufferSize for HTTP client. See http.Transport.ReadBufferSize.
    ReadBufferSize int `mapstructure:"read_buffer_size"`

    // WriteBufferSize for HTTP client. See http.Transport.WriteBufferSize.
    WriteBufferSize int `mapstructure:"write_buffer_size"`

    // Timeout parameter configures `http.Client.Timeout`.
    Timeout time.Duration `mapstructure:"timeout"`

    // Additional headers attached to each HTTP request sent by the client.
    // Existing header values are overwritten if collision happens.
    // Header values are opaque since they may be sensitive.
    Headers map[string]configopaque.String `mapstructure:"headers"`

    // Custom Round Tripper to allow for individual components to intercept HTTP requests
    CustomRoundTripper func(next http.RoundTripper) (http.RoundTripper, error)

    // Auth configuration for outgoing HTTP calls.
    Auth *configauth.Authentication `mapstructure:"auth"`

    // The compression key for supported compression types within collector.
    Compression configcompression.CompressionType `mapstructure:"compression"`

    // MaxIdleConns is used to set a limit to the maximum idle HTTP connections the client can keep open.
    // There's an already set value, and we want to override it only if an explicit value provided
    MaxIdleConns *int `mapstructure:"max_idle_conns"`

    // MaxIdleConnsPerHost is used to set a limit to the maximum idle HTTP connections the host can keep open.
    // There's an already set value, and we want to override it only if an explicit value provided
    MaxIdleConnsPerHost *int `mapstructure:"max_idle_conns_per_host"`

    // MaxConnsPerHost limits the total number of connections per host, including connections in the dialing,
    // active, and idle states.
    // There's an already set value, and we want to override it only if an explicit value provided
    MaxConnsPerHost *int `mapstructure:"max_conns_per_host"`

    // IdleConnTimeout is the maximum amount of time a connection will remain open before closing itself.
    // There's an already set value, and we want to override it only if an explicit value provided
    IdleConnTimeout *time.Duration `mapstructure:"idle_conn_timeout"`

    // DisableKeepAlives, if true, disables HTTP keep-alives and will only use the connection to the server
    // for a single HTTP request.
    //
    // WARNING: enabling this option can result in significant overhead establishing a new HTTP(S)
    // connection for every request. Before enabling this option please consider whether changes
    // to idle connection settings can achieve your goal.
    DisableKeepAlives bool `mapstructure:"disable_keep_alives"`
}

confignet.NetAddr

// NetAddr represents a network endpoint address.
type NetAddr struct {
    // Endpoint configures the address for this network connection.
    // For TCP and UDP networks, the address has the form "host:port". The host must be a literal IP address,
    // or a host name that can be resolved to IP addresses. The port must be a literal port number or a service name.
    // If the host is a literal IPv6 address it must be enclosed in square brackets, as in "[2001:db8::1]:80" or
    // "[fe80::1%zone]:80". The zone specifies the scope of the literal IPv6 address as defined in RFC 4007.
    Endpoint string `mapstructure:"endpoint"`

    // Transport to use. Known protocols are "tcp", "tcp4" (IPv4-only), "tcp6" (IPv6-only), "udp", "udp4" (IPv4-only),
    // "udp6" (IPv6-only), "ip", "ip4" (IPv4-only), "ip6" (IPv6-only), "unix", "unixgram" and "unixpacket".
    Transport string `mapstructure:"transport"`
}

configtls.TLSServerSetting

// TLSServerSetting contains TLS configurations that are specific to server
// connections in addition to the common configurations. This should be used by
// components configuring TLS server connections.
type TLSServerSetting struct {
    // squash ensures fields are correctly decoded in embedded struct.
    TLSSetting `mapstructure:",squash"`

    // These are config options specific to server connections.

    // Path to the TLS cert to use by the server to verify a client certificate. (optional)
    // This sets the ClientCAs and ClientAuth to RequireAndVerifyClientCert in the TLSConfig. Please refer to
    // https://godoc.org/crypto/tls#Config for more information. (optional)
    ClientCAFile string `mapstructure:"client_ca_file"`

    // Reload the ClientCAs file when it is modified
    // (optional, default false)
    ReloadClientCAFile bool `mapstructure:"client_ca_file_reload"`
}

// TLSSetting exposes the common client and server TLS configurations.
// Note: Since there isn't anything specific to a server connection. Components
// with server connections should use TLSSetting.
type TLSSetting struct {
    // Path to the CA cert. For a client this verifies the server certificate.
    // For a server this verifies client certificates. If empty uses system root CA.
    // (optional)
    CAFile string `mapstructure:"ca_file"`

    // Path to the TLS cert to use for TLS required connections. (optional)
    CertFile string `mapstructure:"cert_file"`

    // Path to the TLS key to use for TLS required connections. (optional)
    KeyFile string `mapstructure:"key_file"`

    // MinVersion sets the minimum TLS version that is acceptable.
    // If not set, TLS 1.2 will be used. (optional)
    MinVersion string `mapstructure:"min_version"`

    // MaxVersion sets the maximum TLS version that is acceptable.
    // If not set, refer to crypto/tls for defaults. (optional)
    MaxVersion string `mapstructure:"max_version"`

    // ReloadInterval specifies the duration after which the certificate will be reloaded
    // If not set, it will never be reloaded (optional)
    ReloadInterval time.Duration `mapstructure:"reload_interval"`
}

KeepaliveServerConfig

// KeepaliveServerConfig is the configuration for keepalive.
type KeepaliveServerConfig struct {
    ServerParameters  *KeepaliveServerParameters  `mapstructure:"server_parameters"`
    EnforcementPolicy *KeepaliveEnforcementPolicy `mapstructure:"enforcement_policy"`
}

// KeepaliveServerParameters allow configuration of the keepalive.ServerParameters.
// The same default values as keepalive.ServerParameters are applicable and get applied by the server.
// See https://godoc.org/google.golang.org/grpc/keepalive#ServerParameters for details.
type KeepaliveServerParameters struct {
    MaxConnectionIdle     time.Duration `mapstructure:"max_connection_idle"`
    MaxConnectionAge      time.Duration `mapstructure:"max_connection_age"`
    MaxConnectionAgeGrace time.Duration `mapstructure:"max_connection_age_grace"`
    Time                  time.Duration `mapstructure:"time"`
    Timeout               time.Duration `mapstructure:"timeout"`
}

// KeepaliveEnforcementPolicy allow configuration of the keepalive.EnforcementPolicy.
// The same default values as keepalive.EnforcementPolicy are applicable and get applied by the server.
// See https://godoc.org/google.golang.org/grpc/keepalive#EnforcementPolicy for details.
type KeepaliveEnforcementPolicy struct {
    MinTime             time.Duration `mapstructure:"min_time"`
    PermitWithoutStream bool          `mapstructure:"permit_without_stream"`
}

configauth.Authentication

// Authentication defines the auth settings for the receiver.
type Authentication struct {
    // AuthenticatorID specifies the name of the extension to use in order to authenticate the incoming data point.
    AuthenticatorID component.ID `mapstructure:"authenticator"`
}

confighttp.HTTPServerSettings

// HTTPServerSettings defines settings for creating an HTTP server.
type HTTPServerSettings struct {
    // Endpoint configures the listening address for the server.
    Endpoint string `mapstructure:"endpoint"`

    // TLSSetting struct exposes TLS client configuration.
    TLSSetting *configtls.TLSServerSetting `mapstructure:"tls"`

    // CORS configures the server for HTTP cross-origin resource sharing (CORS).
    CORS *CORSSettings `mapstructure:"cors"`

    // Auth for this receiver
    Auth *configauth.Authentication `mapstructure:"auth"`

    // MaxRequestBodySize sets the maximum request body size in bytes
    MaxRequestBodySize int64 `mapstructure:"max_request_body_size"`

    // IncludeMetadata propagates the client metadata from the incoming requests to the downstream consumers
    // Experimental: *NOTE* this option is subject to change or removal in the future.
    IncludeMetadata bool `mapstructure:"include_metadata"`
}

CORSSettings

// CORSSettings configures a receiver for HTTP cross-origin resource sharing (CORS).
// See the underlying https://github.com/rs/cors package for details.
type CORSSettings struct {
    // AllowedOrigins sets the allowed values of the Origin header for
    // HTTP/JSON requests to an OTLP receiver. An origin may contain a
    // wildcard (*) to replace 0 or more characters (e.g.,
    // "http://*.domain.com", or "*" to allow any origin).
    AllowedOrigins []string `mapstructure:"allowed_origins"`

    // AllowedHeaders sets what headers will be allowed in CORS requests.
    // The Accept, Accept-Language, Content-Type, and Content-Language
    // headers are implicitly allowed. If no headers are listed,
    // X-Requested-With will also be accepted by default. Include "*" to
    // allow any request header.
    AllowedHeaders []string `mapstructure:"allowed_headers"`

    // MaxAge sets the value of the Access-Control-Max-Age response header.
    // Set it to the number of seconds that browsers should cache a CORS
    // preflight response for.
    MaxAge int `mapstructure:"max_age"`
}

telemetry.Config

github.com/open-telemetry/opentelemetry-collector/service/telemetry

// Config defines the configurable settings for service telemetry.
type Config struct {
    Logs    LogsConfig    `mapstructure:"logs"`
    Metrics MetricsConfig `mapstructure:"metrics"`
    Traces  TracesConfig  `mapstructure:"traces"`

    // Resource specifies user-defined attributes to include with all emitted telemetry.
    // Note that some attributes are added automatically (e.g. service.version) even
    // if they are not specified here. In order to suppress such attributes the
    // attribute must be specified in this map with null YAML value (nil string pointer).
    Resource map[string]*string `mapstructure:"resource"`
}

本收集器自身的遥测配置,如:

service:
  telemetry:
    logs:
      level: debug
      initial_fields:
        service: my-instance
    metrics:
      level: detailed
      address: 0.0.0.0:8888

extensions.Config

github.com/open-telemetry/opentelemetry-collector/service/extensions

// Config represents the ordered list of extensions configured for the service.
type Config []component.ID
service:
  extensions: [health_check, pprof, zpages]

pipelines.Config

github.com/open-telemetry/opentelemetry-collector/service/pipelines

// Config defines the configurable settings for service telemetry.
type Config map[component.ID]*PipelineConfig

// PipelineConfig defines the configuration of a Pipeline.
type PipelineConfig struct {
    Receivers  []component.ID `mapstructure:"receivers"`
    Processors []component.ID `mapstructure:"processors"`
    Exporters  []component.ID `mapstructure:"exporters"`
}

以上 map[component.ID]*PipelineConfig 中的 “component.ID” 可配置为以下三种类型:

  1. traces
  2. metrics
  3. logs



最后修改 2023.11.02: docs: 添加语义约定 (7b0ba5f)