Skip to content
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

[extension/jaegerremotesampling] remove jaeger sampling dependency #36977

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
27 changes: 27 additions & 0 deletions .chloggen/remove-jaegersampling.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: extension/jaegerremotesampling

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: remove dependency on jaeger internal code

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [36976]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
20 changes: 11 additions & 9 deletions extension/jaegerremotesampling/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import (
"context"
"fmt"

"github.com/jaegertracing/jaeger/cmd/collector/app/sampling/samplingstrategy"
"github.com/jaegertracing/jaeger/plugin/sampling/strategyprovider/static"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/extension"
"go.uber.org/zap"

"github.com/open-telemetry/opentelemetry-collector-contrib/extension/jaegerremotesampling/internal"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/jaegerremotesampling/internal/server/grpc"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/jaegerremotesampling/internal/server/http"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/jaegerremotesampling/internal/source"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/jaegerremotesampling/internal/source/filesource"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/jaegerremotesampling/internal/source/remotesource"
)

var _ extension.Extension = (*jrsExtension)(nil)
Expand All @@ -24,7 +26,7 @@ type jrsExtension struct {

httpServer component.Component
grpcServer component.Component
samplingStore samplingstrategy.Provider
samplingStore source.Source

closers []func() error
}
Expand All @@ -44,11 +46,11 @@ func (jrse *jrsExtension) Start(ctx context.Context, host component.Host) error
// - local file
// we can then use a simplified logic here to assign the appropriate store
if jrse.cfg.Source.File != "" {
opts := static.Options{
opts := filesource.Options{
StrategiesFile: jrse.cfg.Source.File,
ReloadInterval: jrse.cfg.Source.ReloadInterval,
}
ss, err := static.NewProvider(opts, jrse.telemetry.Logger)
ss, err := filesource.NewFileSource(opts, jrse.telemetry.Logger)
if err != nil {
return fmt.Errorf("failed to create the local file strategy store: %w", err)
}
Expand All @@ -64,7 +66,7 @@ func (jrse *jrsExtension) Start(ctx context.Context, host component.Host) error
return fmt.Errorf("failed to create the remote strategy store: %w", err)
}
jrse.closers = append(jrse.closers, conn.Close)
remoteStore, closer := internal.NewRemoteStrategyStore(
remoteStore, closer := remotesource.NewRemoteSource(
conn,
jrse.cfg.Source.Remote,
jrse.cfg.Source.ReloadInterval,
Expand All @@ -74,7 +76,7 @@ func (jrse *jrsExtension) Start(ctx context.Context, host component.Host) error
}

if jrse.cfg.HTTPServerConfig != nil {
httpServer, err := internal.NewHTTP(jrse.telemetry, *jrse.cfg.HTTPServerConfig, jrse.samplingStore)
httpServer, err := http.NewHTTP(jrse.telemetry, *jrse.cfg.HTTPServerConfig, jrse.samplingStore)
if err != nil {
return fmt.Errorf("error while creating the HTTP server: %w", err)
}
Expand All @@ -86,7 +88,7 @@ func (jrse *jrsExtension) Start(ctx context.Context, host component.Host) error
}

if jrse.cfg.GRPCServerConfig != nil {
grpcServer, err := internal.NewGRPC(jrse.telemetry, *jrse.cfg.GRPCServerConfig, jrse.samplingStore)
grpcServer, err := grpc.NewGRPC(jrse.telemetry, *jrse.cfg.GRPCServerConfig, jrse.samplingStore)
if err != nil {
return fmt.Errorf("error while creating the gRPC server: %w", err)
}
Expand Down
15 changes: 0 additions & 15 deletions extension/jaegerremotesampling/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ require (
)

require (
github.com/apache/thrift v0.21.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
Expand All @@ -38,28 +37,16 @@ require (
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/knadh/koanf/maps v0.1.1 // indirect
github.com/knadh/koanf/providers/confmap v0.1.0 // indirect
github.com/knadh/koanf/v2 v2.1.2 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/mapstructure v1.5.1-0.20231216201459-8508981c8b6c // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/mostynb/go-grpc-compression v1.2.3 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pierrec/lz4/v4 v4.1.22 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/rs/cors v1.11.1 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.19.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
go.opentelemetry.io/collector/client v1.22.1-0.20241220212031-7c2639723f67 // indirect
go.opentelemetry.io/collector/config/configauth v0.116.1-0.20241220212031-7c2639723f67 // indirect
go.opentelemetry.io/collector/config/configcompression v1.22.1-0.20241220212031-7c2639723f67 // indirect
Expand All @@ -75,13 +62,11 @@ require (
go.opentelemetry.io/otel/sdk/metric v1.32.0 // indirect
go.opentelemetry.io/otel/trace v1.32.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect
google.golang.org/protobuf v1.36.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

Expand Down
50 changes: 0 additions & 50 deletions extension/jaegerremotesampling/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 0 additions & 25 deletions extension/jaegerremotesampling/internal/internal_test.go

This file was deleted.

25 changes: 25 additions & 0 deletions extension/jaegerremotesampling/internal/mocks/mock_source.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package mocks // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/jaegerremotesampling/internal/mocks"

import (
"context"

"github.com/jaegertracing/jaeger/proto-gen/api_v2"
)

type MockCfgMgr struct {
GetSamplingStrategyFunc func(ctx context.Context, serviceName string) (*api_v2.SamplingStrategyResponse, error)
}

func (m *MockCfgMgr) Close() error {
return nil
}

func (m *MockCfgMgr) GetSamplingStrategy(ctx context.Context, serviceName string) (*api_v2.SamplingStrategyResponse, error) {
if m.GetSamplingStrategyFunc != nil {
return m.GetSamplingStrategyFunc(ctx, serviceName)
}
return &api_v2.SamplingStrategyResponse{}, nil
}
Loading
Loading