Skip to content

Supporting non-random trace IDs #896

Closed
@anuraaga

Description

Currently many SDKs provide an interface for configuring the way IDs are generated. This is important for X-Ray where all trace IDs have to start with 4 bytes representing the epoch seconds (otherwise, the total number of bytes is the same, it's only a semantic restriction on the first 4 bytes). Being able to ingest arbitrary IDs is a nice thing we'd like to support someday but, the backend relies on this heavily in its indexing scheme currently and it would take a long time, if ever.

https://github.com/open-telemetry/opentelemetry-java/blob/master/sdk/tracing/src/main/java/io/opentelemetry/sdk/trace/IdsGenerator.java
https://github.com/open-telemetry/opentelemetry-go/blob/master/sdk/trace/id_generator.go
https://github.com/open-telemetry/opentelemetry-js/blob/master/packages/opentelemetry-core/src/trace/IdGenerator.ts

Python currently doesn't but it is generated by OpenTelemetry and extracting an interface is simple (actually the JS interface was extracting by a team member to allow JS to work with X-Ray)

https://github.com/open-telemetry/opentelemetry-python/blob/9b41a57b2e8a91ae38ba6f268b90944adcbebd15/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py#L666

We've found OpenTelemetry .NET does not provide an interface and actually uses ID generation logic from the .NET runtime itself. It defines ID formats as an enum

https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.activityidformat?view=netcore-3.1

I was surprised to see the runtime provide tracing functionality built in! But it means trace ID generation cannot be customized at the OpenTelemetry level, we would need to add knobs in the .NET runtime itself.

We have some ideas of trying to work around this by filling epoch in tracestate and have propagators and exporters reconstruct an epoch-prefixed trace ID based on it. It seems like it may not work completely, though, in particular, I expect a lot of trouble making sure a correct trace ID is synced across metrics / logs assuming it's even possible to modify the trace ID during propagation in a generic way. To clarify, it's not enough for only the X-Ray propagator / exporter to support this trace ID translation, we would not be able to interop with any other servers that e.g., use B3 without complete coverage of the trace ID conversion.

Sorry for the long background, but for the spec, I am wondering if it's possible to require all SDKs to support custom ID generation. Not allowing it could break interop with certain backends that require IDs such as epoch-based IDs and this seems against the spirit of OpenTelemetry. With a hard requirement in the spec, we would have a lot more leverage, for example, in making sure the .NET runtime can satisfy our needs with its API.

Metadata

Assignees

No one assigned

    Labels

    area:sdkRelated to the SDKpriority:p3Lowest priority levelrelease:allowed-for-gaEditorial changes that can still be added before GA since they don't require action by SIGsspec:traceRelated to the specification/trace directory

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions