Skip to content

Feature request: Allow reading structable attributes #110

Open
@nhawkes

Description

@nhawkes

At the moment tracing-opentelemetry does a somewhat of a hack to know what fields are metrics. It requires the field name to be prefixed

To publish a new metric, add a key-value pair to your tracing::Event that contains following prefixes:

  • monotonic_counter. (non-negative numbers): Used when the counter should only ever increase
  • counter.: Used when the counter can go up or down
  • value.: Used for discrete data points (i.e., summing them does not make semantic sense)
async fn current_example() { 
     tracing::info!(histogram.racecar.speed = 80_f64);
}

Instead if attributes were exposed it would be possible to do something like this:

/// How fast the racecar is going
#[derive(Valuable)]
#[histogram(key="racecar.speed", unit="mph")]
struct RacecarSpeed(f64);

#[tokio::test]
async fn proposed_example() {
    tracing::info!("Going at {}mph", speed=RacecarSpeed(777.0012_f64));
}

I think there's two approaches here: expose the attributes directly, or expose the typeid and require subscribers to map that typeid to the attribute

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions