service rename
This commit is contained in:
parent
97953f76db
commit
e4cbae0a5e
@ -32,7 +32,7 @@ type randomMetricCollector struct {
|
|||||||
|
|
||||||
func NewRandomMetricCollector(mp metric.MeterProvider) randomMetricCollector {
|
func NewRandomMetricCollector(mp metric.MeterProvider) randomMetricCollector {
|
||||||
rmc := randomMetricCollector{}
|
rmc := randomMetricCollector{}
|
||||||
rmc.meter = mp.Meter("corso-meters")
|
rmc.meter = mp.Meter("corso-collection")
|
||||||
rmc.registerCounter()
|
rmc.registerCounter()
|
||||||
// rmc.registerCpuUsage()
|
// rmc.registerCpuUsage()
|
||||||
return rmc
|
return rmc
|
||||||
@ -110,7 +110,7 @@ func StartClient(ctx context.Context) (func(context.Context) error, error) {
|
|||||||
}
|
}
|
||||||
res := resource.NewWithAttributes(
|
res := resource.NewWithAttributes(
|
||||||
semconv.SchemaURL,
|
semconv.SchemaURL,
|
||||||
semconv.ServiceName("corso-metrics"),
|
semconv.ServiceName("go-sample-app"),
|
||||||
)
|
)
|
||||||
if _, present := os.LookupEnv("OTEL_RESOURCE_ATTRIBUTES"); present {
|
if _, present := os.LookupEnv("OTEL_RESOURCE_ATTRIBUTES"); present {
|
||||||
envResource, err := resource.New(ctx, resource.WithFromEnv())
|
envResource, err := resource.New(ctx, resource.WithFromEnv())
|
||||||
|
|||||||
@ -224,62 +224,6 @@ func NewMetrics(ctx context.Context, w io.Writer) (context.Context, func()) {
|
|||||||
return ctx, func() {}
|
return ctx, func() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMetrics embeds a metrics bus into the provided context. The bus can be
|
|
||||||
// utilized with calls like Inc and Since.
|
|
||||||
// func NewMetrics(ctx context.Context, w io.Writer) (context.Context, func()) {
|
|
||||||
// var (
|
|
||||||
// // report interval time-bounds metrics into buckets. Retention
|
|
||||||
// // controls how long each interval sticks around. Neither one controls
|
|
||||||
// // logging rates; that's handled by dumpMetrics().
|
|
||||||
// sink = metrics.NewInmemSink(reportInterval, retentionDuration)
|
|
||||||
// cfg = metrics.DefaultConfig("corso")
|
|
||||||
// sig = metrics.NewInmemSignal(sink, metrics.DefaultSignal, w)
|
|
||||||
// )
|
|
||||||
|
|
||||||
// cfg.EnableHostname = false
|
|
||||||
// cfg.EnableRuntimeMetrics = false
|
|
||||||
|
|
||||||
// gm, err := metrics.NewGlobal(cfg, sink)
|
|
||||||
// if err != nil {
|
|
||||||
// logger.CtxErr(ctx, err).Error("metrics bus constructor")
|
|
||||||
// sig.Stop()
|
|
||||||
|
|
||||||
// return ctx, func() {}
|
|
||||||
// }
|
|
||||||
|
|
||||||
// stop := make(chan struct{})
|
|
||||||
// go dumpMetrics(ctx, stop, sig)
|
|
||||||
|
|
||||||
// flush := func() {
|
|
||||||
// signalDump(ctx)
|
|
||||||
// time.Sleep(500 * time.Millisecond)
|
|
||||||
// close(stop)
|
|
||||||
// sig.Stop()
|
|
||||||
// gm.Shutdown()
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // return context.WithValue(ctx, sinkCtxKey, sink), flush
|
|
||||||
// return ctx, flush
|
|
||||||
// }
|
|
||||||
|
|
||||||
// dumpMetrics runs a loop that sends a os signal (SIGUSR1 on linux/mac, SIGBREAK on windows)
|
|
||||||
// every logging interval. This syscall getts picked up by the metrics inmem signal and causes
|
|
||||||
// it to dump metrics to the provided writer (which should be the logger).
|
|
||||||
// Expectation is for users to call this in a goroutine. Any signal or close() on the stop chan
|
|
||||||
// will exit the loop.
|
|
||||||
// func dumpMetrics(ctx context.Context, stop <-chan struct{}, sig *metrics.InmemSignal) {
|
|
||||||
// tock := time.NewTicker(reportInterval)
|
|
||||||
|
|
||||||
// for {
|
|
||||||
// select {
|
|
||||||
// case <-tock.C:
|
|
||||||
// signalDump(ctx)
|
|
||||||
// case <-stop:
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Inc increments the given category by 1.
|
// Inc increments the given category by 1.
|
||||||
func Inc(cat metricsCategory, keys ...string) {
|
func Inc(cat metricsCategory, keys ...string) {
|
||||||
cats := append([]string{string(cat)}, keys...)
|
cats := append([]string{string(cat)}, keys...)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user