Skip to content

[SEMCONV] Metrics are incorrectly prefixed with metric.Β #3226

@sjinks

Description

@sjinks

Describe your environment OpenTelemetry 1.18

Steps to reproduce
When using CreateXXXMetricYY() functions from opentelemetry/api/semconv (for example, CreateAsyncInt64MetricProcessContextSwitches() or any other similar function), they create a metric prefixed with metric. (for example, metric.process.context_switches).

I believe this is not correct: for example, for the Context Switches metric, the specification says that the name is process.context_switches, not metric.process.context_switches.

What is the expected behavior?
Metric names match the specification.

What is the actual behavior?
Metric names have an additional prefix of metric..

Additional context
I think this bug was introduced in #3105, here:

static constexpr const char *{{v_metric_name}} = "{{metric.id}}";

By looking at the Process Metrics Model, we see:

  - id: metric.process.context_switches
    type: metric
    metric_name: process.context_switches
    stability: experimental
    brief: "Number of times the process has been context switched."
    instrument: counter
    unit: "{count}"
    attributes:
      - ref: process.context_switch_type

id is what we have now, metric_name is what we should probably have.

The fix I think will be (buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2)

-static constexpr const char *{{v_metric_name}} = "{{metric.id}}";
+static constexpr const char *{{v_metric_name}} = "{{metric.metric_name}}";

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtriage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions