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

New tracer #3836

Merged
merged 17 commits into from
Jun 25, 2020
Merged

New tracer #3836

merged 17 commits into from
Jun 25, 2020

Conversation

jalvz
Copy link
Contributor

@jalvz jalvz commented Jun 2, 2020

Motivation/summary

Checklist

I have considered changes for:

How to test these changes

Related issues

elastic/beats#18861

beater/tracing.go Outdated Show resolved Hide resolved
@apmmachine
Copy link
Contributor

apmmachine commented Jun 3, 2020

💚 Build Succeeded

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #3836 updated]

  • Start Time: 2020-06-25T06:23:01.171+0000

  • Duration: 52 min 39 sec

Test stats 🧪

Test Results
Failed 0
Passed 3211
Skipped 147
Total 3358

Steps errors

Expand to view the steps failures

  • Name: Compress

    • Description: tar --exclude=coverage-files.tgz -czf coverage-files.tgz coverage

    • Duration: 0 min 0 sec

    • Start Time: 2020-06-25T06:37:49.586+0000

    • log

  • Name: Compress

    • Description: tar --exclude=system-tests-linux-files.tgz -czf system-tests-linux-files.tgz system-tests

    • Duration: 0 min 0 sec

    • Start Time: 2020-06-25T06:49:11.117+0000

    • log

  • Name: Test Sync

    • Description: ./script/jenkins/sync.sh

    • Duration: 3 min 38 sec

    • Start Time: 2020-06-25T06:33:09.084+0000

    • log

@jalvz
Copy link
Contributor Author

jalvz commented Jun 18, 2020

Notes:

  • make update after beats update failed with
  File "script/generate_notice.py", line 354, in <module>
    modules = gather_modules(args.main_package, args.build_tags)
  File "script/generate_notice.py", line 118, in gather_modules
    print("WARNING: Unknown license for {}: {}".format(modpath, os.path.join(root, filename)))
NameError: name 'root' is not defined

python ./script/generate_notice.py seemed to fix, but don't know why there is a huge diff.

  • TestServerTracingExternal still failing. But i'd say this should be moved to libbeat. Thoughts?

@jalvz jalvz marked this pull request as ready for review June 18, 2020 13:54
@jalvz jalvz requested a review from axw June 18, 2020 13:54
@axw
Copy link
Member

axw commented Jun 23, 2020

make update after beats update failed with

File "script/generate_notice.py", line 354, in
modules = gather_modules(args.main_package, args.build_tags)
File "script/generate_notice.py", line 118, in gather_modules
print("WARNING: Unknown license for {}: {}".format(modpath, os.path.join(root, filename)))
NameError: name 'root' is not defined

There's an error in the script; like it says, root is an undefined variable - my mistake. However, that line is only reached when there's an unknown license found... so that needs to be fixed. I fixed the script locally and it's triggered by https:/elastic/elastic-agent-client/blob/master/LICENSE.txt. We'll just need to add detection of the Elastic License. I'll look into this.

python ./script/generate_notice.py seemed to fix, but don't know why there is a huge diff.

If you run the script directly, it's not going to be run the same as when you run make update. See the Makefile:

@$(PYTHON) script/generate_notice.py -b "Elastic APM Server" -s "github.com/elastic/beats*" . ./x-pack/apm-server

I suppose the error is only occurring through make update because it includes x-pack packages, which will import elastic-agent-client.

@axw axw mentioned this pull request Jun 23, 2020
2 tasks
_meta/beat.yml Outdated Show resolved Hide resolved
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)
Copy link
Member

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"

Copy link
Contributor Author

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?

Copy link
Member

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
}

Copy link
Contributor Author

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

Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Member

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.

beater/beater.go Outdated Show resolved Hide resolved
@axw
Copy link
Member

axw commented Jun 23, 2020

TestServerTracingExternal still failing. But i'd say this should be moved to libbeat. Thoughts?

That sounds good to me.

@jalvz
Copy link
Contributor Author

jalvz commented Jun 23, 2020

So tests relying on beater_tests.newInstrumentation fail now, I'm kinda stuck with those.
I think those tests should actually be moved system tests (i mean the ones in Python).
Anyone against?

@axw
Copy link
Member

axw commented Jun 24, 2020

So tests relying on beater_tests.newInstrumentation fail now, I'm kinda stuck with those.
I think those tests should actually be moved system tests (i mean the ones in Python).
Anyone against?

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 libbeat/instrumentation.New rather than duplicating logic.

beater/tracing.go Outdated Show resolved Hide resolved
Copy link
Member

@axw axw left a 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 {
Copy link
Member

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)
Copy link
Member

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?

@jalvz jalvz merged commit 6ba318f into elastic:master Jun 25, 2020
jalvz added a commit to jalvz/apm-server that referenced this pull request Jun 30, 2020
@jalvz jalvz mentioned this pull request Jun 30, 2020
10 tasks
jalvz added a commit that referenced this pull request Jul 1, 2020
* 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]>
jalvz added a commit to jalvz/apm-server that referenced this pull request Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants