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

feature: instrumentation for gofiber #356

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

levi-nz
Copy link

@levi-nz levi-nz commented Apr 9, 2022

Instrumentation for fiber, a very popular framework built on fasthttp.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@levi-nz levi-nz requested a review from a team as a code owner April 9, 2022 08:37
package xray

import (
"context"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we run gofmt -w -s ./... to format the files?

"github.com/aws/aws-xray-sdk-go/header"
"github.com/gofiber/fiber/v2"
)

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a description here?

}

// Handler wraps the provided fiber.Handler.
func (h *fiberHandler) Handler(sn SegmentNamer, handler fiber.Handler) fiber.Handler {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think probably a good idea to provide context as an argument of this method to provide abilities to cancel the context or pass the context with a deadline.

@@ -0,0 +1,37 @@
package xray

import (
Copy link
Contributor

Choose a reason for hiding this comment

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

We should add a benchmark here.

return
}

assert.Equal(t, fiber.StatusOK, rc.Response().StatusCode())
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably a good idea to validate all the three error flags fault, error and throttle.

"testing"
)

func TestFiberHandler(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

comment explaining what this test case is testing would be good for readability.

return func(ctx *fiber.Ctx) error {
auxCtx := context.Background()
if h.cfg != nil {
auxCtx = context.WithValue(context.Background(), fasthttpContextConfigKey, h.cfg)
Copy link
Contributor

Choose a reason for hiding this comment

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

not super familiar with gofiber but what I can tell is it's built on fasthttp and looks like we use the same key named as fasthttpContextConfigKey even in fasthttp instrumentation. Do you think that would cause any issue when both the instrumentation are used in a single application?

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.

2 participants