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 17 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
74 changes: 74 additions & 0 deletions text/0000-named-tracers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Named Tracers
z1c0 marked this conversation as resolved.
Show resolved Hide resolved

**Status:** `proposed`

z1c0 marked this conversation as resolved.
Show resolved Hide resolved
_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)

## Motivation

Instead of having a global tracer singleton, every instrumentation library needs to create its own tracer, which also has a proper name that identifies the library / logical component that uses this tracer. If there are two different instrumentation libraries for the same technology (e.g. MongoDb), these instrumentation libraries should have distinct names. In this sense, this proposal suggests the introduction of a "semantic namespace" concept for tracers and the resulting spans.
z1c0 marked this conversation as resolved.
Show resolved Hide resolved
z1c0 marked this conversation as resolved.
Show resolved Hide resolved

The purpose of _Named Tracers_ is the ability to allow for associating an identifier (e.g. _"io.opentelemetry.contrib.mongodb"_) with a tracer. This further allows for logical and semantic coupling of this tracer and a certain technology or library (like _MongoDB_ in this example). Having named tracers enables support for having a dedicated property (component) depending on this name on a tracer that is different for different libraries.
z1c0 marked this conversation as resolved.
Show resolved Hide resolved
z1c0 marked this conversation as resolved.
Show resolved Hide resolved

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.
z1c0 marked this conversation as resolved.
Show resolved Hide resolved


## Explanation

From a user perspective, working with *Named Tracers* and *TracerFactories* is very 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'.

```java
Tracer tracer = OpenTelemetry.getTracerFactory().getTracer("io.opentelemetry.contrib.mongodb");
z1c0 marked this conversation as resolved.
Show resolved Hide resolved
```

In a way, the `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.

In the simplest case, an OpenTelemetry implementation can return a single instance for a requested tracer, regardless of the name specified as long as the name given for the tracer
z1c0 marked this conversation as resolved.
Show resolved Hide resolved

Alternatively, an implementation can provide different tracer instances per specified tracer name, thus being able to associate this tracer with the `component` being traced.

## Prior art and alternatives

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.
z1c0 marked this conversation as resolved.
Show resolved Hide resolved

```java
TraceComponent traceComponent = OpenTelemetry.Tracing.getTracer().componentBuilder("io.opentelemetry.contrib.mongodb");
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

By adapting this proposal, current implementations that do not honor the specified tracer name and provide a single global tracer, would not require much change. However they could change that behavior in future versions and provide more specific tracer implementations then. On the other side, if the mechanism of *Named Tracers* is not a part of the initial specification, such scenarios will be prevented and hard to retrofit in future version, should they be deemed necessary then.
z1c0 marked this conversation as resolved.
Show resolved Hide resolved

## 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)