add more docs for traces.yaml

This commit is contained in:
yushuangyu 2022-06-28 20:11:39 +08:00
parent cf5b714013
commit e11cc6677e
5 changed files with 105 additions and 24 deletions

View File

@ -5,23 +5,85 @@
# For more details, see the OpenTelemetry official docs:
# https://opentelemetry.io/docs/collector/configuration/
traces:
# set enable to true to start tracing
enable: true
# Extensions:
# provide capabilities that can be added to the Collector, but which do not require direct access to telemetry data
# and are not part of pipelines. They are also enabled within the service section.
#
# Categraf supports:
# pprof: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/pprofextension
# health_check: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/healthcheckextension
# basicauth: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/basicauthextension
# jaegerremotesampling: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/jaegerremotesampling
extensions:
health_check:
pprof:
endpoint: 0.0.0.0:1777
zpages:
endpoint: 0.0.0.0:55679
health_check:
#jaegerremotesampling:
# source:
# remote:
# endpoint: jaeger-collector:14250
#basicauth/server:
# htpasswd:
# file: .htpasswd
# inline: |
# ${BASIC_AUTH_USERNAME}:${BASIC_AUTH_PASSWORD}
#
#basicauth/client:
# client_auth:
# username: username
# password: password
# Receiver:
# which can be push or pull based, is how data gets into the Collector. Configuring a receiver does not enable it.
# Receivers are enabled via pipelines within the service section.
#
# Categraf supports:
# jaeger: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/jaegerreceiver
# zipkin: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/zipkinreceiver
# otlp: https://github.com/open-telemetry/opentelemetry-collector/tree/main/receiver/otlpreceiver
# kafka: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/kafkareceiver
receivers:
jaeger:
protocols:
thrift_http:
endpoint: 0.0.0.0:14268
# Processor:
# run on data between being received and being exported. Configuring a processor does not enable it.
# Processors are enabled via pipelines within the service section.
#
# Categraf supports:
# batch: https://github.com/open-telemetry/opentelemetry-collector/tree/main/processor/batchprocessor
# attributes: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/attributesprocessor
# resource: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/resourceprocessor
# span: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/spanprocessor
# tailsampling: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/tailsamplingprocessor
processors:
batch:
batch/example:
send_batch_size: 1000
timeout: 10s
attributes/example:
actions:
- key: ident
value: categraf-01.bj
action: upsert
# Exporter:
# which can be push or pull based, is how you send data to one or more backends/destinations. Configuring an
# exporter does not enable it. Exporters are enabled via pipelines within the service section.
#
# Categraf supports:
# otlp: https://github.com/open-telemetry/opentelemetry-collector/tree/main/exporter/otlpexporter
# otlphttp: https://github.com/open-telemetry/opentelemetry-collector/tree/main/exporter/otlphttpexporter
# jaeger: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/jaegerexporter
# zipkin: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/zipkinexporter
# kafka: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/kafkaexporter
# alibabacloudlogservice: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/alibabacloudlogserviceexporter
exporters:
jaeger:
endpoint: "127.0.0.1:14250"
@ -31,11 +93,23 @@ traces:
zipkin:
endpoint: "http://127.0.0.1:9411/api/v2/spans"
# Service:
# used to configure what components are enabled in the Collector based on the configuration found in the receivers,
# processors, exporters, and extensions sections. If a component is configured, but not defined within the service
# section then it is not enabled. The service section consists of three sub-sections:
# - extensions: Extensions consist of a list of all extensions to enable.
# - pipelines: A pipeline consists of a set of receivers, processors and exporters.
# - telemetry: Telemetry is where the telemetry for the collector itself can be configured.
service:
extensions: [health_check, pprof]
pipelines:
traces:
receivers: [jaeger]
processors: [batch]
exporters: [jaeger,zipkin]
extensions: [health_check, pprof, zpages]
processors: [batch/example, attributes/example]
exporters: [jaeger, zipkin]
telemetry:
logs:
level: info
initial_fields:
service: my-instance

View File

