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
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const SupportPackageIsVersion1 = true
```

<a name="ConfigureInterceptors"></a>
## func [ConfigureInterceptors](<https://github.com/go-coldbrew/core/blob/main/initializers.go#L338>)
## func [ConfigureInterceptors](<https://github.com/go-coldbrew/core/blob/main/initializers.go#L300>)

```go
func ConfigureInterceptors(DoNotLogGRPCReflection bool, traceHeaderName string)
Expand All @@ -121,7 +121,7 @@ func ConfigureInterceptors(DoNotLogGRPCReflection bool, traceHeaderName string)
ConfigureInterceptors configures the interceptors package with the provided DoNotLogGRPCReflection is a boolean that indicates whether to log the grpc.reflection.v1alpha.ServerReflection service calls in logs traceHeaderName is the name of the header to use for tracing \(e.g. X\-Trace\-Id\) \- if empty, defaults to X\-Trace\-Id

<a name="InitializeVTProto"></a>
## func [InitializeVTProto](<https://github.com/go-coldbrew/core/blob/main/initializers.go#L386>)
## func [InitializeVTProto](<https://github.com/go-coldbrew/core/blob/main/initializers.go#L348>)

```go
func InitializeVTProto()
Expand All @@ -132,7 +132,7 @@ InitializeVTProto initializes the vtproto package for use with the service
https://github.com/planetscale/vtprotobuf?tab=readme-ov-file#mixing-protobuf-implementations-with-grpc

<a name="SetupAutoMaxProcs"></a>
## func [SetupAutoMaxProcs](<https://github.com/go-coldbrew/core/blob/main/initializers.go#L352>)
## func [SetupAutoMaxProcs](<https://github.com/go-coldbrew/core/blob/main/initializers.go#L314>)

```go
func SetupAutoMaxProcs()
Expand All @@ -141,7 +141,7 @@ func SetupAutoMaxProcs()
SetupAutoMaxProcs sets up the GOMAXPROCS to match Linux container CPU quota This is used to set the GOMAXPROCS to the number of CPUs allocated to the container

<a name="SetupEnvironment"></a>
## func [SetupEnvironment](<https://github.com/go-coldbrew/core/blob/main/initializers.go#L97>)
## func [SetupEnvironment](<https://github.com/go-coldbrew/core/blob/main/initializers.go#L93>)

```go
func SetupEnvironment(env string)
Expand All @@ -150,7 +150,7 @@ func SetupEnvironment(env string)
SetupEnvironment sets the environment This is used to identify the environment in Sentry and New Relic env is the environment to set for the service \(e.g. prod, staging, dev\)

<a name="SetupHystrixPrometheus"></a>
## func [SetupHystrixPrometheus](<https://github.com/go-coldbrew/core/blob/main/initializers.go#L328>)
## func [SetupHystrixPrometheus](<https://github.com/go-coldbrew/core/blob/main/initializers.go#L290>)

```go
func SetupHystrixPrometheus()
Expand All @@ -159,7 +159,7 @@ func SetupHystrixPrometheus()
SetupHystrixPrometheus sets up the hystrix metrics This is a workaround for hystrix\-go not supporting the prometheus registry It uses sync.Once to ensure the Prometheus collectors are only registered once, since duplicate registration panics.

<a name="SetupLogger"></a>
## func [SetupLogger](<https://github.com/go-coldbrew/core/blob/main/initializers.go#L73>)
## func [SetupLogger](<https://github.com/go-coldbrew/core/blob/main/initializers.go#L69>)

```go
func SetupLogger(logLevel string, jsonlogs bool) error
Expand All @@ -168,7 +168,7 @@ func SetupLogger(logLevel string, jsonlogs bool) error
SetupLogger sets up the logger It uses the coldbrew logger to log messages to stdout logLevel is the log level to set for the logger jsonlogs is a boolean to enable or disable json logs

<a name="SetupNROpenTelemetry"></a>
## func [SetupNROpenTelemetry](<https://github.com/go-coldbrew/core/blob/main/initializers.go#L304>)
## func [SetupNROpenTelemetry](<https://github.com/go-coldbrew/core/blob/main/initializers.go#L266>)

```go
func SetupNROpenTelemetry(serviceName, license, version string, ratio float64) error
Expand All @@ -186,7 +186,7 @@ Parameters:
- ratio: the sampling ratio to use for traces \(0.0 to 1.0\)

