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

Add Jaeger remote sampler #936

Merged
merged 43 commits into from Mar 11, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
6c157f6
Add Jaeger remote sampler
kvrhdn Aug 4, 2021
b3a0fd4
add jaeger_remote/example
kvrhdn Aug 12, 2021
8f55d8d
Extract samplingStrategyParser
kvrhdn Aug 13, 2021
cf5fac2
Generate code from jaeger-idl
kvrhdn Aug 17, 2021
5500e91
Add per operation sampler, fix CI
kvrhdn Aug 17, 2021
14342ba
Fix Description()
kvrhdn Aug 18, 2021
e499f84
Merge branch 'main' into jaeger_remote
kvrhdn Nov 1, 2021
6eb570e
Delete jaeger-idl submodule, directly check in sampling.proto
kvrhdn Nov 1, 2021
0d0bf03
Update OTel dependencies
kvrhdn Nov 1, 2021
68e05c5
Update README.md
kvrhdn Nov 1, 2021
e7ee478
Improve test coverage
kvrhdn Nov 2, 2021
34cbbfb
Merge remote-tracking branch 'base/main' into jaeger_remote
kvrhdn Nov 8, 2021
8b492bf
(Sampler).Description() must not change over time
kvrhdn Nov 8, 2021
8bb5399
Replace internals with jaeger-client-go
kvrhdn Nov 16, 2021
f4f3592
Address linting issues
kvrhdn Nov 29, 2021
8f379c1
Fix race condition in test
kvrhdn Nov 29, 2021
04c1b48
Merge branch 'main' into jaeger_remote
kvrhdn Nov 29, 2021
c9acff6
Merge branch 'main' into jaeger_remote
kvrhdn Dec 7, 2021
a373c13
Merge branch 'main' into jaeger_remote
Aneurysm9 Dec 12, 2021
eb75278
Merge branch 'main' into jaeger_remote
Aneurysm9 Jan 28, 2022
4e0ce71
Update samplers/jaegerremote/README.md
hanyuancheung Mar 3, 2022
bf662c3
Merge branch 'main' into jaeger_remote
hanyuancheung Mar 4, 2022
e49435d
Update samplers/jaegerremote/internal/testutils/mock_agent.go
hanyuancheung Mar 7, 2022
fbe7e30
Merge branch 'main' into jaeger_remote
hanyuancheung Mar 7, 2022
f0ea53d
revmoe go.mod debug info
dino-ma Mar 4, 2022
7906f56
fix Copyright and
dino-ma Mar 7, 2022
97bebca
add from
dino-ma Mar 7, 2022
d4ebea2
Update dependency
dino-ma Mar 7, 2022
3fa7800
Modified according to pr
dino-ma Mar 7, 2022
d311912
change config from https://github.com/open-telemetry/opentelemetry-go…
dino-ma Mar 7, 2022
823989b
(fix:sampler_remote_options.go):change config
dino-ma Mar 8, 2022
d337bb8
(fix:constants.go):remove Copyright
dino-ma Mar 8, 2022
aa1dc44
(fix:samoler_remote.go):fix config and add default
dino-ma Mar 8, 2022
82ea29d
Update samplers/jaegerremote/sampler_remote_options.go
dino-ma Mar 8, 2022
d4a19ac
Merge branch 'jaeger_remote' of github.com:kvrhdn/opentelemetry-go-co…
dino-ma Mar 8, 2022
9ee4701
add local path
dino-ma Mar 9, 2022
bbb1c21
Merge branch 'main' into jaeger_remote
Aneurysm9 Mar 9, 2022
3fc124f
fix lint
dino-ma Mar 9, 2022
ecc557d
make precommit fix
dino-ma Mar 9, 2022
139c1c8
(fix:sampler_remote_option.go):The default port of jaeger agent is 57…
dino-ma Mar 9, 2022
4474a8f
change for Style guide
dino-ma Mar 10, 2022
76fcb9a
change for Update samplers/jaegerremote/sampler_remote_options.go
dino-ma Mar 11, 2022
40f8379
Merge branch 'main' into jaeger_remote
Aneurysm9 Mar 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Expand Up @@ -465,6 +465,24 @@ updates:
schedule:
interval: "weekly"
day: "sunday"
- package-ecosystem: "gomod"
directory: "/samplers/jaegerremote"
labels:
- dependencies
- go
- "Skip Changelog"
schedule:
interval: "weekly"
day: "sunday"
- package-ecosystem: "gomod"
directory: "/samplers/jaegerremote/example"
labels:
- dependencies
- go
- "Skip Changelog"
schedule:
interval: "weekly"
day: "sunday"
- package-ecosystem: "gomod"
directory: "/tools"
labels:
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
@@ -0,0 +1,3 @@
[submodule "samplers/jaegerremote/jaeger-idl"]
path = samplers/jaegerremote/jaeger-idl
url = https://github.com/jaegertracing/jaeger-idl
9 changes: 9 additions & 0 deletions samplers/jaegerremote/Makefile
@@ -0,0 +1,9 @@
PROTOC=docker run --rm -v${PWD}:${PWD} -w${PWD} otel/build-protobuf:latest --proto_path=${PWD}

PROTO_INCLUDES=-I/usr/include/github.com/gogo/protobuf

.PHONY: proto-gen
proto-gen:
$(PROTOC) $(PROTO_INCLUDES) \
--gogo_out=$(PWD)/internal/proto-gen \
${PWD}/jaeger-idl/proto/api_v2/sampling.proto
19 changes: 19 additions & 0 deletions samplers/jaegerremote/README.md
@@ -0,0 +1,19 @@
# Jaeger Remote Sampler

This package implements [Jaeger remote sampler](https://www.jaegertracing.io/docs/latest/sampling/#collector-sampling-configuration).

## Update generated Jaeger code

Files generated from jaeger-idl are checked in and usually do not have to be regenerated.

* Make sure the jaeger-idl submodule is synchronised.

```
git submodule update --init jaeger-idl
```

* Generate Go files from the .proto:

```
make proto-gen
```
80 changes: 80 additions & 0 deletions samplers/jaegerremote/config.go
@@ -0,0 +1,80 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package jaegerremote // import "go.opentelemetry.io/contrib/samplers/jaeger_remote"

import "time"

const (
defaultPollingInterval = time.Minute
defaultSamplingRate = 0.001
)

type config struct {
service string
endpoint string
pollingInterval time.Duration
initialSamplingRate float64
}

func defaultConfig() *config {
return &config{
service: "",
endpoint: "http://localhost:5778",
pollingInterval: defaultPollingInterval,
initialSamplingRate: defaultSamplingRate,
}
}

type Option interface {
apply(config *config)
}

type optionFunc func(config *config)

var _ Option = optionFunc(nil)

func (fn optionFunc) apply(config *config) {
fn(config)
}

func WithService(service string) Option {
return optionFunc(func(config *config) {
config.service = service
})
}

// WithEndpoint sets the endpoint to retrieve the sampling strategy from.
// Defaults to http://localhost:5778
func WithEndpoint(endpoint string) Option {
return optionFunc(func(config *config) {
config.endpoint = endpoint
})
}

// WithPollingInterval sets the interval to poll for the sampling strategy
// file. Defaults to 1 minute.
func WithPollingInterval(pollingInterval time.Duration) Option {
return optionFunc(func(config *config) {
config.pollingInterval = pollingInterval
})
}

// WithInitialSamplingRate sets the sampling rate the sampler starts with,
// before it has fetched the strategy file. Defaults to 0.001.
func WithInitialSamplingRate(initialSamplingRate float64) Option {
return optionFunc(func(config *config) {
config.initialSamplingRate = initialSamplingRate
})
}
16 changes: 16 additions & 0 deletions samplers/jaegerremote/doc.go
@@ -0,0 +1,16 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Package jaegerremote implements the Jaeger Remote protocol.
package jaegerremote // import "go.opentelemetry.io/contrib/samplers/jaegerremote"
yurishkuro marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 11 additions & 0 deletions samplers/jaegerremote/example/docker-compose.yaml
@@ -0,0 +1,11 @@
version: "3"
services:

otel-collector:
image: otel/opentelemetry-collector:latest
command: [ "--config=/etc/otel-collector.yaml" ]
volumes:
- ./otel-collector.yaml:/etc/otel-collector.yaml
- ./strategies.json:/etc/strategies.json
ports:
- "5778:5778" # default jaeger remote sampling port
12 changes: 12 additions & 0 deletions samplers/jaegerremote/example/go.mod
@@ -0,0 +1,12 @@
module go.opentelemetry.io/contrib/samplers/jaegerremote/example

go 1.16

require (
go.opentelemetry.io/contrib/samplers/jaegerremote v0.22.0
go.opentelemetry.io/otel v1.0.0-RC2
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.0.0-RC2
go.opentelemetry.io/otel/sdk v1.0.0-RC2
)

replace go.opentelemetry.io/contrib/samplers/jaegerremote => ../
Aneurysm9 marked this conversation as resolved.
Show resolved Hide resolved