-
Notifications
You must be signed in to change notification settings - Fork 405
/
metrics.go
51 lines (41 loc) · 1.28 KB
/
metrics.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
41
42
43
44
45
46
47
48
49
50
51
package metrics
import (
"context"
"io"
"github.com/fnproject/fn/api/models"
"go.opencensus.io/trace"
)
func NewLogstore(ls models.LogStore) models.LogStore {
return &metricls{ls}
}
type metricls struct {
ls models.LogStore
}
func (m *metricls) InsertCall(ctx context.Context, call *models.Call) error {
ctx, span := trace.StartSpan(ctx, "ls_insert_call")
defer span.End()
return m.ls.InsertCall(ctx, call)
}
func (m *metricls) GetCall(ctx context.Context, fnID, callID string) (*models.Call, error) {
ctx, span := trace.StartSpan(ctx, "ls_get_call")
defer span.End()
return m.ls.GetCall(ctx, fnID, callID)
}
func (m *metricls) GetCalls(ctx context.Context, filter *models.CallFilter) (*models.CallList, error) {
ctx, span := trace.StartSpan(ctx, "ls_get_calls")
defer span.End()
return m.ls.GetCalls(ctx, filter)
}
func (m *metricls) InsertLog(ctx context.Context, call *models.Call, callLog io.Reader) error {
ctx, span := trace.StartSpan(ctx, "ls_insert_log")
defer span.End()
return m.ls.InsertLog(ctx, call, callLog)
}
func (m *metricls) GetLog(ctx context.Context, appName, callID string) (io.Reader, error) {
ctx, span := trace.StartSpan(ctx, "ls_get_log")
defer span.End()
return m.ls.GetLog(ctx, appName, callID)
}
func (m *metricls) Close() error {
return m.ls.Close()
}