Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[usm] service discovery, replace the args list with a struct in detect functions #30076

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

yuri-lipnesh
Copy link
Contributor

@yuri-lipnesh yuri-lipnesh commented Oct 12, 2024

What does this PR do?

This code replaces the argument list with a structure in the detect() function and sub-functions in system-probe service discovery.

Motivation

make service discovery functions flexible for future additions

Describe how to test/QA your changes

Possible Drawbacks / Trade-offs

Additional Notes

current implementation replaces list of arguments with existing structure usm.DetectionContext.
The size of this struct is 64 bytes, which is most likely equal to CPU cache line (64 bytes).
This struct is passed by value, consider passing the structure as a pointer instead of a value.

@yuri-lipnesh yuri-lipnesh added changelog/no-changelog component/system-probe team/usm The USM team team/apm-onboarding qa/done Skip QA week as QA was done before merge and regressions are covered by tests labels Oct 12, 2024
@yuri-lipnesh yuri-lipnesh requested review from a team as code owners October 12, 2024 13:28
@agent-platform-auto-pr
Copy link
Contributor

agent-platform-auto-pr bot commented Oct 12, 2024

Test changes on VM

Use this command from test-infra-definitions to manually test this PR changes on a VM:

inv create-vm --pipeline-id=46937424 --os-family=ubuntu

Note: This applies to commit bdf4a72

Copy link

Regression Detector

Copy link
Contributor

@vitkyrka vitkyrka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the title of the PR description will be used in the squashed commit's summary line, so any prefixes should be added there.

@@ -38,7 +38,7 @@ const (
Injected Instrumentation = "injected"
)

type detector func(pid int, args []string, envs envs.Variables, contextMap usm.DetectorContextMap) Instrumentation
type detector func(dc usm.DetectionContext) Instrumentation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe call the parameter context or ctx instead of dc which is not so transparent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -50,7 +50,8 @@ func TestServiceNameFromCLI(t *testing.T) {
expected: "",
},
}
instance := &phpDetector{ctx: NewDetectionContext(nil, envs.NewVariables(nil), nil)}
dc := NewDetectionContext(0, nil, envs.NewVariables(nil), nil, nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe if you leave the signature of NewDetectionContext() as-is but add a new constructor for the callsite which need it then you don't have to go in and another nil everywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've restored signature of NewDetectionContext()

@@ -619,12 +619,13 @@ func TestExtractServiceMetadata(t *testing.T) {
t.Skip("Not supported on Windows")
}

var fs fs.SubFS
fs = RealFs{}
var f fs.SubFS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this variable name changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my IDE showed warning that name collides with imported package, I restored name as it was

@yuri-lipnesh yuri-lipnesh changed the title replace the args list with a struct in the service discovery detect functions [usm] service discovery, replace the args list with a struct in detect functions Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog component/system-probe qa/done Skip QA week as QA was done before merge and regressions are covered by tests team/apm-onboarding team/usm The USM team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants