Skip to content

Commit

Permalink
Prepare release 2.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyashtrikul committed Jan 9, 2021
1 parent a4de004 commit 67b4a79
Show file tree
Hide file tree
Showing 38 changed files with 355 additions and 160 deletions.
22 changes: 21 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased]


## [2.0.7] - 2021-01-09
- MultiLog:
- Added `LocalMode` (colored human console) and `DebugMode` (trace log level) to `config.Application`
- Application name in log fields
- By default, console log enabled (added `SilentMode` in `multilog.Config` to turn it off)
- Runner:
- All builtin providers are public
- Added startup options:
- `server.NoDefaultProviders()` - turn off all default providers and configurations
- `server.LocalDebug()` - turn on colored console logging and trace level
- Other:
- `mysql.Provide` now returns `driver.Connector` (and added `mysql.ProvideConnector` for manual registering)
- `sql.Provide` now accepting `driver.Connector`
- Deprecated:
- `server.NoWaitOption()` -> `server.NoWait()`
- `server.EnvPathOption(path)` -> `server.EnvPath(path)`
- `server.ConfigOption(cfg)` -> `server.WithConfig(cfg)`
- Field `MySQL` in `sql.Args` structure

## [2.0.6] - 2020-11-12


Expand All @@ -33,7 +52,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## 1.0.0 - 2020-09-28

[Unreleased]: https://github.com/vseinstrumentiru/lego/compare/v2.0.6...HEAD
[Unreleased]: https://github.com/vseinstrumentiru/lego/compare/v2.0.7...HEAD
[2.0.7]: https://github.com/vseinstrumentiru/lego/compare/v2.0.6...v2.0.7
[2.0.6]: https://github.com/vseinstrumentiru/lego/compare/v2.0.5...v2.0.6
[2.0.5]: https://github.com/vseinstrumentiru/lego/compare/v2.0.4...v2.0.5
[2.0.4]: https://github.com/vseinstrumentiru/lego/compare/v2.0.3...v2.0.4
Expand Down
10 changes: 7 additions & 3 deletions config/config.go → config/app.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package config

