Files
fn-serverless/api/logs/metrics/metrics.go
Tom Coupland c3537399f1 The V2 Calls api endpoints have been added beneath fns: (#1203)
/fns/{fnID}/calls
/fns/{fnID}/calls/{callID}

The S3 implementation forces our hand as we if we want to list Calls
under a Fn, we have to use the FnID as a prefix on the object names,
which mean we need it to look up any Call. It also makes sense in
terms of resource hierarchy.

These endpoints can optionally be disabled (as other endpoints), if a
service provider needs to provide this functionality via other means.

The 'calls' test has been fully migrated to fn calls. This has been
done to reduce the copy pasta a bit, and on balance is ok as the
routes calls will be removed soon.
2018-09-12 15:45:53 +01:00

64 lines
1.7 KiB
Go

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) GetCall1(ctx context.Context, appName, callID string) (*models.Call, error) {
ctx, span := trace.StartSpan(ctx, "ls_get_call")
defer span.End()
return m.ls.GetCall1(ctx, appName, callID)
}
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) GetCalls1(ctx context.Context, filter *models.CallFilter) ([]*models.Call, error) {
ctx, span := trace.StartSpan(ctx, "ls_get_calls")
defer span.End()
return m.ls.GetCalls1(ctx, filter)
}
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, appName, callID string, callLog io.Reader) error {
ctx, span := trace.StartSpan(ctx, "ls_insert_log")
defer span.End()
return m.ls.InsertLog(ctx, appName, callID, 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()
}