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 20 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 @@ -674,6 +674,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
11 changes: 11 additions & 0 deletions samplers/jaegerremote/Makefile
@@ -0,0 +1,11 @@
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:
mkdir -p internal/proto-gen

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

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

## Example

[example/](./example) shows how to host remote sampling strategies using the OpenTelemetry Collector.
The Collector uses the Jaeger receiver to host the strategy file, note you do not need to send Jaeger to make use of the Jaeger remote sampling protocol.
hanyuancheung marked this conversation as resolved.
Show resolved Hide resolved

Run the OpenTelemetry Collector using docker-compose:

```shell
$ docker-compose up -d
```

You can fetch the strategy file using curl:

```shell
$ curl 'localhost:5778/sampling?service=foo'
$ curl 'localhost:5778/sampling?service=myService'
```

Run the Go program.
This program will start with an initial sampling percentage of 50% and tries to fetch the sampling strategies from the OpenTelemetry Collector.
It will print the entire Jaeger remote sampler structure every 10 seconds, this allows you to observe the internal sampler.

```shell
$ go run .
```

## Update generated Jaeger code

Code is generated using the .proto files from [jaeger-idl](https://github.com/jaegertracing/jaeger-idl).
In case [sampling.proto](./jaeger-idl/proto/api_v2/sampling.proto) is modified these have to be regenerated.

```shell
$ make proto-gen
```
32 changes: 32 additions & 0 deletions samplers/jaegerremote/constants.go
@@ -0,0 +1,32 @@
// 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.

// Copyright (c) 2021 The Jaeger Authors.
// Copyright (c) 2017 Uber Technologies, Inc.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move copyright headers to the top

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove them here


package jaegerremote

import (
"fmt"
)

const (
// defaultSamplingServerPort is the default port to fetch sampling config from, via http
defaultSamplingServerPort = 5778
)

var (
// defaultSamplingServerURL is the default url to fetch sampling config from, via http
defaultSamplingServerURL = fmt.Sprintf("http://127.0.0.1:%d/sampling", defaultSamplingServerPort)
)
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
13 changes: 13 additions & 0 deletions samplers/jaegerremote/example/go.mod
@@ -0,0 +1,13 @@
module go.opentelemetry.io/contrib/samplers/jaegerremote/example

go 1.16

require (
github.com/davecgh/go-spew v1.1.1
go.opentelemetry.io/contrib/samplers/jaegerremote v0.22.0
go.opentelemetry.io/otel v1.1.0
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.1.0
go.opentelemetry.io/otel/sdk v1.1.0
)

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