Skip to content

chore: remove prometheus #571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 16 additions & 19 deletions api/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@ package api

import (
"fmt"
"net"
"net/http"

"github.com/alibaba/sentinel-golang/core/config"
"github.com/alibaba/sentinel-golang/core/log/metric"
"github.com/alibaba/sentinel-golang/core/system_metric"
metric_exporter "github.com/alibaba/sentinel-golang/exporter/metric"
"github.com/alibaba/sentinel-golang/util"
"github.com/pkg/errors"
)
Expand Down Expand Up @@ -117,22 +114,22 @@ func initCoreComponents() error {
util.StartTimeTicker()
}

if config.MetricExportHTTPAddr() != "" {
httpAddr := config.MetricExportHTTPAddr()
httpPath := config.MetricExportHTTPPath()

l, err := net.Listen("tcp", httpAddr)
if err != nil {
return fmt.Errorf("init metric exporter http server err: %s", err.Error())
}

http.Handle(httpPath, metric_exporter.HTTPHandler())
go func() {
_ = http.Serve(l, nil)
}()

return nil
}
//if config.MetricExportHTTPAddr() != "" {
// httpAddr := config.MetricExportHTTPAddr()
// httpPath := config.MetricExportHTTPPath()
//
// l, err := net.Listen("tcp", httpAddr)
// if err != nil {
// return fmt.Errorf("init metric exporter http server err: %s", err.Error())
// }
//
// http.Handle(httpPath, metric_exporter.HTTPHandler())
// go func() {
// _ = http.Serve(l, nil)
// }()
//
// return nil
//}

return nil
}
Expand Down
24 changes: 12 additions & 12 deletions core/circuitbreaker/circuit_breaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

"github.com/alibaba/sentinel-golang/core/base"
sbase "github.com/alibaba/sentinel-golang/core/stat/base"
metric_exporter "github.com/alibaba/sentinel-golang/exporter/metric"
//metric_exporter "github.com/alibaba/sentinel-golang/exporter/metric"
"github.com/alibaba/sentinel-golang/logging"
"github.com/alibaba/sentinel-golang/util"
"github.com/pkg/errors"
Expand All @@ -47,15 +47,15 @@ const (
Open
)

var (
stateChangedCounter = metric_exporter.NewCounter(
"circuit_breaker_state_changed_total",
"Circuit breaker total state change count",
[]string{"resource", "from_state", "to_state"})
)
//var (
// stateChangedCounter = metric_exporter.NewCounter(
// "circuit_breaker_state_changed_total",
// "Circuit breaker total state change count",
// []string{"resource", "from_state", "to_state"})
//)

func init() {
metric_exporter.Register(stateChangedCounter)
//metric_exporter.Register(stateChangedCounter)
}

func newState() *State {
Expand Down Expand Up @@ -176,7 +176,7 @@ func (b *circuitBreakerBase) fromClosedToOpen(snapshot interface{}) bool {
listener.OnTransformToOpen(Closed, *b.rule, snapshot)
}

stateChangedCounter.Add(float64(1), b.BoundRule().Resource, "Closed", "Open")
//stateChangedCounter.Add(float64(1), b.BoundRule().Resource, "Closed", "Open")
return true
}
return false
Expand Down Expand Up @@ -207,7 +207,7 @@ func (b *circuitBreakerBase) fromOpenToHalfOpen(ctx *base.EntryContext) bool {
})
}

stateChangedCounter.Add(float64(1), b.BoundRule().Resource, "Open", "HalfOpen")
//stateChangedCounter.Add(float64(1), b.BoundRule().Resource, "Open", "HalfOpen")
return true
}
return false
Expand All @@ -223,7 +223,7 @@ func (b *circuitBreakerBase) fromHalfOpenToOpen(snapshot interface{}) bool {
listener.OnTransformToOpen(HalfOpen, *b.rule, snapshot)
}

