-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[elastic-agent] initial instrumentation #29031
Changes from 15 commits
53cbb1b
9f960a2
97f5658
234ab4e
8bf85e9
1303efc
be720ae
e81239a
c3fc48e
0e4f1f7
69c327b
696d0ea
8207973
55bd680
ba1b101
10d67d7
b9b5e5b
4dc7c89
49a08da
3956d45
c6f4aa2
a9620bc
eb315d9
b2560ae
4cf02d0
83c1979
e6ead42
e2b75fc
4b7fd3d
c89a52d
6f05e1b
5c2fddb
7657748
010bb60
8d9603a
d303e3d
92a87e2
c0b4b9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ package application | |
import ( | ||
"context" | ||
|
||
"go.elastic.co/apm" | ||
|
||
"github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/program" | ||
"github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/transpiler" | ||
"github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/sorted" | ||
|
@@ -51,6 +53,7 @@ func newFleetServerBootstrap( | |
rawConfig *config.Config, | ||
statusCtrl status.Controller, | ||
agentInfo *info.AgentInfo, | ||
tracer *apm.Tracer, | ||
) (*FleetServerBootstrap, error) { | ||
cfg, err := configuration.NewFromConfig(rawConfig) | ||
if err != nil { | ||
|
@@ -79,7 +82,7 @@ func newFleetServerBootstrap( | |
} | ||
|
||
bootstrapApp.bgContext, bootstrapApp.cancelCtxFn = context.WithCancel(ctx) | ||
bootstrapApp.srv, err = server.NewFromConfig(log, cfg.Settings.GRPC, &operation.ApplicationStatusHandler{}) | ||
bootstrapApp.srv, err = server.NewFromConfig(log, cfg.Settings.GRPC, &operation.ApplicationStatusHandler{}, tracer) | ||
if err != nil { | ||
return nil, errors.New(err, "initialize GRPC listener") | ||
} | ||
|
@@ -133,6 +136,7 @@ func (b *FleetServerBootstrap) Start() error { | |
if err := b.srv.Start(); err != nil { | ||
return err | ||
} | ||
// TODO: Does it make sense to pass in a ctx here? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you either clarify the TODOs and remove them or add a bit more detail, your github handle and/or a link to a follow up task? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 i should start writing "QUESTION" since that's what they really are, they just get highlighed when I use |
||
if err := b.source.Start(); err != nil { | ||
return err | ||
} | ||
|
@@ -166,20 +170,22 @@ func bootstrapEmitter(ctx context.Context, log *logger.Logger, agentInfo transpi | |
case c = <-ch: | ||
} | ||
|
||
err := emit(log, agentInfo, router, modifiers, c) | ||
err := emit(ctx, log, agentInfo, router, modifiers, c) | ||
if err != nil { | ||
log.Error(err) | ||
} | ||
} | ||
}() | ||
|
||
return func(c *config.Config) error { | ||
return func(ctx context.Context, c *config.Config) error { | ||
span, _ := apm.StartSpan(ctx, "emit", "app.internal") | ||
defer span.End() | ||
ch <- c | ||
return nil | ||
}, nil | ||
} | ||
|
||
func emit(log *logger.Logger, agentInfo transpiler.AgentInfo, router pipeline.Router, modifiers *pipeline.ConfigModifiers, c *config.Config) error { | ||
func emit(ctx context.Context, log *logger.Logger, agentInfo transpiler.AgentInfo, router pipeline.Router, modifiers *pipeline.ConfigModifiers, c *config.Config) error { | ||
if err := info.InjectAgentConfig(c); err != nil { | ||
return err | ||
} | ||
|
@@ -218,7 +224,7 @@ func emit(log *logger.Logger, agentInfo transpiler.AgentInfo, router pipeline.Ro | |
return errors.New("bootstrap configuration is incorrect causing fleet-server to not be started") | ||
} | ||
|
||
return router.Route(ast.HashStr(), map[pipeline.RoutingKey][]program.Program{ | ||
return router.Route(ctx, ast.HashStr(), map[pipeline.RoutingKey][]program.Program{ | ||
pipeline.DefaultRK: { | ||
{ | ||
Spec: spec, | ||
|
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.
Interesting I didn't know about go.elastic.co, when the restructuring of the repository is complete we should take a look a it. @kvch @cmacknz @ruflin
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.
TBH, I am not a huge fan of vanity imports. It looks great, but it is just vanity... :)