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

Propose "Named Tracers" #16

Merged
merged 34 commits into from
Sep 26, 2019
Merged
Changes from 23 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
67f199a
First draft: "named tracers"
z1c0 Aug 8, 2019
5c6c2b6
Implement feedback.
z1c0 Aug 8, 2019
dd23e27
Merge pull request #1 from z1c0/master
z1c0 Aug 12, 2019
c68f45d
Merge remote-tracking branch 'upstream/master'
z1c0 Aug 12, 2019
92104bd
Move named tracers proposal into text folder
z1c0 Aug 12, 2019
93ff941
Merge pull request #2 from z1c0/master
z1c0 Aug 12, 2019
5f7f2a0
Apply suggestions from code review
z1c0 Aug 13, 2019
f628980
Apply suggestions from code review
z1c0 Aug 13, 2019
0a676a5
Add examples section.
z1c0 Aug 13, 2019
3c4d150
Update 0000-named-tracers.md
z1c0 Aug 13, 2019
17de20c
Merge pull request #4 from dynatrace-oss-contrib/z1c0-patch-2
z1c0 Aug 14, 2019
40d93e3
Merge branch 'master' into master
z1c0 Aug 14, 2019
94c4b9c
Merge branch 'master' into master
bogdandrutu Aug 27, 2019
eba8220
Implement feedback from code review
z1c0 Aug 28, 2019
6192c93
Merge branch 'master' of https://github.com/open-telemetry/oteps
Oberon00 Aug 30, 2019
368f6fd
Remove the implementation details about enabling / disabling ... of
z1c0 Sep 16, 2019
8219749
Merge branch 'master' into master
z1c0 Sep 16, 2019
890fd79
Update text/0000-named-tracers.md
z1c0 Sep 17, 2019
c905402
Update text/0000-named-tracers.md
z1c0 Sep 17, 2019
db2f617
Reworked this RFC based on feedback on GitHub.
z1c0 Sep 19, 2019
a8f344f
Merge branch 'master' into master
z1c0 Sep 19, 2019
c747703
Implement latest review suggestions
z1c0 Sep 20, 2019
22df407
Merge branch 'master' of https://github.com/dynatrace-oss-contrib/rfcs
z1c0 Sep 20, 2019
cfde119
Removed formatting
z1c0 Sep 22, 2019
f83fb87
Re-introduce plain string factory and move Resource-based approach to…
z1c0 Sep 24, 2019
f569a2a
Merge branch 'master' into master
z1c0 Sep 24, 2019
8a882f2
Use ` to format the names in the examples.
bogdandrutu Sep 24, 2019
617f5f8
Fix typo and broken link
z1c0 Sep 25, 2019
fe68315
Merge branch 'master' of https://github.com/dynatrace-oss-contrib/rfcs
z1c0 Sep 25, 2019
005cfa2
Extended the OTEP to included Metrics as well.
z1c0 Sep 26, 2019
124bc83
Update text/0000-named-tracers.md
z1c0 Sep 26, 2019
f618455
Update text/0000-named-tracers.md
z1c0 Sep 26, 2019
595f19d
Implement latest feedback.
z1c0 Sep 26, 2019
995819d
Rename 0000-named-tracers.md to 0016-named-tracers.md
bogdandrutu Sep 26, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions text/0000-named-tracers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Named Tracers
z1c0 marked this conversation as resolved.
Show resolved Hide resolved

z1c0 marked this conversation as resolved.
Show resolved Hide resolved
**Status:** `proposed`

_Creating Tracers using a factory mechanism and naming those Tracers in accordance with the library that provides the instrumentation for a traced component._

## Suggested reading

* [Proposal: Tracer Components](https://github.com/open-telemetry/opentelemetry-specification/issues/10)
* [Global Instance discussions](https://github.com/open-telemetry/opentelemetry-specification/labels/global%20instance)
* [Proposal: Add a version resource](https://github.com/open-telemetry/oteps/pull/38)

## Motivation

The mechanism of "Named Tracers" proposed here is motivated by following scenarios:

* For a consumer of OpenTelemetry instrumentation libraries, there is currently no possibility of influencing the amount of the data produced by such libraries. Instrumentation libraries can easily "spam" backend systems, deliver bogus data or - in the worst case - crash or slow down applications. These problems might even occur suddenly in production environments caused by external factors such as increasing load or unexpected input data.
z1c0 marked this conversation as resolved.
Show resolved Hide resolved

* If a library hasn't implemented [semantic conventions](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-semantic-conventions.md) correctly or those conventions change over time, it's currently hard to interpret and sanitize these data selectively. The produced Spans cannot associated with those instrumentation libraries later.
z1c0 marked this conversation as resolved.
Show resolved Hide resolved

This proposal attempts to solve the stated problems by introducing the concept of:
* _Named Tracers_ identified via a Resource (e.g. _"io.opentelemetry.contrib.mongodb"_, _"1.0.0"_) which is associated with the Tracer and the Spans it produces.
* A `TracerFactory` as the only means of creating a Tracer.

Based on such an identifier, a Sampler could be implemented that discards Spans from certain libraries. Also, by providing a custom Exporter, Span data could be sanitized before it gets processed in a back-end system. However, this is beyond the scope of this proposal, which only provides the fundamental mechanisms.

## Explanation

From a user perspective, working with *Named Tracers* and *TracerFactories* is conceptually similar to how e.g. the [Java logging API](https://docs.oracle.com/javase/7/docs/api/java/util/logging/Logger.html#getLogger(java.lang.String)) and logging frameworks like [log4j](https://www.slf4j.org/apidocs/org/slf4j/LoggerFactory.html) work. In analogy to requesting Logger objects through LoggerFactories, a tracing library would create specific 'Tracer' objects through a 'TracerFactory'.

Instead of using plain strings as an argument for creating new Tracers a Resource identifying an instrumentation library is used. Such resources must have a _version_ and _name_ labels (there could be semantic convention definitions for those labels). Version values will follow the conventions proposed [here](https://github.com/open-telemetry/oteps/pull/38).
z1c0 marked this conversation as resolved.
Show resolved Hide resolved

z1c0 marked this conversation as resolved.
Show resolved Hide resolved

```java
// Create resource for given instrumentation library information (name + version)
Map<String, String> libraryLabels = new HashMap<>();
libraryLabels.put("name", "io.opentelemetry.contrib.mongodb");
libraryLabels.put("version", "1.0.0");
z1c0 marked this conversation as resolved.
Show resolved Hide resolved
Resource libraryResource = Resource.create(libraryLabels);
// Create tracer for given instrumentation library.
Tracer tracer = OpenTelemetry.getTracerFactory().getTracer(libraryResource);
z1c0 marked this conversation as resolved.
Show resolved Hide resolved
```

This `TracerFactory` replaces the global `Tracer` singleton object as a ubiquitous point to request a Tracer instance.

## Internal details

By providing a `TracerFactory` and *Named Tracers*, a vendor or OpenTelemetry implementation gains more flexibility in providing Tracers and which attributes they set in the resulting spans that are produced.

The SpanData class is extended with a `getLibraryResource` function that returns the resource associated with the Tracer that created the span.
z1c0 marked this conversation as resolved.
Show resolved Hide resolved

If there are two different instrumentation libraries for the same technology (e.g. MongoDb), these instrumentation libraries should have distinct names.
z1c0 marked this conversation as resolved.
Show resolved Hide resolved

## Prior art and alternatives

This proposal originates from an `opentelemetry-specification` proposal on [components](https://github.com/open-telemetry/opentelemetry-specification/issues/10) since having a concept of named Tracers would automatically enable determining this semantic `component` property.


Alternatively, instead of having a `TracerFactory`, existing (global) Tracers could return additional indirection objects (called e.g. `TraceComponent`), which would be able to produce spans for specifically named traced components.

```java
TraceComponent traceComponent = OpenTelemetry.Tracing.getTracer().componentBuilder(libraryResource);
Span span = traceComponent.spanBuilder("someMethod").startSpan();
```

Overall, this would not change a lot compared to the `TracerFactory` since the levels of indirection until producing an actual span are the same.

Instead of setting the `component` property based on the given Tracer names, those names could also be used as *prefixes* for produced span names (e.g. `<TracerName-SpanName>`). However, with regard to data quality and semantic conventions, a dedicated `component` set on spans is probably preferred.

## Future possibilities

Based on the Resource information identifying a Tracer these could be configured (enabled / disabled) programmatically or via external configuration sources (e.g. environment).

## Examples (of Tracer names)

Since Tracer names describe the libraries which use the Tracers, those names should be defined in a way that makes them as unique as possible. The name of the Tracer should represent the identity of the library, class or package that provides the instrumentation.

Examples (based on existing contribution libraries from OpenTracing and OpenCensus):

* _io.opentracing.contrib.spring.rabbitmq_
z1c0 marked this conversation as resolved.
Show resolved Hide resolved
* _io.opentracing.contrib.jdbc_
* _io.opentracing.thrift_
* _io.opentracing.contrib.asynchttpclient_
* _io.opencensus.contrib.http.servlet_
* _io.opencensus.contrib.spring.sleuth.v1x_
* _io.opencensus.contrib.http.jaxrs_
* _github.com/opentracing-contrib/go-amqp_ (Go)
* _github.com/opentracing-contrib/go-grpc_ (Go)
* _OpenTracing.Contrib.NetCore.AspNetCore_ (.NET)
* _OpenTracing.Contrib.NetCore.EntityFrameworkCore_ (.NET)