Skip to content

Commit

Permalink
[v2] Ensure similar naming for query service metrics (#5785)
Browse files Browse the repository at this point in the history
**Which problem is this PR solving?**

This PR addresses a part of the issue [#5633
](#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]>
  • Loading branch information
Wise-Wizard authored Jul 31, 2024
1 parent 12f8fbb commit 77333cc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions cmd/jaeger/internal/all-in-one.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ service:
service.name: jaeger
metrics:
level: detailed
address: 0.0.0.0:8888
# TODO Initialize telemetery tracer once OTEL released new feature.
# https://github.com/open-telemetry/opentelemetry-collector/issues/10663

Expand Down
3 changes: 2 additions & 1 deletion cmd/jaeger/internal/extension/jaegerquery/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ func (*server) Dependencies() []component.ID {

func (s *server) Start(_ context.Context, host component.Host) error {
mf := otelmetrics.NewFactory(s.telset.MeterProvider)
queryMetricsFactory := mf.Namespace(metrics.NSOptions{Name: "query"})
baseFactory := mf.Namespace(metrics.NSOptions{Name: "jaeger"})
queryMetricsFactory := baseFactory.Namespace(metrics.NSOptions{Name: "query"})
f, err := jaegerstorage.GetStorageFactory(s.config.TraceStoragePrimary, host)
if err != nil {
return fmt.Errorf("cannot find primary storage %s: %w", s.config.TraceStoragePrimary, err)
Expand Down
17 changes: 8 additions & 9 deletions scripts/compare_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import json

# Load the JSON files
v1_metrics_path = "./V1_Metrics.json"
v2_metrics_path = "./V2_Metrics.json"

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

# Extract names and labels of the metrics
def extract_metrics_with_labels(metrics):
def extract_metrics_with_labels(metrics, strip_prefix=None):
result = {}
for metric in metrics:
name = metric['name']
if strip_prefix and name.startswith(strip_prefix):
name = name[len(strip_prefix):]
labels = {}
if 'metrics' in metric and 'labels' in metric['metrics'][0]:
labels = metric['metrics'][0]['labels']
result[name] = labels
return result


v1_metrics_with_labels = extract_metrics_with_labels(v1_metrics)
v2_metrics_with_labels = extract_metrics_with_labels(v2_metrics)
v2_metrics_with_labels = extract_metrics_with_labels(
v2_metrics, strip_prefix="otelcol_")

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

for name, labels in v1_metrics_with_labels.items():
if name in v2_metrics_with_labels:
if labels == v2_metrics_with_labels[name]:
common_metrics[name] = labels
else:
v1_only_metrics[name] = labels
common_metrics[name] = labels
else:
v1_only_metrics[name] = labels

Expand All @@ -54,9 +54,8 @@ def extract_metrics_with_labels(metrics):
"v2_only_metrics": v2_only_metrics
}

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

print(f"Differences written to {differences_path}")
print(f"Differences written to {differences_path}")

0 comments on commit 77333cc

Please sign in to comment.