Skip to content
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
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- Thanks for submitting a pull request! Here are some tips for you:
1. Please make sure you have read and understood the contributing guidelines: https://github.com/sentinel-group/blob/master/CONTRIBUTING.md
1. Please make sure you have read and understood the contributing guidelines: https://github.com/alibaba/blob/master/CONTRIBUTING.md
2. Please make sure the PR has a corresponding issue.
-->

Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ The final commit message should be clear and concise.

### Open an issue / PR

We use [GitHub Issues](https://github.com/sentinel-group/sentinel-golang/issues) and [Pull Requests](https://github.com/sentinel-group/sentinel-golang/pulls) for trackers.
We use [GitHub Issues](https://github.com/alibaba/sentinel-golang/issues) and [Pull Requests](https://github.com/alibaba/sentinel-golang/pulls) for trackers.

If you find a typo in document, find a bug in code, or want new features, or want to give suggestions,
you can [open an issue on GitHub](https://github.com/sentinel-group/sentinel-golang/issues/new) to report it.
you can [open an issue on GitHub](https://github.com/alibaba/sentinel-golang/issues/new) to report it.
Please follow the guideline message in the issue template.

If you want to contribute, please follow the [contribution workflow](#github-workflow) and create a new pull request.
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Sentinel: The Sentinel of Your Microservices

[![Build Status](https://travis-ci.org/sentinel-group/sentinel-golang.svg?branch=master)](https://travis-ci.org/sentinel-group/sentinel-golang)
[![Build Status](https://travis-ci.org/alibaba/sentinel-golang.svg?branch=master)](https://travis-ci.org/alibaba/sentinel-golang)
[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
[![Gitter](https://badges.gitter.im/alibaba/Sentinel.svg)](https://gitter.im/alibaba/Sentinel)

Expand All @@ -19,19 +19,19 @@ Sentinel has the following features:

## Documentation

See the [中文文档](https://github.com/sentinel-group/sentinel-golang/wiki/介绍) for document in Chinese.
See the [中文文档](https://github.com/alibaba/sentinel-golang/wiki/介绍) for document in Chinese.

See the [Wiki](https://github.com/sentinel-group/sentinel-golang/wiki) for full documentation, examples, blog posts, and other information.
See the [Wiki](https://github.com/alibaba/sentinel-golang/wiki) for full documentation, examples, blog posts, and other information.

If you are using Sentinel, please [**leave a comment here**](https://github.com/alibaba/Sentinel/issues/18) to tell us your scenario to make Sentinel better.
It's also encouraged to add the link of your blog post, tutorial, demo or customized components to [**Awesome Sentinel**](https://github.com/sentinel-group/sentinel-awesome).
It's also encouraged to add the link of your blog post, tutorial, demo or customized components to [**Awesome Sentinel**](https://github.com/alibaba/sentinel-awesome).

## Bugs and Feedback

For bug report, questions and discussions please submit [GitHub Issues](https://github.com/sentinel-group/sentinel-golang/issues).
For bug report, questions and discussions please submit [GitHub Issues](https://github.com/alibaba/sentinel-golang/issues).

## Contributing

Contributions are always welcomed! Please see [CONTRIBUTING](./CONTRIBUTING.md) for detailed guidelines.

You can start with the issues labeled with [`good first issue`](https://github.com/sentinel-group/sentinel-golang/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22).
You can start with the issues labeled with [`good first issue`](https://github.com/alibaba/sentinel-golang/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22).
2 changes: 1 addition & 1 deletion api/api.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package api

import (
"github.com/sentinel-group/sentinel-golang/core/base"
"github.com/alibaba/sentinel-golang/core/base"
)

// Entry is the basic API of Sentinel.
Expand Down
2 changes: 1 addition & 1 deletion api/api_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package api

import (
"github.com/sentinel-group/sentinel-golang/core/base"
"github.com/alibaba/sentinel-golang/core/base"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"testing"
Expand Down
10 changes: 5 additions & 5 deletions api/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package api

import (
"fmt"
"github.com/sentinel-group/sentinel-golang/core/config"
"github.com/sentinel-group/sentinel-golang/core/log/metric"
"github.com/sentinel-group/sentinel-golang/core/system"
"github.com/sentinel-group/sentinel-golang/logging"
"github.com/alibaba/sentinel-golang/core/config"
"github.com/alibaba/sentinel-golang/core/log/metric"
"github.com/alibaba/sentinel-golang/core/system"
"github.com/alibaba/sentinel-golang/logging"
)

// InitDefault initializes Sentinel using the configuration from system
Expand Down Expand Up @@ -55,7 +55,7 @@ func initSentinel(configPath string, logDir string) (err error) {
}

metric.InitTask()
system.InitCollector()
system.InitCollector(config.SystemStatCollectIntervalMs())

return err
}
2 changes: 1 addition & 1 deletion api/option.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package api

import (
"github.com/sentinel-group/sentinel-golang/core/base"
"github.com/alibaba/sentinel-golang/core/base"
)

// Options represents the options of a Sentinel resource entry.
Expand Down
10 changes: 5 additions & 5 deletions api/slot_chain.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package api

import (
"github.com/sentinel-group/sentinel-golang/core/base"
"github.com/sentinel-group/sentinel-golang/core/flow"
"github.com/sentinel-group/sentinel-golang/core/log"
"github.com/sentinel-group/sentinel-golang/core/stat"
"github.com/sentinel-group/sentinel-golang/core/system"
"github.com/alibaba/sentinel-golang/core/base"
"github.com/alibaba/sentinel-golang/core/flow"
"github.com/alibaba/sentinel-golang/core/log"
"github.com/alibaba/sentinel-golang/core/stat"
"github.com/alibaba/sentinel-golang/core/system"
)

var globalSlotChain = BuildDefaultSlotChain()
Expand Down
3 changes: 2 additions & 1 deletion core/base/metric_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import (
"strconv"
"strings"

"github.com/sentinel-group/sentinel-golang/util"
"github.com/alibaba/sentinel-golang/util"
)

const metricPartSeparator = "|"

// MetricItem represents the data of metric log per line.
type MetricItem struct {
Resource string
Classification int32
Expand Down
4 changes: 2 additions & 2 deletions core/base/slot_chain.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package base

import (
"github.com/sentinel-group/sentinel-golang/logging"
"github.com/sentinel-group/sentinel-golang/util"
"github.com/alibaba/sentinel-golang/logging"
"github.com/alibaba/sentinel-golang/util"
"sync"
)

Expand Down
70 changes: 33 additions & 37 deletions core/config/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,25 @@ package config

import "github.com/pkg/errors"

type Config struct {
Version string
Sentinel struct {
App struct {
// Name represents the name of current running service.
Name string
// Type indicates the classification of the service (e.g. web service, API gateway).
Type int32
}
Log struct {
// Dir represents the log directory path.
Dir string
// UsePid indicates whether the filename ends with the process ID (PID).
UsePid bool
// Metric represents the configuration items of the metric log.
Metric struct {
SingleFileMaxSize uint64
MaxFileCount uint32
FlushIntervalSec uint32
}
}
type Entity struct {
// Version represents the format version of the entity.
Version string

Sentinel SentinelConfig
}

// SentinelConfig represent the general configuration of Sentinel.
type SentinelConfig struct {
App struct {
// Name represents the name of current running service.
Name string
// Type indicates the classification of the service (e.g. web service, API gateway).
Type int32
}
// Log represents configuration items related to logging.
Log LogConfig
// Stat represents configuration items related to statistics.
Stat StatConfig
}

// LogConfig represent the configuration of logging in Sentinel.
Expand All @@ -43,23 +40,15 @@ type MetricLogConfig struct {
FlushIntervalSec uint32 `yaml:"flushIntervalSec"`
}

// SentinelConfig represent the general configuration of Sentinel.
type SentinelConfig struct {
App struct {
// Name represents the name of current running service.
Name string
// Type indicates the classification of the service (e.g. web service, API gateway).
Type int32
}
// Log represents configuration items related to logging.
Log LogConfig
// StatConfig represents the configuration items of statistics.
type StatConfig struct {
System SystemStatConfig `yaml:"system"`
}

type Entity struct {
// Version represents the format version of the entity.
Version string

Sentinel SentinelConfig
// SystemStatConfig represents the configuration items of system statistics.
type SystemStatConfig struct {
// CollectIntervalMs represents the collecting interval of the system metrics collector.
CollectIntervalMs uint32 `yaml:"collectIntervalMs"`
}

func NewDefaultConfig() *Entity {
Expand All @@ -73,7 +62,11 @@ func NewDefaultConfig() *Entity {
Name: UnknownProjectName,
Type: DefaultAppType,
},
Log: LogConfig{Metric: MetricLogConfig{SingleFileMaxSize: DefaultMetricLogSingleFileMaxSize, MaxFileCount: DefaultMetricLogMaxFileAmount, FlushIntervalSec: DefaultMetricLogFlushIntervalSec}},
Log: LogConfig{Metric: MetricLogConfig{SingleFileMaxSize: DefaultMetricLogSingleFileMaxSize,
MaxFileCount: DefaultMetricLogMaxFileAmount, FlushIntervalSec: DefaultMetricLogFlushIntervalSec}},
Stat: StatConfig{
System: SystemStatConfig{CollectIntervalMs: DefaultSystemStatCollectIntervalMs},
},
},
}
}
Expand All @@ -92,5 +85,8 @@ func checkValid(conf *SentinelConfig) error {
if mc.SingleFileMaxSize <= 0 {
return errors.New("Bad metric log config: singleFileMaxSize <= 0")
}
if conf.Stat.System.CollectIntervalMs == 0 {
return errors.New("Bad system stat config: collectIntervalMs = 0")
}
return nil
}
25 changes: 17 additions & 8 deletions core/config/local_storage.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package config

import (
"github.com/sentinel-group/sentinel-golang/logging"
"github.com/sentinel-group/sentinel-golang/util"
"github.com/alibaba/sentinel-golang/logging"
"github.com/alibaba/sentinel-golang/util"
"gopkg.in/yaml.v2"
"io/ioutil"
"os"
Expand All @@ -17,11 +17,12 @@ const (
AppNameEnvKey = "SENTINEL_APP_NAME"
AppTypeEnvKey = "SENTINEL_APP_TYPE"

DefaultConfigFilename = "sentinel.yml"
DefaultAppType int32 = 0
DefaultMetricLogFlushIntervalSec uint32 = 1
DefaultMetricLogSingleFileMaxSize uint64 = 1024 * 1024 * 50
DefaultMetricLogMaxFileAmount uint32 = 8
DefaultConfigFilename = "sentinel.yml"
DefaultAppType int32 = 0
DefaultMetricLogFlushIntervalSec uint32 = 1
DefaultMetricLogSingleFileMaxSize uint64 = 1024 * 1024 * 50
DefaultMetricLogMaxFileAmount uint32 = 8
DefaultSystemStatCollectIntervalMs uint32 = 1000
)

var localConf = NewDefaultConfig()
Expand All @@ -44,6 +45,10 @@ func InitConfigFromFile(filePath string) error {
}
loadFromSystemEnv()

if err = checkValid(&localConf.Sentinel); err != nil {
return err
}

logger := logging.GetDefaultLogger()
logger.Infof("App name resolved: %s", AppName())

Expand Down Expand Up @@ -74,7 +79,7 @@ func loadFromSystemEnv() {
appTypeStr := os.Getenv(AppTypeEnvKey)
appType, err := strconv.ParseInt(appTypeStr, 10, 32)
if err != nil {

logging.GetDefaultLogger().Warnf("Ignoring bad appType from system env: %s", appTypeStr)
} else {
localConf.Sentinel.App.Type = int32(appType)
}
Expand All @@ -99,3 +104,7 @@ func MetricLogSingleFileMaxSize() uint64 {
func MetricLogMaxFileAmount() uint32 {
return localConf.Sentinel.Log.Metric.MaxFileCount
}

func SystemStatCollectIntervalMs() uint32 {
return localConf.Sentinel.Stat.System.CollectIntervalMs
}
4 changes: 2 additions & 2 deletions core/flow/rule_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"encoding/json"
"fmt"
"github.com/pkg/errors"
"github.com/sentinel-group/sentinel-golang/logging"
"github.com/sentinel-group/sentinel-golang/util"
"github.com/alibaba/sentinel-golang/logging"
"github.com/alibaba/sentinel-golang/util"
"sync"
)

Expand Down
4 changes: 2 additions & 2 deletions core/flow/slot.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package flow

import (
"github.com/sentinel-group/sentinel-golang/core/base"
"github.com/sentinel-group/sentinel-golang/core/stat"
"github.com/alibaba/sentinel-golang/core/base"
"github.com/alibaba/sentinel-golang/core/stat"
"time"
)

Expand Down
2 changes: 1 addition & 1 deletion core/flow/tc_default.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package flow

import (
"github.com/sentinel-group/sentinel-golang/core/base"
"github.com/alibaba/sentinel-golang/core/base"
)

type DefaultTrafficShapingCalculator struct {
Expand Down
4 changes: 2 additions & 2 deletions core/flow/tc_throttling.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package flow

import (
"github.com/sentinel-group/sentinel-golang/core/base"
"github.com/sentinel-group/sentinel-golang/util"
"github.com/alibaba/sentinel-golang/core/base"
"github.com/alibaba/sentinel-golang/util"
"math"
"sync/atomic"
"time"
Expand Down
2 changes: 1 addition & 1 deletion core/flow/tc_throttling_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package flow

import (
"github.com/sentinel-group/sentinel-golang/core/base"
"github.com/alibaba/sentinel-golang/core/base"
"github.com/stretchr/testify/assert"
"sync"
"sync/atomic"
Expand Down
2 changes: 1 addition & 1 deletion core/flow/traffic_shaping.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package flow

import (
"github.com/sentinel-group/sentinel-golang/core/base"
"github.com/alibaba/sentinel-golang/core/base"
)

// TrafficShapingCalculator calculates the actual traffic shaping threshold
Expand Down
10 changes: 5 additions & 5 deletions core/log/metric/aggregator.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package metric

import (
"github.com/sentinel-group/sentinel-golang/core/base"
"github.com/sentinel-group/sentinel-golang/core/config"
"github.com/sentinel-group/sentinel-golang/core/stat"
"github.com/sentinel-group/sentinel-golang/logging"
"github.com/sentinel-group/sentinel-golang/util"
"github.com/alibaba/sentinel-golang/core/base"
"github.com/alibaba/sentinel-golang/core/config"
"github.com/alibaba/sentinel-golang/core/stat"
"github.com/alibaba/sentinel-golang/logging"
"github.com/alibaba/sentinel-golang/util"
"sort"
"sync"
"time"
Expand Down
2 changes: 1 addition & 1 deletion core/log/metric/common.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package metric

import (
"github.com/sentinel-group/sentinel-golang/core/base"
"github.com/alibaba/sentinel-golang/core/base"
"io/ioutil"
"os"
"path/filepath"
Expand Down
Loading