Skip to content

Commit

Permalink
add changes
Browse files Browse the repository at this point in the history
  • Loading branch information
etaques committed Oct 3, 2023
1 parent d0bdb73 commit 3c0eba9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
17 changes: 16 additions & 1 deletion sinks/api/http/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ package http

import (
"context"
"time"

"github.com/orb-community/orb/sinks"
"github.com/orb-community/orb/sinks/authentication_type"
"github.com/orb-community/orb/sinks/backend"
"go.uber.org/zap"
"time"
)

var _ sinks.SinkService = (*loggingMiddleware)(nil)
Expand Down Expand Up @@ -90,6 +91,20 @@ func (l loggingMiddleware) UpdateSinkInternal(ctx context.Context, s sinks.Sink)
return l.svc.UpdateSinkInternal(ctx, s)
}

func (l loggingMiddleware) UpdateSinkStatusInternal(ctx context.Context, s sinks.Sink) (sink sinks.Sink, err error) {
defer func(begin time.Time) {
if err != nil {
l.logger.Warn("method call: edit_internal_sink",
zap.Error(err),
zap.Duration("duration", time.Since(begin)))
} else {
l.logger.Debug("method call: edit_internal_sink",
zap.Duration("duration", time.Since(begin)))
}
}(time.Now())
return l.svc.UpdateSinkInternal(ctx, s)
}

func (l loggingMiddleware) ListSinks(ctx context.Context, token string, pm sinks.PageMetadata) (_ sinks.Page, err error) {
defer func(begin time.Time) {
if err != nil {
Expand Down
8 changes: 7 additions & 1 deletion sinks/api/http/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ package http

import (
"context"
"time"

"github.com/go-kit/kit/metrics"
"github.com/mainflux/mainflux"
"github.com/orb-community/orb/pkg/errors"
"github.com/orb-community/orb/sinks"
"github.com/orb-community/orb/sinks/authentication_type"
"github.com/orb-community/orb/sinks/backend"
"go.uber.org/zap"
"time"
)

var _ sinks.SinkService = (*metricsMiddleware)(nil)
Expand Down Expand Up @@ -96,6 +97,11 @@ func (m metricsMiddleware) UpdateSinkInternal(ctx context.Context, s sinks.Sink)
return m.svc.UpdateSinkInternal(ctx, s)
}

func (m metricsMiddleware) UpdateSinkStatusInternal(ctx context.Context, s sinks.Sink) (sink sinks.Sink, err error) {

return m.svc.UpdateSinkInternal(ctx, s)
}

func (m metricsMiddleware) ListSinks(ctx context.Context, token string, pm sinks.PageMetadata) (sink sinks.Page, err error) {
ownerID, err := m.identify(token)
if err != nil {
Expand Down

0 comments on commit 3c0eba9

Please sign in to comment.