From 47071b0ccdb9b2b4370d4461607f71d2d1c3f004 Mon Sep 17 00:00:00 2001 From: Barun Das Date: Wed, 28 Feb 2024 19:58:35 -0500 Subject: [PATCH 01/21] fix merge conflict --- component/otelcol/exporter/debug/debug.go | 72 +++++++++++++++++++++++ go.mod | 32 +++++----- go.sum | 60 ++++++++++--------- 3 files changed, 120 insertions(+), 44 deletions(-) create mode 100644 component/otelcol/exporter/debug/debug.go diff --git a/component/otelcol/exporter/debug/debug.go b/component/otelcol/exporter/debug/debug.go new file mode 100644 index 000000000000..973e16f91d88 --- /dev/null +++ b/component/otelcol/exporter/debug/debug.go @@ -0,0 +1,72 @@ +package debug + +import ( + "github.com/grafana/agent/component" + "github.com/grafana/agent/component/otelcol" + "github.com/grafana/agent/component/otelcol/exporter" + otelcomponent "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/config/configtelemetry" + debugexporter "go.opentelemetry.io/collector/exporter/debugexporter" + otelextension "go.opentelemetry.io/collector/extension" +) + +func init() { + component.Register(component.Registration{ + Name: "otelcol.exporter.debug", + Args: Arguments{}, + Exports: otelcol.ConsumerExports{}, + + Build: func(opts component.Options, args component.Arguments) (component.Component, error) { + fact := debugexporter.NewFactory() + return exporter.New(opts, fact, args.(Arguments), exporter.TypeAll) + }, + }) +} + +// Arguments configures the otelcol.exporter.debug component. +type Arguments struct { + Verbosity configtelemetry.Level `river:"verbosity,attr,optional"` + SamplingInitial int `river:"sampling_initial,attr,optional"` + SamplingThereafter int `river:"sampling_thereafter,attr,optional"` + + // DebugMetrics configures component internal metrics. Optional. + DebugMetrics otelcol.DebugMetricsArguments `river:"debug_metrics,block,optional"` +} + +var _ exporter.Arguments = Arguments{} + +// DefaultArguments holds default values for Arguments. +var DefaultArguments = Arguments{ + Verbosity: configtelemetry.LevelBasic, + SamplingInitial: 2, + SamplingThereafter: 500, +} + +// SetToDefault implements river.Defaulter. +func (args *Arguments) SetToDefault() { + *args = DefaultArguments +} + +// Convert implements exporter.Arguments. +func (args Arguments) Convert() (otelcomponent.Config, error) { + return &debugexporter.Config{ + Verbosity: args.Verbosity, + SamplingInitial: args.SamplingInitial, + SamplingThereafter: args.SamplingInitial, + }, nil +} + +// Extensions implements exporter.Arguments. +func (args Arguments) Extensions() map[otelcomponent.ID]otelextension.Extension { + return nil +} + +// Exporters implements exporter.Arguments. +func (args Arguments) Exporters() map[otelcomponent.DataType]map[otelcomponent.ID]otelcomponent.Component { + return nil +} + +// DebugMetricsConfig implements receiver.Arguments. +func (args Arguments) DebugMetricsConfig() otelcol.DebugMetricsArguments { + return args.DebugMetrics +} diff --git a/go.mod b/go.mod index 81e677a27a6c..59c360991779 100644 --- a/go.mod +++ b/go.mod @@ -155,7 +155,7 @@ require ( github.com/prometheus/statsd_exporter v0.22.8 github.com/richardartoul/molecule v1.0.1-0.20221107223329-32cfee06a052 github.com/rs/cors v1.10.1 - github.com/shirou/gopsutil/v3 v3.23.9 + github.com/shirou/gopsutil/v3 v3.23.10 github.com/sijms/go-ora/v2 v2.7.6 github.com/sirupsen/logrus v1.9.3 github.com/spaolacci/murmur3 v1.1.0 @@ -170,39 +170,39 @@ require ( github.com/wk8/go-ordered-map v0.2.0 github.com/xdg-go/scram v1.1.2 github.com/zeebo/xxh3 v1.0.2 - go.opentelemetry.io/collector v0.87.0 - go.opentelemetry.io/collector/component v0.87.0 + go.opentelemetry.io/collector v0.89.0 + go.opentelemetry.io/collector/component v0.89.0 go.opentelemetry.io/collector/config/configauth v0.87.0 go.opentelemetry.io/collector/config/configcompression v0.87.0 go.opentelemetry.io/collector/config/configgrpc v0.87.0 go.opentelemetry.io/collector/config/confighttp v0.87.0 go.opentelemetry.io/collector/config/confignet v0.87.0 go.opentelemetry.io/collector/config/configopaque v0.87.0 - go.opentelemetry.io/collector/config/configtelemetry v0.87.0 + go.opentelemetry.io/collector/config/configtelemetry v0.89.0 go.opentelemetry.io/collector/config/configtls v0.87.0 - go.opentelemetry.io/collector/confmap v0.87.0 - go.opentelemetry.io/collector/connector v0.87.0 - go.opentelemetry.io/collector/consumer v0.87.0 - go.opentelemetry.io/collector/exporter v0.87.0 + go.opentelemetry.io/collector/confmap v0.89.0 + go.opentelemetry.io/collector/connector v0.89.0 + go.opentelemetry.io/collector/consumer v0.89.0 + go.opentelemetry.io/collector/exporter v0.89.0 go.opentelemetry.io/collector/exporter/loggingexporter v0.87.0 go.opentelemetry.io/collector/exporter/otlpexporter v0.87.0 go.opentelemetry.io/collector/exporter/otlphttpexporter v0.87.0 - go.opentelemetry.io/collector/extension v0.87.0 + go.opentelemetry.io/collector/extension v0.89.0 go.opentelemetry.io/collector/extension/auth v0.87.0 - go.opentelemetry.io/collector/featuregate v1.0.0-rcv0016 + go.opentelemetry.io/collector/featuregate v1.0.0-rcv0018 go.opentelemetry.io/collector/otelcol v0.87.0 - go.opentelemetry.io/collector/pdata v1.0.0-rcv0016 - go.opentelemetry.io/collector/processor v0.87.0 + go.opentelemetry.io/collector/pdata v1.0.0-rcv0018 + go.opentelemetry.io/collector/processor v0.89.0 go.opentelemetry.io/collector/processor/batchprocessor v0.87.0 go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.87.0 - go.opentelemetry.io/collector/receiver v0.87.0 + go.opentelemetry.io/collector/receiver v0.89.0 go.opentelemetry.io/collector/receiver/otlpreceiver v0.87.0 go.opentelemetry.io/collector/semconv v0.87.0 - go.opentelemetry.io/collector/service v0.87.0 + go.opentelemetry.io/collector/service v0.89.0 go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux v0.45.0 go.opentelemetry.io/otel v1.21.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 - go.opentelemetry.io/otel/exporters/prometheus v0.42.0 + go.opentelemetry.io/otel/exporters/prometheus v0.43.0 go.opentelemetry.io/otel/metric v1.21.0 go.opentelemetry.io/otel/sdk v1.21.0 go.opentelemetry.io/otel/sdk/metric v1.20.0 @@ -614,6 +614,7 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor v0.87.0 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.87.0 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver v0.87.0 + go.opentelemetry.io/collector/exporter/debugexporter v0.89.0 go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v0.42.0 golang.org/x/crypto/x509roots/fallback v0.0.0-20240208163226-62c9f1799c91 k8s.io/apimachinery v0.28.3 @@ -649,6 +650,7 @@ require ( github.com/google/gnostic-models v0.6.8 // indirect github.com/grafana/jfr-parser v0.8.0 // indirect github.com/grafana/jsonparser v0.0.0-20240209175146-098958973a2d // indirect + github.com/hashicorp/go-version v1.6.0 // indirect github.com/hetznercloud/hcloud-go/v2 v2.4.0 // indirect github.com/influxdata/tdigest v0.0.2-0.20210216194612-fc98d27c9e8b // indirect github.com/julienschmidt/httprouter v1.3.0 // indirect diff --git a/go.sum b/go.sum index 95dd6c93ba9c..bcf5b295bbb3 100644 --- a/go.sum +++ b/go.sum @@ -2079,8 +2079,8 @@ github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shirou/gopsutil v0.0.0-20181107111621-48177ef5f880/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v2.20.9+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shirou/gopsutil/v3 v3.23.9 h1:ZI5bWVeu2ep4/DIxB4U9okeYJ7zp/QLTO4auRb/ty/E= -github.com/shirou/gopsutil/v3 v3.23.9/go.mod h1:x/NWSb71eMcjFIO0vhyGW5nZ7oSIgVjrCnADckb85GA= +github.com/shirou/gopsutil/v3 v3.23.10 h1:/N42opWlYzegYaVkWejXWJpbzKv2JDy3mrgGzKsh9hM= +github.com/shirou/gopsutil/v3 v3.23.10/go.mod h1:JIE26kpucQi+innVlAUnIEOSBhBUkirr5b44yr55+WE= github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= @@ -2343,10 +2343,10 @@ go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/collector v0.87.0 h1:160HewHp+/wzr62BzWjQgIvdTtzpaYTlCnGVb8DYnM0= -go.opentelemetry.io/collector v0.87.0/go.mod h1:VsAXXIK0D1na+Ysoy1/GIx0GgkH8vQqA6zwosddFz7A= -go.opentelemetry.io/collector/component v0.87.0 h1:Q+lwM5WAa2x4a5lgyaF6SjFBpIij5gyjsoiv9KFG36A= -go.opentelemetry.io/collector/component v0.87.0/go.mod h1:LsfDQRkwJRHOSHNnM1/pdi/6EQNj41WpIxpZRqSdI0E= +go.opentelemetry.io/collector v0.89.0 h1:lzpfD9NTHh+1M+qzcoYUH+i2rOgFSox3bGQFUI5BPJg= +go.opentelemetry.io/collector v0.89.0/go.mod h1:UZUtmQ3kai0CLPWvPmHKpmwqqEoo50n1bwzYYhXX0eA= +go.opentelemetry.io/collector/component v0.89.0 h1:PoQJX86BpaSZhzx0deQXHh3QMuW6XKVmolSdTKE506c= +go.opentelemetry.io/collector/component v0.89.0/go.mod h1:ZZncnMVaNs++JIbAMiemUIWLZrZ3PMEzI3S3K8pnkws= go.opentelemetry.io/collector/config/configauth v0.87.0 h1:FufZLHvJ+VcAM2xi404TpuYnpO1Rmeq7XtHleQLavrs= go.opentelemetry.io/collector/config/configauth v0.87.0/go.mod h1:xT8mIo1b57j0znSOssEFaJtE3rGw/kTZZucP5lEw6OU= go.opentelemetry.io/collector/config/configcompression v0.87.0 h1:hWRT47RJbjbowDGQMXQO/dt/pzyYjMcf+rroW8b8fws= @@ -2359,44 +2359,46 @@ go.opentelemetry.io/collector/config/confignet v0.87.0 h1:ULV44732QN0wTCtSIdYG04 go.opentelemetry.io/collector/config/confignet v0.87.0/go.mod h1:cpO8JYWGONaViOygKVw+Hd2UoBcn2cUiyi0WWeFTwJY= go.opentelemetry.io/collector/config/configopaque v0.87.0 h1:+qqJG1oEzX4+/YNbgeaXW9YM0BPWSj5XCi5y2zZLhDY= go.opentelemetry.io/collector/config/configopaque v0.87.0/go.mod h1:TPCHaU+QXiEV+JXbgyr6mSErTI9chwQyasDVMdJr3eY= -go.opentelemetry.io/collector/config/configtelemetry v0.87.0 h1:xUqayM9b41OvXkjU3p8RkUr8hUrCjfDUmO+oKhRNSwc= -go.opentelemetry.io/collector/config/configtelemetry v0.87.0/go.mod h1:+LAXM5WFMW/UbTlAuSs6L/W72WC+q8TBJt/6z39FPOU= +go.opentelemetry.io/collector/config/configtelemetry v0.89.0 h1:NtRknYDfMgP1r8mnByo6qQQK8IBw/lF9Qke5f7VhGZ0= +go.opentelemetry.io/collector/config/configtelemetry v0.89.0/go.mod h1:+LAXM5WFMW/UbTlAuSs6L/W72WC+q8TBJt/6z39FPOU= go.opentelemetry.io/collector/config/configtls v0.87.0 h1:EXa9Plr74+r9t2/59dTyjR3y53zqwigHN0dQsI8VGiQ= go.opentelemetry.io/collector/config/configtls v0.87.0/go.mod h1:3UoeynehS/NNhg1Qbt3xQdgPyrkWnjBRLUG2Gw7BFFc= go.opentelemetry.io/collector/config/internal v0.87.0 h1:wffyWbpanr2HFQaPPp5bG62KqJYlw5EdPxwR0iG+Lbo= go.opentelemetry.io/collector/config/internal v0.87.0/go.mod h1:42VsQ/1kP2qnvzjNi+dfNP+KyCFRADejyrJ8m2GVL3M= -go.opentelemetry.io/collector/confmap v0.87.0 h1:LFnyDKIOMtlJm5EsdcFN2t0rcU/QLbS9QEs/awM2HOA= -go.opentelemetry.io/collector/confmap v0.87.0/go.mod h1:inqYRP70+bMrUwGGnuhcWyyufxyU3VQT6rl3/EX0f+g= -go.opentelemetry.io/collector/connector v0.87.0 h1:Y00shHpxBSxliE/liJex2JMdYpJxbakfCUbaXe9eVMU= -go.opentelemetry.io/collector/connector v0.87.0/go.mod h1:qk+c3IeAdRkpUjXLh3PqAnC8BkKuMF7EhA5GpGNu7AI= -go.opentelemetry.io/collector/consumer v0.87.0 h1:oR5XKZoVF/hwz0FnrYPaHcbbQazHifMsxpENMR7ivvo= -go.opentelemetry.io/collector/consumer v0.87.0/go.mod h1:lui5rg1byAT7QPbCY733StCDc/TPxS3hVNXKoVQ3LsI= -go.opentelemetry.io/collector/exporter v0.87.0 h1:DZ0QT2yp1qACmHMxs6W2ho5RPqdevCx9R/LFCxnxi9w= -go.opentelemetry.io/collector/exporter v0.87.0/go.mod h1:SGobdCR0xwQElJT2Sbofo7BprMlV8XeXdsNP9fsNaKY= +go.opentelemetry.io/collector/confmap v0.89.0 h1:N5Vg1+FXEFBHHlGIPg4OSlM9uTHjCI7RlWWrKjtOzWQ= +go.opentelemetry.io/collector/confmap v0.89.0/go.mod h1:D8FMPvuihtVxwXaz/qp5q9X2lq9l97QyjfsdZD1spmc= +go.opentelemetry.io/collector/connector v0.89.0 h1:2v7RgaLrlGmvHV1BjG133MswZ2BhH77vTHOLa4/Tqm0= +go.opentelemetry.io/collector/connector v0.89.0/go.mod h1:z82Yw0wZarpva9byeqByb3+eZSZ35DMdNRkjFgMm0S0= +go.opentelemetry.io/collector/consumer v0.89.0 h1:MteKhkudX2L1ylbtdpSazO8SwyHSxl6fUEElc0rRLDQ= +go.opentelemetry.io/collector/consumer v0.89.0/go.mod h1:aOaoi6R0qVvfHu0pEPCzSE74gIPNJoCQM8Ml4Bc9NHE= +go.opentelemetry.io/collector/exporter v0.89.0 h1:8sYpJdKDQ2RuYOPKDsMz/lMJqp4WEWZgfJzyn9IgOag= +go.opentelemetry.io/collector/exporter v0.89.0/go.mod h1:zR8PFXMHlG0qPIEdRPNaefxDNj4UVP47uJ4vbHs+YME= +go.opentelemetry.io/collector/exporter/debugexporter v0.89.0 h1:MQUEX4OWszJQqQMqtYERiiw02Ta9QMWPe/hHWoD4YBU= +go.opentelemetry.io/collector/exporter/debugexporter v0.89.0/go.mod h1:eLoVrKOjgPvAmg0XJuellJ03zEpEol26l8i48Rhv53Q= go.opentelemetry.io/collector/exporter/loggingexporter v0.87.0 h1:F/WkglGgCSHOFYjafYEAwD/qGpZ5HpawLMWu/Jcf0SE= go.opentelemetry.io/collector/exporter/loggingexporter v0.87.0/go.mod h1:rYi0mKzgRH6xwsrYN9gb+WBccfoP1SpJ9U0xklrhV7g= go.opentelemetry.io/collector/exporter/otlpexporter v0.87.0 h1:1seSC+OX1QnbpED0Kuo1DbWQSER+vy88yp4zxBubY4A= go.opentelemetry.io/collector/exporter/otlpexporter v0.87.0/go.mod h1:Q4aS69GcAdcJLssnEd8ddt2rX97s/CkW/n1DdgdIaHQ= go.opentelemetry.io/collector/exporter/otlphttpexporter v0.87.0 h1:EqexJl7mzozDw4KY9mzR14uij0QlB9zIg8CfNGJYNt0= go.opentelemetry.io/collector/exporter/otlphttpexporter v0.87.0/go.mod h1:uwNO6qMa82a0EeokQx3YEiMl+R8HJulaDpUSS6T3pkg= -go.opentelemetry.io/collector/extension v0.87.0 h1:EMIaEequ5rjWzoid6vNImjQGVMfzbME+8JSa5XACYKs= -go.opentelemetry.io/collector/extension v0.87.0/go.mod h1:D3srNZC99QVTAdLNUVuqfmmgJge4sQHDrnt5XWscvxI= +go.opentelemetry.io/collector/extension v0.89.0 h1:iiaWIPPFqP4T0FSgl6+D1xRUhVnhsk88uk2BxCFqt7E= +go.opentelemetry.io/collector/extension v0.89.0/go.mod h1:tBh5wD4AZ3xFO6M1CjkEEx2urexTqcAcgi9cJSPME3E= go.opentelemetry.io/collector/extension/auth v0.87.0 h1:na1OumQSd5l+JvUiMr3oaiW6fuiDr7mEnydwQwmE+nk= go.opentelemetry.io/collector/extension/auth v0.87.0/go.mod h1:b7T9VefuK1GzSp5z1yjbkAvTxpWvflUmYoawTcGGuOs= go.opentelemetry.io/collector/extension/zpagesextension v0.87.0 h1:vSaCojdWMq34LDw2qR6To0PkSe4p+1BtP2Xr37PHH7w= go.opentelemetry.io/collector/extension/zpagesextension v0.87.0/go.mod h1:aXIFi7aIGD2uQCJPCF8uRSPJEK0+jjiZfvOehNGA1ZU= -go.opentelemetry.io/collector/featuregate v1.0.0-rcv0016 h1:/6N9990tbjotvXgrXpV5AbaFiyxTdFEXDypGBHVDSQM= -go.opentelemetry.io/collector/featuregate v1.0.0-rcv0016/go.mod h1:fLmJMf1AoHttkF8p5oJAc4o5ZpHu8yO5XYJ7gbLCLzo= -go.opentelemetry.io/collector/pdata v1.0.0-rcv0016 h1:qCPXSQCoD3qeWFb1RuIks8fw9Atxpk78bmtVdi15KhE= -go.opentelemetry.io/collector/pdata v1.0.0-rcv0016/go.mod h1:OdN0alYOlYhHXu6BDlGehrZWgtBuiDsz/rlNeJeXiNg= -go.opentelemetry.io/collector/processor v0.87.0 h1:aUGtRyeQk0WgQwp2rZBvJ1j+6+WJO8XMb1kjtanIWo8= -go.opentelemetry.io/collector/processor v0.87.0/go.mod h1:FHqpqdm/uyjjhNQxXJBhvQDIwjnP01EW9M6t0xVaRR4= +go.opentelemetry.io/collector/featuregate v1.0.0-rcv0018 h1:iK4muX3KIMqKk0xwKcRzu4ravgCtUdzsvuxxdz6A27g= +go.opentelemetry.io/collector/featuregate v1.0.0-rcv0018/go.mod h1:xGbRuw+GbutRtVVSEy3YR2yuOlEyiUMhN2M9DJljgqY= +go.opentelemetry.io/collector/pdata v1.0.0-rcv0018 h1:a2IHOZKphRzPagcvOHQHHUE0DlITFSKlIBwaWhPZpl4= +go.opentelemetry.io/collector/pdata v1.0.0-rcv0018/go.mod h1:oNIcTRyEJYIfMcRYyyh5lquDU0Vl+ktTL6ka+p+dYvg= +go.opentelemetry.io/collector/processor v0.89.0 h1:ypMnoOqBYbXgbDnAm9/Cb4uN3kxvmI05Vf6o4u/riBU= +go.opentelemetry.io/collector/processor v0.89.0/go.mod h1:HzMQ2VbxaECk7Oy1mHtug4qsl4acAW4XP1hpTgQKv84= go.opentelemetry.io/collector/processor/batchprocessor v0.87.0 h1:/a2yjC8XMg1j/9hnpDbxTKbG/AyWac2xsQSx0PmFz1M= go.opentelemetry.io/collector/processor/batchprocessor v0.87.0/go.mod h1:uY8Lu7zFtNZC39ylu8bphgqO0c3VIqVdegKxXlHo9Po= go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.87.0 h1:pWR4fPyKOBo0YWi745pai6ae7jFdlRvRiEg7VmtpGNw= go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.87.0/go.mod h1:Id8f4KVl5p5Uzn7RlfFwufdaiINQTKILcTCLQFsSH6c= -go.opentelemetry.io/collector/receiver v0.87.0 h1:4HpA5Rxb1jcMywCB8y5aNTXiqSt3n7oaFLfQbAkSaWM= -go.opentelemetry.io/collector/receiver v0.87.0/go.mod h1:uApnlS81KGGfQJrzbCdBZWsB5DQJgcPTsYlb9CFdE3s= +go.opentelemetry.io/collector/receiver v0.89.0 h1:wC/FB8e2Ej06jjNW2OiuZoyiSyB8TQNIzYyPlh9oRqI= +go.opentelemetry.io/collector/receiver v0.89.0/go.mod h1:Rk7Bkz45fVdrcJaVDsPTnHa97ZfSs1ULO76LXc4kLN0= go.opentelemetry.io/collector/receiver/otlpreceiver v0.87.0 h1:iXO30EKZwEP1TEuLlQjxVaeVeffDkdJqz9DuqjzME9c= go.opentelemetry.io/collector/receiver/otlpreceiver v0.87.0/go.mod h1:1IE82wJuyGW0z0BeJ3A0SoPxsPlqf9aefCycbtuxUO0= go.opentelemetry.io/collector/semconv v0.87.0 h1:BsG1jdLLRCBRlvUujk4QA86af7r/ZXnizczQpEs/gg8= @@ -2427,8 +2429,8 @@ go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 h1:3d+S2 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0/go.mod h1:0+KuTDyKL4gjKCF75pHOX4wuzYDUZYfAQdSu43o+Z2I= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 h1:IeMeyr1aBvBiPVYihXIaeIZba6b8E1bYp7lbdxK8CQg= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0/go.mod h1:oVdCUtjq9MK9BlS7TtucsQwUcXcymNiEDjgDD2jMtZU= -go.opentelemetry.io/otel/exporters/prometheus v0.42.0 h1:jwV9iQdvp38fxXi8ZC+lNpxjK16MRcZlpDYvbuO1FiA= -go.opentelemetry.io/otel/exporters/prometheus v0.42.0/go.mod h1:f3bYiqNqhoPxkvI2LrXqQVC546K7BuRDL/kKuxkujhA= +go.opentelemetry.io/otel/exporters/prometheus v0.43.0 h1:Skkl6akzvdWweXX6LLAY29tyFSO6hWZ26uDbVGTDXe8= +go.opentelemetry.io/otel/exporters/prometheus v0.43.0/go.mod h1:nZStMoc1H/YJpRjSx9IEX4abBMekORTLQcTUT1CgLkg= go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.42.0 h1:4jJuoeOo9W6hZnz+r046fyoH5kykZPRvKfUXJVfMpB0= go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.42.0/go.mod h1:/MtYTE1SfC2QIcE0bDot6fIX+h+WvXjgTqgn9P0LNPE= go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.19.0 h1:Nw7Dv4lwvGrI68+wULbcq7su9K2cebeCUrDjVrUJHxM= @@ -2797,7 +2799,7 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= From cfafe7d922d3e0e1624ce2a35ec1ea4037c686c0 Mon Sep 17 00:00:00 2001 From: Barun Das Date: Mon, 27 Nov 2023 17:43:16 -0500 Subject: [PATCH 02/21] updated changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 183490b615e3..d4a686658375 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -199,6 +199,8 @@ v0.39.0 (2024-01-09) ### Enhancements +- Added `otelcol.exporter.debug` component based on `go.opentelemetry.io/collector/exporter/debugexporter`. (@BarunKGP) + - Flow Windows service: Support environment variables. (@jkroepke) - Allow disabling collection of root Cgroup stats in From bb31feb403f21129106d7923d362ad5fb6e6c13f Mon Sep 17 00:00:00 2001 From: Barun Das Date: Tue, 28 Nov 2023 21:10:09 -0500 Subject: [PATCH 03/21] revert dependency versions --- go.mod | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/go.mod b/go.mod index 59c360991779..6c3aff363ccc 100644 --- a/go.mod +++ b/go.mod @@ -155,7 +155,7 @@ require ( github.com/prometheus/statsd_exporter v0.22.8 github.com/richardartoul/molecule v1.0.1-0.20221107223329-32cfee06a052 github.com/rs/cors v1.10.1 - github.com/shirou/gopsutil/v3 v3.23.10 + github.com/shirou/gopsutil/v3 v3.23.9 github.com/sijms/go-ora/v2 v2.7.6 github.com/sirupsen/logrus v1.9.3 github.com/spaolacci/murmur3 v1.1.0 @@ -170,42 +170,42 @@ require ( github.com/wk8/go-ordered-map v0.2.0 github.com/xdg-go/scram v1.1.2 github.com/zeebo/xxh3 v1.0.2 - go.opentelemetry.io/collector v0.89.0 - go.opentelemetry.io/collector/component v0.89.0 + go.opentelemetry.io/collector v0.87.0 + go.opentelemetry.io/collector/component v0.87.0 go.opentelemetry.io/collector/config/configauth v0.87.0 go.opentelemetry.io/collector/config/configcompression v0.87.0 go.opentelemetry.io/collector/config/configgrpc v0.87.0 go.opentelemetry.io/collector/config/confighttp v0.87.0 go.opentelemetry.io/collector/config/confignet v0.87.0 go.opentelemetry.io/collector/config/configopaque v0.87.0 - go.opentelemetry.io/collector/config/configtelemetry v0.89.0 + go.opentelemetry.io/collector/config/configtelemetry v0.87.0 go.opentelemetry.io/collector/config/configtls v0.87.0 - go.opentelemetry.io/collector/confmap v0.89.0 - go.opentelemetry.io/collector/connector v0.89.0 - go.opentelemetry.io/collector/consumer v0.89.0 - go.opentelemetry.io/collector/exporter v0.89.0 + go.opentelemetry.io/collector/confmap v0.87.0 + go.opentelemetry.io/collector/connector v0.87.0 + go.opentelemetry.io/collector/consumer v0.87.0 + go.opentelemetry.io/collector/exporter v0.87.0 go.opentelemetry.io/collector/exporter/loggingexporter v0.87.0 go.opentelemetry.io/collector/exporter/otlpexporter v0.87.0 go.opentelemetry.io/collector/exporter/otlphttpexporter v0.87.0 - go.opentelemetry.io/collector/extension v0.89.0 + go.opentelemetry.io/collector/extension v0.87.0 go.opentelemetry.io/collector/extension/auth v0.87.0 - go.opentelemetry.io/collector/featuregate v1.0.0-rcv0018 + go.opentelemetry.io/collector/featuregate v1.0.0-rcv0016 go.opentelemetry.io/collector/otelcol v0.87.0 - go.opentelemetry.io/collector/pdata v1.0.0-rcv0018 - go.opentelemetry.io/collector/processor v0.89.0 + go.opentelemetry.io/collector/pdata v1.0.0-rcv0016 + go.opentelemetry.io/collector/processor v0.87.0 go.opentelemetry.io/collector/processor/batchprocessor v0.87.0 go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.87.0 - go.opentelemetry.io/collector/receiver v0.89.0 + go.opentelemetry.io/collector/receiver v0.87.0 go.opentelemetry.io/collector/receiver/otlpreceiver v0.87.0 go.opentelemetry.io/collector/semconv v0.87.0 - go.opentelemetry.io/collector/service v0.89.0 + go.opentelemetry.io/collector/service v0.87.0 go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux v0.45.0 go.opentelemetry.io/otel v1.21.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 - go.opentelemetry.io/otel/exporters/prometheus v0.43.0 + go.opentelemetry.io/otel/exporters/prometheus v0.42.0 go.opentelemetry.io/otel/metric v1.21.0 go.opentelemetry.io/otel/sdk v1.21.0 - go.opentelemetry.io/otel/sdk/metric v1.20.0 + go.opentelemetry.io/otel/sdk/metric v1.19.0 go.opentelemetry.io/otel/trace v1.21.0 go.opentelemetry.io/proto/otlp v1.0.0 go.uber.org/atomic v1.11.0 From 712d15d2f942f78caaa79a35d16d2e8c26ae6916 Mon Sep 17 00:00:00 2001 From: Barun Das Date: Sat, 2 Dec 2023 18:22:22 -0500 Subject: [PATCH 04/21] verbosity struct --- component/otelcol/exporter/debug/debug.go | 31 +++++++++++++++++------ 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/component/otelcol/exporter/debug/debug.go b/component/otelcol/exporter/debug/debug.go index 973e16f91d88..3d4be8f0448c 100644 --- a/component/otelcol/exporter/debug/debug.go +++ b/component/otelcol/exporter/debug/debug.go @@ -1,6 +1,8 @@ package debug import ( + "fmt" + "github.com/grafana/agent/component" "github.com/grafana/agent/component/otelcol" "github.com/grafana/agent/component/otelcol/exporter" @@ -23,14 +25,32 @@ func init() { }) } +type Verbosity struct { + Type string +} + +func (v Verbosity) convert() configtelemetry.Level { + if (v.Type == "basic") { + return configtelemetry.LevelBasic + } else if (v.Type == "normal") { + return configtelemetry.LevelNormal + } else if (v.Tyep == "detailed") { + return configtelemetry.LevelDetailed + } else { + return fmt.Errorf("invalid type in verbosity %v", v) + } + +} + // Arguments configures the otelcol.exporter.debug component. type Arguments struct { - Verbosity configtelemetry.Level `river:"verbosity,attr,optional"` + // Verbosity configtelemetry.Level `river:"verbosity,attr,optional"` + Verbosity string `river:"verbosity, attr, optional"` SamplingInitial int `river:"sampling_initial,attr,optional"` SamplingThereafter int `river:"sampling_thereafter,attr,optional"` - // DebugMetrics configures component internal metrics. Optional. - DebugMetrics otelcol.DebugMetricsArguments `river:"debug_metrics,block,optional"` + // DebugMetrics configures component internal metrics. Optional. + _ DebugMetrics otelcol.DebugMetricsArguments `river: ";"` } var _ exporter.Arguments = Arguments{} @@ -65,8 +85,3 @@ func (args Arguments) Extensions() map[otelcomponent.ID]otelextension.Extension func (args Arguments) Exporters() map[otelcomponent.DataType]map[otelcomponent.ID]otelcomponent.Component { return nil } - -// DebugMetricsConfig implements receiver.Arguments. -func (args Arguments) DebugMetricsConfig() otelcol.DebugMetricsArguments { - return args.DebugMetrics -} From d8047529a0d96828a49e1a1ee8dbe59eddbf4f46 Mon Sep 17 00:00:00 2001 From: "Das, Barun" Date: Sat, 2 Dec 2023 19:08:50 -0500 Subject: [PATCH 05/21] wrapper over debugexporter verbosity --- component/otelcol/exporter/debug/debug.go | 72 +++++++++++++++-------- 1 file changed, 48 insertions(+), 24 deletions(-) diff --git a/component/otelcol/exporter/debug/debug.go b/component/otelcol/exporter/debug/debug.go index 3d4be8f0448c..6040da13959b 100644 --- a/component/otelcol/exporter/debug/debug.go +++ b/component/otelcol/exporter/debug/debug.go @@ -25,39 +25,52 @@ func init() { }) } -type Verbosity struct { - Type string -} - -func (v Verbosity) convert() configtelemetry.Level { - if (v.Type == "basic") { - return configtelemetry.LevelBasic - } else if (v.Type == "normal") { - return configtelemetry.LevelNormal - } else if (v.Tyep == "detailed") { - return configtelemetry.LevelDetailed - } else { - return fmt.Errorf("invalid type in verbosity %v", v) - } +// Arguments configures the otelcol.exporter.debug component. +type exporterArguments struct { + // Verbosity configtelemetry.Level `river:"verbosity,attr,optional"` + Verbosity configtelemetry.Level `river:"verbosity, attr, optional"` + SamplingInitial int `river:"sampling_initial,attr,optional"` + SamplingThereafter int `river:"sampling_thereafter,attr,optional"` + // DebugMetrics configures component internal metrics. Optional. + DebugMetrics otelcol.DebugMetricsArguments `river:"debug_metrics,block,optional"` } -// Arguments configures the otelcol.exporter.debug component. type Arguments struct { // Verbosity configtelemetry.Level `river:"verbosity,attr,optional"` - Verbosity string `river:"verbosity, attr, optional"` - SamplingInitial int `river:"sampling_initial,attr,optional"` - SamplingThereafter int `river:"sampling_thereafter,attr,optional"` + Verbosity string `river:"verbosity, attr, optional"` + SamplingInitial int `river:"sampling_initial,attr,optional"` + SamplingThereafter int `river:"sampling_thereafter,attr,optional"` - // DebugMetrics configures component internal metrics. Optional. - _ DebugMetrics otelcol.DebugMetricsArguments `river: ";"` + // DebugMetrics configures component internal metrics. Optional. + // DebugMetrics otelcol.DebugMetricsArguments `river:"debug_metrics,block,optional"` +} + +func (args Arguments) convertToExporter() (exporterArguments, error) { + const exporterVerbosity = map[string]configtelemetry.Level{ + "basic": configtelemetry.LevelBasic, + "normal": configtelemetry.LevelNormal, + "detailed": configtelemetry.LevelDetailed, + } + + if _, ok := exporterVerbosity[args.Verbosity]; !ok { + return exporterArguments{}, fmt.Errorf("Invalid verbosity in arguments %v", args) + } + + e := &exporterArguments{ + Verbosity: args.Verbosity, + SamplingInitial: args.SamplingInitial, + SamplingThereafter: args.SamplingThereafter, + } + + return *e, nil } var _ exporter.Arguments = Arguments{} // DefaultArguments holds default values for Arguments. var DefaultArguments = Arguments{ - Verbosity: configtelemetry.LevelBasic, + Verbosity: "basic", SamplingInitial: 2, SamplingThereafter: 500, } @@ -69,10 +82,15 @@ func (args *Arguments) SetToDefault() { // Convert implements exporter.Arguments. func (args Arguments) Convert() (otelcomponent.Config, error) { + exporterArgs, err := args.convertToExporter() + if err != nil { + return nil, fmt.Errorf("Error in conversion to config arguments, %v", err) + } + return &debugexporter.Config{ - Verbosity: args.Verbosity, - SamplingInitial: args.SamplingInitial, - SamplingThereafter: args.SamplingInitial, + Verbosity: exporterArgs.Verbosity, + SamplingInitial: exporterArgs.SamplingInitial, + SamplingThereafter: exporterArgs.SamplingInitial, }, nil } @@ -85,3 +103,9 @@ func (args Arguments) Extensions() map[otelcomponent.ID]otelextension.Extension func (args Arguments) Exporters() map[otelcomponent.DataType]map[otelcomponent.ID]otelcomponent.Component { return nil } + +// DebugMetricsConfig implements receiver.Arguments. +func (args Arguments) DebugMetricsConfig() otelcol.DebugMetricsArguments { + exporterArgs, _ := args.convertToExporter() + return exporterArgs.DebugMetrics +} From 68c7c31ec7957379ab89a0d783b1380a4ee3b935 Mon Sep 17 00:00:00 2001 From: "Das, Barun" Date: Sat, 2 Dec 2023 19:30:02 -0500 Subject: [PATCH 06/21] test debugexporter --- component/otelcol/exporter/debug/debug.go | 6 ++-- .../otelcol/exporter/debug/debug_test.go | 32 +++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 component/otelcol/exporter/debug/debug_test.go diff --git a/component/otelcol/exporter/debug/debug.go b/component/otelcol/exporter/debug/debug.go index 6040da13959b..11edbe6efc35 100644 --- a/component/otelcol/exporter/debug/debug.go +++ b/component/otelcol/exporter/debug/debug.go @@ -54,12 +54,12 @@ func (args Arguments) convertToExporter() (exporterArguments, error) { } if _, ok := exporterVerbosity[args.Verbosity]; !ok { - return exporterArguments{}, fmt.Errorf("Invalid verbosity in arguments %v", args) + return exporterArguments{}, fmt.Errorf("Invalid verbosity %q", args.Verbosity) } e := &exporterArguments{ - Verbosity: args.Verbosity, - SamplingInitial: args.SamplingInitial, + Verbosity: args.Verbosity, + SamplingInitial: args.SamplingInitial, SamplingThereafter: args.SamplingThereafter, } diff --git a/component/otelcol/exporter/debug/debug_test.go b/component/otelcol/exporter/debug/debug_test.go new file mode 100644 index 000000000000..90b08965733c --- /dev/null +++ b/component/otelcol/exporter/debug/debug_test.go @@ -0,0 +1,32 @@ +package debug_test + +import ( + "testing" + + "github.com/grafana/agent/component/otelcol/exporter/debug" + "github.com/stretchr/testify/require" +) + +func Test(t *testing.T) { + happyArgs := debug.Arguments{ + Verbosity: "detailed", + SamplingInitial: 5, + SamplingThereafter: 20, + } + // Check no errors on converting to exporter args + otelcomp, err := happyArgs.Convert() + require.NoError(t, err) + + // Check that exporter is created correctly + err = &otelcomp.Validate() + require.NoError(t, err, "error on creating debug exporter config") + + invalidArgs := debug.Arguments{ + Verbosity: "test", + SamplingInitial: 5, + SamplingThereafter: 20, + } + // Check error on converting invalid args + _, err = invalidArgs.Convert() + require.NotNil(t, err, "no error on invalid arguments") +} From 180f36ef34c40049f7e03aa8f4b1fa304dc1ce17 Mon Sep 17 00:00:00 2001 From: "Das, Barun" Date: Sat, 2 Dec 2023 20:02:59 -0500 Subject: [PATCH 07/21] improve debug exporter tests --- component/otelcol/exporter/debug/debug.go | 36 ++++++++++------ .../otelcol/exporter/debug/debug_test.go | 41 ++++++++++--------- 2 files changed, 45 insertions(+), 32 deletions(-) diff --git a/component/otelcol/exporter/debug/debug.go b/component/otelcol/exporter/debug/debug.go index 11edbe6efc35..b40e0283692b 100644 --- a/component/otelcol/exporter/debug/debug.go +++ b/component/otelcol/exporter/debug/debug.go @@ -47,22 +47,34 @@ type Arguments struct { } func (args Arguments) convertToExporter() (exporterArguments, error) { - const exporterVerbosity = map[string]configtelemetry.Level{ - "basic": configtelemetry.LevelBasic, - "normal": configtelemetry.LevelNormal, - "detailed": configtelemetry.LevelDetailed, - } - - if _, ok := exporterVerbosity[args.Verbosity]; !ok { - return exporterArguments{}, fmt.Errorf("Invalid verbosity %q", args.Verbosity) - } - + // const exporterVerbosity = map[string]configtelemetry.Level{ + // "basic": configtelemetry.LevelBasic, + // "normal": configtelemetry.LevelNormal, + // "detailed": configtelemetry.LevelDetailed, + // } e := &exporterArguments{ - Verbosity: args.Verbosity, SamplingInitial: args.SamplingInitial, SamplingThereafter: args.SamplingThereafter, } + switch args.Verbosity { + case "basic": + e.Verbosity = configtelemetry.LevelBasic + case "normal": + e.Verbosity = configtelemetry.LevelNormal + case "detailed": + e.Verbosity = configtelemetry.LevelDetailed + default: + // Invalid verbosity + // debugexporter only supports basic, normal and detailed levels + return exporterArguments{}, fmt.Errorf("invalid verbosity %q", args.Verbosity) + } + + // if _, ok := exporterVerbosity[args.Verbosity]; !ok { + // return exporterArguments{}, fmt.Errorf("Invalid verbosity %q", args.Verbosity) + // } + + return *e, nil } @@ -84,7 +96,7 @@ func (args *Arguments) SetToDefault() { func (args Arguments) Convert() (otelcomponent.Config, error) { exporterArgs, err := args.convertToExporter() if err != nil { - return nil, fmt.Errorf("Error in conversion to config arguments, %v", err) + return nil, fmt.Errorf("error in conversion to config arguments, %v", err) } return &debugexporter.Config{ diff --git a/component/otelcol/exporter/debug/debug_test.go b/component/otelcol/exporter/debug/debug_test.go index 90b08965733c..2bb5a9ad1cfb 100644 --- a/component/otelcol/exporter/debug/debug_test.go +++ b/component/otelcol/exporter/debug/debug_test.go @@ -5,28 +5,29 @@ import ( "github.com/grafana/agent/component/otelcol/exporter/debug" "github.com/stretchr/testify/require" + otelcomponent "go.opentelemetry.io/collector/component" ) func Test(t *testing.T) { - happyArgs := debug.Arguments{ - Verbosity: "detailed", - SamplingInitial: 5, - SamplingThereafter: 20, - } - // Check no errors on converting to exporter args - otelcomp, err := happyArgs.Convert() - require.NoError(t, err) - - // Check that exporter is created correctly - err = &otelcomp.Validate() - require.NoError(t, err, "error on creating debug exporter config") + happyArgs := debug.Arguments{ + Verbosity: "detailed", + SamplingInitial: 5, + SamplingThereafter: 20, + } + // Check no errors on converting to exporter args + otelconf, err := happyArgs.Convert() + require.NoError(t, err) - invalidArgs := debug.Arguments{ - Verbosity: "test", - SamplingInitial: 5, - SamplingThereafter: 20, - } - // Check error on converting invalid args - _, err = invalidArgs.Convert() - require.NotNil(t, err, "no error on invalid arguments") + // Check that exporter config is created correctly + err = otelcomponent.ValidateConfig(otelconf) + require.NoError(t, err, "error on creating debug exporter config") + + invalidArgs := debug.Arguments{ + Verbosity: "test", + SamplingInitial: 5, + SamplingThereafter: 20, + } + // Check error on converting invalid args + _, err = invalidArgs.Convert() + require.NotNil(t, err, "no error on invalid arguments") } From c69c7684b07c0d286ce58516cbd57cb35efb3dae Mon Sep 17 00:00:00 2001 From: "Das, Barun" Date: Sat, 2 Dec 2023 20:20:12 -0500 Subject: [PATCH 08/21] cleanup --- component/otelcol/exporter/debug/debug.go | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/component/otelcol/exporter/debug/debug.go b/component/otelcol/exporter/debug/debug.go index b40e0283692b..582935825135 100644 --- a/component/otelcol/exporter/debug/debug.go +++ b/component/otelcol/exporter/debug/debug.go @@ -27,7 +27,6 @@ func init() { // Arguments configures the otelcol.exporter.debug component. type exporterArguments struct { - // Verbosity configtelemetry.Level `river:"verbosity,attr,optional"` Verbosity configtelemetry.Level `river:"verbosity, attr, optional"` SamplingInitial int `river:"sampling_initial,attr,optional"` SamplingThereafter int `river:"sampling_thereafter,attr,optional"` @@ -37,21 +36,12 @@ type exporterArguments struct { } type Arguments struct { - // Verbosity configtelemetry.Level `river:"verbosity,attr,optional"` Verbosity string `river:"verbosity, attr, optional"` SamplingInitial int `river:"sampling_initial,attr,optional"` SamplingThereafter int `river:"sampling_thereafter,attr,optional"` - - // DebugMetrics configures component internal metrics. Optional. - // DebugMetrics otelcol.DebugMetricsArguments `river:"debug_metrics,block,optional"` } func (args Arguments) convertToExporter() (exporterArguments, error) { - // const exporterVerbosity = map[string]configtelemetry.Level{ - // "basic": configtelemetry.LevelBasic, - // "normal": configtelemetry.LevelNormal, - // "detailed": configtelemetry.LevelDetailed, - // } e := &exporterArguments{ SamplingInitial: args.SamplingInitial, SamplingThereafter: args.SamplingThereafter, @@ -70,11 +60,6 @@ func (args Arguments) convertToExporter() (exporterArguments, error) { return exporterArguments{}, fmt.Errorf("invalid verbosity %q", args.Verbosity) } - // if _, ok := exporterVerbosity[args.Verbosity]; !ok { - // return exporterArguments{}, fmt.Errorf("Invalid verbosity %q", args.Verbosity) - // } - - return *e, nil } From 11cead82a9f017444e35ef088ab1cdeca1ca6ca7 Mon Sep 17 00:00:00 2001 From: "Das, Barun" Date: Sun, 3 Dec 2023 19:07:59 -0500 Subject: [PATCH 09/21] refactoring --- component/otelcol/exporter/debug/debug.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/component/otelcol/exporter/debug/debug.go b/component/otelcol/exporter/debug/debug.go index 582935825135..4ec559d3709c 100644 --- a/component/otelcol/exporter/debug/debug.go +++ b/component/otelcol/exporter/debug/debug.go @@ -28,8 +28,8 @@ func init() { // Arguments configures the otelcol.exporter.debug component. type exporterArguments struct { Verbosity configtelemetry.Level `river:"verbosity, attr, optional"` - SamplingInitial int `river:"sampling_initial,attr,optional"` - SamplingThereafter int `river:"sampling_thereafter,attr,optional"` + SamplingInitial int `river:"sampling_initial,attr, optional"` + SamplingThereafter int `river:"sampling_thereafter,attr, optional"` // DebugMetrics configures component internal metrics. Optional. DebugMetrics otelcol.DebugMetricsArguments `river:"debug_metrics,block,optional"` @@ -37,8 +37,8 @@ type exporterArguments struct { type Arguments struct { Verbosity string `river:"verbosity, attr, optional"` - SamplingInitial int `river:"sampling_initial,attr,optional"` - SamplingThereafter int `river:"sampling_thereafter,attr,optional"` + SamplingInitial int `river:"sampling_initial,attr, optional"` + SamplingThereafter int `river:"sampling_thereafter,attr, optional"` } func (args Arguments) convertToExporter() (exporterArguments, error) { From de95b72d5bd0a386695e9b43e9c2db23c1e03538 Mon Sep 17 00:00:00 2001 From: Barun Das Date: Wed, 28 Feb 2024 19:59:53 -0500 Subject: [PATCH 10/21] fix merge conflicts --- go.mod | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 6c3aff363ccc..fe63768fd495 100644 --- a/go.mod +++ b/go.mod @@ -614,7 +614,7 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor v0.87.0 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.87.0 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver v0.87.0 - go.opentelemetry.io/collector/exporter/debugexporter v0.89.0 + go.opentelemetry.io/collector/exporter/debugexporter v0.87.0 go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v0.42.0 golang.org/x/crypto/x509roots/fallback v0.0.0-20240208163226-62c9f1799c91 k8s.io/apimachinery v0.28.3 @@ -648,7 +648,7 @@ require ( github.com/go-jose/go-jose/v3 v3.0.1 // indirect github.com/golang-jwt/jwt/v5 v5.0.0 // indirect github.com/google/gnostic-models v0.6.8 // indirect - github.com/grafana/jfr-parser v0.8.0 // indirect +github.com/grafana/jfr-parser v0.8.0 // indirect github.com/grafana/jsonparser v0.0.0-20240209175146-098958973a2d // indirect github.com/hashicorp/go-version v1.6.0 // indirect github.com/hetznercloud/hcloud-go/v2 v2.4.0 // indirect From 22425225fb46dd93ade13ecf255a1747b06a21bf Mon Sep 17 00:00:00 2001 From: "Das, Barun" Date: Mon, 4 Dec 2023 21:47:57 -0500 Subject: [PATCH 11/21] remove exporterArgs --- component/otelcol/exporter/debug/debug.go | 40 ++++++++--------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/component/otelcol/exporter/debug/debug.go b/component/otelcol/exporter/debug/debug.go index 4ec559d3709c..d6ee57a80657 100644 --- a/component/otelcol/exporter/debug/debug.go +++ b/component/otelcol/exporter/debug/debug.go @@ -25,42 +25,28 @@ func init() { }) } -// Arguments configures the otelcol.exporter.debug component. -type exporterArguments struct { - Verbosity configtelemetry.Level `river:"verbosity, attr, optional"` - SamplingInitial int `river:"sampling_initial,attr, optional"` - SamplingThereafter int `river:"sampling_thereafter,attr, optional"` - - // DebugMetrics configures component internal metrics. Optional. - DebugMetrics otelcol.DebugMetricsArguments `river:"debug_metrics,block,optional"` -} - type Arguments struct { Verbosity string `river:"verbosity, attr, optional"` SamplingInitial int `river:"sampling_initial,attr, optional"` SamplingThereafter int `river:"sampling_thereafter,attr, optional"` } -func (args Arguments) convertToExporter() (exporterArguments, error) { - e := &exporterArguments{ - SamplingInitial: args.SamplingInitial, - SamplingThereafter: args.SamplingThereafter, - } - +func (args Arguments) convertVerbosity() (configtelemetry.Level, error) { + var verbosity configtelemetry.Level switch args.Verbosity { case "basic": - e.Verbosity = configtelemetry.LevelBasic + verbosity = configtelemetry.LevelBasic case "normal": - e.Verbosity = configtelemetry.LevelNormal + verbosity = configtelemetry.LevelNormal case "detailed": - e.Verbosity = configtelemetry.LevelDetailed + verbosity = configtelemetry.LevelDetailed default: // Invalid verbosity // debugexporter only supports basic, normal and detailed levels - return exporterArguments{}, fmt.Errorf("invalid verbosity %q", args.Verbosity) + return verbosity, fmt.Errorf("invalid verbosity %q", args.Verbosity) } - return *e, nil + return verbosity, nil } var _ exporter.Arguments = Arguments{} @@ -79,15 +65,15 @@ func (args *Arguments) SetToDefault() { // Convert implements exporter.Arguments. func (args Arguments) Convert() (otelcomponent.Config, error) { - exporterArgs, err := args.convertToExporter() + verbosity, err := args.convertVerbosity() if err != nil { return nil, fmt.Errorf("error in conversion to config arguments, %v", err) } return &debugexporter.Config{ - Verbosity: exporterArgs.Verbosity, - SamplingInitial: exporterArgs.SamplingInitial, - SamplingThereafter: exporterArgs.SamplingInitial, + Verbosity: verbosity, + SamplingInitial: args.SamplingInitial, + SamplingThereafter: args.SamplingInitial, }, nil } @@ -103,6 +89,6 @@ func (args Arguments) Exporters() map[otelcomponent.DataType]map[otelcomponent.I // DebugMetricsConfig implements receiver.Arguments. func (args Arguments) DebugMetricsConfig() otelcol.DebugMetricsArguments { - exporterArgs, _ := args.convertToExporter() - return exporterArgs.DebugMetrics + var debugMetrics otelcol.DebugMetricsArguments + return debugMetrics } From f0f27b3bda98c6e2b2afc17d2ef38a1558547953 Mon Sep 17 00:00:00 2001 From: "Das, Barun" Date: Wed, 20 Dec 2023 08:36:07 +0530 Subject: [PATCH 12/21] reformat debug_test --- component/otelcol/exporter/debug/debug.go | 2 +- .../otelcol/exporter/debug/debug_test.go | 87 +++++++++++++++---- 2 files changed, 69 insertions(+), 20 deletions(-) diff --git a/component/otelcol/exporter/debug/debug.go b/component/otelcol/exporter/debug/debug.go index d6ee57a80657..07ac5bbe4e70 100644 --- a/component/otelcol/exporter/debug/debug.go +++ b/component/otelcol/exporter/debug/debug.go @@ -73,7 +73,7 @@ func (args Arguments) Convert() (otelcomponent.Config, error) { return &debugexporter.Config{ Verbosity: verbosity, SamplingInitial: args.SamplingInitial, - SamplingThereafter: args.SamplingInitial, + SamplingThereafter: args.SamplingThereafter, }, nil } diff --git a/component/otelcol/exporter/debug/debug_test.go b/component/otelcol/exporter/debug/debug_test.go index 2bb5a9ad1cfb..f5fef39ba466 100644 --- a/component/otelcol/exporter/debug/debug_test.go +++ b/component/otelcol/exporter/debug/debug_test.go @@ -4,30 +4,79 @@ import ( "testing" "github.com/grafana/agent/component/otelcol/exporter/debug" + "github.com/grafana/river" "github.com/stretchr/testify/require" otelcomponent "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/config/configtelemetry" + debugexporter "go.opentelemetry.io/collector/exporter/debugexporter" ) func Test(t *testing.T) { - happyArgs := debug.Arguments{ - Verbosity: "detailed", - SamplingInitial: 5, - SamplingThereafter: 20, + tests := []struct { + testName string + args string + expectedReturn otelcomponent.Config + errorMsg string + }{ + { + testName: "defaultConfig", + args: ` + verbosity = "basic" + sampling_initial = 1 + sampling_thereafter = 500 + `, + expectedReturn: debugexporter.Config{ + Verbosity: configtelemetry.LevelBasic, + SamplingInitial: 2, + SamplingThereafter: 500, + }, + }, + + { + testName: "validConfig", + args:` + verbosity: "detailed", + sampling_initial: 5, + sampling_thereafter: 20, + `, + expectedReturn: debugexporter.Config{ + Verbosity: configtelemetry.LevelDetailed, + SamplingInitial: 5, + SamplingThereafter: 20, + }, + }, + + { + testName: "invalidConfig", + args: ` + verbosity: "test", + sampling_initial: 5, + sampling_thereafter: 20, + `, + errorMsg: "error in conversion to config arguments", + }, } - // Check no errors on converting to exporter args - otelconf, err := happyArgs.Convert() - require.NoError(t, err) - - // Check that exporter config is created correctly - err = otelcomponent.ValidateConfig(otelconf) - require.NoError(t, err, "error on creating debug exporter config") - - invalidArgs := debug.Arguments{ - Verbosity: "test", - SamplingInitial: 5, - SamplingThereafter: 20, + + for _, tc := range tests { + t.Run(tc.testName, func(t *testing.T) { + var args debug.Arguments + err := river.Unmarshal([]byte(tc.args), &args) + if tc.errorMsg != "" { + require.ErrorContains(t, err, tc.errorMsg) + return + } + + require.NoError(t, err) + + actualPtr, err := args.Convert() + require.NoError(t, err) + + actual := actualPtr.(*otelcomponent.Config) + + require.NoError(t, otelcomponent.ValidateConfig(actual)) + + require.Equal(t, tc.expectedReturn, *actual) + }) } - // Check error on converting invalid args - _, err = invalidArgs.Convert() - require.NotNil(t, err, "no error on invalid arguments") + } From 29bb1099f843f78be2eb409f0c7a34e49646cf31 Mon Sep 17 00:00:00 2001 From: Barun Das Date: Wed, 28 Feb 2024 20:00:49 -0500 Subject: [PATCH 13/21] fix merge conflicts --- go.sum | 64 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/go.sum b/go.sum index bcf5b295bbb3..076f5fccd08a 100644 --- a/go.sum +++ b/go.sum @@ -2079,8 +2079,8 @@ github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shirou/gopsutil v0.0.0-20181107111621-48177ef5f880/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v2.20.9+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shirou/gopsutil/v3 v3.23.10 h1:/N42opWlYzegYaVkWejXWJpbzKv2JDy3mrgGzKsh9hM= -github.com/shirou/gopsutil/v3 v3.23.10/go.mod h1:JIE26kpucQi+innVlAUnIEOSBhBUkirr5b44yr55+WE= +github.com/shirou/gopsutil/v3 v3.23.9 h1:ZI5bWVeu2ep4/DIxB4U9okeYJ7zp/QLTO4auRb/ty/E= +github.com/shirou/gopsutil/v3 v3.23.9/go.mod h1:x/NWSb71eMcjFIO0vhyGW5nZ7oSIgVjrCnADckb85GA= github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= @@ -2343,10 +2343,10 @@ go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/collector v0.89.0 h1:lzpfD9NTHh+1M+qzcoYUH+i2rOgFSox3bGQFUI5BPJg= -go.opentelemetry.io/collector v0.89.0/go.mod h1:UZUtmQ3kai0CLPWvPmHKpmwqqEoo50n1bwzYYhXX0eA= -go.opentelemetry.io/collector/component v0.89.0 h1:PoQJX86BpaSZhzx0deQXHh3QMuW6XKVmolSdTKE506c= -go.opentelemetry.io/collector/component v0.89.0/go.mod h1:ZZncnMVaNs++JIbAMiemUIWLZrZ3PMEzI3S3K8pnkws= +go.opentelemetry.io/collector v0.87.0 h1:160HewHp+/wzr62BzWjQgIvdTtzpaYTlCnGVb8DYnM0= +go.opentelemetry.io/collector v0.87.0/go.mod h1:VsAXXIK0D1na+Ysoy1/GIx0GgkH8vQqA6zwosddFz7A= +go.opentelemetry.io/collector/component v0.87.0 h1:Q+lwM5WAa2x4a5lgyaF6SjFBpIij5gyjsoiv9KFG36A= +go.opentelemetry.io/collector/component v0.87.0/go.mod h1:LsfDQRkwJRHOSHNnM1/pdi/6EQNj41WpIxpZRqSdI0E= go.opentelemetry.io/collector/config/configauth v0.87.0 h1:FufZLHvJ+VcAM2xi404TpuYnpO1Rmeq7XtHleQLavrs= go.opentelemetry.io/collector/config/configauth v0.87.0/go.mod h1:xT8mIo1b57j0znSOssEFaJtE3rGw/kTZZucP5lEw6OU= go.opentelemetry.io/collector/config/configcompression v0.87.0 h1:hWRT47RJbjbowDGQMXQO/dt/pzyYjMcf+rroW8b8fws= @@ -2359,46 +2359,46 @@ go.opentelemetry.io/collector/config/confignet v0.87.0 h1:ULV44732QN0wTCtSIdYG04 go.opentelemetry.io/collector/config/confignet v0.87.0/go.mod h1:cpO8JYWGONaViOygKVw+Hd2UoBcn2cUiyi0WWeFTwJY= go.opentelemetry.io/collector/config/configopaque v0.87.0 h1:+qqJG1oEzX4+/YNbgeaXW9YM0BPWSj5XCi5y2zZLhDY= go.opentelemetry.io/collector/config/configopaque v0.87.0/go.mod h1:TPCHaU+QXiEV+JXbgyr6mSErTI9chwQyasDVMdJr3eY= -go.opentelemetry.io/collector/config/configtelemetry v0.89.0 h1:NtRknYDfMgP1r8mnByo6qQQK8IBw/lF9Qke5f7VhGZ0= -go.opentelemetry.io/collector/config/configtelemetry v0.89.0/go.mod h1:+LAXM5WFMW/UbTlAuSs6L/W72WC+q8TBJt/6z39FPOU= +go.opentelemetry.io/collector/config/configtelemetry v0.87.0 h1:xUqayM9b41OvXkjU3p8RkUr8hUrCjfDUmO+oKhRNSwc= +go.opentelemetry.io/collector/config/configtelemetry v0.87.0/go.mod h1:+LAXM5WFMW/UbTlAuSs6L/W72WC+q8TBJt/6z39FPOU= go.opentelemetry.io/collector/config/configtls v0.87.0 h1:EXa9Plr74+r9t2/59dTyjR3y53zqwigHN0dQsI8VGiQ= go.opentelemetry.io/collector/config/configtls v0.87.0/go.mod h1:3UoeynehS/NNhg1Qbt3xQdgPyrkWnjBRLUG2Gw7BFFc= go.opentelemetry.io/collector/config/internal v0.87.0 h1:wffyWbpanr2HFQaPPp5bG62KqJYlw5EdPxwR0iG+Lbo= go.opentelemetry.io/collector/config/internal v0.87.0/go.mod h1:42VsQ/1kP2qnvzjNi+dfNP+KyCFRADejyrJ8m2GVL3M= -go.opentelemetry.io/collector/confmap v0.89.0 h1:N5Vg1+FXEFBHHlGIPg4OSlM9uTHjCI7RlWWrKjtOzWQ= -go.opentelemetry.io/collector/confmap v0.89.0/go.mod h1:D8FMPvuihtVxwXaz/qp5q9X2lq9l97QyjfsdZD1spmc= -go.opentelemetry.io/collector/connector v0.89.0 h1:2v7RgaLrlGmvHV1BjG133MswZ2BhH77vTHOLa4/Tqm0= -go.opentelemetry.io/collector/connector v0.89.0/go.mod h1:z82Yw0wZarpva9byeqByb3+eZSZ35DMdNRkjFgMm0S0= -go.opentelemetry.io/collector/consumer v0.89.0 h1:MteKhkudX2L1ylbtdpSazO8SwyHSxl6fUEElc0rRLDQ= -go.opentelemetry.io/collector/consumer v0.89.0/go.mod h1:aOaoi6R0qVvfHu0pEPCzSE74gIPNJoCQM8Ml4Bc9NHE= -go.opentelemetry.io/collector/exporter v0.89.0 h1:8sYpJdKDQ2RuYOPKDsMz/lMJqp4WEWZgfJzyn9IgOag= -go.opentelemetry.io/collector/exporter v0.89.0/go.mod h1:zR8PFXMHlG0qPIEdRPNaefxDNj4UVP47uJ4vbHs+YME= -go.opentelemetry.io/collector/exporter/debugexporter v0.89.0 h1:MQUEX4OWszJQqQMqtYERiiw02Ta9QMWPe/hHWoD4YBU= -go.opentelemetry.io/collector/exporter/debugexporter v0.89.0/go.mod h1:eLoVrKOjgPvAmg0XJuellJ03zEpEol26l8i48Rhv53Q= +go.opentelemetry.io/collector/confmap v0.87.0 h1:LFnyDKIOMtlJm5EsdcFN2t0rcU/QLbS9QEs/awM2HOA= +go.opentelemetry.io/collector/confmap v0.87.0/go.mod h1:inqYRP70+bMrUwGGnuhcWyyufxyU3VQT6rl3/EX0f+g= +go.opentelemetry.io/collector/connector v0.87.0 h1:Y00shHpxBSxliE/liJex2JMdYpJxbakfCUbaXe9eVMU= +go.opentelemetry.io/collector/connector v0.87.0/go.mod h1:qk+c3IeAdRkpUjXLh3PqAnC8BkKuMF7EhA5GpGNu7AI= +go.opentelemetry.io/collector/consumer v0.87.0 h1:oR5XKZoVF/hwz0FnrYPaHcbbQazHifMsxpENMR7ivvo= +go.opentelemetry.io/collector/consumer v0.87.0/go.mod h1:lui5rg1byAT7QPbCY733StCDc/TPxS3hVNXKoVQ3LsI= +go.opentelemetry.io/collector/exporter v0.87.0 h1:DZ0QT2yp1qACmHMxs6W2ho5RPqdevCx9R/LFCxnxi9w= +go.opentelemetry.io/collector/exporter v0.87.0/go.mod h1:SGobdCR0xwQElJT2Sbofo7BprMlV8XeXdsNP9fsNaKY= +go.opentelemetry.io/collector/exporter/debugexporter v0.87.0 h1:xPZme8RnjgXSRG2EKXwV1Uy+e44pqZpSqRWAkYOHsog= +go.opentelemetry.io/collector/exporter/debugexporter v0.87.0/go.mod h1:L3LYJKt//OTHLS6JM3D/GLjTYejGYIqvHJAtIMrxCAI= go.opentelemetry.io/collector/exporter/loggingexporter v0.87.0 h1:F/WkglGgCSHOFYjafYEAwD/qGpZ5HpawLMWu/Jcf0SE= go.opentelemetry.io/collector/exporter/loggingexporter v0.87.0/go.mod h1:rYi0mKzgRH6xwsrYN9gb+WBccfoP1SpJ9U0xklrhV7g= go.opentelemetry.io/collector/exporter/otlpexporter v0.87.0 h1:1seSC+OX1QnbpED0Kuo1DbWQSER+vy88yp4zxBubY4A= go.opentelemetry.io/collector/exporter/otlpexporter v0.87.0/go.mod h1:Q4aS69GcAdcJLssnEd8ddt2rX97s/CkW/n1DdgdIaHQ= go.opentelemetry.io/collector/exporter/otlphttpexporter v0.87.0 h1:EqexJl7mzozDw4KY9mzR14uij0QlB9zIg8CfNGJYNt0= go.opentelemetry.io/collector/exporter/otlphttpexporter v0.87.0/go.mod h1:uwNO6qMa82a0EeokQx3YEiMl+R8HJulaDpUSS6T3pkg= -go.opentelemetry.io/collector/extension v0.89.0 h1:iiaWIPPFqP4T0FSgl6+D1xRUhVnhsk88uk2BxCFqt7E= -go.opentelemetry.io/collector/extension v0.89.0/go.mod h1:tBh5wD4AZ3xFO6M1CjkEEx2urexTqcAcgi9cJSPME3E= +go.opentelemetry.io/collector/extension v0.87.0 h1:EMIaEequ5rjWzoid6vNImjQGVMfzbME+8JSa5XACYKs= +go.opentelemetry.io/collector/extension v0.87.0/go.mod h1:D3srNZC99QVTAdLNUVuqfmmgJge4sQHDrnt5XWscvxI= go.opentelemetry.io/collector/extension/auth v0.87.0 h1:na1OumQSd5l+JvUiMr3oaiW6fuiDr7mEnydwQwmE+nk= go.opentelemetry.io/collector/extension/auth v0.87.0/go.mod h1:b7T9VefuK1GzSp5z1yjbkAvTxpWvflUmYoawTcGGuOs= go.opentelemetry.io/collector/extension/zpagesextension v0.87.0 h1:vSaCojdWMq34LDw2qR6To0PkSe4p+1BtP2Xr37PHH7w= go.opentelemetry.io/collector/extension/zpagesextension v0.87.0/go.mod h1:aXIFi7aIGD2uQCJPCF8uRSPJEK0+jjiZfvOehNGA1ZU= -go.opentelemetry.io/collector/featuregate v1.0.0-rcv0018 h1:iK4muX3KIMqKk0xwKcRzu4ravgCtUdzsvuxxdz6A27g= -go.opentelemetry.io/collector/featuregate v1.0.0-rcv0018/go.mod h1:xGbRuw+GbutRtVVSEy3YR2yuOlEyiUMhN2M9DJljgqY= -go.opentelemetry.io/collector/pdata v1.0.0-rcv0018 h1:a2IHOZKphRzPagcvOHQHHUE0DlITFSKlIBwaWhPZpl4= -go.opentelemetry.io/collector/pdata v1.0.0-rcv0018/go.mod h1:oNIcTRyEJYIfMcRYyyh5lquDU0Vl+ktTL6ka+p+dYvg= -go.opentelemetry.io/collector/processor v0.89.0 h1:ypMnoOqBYbXgbDnAm9/Cb4uN3kxvmI05Vf6o4u/riBU= -go.opentelemetry.io/collector/processor v0.89.0/go.mod h1:HzMQ2VbxaECk7Oy1mHtug4qsl4acAW4XP1hpTgQKv84= +go.opentelemetry.io/collector/featuregate v1.0.0-rcv0016 h1:/6N9990tbjotvXgrXpV5AbaFiyxTdFEXDypGBHVDSQM= +go.opentelemetry.io/collector/featuregate v1.0.0-rcv0016/go.mod h1:fLmJMf1AoHttkF8p5oJAc4o5ZpHu8yO5XYJ7gbLCLzo= +go.opentelemetry.io/collector/pdata v1.0.0-rcv0016 h1:qCPXSQCoD3qeWFb1RuIks8fw9Atxpk78bmtVdi15KhE= +go.opentelemetry.io/collector/pdata v1.0.0-rcv0016/go.mod h1:OdN0alYOlYhHXu6BDlGehrZWgtBuiDsz/rlNeJeXiNg= +go.opentelemetry.io/collector/processor v0.87.0 h1:aUGtRyeQk0WgQwp2rZBvJ1j+6+WJO8XMb1kjtanIWo8= +go.opentelemetry.io/collector/processor v0.87.0/go.mod h1:FHqpqdm/uyjjhNQxXJBhvQDIwjnP01EW9M6t0xVaRR4= go.opentelemetry.io/collector/processor/batchprocessor v0.87.0 h1:/a2yjC8XMg1j/9hnpDbxTKbG/AyWac2xsQSx0PmFz1M= go.opentelemetry.io/collector/processor/batchprocessor v0.87.0/go.mod h1:uY8Lu7zFtNZC39ylu8bphgqO0c3VIqVdegKxXlHo9Po= go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.87.0 h1:pWR4fPyKOBo0YWi745pai6ae7jFdlRvRiEg7VmtpGNw= go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.87.0/go.mod h1:Id8f4KVl5p5Uzn7RlfFwufdaiINQTKILcTCLQFsSH6c= -go.opentelemetry.io/collector/receiver v0.89.0 h1:wC/FB8e2Ej06jjNW2OiuZoyiSyB8TQNIzYyPlh9oRqI= -go.opentelemetry.io/collector/receiver v0.89.0/go.mod h1:Rk7Bkz45fVdrcJaVDsPTnHa97ZfSs1ULO76LXc4kLN0= +go.opentelemetry.io/collector/receiver v0.87.0 h1:4HpA5Rxb1jcMywCB8y5aNTXiqSt3n7oaFLfQbAkSaWM= +go.opentelemetry.io/collector/receiver v0.87.0/go.mod h1:uApnlS81KGGfQJrzbCdBZWsB5DQJgcPTsYlb9CFdE3s= go.opentelemetry.io/collector/receiver/otlpreceiver v0.87.0 h1:iXO30EKZwEP1TEuLlQjxVaeVeffDkdJqz9DuqjzME9c= go.opentelemetry.io/collector/receiver/otlpreceiver v0.87.0/go.mod h1:1IE82wJuyGW0z0BeJ3A0SoPxsPlqf9aefCycbtuxUO0= go.opentelemetry.io/collector/semconv v0.87.0 h1:BsG1jdLLRCBRlvUujk4QA86af7r/ZXnizczQpEs/gg8= @@ -2429,8 +2429,8 @@ go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 h1:3d+S2 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0/go.mod h1:0+KuTDyKL4gjKCF75pHOX4wuzYDUZYfAQdSu43o+Z2I= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 h1:IeMeyr1aBvBiPVYihXIaeIZba6b8E1bYp7lbdxK8CQg= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0/go.mod h1:oVdCUtjq9MK9BlS7TtucsQwUcXcymNiEDjgDD2jMtZU= -go.opentelemetry.io/otel/exporters/prometheus v0.43.0 h1:Skkl6akzvdWweXX6LLAY29tyFSO6hWZ26uDbVGTDXe8= -go.opentelemetry.io/otel/exporters/prometheus v0.43.0/go.mod h1:nZStMoc1H/YJpRjSx9IEX4abBMekORTLQcTUT1CgLkg= +go.opentelemetry.io/otel/exporters/prometheus v0.42.0 h1:jwV9iQdvp38fxXi8ZC+lNpxjK16MRcZlpDYvbuO1FiA= +go.opentelemetry.io/otel/exporters/prometheus v0.42.0/go.mod h1:f3bYiqNqhoPxkvI2LrXqQVC546K7BuRDL/kKuxkujhA= go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.42.0 h1:4jJuoeOo9W6hZnz+r046fyoH5kykZPRvKfUXJVfMpB0= go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.42.0/go.mod h1:/MtYTE1SfC2QIcE0bDot6fIX+h+WvXjgTqgn9P0LNPE= go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.19.0 h1:Nw7Dv4lwvGrI68+wULbcq7su9K2cebeCUrDjVrUJHxM= @@ -2439,8 +2439,8 @@ go.opentelemetry.io/otel/metric v1.21.0 h1:tlYWfeo+Bocx5kLEloTjbcDwBuELRrIFxwdQ3 go.opentelemetry.io/otel/metric v1.21.0/go.mod h1:o1p3CA8nNHW8j5yuQLdc1eeqEaPfzug24uvsyIEJRWM= go.opentelemetry.io/otel/sdk v1.21.0 h1:FTt8qirL1EysG6sTQRZ5TokkU8d0ugCj8htOgThZXQ8= go.opentelemetry.io/otel/sdk v1.21.0/go.mod h1:Nna6Yv7PWTdgJHVRD9hIYywQBRx7pbox6nwBnZIxl/E= -go.opentelemetry.io/otel/sdk/metric v1.20.0 h1:5eD40l/H2CqdKmbSV7iht2KMK0faAIL2pVYzJOWobGk= -go.opentelemetry.io/otel/sdk/metric v1.20.0/go.mod h1:AGvpC+YF/jblITiafMTYgvRBUiwi9hZf0EYE2E5XlS8= +go.opentelemetry.io/otel/sdk/metric v1.19.0 h1:EJoTO5qysMsYCa+w4UghwFV/ptQgqSL/8Ni+hx+8i1k= +go.opentelemetry.io/otel/sdk/metric v1.19.0/go.mod h1:XjG0jQyFJrv2PbMvwND7LwCEhsJzCzV5210euduKcKY= go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8fpfLc= go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= From 3bf13bf6fb2d63d65bf843021c9573205791d699 Mon Sep 17 00:00:00 2001 From: "Das, Barun" Date: Sun, 14 Jan 2024 21:58:23 +0530 Subject: [PATCH 14/21] tests passing --- .../otelcol/exporter/debug/debug_test.go | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/component/otelcol/exporter/debug/debug_test.go b/component/otelcol/exporter/debug/debug_test.go index f5fef39ba466..d55c460e866d 100644 --- a/component/otelcol/exporter/debug/debug_test.go +++ b/component/otelcol/exporter/debug/debug_test.go @@ -1,6 +1,7 @@ package debug_test import ( + "fmt" "testing" "github.com/grafana/agent/component/otelcol/exporter/debug" @@ -15,14 +16,14 @@ func Test(t *testing.T) { tests := []struct { testName string args string - expectedReturn otelcomponent.Config + expectedReturn debugexporter.Config errorMsg string }{ { testName: "defaultConfig", - args: ` + args: ` verbosity = "basic" - sampling_initial = 1 + sampling_initial = 2 sampling_thereafter = 500 `, expectedReturn: debugexporter.Config{ @@ -35,9 +36,9 @@ func Test(t *testing.T) { { testName: "validConfig", args:` - verbosity: "detailed", - sampling_initial: 5, - sampling_thereafter: 20, + verbosity = "detailed" + sampling_initial = 5 + sampling_thereafter = 20 `, expectedReturn: debugexporter.Config{ Verbosity: configtelemetry.LevelDetailed, @@ -49,9 +50,9 @@ func Test(t *testing.T) { { testName: "invalidConfig", args: ` - verbosity: "test", - sampling_initial: 5, - sampling_thereafter: 20, + verbosity = "test" + sampling_initial = 5 + sampling_thereafter = 20 `, errorMsg: "error in conversion to config arguments", }, @@ -61,20 +62,21 @@ func Test(t *testing.T) { t.Run(tc.testName, func(t *testing.T) { var args debug.Arguments err := river.Unmarshal([]byte(tc.args), &args) + require.NoError(t, err) + + actualPtr, err := args.Convert() if tc.errorMsg != "" { require.ErrorContains(t, err, tc.errorMsg) return - } - - require.NoError(t, err) - - actualPtr, err := args.Convert() + } + require.NoError(t, err) - - actual := actualPtr.(*otelcomponent.Config) + + actual := actualPtr.(*debugexporter.Config) + fmt.Printf("Passed conversion") require.NoError(t, otelcomponent.ValidateConfig(actual)) - + require.Equal(t, tc.expectedReturn, *actual) }) } From f3614d523c3269b2eebf6abef171cc33843b9474 Mon Sep 17 00:00:00 2001 From: "Das, Barun" Date: Sun, 14 Jan 2024 21:58:38 +0530 Subject: [PATCH 15/21] refactor --- component/otelcol/exporter/debug/debug.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/component/otelcol/exporter/debug/debug.go b/component/otelcol/exporter/debug/debug.go index 07ac5bbe4e70..d5aad0f9e097 100644 --- a/component/otelcol/exporter/debug/debug.go +++ b/component/otelcol/exporter/debug/debug.go @@ -26,9 +26,9 @@ func init() { } type Arguments struct { - Verbosity string `river:"verbosity, attr, optional"` - SamplingInitial int `river:"sampling_initial,attr, optional"` - SamplingThereafter int `river:"sampling_thereafter,attr, optional"` + Verbosity string `river:"verbosity,attr,optional"` + SamplingInitial int `river:"sampling_initial,attr,optional"` + SamplingThereafter int `river:"sampling_thereafter,attr,optional"` } func (args Arguments) convertVerbosity() (configtelemetry.Level, error) { From f6f0ea72ec5e8025f4a2ae127c5a315fe5e62e58 Mon Sep 17 00:00:00 2001 From: Barun Das Date: Sun, 14 Jan 2024 11:34:05 -0500 Subject: [PATCH 16/21] Update CHANGELOG.md Co-authored-by: Paulin Todev --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4a686658375..536130498013 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -199,7 +199,7 @@ v0.39.0 (2024-01-09) ### Enhancements -- Added `otelcol.exporter.debug` component based on `go.opentelemetry.io/collector/exporter/debugexporter`. (@BarunKGP) +- Added a new `otelcol.exporter.debug` component based on OTel Collector's "debug" exporter`. (@BarunKGP) - Flow Windows service: Support environment variables. (@jkroepke) From a09543388f2ed80fe92b80cfb6aa94ef77d9b5da Mon Sep 17 00:00:00 2001 From: "Das, Barun" Date: Mon, 12 Feb 2024 23:47:35 -0500 Subject: [PATCH 17/21] doc added for debug exporter --- .../components/otelcol.exporter.debug.md | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 docs/sources/flow/reference/components/otelcol.exporter.debug.md diff --git a/docs/sources/flow/reference/components/otelcol.exporter.debug.md b/docs/sources/flow/reference/components/otelcol.exporter.debug.md new file mode 100644 index 000000000000..e3e468ce784b --- /dev/null +++ b/docs/sources/flow/reference/components/otelcol.exporter.debug.md @@ -0,0 +1,89 @@ +--- +aliases: +- /docs/grafana-cloud/agent/flow/reference/components/otelcol.exporter.debug/ +- /docs/grafana-cloud/monitor-infrastructure/agent/flow/reference/components/otelcol.exporter.debug/ +- /docs/grafana-cloud/monitor-infrastructure/integrations/agent/flow/reference/components/otelcol.exporter.debug/ +- /docs/grafana-cloud/send-data/agent/flow/reference/components/otelcol.exporter.debug/ +canonical: https://grafana.com/docs/agent/latest/flow/reference/components/otelcol.exporter.debug/ +description: Learn about otelcol.exporter.debug +title: otelcol.exporter.debug +--- + +# otelcol.exporter.debug + +`otelcol.exporter.debug` accepts telemetry data from other `otelcol` components +and writes them to the console. + +This component writes logs at the info level. The [logging config block][] must be +configured to write logs at the info level. + +> **NOTE**: `otelcol.exporter.debug` is a wrapper over the upstream +> OpenTelemetry Collector `debug` exporter. Bug reports or feature requests will +> be redirected to the upstream repository, if necessary. + +Multiple `otelcol.exporter.debug` components can be specified by giving them +different labels. + +## Usage + +```river +otelcol.exporter.debug "LABEL" { } +``` + +## Arguments + +`otelcol.exporter.debug` supports the following arguments: + +Name | Type | Description | Default | Required +---- | ---- | ----------- | ------- | -------- +`verbosity` | `string` | Verbosity of the generated logs. | `"basic"` | no +`sampling_initial` | `int` | Number of messages initially logged each second. | `2` | no +`sampling_thereafter` | `int` | Sampling rate after the initial messages are logged. | `500` | no + +The `verbosity` argument must be one of `"basic"`, `"normal"`, or `"detailed"`. + +## Exported fields + +The following fields are exported and can be referenced by other components: + +Name | Type | Description +---- | ---- | ----------- +`input` | `otelcol.Consumer` | A value that other components can use to send telemetry data to. + +`input` accepts `otelcol.Consumer` data for any telemetry signal (metrics, +logs, or traces). + +## Component health + +`otelcol.exporter.debug` is only reported as unhealthy if given an invalid +configuration. + +## Debug information + +`otelcol.exporter.debug` does not expose any component-specific debug +information. + +## Example + +This example scrapes prometheus unix metrics and writes them to the console: + +```river +prometheus.exporter.unix "default" { } + +prometheus.scrape "default" { + targets = prometheus.exporter.unix.default.targets + forward_to = [otelcol.receiver.prometheus.default.receiver] +} + +otelcol.receiver.prometheus "default" { + output { + metrics = [otelcol.exporter.debug.default.input] + } +} + +otelcol.exporter.debug "default" { + verbosity = "detailed" + sampling_initial = 1 + sampling_thereafter = 1 +} +``` From 4cfd7bb49af60ea2eb766f49b5dcea3e11806efb Mon Sep 17 00:00:00 2001 From: "Das, Barun" Date: Tue, 13 Feb 2024 00:02:23 -0500 Subject: [PATCH 18/21] remove logging level sentence --- .../flow/reference/components/otelcol.exporter.debug.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/docs/sources/flow/reference/components/otelcol.exporter.debug.md b/docs/sources/flow/reference/components/otelcol.exporter.debug.md index e3e468ce784b..27aa5694d0af 100644 --- a/docs/sources/flow/reference/components/otelcol.exporter.debug.md +++ b/docs/sources/flow/reference/components/otelcol.exporter.debug.md @@ -12,10 +12,7 @@ title: otelcol.exporter.debug # otelcol.exporter.debug `otelcol.exporter.debug` accepts telemetry data from other `otelcol` components -and writes them to the console. - -This component writes logs at the info level. The [logging config block][] must be -configured to write logs at the info level. +and writes them to the console (stderr). The verbosity of the logs can also be controlled. > **NOTE**: `otelcol.exporter.debug` is a wrapper over the upstream > OpenTelemetry Collector `debug` exporter. Bug reports or feature requests will From 1c70e291e88133c674fde6af8ef409081be1077c Mon Sep 17 00:00:00 2001 From: Barun Das Date: Tue, 13 Feb 2024 20:17:42 -0500 Subject: [PATCH 19/21] Add label experimental Co-authored-by: Paulin Todev --- .../sources/flow/reference/components/otelcol.exporter.debug.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/sources/flow/reference/components/otelcol.exporter.debug.md b/docs/sources/flow/reference/components/otelcol.exporter.debug.md index 27aa5694d0af..96bc3b3c5c77 100644 --- a/docs/sources/flow/reference/components/otelcol.exporter.debug.md +++ b/docs/sources/flow/reference/components/otelcol.exporter.debug.md @@ -6,6 +6,8 @@ aliases: - /docs/grafana-cloud/send-data/agent/flow/reference/components/otelcol.exporter.debug/ canonical: https://grafana.com/docs/agent/latest/flow/reference/components/otelcol.exporter.debug/ description: Learn about otelcol.exporter.debug +labels: + stage: experimental title: otelcol.exporter.debug --- From 0dd0b0a54fd844b9903921edb2dd67e1ce2f4d23 Mon Sep 17 00:00:00 2001 From: Barun Das Date: Tue, 20 Feb 2024 09:12:19 -0500 Subject: [PATCH 20/21] fix linting issue --- component/otelcol/exporter/debug/debug_test.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/component/otelcol/exporter/debug/debug_test.go b/component/otelcol/exporter/debug/debug_test.go index d55c460e866d..2a764f6b5313 100644 --- a/component/otelcol/exporter/debug/debug_test.go +++ b/component/otelcol/exporter/debug/debug_test.go @@ -35,7 +35,7 @@ func Test(t *testing.T) { { testName: "validConfig", - args:` + args: ` verbosity = "detailed" sampling_initial = 5 sampling_thereafter = 20 @@ -63,15 +63,15 @@ func Test(t *testing.T) { var args debug.Arguments err := river.Unmarshal([]byte(tc.args), &args) require.NoError(t, err) - + actualPtr, err := args.Convert() if tc.errorMsg != "" { require.ErrorContains(t, err, tc.errorMsg) return - } - + } + require.NoError(t, err) - + actual := actualPtr.(*debugexporter.Config) fmt.Printf("Passed conversion") @@ -80,5 +80,4 @@ func Test(t *testing.T) { require.Equal(t, tc.expectedReturn, *actual) }) } - } From 96da7adc7a17321724332732bf08fe6fe6ad2e7e Mon Sep 17 00:00:00 2001 From: Barun Das Date: Wed, 28 Feb 2024 19:34:05 -0500 Subject: [PATCH 21/21] documentation edits --- .../components/otelcol.exporter.debug.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/sources/flow/reference/components/otelcol.exporter.debug.md b/docs/sources/flow/reference/components/otelcol.exporter.debug.md index 96bc3b3c5c77..34063a7a5f01 100644 --- a/docs/sources/flow/reference/components/otelcol.exporter.debug.md +++ b/docs/sources/flow/reference/components/otelcol.exporter.debug.md @@ -13,15 +13,15 @@ title: otelcol.exporter.debug # otelcol.exporter.debug -`otelcol.exporter.debug` accepts telemetry data from other `otelcol` components -and writes them to the console (stderr). The verbosity of the logs can also be controlled. +`otelcol.exporter.debug` accepts telemetry data from other `otelcol` components and writes them to the console (stderr). +You can control the verbosity of the logs. -> **NOTE**: `otelcol.exporter.debug` is a wrapper over the upstream -> OpenTelemetry Collector `debug` exporter. Bug reports or feature requests will -> be redirected to the upstream repository, if necessary. +{{< admonition type="note" >}} +`otelcol.exporter.debug` is a wrapper over the upstream OpenTelemetry Collector `debug` exporter. +If necessary, bug reports or feature requests are redirected to the upstream repository. +{{< /admonition >}} -Multiple `otelcol.exporter.debug` components can be specified by giving them -different labels. +Multiple `otelcol.exporter.debug` components can be specified by giving them different labels. ## Usage @@ -64,7 +64,7 @@ information. ## Example -This example scrapes prometheus unix metrics and writes them to the console: +This example scrapes Prometheus UNIX metrics and writes them to the console: ```river prometheus.exporter.unix "default" { }