/
tracing.go
40 lines (30 loc) · 1.39 KB
/
tracing.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package catalog
import (
"context"
"github.com/estafette/estafette-ci-api/pkg/api"
contracts "github.com/estafette/estafette-ci-contracts"
"github.com/opentracing/opentracing-go"
)
// NewTracingService returns a new instance of a tracing Service.
func NewTracingService(s Service) Service {
return &tracingService{s, "estafette"}
}
type tracingService struct {
Service Service
prefix string
}
func (s *tracingService) CreateCatalogEntity(ctx context.Context, catalogEntity contracts.CatalogEntity) (insertedCatalogEntity *contracts.CatalogEntity, err error) {
span, ctx := opentracing.StartSpanFromContext(ctx, api.GetSpanName(s.prefix, "CreateCatalogEntity"))
defer func() { api.FinishSpanWithError(span, err) }()
return s.Service.CreateCatalogEntity(ctx, catalogEntity)
}
func (s *tracingService) UpdateCatalogEntity(ctx context.Context, catalogEntity contracts.CatalogEntity) (err error) {
span, ctx := opentracing.StartSpanFromContext(ctx, api.GetSpanName(s.prefix, "UpdateCatalogEntity"))
defer func() { api.FinishSpanWithError(span, err) }()
return s.Service.UpdateCatalogEntity(ctx, catalogEntity)
}
func (s *tracingService) DeleteCatalogEntity(ctx context.Context, id string) (err error) {
span, ctx := opentracing.StartSpanFromContext(ctx, api.GetSpanName(s.prefix, "DeleteCatalogEntity"))
defer func() { api.FinishSpanWithError(span, err) }()
return s.Service.DeleteCatalogEntity(ctx, id)
}