-
Notifications
You must be signed in to change notification settings - Fork 527
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
New tracer #3836
New tracer #3836
Conversation
💚 Build SucceededExpand to view the summary
Build stats
Test stats 🧪
Steps errorsExpand to view the steps failures
|
Notes:
|
There's an error in the script; like it says,
If you run the script directly, it's not going to be run the same as when you run Line 130 in 3d62fee
I suppose the error is only occurring through |
beater/beater.go
Outdated
useLegacyTracer := common.MustNewVersion(version.GetDefaultVersion()).LessThan(&common.Version{Major: 8, Minor: 0}) | ||
|
||
if !tracer.Active() && useLegacyTracer { | ||
tracer, tracerServer, err = initLegacyTracer(b.Info, bt.config, bt.logger) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of holding onto that old code, can we instead dynamically rename apm-server.instrumentation
to instrumentation
, if the latter doesn't exist in the config?
I think we can do this by defining a ConfigOverride in libbeat/cmd/instance.Settings, whose Check method checks for existing "instrumentation", and if not specified sets it to "apm-server.instrumentation"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm how would that exactly work?
{
Check: func(cfg *common.Config) bool {
return cfg.HasField("instrumentation")
},
Config: ???
Config
is just a config, not a function, so how do I copy apm-server.instrumentation
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant make Check
do the modification. It would be a bit of a hack, so it should really be replaced with something more fit for purpose. But in the mean time...
Check: func(cfg *common.Config) bool {
if !cfg.HasField("instrumentation") {
// Check if cfg has "apm-server.instrumentation", and rename it to "instrumentation"
}
return true
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, uh. that's quite a hack, yes..
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about not using Check
but changing libbeatConfigOverride
to be a function and taking care of the overwrite there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But how do I pass to a function the original config I need to copy?
Or you mean to change the whole thing in libbeat?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I presume @simitt meant changing libbeat. I think that's the right long-term solution. IMO, ConditionalOverride
should be an implementation of an interface like ConfigTransformer
:
type ConfigTransformer interface {
// TransformConfig transforms the provided config, returning a possibly modified config.
TransformConfig(*common.Config) (*common.Config, error)
}
type ConditionalOverride struct {
Check OverrideChecker
Config *common.Config
}
func (o *ConditionalOverride) TransformConfig(in *common.Config) (*common.Config, error) {
if !o.Check(in) {
return in, nil
}
return common.MergeConfigs(in, o.Config)
}
We could then provide an alternative implementation of that interface which does what we need.
That sounds good to me. |
So tests relying on |
I'm OK with that. It feels a bit heavy, but it's not code that needs to change often so I guess unit tests aren't really needed. BTW, the issue with those tests is that you created a tracer but didn't configure its transport to send to the listener. If you do stick with the unit tests, maybe use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a couple of minor things.
}), | ||
}, | ||
{ | ||
Check: func(cfg *common.Config) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add a TODO here to update libbeat, adding a more fit for purpose API?
cmd/root_test.go
Outdated
) | ||
|
||
func TestOverrideLegacyInstrumentationConfig(t *testing.T) { | ||
cfg, err := cfgfile.Load("tests/legacy_instrumentation.yml", libbeatConfigOverrides) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's conventional to add test-related data files in a directory called "testdata", which the go
tool has a special case to ignore when listing packages and such. Can you please rename?
* script: add detection of Elastic License * Support new instrumentation config and tracer from Libbeat (#3836) * Update beats framework to f9b5f18382ac Co-authored-by: Andrew Wilkins <[email protected]>
…lastic#3836)" This reverts commit 6ba318f.
Motivation/summary
Checklist
I have considered changes for:
How to test these changes
Related issues
elastic/beats#18861