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

BatchSpanProcessor exports spans multiple times #1665

Closed
TsvetanMilanov opened this issue Nov 10, 2020 · 0 comments · Fixed by #1666
Closed

BatchSpanProcessor exports spans multiple times #1665

TsvetanMilanov opened this issue Nov 10, 2020 · 0 comments · Fixed by #1666
Labels
bug Something isn't working

Comments

@TsvetanMilanov
Copy link
Contributor

Please answer these questions before submitting a bug report.

What version of OpenTelemetry are you using?

0.12.0

What version of Node are you using?

12.16.1

Please provide the code you used to setup the OpenTelemetry SDK

const opentelemetry = require("@opentelemetry/api");
const { NodeTracerProvider } = require("@opentelemetry/node");
const { BatchSpanProcessor } = require("@opentelemetry/tracing");
const { JaegerExporter } = require("@opentelemetry/exporter-jaeger");

const provider = new NodeTracerProvider();

const exporter = new JaegerExporter({ serviceName: "test" });

const processor = new BatchSpanProcessor(exporter, { bufferSize: 5 });

provider.addSpanProcessor(processor);

provider.register();

const tracer = opentelemetry.trace.getTracer("default");

const rootSpan = tracer.startSpan("root");

tracer.withSpan(rootSpan, () => {
    for (let i = 0; i <= 10; i++) {
        const span = tracer.startSpan(`job-${i}`);

        span.end();
    }
});

rootSpan.end();

What did you do?

In the example code provided above, the BatchSpanProcessor is configured with batch size 5 and the code generates 12 spans without any delay. The idea of the code is to force the BatchSpanProcessor to call the _flush method more than once and have "concurrent" exports of this._finishedSpans.

What did you expect to see?

I expected to see 12 spans in Jaeger.

What did you see instead?

I saw 63 spans in Jaeger.

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

Successfully merging a pull request may close this issue.

1 participant