-
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
Add basic configuration for the APM tracer #18861
Conversation
Pinging @elastic/integrations (Team:Integrations) |
💔 Tests FailedExpand to view the summary
Build stats
Test stats 🧪
Test errorsExpand to view the tests failures
--------------------- >> end captured stdout << ----------------------
Steps errorsExpand to view the steps failures
Log outputExpand to view the last 100 lines of log output
|
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.
Looks great! Much more straightforward than the approach I had in mind originally.
Co-authored-by: Andrew Wilkins <[email protected]>
Co-authored-by: Andrew Wilkins <[email protected]>
Co-authored-by: Andrew Wilkins <[email protected]>
Co-authored-by: Andrew Wilkins <[email protected]>
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 once the config files are updated to render conditionally on apm-server.
@urso / @ycombinator can any of you have a look at this, or assign it to someone else? Thanks. |
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.
Do we need to add docs about enabling instrumentation in beats? Please add the needs_docs
label if you plan to add docs later.
libbeat/beat/instrumentation.go
Outdated
// Listener is only relevant for APM Server sending tracing data to itself | ||
// APM Server needs this Listener to create an ad-hoc tracing server | ||
Listener net.Listener | ||
} |
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.
The 'libbeat/beat' package should be the minimal package with public API that is required to implement a custom Beat. It should provide mostly interfaces only. Can we move this functionality into a separate package and turn 'Instrumentation' into an interface? Do we even need Instrumentation
or would it be enough to have a Tracer within the Beat structure?
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.
Done. Just the Tracer is not enough, thou - we need the Listener
libbeat/cmd/instance/beat.go
Outdated
Logging *common.Config `config:"logging"` | ||
MetricLogging *common.Config `config:"logging.metrics"` | ||
Keystore *common.Config `config:"keystore"` | ||
Instrumentation *common.Config `config:"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 know there are no clear rules, but I'd prefer to use concrete types and only use common.Config if we really need it (e.g. capture a configuration without interpreting it yet). You might consider to change this line to Instrumentation instrumentation.Config
).
// Instrumentation is an interface that can return an APM tracer a net.listener | ||
type Instrumentation interface { | ||
Tracer() *apm.Tracer | ||
Listener() net.Listener |
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'm curious, but why do we need the Listener here? Is it still for apm-server itself, or is it some general requirement? I didn't see the listener used.
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.
Yes, it is for apm-server: we need to create an adhoc tracing server so it doesn't send traces to itself infinitely. Possibly this can be useful for the Elastic Agent too.
This includes an instrumentation namespace at the top of all beat config files. The tracer is exposed trough the Beat object.
This includes an instrumentation namespace at the top of all beat config files. The tracer is exposed trough the Beat object.
This includes an instrumentation namespace at the top of all beat config files. The tracer is exposed trough the Beat object.
What does this PR do?
This adds configuration for the APM tracer, and sets it on the
Beat
object so that every Beat can use it.Libbeat is responsible for correct initialization and closing.
A top level
instrumentation
config option is added tolibbeat.yml
/reference.yml
to set it up, disabled by default.Why is it important?
Dogfooding!
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
Run any beat with configuration enabled and disabled, alongside with APM Server, Elasticsearch and Kibana. Observe
output
transactions (or lack thereof when disabled) in the Kibana APM tab, coming from the libbeat publisher.Related issues
Closes #18360
An APM Server PR showing how to use the tracer from the Beat is coming up soon.