Skip to content

feat(stg): add OTel semconv messaging.kafka.cluster.id relationship rules#3088

Merged
mborroni merged 3 commits into
newrelic:mainfrom
shashank-reddy-nr:fix-otel-kafka-rel
Jul 23, 2026
Merged

feat(stg): add OTel semconv messaging.kafka.cluster.id relationship rules#3088
mborroni merged 3 commits into
newrelic:mainfrom
shashank-reddy-nr:fix-otel-kafka-rel

Conversation

@shashank-reddy-nr

@shashank-reddy-nr shashank-reddy-nr commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Relevant information

OTel instrumentation packages for Kafka emit the OTel incubating semantic convention attribute messaging.kafka.cluster.id on producer and consumer spans.

The existing STG relationship rules in EXT-SERVICE-to-KAFKATOPIC.stg.yml (added by #2994) match on kafka.cluster.id — a legacy attribute not emitted by OTel instrumentation packages. This PR adds the parallel rules for messaging.kafka.cluster.id so that services instrumented with these OTel packages can have their spans resolved to KAFKATOPIC entities.

Changes:

  1. relationships/synthesis/EXT-SERVICE-to-KAFKATOPIC.stg.yml — Two new rules:

    • extServiceProducesOtelInstrKafkaTopicStg — producer spans with messaging.kafka.cluster.id
    • extServiceConsumesOtelInstrKafkaTopicStg — consumer spans with messaging.kafka.cluster.id

    Both rules look up KAFKATOPIC via the existing clusterId field in KAFKATOPIC.stg.yml candidates, mapping messaging.kafka.cluster.id → entity tag kafka.cluster.id.

  2. entity-types/infra-kafkatopic/definition.stg.yml — Add kafka.cluster.id: tag to infra_kafkatopic_otel_jmxmetrics_stg, infra_kafkatopic_otel_jmxscraper_stg, and infra_kafkatopic_otel_prometheus_stg rules. Only infra_kafkatopic_otel_kafkametrics_stg had this tag; the other three OTel receivers set kafka.cluster.id on their metrics but the tag was not being captured on the synthesized entity, which would have caused the candidate lookup to miss those entities.

Flow:

OTel span (messaging.kafka.cluster.id=<uuid>, messaging.destination.name=<topic>)
  → new synthesis rule extServiceProducesOtelInstrKafkaTopicStg / extServiceConsumesOtelInstrKafkaTopicStg
    → lookupGuid: candidateCategory=KAFKATOPIC, clusterId=<uuid>, topic=<topic>
      → KAFKATOPIC.stg.yml candidates: match entity tag kafka.cluster.id=<uuid> + tag topic=<topic>
        → KAFKATOPIC entity (synthesized from kafkametricsreceiver / jmxmetrics / jmxscraper / prometheus)

ARB Jira ticket:
https://new-relic.atlassian.net/browse/NR-XXXX

Checklist

  • I've read the guidelines and understand the acceptance criteria.
  • The value of the attribute marked as identifier will be unique and valid.
  • I've confirmed that my entity type wasn't already defined. If it is I'm providing an explanation above.
  • I've linked an ARB ticket & received approval from API Review Board in order to make these changes

…ules

Add EXT-SERVICE → KAFKATOPIC relationship synthesis rules for
messaging.kafka.cluster.id (OTel incubating semconv) emitted by
OTel instrumentation packages (Java #18978, Python #4727, JS #3577,
.NET #4739).

The existing rules in this file use kafka.cluster.id (a legacy
attribute). The new rules cover the OTel-standard attribute name
messaging.kafka.cluster.id so that spans from OTel-instrumented
producers/consumers resolve to the correct KAFKATOPIC entity via
the clusterId field in the KAFKATOPIC candidate lookup.

Also add kafka.cluster.id tag to infra_kafkatopic_otel_jmxmetrics_stg,
infra_kafkatopic_otel_jmxscraper_stg, and
infra_kafkatopic_otel_prometheus_stg synthesis rules so that KAFKATOPIC
entities from those receivers expose the cluster UUID needed by the
candidate lookup.

Assisted-by: Claude Sonnet 4.6
entityBot
entityBot previously approved these changes Jul 23, 2026

@entityBot entityBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't think these changes require an API Review Board (ARB) review, so it is not required to merge this PR. Note that all API changes do require one: if you believe this PR needs an ARB review, please create the ticket and add the ARB:pending label. Reach #api-review-board in case of doubts.

@entityBot
entityBot requested a review from a team July 23, 2026 06:30
The existing extServiceProducesSelfHostKafkaTopicClusterIdStg and
extServiceConsumesSelfHostKafkaTopicClusterIdStg rules matched
kafka.cluster.id on spans, which is not a real OTel span attribute.
OTel instrumentation packages (Java, Python, JS, .NET) emit
messaging.kafka.cluster.id per OTel incubating semconv.

Update both rules to match messaging.kafka.cluster.id and remove
the duplicate rules added in the previous commit.

Assisted-by: Claude Sonnet 4.6
entityBot
entityBot previously approved these changes Jul 23, 2026

@entityBot entityBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't think these changes require an API Review Board (ARB) review, so it is not required to merge this PR. Note that all API changes do require one: if you believe this PR needs an ARB review, please create the ticket and add the ARB:pending label. Reach #api-review-board in case of doubts.

…uster.id

Add two STG relationship rules for Java kafka-clients-cluster-metrics metrics that
carry messaging.kafka.cluster.id (OTel incubating semconv) as a data-point attribute:

- extServiceProducesKafkaClientMetricsTopicClusterIdStg (kafka.producer.* metrics)
- extServiceConsumesKafkaClientMetricsTopicClusterIdStg (kafka.consumer.* metrics)

Both rules use lookupGuid(KAFKATOPIC, clusterId=messaging.kafka.cluster.id, topic=topic)
matching the existing KAFKATOPIC candidates file which maps clusterId → kafka.cluster.id tag.

This covers the app-side metrics path from opentelemetry-java-instrumentation PR #18978
which adds messaging.kafka.cluster.id to kafka-clients-cluster-metrics via
ClusterResourceListener.onUpdate(). The collector-side (kafkametricsreceiver PR #48897)
emits kafka.cluster.id as a resource attribute, handled by existing KAFKATOPIC
synthesis tags added in the earlier commit.

Assisted-by: Claude Sonnet 4.6

@entityBot entityBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't think these changes require an API Review Board (ARB) review, so it is not required to merge this PR. Note that all API changes do require one: if you believe this PR needs an ARB review, please create the ticket and add the ARB:pending label. Reach #api-review-board in case of doubts.

@shashank-reddy-nr shashank-reddy-nr changed the title feat(stg): add OTel semconv messaging.kafka.cluster.id relationship rules for KAFKATOPIC feat(stg): add OTel semconv messaging.kafka.cluster.id relationship rules Jul 23, 2026

@vagrawal-newrelic vagrawal-newrelic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@entityBot
entityBot requested a review from a team July 23, 2026 07:32
@mborroni
mborroni merged commit 312fb76 into newrelic:main Jul 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants