90 Commits

Author SHA1 Message Date
Julian Tescher
865f6509c1
opentelemetry: prepare for v0.12.0 release (#1341) (#1342)
# 0.12.0 (March 31, 2021)

### Breaking Changes

- Upgrade to `v0.13.0` of `opentelemetry` (#1322)
  For list of breaking changes in OpenTelemetry, see the
  [v0.13.0 changelog](https://github.com/open-telemetry/opentelemetry-rust/blob/main/opentelemetry/CHANGELOG.md#v0130).

### Changed

- Improve performance when tracked inactivity is disabled (#1315)
2021-04-01 10:30:42 -07:00
Julian Tescher
151255691b opentelemetry: disabled tracked inactivity perf (#1315)
## Motivation

Optional inactivity tracking should have minimal overhead when disabled.

## Solution

Check to see if inactivity tracking is enabled before doing more
expensive operations. Performance improvement of ~6% using current
benchmarks.

* Address comments and switch to i64 timing values

Authored-by: Julian Tescher
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2021-03-31 15:17:39 -07:00
Tim
bab71acb28
opentelemetry: support otel 0.13.0 (#1322) (#1330)
This backports #1322 from `master` to `v0.1.x`,

* opentelemetry: support otel 0.13.0

Switches to `Cow<'static, str>` for otel event names and updates docs to
show simplified install methods.

* Add simple vs batch comment

Co-authored-by: Julian Tescher <jatescher@gmail.com>
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2021-03-31 14:45:13 -07:00
Julian Tescher
f5f99dd34f opentelemetry: clarify otel.kind field usage in docs (#1218)
This patch resolves the field value capitalization ambiguity currently
in `otel.kind` by instead recommending an enum value. This also brings
type safety to the value, further reducing the risk of typos and other
misuse.

Resolves #1209
2021-02-04 12:05:12 -08:00
Taiki Endo
8cbc00e731 chore: disable default features of tracing dependencies (#1144)
This avoids relatively heavy dependencies (`tracing-attributes`, `syn`,
etc.) in some cases.
2021-01-28 10:28:56 -08:00
Julian Tescher
2003af6815
opentelemetry: prepare for v0.11.0 release (#1206) (#1207) 2021-01-26 10:32:39 -08:00
Julian Tescher
1a1d5b01f8 opentelemetry: update to otel v0.12.x (#1200) 2021-01-26 10:08:31 -08:00
Julian Tescher
035342b1b8
opentelemetry: prepare for v0.10.0 release (#1166) (#1169)
* opentelemetry: prepare for v0.10.0 release

* Update doc links
2021-01-04 12:42:08 -08:00
Julian Tescher
49b4a589bf
opentelemetry: update to otel v0.11.x (#1161) (#1162)
## Motivation

Support the latest OpenTelemetry specification

## Solution

In order to support the latest spec, this patch makes the following
breaking API changes:

* Update `opentelemetry` to 0.11.x
* Update `OpenTelemetrySpanExt::set_parent` to take a context by value
  as it is now stored and propagated.
* Rename `PreSampledTracer::sampled_span_context` to
  `PreSampledTracer::sampled_context` as it now returns a full otel
  context

Additionally the following doc and example changes:

* Show w3c trace context propagator as recommendation in examples
2020-12-30 12:09:16 -08:00
Julian Tescher
1cdd554954
opentelemetry: prepare for 0.9.0 release (#1104) (#1105) 2020-11-15 13:31:54 -08:00
Julian Tescher
642ad19d62
opentelemetry: update to latest otel release version (#1049) (#1099)
This backports  #1049, which was already approved on master.

## Motivation

Support the latest OpenTelemetry specification

## Solution

In order to support the latest spec, this patch makes the following
breaking API changes:

* Update `opentelemetry` to 0.10.x
* Update `CompatSpan` to reflect changes to `Span` trait
* Record `u64` values as strings as they are no longer supported in
  OpenTelemetry.

Additionally the following non-public api, doc, and example changes:

* Update examples and docs to use new simplified pipeline builder.
* As `opentelemetry::api` no longer exports trace types, internally use
`opentelemetry::trace as otel` to disambiguate from tracing types.
* Remove `rand` dependency as it is no longer needed

Co-authored-by: Eliza Weisman <eliza@buoyant.io>
# Conflicts:
#	examples/examples/opentelemetry-remote-context.rs
#	tracing-opentelemetry/Cargo.toml
#	tracing-opentelemetry/src/layer.rs
#	tracing-opentelemetry/src/span_ext.rs
#	tracing-opentelemetry/src/tracer.rs
2020-11-13 12:16:22 -08:00
Julian Tescher
1aa9efff04
opentelemetry: Backport #1036 - prepare for 0.8.0 release (#1037) 2020-10-13 16:51:34 -07:00
Julian Tescher
73c0c10594
opentelemetry: Assign default ids if missing (#1029)
## Motivation

It is currently possible to create a span graph which includes a span
that has both an invalid parent otel context _and_ a missing trace id by
assigning an invalid extracted parent context to a non-root span.
Constructing this particular graph will currently cause a panic.

## Solution

Explicitly assign invalid trace / span ids when sampling using the otel
SDK if the span builder does not contain these values.
2020-10-10 15:41:58 -07:00
Eliza Weisman
4b54cbc689
chore: fix nightly clippy warnings (#991) (#1025)
This backports PR #991 to v0.1.x. This is primarily necessary for the MSRV
bump, since some dependencies no longer compile on Rust 1.40.0.

This has already been approved on `master`, in PR #991, so it should be 
fine to ship.

## Motivation

This will avoid breaking CI on new releases of clippy. It also makes the
code a little easier to read.

## Solution

- Convert `match val { pat => true, _ => false }` to `matches!(val, pat)`
- Remove unnecessary closures
- Convert `self: &mut Self` to `&mut self`

This bumps the MSRV to 1.42.0 for `matches!`.
The latest version of rust is 1.46.0, so as per
https://github.com/tokio-rs/tracing#supported-rust-versions this is not
considered a breaking change.

I didn't fix the following warning because the fix was not trivial/needed
a decision:

```
warning: you are deriving `Ord` but have implemented `PartialOrd` explicitly
   --> tracing-subscriber/src/filter/env/field.rs:16:32
    |
16  | #[derive(Debug, Eq, PartialEq, Ord)]
    |                                ^^^
    |
    = note: `#[warn(clippy::derive_ord_xor_partial_ord)]` on by default
note: `PartialOrd` implemented here
   --> tracing-subscriber/src/filter/env/field.rs:98:1
    |
98  | / impl PartialOrd for Match {
99  | |     fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
100 | |         // Ordering for `Match` directives is based first on _whether_ a value
101 | |         // is matched or not. This is semantically meaningful --- we would
...   |
121 | |     }
122 | | }
    | |_^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_ord_xor_partial_ord
```

As a side note, this found a bug in clippy 😆 https://github.com/rust-lang/rust-clippy/issues/6089
2020-10-07 14:10:49 -07:00
Bernardo Meurer
ca9b66819a
tracing-opentelemetry: implement additional record types (bool, i64, u64) (#1007) (#1013)
This backports #1007 to v0.1.x.

## Motivation

While using `tracing-opentelemetry` I noticed all the data gets sent to the
collector as a string. This implements the additional data types and (possibly)
saves bandwidth.

## Solution

I just implemented additional `fn record_$type(...)` methods of the
`field::Visit` trait to `SpanEventVisitor` and `SpanAttributeVisitor`.

(cherry picked from commit 04bbb15d3a4c0f74027312b8951484807ca22d48)
2020-10-05 11:18:33 -07:00
Takayuki Maeda
6f01226570
docs: add deny(broken_intra_doc_links) (#981)
## Motivation

In order to get a compiler warning (or error) when links are broken. 
Closes #940

## Solution

- [x] add `deny(broken_intra_doc_links)`
- [x] add a note to the CONTRIBUTING.md documentation on building docs locally

Co-authored-by: Eliza Weisman <eliza@buoyant.io>
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-09-23 10:24:34 -07:00
Julian Tescher
3bda893a6e
opentelemetry: Add PreSampledTracer interface (#962)
## Motivation

Currently the `OpenTelemetryLayer` is coupled to the opentelemetry SDK
in a way that makes using alternate API implementations difficult (they
would have to use the SDK's sampler and id generator) as well as causing
duplication when specifying sampler configuration (it must currently be
set on both the tracer provider configuration as well as the layer
configuration, which is difficult to remember to keep in sync).

## Solution

This change creates an interface for working with pre-sampled tracers,
and implements it for the current opentelemetry SDK. This simplifies the
layer as it no longer needs to track an id generator or sampler, and
allows other otel API implementations to implement the trait rather than
rely on the current SDK.

Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2020-09-01 14:54:07 -07:00
Julian Tescher
9ab7f6eeb1
opentelemetry: Connect external traces (#956)
## Motivation

There are cases where an `opentelemetry` span will be created before a
`tracing` span (e.g. some server middleware). In this case it would be
helpful for `tracing-opentelemetry` to connect generated spans to the
existing trace rather than starting a new trace.

## Solution

If a parent trace id does not exist, check the current otel context and
only generate a new trace id if no valid id is found.
2020-08-25 15:53:38 -07:00
Eliza Weisman
f470db1b03
docs: add a version of the logo with text (#953)
This changes the logo to a wordmark. This should be consistent
with the ones for all the other Tokio crates, when we add them
elsewhere.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-08-24 15:55:00 -07:00
Eliza Weisman
3f8280ae69
docs: consistent MSRV docs & policy explanation (#941)
## Motivation

PR #934 fixed a bug in the CI configuration where MSRV checks were not
being run correctly. After this was fixed, it was necessary to bump the
MSRV to 1.40.0, as the tests were no longer actually passing on 1.39,
because some dependencies no longer support it.

While updating the documentation to indicate that the new MSRV is 1.40,
I noticed that the note on the MSRV was located inconsistently in the
READMEs and `lib.rs` documentation of various crates, and missing
entirely in some cases. Additionally, there have been some questions on
what our MSRV _policies_ are, and whether MSRV bumps are considered
breaking changes (see e.g. #936). 

## Solution

I've updated all the MSRV notes in the documentation and READMEs to
indicate that the MSRV is 1.40. I've also ensured that the MSRV note is
in the same place for every crate (at the end of the "Overview" section
in the docs), and that it's formatted consistently.

Furthermore, I added a new section to the READMEs and `lib.rs` docs
explaining the current MSRV policy in some detail. Hopefully, this
should answer questions like #936 in the future. The MSRV note in the
overview section includes a link to the section with further details.

Finally, while doing this, I noticed a couple of crates
(`tracing-journald` and `tracing-serde`) were missing top-level `lib.rs`
docs. Rather than just adding an MSRV note and nothing else, I went
ahead and fixed this using documentation from those crate's READMEs.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-08-18 12:11:16 -07:00
Julian Tescher
8fd9e7648a
opentelemetry: prepare for v0.7.0 release (#933) 2020-08-14 11:48:29 -07:00
Maxime Bedard
798ed9d31a
Bump to opentelemetry:0.8, opentelemetry-jaeger:0.7 (#932) 2020-08-14 10:35:52 -07:00
Eliza Weisman
bb8e977ab7
docs: fix broken splash graphic link (#913)
Somehow a single line of whitespace is load-bearing I guess? MARKDOWN!

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-08-10 15:24:31 -07:00
Eliza Weisman
59da1ccc60
docs: put splash graphic in all READMEs (#911)
This puts the splash SVG in every crate's README, so
that it will be rendered on crates.io.

I also changed the link to an absolute URL, to ensure that
it works even outside of the repo.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-08-10 14:04:02 -07:00
Jan Kühle
002497bcb4
opentelemetry: set span kind through otel.kind (#890)
OpenTelemetry supports a span kind as special metadata to spans. The
span kind defines relationships between spans (e.g. server vs client).
Some distributed tracing providers use this information to enrich their
UIs.

This makes it possible to set the span kind by adding a special
attribute called `otel.kind`, similar to the existing `otel.name`.
2020-08-05 13:09:17 -07:00
Julian Tescher
c83746a93f
opentelemetry: prepare for v0.6.0 release (#885)
### Breaking Changes

- Upgrade to `v0.7.0` of `opentelemetry` (#867) 
   For list of breaking changes in OpenTelemetry, see the [v0.7.0 changelog](https://github.com/open-telemetry/opentelemetry-rust/blob/master/CHANGELOG.md#v070).
2020-08-04 15:29:49 -07:00
Julian Tescher
4b2e60615f
opentelemetry: Add semantic convention docs (#877)
This branch adds crate-level docs for the otel trace semantic
conventions and their usage as well as notes on stability status.
2020-08-03 17:10:15 -07:00
Julian Tescher
6935338edb
opentelemetry: Upgrade to opentelemetry v0.7.0 (#867)
Upgrade `opentelemetry` to latest release version
2020-07-31 09:29:09 -07:00
Josh Stone
0de7d51689
chore: Include the LICENSE in every crate (#842)
## Motivation

The MIT license states:

> The above copyright notice and this permission notice
> shall be included in all copies or substantial portions
> of the Software.

## Solution

Therefore the LICENSE files should be present in each crate directory,
so they are included with `cargo publish`.
2020-07-23 12:23:04 -07:00
Eliza Weisman
add986d651
chore: add tracing logo to RustDoc (#832)
Now that the new https://tokio.rs is live, we can add the new Tracing
logo to the RustDoc!

I also added a couple missing `html_root_url` attributes in published
crates.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-07-21 14:25:36 -07:00
Luca Palmieri
0b7594dc55
Prevent deadlock panic when using OpenTelemetryLayer with SpanTrace (#765) 2020-06-23 08:18:22 -07:00
Julian Tescher
180e494c7a
opentelemetry: prepare for v0.5.0 release (#744) 2020-06-02 15:15:30 -07:00
Julian Tescher
1cd3a76512
opentelemetry: Upgrade to opentelemetry v0.6.0 (#745) 2020-06-02 13:42:18 -07:00
Coenen Benjamin
93f921c7a0
opentelemetry: filter out invalid parent contexts (#743)
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-06-01 09:13:00 -07:00
Julian Tescher
5e3fa9c0c3
opentelemetry: Fix crate url metadata (#739)
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2020-05-28 12:21:17 -07:00
Julian Tescher
16d1369e3c
opentelemetry: support tracing-log special values (#736)
## Motivation

Currently, when converting `log::Record`s to `tracing::Event`s using
`tracing-log`, data from `log`'s metadata is converted to special fields
prefixed with `log.`, rather than being recorded as `tracing` metadata.
In order to properly display this data from `log`, the `tracing-log`
crate provides the [`NormalizeMetadata`
trait](https://docs.rs/tracing-log/0.1.1/tracing_log/trait.NormalizeEvent.html).
`tracing-opentelemetry` does not currently use this, however, and
location data from `log` events is treated as a regular field rather
than a source code location in OpenTelemetry logs.

## Solution

Update `tracing-opentelemetry`'s `on_event` implementation to format
recorded logs similarly to how `tracing-subscriber::fmt` does. Event
metadata is normalized and intermediate `log.` prefixed values are
properly ignored. This is flagged under a new `tracing-log` feature that
is enabled by default but allows for opting-out.
2020-05-27 13:15:34 -07:00
Julian Tescher
21f28f74bd
opentelemetry: Add dynamic span name field (#732)
opentelemetry: Add dynamic span name field

## Motivation

The OpenTelemetry [spec for HTTP server
request](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/http.md#http-server-semantic-conventions)
span names states that:

> Given an inbound request for a route (e.g. "/users/:userID?") the name
> attribute of the span SHOULD be set to this route. If the route does not
> include the application root, it SHOULD be prepended to the span name.

However, `tracing` span names must be `'static`, so it is currently not
always possible to add this dynamic information.

## Solution

This patch adds support for setting OpenTelemetry span names by
specifying a field named `otel.name` for a given span.

Resolves #720
2020-05-25 20:02:31 -07:00
Justin Carter
74f7764db0
Add on_follows_from to OpenTelemetryLayer (#723) 2020-05-25 19:59:26 -07:00
Julian Tescher
89eee6b9b9
tracing_opentelemetry: Switch to Context propagation (#713)
The [OpenTelemetry Propagation
Spec](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/context/api-propagators.md)
has been changed from operating primarily on `SpanContext`s to a more
generic `Context` struct which is a propagation mechanism that carries
execution-scoped values across API boundaries and between logically
associated execution units.

The following APIs are updated to facilitate this change:

* OpenTelemetrySpanExt's `set_parent` now accepts a reference to an
  extracted parent context.
* OpenTelemetrySpanExt's `context` now returns a context.

Additionally the need to sample spans before their context can be
injected into `Carrier`s necessitates that a `Sampler` is stored in the
`OpenTelemetryLayer`. Accordingly:

* `OpenTelemetryLayer::with_tracer(tracer)` has been removed in favor of
  `tracing_opentelemetry::layer().with_tracer(tracer).with_sampler(sampler)`

Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2020-05-12 21:56:17 -07:00
Julian Tescher
5a971befac
Import tracing-opentelemetry (#700)
Import `tracing-opentelemetry` from 
https://github.com/jtescher/tracing-opentelemetry

Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2020-04-30 16:32:31 -07:00