forked from jaegertracing/jaeger
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use OpenTelemetry SDK in HotROD 🚗 (jaegertracing#4187)
Based on earlier PR jaegertracing#3390 by @rbroggi. ## Which problem is this PR solving? - Resolves jaegertracing#3380 ## Short description of the changes - Switch from jaeger-client-go SDK to OTel SDK paired with ot-otel bridge - Add cli flag to select which Otel Exporter to use (Jaeger, OTLP or stdout) - Add favicon 🚗 - Added OTEL version of rpcmetrics from jaeger-client-go - Remove dependency on github.com/uber/jaeger-lib in HotROD (addresses one of outstanding tasks in jaegertracing#3766) --------- Signed-off-by: rbroggi <[email protected]> Signed-off-by: Yuri Shkuro <[email protected]> Co-authored-by: rbroggi <[email protected]> Signed-off-by: shubbham1215 <[email protected]>
- Loading branch information
1 parent
3f74fc7
commit 276def4
Showing
24 changed files
with
816 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
go.work | ||
go.work.sum | ||
|
||
*.out | ||
*.test | ||
*.xml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Package rpcmetrics implements an OpenTelemetry SpanProcessor that can be used to emit RPC metrics. | ||
|
||
This package is copied from jaeger-client-go and adapted to work with OpenTelemtery SDK. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright (c) 2023 The Jaeger Authors. | ||
// Copyright (c) 2017 Uber Technologies, Inc. | ||
// | ||
// 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 rpcmetrics | ||
|
||
import "sync" | ||
|
||
// normalizedEndpoints is a cache for endpointName -> safeName mappings. | ||
type normalizedEndpoints struct { | ||
names map[string]string | ||
maxSize int | ||
normalizer NameNormalizer | ||
mux sync.RWMutex | ||
} | ||
|
||
func newNormalizedEndpoints(maxSize int, normalizer NameNormalizer) *normalizedEndpoints { | ||
return &normalizedEndpoints{ | ||
maxSize: maxSize, | ||
normalizer: normalizer, | ||
names: make(map[string]string, maxSize), | ||
} | ||
} | ||
|
||
// normalize looks up the name in the cache, if not found it uses normalizer | ||
// to convert the name to a safe name. If called with more than maxSize unique | ||
// names it returns "" for all other names beyond those already cached. | ||
func (n *normalizedEndpoints) normalize(name string) string { | ||
n.mux.RLock() | ||
norm, ok := n.names[name] | ||
l := len(n.names) | ||
n.mux.RUnlock() | ||
if ok { | ||
return norm | ||
} | ||
if l >= n.maxSize { | ||
return "" | ||
} | ||
return n.normalizeWithLock(name) | ||
} | ||
|
||
func (n *normalizedEndpoints) normalizeWithLock(name string) string { | ||
norm := n.normalizer.Normalize(name) | ||
n.mux.Lock() | ||
defer n.mux.Unlock() | ||
// cache may have grown while we were not holding the lock | ||
if len(n.names) >= n.maxSize { | ||
return "" | ||
} | ||
n.names[name] = norm | ||
return norm | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) 2023 The Jaeger Authors. | ||
// Copyright (c) 2017 Uber Technologies, Inc. | ||
// | ||
// 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 rpcmetrics | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestNormalizedEndpoints(t *testing.T) { | ||
n := newNormalizedEndpoints(1, DefaultNameNormalizer) | ||
|
||
assertLen := func(l int) { | ||
n.mux.RLock() | ||
defer n.mux.RUnlock() | ||
assert.Len(t, n.names, l) | ||
} | ||
|
||
assert.Equal(t, "ab_cd", n.normalize("ab^cd"), "one translation") | ||
assert.Equal(t, "ab_cd", n.normalize("ab^cd"), "cache hit") | ||
assertLen(1) | ||
assert.Equal(t, "", n.normalize("xys"), "cache overflow") | ||
assertLen(1) | ||
} | ||
|
||
func TestNormalizedEndpointsDoubleLocking(t *testing.T) { | ||
n := newNormalizedEndpoints(1, DefaultNameNormalizer) | ||
assert.Equal(t, "ab_cd", n.normalize("ab^cd"), "fill out the cache") | ||
assert.Equal(t, "", n.normalizeWithLock("xys"), "cache overflow") | ||
} |
Oops, something went wrong.