open-telemetry / opentelemetry-collector-contrib

Contrib repository for the OpenTelemetry Collector
https://opentelemetry.io
Apache License 2.0
2.89k stars 2.27k forks source link

[processor/resourcedetectionprocessor] Add a more general and flexible detector #34556

Open JaredTan95 opened 1 month ago

JaredTan95 commented 1 month ago

Component(s)

processor/resourcedetection

Is your feature request related to a problem? Please describe.

Currently resourcedetectionprocessor has built-in aws, azure, consul, docker, k8snode, system and so on rich out-of-the-box detection. Those detectors all rely on third-party components, and adding new detectors requires the user to add an implementation of the new detector in the otel-col-contrib library. Therefore, a more flexible approach is needed.

Describe the solution you'd like

This proposal is intended to refer to a more flexible, general-purpose approach to detection, similar to the prometheus HTTP SD config, where users simply implement a custom interface and return it in a specified format.

This feature will be on the processor/resourcedetectionprocessor/internal/http directory, and the following configuration items are provided:

processors:
  resourcedetection/http:
    detectors: [http]
    http:
      endpoint: http://my-http-resourcedetection:8080 # external http url
      interval: 1h # the interval of requests
      headers:
        my-token: xxxxxxxxxxx
        tanent: one
      .......more options......

the response of the http should be returned as json(contains real attributes and their values) , Examples:

[
    {
        "datacenter": "idc01",
        "enabled": true
    },
    {
        "zone": "zone01",
        "enabled": false
    }
]

Based on the above results, the http detector will append or override datacenter=idc01 in the resource value in telemetry data.

Describe alternatives you've considered

No response

Additional context

No response

github-actions[bot] commented 1 month ago

Pinging code owners:

Frapschen commented 1 month ago

Our customer has a use case: they want to add some attributes from a remote HTTP Server. We found that the case is more likely how the resource detection processor works. We think it's a common use case and would be happy to contribute it if this is accepted.