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

add APM instrumentation middleware module for Fiber framework #999

Merged
merged 8 commits into from Sep 16, 2021

Conversation

blessedvictim
Copy link
Contributor

@blessedvictim blessedvictim commented Aug 8, 2021

These changes add middleware to the fiber framework.

Closes #955

@cla-checker-service
Copy link

cla-checker-service bot commented Aug 8, 2021

💚 CLA has been signed

@elastic-apm-tech elastic-apm-tech added this to In Progress in APM-Agents (OLD) Aug 8, 2021
@apmmachine
Copy link
Collaborator

apmmachine commented Aug 8, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2021-09-16T06:51:00.261+0000

  • Duration: 31 min 0 sec

  • Commit: 4b7e055

Test stats 🧪

Test Results
Failed 0
Passed 11078
Skipped 268
Total 11346

Trends 🧪

Image of Build Times

Image of Tests

@axw
Copy link
Member

axw commented Aug 9, 2021

Thanks for the PR, @blessedvictim! I've taken a quick look over the PR and it looks good. Before I do a full review, can you please:

@blessedvictim blessedvictim force-pushed the add-apmfiber-module branch 2 times, most recently from 80e3173 to e67e92f Compare August 10, 2021 08:35
@blessedvictim
Copy link
Contributor Author

@axw hi, i already sign CLA and add license headers

@axw
Copy link
Member

axw commented Aug 10, 2021

@blessedvictim 2 of your comments are associated with a different email (@sports.ru). Can you please make sure all commits are created with the same email that you used to sign the CLA?

@blessedvictim blessedvictim force-pushed the add-apmfiber-module branch 2 times, most recently from 29c141d to 99a5c79 Compare August 10, 2021 10:25
@blessedvictim
Copy link
Contributor Author

@axw hi, there are still unresolved problems ?

@axw
Copy link
Member

axw commented Aug 13, 2021

Thanks for those updates @blessedvictim. Nothing blocking now. Someone will hopefully be able to review within the next week. We're just a bit busy at the moment.

Copy link
Contributor

@simitt simitt left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution! I do have a couple of remark, but the PR generally looks good.

Can you please add an entry to the supported tech stack doc and also an example showing how to use this module, similar to the fasthttp example.

