[chore] [receiver/k8sobjects] Extract logic for watching/pulling K8s resources into separate package#43108
Conversation
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
# Conflicts: # receiver/k8sobjectsreceiver/config.go # receiver/k8sobjectsreceiver/receiver.go
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
ChrsMark
left a comment
There was a problem hiding this comment.
Thank's for working on this!
Overall looks good with some nits.
Thanks for the feedback @ChrsMark! I will address the comments and update the PR in the next few days |
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
…er-code' into feat/40825/reusable-k8s-receiver-code
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
…and its sub-packages Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
…andling Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
| cancelCtx, cancel := context.WithCancel(ctx) | ||
|
|
||
| wait.UntilWithContext(cancelCtx, func(newCtx context.Context) { | ||
| resourceVersion, err := getResourceVersion(newCtx, o.config.Config, resource) |
There was a problem hiding this comment.
In the current code, watchers have their own copy of the config:
opentelemetry-collector-contrib/receiver/k8sobjectsreceiver/receiver.go
Lines 288 to 310 in 21380a7
while here, config seems to be shared, so all goroutines will operate on the same ResourceVersion, right?
There was a problem hiding this comment.
There would be one instance of an Observer per resource type, where each one has its own copy of the config, so they should not use the same resource version. An example of how this would be used in the k8sobjectsreceiver can be seen in the following commit: 553fc36#diff-50ed6c76b6431c811210dccb90da133a8ef78e9321de67aceb801301b21ad723L110-L138 - I had to undo this change for this PR because the introduction of the new module and the adaptation of the k8sobserver to use the new module has to be done in two separate PRs
|
@hvaghani221, @TylerHelmuth, @ChrsMark, @krisztianfekete please review as codeowners? |
|
3/5 code-owners approved and Tyler is out this week. I think we can merge this since it's an internal package addition and the actual refactoring will come as follow-up. |
Description
This PR refactors the
k8sobjectsreceiver by extracting the components responsible for receiving the K8s resources in the cluster into a separate package with anObserverinterface, and the pull/watch based implementations thereof.This package can then also be used by the
k8seventsreceiver, which would then only need to format the received events to conform with the semantic conventions.Link to tracking issue
Part of #40825 - next steps as part of this issue would be to also make use of the observer components in the k8seventsreceiver
Testing
Added tests for the new components. The tests for the receiver itself could be refactored to not use the concrete implementations of the Observer interface, but that should probably be done as a follow up to not make this PR too large