GoogleCloudPlatform/opentelemetry-operations-js

Sending TimeSeries failed - out of order

omBratteng opened this issue · 1 comments

Please answer these questions before submitting a bug report.

What version of OpenTelemetry are you using?

[
    "@google-cloud/opentelemetry-cloud-monitoring-exporter": "^0.17.0",
    "@google-cloud/opentelemetry-cloud-trace-exporter": "^2.1.0",
    "@google-cloud/opentelemetry-cloud-trace-propagator": "^0.17.0",
    "@opentelemetry/api": "^1.6.0",
    "@opentelemetry/exporter-prometheus": "^0.44.0",
    "@opentelemetry/exporter-trace-otlp-grpc": "^0.44.0",
    "@opentelemetry/instrumentation-fastify": "^0.32.3",
    "@opentelemetry/instrumentation-graphql": "^0.35.2",
    "@opentelemetry/instrumentation-grpc": "^0.44.0",
    "@opentelemetry/instrumentation-http": "^0.44.0",
    "@opentelemetry/instrumentation-ioredis": "^0.35.2",
    "@opentelemetry/instrumentation-pg": "^0.36.2",
    "@opentelemetry/instrumentation-pino": "^0.34.2",
    "@opentelemetry/resource-detector-container": "^0.3.2",
    "@opentelemetry/resource-detector-gcp": "^0.29.2",
    "@opentelemetry/sdk-node": "^0.44.0",
]

What version of Node are you using?

v18.18.2

What did you do?

Just started with metrics in our API, where we are using a counter on each response to our API.

WE are using Fastify, so counter increments in the onResponse hook, code available here.
https://github.com/dailydotdev/daily-api/blob/91f95ee0ea55c7728e0c17c19936b26f08a1a21e/src/telemetry/opentelemetry.ts#L150-L155

What did you expect to see?

Not an error

What did you see instead?

Error: PeriodicExportingMetricReader: metrics export failed (error Error: Send TimeSeries failed: One or more TimeSeries could not be written: Points must be written in order. One or more of the points specified had an older start time than the most recent point.: generic_node{node_id:5855858856619293314,location:us-central1-f,namespace:} timeSeries[0-89]: workload.googleapis.com/requests{http_method:POST,dailydev_apps_version:unknown,http_status_code:200,http_route:/graphql})
    at doExport (/opt/app/node_modules/@opentelemetry/sdk-metrics/build/src/export/PeriodicExportingMetricReader.js:76:23)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async PeriodicExportingMetricReader._doRun (/opt/app/node_modules/@opentelemetry/sdk-metrics/build/src/export/PeriodicExportingMetricReader.js:84:13)
    at async PeriodicExportingMetricReader._runOnce (/opt/app/node_modules/@opentelemetry/sdk-metrics/build/src/export/PeriodicExportingMetricReader.js:55:13)

Additional context

We are running in kubernetes, currently at this time we have 3 replicas of the pods

Think we figured it out, had to add some more resource attributes so that it wouldn't create a generic_node but a k8s_pod instead plus some other attributes from the @google-cloud/opentelemetry-resource-util package.