Skip to content

feature: instrumentation for gofiber#356

Open
leafypout wants to merge 2 commits intoaws:masterfrom
leafypout:master
Open

feature: instrumentation for gofiber#356
leafypout wants to merge 2 commits intoaws:masterfrom
leafypout:master

Conversation

@leafypout
Copy link
Copy Markdown

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.

@leafypout leafypout requested a review from a team as a code owner April 9, 2022 08:37
Comment thread xray/fiber.go
package xray

import (
"context"
Copy link
Copy Markdown
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?

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

Copy link
Copy Markdown
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?

Comment thread xray/fiber.go
}

// Handler wraps the provided fiber.Handler.
func (h *fiberHandler) Handler(sn SegmentNamer, handler fiber.Handler) fiber.Handler {
Copy link
Copy Markdown
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.

Comment thread xray/fiber_test.go
@@ -0,0 +1,37 @@
package xray

import (
Copy link
Copy Markdown
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.

Comment thread xray/fiber_test.go
return
}

assert.Equal(t, fiber.StatusOK, rc.Response().StatusCode())
Copy link
Copy Markdown
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.

Comment thread xray/fiber_test.go
"testing"
)

func TestFiberHandler(t *testing.T) {
Copy link
Copy Markdown
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.

Comment thread xray/fiber.go
return func(ctx *fiber.Ctx) error {
auxCtx := context.Background()
if h.cfg != nil {
auxCtx = context.WithValue(context.Background(), fasthttpContextConfigKey, h.cfg)
Copy link
Copy Markdown
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