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

beater: CreatorParams.RunServer -> WrapRunServer #3803

Merged
merged 2 commits into from
May 20, 2020

Conversation

axw
Copy link
Member

@axw axw commented May 19, 2020

Motivation/summary

Rather than passing in a RunServerFunc to CreatorParams,
pass in a function that can wrap a RunServerFunc. This
enables us to run the tracer server with an overridden reporter,
such as the one provided by the transaction histogram
aggregator.

We unexport beater.RunServer to ensure wrappers do not
mistakenly call it directly, rather than going through the
RunServerFunc provided to them.

Checklist

I have considered changes for:
- [ ] documentation
- [ ] logging (add log lines, choose appropriate log selector, etc.)
- [ ] metrics and monitoring (create issue for Kibana team to add metrics to visualizations, e.g. Kibana#44001)

How to test these changes

  • Enable self-instrumentation
  • Enable aggregation
  • Send some traces to the server
  • Wait for the server to record transaction.duration.histogram metrics docs for the API requests

Related issues

Fixes #3801

Rather than passing in a RunServerFunc to CreatorParams,
pass in a function that can wrap a RunServerFunc, like
middleware. This enables us to run the tracer server
with an overridden reporter, such as the one provided
by the transaction histogram aggregator.

Unexport beater.RunServer to ensure wrappers do not
mistakenly call it directly, rather than going through
the RunServerFunc provided to them.
@codecov-commenter
Copy link

codecov-commenter commented May 19, 2020

Codecov Report

Merging #3803 into master will increase coverage by 0.06%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #3803      +/-   ##
==========================================
+ Coverage   79.83%   79.89%   +0.06%     
==========================================
  Files         136      136              
  Lines        6158     6158              
==========================================
+ Hits         4916     4920       +4     
+ Misses       1242     1238       -4     
Impacted Files Coverage Δ
x-pack/apm-server/main.go 0.00% <ø> (ø)
beater/beater.go 71.90% <100.00%> (+1.90%) ⬆️
beater/server.go 69.04% <100.00%> (ø)
beater/jaeger/common.go 78.78% <0.00%> (-6.07%) ⬇️
kibana/connecting_client.go 72.58% <0.00%> (+4.83%) ⬆️

@apmmachine
Copy link
Contributor

apmmachine commented May 19, 2020

💚 Build Succeeded

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

Test stats 🧪

Test Results
Failed 0
Passed 3227
Skipped 145
Total 3372

@@ -137,7 +135,7 @@ func (bt *beater) Run(b *beat.Beat) error {
}
defer tracer.Close()

runServer := bt.runServer
runServer := runServer
Copy link
Contributor

Choose a reason for hiding this comment

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

For clarity, can't you move L144 up here, and wrap that same origRunServer in L166?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not too sure what you mean, but I've extracted this tracer-related code to a separate function. Hopefully that will clarify things, let me know.

@axw axw merged commit dad2676 into elastic:master May 20, 2020
@axw axw deleted the beater-wraprunserver branch May 20, 2020 08:06
axw added a commit to axw/apm-server that referenced this pull request May 20, 2020
* beater: CreatorParams.RunServer -> WrapRunServer

Rather than passing in a RunServerFunc to CreatorParams,
pass in a function that can wrap a RunServerFunc, like
middleware. This enables us to run the tracer server
with an overridden reporter, such as the one provided
by the transaction histogram aggregator.

Unexport beater.RunServer to ensure wrappers do not
mistakenly call it directly, rather than going through
the RunServerFunc provided to them.

* beater: extract runServerWithTracerServer
axw added a commit to axw/apm-server that referenced this pull request May 20, 2020
* beater: CreatorParams.RunServer -> WrapRunServer

Rather than passing in a RunServerFunc to CreatorParams,
pass in a function that can wrap a RunServerFunc, like
middleware. This enables us to run the tracer server
with an overridden reporter, such as the one provided
by the transaction histogram aggregator.

Unexport beater.RunServer to ensure wrappers do not
mistakenly call it directly, rather than going through
the RunServerFunc provided to them.

* beater: extract runServerWithTracerServer
axw added a commit that referenced this pull request May 20, 2020
* beater: CreatorParams.RunServer -> WrapRunServer

Rather than passing in a RunServerFunc to CreatorParams,
pass in a function that can wrap a RunServerFunc, like
middleware. This enables us to run the tracer server
with an overridden reporter, such as the one provided
by the transaction histogram aggregator.

Unexport beater.RunServer to ensure wrappers do not
mistakenly call it directly, rather than going through
the RunServerFunc provided to them.

* beater: extract runServerWithTracerServer
axw added a commit that referenced this pull request May 20, 2020
* beater: CreatorParams.RunServer -> WrapRunServer

Rather than passing in a RunServerFunc to CreatorParams,
pass in a function that can wrap a RunServerFunc, like
middleware. This enables us to run the tracer server
with an overridden reporter, such as the one provided
by the transaction histogram aggregator.

Unexport beater.RunServer to ensure wrappers do not
mistakenly call it directly, rather than going through
the RunServerFunc provided to them.

* beater: extract runServerWithTracerServer
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.

Transaction duration metrics not published for apm-server
4 participants