From f4ab69d587904ef8ae93dfa7316e39390727bce1 Mon Sep 17 00:00:00 2001 From: Erik Baranowski <39704712+erikbaranowski@users.noreply.github.com> Date: Mon, 1 Apr 2024 10:50:03 -0400 Subject: [PATCH] wire up static traces converter test for all major scenarios and squash a bug along the way (#6801) * wire up static traces converter test for all major scenarios and squash a bug along the way Signed-off-by: erikbaranowski <39704712+erikbaranowski@users.noreply.github.com> --------- Signed-off-by: erikbaranowski <39704712+erikbaranowski@users.noreply.github.com> --- .../internal/build/builder_traces.go | 32 +++++++++---- .../staticconvert/testdata/traces.river | 38 +++++++++++++-- .../staticconvert/testdata/traces.yaml | 48 +++++++++++++++---- 3 files changed, 97 insertions(+), 21 deletions(-) diff --git a/internal/converter/internal/staticconvert/internal/build/builder_traces.go b/internal/converter/internal/staticconvert/internal/build/builder_traces.go index 6762d8e580f2..da2411b9eaa3 100644 --- a/internal/converter/internal/staticconvert/internal/build/builder_traces.go +++ b/internal/converter/internal/staticconvert/internal/build/builder_traces.go @@ -75,13 +75,19 @@ func removeReceiver(otelCfg *otelcol.Config, pipelineType otel_component.Type, r } delete(otelCfg.Receivers, otel_component.NewID(receiverType)) - spr := make([]otel_component.ID, 0, len(otelCfg.Service.Pipelines[otel_component.NewID(pipelineType)].Receivers)-1) - for _, r := range otelCfg.Service.Pipelines[otel_component.NewID(pipelineType)].Receivers { - if r != otel_component.NewID(receiverType) { - spr = append(spr, r) + for ix, p := range otelCfg.Service.Pipelines { + if ix.Type() != pipelineType { + continue + } + + spr := make([]otel_component.ID, 0) + for _, r := range p.Receivers { + if r.Type() != receiverType { + spr = append(spr, r) + } } + otelCfg.Service.Pipelines[ix].Receivers = spr } - otelCfg.Service.Pipelines[otel_component.NewID(pipelineType)].Receivers = spr } // removeProcessor removes a processor from the otel config for a specific pipeline type. @@ -91,11 +97,17 @@ func removeProcessor(otelCfg *otelcol.Config, pipelineType otel_component.Type, } delete(otelCfg.Processors, otel_component.NewID(processorType)) - spr := make([]otel_component.ID, 0, len(otelCfg.Service.Pipelines[otel_component.NewID(pipelineType)].Processors)-1) - for _, r := range otelCfg.Service.Pipelines[otel_component.NewID(pipelineType)].Processors { - if r != otel_component.NewID(processorType) { - spr = append(spr, r) + for ix, p := range otelCfg.Service.Pipelines { + if ix.Type() != pipelineType { + continue + } + + spr := make([]otel_component.ID, 0) + for _, r := range p.Processors { + if r.Type() != processorType { + spr = append(spr, r) + } } + otelCfg.Service.Pipelines[ix].Processors = spr } - otelCfg.Service.Pipelines[otel_component.NewID(pipelineType)].Processors = spr } diff --git a/internal/converter/internal/staticconvert/testdata/traces.river b/internal/converter/internal/staticconvert/testdata/traces.river index 716aefad0e3b..85364b105d81 100644 --- a/internal/converter/internal/staticconvert/testdata/traces.river +++ b/internal/converter/internal/staticconvert/testdata/traces.river @@ -1,3 +1,18 @@ +otelcol.extension.jaeger_remote_sampling "default_0" { + grpc { } + + http { } + + source { + remote { + endpoint = "jaeger-collector:14250" + compression = "" + write_buffer_size = "0B" + } + reload_interval = "30s" + } +} + otelcol.receiver.otlp "default" { grpc { include_metadata = true @@ -54,7 +69,8 @@ discovery.relabel "default_prometheus1" { otelcol.processor.discovery "default" { targets = discovery.relabel.default_prometheus1.output - pod_associations = [] + operation_type = "insert" + pod_associations = ["ip", "net.host.ip"] output { metrics = [] @@ -84,7 +100,19 @@ otelcol.processor.tail_sampling "default" { decision_wait = "5s" output { - traces = [otelcol.exporter.otlp.default_0.input, otelcol.exporter.logging.default.input] + traces = [otelcol.processor.batch.default.input] + } +} + +otelcol.processor.batch "default" { + timeout = "5s" + send_batch_size = 2048 + send_batch_max_size = 4096 + + output { + metrics = [] + logs = [] + traces = [otelcol.exporter.otlp.default_0.input, otelcol.exporter.logging.default.input] } } @@ -94,7 +122,11 @@ otelcol.exporter.otlp "default_0" { } client { - endpoint = "http://localhost:1234/write" + endpoint = "tempo.example.com:14250" + + tls { + insecure = true + } } } diff --git a/internal/converter/internal/staticconvert/testdata/traces.yaml b/internal/converter/internal/staticconvert/testdata/traces.yaml index 2553da25200a..251f4d24ee56 100644 --- a/internal/converter/internal/staticconvert/testdata/traces.yaml +++ b/internal/converter/internal/staticconvert/testdata/traces.yaml @@ -1,15 +1,24 @@ traces: configs: - name: trace_config + attributes: + actions: + - key: db.table + action: delete + batch: + timeout: 5s + send_batch_size: 2048 + send_batch_max_size: 4096 + remote_write: + - endpoint: tempo.example.com:14250 + insecure: true + automatic_logging: + backend: "stdout" receivers: otlp: protocols: grpc: http: - remote_write: - - endpoint: http://localhost:1234/write - automatic_logging: - backend: "stdout" scrape_configs: - job_name: "prometheus1" azure_sd_configs: @@ -27,6 +36,13 @@ traces: target_label: __param_target1 - source_labels: [__address2__] target_label: __param_target2 + prom_sd_operation_type: "insert" + prom_sd_pod_associations: + - ip + - net.host.ip + # spanmetrics: + # namespace: testing + # metrics_instance: default tail_sampling: policies: [ @@ -35,7 +51,23 @@ traces: type: always_sample }, ] - attributes: - actions: - - key: db.table - action: delete \ No newline at end of file + # load_balancing: + # resolver: + # static: + # hostnames: + # - tempo1.example.com + # - tempo2.example.com + # service_graphs: + # enabled: true + jaeger_remote_sampling: + - source: + reload_interval: 30s + remote: + endpoint: jaeger-collector:14250 + +# This metrics config is needed when we enable spanmetrics for traces +# +# metrics: +# global: +# remote_write: +# - url: http://localhost:9009/api/prom/push