Skip to content

core: tracking issue for valuable integration #1570

Open
@hawkw

Description

@hawkw

Feature Request

Crates

  • tracing-core

Motivation

The valuable crate provides an extensible system for dynamic inspection of structured values. It was primarily implemented in order to extend tracing's value system with support for visiting nested values (such as a struct's fields). This would be a significant improvement relative to the current value system (see e.g. #819, #845, etc). However, in order to benefit from valuable, we have to actually integrate it into tracing.

Proposal

There are actually two separate problems we will want to solve: valuable support in tracing 0.1, and valuable support for the upcoming v0.2.

In 0.2

For 0.2, the solution will be fairly simple, but probably takes a lot of work to implement. The intent is to more or less completely replace the existing Value trait with valuable::Valuable. I think we would also want to replace the ValueSet type with something implementing valuable's abstraction for arrays, as well. We would then modify the macros to record key-value pairs using valuable, rather than using the tracing_core::field::Value trait, and update existing code to use valuable. Of course, we'll want to make sure it's possible to reimplement the basic tracing field behaviors (e.g. recording primitives) on top of valuable with no additional friction.

In 0.1

It's probably a good idea to implement the valuable integration in tracing 0.1 before performing a whole-sale replacement in 0.2 --- it's quite likely that we'll hit things in valuable that may need to be changed or improved in order to support use in tracing, and this may require breaking changes in valuable. Using valuable to completely replace the Value trait makes valuable a public API dependency, and breaking changes to valuable are breaking changes in tracing-core. Therefore, we ought to make sure any breaking changes to valuable are out of the way prior to replacing the entire value system in 0.2.

Thus, we probably want to add optional support for valuable in 0.1 first. Unlike replacing the entire Value trait, this would be a backwards-compatible addition to the existing Value system. We'd probably want to do this by adding a new Visit::record_valuable method where the visitor is passed a dyn Valuable, behind a feature flag. We'd also add a Value implementation for valuable::Value that dispatches to this method. Since valuable::Value implements Debug, this can always fall back to the Visit type's record_debug if the visitor doesn't opt in to valuable support.

Alternatives

We could skip adding valuable support in 0.1, and just do the wholesale replacement in 0.2. However, I don't think this is a great idea, since it means we don't get the opportunity for users to actually test out using valuable with tracing, and there might be unforseen issues that require breaking API changes in valuable. Also, I think the 0.1 version of optional valuable integration is probably fairly simple to implement, so it seems like something we might as well do.

Metadata

Metadata

Assignees

No one assigned

    Labels

    crate/coreRelated to the `tracing-core` cratecrate/tracingRelated to the `tracing` cratekind/featureNew feature or requestmeta/breakingThis is a breaking change, and should wait until the next breaking release.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions