Repository: denoland/deno
Pull request: tests(otel): ensure delta temporality is working

<!--
Before submitting a PR, please read https://docs.deno.com/runtime/manual/references/contributing

1. Give the PR a descriptive title.

  Examples of good title:
    - fix(std/http): Fix race condition in server
    - docs(console): Update docstrings
    - feat(doc): Handle nested reexports

  Examples of bad title:
    - fix #7123
    - update docs
    - fix bugs

2. Ensure there is a related issue and it is referenced in the PR text.
3. Ensure there are tests that cover the changes.
4. Ensure `cargo test` passes.
5. Ensure `./tools/format.js` passes without changing files.
6. Ensure `./tools/lint.js` passes.
7. Open as a draft PR if your work is still in progress. The CI won't run
   all steps, but you can add '[ci]' to a commit message to force it to.
8. If you would like to run the benchmarks on the CI, add the 'ci-bench' label.
-->


Changed files:
filename: tests/specs/cli/otel_basic/__test__.jsonc
patch: @@ -60,6 +60,22 @@
     "events": {
       "args": "run -A main.ts events.ts",
       "output": "events.out"
+    },
+    "metric_temporality_delta": {
+      "envs": {
+        "OTEL_METRIC_EXPORT_INTERVAL": "1000",
+        "OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE": "delta"
+      },
+      "args": "run -A main.ts metric_temporality.ts",
+      "output": "metric_temporality_delta.out"
+    },
+    "metric_temporality_cumulative": {
+      "envs": {
+        "OTEL_METRIC_EXPORT_INTERVAL": "1000",
+        "OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE": "cumulative"
+      },
+      "args": "run -A main.ts metric_temporality.ts",
+      "output": "metric_temporality_cumulative.out"
     }
   }
 }

filename: tests/specs/cli/otel_basic/metric_temporality.ts
patch: @@ -0,0 +1,10 @@
+import { metrics } from "npm:@opentelemetry/api@1";
+
+const meter = metrics.getMeter("delta_test");
+
+const counter = meter.createCounter("delta_counter", {
+  description: "Counter with delta temporality",
+});
+counter.add(1);
+
+setTimeout(() => counter.add(1), 2000);

filename: tests/specs/cli/otel_basic/metric_temporality_cumulative.out
patch: @@ -0,0 +1,46 @@
+{
+  "spans": [],
+  "logs": [],
+  "metrics": [
+    {
+      "name": "delta_counter",
+      "description": "Counter with delta temporality",
+      "unit": "",
+      "metadata": [],
+      "sum": {
+        "dataPoints": [
+          {
+            "attributes": [],
+            "startTimeUnixNano": "[WILDCARD]",
+            "timeUnixNano": "[WILDCARD]",
+            "exemplars": [],
+            "flags": 0,
+            "asDouble": 1
+          }
+        ],
+        "aggregationTemporality": 2,
+        "isMonotonic": true
+      }
+    },
+    {
+      "name": "delta_counter",
+      "description": "Counter with delta temporality",
+      "unit": "",
+      "metadata": [],
+      "sum": {
+        "dataPoints": [
+          {
+            "attributes": [],
+            "startTimeUnixNano": "[WILDCARD]",
+            "timeUnixNano": "[WILDCARD]",
+            "exemplars": [],
+            "flags": 0,
+            "asDouble": 2
+          }
+        ],
+        "aggregationTemporality": 2,
+        "isMonotonic": true
+      }
+    }
+  ]
+}

filename: tests/specs/cli/otel_basic/metric_temporality_delta.out
patch: @@ -0,0 +1,46 @@
+{
+  "spans": [],
+  "logs": [],
+  "metrics": [
+    {
+      "name": "delta_counter",
+      "description": "Counter with delta temporality",
+      "unit": "",
+      "metadata": [],
+      "sum": {
+        "dataPoints": [
+          {
+            "attributes": [],
+            "startTimeUnixNano": "[WILDCARD]",
+            "timeUnixNano": "[WILDCARD]",
+            "exemplars": [],
+            "flags": 0,
+            "asDouble": 1
+          }
+        ],
+        "aggregationTemporality": 1,
+        "isMonotonic": true
+      }
+    },
+    {
+      "name": "delta_counter",
+      "description": "Counter with delta temporality",
+      "unit": "",
+      "metadata": [],
+      "sum": {
+        "dataPoints": [
+          {
+            "attributes": [],
+            "startTimeUnixNano": "[WILDCARD]",
+            "timeUnixNano": "[WILDCARD]",
+            "exemplars": [],
+            "flags": 0,
+            "asDouble": 1
+          }
+        ],
+        "aggregationTemporality": 1,
+        "isMonotonic": true
+      }
+    }
+  ]
+}