[#44] add tracing support refactoring #53

Merged
alexvanin merged 1 commit from pogpp/frostfs-http-gw:feature/tracing_refactoring into master 2023-05-31 12:56:13 +00:00
Member

Closes #44
Signed-off-by: Pavel Pogodaev p.pogodaev@yadro.com

Closes #44 Signed-off-by: Pavel Pogodaev <p.pogodaev@yadro.com>
alexvanin requested review from alexvanin 2023-05-30 14:10:44 +00:00
alexvanin requested review from storage-services-committers 2023-05-30 14:10:44 +00:00
alexvanin requested review from storage-services-developers 2023-05-30 14:10:44 +00:00
alexvanin refused to review 2023-05-30 14:10:48 +00:00
alexvanin requested changes 2023-05-30 14:59:10 +00:00
alexvanin left a comment
Owner

Check fetchOwnerAndBearerToken() usage. It uses fasthttp.RequestCtx instead of ctx.

Check `fetchOwnerAndBearerToken()` usage. It uses `fasthttp.RequestCtx` instead of `ctx`.
@ -162,0 +158,4 @@
// // Expect to see the same token without errors.
// actual, err := LoadBearerToken(ctx)
// require.NoError(t, err)
// require.Equal(t, tkn, actual)
Owner

We can replace StoreBearerToken call with StoreBearerTokenAppCtx.

	// Expect to see the token within the context.
	appCtx, err := StoreBearerTokenAppCtx(ctx, context.Background())
	require.NoError(t, err)

	// Expect to see the same token without errors.
	actual, err := LoadBearerToken(appCtx)
	require.NoError(t, err)
	require.Equal(t, tkn, actual)
We can replace `StoreBearerToken` call with `StoreBearerTokenAppCtx`. ```go // Expect to see the token within the context. appCtx, err := StoreBearerTokenAppCtx(ctx, context.Background()) require.NoError(t, err) // Expect to see the same token without errors. actual, err := LoadBearerToken(appCtx) require.NoError(t, err) require.Equal(t, tkn, actual) ```
alexvanin marked this conversation as resolved
utils/util.go Outdated
@ -45,1 +46,4 @@
}
func AddToContext(ctx context.Context, c *fasthttp.RequestCtx) {
c.SetUserValue("context", ctx)
Owner

Put context into constant. Also it would be nice to add comments to a public functions in the package!

// AddToContext adds new context to fasthttp request.
Put `context` into constant. Also it would be nice to add comments to a public functions in the package! ``` // AddToContext adds new context to fasthttp request. ```
alexvanin marked this conversation as resolved
pogpp force-pushed feature/tracing_refactoring from 7988bed472 to 70cbf5285c 2023-05-30 16:39:19 +00:00 Compare
pogpp requested review from alexvanin 2023-05-31 07:47:33 +00:00
alexvanin approved these changes 2023-05-31 08:06:26 +00:00
dkirillov reviewed 2023-05-31 08:48:16 +00:00
utils/util.go Outdated
@ -46,0 +51,4 @@
}
// GetFromContext returns main context from fasthttp request context.
func GetFromContext(c *fasthttp.RequestCtx) context.Context {
Member

Let's rename these functions to

  • GetContext and SetContext or
  • GetFromRequest and SetToRequest or
  • GetContextFromRequest and SetContextToRequest
    ?
Let's rename these functions to * `GetContext` and `SetContext` or * `GetFromRequest` and `SetToRequest` or * `GetContextFromRequest` and `SetContextToRequest` ?
Owner

Last one seems good to me.

Last one seems good to me.
dkirillov reviewed 2023-05-31 08:53:23 +00:00
app.go Outdated
@ -101,6 +103,7 @@ func newApp(ctx context.Context, opt ...Option) App {
)
a := &app{
ctx: ctx,
Member

If we store appCtx to this, we now can:

  • drop appCtx from here and here
  • don't provide context here (use a.ctx inside a.initTracing, a.initTree, a.initServers and other similar places)
If we store appCtx to this, we now can: * drop `appCtx` from [here](https://git.frostfs.info/pogpp/frostfs-http-gw/src/commit/70cbf5285cce99a35139f722b091ebbacad3646a/uploader/upload.go#L32) and [here](https://git.frostfs.info/pogpp/frostfs-http-gw/src/commit/70cbf5285cce99a35139f722b091ebbacad3646a/downloader/download.go#L204) * don't provide context [here](https://git.frostfs.info/pogpp/frostfs-http-gw/src/commit/70cbf5285cce99a35139f722b091ebbacad3646a/main.go#L15) (use `a.ctx` inside `a.initTracing`, `a.initTree`, `a.initServers` and other similar places)
dkirillov reviewed 2023-05-31 08:54:48 +00:00
app.go Outdated
@ -503,2 +506,4 @@
}
func (a *app) tokenizer(h fasthttp.RequestHandler) fasthttp.RequestHandler {
return func(ctx *fasthttp.RequestCtx) {
Member

Since we started to rename variables with type *fasthttp.RequestCtx to req let's stick on it.

Since we started to rename variables with type `*fasthttp.RequestCtx` to `req` let's stick on it.
dkirillov reviewed 2023-05-31 08:54:54 +00:00
app.go Outdated
@ -505,0 +518,4 @@
}
func (a *app) tracer(h fasthttp.RequestHandler) fasthttp.RequestHandler {
return func(ctx *fasthttp.RequestCtx) {
Member

Since we started to rename variables with type *fasthttp.RequestCtx to req let's stick on it.

Since we started to rename variables with type `*fasthttp.RequestCtx` to `req` let's stick on it.
dkirillov reviewed 2023-05-31 08:57:38 +00:00
app.go Outdated
@ -505,0 +521,4 @@
return func(ctx *fasthttp.RequestCtx) {
appCtx := utils.GetFromContext(ctx)
appCtx, span := utils.StartHTTPServerSpan(appCtx, ctx, "OPERATION With Object")
Member

Maybe we should write REQUEST to http-gw instead of OPERATION With Object?

Maybe we should write `REQUEST to http-gw` instead of `OPERATION With Object`?
pogpp force-pushed feature/tracing_refactoring from 70cbf5285c to cdaab4feab 2023-05-31 12:09:58 +00:00 Compare
alexvanin merged commit cdaab4feab into master 2023-05-31 12:56:13 +00:00
alexvanin deleted branch feature/tracing_refactoring 2023-05-31 12:56:14 +00:00
Sign in to join this conversation.
No reviewers
TrueCloudLab/storage-services-developers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-http-gw#53
No description provided.