<a name="SetupNewRelic"></a>
## func [SetupNewRelic](<https://github.com/go-coldbrew/core/blob/main/initializers.go#L47>)
## func [SetupNewRelic](<https://github.com/go-coldbrew/core/blob/main/initializers.go#L43>)

```go
func SetupNewRelic(serviceName, apiKey string, tracing bool) error
Expand All @@ -195,7 +195,7 @@ func SetupNewRelic(serviceName, apiKey string, tracing bool) error
SetupNewRelic sets up the New Relic tracing and monitoring agent for the service It uses the New Relic Go Agent to send traces to New Relic One APM and Insights serviceName is the name of the service apiKey is the New Relic license key tracing is a boolean to enable or disable tracing

<a name="SetupOpenTelemetry"></a>
## func [SetupOpenTelemetry](<https://github.com/go-coldbrew/core/blob/main/initializers.go#L212>)
## func [SetupOpenTelemetry](<https://github.com/go-coldbrew/core/blob/main/initializers.go#L174>)

```go
func SetupOpenTelemetry(config OTLPConfig) error
Expand Down Expand Up @@ -233,7 +233,7 @@ err := SetupOpenTelemetry(config)
```

<a name="SetupReleaseName"></a>
## func [SetupReleaseName](<https://github.com/go-coldbrew/core/blob/main/initializers.go#L106>)
## func [SetupReleaseName](<https://github.com/go-coldbrew/core/blob/main/initializers.go#L102>)

```go
func SetupReleaseName(rel string)
Expand All @@ -242,7 +242,7 @@ func SetupReleaseName(rel string)
SetupReleaseName sets the release name This is used to identify the release in Sentry rel is the release name to set for the service \(e.g. v1.0.0\)

<a name="SetupSentry"></a>
## func [SetupSentry](<https://github.com/go-coldbrew/core/blob/main/initializers.go#L88>)
## func [SetupSentry](<https://github.com/go-coldbrew/core/blob/main/initializers.go#L84>)

```go
func SetupSentry(dsn string)
Expand Down Expand Up @@ -272,7 +272,7 @@ type CB interface {
```

<a name="New"></a>
### func [New](<https://github.com/go-coldbrew/core/blob/main/core.go#L548>)
### func [New](<https://github.com/go-coldbrew/core/blob/main/core.go#L544>)

```go
func New(c config.Config) CB
Expand Down Expand Up @@ -325,7 +325,7 @@ type CBStopper interface {
```

<a name="OTLPConfig"></a>
## type [OTLPConfig](<https://github.com/go-coldbrew/core/blob/main/initializers.go#L150-L182>)
## type [OTLPConfig](<https://github.com/go-coldbrew/core/blob/main/initializers.go#L112-L144>)

OTLPConfig holds configuration for OpenTelemetry OTLP exporter

Expand Down
6 changes: 1 addition & 5 deletions core.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func parseHeaders(headerString string) map[string]string {
return headers
}

