|
1 | 1 | package replica |
2 | 2 |
|
3 | | -import ( |
4 | | - "time" |
5 | | - |
6 | | - "go.opentelemetry.io/otel" |
7 | | - "go.opentelemetry.io/otel/attribute" |
8 | | - |
9 | | - "github.com/fil-forge/piri/lib/telemetry" |
10 | | -) |
11 | | - |
12 | | -var replicaDurationBounds = []float64{ |
13 | | - (5 * time.Millisecond).Seconds(), |
14 | | - (10 * time.Millisecond).Seconds(), |
15 | | - (100 * time.Millisecond).Seconds(), |
16 | | - (time.Second).Seconds(), |
17 | | - (3 * time.Second).Seconds(), |
18 | | - (5 * time.Second).Seconds(), |
19 | | - (10 * time.Second).Seconds(), |
20 | | - (30 * time.Second).Seconds(), |
21 | | - (time.Minute).Seconds(), |
22 | | - (2 * time.Minute).Seconds(), |
23 | | - (3 * time.Minute).Seconds(), |
24 | | - (5 * time.Minute).Seconds(), |
25 | | - (6 * time.Minute).Seconds(), |
26 | | - (7 * time.Minute).Seconds(), |
27 | | - (8 * time.Minute).Seconds(), |
28 | | - (9 * time.Minute).Seconds(), |
29 | | - (10 * time.Minute).Seconds(), |
30 | | - (30 * time.Minute).Seconds(), |
31 | | -} |
32 | | - |
33 | | -type Metrics struct { |
34 | | - durationTimer *telemetry.Timer |
35 | | -} |
36 | | - |
37 | | -func NewMetrics() (*Metrics, error) { |
38 | | - meter := otel.GetMeterProvider().Meter("github.com/fil-forge/piri/pkg/service/storage/handlers/replica") |
39 | | - durationTimer, err := telemetry.NewTimer( |
40 | | - meter, |
41 | | - "transfer_duration", |
42 | | - "durating of replica transfer operation", |
43 | | - replicaDurationBounds, |
44 | | - ) |
45 | | - if err != nil { |
46 | | - return nil, err |
47 | | - } |
48 | | - |
49 | | - return &Metrics{ |
50 | | - durationTimer: durationTimer, |
51 | | - }, nil |
52 | | -} |
53 | | - |
54 | | -func (m *Metrics) startDuration(source, sink string) *telemetry.StopWatch { |
55 | | - if m == nil || m.durationTimer == nil { |
56 | | - return nil |
57 | | - } |
58 | | - return m.durationTimer.Start( |
59 | | - attribute.String("source", source), |
60 | | - attribute.String("sink", sink), |
61 | | - ) |
62 | | -} |
| 3 | +// import ( |
| 4 | +// "time" |
| 5 | + |
| 6 | +// "go.opentelemetry.io/otel" |
| 7 | +// "go.opentelemetry.io/otel/attribute" |
| 8 | + |
| 9 | +// "github.com/fil-forge/piri/lib/telemetry" |
| 10 | +// ) |
| 11 | + |
| 12 | +// var replicaDurationBounds = []float64{ |
| 13 | +// (5 * time.Millisecond).Seconds(), |
| 14 | +// (10 * time.Millisecond).Seconds(), |
| 15 | +// (100 * time.Millisecond).Seconds(), |
| 16 | +// (time.Second).Seconds(), |
| 17 | +// (3 * time.Second).Seconds(), |
| 18 | +// (5 * time.Second).Seconds(), |
| 19 | +// (10 * time.Second).Seconds(), |
| 20 | +// (30 * time.Second).Seconds(), |
| 21 | +// (time.Minute).Seconds(), |
| 22 | +// (2 * time.Minute).Seconds(), |
| 23 | +// (3 * time.Minute).Seconds(), |
| 24 | +// (5 * time.Minute).Seconds(), |
| 25 | +// (6 * time.Minute).Seconds(), |
| 26 | +// (7 * time.Minute).Seconds(), |
| 27 | +// (8 * time.Minute).Seconds(), |
| 28 | +// (9 * time.Minute).Seconds(), |
| 29 | +// (10 * time.Minute).Seconds(), |
| 30 | +// (30 * time.Minute).Seconds(), |
| 31 | +// } |
| 32 | + |
| 33 | +// type Metrics struct { |
| 34 | +// durationTimer *telemetry.Timer |
| 35 | +// } |
| 36 | + |
| 37 | +// func NewMetrics() (*Metrics, error) { |
| 38 | +// meter := otel.GetMeterProvider().Meter("github.com/fil-forge/piri/pkg/service/storage/handlers/replica") |
| 39 | +// durationTimer, err := telemetry.NewTimer( |
| 40 | +// meter, |
| 41 | +// "transfer_duration", |
| 42 | +// "durating of replica transfer operation", |
| 43 | +// replicaDurationBounds, |
| 44 | +// ) |
| 45 | +// if err != nil { |
| 46 | +// return nil, err |
| 47 | +// } |
| 48 | + |
| 49 | +// return &Metrics{ |
| 50 | +// durationTimer: durationTimer, |
| 51 | +// }, nil |
| 52 | +// } |
| 53 | + |
| 54 | +// func (m *Metrics) startDuration(source, sink string) *telemetry.StopWatch { |
| 55 | +// if m == nil || m.durationTimer == nil { |
| 56 | +// return nil |
| 57 | +// } |
| 58 | +// return m.durationTimer.Start( |
| 59 | +// attribute.String("source", source), |
| 60 | +// attribute.String("sink", sink), |
| 61 | +// ) |
| 62 | +// } |
0 commit comments