stateChangedCounter.Add(float64(1), b.BoundRule().Resource, "HalfOpen", "Open")
//stateChangedCounter.Add(float64(1), b.BoundRule().Resource, "HalfOpen", "Open")
return true
}
return false
Expand All @@ -238,7 +238,7 @@ func (b *circuitBreakerBase) fromHalfOpenToClosed() bool {
listener.OnTransformToClosed(HalfOpen, *b.rule)
}

stateChangedCounter.Add(float64(1), b.BoundRule().Resource, "HalfOpen", "Closed")
//stateChangedCounter.Add(float64(1), b.BoundRule().Resource, "HalfOpen", "Closed")
return true
}
return false
Expand Down
20 changes: 10 additions & 10 deletions core/flow/slot.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package flow
import (
"github.com/alibaba/sentinel-golang/core/base"
"github.com/alibaba/sentinel-golang/core/stat"
metric_exporter "github.com/alibaba/sentinel-golang/exporter/metric"
//metric_exporter "github.com/alibaba/sentinel-golang/exporter/metric"
"github.com/alibaba/sentinel-golang/logging"
"github.com/alibaba/sentinel-golang/util"
"github.com/pkg/errors"
Expand All @@ -27,16 +27,16 @@ const (
RuleCheckSlotOrder = 2000
)

var (
DefaultSlot = &Slot{}
flowWaitCount = metric_exporter.NewCounter(
"flow_wait_total",
"Flow wait count",
[]string{"resource"})
)
//var (
// DefaultSlot = &Slot{}
// flowWaitCount = metric_exporter.NewCounter(
// "flow_wait_total",
// "Flow wait count",
// []string{"resource"})
//)

func init() {
metric_exporter.Register(flowWaitCount)
//metric_exporter.Register(flowWaitCount)
}

type Slot struct {
Expand Down Expand Up @@ -67,7 +67,7 @@ func (s *Slot) Check(ctx *base.EntryContext) *base.TokenResult {
}
if r.Status() == base.ResultStatusShouldWait {
if nanosToWait := r.NanosToWait(); nanosToWait > 0 {
flowWaitCount.Add(float64(ctx.Input.BatchCount), ctx.Resource.Name())
//flowWaitCount.Add(float64(ctx.Input.BatchCount), ctx.Resource.Name())
// Handle waiting action.
util.Sleep(nanosToWait)
}
Expand Down
18 changes: 9 additions & 9 deletions core/flow/traffic_shaping.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ package flow

import (
"github.com/alibaba/sentinel-golang/core/base"
metric_exporter "github.com/alibaba/sentinel-golang/exporter/metric"
//metric_exporter "github.com/alibaba/sentinel-golang/exporter/metric"
)

var (
resourceFlowThresholdGauge = metric_exporter.NewGauge(
"resource_flow_threshold",
"Resource flow threshold",
[]string{"resource"})
)
//var (
// resourceFlowThresholdGauge = metric_exporter.NewGauge(
// "resource_flow_threshold",
// "Resource flow threshold",
// []string{"resource"})
//)

func init() {
metric_exporter.Register(resourceFlowThresholdGauge)
//metric_exporter.Register(resourceFlowThresholdGauge)
}

// TrafficShapingCalculator calculates the actual traffic shaping threshold
Expand Down Expand Up @@ -86,7 +86,7 @@ func (t *TrafficShapingController) FlowCalculator() TrafficShapingCalculator {
func (t *TrafficShapingController) PerformChecking(resStat base.StatNode, batchCount uint32, flag int32) *base.TokenResult {
allowedTokens := t.flowCalculator.CalculateAllowedTokens(batchCount, flag)

resourceFlowThresholdGauge.Set(float64(allowedTokens), t.rule.Resource)
//resourceFlowThresholdGauge.Set(float64(allowedTokens), t.rule.Resource)

return t.flowChecker.DoCheck(resStat, batchCount, allowedTokens)
}
16 changes: 8 additions & 8 deletions core/stat/stat_slot.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package stat

import (
"github.com/alibaba/sentinel-golang/core/base"
metric_exporter "github.com/alibaba/sentinel-golang/exporter/metric"
//metric_exporter "github.com/alibaba/sentinel-golang/exporter/metric"
"github.com/alibaba/sentinel-golang/util"
)

Expand All @@ -29,14 +29,14 @@ const (
var (
DefaultSlot = &Slot{}

handledCounter = metric_exporter.NewCounter(
"handled_total",
"Total handled count",
[]string{"resource", "result", "block_type"})
//handledCounter = metric_exporter.NewCounter(
// "handled_total",
// "Total handled count",
// []string{"resource", "result", "block_type"})
)

func init() {
metric_exporter.Register(handledCounter)
//metric_exporter.Register(handledCounter)
}

type Slot struct {
Expand All @@ -52,7 +52,7 @@ func (s *Slot) OnEntryPassed(ctx *base.EntryContext) {
s.recordPassFor(InboundNode(), ctx.Input.BatchCount)
}

handledCounter.Add(float64(ctx.Input.BatchCount), ctx.Resource.Name(), ResultPass, "")
//handledCounter.Add(float64(ctx.Input.BatchCount), ctx.Resource.Name(), ResultPass, "")
}

func (s *Slot) OnEntryBlocked(ctx *base.EntryContext, blockError *base.BlockError) {
Expand All @@ -61,7 +61,7 @@ func (s *Slot) OnEntryBlocked(ctx *base.EntryContext, blockError *base.BlockErro
s.recordBlockFor(InboundNode(), ctx.Input.BatchCount)
}

handledCounter.Add(float64(ctx.Input.BatchCount), ctx.Resource.Name(), ResultBlock, blockError.BlockType().String())
//handledCounter.Add(float64(ctx.Input.BatchCount), ctx.Resource.Name(), ResultBlock, blockError.BlockType().String())
}

func (s *Slot) OnCompleted(ctx *base.EntryContext) {
Expand Down
26 changes: 13 additions & 13 deletions core/system_metric/sys_metric_stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"sync/atomic"
"time"

metric_exporter "github.com/alibaba/sentinel-golang/exporter/metric"
//metric_exporter "github.com/alibaba/sentinel-golang/exporter/metric"
"github.com/alibaba/sentinel-golang/logging"
"github.com/alibaba/sentinel-golang/util"
"github.com/shirou/gopsutil/v3/load"
Expand Down Expand Up @@ -50,14 +50,14 @@ var (

ssStopChan = make(chan struct{})

cpuRatioGauge = metric_exporter.NewGauge(
"cpu_ratio",
"Process cpu ratio",
[]string{})
processMemoryGauge = metric_exporter.NewGauge(
"process_memory_bytes",
"Process memory in bytes",
[]string{})
//cpuRatioGauge = metric_exporter.NewGauge(
// "cpu_ratio",
// "Process cpu ratio",
// []string{})
//processMemoryGauge = metric_exporter.NewGauge(
// "process_memory_bytes",
// "Process memory in bytes",
// []string{})
)

func init() {
Expand All @@ -74,8 +74,8 @@ func init() {
currentProcess.Store(p)
})

metric_exporter.Register(cpuRatioGauge)
metric_exporter.Register(processMemoryGauge)
//metric_exporter.Register(cpuRatioGauge)
//metric_exporter.Register(processMemoryGauge)
}

// getMemoryStat returns the current machine's memory statistic
Expand Down Expand Up @@ -118,7 +118,7 @@ func retrieveAndUpdateMemoryStat() {
return
}

processMemoryGauge.Set(float64(memoryUsedBytes))
//processMemoryGauge.Set(float64(memoryUsedBytes))

currentMemoryUsage.Store(memoryUsedBytes)
}
Expand Down Expand Up @@ -176,7 +176,7 @@ func retrieveAndUpdateCpuStat() {
return
}

cpuRatioGauge.Set(cpuPercent)
//cpuRatioGauge.Set(cpuPercent)

currentCpuUsage.Store(cpuPercent)
}
Expand Down
65 changes: 0 additions & 65 deletions exporter/metric/empty_exporter.go

This file was deleted.

Loading
Loading