Skip to content

Commit

Permalink
Merge pull request #189 from numary/feature/use-shared-otlp-lib
Browse files Browse the repository at this point in the history
Use otlp module provided by go-libs.
  • Loading branch information
gfyrag authored Apr 22, 2022
2 parents ba2d5bb + 7511aab commit 0acabba
Show file tree
Hide file tree
Showing 16 changed files with 21 additions and 746 deletions.
30 changes: 15 additions & 15 deletions cmd/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/gin-gonic/gin"
"github.com/numary/go-libs/sharedlogging"
"github.com/numary/go-libs/sharedlogging/sharedlogginglogrus"
"github.com/numary/go-libs/sharedotlp/sharedotlpmetrics"
"github.com/numary/go-libs/sharedotlp/sharedotlptraces"
"github.com/numary/go-libs/sharedpublish"
"github.com/numary/go-libs/sharedpublish/sharedpublishhttp"
"github.com/numary/go-libs/sharedpublish/sharedpublishkafka"
Expand Down Expand Up @@ -109,26 +111,24 @@ func NewContainer(v *viper.Viper, userOptions ...fx.Option) *fx.App {

// Handle OpenTelemetry
if v.GetBool(otelTracesFlag) {
options = append(options, opentelemetrytraces.TracesModule(opentelemetrytraces.ModuleConfig{
ServiceName: ServiceName,
Version: Version,
Batch: v.GetBool(otelTracesBatchFlag),
Exporter: v.GetString(otelTracesExporterFlag),
JaegerConfig: func() *opentelemetrytraces.JaegerConfig {
if v.GetString(otelTracesExporterFlag) != opentelemetrytraces.JaegerExporter {
options = append(options, sharedotlptraces.TracesModule(sharedotlptraces.ModuleConfig{
Batch: v.GetBool(otelTracesBatchFlag),
Exporter: v.GetString(otelTracesExporterFlag),
JaegerConfig: func() *sharedotlptraces.JaegerConfig {
if v.GetString(otelTracesExporterFlag) != sharedotlptraces.JaegerExporter {
return nil
}
return &opentelemetrytraces.JaegerConfig{
return &sharedotlptraces.JaegerConfig{
Endpoint: v.GetString(otelTracesExporterJaegerEndpointFlag),
User: v.GetString(otelTracesExporterJaegerUserFlag),
Password: v.GetString(otelTracesExporterJaegerPasswordFlag),
}
}(),
OTLPConfig: func() *opentelemetrytraces.OTLPConfig {
if v.GetString(otelTracesExporterFlag) != opentelemetrytraces.OTLPExporter {
OTLPConfig: func() *sharedotlptraces.OTLPConfig {
if v.GetString(otelTracesExporterFlag) != sharedotlptraces.OTLPExporter {
return nil
}
return &opentelemetrytraces.OTLPConfig{
return &sharedotlptraces.OTLPConfig{
Mode: v.GetString(otelTracesExporterOTLPModeFlag),
Endpoint: v.GetString(otelTracesExporterOTLPEndpointFlag),
Insecure: v.GetBool(otelTracesExporterOTLPInsecureFlag),
Expand All @@ -137,13 +137,13 @@ func NewContainer(v *viper.Viper, userOptions ...fx.Option) *fx.App {
}))
}
if v.GetBool(otelMetricsFlag) {
options = append(options, opentelemetrymetrics.MetricsModule(opentelemetrymetrics.MetricsModuleConfig{
options = append(options, sharedotlpmetrics.MetricsModule(sharedotlpmetrics.MetricsModuleConfig{
Exporter: v.GetString(otelMetricsExporterFlag),
OTLPConfig: func() *opentelemetrymetrics.OTLPMetricsConfig {
if v.GetString(otelMetricsExporterFlag) != opentelemetrymetrics.OTLPMetricsExporter {
OTLPConfig: func() *sharedotlpmetrics.OTLPMetricsConfig {
if v.GetString(otelMetricsExporterFlag) != sharedotlpmetrics.OTLPMetricsExporter {
return nil
}
return &opentelemetrymetrics.OTLPMetricsConfig{
return &sharedotlpmetrics.OTLPMetricsConfig{
Mode: v.GetString(otelMetricsExporterOTLPModeFlag),
Endpoint: v.GetString(otelMetricsExporterOTLPEndpointFlag),
Insecure: v.GetBool(otelMetricsExporterOTLPInsecureFlag),
Expand Down
6 changes: 3 additions & 3 deletions cmd/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"context"
"errors"
"github.com/ThreeDotsLabs/watermill/pubsub/gochannel"
"github.com/numary/go-libs/sharedotlp/sharedotlptraces"
"github.com/numary/ledger/internal/pgtesting"
"github.com/numary/ledger/pkg/bus"
"github.com/numary/ledger/pkg/core"
"github.com/numary/ledger/pkg/ledger"
"github.com/numary/ledger/pkg/opentelemetry/opentelemetrytraces"
"github.com/numary/ledger/pkg/storage"
"github.com/numary/ledger/pkg/storage/sqlstorage"
"github.com/pborman/uuid"
Expand Down Expand Up @@ -77,7 +77,7 @@ func TestContainers(t *testing.T) {
return nil
},
})
}, fx.ParamTags(``, ``, ``, opentelemetrytraces.TracerProviderOptionKey))),
}, fx.ParamTags(``, ``, ``, sharedotlptraces.TracerProviderOptionKey))),
},
},
{
Expand Down Expand Up @@ -115,7 +115,7 @@ func TestContainers(t *testing.T) {
return nil
},
})
}, fx.ParamTags(``, ``, ``, opentelemetrytraces.TracerProviderOptionKey))),
}, fx.ParamTags(``, ``, ``, sharedotlptraces.TracerProviderOptionKey))),
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ require (
github.com/gibson042/canonicaljson-go v1.0.3
github.com/go-redis/redis/v8 v8.11.4
github.com/go-redis/redismock/v8 v8.0.6
github.com/numary/go-libs v0.0.0-20220325095600-77c50f13215d
github.com/numary/go-libs v0.0.0-20220421111437-7c311b956456
github.com/xdg-go/scram v1.1.0
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,8 @@ github.com/numary/go-libs v0.0.0-20220325080412-02604f34c81f h1:eeqeJgc0BhJ1vjRx
github.com/numary/go-libs v0.0.0-20220325080412-02604f34c81f/go.mod h1:Ko0TOXuzUP7hP70Vj+E8xRU0BBqxHKeh/He/r8xqmNY=
github.com/numary/go-libs v0.0.0-20220325095600-77c50f13215d h1:9liBLU1oViJz9B3dAdSSIxbUaYA9vns1gxSClcTJmjY=
github.com/numary/go-libs v0.0.0-20220325095600-77c50f13215d/go.mod h1:Ko0TOXuzUP7hP70Vj+E8xRU0BBqxHKeh/He/r8xqmNY=
github.com/numary/go-libs v0.0.0-20220421111437-7c311b956456 h1:LXyf/KcN++yvqhv3PpHuJ+y0Ngl9BGrHBuQFyfATtAA=
github.com/numary/go-libs v0.0.0-20220421111437-7c311b956456/go.mod h1:6tDsBoFNhjhfN3/G7JFmv5B2GIfuzTNhA2QrdnwOCew=
github.com/numary/ledger v0.0.0-20210702172952-a5bd30e551d0/go.mod h1:u2K28z9TDYd6id1qeD2uv7JDlajuRZ0fvOnCeDZmDxk=
github.com/numary/ledger v0.0.0-20211227131550-dc7b78f85b5b/go.mod h1:uovuDsK7Gs7duqKQ9PgaFulJnPTDftGdR/n3rBRzNIs=
github.com/numary/ledger v1.2.1/go.mod h1:dCGgCTrHvVfl4YKMKY0oq3bQexsEU/mhGHM9qRrNjJ0=
Expand Down
39 changes: 0 additions & 39 deletions pkg/opentelemetry/opentelemetrymetrics/controller.go

This file was deleted.

20 changes: 0 additions & 20 deletions pkg/opentelemetry/opentelemetrymetrics/exporter.go

This file was deleted.

66 changes: 0 additions & 66 deletions pkg/opentelemetry/opentelemetrymetrics/metrics.go

This file was deleted.

85 changes: 0 additions & 85 deletions pkg/opentelemetry/opentelemetrymetrics/metrics_test.go

This file was deleted.

17 changes: 0 additions & 17 deletions pkg/opentelemetry/opentelemetrymetrics/noopexporter.go

This file was deleted.

Loading

0 comments on commit 0acabba

Please sign in to comment.