// processConfig processes the config and sets up the logger, newrelic, sentry, environment, release name, jaeger, hystrix prometheus and signal handler
// processConfig processes the config and sets up the logger, newrelic, sentry, environment, release name, OpenTelemetry tracing, hystrix prometheus and signal handler
func (c *cb) processConfig() {
if err := SetupLogger(c.config.LogLevel, c.config.JSONLogs); err != nil {
log.Error(context.Background(), "msg", "failed to setup logger", "err", err)
Expand All @@ -112,10 +112,6 @@ func (c *cb) processConfig() {
SetupSentry(c.config.SentryDSN)
SetupEnvironment(c.config.Environment)
SetupReleaseName(c.config.ReleaseName)
cls := setupJaeger(c.config.AppName)
if cls != nil {
c.closers = append(c.closers, cls)
}
SetupHystrixPrometheus()
ConfigureInterceptors(c.config.DoNotLogGRPCReflection, c.config.TraceHeaderName)
Comment thread
ankurs marked this conversation as resolved.
if !c.config.DisableSignalHandler {
Expand Down
5 changes: 0 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ require (
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.1.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0
github.com/jaegertracing/jaeger-lib v2.4.1+incompatible
github.com/klauspost/compress v1.18.5
github.com/newrelic/go-agent/v3 v3.42.0
github.com/opentracing/opentracing-go v1.2.0
github.com/prometheus/client_golang v1.23.2
github.com/uber/jaeger-client-go v2.30.0+incompatible
go.opentelemetry.io/otel v1.42.0
go.opentelemetry.io/otel/bridge/opentracing v1.42.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.42.0
Expand Down Expand Up @@ -47,7 +45,6 @@ require (
github.com/Antonboom/testifylint v1.6.4 // indirect
github.com/BurntSushi/toml v1.6.0 // indirect
github.com/Djarvur/go-err113 v0.1.1 // indirect
github.com/HdrHistogram/hdrhistogram-go v1.2.0 // indirect
github.com/Masterminds/semver/v3 v3.4.0 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/MirrexOne/unqueryvet v1.5.4 // indirect
Expand Down Expand Up @@ -247,7 +244,6 @@ require (
github.com/timonwong/loggercheck v0.11.0 // indirect
github.com/tomarrell/wrapcheck/v2 v2.12.0 // indirect
github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
github.com/ultraware/funlen v0.2.0 // indirect
github.com/ultraware/whitespace v0.2.0 // indirect
github.com/uudashr/gocognit v1.2.1 // indirect
Expand All @@ -268,7 +264,6 @@ require (
go.opentelemetry.io/otel/metric v1.42.0 // indirect
go.opentelemetry.io/otel/trace v1.42.0 // indirect
go.opentelemetry.io/proto/otlp v1.10.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.1 // indirect
go.yaml.in/yaml/v2 v2.4.4 // indirect
Expand Down
10 changes: 0 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk
github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/Djarvur/go-err113 v0.1.1 h1:eHfopDqXRwAi+YmCUas75ZE0+hoBHJ2GQNLYRSxao4g=
github.com/Djarvur/go-err113 v0.1.1/go.mod h1:IaWJdYFLg76t2ihfflPZnM1LIQszWOsFDh2hhhAVF6k=
github.com/HdrHistogram/hdrhistogram-go v1.2.0 h1:XMJkDWuz6bM9Fzy7zORuVFKH7ZJY41G2q8KWhVGkNiY=
github.com/HdrHistogram/hdrhistogram-go v1.2.0/go.mod h1:CiIeGiHSd06zjX+FypuEJ5EQ07KKtxZ+8J6hszwVQig=
github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0=
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
Expand Down Expand Up @@ -340,8 +338,6 @@ github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUq
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jaegertracing/jaeger-lib v2.4.1+incompatible h1:T+iarSGas1APzunL/14yHIHVyNDi3WK0Xvo8RQu5MT8=
github.com/jaegertracing/jaeger-lib v2.4.1+incompatible/go.mod h1:VqeqQrZmZr9G4WdLw4ei9tAHU54iJRkfoFHvTTQn4jQ=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jgautheron/goconst v1.8.2 h1:y0XF7X8CikZ93fSNT6WBTb/NElBu9IjaY7CCYQrCMX4=
Expand Down Expand Up @@ -622,10 +618,6 @@ github.com/tomarrell/wrapcheck/v2 v2.12.0 h1:H/qQ1aNWz/eeIhxKAFvkfIA+N7YDvq6TWVF
github.com/tomarrell/wrapcheck/v2 v2.12.0/go.mod h1:AQhQuZd0p7b6rfW+vUwHm5OMCGgp63moQ9Qr/0BpIWo=
github.com/tommy-muehle/go-mnd/v2 v2.5.1 h1:NowYhSdyE/1zwK9QCLeRb6USWdoif80Ie+v+yU8u1Zw=
github.com/tommy-muehle/go-mnd/v2 v2.5.1/go.mod h1:WsUAkMJMYww6l/ufffCD3m+P7LEvr8TnZn9lwVDlgzw=
github.com/uber/jaeger-client-go v2.30.0+incompatible h1:D6wyKGCecFaSRUpo8lCVbaOOb6ThwMmTEbhRwtKR97o=
github.com/uber/jaeger-client-go v2.30.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk=
github.com/uber/jaeger-lib v2.4.1+incompatible h1:td4jdvLcExb4cBISKIpHuGoVXh+dVKhn2Um6rjCsSsg=
github.com/uber/jaeger-lib v2.4.1+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U=
github.com/ultraware/funlen v0.2.0 h1:gCHmCn+d2/1SemTdYMiKLAHFYxTYz7z9VIDRaTGyLkI=
github.com/ultraware/funlen v0.2.0/go.mod h1:ZE0q4TsJ8T1SQcjmkhN/w+MceuatI6pBFSxxyteHIJA=
github.com/ultraware/whitespace v0.2.0 h1:TYowo2m9Nfj1baEQBjuHzvMRbp19i+RCcRYrSWoFa+g=
Expand Down Expand Up @@ -688,8 +680,6 @@ go.opentelemetry.io/otel/trace v1.42.0/go.mod h1:f3K9S+IFqnumBkKhRJMeaZeNk9epyhn
go.opentelemetry.io/proto/otlp v1.10.0 h1:IQRWgT5srOCYfiWnpqUYz9CVmbO8bFmKcwYxpuCSL2g=
go.opentelemetry.io/proto/otlp v1.10.0/go.mod h1:/CV4QoCR/S9yaPj8utp3lvQPoqMtxXdzn7ozvvozVqk=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs=
go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8=
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
Expand Down
38 changes: 0 additions & 38 deletions initializers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package core
import (
"context"
"fmt"
"io"
"os"
"os/signal"
"strings"
Expand All @@ -20,12 +19,9 @@ import (
cbslog "github.com/go-coldbrew/log/loggers/slog"
nrutil "github.com/go-coldbrew/tracing/newrelic"
protov1 "github.com/golang/protobuf/proto" //nolint:staticcheck
jprom "github.com/jaegertracing/jaeger-lib/metrics/prometheus"
newrelic "github.com/newrelic/go-agent/v3/newrelic"
"github.com/opentracing/opentracing-go"
"github.com/prometheus/client_golang/prometheus"
jaegerconfig "github.com/uber/jaeger-client-go/config"
"github.com/uber/jaeger-client-go/zipkin"
"go.opentelemetry.io/otel"
otelBridge "go.opentelemetry.io/otel/bridge/opentracing"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
Expand Down Expand Up @@ -109,40 +105,6 @@ func SetupReleaseName(rel string) {
}
}

// setupJaeger sets up the Jaeger tracing.
// It uses the Jaeger Zipkin B3 HTTP Propagator to propagate the tracing headers to downstream services.
//
// Deprecated: The Jaeger client (github.com/uber/jaeger-client-go) is EOL.
// Use SetupOpenTelemetry or SetupNROpenTelemetry instead, which support
// OTLP-compatible backends including Jaeger's OTLP receiver.
func setupJaeger(serviceName string) io.Closer {
conf, err := jaegerconfig.FromEnv()
if err != nil {
log.Info(context.Background(), "msg", "could not initialize jaeger", "err", err)
return nil
}
if conf.ServiceName == "" && serviceName == "" {
// Jaeger not configured, skip initialization
return nil
}
log.Warn(context.Background(), "msg", "Jaeger client is deprecated and EOL. Please migrate to SetupOpenTelemetry or SetupNROpenTelemetry with OTLP-compatible backends.")
conf.ServiceName = serviceName
zipkinPropagator := zipkin.NewZipkinB3HTTPHeaderPropagator()
jaegerTracer, closer, err := conf.NewTracer(
jaegerconfig.Injector(opentracing.HTTPHeaders, zipkinPropagator),
jaegerconfig.Extractor(opentracing.HTTPHeaders, zipkinPropagator),
jaegerconfig.ZipkinSharedRPCSpan(true),
jaegerconfig.Metrics(jprom.New()),
)
if err != nil {
log.Info(context.Background(), "msg", "could not initialize jaeger", "err", err)
return nil
}
opentracing.SetGlobalTracer(jaegerTracer)
log.Info(context.Background(), "msg", "jaeger tracing initialized")
return closer
}

// OTLPConfig holds configuration for OpenTelemetry OTLP exporter
//
// This struct provides a flexible way to configure OpenTelemetry tracing
Expand Down
Loading