Fixes unresolved issue identified in #691 and attempted in #697.
Adds unit test to ensure the UnaryServerInfo function does not panic
during an error returned from the handler and appropriately annotates
the span with the correct event.
Restructures the interceptor to remove this class of errors.
Co-authored-by: Joshua MacDonald <jmacd@users.noreply.github.com>
* Point to the convenience functions in api/key package
This is to increase the visibility of the api/key package through the
api/core package, otherwise developers often tend to miss the api/key
package altogether and write `core.Key(name).TYPE(value)` and complain
at the verbosity of such a construction. The api/key package would
allow them to write `key.TYPE(name, value)`.
* Use the api/key package where applicable
This transforms all the uses of `core.Key(name).TYPE(value)` to
`key.TYPE(name, value)`. This also should help increasing the
visibility of the api/key package for developers reading the otel-go
code.
Co-authored-by: Joshua MacDonald <jmacd@users.noreply.github.com>
* othttp: add RemoteAddrKey for HTTP client address
Include the requesting HTTP client's network address in each top-level
span emitted by othttp.NewHandler.
* Copyedit documentation for attribute keys
* Ensure spans created by httptrace client tracer reflect operation structure
* Cleanup (clientTracer).start based on PR feedback
* Ensure a span is recorded even if end() is called before start()
* Ensure start attributes for spans started by (clientTracer).end() are recorded
Co-authored-by: Rahul Patel <rahulpa@google.com>
Update license header to standard format for source files missed prior.
Add license header to new source files.
Add Makefile check to test all `*.go` and `*.sh` files have a copyright
notice (or comment about them being auto-generated) within the first few
lines.
* Update License header for all source files
- Add Apache 2.0 header to source files that did not have one.
- Update all existing headers dated to 2019 to be 2020
- Remove comma from License header to comply with the Apache 2.0
guidelines.
* Update Copyright notice
Use the standard Copyright notices outlined by the
[CNCF](https://github.com/cncf/foundation/blob/master/copyright-notices.md#copyright-notices)
* Add request filtering capability to othhtp.Handler
* Add simple and useful filters for othttp plugin
* Add note that all requests are traced in the absence of any filters
* Add copyright notice to plugin/othttp/filters/filters_test.go
Co-Authored-By: Tyler Yahn <MrAlias@users.noreply.github.com>
* Add package docstring for filters package
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Rahul Patel <rahulpa@google.com>
* Add global propagators
The default global propagators are set to the chained W3C trace and
correlation context propagators.
* Use global propagators in plugins
The httptrace and grpcplugins should also get some API for setting a
propagator to use (the othttp plugin already has such an API), but
that can come in some other PR.
* Decrease indentation in trace propagators
* Drop obsolete TODOs
Now we do "something" with correlation context - it ends up in the
context, and we put the context into the request, so the chained HTTP
handler can access it too.
The other TODO was about tag.Upsert which is long gone.
* Do not unnecessarily update the request context
The request context already contains the span (and we add some
attribute there), so inserting it into context again is pointless.
Co-authored-by: Joshua MacDonald <jmacd@users.noreply.github.com>
* Drop bogus comment, fix typo
A result of copy-pasting.
* Unexport HTTP header constants
* Rename instruments in tests
"ajwaj" is my favourite placeholder text, but seems like I forgot to
replace its occurences with proper names.
Co-authored-by: Rahul Patel <rghetia@yahoo.com>
The `go.opentelemetry.io/otel/exporter/trace/jaeger` package was
mistakenly released with a `v1.0.0` tag instead of `v0.1.0`. This
resulted in all subsequent releases not becoming the default latest,
meaning that `go get`s pulled in the incompatible `v0.1.0` release of
that package when pulling in more recent packages from other otel
packages. Renaming the `exporter` directory to `exporters` fixes this
issue by consequentially renaming the package.
Additionally, this action also renames *all* exporters. This is
understood to be a disruptive action to existing users as they will need
to update any dependencies they currently have on our exporters.
However, it was decided to take this action regardless. The need to
resolve the existing issue explained above is highly important, and
given the Alpha state of this project these kinds of breaking changes
should be expected (though not without reason).
Resolves#331
Co-authored-by: Rahul Patel <rghetia@yahoo.com>
It would be nice to follow a single schema for naming context
functions. In the trace package we followed the form FooFromContext
and ContextWithFoo. Do the same in the correlation package. The schema
WithFoo is mainly used for functions following the options pattern.
Not sure about a name of the NewContext function, though. For now I
have left it alone.
Co-authored-by: Rahul Patel <rghetia@yahoo.com>
Correlation context propagation shouldn't be a part of the trace
package - it is a different aspect of the propagation cross-cutting
concern.
This commit also adds a DefaultHTTPPropagator function for correlation
context propagation and makes the plugins use it.
Co-authored-by: Joshua MacDonald <jmacd@users.noreply.github.com>
* Remove binary propagators
They are in process of being dropped from the specification and we
haven't be using them anywhere in the project. Can reintroduce them
later.
* Rename Supplier to HTTPSupplier
The supplier is used only in HTTP propagators currently. It's not
clear if it will be useful for binary propagators if they get to be
specified at some point.
* Rework propagation interfaces
The biggest change here is that HTTP extractors return a new context
with whatever information the propagator is able to retrieve from the
supplier. Such interface does not hardcode any extractor's
functionality (like it was before by explicitly returning a span
context and correlation context) and makes it easy to chain multiple
propagators.
Injection part hasn't changed.
* Add Propagators interface
This interface (and its default implementation) is likely going to be
the propagation API used the most. Single injectors, extractors or
propagators are likely going to be used just as parameters to the
Option functions that configure the Propagators implementation.
* Drop noop propagator
It's rather pointless - just create an empty Propagators instance.
* Fix wrong name in docs
Co-authored-by: Joshua MacDonald <jmacd@users.noreply.github.com>
This PR removes the non-compliant ChildOf and FollowsFrom interfaces
and the Relation type, which were inherited from OpenTracing via the
initial prototype. Instead allow adding a span context to the go
context as a remote span context and use a simple algorithm for
figuring out an actual parent of the new span, which was proposed for
the OpenTelemetry specification.
Also add a way to ignore current span and remote span context in go
context, so we can force the tracer to create a new root span - a span
with a new trace ID.
That required some moderate changes in the opentracing bridge - first
reference with ChildOfRef reference type becomes a local parent, the
rest become links. This also fixes links handling in the meantime. The
downside of the approach proposed here is that we can only set the
remote parent when creating a span through the opentracing API.
Co-authored-by: Joshua MacDonald <jmacd@users.noreply.github.com>
* Remove Vendor constants from tracing plugins
Unused. And confusing, since "ot" may mean "opentracing" as well.
* Simplify current span key declaration
No need for a block.
* Fix typo
Co-authored-by: Joshua MacDonald <jmacd@users.noreply.github.com>
* Rename distributedcontext package to correlation
Correlation is the name we agreed upon.
* Move trace propagators to api/trace
The trace propagators tests had to be moved to a testtrace subpackage
to avoid import cycles between api/trace and internal/trace.
Needed to shut up golint about stutter in trace.TraceContext -
TraceContext is a name of a W3C spec, so this stutter is
expected. It's certainly still better than golint's suggestion of
having trace.Context.
* Rename api/propagators to api/propagation
This package will not contain any propagators in the long run, just
the interface definitions.
Co-authored-by: Joshua MacDonald <jmacd@users.noreply.github.com>
Spans should not have the Tracer name as a prefix for their names. This
removes the `spanNameWithPrefix` function and instead passes through the
span name unmodified wherever this had been called.
Tests that checked Span names are updated to have the non-prefix
expected names.