Skip to content

Commit d5557e2

Browse files
Wise-WizardJaredTan95
authored andcommitted
[v2] Ensure similar naming for query service metrics (jaegertracing#5785)
**Which problem is this PR solving?** This PR addresses a part of the issue [jaegertracing#5633 ](jaegertracing#5633) **Description of the changes** This is a Draft PR to achieve Observability Parity between V1 and V2 components by configuring OTEL Collector config files to initialise internal tracer and metrics **How was this change tested?** The changes were tested by running the following command: ```bash make test ``` ```bash CI actions ``` **Checklist** - [x] I have read [CONTRIBUTING_GUIDELINES.md](https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md) - [x] I have signed all commits - [x] I have added unit tests for the new functionality - [x] I have run lint and test steps successfully - `for jaeger: make lint test` - `for jaeger-ui: yarn lint` and `yarn test` --------- Signed-off-by: Wise-Wizard <[email protected]> Signed-off-by: Jared Tan <[email protected]>
1 parent 4aa499e commit d5557e2

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

cmd/jaeger/internal/all-in-one.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ service:
1010
service.name: jaeger
1111
metrics:
1212
level: detailed
13+
address: 0.0.0.0:8888
1314
# TODO Initialize telemetery tracer once OTEL released new feature.
1415
# https://github.com/open-telemetry/opentelemetry-collector/issues/10663
1516

cmd/jaeger/internal/extension/jaegerquery/server.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ func (*server) Dependencies() []component.ID {
5050

5151
func (s *server) Start(_ context.Context, host component.Host) error {
5252
mf := otelmetrics.NewFactory(s.telset.MeterProvider)
53-
queryMetricsFactory := mf.Namespace(metrics.NSOptions{Name: "query"})
53+
baseFactory := mf.Namespace(metrics.NSOptions{Name: "jaeger"})
54+
queryMetricsFactory := baseFactory.Namespace(metrics.NSOptions{Name: "query"})
5455
f, err := jaegerstorage.GetStorageFactory(s.config.TraceStoragePrimary, host)
5556
if err != nil {
5657
return fmt.Errorf("cannot find primary storage %s: %w", s.config.TraceStoragePrimary, err)

scripts/compare_metrics.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import json
88

9-
# Load the JSON files
109
v1_metrics_path = "./V1_Metrics.json"
1110
v2_metrics_path = "./V2_Metrics.json"
1211

@@ -17,18 +16,22 @@
1716
v2_metrics = json.load(file)
1817

1918
# Extract names and labels of the metrics
20-
def extract_metrics_with_labels(metrics):
19+
def extract_metrics_with_labels(metrics, strip_prefix=None):
2120
result = {}
2221
for metric in metrics:
2322
name = metric['name']
23+
if strip_prefix and name.startswith(strip_prefix):
24+
name = name[len(strip_prefix):]
2425
labels = {}
2526
if 'metrics' in metric and 'labels' in metric['metrics'][0]:
2627
labels = metric['metrics'][0]['labels']
2728
result[name] = labels
2829
return result
2930

31+
3032
v1_metrics_with_labels = extract_metrics_with_labels(v1_metrics)
31-
v2_metrics_with_labels = extract_metrics_with_labels(v2_metrics)
33+
v2_metrics_with_labels = extract_metrics_with_labels(
34+
v2_metrics, strip_prefix="otelcol_")
3235

3336
# Compare the metrics names and labels
3437
common_metrics = {}
@@ -37,10 +40,7 @@ def extract_metrics_with_labels(metrics):
3740

3841
for name, labels in v1_metrics_with_labels.items():
3942
if name in v2_metrics_with_labels:
40-
if labels == v2_metrics_with_labels[name]:
41-
common_metrics[name] = labels
42-
else:
43-
v1_only_metrics[name] = labels
43+
common_metrics[name] = labels
4444
else:
4545
v1_only_metrics[name] = labels
4646

@@ -54,9 +54,8 @@ def extract_metrics_with_labels(metrics):
5454
"v2_only_metrics": v2_only_metrics
5555
}
5656

57-
# Write the differences to a new JSON file
5857
differences_path = "./differences.json"
5958
with open(differences_path, 'w') as file:
6059
json.dump(differences, file, indent=4)
6160

62-
print(f"Differences written to {differences_path}")
61+
print(f"Differences written to {differences_path}")

0 commit comments

Comments
 (0)