-
Notifications
You must be signed in to change notification settings - Fork 117
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
base: master
Are you sure you want to change the base?
Conversation
package xray | ||
|
||
import ( | ||
"context" |
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.
Can we run gofmt -w -s ./...
to format the files?
"github.com/aws/aws-xray-sdk-go/header" | ||
"github.com/gofiber/fiber/v2" | ||
) | ||
|
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.
Can we add a description here?
} | ||
|
||
// Handler wraps the provided fiber.Handler. | ||
func (h *fiberHandler) Handler(sn SegmentNamer, handler fiber.Handler) fiber.Handler { |
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 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 ( |
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.
We should add a benchmark here.
return | ||
} | ||
|
||
assert.Equal(t, fiber.StatusOK, rc.Response().StatusCode()) |
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.
Probably a good idea to validate all the three error flags fault
, error
and throttle
.
"testing" | ||
) | ||
|
||
func TestFiberHandler(t *testing.T) { |
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.
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) |
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.
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?
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.