From cc0b90a7cb1d0bf0a5e4d0027cc262bc34ac457c Mon Sep 17 00:00:00 2001 From: b1ackd0t Date: Tue, 11 Jul 2023 23:31:49 +0300 Subject: [PATCH] Remove Spans From Tokenizer Repository Under Users Service (#1847) Signed-off-by: rodneyosodo Co-authored-by: Drasko DRASKOVIC --- cmd/users/main.go | 2 -- users/jwt/tracing/doc.go | 12 --------- users/jwt/tracing/tracing.go | 47 ------------------------------------ 3 files changed, 61 deletions(-) delete mode 100644 users/jwt/tracing/doc.go delete mode 100644 users/jwt/tracing/tracing.go diff --git a/cmd/users/main.go b/cmd/users/main.go index dce3259946e..104a6320f81 100644 --- a/cmd/users/main.go +++ b/cmd/users/main.go @@ -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 { diff --git a/users/jwt/tracing/doc.go b/users/jwt/tracing/doc.go deleted file mode 100644 index fb1b6896e4e..00000000000 --- a/users/jwt/tracing/doc.go +++ /dev/null @@ -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 diff --git a/users/jwt/tracing/tracing.go b/users/jwt/tracing/tracing.go deleted file mode 100644 index da348733617..00000000000 --- a/users/jwt/tracing/tracing.go +++ /dev/null @@ -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) -}