func Undefined() *Application {
const Undefined = "undefined"

func UndefinedApplication() *Application {
return &Application{
Name: "undefined",
DataCenter: "undefined",
Name: Undefined,
DataCenter: Undefined,
}
}

type Application struct {
Name string
DataCenter string
DebugMode bool
LocalMode bool
}

func (c Application) FullName() string {
Expand Down
6 changes: 3 additions & 3 deletions config/config_test.go → config/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ func TestUndefined(t *testing.T) {
name string
want *Application
}{
{"success", &Application{"undefined", "undefined"}},
{"success", &Application{Name: "undefined", DataCenter: "undefined"}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := Undefined(); !reflect.DeepEqual(got, tt.want) {
t.Errorf("Undefined() = %v, want %v", got, tt.want)
if got := UndefinedApplication(); !reflect.DeepEqual(got, tt.want) {
t.Errorf("UndefinedApplication() = %v, want %v", got, tt.want)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion internal/env/configenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (e *configEnv) Configure(cfg Config) error {
e.setInstances(parsed)

if !parsed.exist(base.Application{}) {
app := base.Undefined()
app := base.UndefinedApplication()

if name := e.viper.GetString("name"); name != "" {
app = &base.Application{
Expand Down
2 changes: 1 addition & 1 deletion internal/env/noconfigenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (e *noConfigEnv) Configure() error {
return err
}

app := base.Undefined()
app := base.UndefinedApplication()

if name := e.viper.GetString("name"); name != "" {
app = &base.Application{
Expand Down
File renamed without changes.
52 changes: 52 additions & 0 deletions metrics/configure.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package metrics

import (
health "github.com/AppsFlyer/go-sundheit"
"go.opencensus.io/plugin/ocgrpc"
"go.opencensus.io/plugin/ochttp"
"go.opencensus.io/stats/view"
"go.opencensus.io/trace"
"go.uber.org/dig"

"github.com/vseinstrumentiru/lego/v2/metrics/tracing"
)

func ConfigureStats() error {
return view.Register(
// Health checks
health.ViewCheckCountByNameAndStatus,
health.ViewCheckStatusByName,
health.ViewCheckExecutionTime,
// HTTP Client
ochttp.ClientCompletedCount,
ochttp.ClientSentBytesDistribution,
ochttp.ClientReceivedBytesDistribution,
ochttp.ClientRoundtripLatencyDistribution,
// GRPC Client
ocgrpc.ClientSentBytesPerRPCView,
ocgrpc.ClientReceivedBytesPerRPCView,
ocgrpc.ClientRoundtripLatencyView,
ocgrpc.ClientRoundtripLatencyView,
)
}

type TraceConfigArgs struct {
dig.In
Trace *tracing.Config `optional:"true"`
}

func ConfigureTrace(in TraceConfigArgs) error {
if in.Trace != nil {
trace.ApplyConfig(
trace.Config{
DefaultSampler: trace.Sampler(in.Trace.Sampler),
MaxAnnotationEventsPerSpan: in.Trace.MaxAnnotationEventsPerSpan,
MaxMessageEventsPerSpan: in.Trace.MaxMessageEventsPerSpan,
MaxAttributesPerSpan: in.Trace.MaxAttributesPerSpan,
MaxLinksPerSpan: in.Trace.MaxLinksPerSpan,
},
)
}

return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ import (
"go.uber.org/dig"

"github.com/vseinstrumentiru/lego/v2/config"
"github.com/vseinstrumentiru/lego/v2/internal/metrics/propagation"
"github.com/vseinstrumentiru/lego/v2/metrics/exporters"
"github.com/vseinstrumentiru/lego/v2/metrics/propagation"
"github.com/vseinstrumentiru/lego/v2/multilog"
)

type argsIn struct {
type Args struct {
dig.In
App *config.Application
Config *exporters.Jaeger `optional:"true"`
Log multilog.Logger
Propagation *propagation.HTTPFormatCollection
}

func Configure(in argsIn) error {
func Configure(in Args) error {
if in.Config == nil {
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import (
lenewrelic "github.com/vseinstrumentiru/lego/v2/multilog/newrelic"
)

type argsIn struct {
type ConfigArgs struct {
dig.In
App *config.Application `optional:"true"`
Config *exporters.NewRelic `optional:"true"`
NewRelic *newrelic.Application `optional:"true"`
Log multilog.Logger
}

func Configure(in argsIn) error {
func Configure(in ConfigArgs) error {
if in.Config == nil || !in.Config.Enabled {
return nil
}
Expand Down
27 changes: 27 additions & 0 deletions metrics/exporters/newrelicexporter/logger.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package newrelicexporter

import "github.com/vseinstrumentiru/lego/v2/multilog"

type loggerWrap struct {
multilog.Logger
}

func (l loggerWrap) Error(msg string, context map[string]interface{}) {
l.Logger.Error(msg, context)
}

func (l loggerWrap) Warn(msg string, context map[string]interface{}) {
l.Logger.Warn(msg, context)
}

func (l loggerWrap) Info(msg string, context map[string]interface{}) {
l.Logger.Info(msg, context)
}

func (l loggerWrap) Debug(msg string, context map[string]interface{}) {
l.Logger.Debug(msg, context)
}

func (l loggerWrap) DebugEnabled() bool {
return false
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,14 @@ import (
"github.com/vseinstrumentiru/lego/v2/multilog"
)

type args struct {
type ProvideArgs struct {
dig.In
App *config.Application
Config *exporters.NewRelic `optional:"true"`
Logger multilog.Logger
}

type loggerWrap struct {
multilog.Logger
}

func (l loggerWrap) Error(msg string, context map[string]interface{}) {
l.Logger.Error(msg, context)
}

func (l loggerWrap) Warn(msg string, context map[string]interface{}) {
l.Logger.Warn(msg, context)
}

func (l loggerWrap) Info(msg string, context map[string]interface{}) {
l.Logger.Info(msg, context)
}

func (l loggerWrap) Debug(msg string, context map[string]interface{}) {
l.Logger.Debug(msg, context)
}

func (l loggerWrap) DebugEnabled() bool {
return false
}

func Provide(in args) (app *newrelic.Application, err error) {
func Provide(in ProvideArgs) (app *newrelic.Application, err error) {
if in.Config == nil {
return nil, nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ import (
"go.uber.org/dig"

"github.com/vseinstrumentiru/lego/v2/config"
"github.com/vseinstrumentiru/lego/v2/internal/metrics/propagation"
"github.com/vseinstrumentiru/lego/v2/metrics/exporters"
"github.com/vseinstrumentiru/lego/v2/metrics/propagation"
"github.com/vseinstrumentiru/lego/v2/multilog"
)

type argsIn struct {
type Args struct {
dig.In
App *config.Application
Config *exporters.Opencensus `optional:"true"`
Log multilog.Logger
Propagation *propagation.HTTPFormatCollection
}

func Configure(in argsIn) error {
func Configure(in Args) error {
if in.Config == nil {
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import (
"github.com/vseinstrumentiru/lego/v2/version"
)

type argsIn struct {
type Args struct {
dig.In
Router *http.ServeMux
App *config.Application
Log multilog.Logger
Version version.Info
}

func Configure(in argsIn) error {
func Configure(in Args) error {
log := in.Log.WithFields(map[string]interface{}{"component": "exporter.prometheus"})

exp, err := prometheus.NewExporter(prometheus.Options{
Expand Down
File renamed without changes.
Loading

0 comments on commit 67b4a79

Please sign in to comment.