@ -5,10 +5,12 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/jaegerexporter"
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/kafkaexporter"
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/zipkinexporter"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/basicauthextension"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/oauth2clientauthextension"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/pprofextension"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourceprocessor"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/spanprocessor"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaegerreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kafkareceiver"
@ -16,20 +18,15 @@ import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/exporter/otlpexporter"
"go.opentelemetry.io/collector/exporter/otlphttpexporter"
"go.opentelemetry.io/collector/extension/ballastextension"
"go.opentelemetry.io/collector/extension/zpagesextension"
"go.opentelemetry.io/collector/processor/batchprocessor"
"go.opentelemetry.io/collector/processor/memorylimiterprocessor"
"go.opentelemetry.io/collector/receiver/otlpreceiver"
)
// Add more factories here if you need
func components() (component.Factories, error) {
extensions, err := component.MakeExtensionFactoryMap(
oauth2clientauthextension.NewFactory(),
basicauthextension.NewFactory(),
healthcheckextension.NewFactory(),
ballastextension.NewFactory(),
zpagesextension.NewFactory(),
pprofextension.NewFactory(),
)
if err != nil {
@ -60,9 +57,10 @@ func components() (component.Factories, error) {
processors, err := component.MakeProcessorFactoryMap(
batchprocessor.NewFactory(),
memorylimiterprocessor.NewFactory(),
attributesprocessor.NewFactory(),
tailsamplingprocessor.NewFactory(),
resourceprocessor.NewFactory(),
spanprocessor.NewFactory(),
)
if err != nil {
return component.Factories{}, err

9
go.mod
View File

@ -27,10 +27,12 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/jaegerexporter v0.54.0
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/kafkaexporter v0.54.0
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/zipkinexporter v0.54.0
github.com/open-telemetry/opentelemetry-collector-contrib/extension/basicauthextension v0.54.0
github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension v0.54.0
github.com/open-telemetry/opentelemetry-collector-contrib/extension/oauth2clientauthextension v0.54.0
github.com/open-telemetry/opentelemetry-collector-contrib/extension/pprofextension v0.54.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor v0.54.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourceprocessor v0.54.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/spanprocessor v0.54.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor v0.54.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaegerreceiver v0.54.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kafkareceiver v0.54.0
@ -59,6 +61,7 @@ require (
cloud.google.com/go/compute v1.6.1 // indirect
contrib.go.opencensus.io/exporter/prometheus v0.4.1 // indirect
github.com/BurntSushi/toml v1.1.0 // indirect
github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962 // indirect
github.com/HdrHistogram/hdrhistogram-go v1.1.0 // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/VividCortex/gohistogram v1.0.0 // indirect
@ -165,6 +168,7 @@ require (
github.com/spf13/viper v1.11.0 // indirect
github.com/stretchr/objx v0.4.0 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/tg123/go-htpasswd v1.2.0 // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.4.0 // indirect
github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect
@ -178,7 +182,6 @@ require (
go.opentelemetry.io/collector/semconv v0.54.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.32.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.32.0 // indirect
go.opentelemetry.io/contrib/zpages v0.32.0 // indirect
go.opentelemetry.io/otel v1.7.0 // indirect
go.opentelemetry.io/otel/exporters/prometheus v0.30.0 // indirect
go.opentelemetry.io/otel/sdk v1.7.0 // indirect
@ -186,9 +189,7 @@ require (
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/automaxprocs v1.5.1 // indirect
golang.org/x/crypto v0.0.0-20220507011949-2cf3adece122 // indirect
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220608133413-ed9918b62aac // indirect
google.golang.org/grpc v1.47.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect

14
go.sum
View File

@ -68,6 +68,8 @@ github.com/ClickHouse/clickhouse-go/v2 v2.0.15 h1:lLAZliqrZEygkxosLaW1qHyeTb4Ho7
github.com/ClickHouse/clickhouse-go/v2 v2.0.15/go.mod h1:Z21o82zD8FFqefOQDg93c0XITlxGbTsWQuRm588Azkk=
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962 h1:KeNholpO2xKjgaaSyd+DyQRrsQjhbSeS7qe4nEw8aQw=
github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962/go.mod h1:kC29dT1vFpj7py2OvG1khBdQpo3kInWP+6QipLbdngo=
github.com/HdrHistogram/hdrhistogram-go v1.1.0 h1:6dpdDPTRoo78HxAJ6T1HfMiKSnqhgRRqzCuPshRkQ7I=
github.com/HdrHistogram/hdrhistogram-go v1.1.0/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
@ -706,10 +708,10 @@ github.com/open-telemetry/opentelemetry-collector-contrib/exporter/kafkaexporter
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/kafkaexporter v0.54.0/go.mod h1:n+/wWXv7VxQwyvLXa8U8DkCLftkoBjogwHEkhB1G+hs=
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/zipkinexporter v0.54.0 h1:A1WV0sZ2D/F+HkOJwIyfs6uJIYczRqkdJjKjVF4G17E=
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/zipkinexporter v0.54.0/go.mod h1:Fwtsr30iPRADWg6MMs7+nvM1YMqCSX3b7/BqFYup6cE=
github.com/open-telemetry/opentelemetry-collector-contrib/extension/basicauthextension v0.54.0 h1:Fu3WCnBlfI4sAmFytU9HGGFQrCVxbkWn5XZk3xxeU2c=
github.com/open-telemetry/opentelemetry-collector-contrib/extension/basicauthextension v0.54.0/go.mod h1:9nVL6GmhuVHEqhy5h1MUVxETgzYDd7vXGD1tKpeo92A=
github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension v0.54.0 h1:fiX1Agy5BSx3QRphNbufnW6Yvvro2g8mHybRzpgWM5k=
github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension v0.54.0/go.mod h1:/AfCHLiWnvqclKsY1KOi5VWeUEa/8Q4s+nDE2f/J9vs=
github.com/open-telemetry/opentelemetry-collector-contrib/extension/oauth2clientauthextension v0.54.0 h1:e11t8NnSozeryh16+i6zdYVU6LNMqLEE7XduwvdjALg=
github.com/open-telemetry/opentelemetry-collector-contrib/extension/oauth2clientauthextension v0.54.0/go.mod h1:fJ4ScWR6G1ljPvSb0iG6/kG/T+FnDzI6EoNQFv56zLo=
github.com/open-telemetry/opentelemetry-collector-contrib/extension/pprofextension v0.54.0 h1:3HbhTEm0RPvbySmuFmbzv9ZuDBWvUPsLqwnuo5uLWt0=
github.com/open-telemetry/opentelemetry-collector-contrib/extension/pprofextension v0.54.0/go.mod h1:5bWnzEUIlYXKUf9l0Bozfkx5FkFmrJKbuXEG/2RabkQ=
github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.54.0 h1:dYT3V8dSbdlo+P+f7sAV9pLha034GDxTF3GphUysHFI=
@ -723,6 +725,10 @@ github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/zipkin
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/zipkin v0.54.0/go.mod h1:ToGJcoJY47BYfDbPhzL8QK5SuDQtxLwSwnvvAnD9t+E=
github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor v0.54.0 h1:42cxlxEo+TMGAGnUAIve896iRASuoxiI/2JQuGJJ6p0=
github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor v0.54.0/go.mod h1:DdE50zrDFgiwvyyKbtwBDbhsyKBEPYNkD6h3xBjCNnk=
github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourceprocessor v0.54.0 h1:Gs/Ml4v66h7oynnW31dOI1bs9okjj7OcP030gKAGfqo=
github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourceprocessor v0.54.0/go.mod h1:VOcrn6v3oAV1JLdQgaMBLw9wx5yeVPOCzgVXKV4V1UA=
github.com/open-telemetry/opentelemetry-collector-contrib/processor/spanprocessor v0.54.0 h1:NzCPGipIbcHiSRQiMFawDxZpUNUj82F821jSaPZlYIg=
github.com/open-telemetry/opentelemetry-collector-contrib/processor/spanprocessor v0.54.0/go.mod h1:w0DOQPKYh1OUpnXkkCzbcEOvt3y6P4M3rtyPpB2xSds=
github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor v0.54.0 h1:sBx0ho+3uOV2D0IWqyj1/+UuaJohucA150z9sBByBy0=
github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor v0.54.0/go.mod h1:QyYeI/vIgSkSmU69+Gs9UQL6QzZOsSsvy3qt455dZ0Y=
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaegerreceiver v0.54.0 h1:dYyzLKgIInpee34hH0VvtwuHTGlER8PQZSG31F6hZ5U=
@ -910,6 +916,8 @@ github.com/stretchr/testify v1.7.4 h1:wZRexSlwd7ZXfKINDLsO4r7WBt3gTKONc6K/VesHvH
github.com/stretchr/testify v1.7.4/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/tg123/go-htpasswd v1.2.0 h1:UKp34m9H467/xklxUxU15wKRru7fwXoTojtxg25ITF0=
github.com/tg123/go-htpasswd v1.2.0/go.mod h1:h7IzlfpvIWnVJhNZ0nQ9HaFxHb7pn5uFJYLlEUJa2sM=
github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw=
github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk=
github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//o=
@ -970,7 +978,6 @@ go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.3
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.32.0 h1:mac9BKRqwaX6zxHPDe3pvmWpwuuIM0vuXv2juCnQevE=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.32.0/go.mod h1:5eCOqeGphOyz6TsY3ZDNjE33SM/TFAK3RGuCL2naTgY=
go.opentelemetry.io/contrib/zpages v0.32.0 h1:AVKTx5ppWDaem7A61HFsO1T3CK/t6kFRQoZQMj0/TW4=
go.opentelemetry.io/contrib/zpages v0.32.0/go.mod h1:Jx75I61RDcZU3d/1WrP6UdINlzGGLAwFNdQ3bCTb+qw=
go.opentelemetry.io/otel v1.7.0 h1:Z2lA3Tdch0iDcrhJXDIlC94XE+bxok1F9B+4Lz/lGsM=
go.opentelemetry.io/otel v1.7.0/go.mod h1:5BdUoMIz5WEs0vt0CUEMtSSaTSHBBVwrhnz7+nrD5xk=
go.opentelemetry.io/otel/exporters/prometheus v0.30.0 h1:YXo5ZY5nofaEYMCMTTMaRH2cLDZB8+0UGuk5RwMfIo0=
@ -1008,6 +1015,7 @@ go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8=
go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190228161510-8dd112bcdc25/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=

View File

@ -27,7 +27,7 @@ func LoadConfigs(configDir string, configPtr interface{}) error {
if strings.HasSuffix(fpath, "json") {
loaders = append(loaders, &multiconfig.JSONLoader{Path: path.Join(configDir, fpath)})
}
if strings.HasSuffix(fpath, "yaml") {
if strings.HasSuffix(fpath, "yaml") || strings.HasSuffix(fpath, "yml") {
loaders = append(loaders, &multiconfig.YAMLLoader{Path: path.Join(configDir, fpath)})
}
}