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

opentelemetry: allocate fewer strings for recording events #1917

Merged
merged 2 commits into from Feb 9, 2022

Commits on Feb 9, 2022

  1. opentelemetry: use static strings for event targets

    This changes the `tracing-opentelemetry` subscriber to use
    `&'static str`s for event targets when possible, similarly to how we did
    this for source locations in #1911.
    
    Signed-off-by: Eliza Weisman <eliza@buoyant.io>
    hawkw committed Feb 9, 2022
    Configuration menu
    Copy the full SHA
    4ac91f6 View commit details
    Browse the repository at this point in the history
  2. opentelemetry: don't allocate level strings for all events

    Currently, the OpenTelemetry subscriber calls `level.to_string()` to
    produce a string that's added as a key-value pair when recording
    `tracing` events. This means a new `String` will be allocated for _all_
    events.
    
    This can be avoided by using `Level::as_str` instead, which returns an
    `&'static str`.  Because `opentelemetry`'s `String` values are `Cow`'s,
    we can use the `&'static str` without allocating a `String`.
    
    Signed-off-by: Eliza Weisman <eliza@buoyant.io>
    hawkw committed Feb 9, 2022
    Configuration menu
    Copy the full SHA
    1653064 View commit details
    Browse the repository at this point in the history