-
Notifications
You must be signed in to change notification settings - Fork 3
/
metric.go
55 lines (42 loc) · 1.24 KB
/
metric.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
52
53
54
55
package datadog
import (
"context"
"log"
"time"
"go.opentelemetry.io/otel/api/global"
export "go.opentelemetry.io/otel/sdk/export/metric"
"go.opentelemetry.io/otel/sdk/metric/batcher/ungrouped"
"go.opentelemetry.io/otel/sdk/metric/controller/push"
"go.opentelemetry.io/otel/sdk/metric/selector/simple"
)
func InstallNewPipeline() (*push.Controller, error) {
controller, err := NewExportPipeline()
if err != nil {
return controller, err
}
global.SetMeterProvider(controller)
return controller, err
}
func NewExportPipeline() (*push.Controller, error) {
exp, err := NewMeterExpoter()
if err != nil {
return nil, err
}
selector := simple.NewWithExactMeasure()
batcher := ungrouped.New(selector, export.NewDefaultLabelEncoder(), true)
pusher := push.New(batcher, exp, time.Minute)
pusher.Start()
return pusher, nil
}
// MeterExporter exports metrics to DataDog
type MeterExporter struct {
}
// NewMeterExpoter constructs a NewMeterExpoter
func NewMeterExpoter() (*MeterExporter, error) {
return &MeterExporter{}, nil
}
// Export exports the provide metric record to DataDog.
func (e *MeterExporter) Export(ctx context.Context, checkpoint export.CheckpointSet) error {
log.Printf("Export Checkpoint: %+v\n", checkpoint)
return nil
}