Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add client_requests timing module to metrics #802

Merged
merged 3 commits into from
May 6, 2024

Conversation

michaeldjeffrey
Copy link
Contributor

@michaeldjeffrey michaeldjeffrey commented May 3, 2024

Questions:

  • Is there a way we can handle repos that take this as a dependency having a different metrics crate version than oracles?
    • Ended up updating metrics to latest api style and putting a >=0.22 on the dep.

  • Add a timing span to anything that can be instrumented and returns a Result.

    Example: ```ignore let client = GatewayClient::new(channel);

    client.info(req) .with_timing("iot_fetch_info") .await?; ```

    This will result in a prometheus metric

    client_request_duration_seconds{name = "iot_fetch_info", quantile="xxx"}

  • Install the ApiTimingLayer.

    Adding .with_span_events(FmtSpan::CLOSE) to a regular format layer will print the timing spans to stdout as well.

    Example: ignore tracing_subscriber::registry() .with(tracing_subscriber::fmt::layer().with_span_events(FmtSpan::CLOSE)) .with(metrics::client_requests::client_request_timing_layer("histogram_name")) .init();

  • Remove unused install_metrics function, replace with nested install function that start_metrics delegates to. This allows us to start metrics in tests without needing to make a Settings struct.

- Add a timing span to anything that can be instrumented and returns a Result.

  Example:
  ```ignore
  let client = GatewayClient::new(channel);

  client.info(req)
    .with_timing("iot_fetch_info")
    .await?;
  ```

  This will result in a prometheus metric
  >> client_request_duration_seconds{name = "iot_fetch_info", quantile="xxx"}

- Install the `ApiTimingLayer`.

  Adding `.with_span_events(FmtSpan::CLOSE)` to a regular format layer will
  print the timing spans to stdout as well.

  Example:
  ```ignore
  tracing_subscriber::registry()
    .with(tracing_subscriber::fmt::layer().with_span_events(FmtSpan::CLOSE))
    .with(metrics::client_requests::client_request_timing_layer("histogram_name"))
    .init();
  ```

- Remove unused `install_metrics` function, replace with nested
  `install` function that `start_metrics` delegates to. This allows us to
  start metrics in tests without needing to make a `Settings` struct.
* Update metrics crate

Also bumps metrics-exporter-prometheus.

The biggest change from 0.21 -> 0.22 is in this PR
metrics-rs/metrics#394

* allow for versions greater than 0.22

this may change if the api to metrics changes _again_ before a major version.
Makes the values hide a little bit less in the code
@michaeldjeffrey michaeldjeffrey merged commit 2531d93 into main May 6, 2024
1 check passed
@michaeldjeffrey michaeldjeffrey deleted the mj/telemtry-histograms branch May 6, 2024 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants