mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
fn: better slot/container/request state tracking (#719)
* fn: better slot/container/request state tracking
This commit is contained in:
@@ -2,6 +2,8 @@ package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/opentracing/opentracing-go"
|
||||
"github.com/opentracing/opentracing-go/log"
|
||||
)
|
||||
@@ -106,6 +108,14 @@ func PublishHistogramToSpan(span opentracing.Span, key string, value float64) {
|
||||
span.LogFields(log.Float64(fieldname, value))
|
||||
}
|
||||
|
||||
// PublishElapsedTimeToSpan publishes the specifed histogram elapsed time since start
|
||||
// It does this by logging an appropriate field value to a tracing span
|
||||
// Use this when the current tracing span is long-lived and you want the metric to be visible before it ends
|
||||
func PublishElapsedTimeHistogram(ctx context.Context, key string, start, end time.Time) {
|
||||
elapsed := float64(end.Sub(start).Seconds())
|
||||
PublishHistogram(ctx, key, elapsed)
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
// FnPrefix is a constant for "fn_", used as a prefix for span names, field names, Prometheus metric names and Prometheus label names
|
||||
|
||||
Reference in New Issue
Block a user