Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@opentelemetry/exporter-trace-otlp-http sends time as an object #4216

Closed
vmihailenco opened this issue Oct 19, 2023 · 7 comments · Fixed by #4220
Closed

@opentelemetry/exporter-trace-otlp-http sends time as an object #4216

vmihailenco opened this issue Oct 19, 2023 · 7 comments · Fixed by #4220
Labels
bug Something isn't working priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect

Comments

@vmihailenco
Copy link

What happened?

After updating to the latest version, OpenTelemetry started sending time as an object:

                  {
                     "traceId":"6530d7d67a99987d946f0be78b547acb",
                     "spanId":"5917146c1d45991b",
                     "name":"main-operation",
                     "kind":1,
                     "startTimeUnixNano":{
                        "low":-1013133952,
                        "high":395276536
                     },
                     "endTimeUnixNano":{
                        "low":-1011286551,
                        "high":395276536
                     },
                     "attributes":[
                        
                     ],
                     "droppedAttributesCount":0,
                     "events":[
                        
                     ],
                     "droppedEventsCount":0,
                     "status":{
                        "code":0
                     },
                     "links":[
                        
                     ],
                     "droppedLinksCount":0
                  }

See the code below to reproduce.

OpenTelemetry Setup Code

'use strict'

const otel = require('@opentelemetry/api')
const { BatchSpanProcessor } = require('@opentelemetry/sdk-trace-base')
const { Resource } = require('@opentelemetry/resources')
const { NodeSDK } = require('@opentelemetry/sdk-node')
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http')
const { AWSXRayIdGenerator } = require('@opentelemetry/id-generator-aws-xray')

const dsn = process.env.UPTRACE_DSN
console.log('using dsn:', dsn)

const exporter = new OTLPTraceExporter({
  url: 'https://otlp.uptrace.dev/v1/traces',
  headers: { 'uptrace-dsn': dsn },
  compression: 'gzip',
})
const bsp = new BatchSpanProcessor(exporter, {
  maxExportBatchSize: 1000,
  maxQueueSize: 1000,
})

const sdk = new NodeSDK({
  spanProcessor: bsp,
  resource: new Resource({
    'service.name': 'myservice',
    'service.version': '1.0.0',
  }),
  idGenerator: new AWSXRayIdGenerator(),
})
sdk.start()

const tracer = otel.trace.getTracer('app_or_package_name', '1.0.0')

tracer.startActiveSpan('main', (main) => {
  main.end()
  console.log('trace id:', main.spanContext().traceId)
})

// Send buffered spans.
setTimeout(async () => {
  await sdk.shutdown()
}, 1000)

package.json

{
  "name": "otlp-node",
  "version": "1.0.0",
  "description": "",
  "main": "main.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "Apache-2.0",
  "dependencies": {
    "@opentelemetry/api": "~1.6.0",
    "@opentelemetry/exporter-trace-otlp-http": "~0.44.0",
    "@opentelemetry/sdk-node": "0.44.0",
    "@opentelemetry/sdk-trace-base": "1.17.1"
  }
}

Relevant log output

OTLPExporterError: Bad Request
    at IncomingMessage.<anonymous> (/home/vmihailenco/workspace/uptrace-js/example/otlp-traces/node_modules/@opentelemetry/otlp-exporter-base/build/src/platform/node/util.js:103:39)
    at IncomingMessage.emit (node:events:526:35)
    at endReadableNT (node:internal/streams/readable:1359:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  data: '{"status":400,"code":"json_unmarshal","message":"json: cannot unmarshal object into Go value of type uint64"}\n',
  code: 400
}

Node.js v18.17.1
@vmihailenco vmihailenco added bug Something isn't working triage labels Oct 19, 2023
@cristianmadularu
Copy link
Contributor

I think that this might have caused the problem.
#4062

@hugo082
Copy link

hugo082 commented Oct 21, 2023

FYI, downgrading to 0.43.0 fix the issue

@seemk seemk mentioned this issue Oct 22, 2023
3 tasks
@seemk
Copy link
Contributor

seemk commented Oct 22, 2023

PR for the fix at #4220

@jdmarshall
Copy link

I don't think this is limited to the trace exporter. I'm seeing the same at

sdk-metrics/build/src/export/PeriodicExportingMetricReader.js:55:13

with 0.44

eamodio added a commit to gitkraken/vscode-gitlens that referenced this issue Oct 24, 2023
@polRk
Copy link

polRk commented Oct 25, 2023

The same error

{"stack":"OTLPExporterError: Bad Request\n at IncomingMessage. (/home/polyakov/packages/telemetry/node_modules/@opentelemetry/otlp-exporter-base/build/src/platform/node/util.js:103:39)\n at IncomingMessage.emit (node:events:526:35)\n at endReadableNT (node:internal/streams/readable:1376:12)\n at process.processTicksAndRejections (node:internal/process/task_queues:82:21)","message":"Bad Request","name":"OTLPExporterError","data":"{"code":3,"message":"ReadUint64: unsupported value type, error found in #10 byte of ...|UnixNano\":{\"low\":194|..., bigger context ...|\":\"graphql\"},\"logRecords\":[{\"timeUnixNano\":{\"low\":1948385984,\"high\":395403571},\"observedTimeU|..."}","code":"400"}

eamodio added a commit to gitkraken/vscode-gitlens that referenced this issue Oct 25, 2023
@lextas
Copy link

lextas commented Oct 27, 2023

duplicate of same cause as #4202

@jdmarshall
Copy link

This report is more specific. Perhaps the other should be labeled the dupe?

stfsy added a commit to discue/open-telemetry-tracing that referenced this issue Oct 29, 2023
stefreak added a commit to garden-io/garden that referenced this issue Oct 30, 2023
Latest version leads to "Bad request" bug on otlp shutdown due to
open-telemetry/opentelemetry-js#4216
@dyladan dyladan added priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect and removed triage labels Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants