Skip to content

Inactive Apm Tracer starts an invalid span with zeroes in the trace id #1500

Open

Description

Describe the bug
Inactive APM Tracer produces invalid spans for OpenTelemetry Tracing bridge. The bug lives inside
go.elastic.co/apm/module/apmotel/v2@v2.4.3/tracer.go:105 in this code:
s.tx = t.provider.apmTracer.StartTransactionOptions(spanName, "", tranOpts) It returns an APM transaction with invalid trace and span ids (all the zero bytes).

To Reproduce
Steps to reproduce the behavior:

  1. Use Elastic APM as a bridge to OpenTelemetry API as described here https://www.elastic.co/guide/en/apm/agent/go/current/opentelemetry.html I've taken an existent working ELK Apm instance and have created a tracing provider like it described in the docs.
  2. Try to create a new span with the tracer with the code (I've done so in a webserver middleware):
ctx, span := ot.tracer.Start(
	handlerContext.GetContext(),
	serverRequestName(handlerContext.GetHandler()),
)
defer span.End()
  1. This span will have invalid trace and span ids. See the screenshot from my debug session as proof.
    Screenshot from 2023-08-28 15-54-14

Expected behavior
I suppose that in any case span should have a correct state (or there should be something like Noop span with message details that tracer is not in active state right now).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions