open-telemetry / opentelemetry-collector

OpenTelemetry Collector
https://opentelemetry.io
Apache License 2.0
4.32k stars 1.43k forks source link

Incorrect warn message when using service::telemetry::metrics::readers config #9285

Open petertakacs opened 8 months ago

petertakacs commented 8 months ago

Describe the bug When config service::telemetry::metrics::readers contains a prometheus exporter, the collector incorrectly logs a warn message to the console that address field is deprecated:

2024-01-15T13:10:16.667+0100 warn service@v0.92.0/telemetry.go:124 service::telemetry::metrics::address is being deprecated in favor of service::telemetry::metrics::readers

Steps to reproduce Run the collector with the following config:

service:
  telemetry:
    metrics:
      level: normal
      #address: ""
      readers:
        - pull:
            exporter:
              prometheus:
                host: localhost
                port: 9999

What did you expect to see? If I specify the metrics::readers fields with --feature-gates=telemetry.useOtelForInternalMetrics --feature-gates=telemetry.useOtelWithSDKConfigurationForInternalTelemetry flags, I should not see the warning

What version did you use? v0.92 (with ocb)

Environment Go: go version go1.21.4 darwin/arm64

OS: ProductName: macOS ProductVersion: 13.3.1 ProductVersionExtra: (a) BuildVersion: 22E772610a

Additional context If the address is specified as an empty string I don't get the warning (as expected)

fatsheep9146 commented 8 months ago

@petertakacs I can not reproduce on my environment. I use the image otel/opentelemetry-collector-contrib:0.92.0 The collector you use is built by your own, not from official opentelemetry image repo, right?

petertakacs commented 8 months ago

@fatsheep9146 I did some debugging seems like the :8888 default port is set here regardless if the new reader config is provided or not

This might be the problematic part where the code checks only the Address and logs a warning by default: https://github.com/open-telemetry/opentelemetry-collector/blob/1cea6363f60421d4faed7469ccdcae25f82231b2/service/telemetry.go#L122

The collector I'm using is built from the official repo using the ocb (https://github.com/open-telemetry/opentelemetry-collector/releases/download/cmd%2Fbuilder%2Fv0.92.0/ocb_0.92.0_linux_amd64)