Skip to content

Conversation

mabdinur
Copy link
Contributor

@mabdinur mabdinur commented Oct 16, 2025

Motivation

Add OpenTelemetry metrics API support to Node.js parametric server for cross-language testing and fix type preservation issues that could cause incorrect int/double handling in OTLP exports.

Changes

Added OTel Metrics Endpoints to Node.js Parametric Server (server.js)

Implemented 13 endpoints matching the Python parametric server:

  • Meter management: get_meter, force_flush
  • Synchronous instruments: create_counter, counter_add, create_updowncounter, updowncounter_add, create_gauge, gauge_record, create_histogram, histogram_record
  • Asynchronous instruments: create_asynchronous_counter, create_asynchronous_updowncounter, create_asynchronous_gauge

Fixed OpenTelemetry API Module Singleton Issue (package.json)

Added npm overrides to ensure single @opentelemetry/api instance, preventing MeterProvider registration failures:

"overrides": {
  "@opentelemetry/api": "$@opentelemetry/api"
}

Fixed Type Preservation (server.py)

Reordered Pydantic Union types from Union[float, int]Union[int, float] in all metric value fields (10 models + 3 functions). This ensures:

  • 42 stays as int → OTLP asInt (sfixed64)
  • 42.0 stays as float → OTLP asDouble

Critical for correct OTLP protocol compliance.

Cleanup

Removed debug print statements.

Workflow

  1. ⚠️ Create your PR as draft ⚠️
  2. Work on you PR until the CI passes
  3. Mark it as ready for review
    • Test logic is modified? -> Get a review from RFC owner.
    • Framework is modified, or non obvious usage of it -> get a review from R&P team

🚀 Once your PR is reviewed and the CI green, you can merge it!

🛟 #apm-shared-testing 🛟

Reviewer checklist

  • If PR title starts with [<language>], double-check that only <language> is impacted by the change
  • No system-tests internal is modified. Otherwise, I have the approval from R&P team
  • A docker base image is modified?
    • the relevant build-XXX-image label is present
  • A scenario is added (or removed)?

Copy link
Contributor

CODEOWNERS have been resolved as:

tests/parametric/test_otel_metrics.py                                   @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
utils/build/docker/nodejs/parametric/package.json                       @DataDog/dd-trace-js @DataDog/system-tests-core
utils/build/docker/nodejs/parametric/server.js                          @DataDog/dd-trace-js @DataDog/system-tests-core
utils/build/docker/python/parametric/apm_test_client/server.py          @DataDog/apm-python @DataDog/asm-python @DataDog/system-tests-core
utils/parametric/_library_client.py                                     @DataDog/system-tests-core

@mabdinur mabdinur force-pushed the munir/otel-metrics-nodejs branch from aedb064 to fb68f4f Compare October 16, 2025 20:34
@mabdinur mabdinur force-pushed the munir/otel-metrics-nodejs branch from fb68f4f to 1df6f3c Compare October 16, 2025 20:45
for sum_data_point in sum_aggregation["data_points"]:
if attributes == {item["key"]: item["value"]["string_value"] for item in sum_data_point["attributes"]}:
assert sum_data_point["as_double"] == value
assert float(sum_data_point.get("as_int", 0)) == value
Copy link
Contributor Author

Choose a reason for hiding this comment

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

float is used to convert strings into a number (float(9) == int(9) in python).

@mabdinur mabdinur marked this pull request as ready for review October 17, 2025 12:21
@mabdinur mabdinur requested review from a team as code owners October 17, 2025 12:21
@mabdinur mabdinur requested review from genesor, nsrip-dd and quinna-h and removed request for a team October 17, 2025 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants