Skip to content

Make id zero reserved as no ID #67

@codefromthecrypt

Description

@codefromthecrypt

Over a while, a few people have expressed interest in making span ID zero invalid. This mostly has impact to semantics of no ID and span id generators:

No ID applied to Zipkin:

  • In zipkin parent id being absent means it is the root span, ex you leave the field out of json (or set it to null) vs setting it to 0
  • In finagle's fixed-width encoding, there was a special comparison of when span id == trace id == parent id, it is the root span. This is interesting because it doesn't require interpreting the value ids, rather comparing them

Here are some reasons to make zero special:

  • In some languages zero means false, so dodging ID zero can avoid some confusion when people write custom zipkin code.
  • in fixed-width binary encoding, you cannot represent null without a flag. If zero implies no ID, you don't need a flag.
  • In memory, the parent id is bigger since we need a reference to indicate if it is null or not. If zero meant unset, we don't need to box the u64.

Here is the work needed if we make zero special:

  • we'd coerce zero to null where we accept span IDs
  • all instrumentation need to avoid generating zero (ex while (id == 0) id = randomId )
  • we have to be explicit that by zero we really mean no bits :) numeric interpretation of IDs has led to confusion before, especially encoding.

Thoughts? cc @openzipkin/instrumentation-owners @mansu @bogdandrutu @openzipkin/core

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions