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

Batched exporter starts sends just first 2048 spans #3772

Closed
jankaifer opened this issue Apr 28, 2023 · 2 comments
Closed

Batched exporter starts sends just first 2048 spans #3772

jankaifer opened this issue Apr 28, 2023 · 2 comments
Labels
bug Something isn't working triage

Comments

@jankaifer
Copy link

jankaifer commented Apr 28, 2023

What happened?

Batched exporter starts ignoring spans when I generate too many and don't manually flush.

Steps to Reproduce

Generate 10k spans and send them to batched processor

Expected Result

All of those spans are sent.

Actual Result

Only the first 2048 spans are reported, the rest is discarded.

Additional Details

Repro: https://github.com/jankaifer/batched-grpc/tree/5dbb9a3ffd80d7333cb14e035f8e5070db47802b

OpenTelemetry Setup Code

import { context, trace } from "@opentelemetry/api";
import { NodeSDK } from "@opentelemetry/sdk-node";
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-grpc";

const N = 10_000;

const sdk = new NodeSDK({
  traceExporter: new OTLPTraceExporter(),
});
sdk.start();

const tracer = trace.getTracer("example-tracer-node");
tracer.startActiveSpan("main", (span) => {
  for (let i = 0; i < N; i++) {
    const globalCtx = context.active();
    const ctx = trace.setSpan(globalCtx, span);
    tracer.startActiveSpan("child", undefined, ctx, (childSpan) => {
      // Do stuff
      console.log("doing stuff", i);
      childSpan.end();
    });
  }
  span.end();
});

await sdk.shutdown();
console.log("finished");

package.json

{
  "name": "batched-grpc",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@opentelemetry/api": "^1.4.1",
    "@opentelemetry/exporter-trace-otlp-grpc": "^0.38.0",
    "@opentelemetry/resources": "^1.12.0",
    "@opentelemetry/sdk-node": "^0.38.0",
    "@opentelemetry/sdk-trace-base": "^1.12.0",
    "@opentelemetry/semantic-conventions": "^1.12.0"
  }
}

Relevant log output

I measured the bumper of reported spans in Zipkin (you can even see that the root span is child because main was not reported):
Screenshot from 2023-04-28 15-23-31

@jankaifer jankaifer added bug Something isn't working triage labels Apr 28, 2023
@Flarna
Copy link
Member

Flarna commented Apr 28, 2023

2048 is default max queue size (see here).

You can change this (env or constructor option).
As you create spans in a sync loop node has no chance to export any spans.

If above is just simplified and the loop is actually async it's likely that #3458 will improve your situation.

@jankaifer
Copy link
Author

Thanks, I suspected it was something like this, but I haven't found a mention of this in the docs or closed issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

No branches or pull requests

2 participants