module/apmfiber/middleware.go Show resolved Hide resolved
// be ignored. If r is nil, all requests will be reported.
func WithRequestIgnorer(fn apmfasthttp.RequestIgnorerFunc) Option {
if fn == nil {
panic("fn == nil")
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not aligned with the comment, but it should be - it should not panic because of an unset ignore function

If r is nil, all requests will be reported.

module/apmfiber/middleware.go Show resolved Hide resolved
module/apmfiber/middleware.go Show resolved Hide resolved
tracer *apm.Tracer
requestIgnorer apmfasthttp.RequestIgnorerFunc
panicPropagation bool
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think introducing this type is necesarry, you should be able to use the middleware.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed


resp, err := e.Test(req)
assert.Nil(t, err)
assert.Equal(t, resp.StatusCode, http.StatusInternalServerError)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you also test for the recovered error?

@misuto
Copy link

misuto commented Aug 22, 2021

I'm also interested in this functionality. I could help by fixing the parts brought up in the comments above but i'm not sure how to wrangle the branches to make this as painless as possible. I guess i should branch from blessedvictim:add-apmfiber-module but don't know to where i should target the PR. Which is the preferred way to do this?

@axw
Copy link
Member

axw commented Aug 26, 2021

@misuto thanks for the offer. Let's wait for @blessedvictim to respond.

@blessedvictim blessedvictim force-pushed the add-apmfiber-module branch 2 times, most recently from 0b4e7bc to e0d5b29 Compare August 26, 2021 20:43
@blessedvictim
Copy link
Contributor Author

it seems the mentioned issues are fixed now

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.

Thanks @blessedvictim, looks great! Just a few, very minor, comments on the code.

Not sure if you saw @simitt's request?

Can you please add an entry to the supported tech stack doc and also an example showing how to use this module, similar to the fasthttp example.

Then there are a couple of other small things that need to be updated before this can be merged, by running make fmt scripts/Dockerfile-testing.

tx.Name = string(reqCtx.Method()) + " unknown route"
} else {
// Workaround for set tx.Name as template path, not absolute
tx.Name = string(reqCtx.Method()) + " " + c.Route().Path
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
tx.Name = string(reqCtx.Method()) + " " + c.Route().Path
tx.Name = string(reqCtx.Method()) + " " + path

Comment on lines 88 to 90
defer func() {
panic(v)
}()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
defer func() {
panic(v)
}()
defer panic(v)

//go:build go1.12
// +build go1.12

package apmfiber
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
package apmfiber
package apmfiber // import "go.elastic.co/apm/module/apmfiber"

(this is needed to satisfy make check)

@axw
Copy link
Member

axw commented Aug 29, 2021

jenkins run the tests please

module/apmfiber/middleware.go Outdated Show resolved Hide resolved
@axw
Copy link
Member

axw commented Sep 1, 2021

@blessedvictim please let us know if you would like any help with the remaining requested changes. If you'd like, we can make the changes and push to your branch and merge.

@blessedvictim blessedvictim force-pushed the add-apmfiber-module branch 2 times, most recently from 69374ed to 8ce1a9c Compare September 1, 2021 15:21
@blessedvictim
Copy link
Contributor Author

@axw added an example and some description for the apmfiber. Seems like all requested changes done, isn't it ?

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.

Doc addition looks good, thanks - just a couple of minor formatting/copy-paste issues.

A couple of other things remaining:

  • run make scripts/Dockerfile-testing (needed for our CI to pass)
  • merge master. There was a minor breaking change to the apmfasthttp exported API recently, the order of args to apmfasthttp.StartTransactionWithBody has changed

docs/instrumenting.asciidoc Outdated Show resolved Hide resolved
docs/instrumenting.asciidoc Outdated Show resolved Hide resolved
blessedvictim added 3 commits September 2, 2021 11:29
delete options type
restore WithPanicPropagation
add tests for WithPanicPropagation
add tests for WithRequestIgnorer
@blessedvictim blessedvictim force-pushed the add-apmfiber-module branch 2 times, most recently from 5427d41 to 648b37a Compare September 2, 2021 08:38
@blessedvictim
Copy link
Contributor Author

@axw I notify you that the noticed problems have been fixed. Is there any other blockers ?

@axw
Copy link
Member

axw commented Sep 10, 2021

/test

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.

Looks great, thank you very much for your contribution @blessedvictim! Just need to wait for CI to be happy, then we'll merge.

@axw axw enabled auto-merge (squash) September 10, 2021 00:57
@axw
Copy link
Member

axw commented Sep 10, 2021

jenkins run the tests please

module/apmfiber/middleware_test.go Show resolved Hide resolved
module/apmfiber/go.mod Show resolved Hide resolved
increase  go version in build tag
auto-merge was automatically disabled September 15, 2021 09:38

Head branch was pushed to by a user without write access

@axw
Copy link
Member

axw commented Sep 15, 2021

Thanks @blessedvictim. There are some test failures on older versions of Go, which I think are probably unrelated to your changes. I'll investigate tomorrow and merge if I can sort out the issues.

@axw axw enabled auto-merge (squash) September 16, 2021 06:51
@axw
Copy link
Member

axw commented Sep 16, 2021

@elasticmachine, run elasticsearch-ci/docs

@axw axw disabled auto-merge September 16, 2021 07:48
@axw axw merged commit bc8b25e into elastic:master Sep 16, 2021
APM-Agents (OLD) automation moved this from In Progress to Done Sep 16, 2021
@axw
Copy link
Member

axw commented Sep 16, 2021

Thanks again for your contribution @blessedvictim!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

Fiber integration
5 participants