Skip to content

Commit 281d4aa

Browse files
danish9039yurishkuro
authored andcommitted
Move pkg/normalizer to collector (jaegertracing#6877)
<!-- !! Please DELETE this comment before posting. We appreciate your contribution to the Jaeger project! πŸ‘‹πŸŽ‰ --> ## Which problem is this PR solving? - part of jaegertracing#6869 ## Description of the changes - inline the `/pkg/normalizer `package into the metrics.go file where it's used. ## How was this change tested? - ## Checklist - [ ] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [ ] I have signed all commits - [ ] I have added unit tests for the new functionality - [ ] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `npm run lint` and `npm run test` --------- Signed-off-by: danish9039 <[email protected]> Signed-off-by: Yuri Shkuro <[email protected]> Co-authored-by: Yuri Shkuro <[email protected]> Signed-off-by: amol-verma-allen <[email protected]>
1 parent 9433894 commit 281d4aa

File tree

4 files changed

+22
-29
lines changed

4 files changed

+22
-29
lines changed

β€Žcmd/collector/app/metrics.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"github.com/jaegertracing/jaeger-idl/model/v1"
1515
"github.com/jaegertracing/jaeger/cmd/collector/app/processor"
1616
"github.com/jaegertracing/jaeger/pkg/metrics"
17-
"github.com/jaegertracing/jaeger/pkg/normalizer"
1817
"github.com/jaegertracing/jaeger/pkg/otelsemconv"
1918
)
2019

@@ -281,7 +280,7 @@ func (m metricsBySvc) countTracesByServiceName(serviceName string, isDebug bool,
281280
// an alert should be raised to investigate what's causing so many unique
282281
// service names.
283282
func (m *traceCountsBySvc) countByServiceName(serviceName string, isDebug bool, samplerType model.SamplerType) {
284-
serviceName = normalizer.ServiceName(serviceName)
283+
serviceName = normalizeServiceName(serviceName)
285284
counts := m.counts
286285
if isDebug {
287286
counts = m.debugCounts
@@ -312,6 +311,7 @@ func (m *traceCountsBySvc) countByServiceName(serviceName string, isDebug bool,
312311
}
313312
counter = counts[otherServicesSampler]
314313
}
314+
315315
m.lock.Unlock()
316316
counter.Inc(1)
317317
}
@@ -327,7 +327,7 @@ func (m *traceCountsBySvc) countByServiceName(serviceName string, isDebug bool,
327327
// an alert should be raised to investigate what's causing so many unique
328328
// service names.
329329
func (m *spanCountsBySvc) countByServiceName(serviceName string, isDebug bool) {
330-
serviceName = normalizer.ServiceName(serviceName)
330+
serviceName = normalizeServiceName(serviceName)
331331
counts := m.counts
332332
if isDebug {
333333
counts = m.debugCounts

β€Žpkg/normalizer/service_name.go renamed to β€Žcmd/collector/app/normalize.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
// Copyright (c) 2017 Uber Technologies, Inc.
33
// SPDX-License-Identifier: Apache-2.0
44

5-
package normalizer
5+
package app
66

77
import (
88
"strings"
99
)
1010

11-
// ServiceName converts service name to a lowercase string that is safe to use in metrics
12-
func ServiceName(serviceName string) string {
11+
// normalizeServiceName converts service name to a string that is safe to use in metrics
12+
func normalizeServiceName(serviceName string) string {
1313
return serviceNameReplacer.Replace(serviceName)
1414
}
1515

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (c) 2025 The Jaeger Authors.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package app
5+
6+
import (
7+
"testing"
8+
9+
"github.com/stretchr/testify/assert"
10+
)
11+
12+
func TestNormalizeServiceName(t *testing.T) {
13+
assert.Equal(t, "abc", normalizeServiceName("ABC"), "lower case conversion")
14+
assert.Equal(t, "a_b_c__", normalizeServiceName("a&b%c/:"), "disallowed runes to underscore")
15+
assert.Equal(t, "a_z_0123456789.", normalizeServiceName("A_Z_0123456789."), "allowed runes")
16+
}

β€Žpkg/normalizer/service_name_test.go

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
Β (0)