mirror of
https://github.com/mainflux/mainflux.git
synced 2025-04-24 13:48:49 +08:00
Remove Spans From Tokenizer Repository Under Users Service (#1847)
Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Co-authored-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
This commit is contained in:
parent
ed0436f0ae
commit
cc0b90a7cb
@ -39,7 +39,6 @@ import (
|
||||
gtracing "github.com/mainflux/mainflux/users/groups/tracing"
|
||||
"github.com/mainflux/mainflux/users/hasher"
|
||||
"github.com/mainflux/mainflux/users/jwt"
|
||||
jtracing "github.com/mainflux/mainflux/users/jwt/tracing"
|
||||
"github.com/mainflux/mainflux/users/policies"
|
||||
papi "github.com/mainflux/mainflux/users/policies/api"
|
||||
grpcapi "github.com/mainflux/mainflux/users/policies/api/grpc"
|
||||
@ -189,7 +188,6 @@ func newService(ctx context.Context, db *sqlx.DB, tracer trace.Tracer, c config,
|
||||
logger.Error(fmt.Sprintf("failed to parse refresh token duration: %s", err.Error()))
|
||||
}
|
||||
tokenizer := jwt.NewRepository([]byte(c.SecretKey), aDuration, rDuration)
|
||||
tokenizer = jtracing.New(tokenizer, tracer)
|
||||
|
||||
emailer, err := emailer.New(c.ResetURL, &ec)
|
||||
if err != nil {
|
||||
|
@ -1,12 +0,0 @@
|
||||
// Copyright (c) Mainflux
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Package tracing provides tracing instrumentation for Mainflux WebSocket adapter service.
|
||||
//
|
||||
// This package provides tracing middleware for Mainflux WebSocket adapter service.
|
||||
// It can be used to trace incoming requests and add tracing capabilities to
|
||||
// Mainflux WebSocket adapter service.
|
||||
//
|
||||
// For more details about tracing instrumentation for Mainflux messaging refer
|
||||
// to the documentation at https://docs.mainflux.io/tracing/.
|
||||
package tracing
|
@ -1,47 +0,0 @@
|
||||
// Copyright (c) Mainflux
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package tracing
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/mainflux/mainflux/users/jwt"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
var _ jwt.Repository = (*tokenRepoMiddlware)(nil)
|
||||
|
||||
type tokenRepoMiddlware struct {
|
||||
repo jwt.Repository
|
||||
tracer trace.Tracer
|
||||
}
|
||||
|
||||
// New returns a new jwt service with tracing capabilities.
|
||||
func New(repo jwt.Repository, tracer trace.Tracer) jwt.Repository {
|
||||
return &tokenRepoMiddlware{
|
||||
repo: repo,
|
||||
tracer: tracer,
|
||||
}
|
||||
}
|
||||
|
||||
func (trm tokenRepoMiddlware) Issue(ctx context.Context, claim jwt.Claims) (jwt.Token, error) {
|
||||
ctx, span := trm.tracer.Start(ctx, "issue_token", trace.WithAttributes(
|
||||
attribute.String("client_id", claim.ClientID),
|
||||
attribute.String("email", claim.Email),
|
||||
attribute.String("type", claim.Type),
|
||||
))
|
||||
defer span.End()
|
||||
|
||||
return trm.repo.Issue(ctx, claim)
|
||||
}
|
||||
|
||||
func (trm tokenRepoMiddlware) Parse(ctx context.Context, accessToken string) (jwt.Claims, error) {
|
||||
ctx, span := trm.tracer.Start(ctx, "parse_token", trace.WithAttributes(
|
||||
attribute.String("accesstoken", accessToken),
|
||||
))
|
||||
defer span.End()
|
||||
|
||||
return trm.repo.Parse(ctx, accessToken)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user