opentelemetry-js: Exporter trace otlp http sending unknown field to API

What happened?

When trying to send data to OTLP collector receive bad request from API. I’ve tried with gRPC exporter and it worked just fine. May be something related to HTTP only.

Steps to Reproduce

Just try to send anything to trace

Expected Result

Expected to receive tracing on OTLP collector

Actual Result

Receive bad request from API

Additional Details

Node Version: v18.6 and v16.16

docker image: otel/opentelemetry-collector-contrib:latest

Collector conf:

receivers:
  otlp:
    protocols:
      http:
      grpc:

processors:
  batch:

exporters:
  logging:
  sentry:
    dsn: <my-self-hosted-sentry>

extensions:
  health_check:
  pprof:
  zpages:

service:
  extensions: [health_check,pprof,zpages]
  pipelines:
    traces:
      receivers: [otlp]
      processors: [batch]
      exporters: [logging,sentry]

OpenTelemetry Setup Code

import * as opentelemetry from '@opentelemetry/sdk-node';
import { diag, DiagConsoleLogger, DiagLogLevel } from '@opentelemetry/api';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import { Resource } from '@opentelemetry/resources';

diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);

const exporter = new OTLPTraceExporter({
  url: 'http://localhost:4318/v1/trace',
});

const sdk = new opentelemetry.NodeSDK({
  resource: new Resource({
    [SemanticResourceAttributes.SERVICE_NAME]: 'local-ex-node',
  }),
  instrumentations: [getNodeAutoInstrumentations()],
  traceExporter: exporter,
});

sdk
  .start()
  .then(() => {
    console.log('Tracing initialized');
  })
  .catch((error) => console.log('Error initializing tracing', error));

process.on('SIGTERM', () => {
  sdk
    .shutdown()
    .then(() => console.log('Tracing terminated'))
    .catch((error) => console.log('Error terminating tracing', error))
    .finally(() => process.exit(0));
});

package.json

"@opentelemetry/api": "^1.1.0",
"@opentelemetry/auto-instrumentations-node": "^0.31.0",
"@opentelemetry/exporter-trace-otlp-grpc": "^0.30.0",
"@opentelemetry/exporter-trace-otlp-http": "^0.30.0",
"@opentelemetry/sdk-node": "^0.30.0"

Relevant log output

{"stack":"OTLPExporterError: Bad Request
    at IncomingMessage.<anonymous> (/home/breno/.../node_modules/@opentelemetry/otlp-exporter-base/src/platform/node/util.ts:91:25)
    at /home/breno/.../node_modules/@opentelemetry/context-async-hooks/src/AbstractAsyncHooksContextManager.ts:74:49
    at AsyncLocalStorage.run (node:async_hooks:316:14)
    at AsyncLocalStorageContextManager.with (/home/breno/.../node_modules/@opentelemetry/context-async-hooks/src/AsyncLocalStorageContextManager.ts:40:36)
    at IncomingMessage.contextWrapper (/home/breno/.../node_modules/@opentelemetry/context-async-hooks/src/AbstractAsyncHooksContextManager.ts:74:26)
    at IncomingMessage.emit (node:events:539:35)
    at IncomingMessage.emit (node:domain:475:12)
    at endReadableNT (node:internal/streams/readable:1345:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)","message":"Bad Request","name":"OTLPExporterError","data":"{\"code\":3,\"message\":\"unknown field \\\"scopeSpans\\\" in v1.ResourceSpans\"}","code":"400"}

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (10 by maintainers)

Most upvoted comments

If you’re using Tempo, you should check this issue: https://github.com/grafana/tempo/issues/1746 In that case, consider using another exporter like Zipkin waiting a fix

I’m experiencing the same issue. I narrowed it down to a change in @opentelemetry/exporter-trace-otlp-http@0.29.0. Could we please open and resolve this issue?

I’m available to help if necessary 😃

otel/opentelemetry-collector-contrib:0.53.0

working just fine, I’ll test on which version it is breaking…

@dyladan

There were recently some deprecated fields removed but it says the unknown field is scopeSpans which is the new field not the old field. This definitely looks like a real bug.