* Let SynchronizedMove(nil) reset and discard
* Add common test for SynchronizedMove(nil)
* End-to-end test for the Processor and SumObserver
* Implement SynchronizedMove(nil) six ways
* Lint
* Changelog
* Test no reset for wrong aggregator type; Fix four Aggregators
* Cleanup
* imports
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Enable support for externally-defined ID generators
* Moved the SDK's `internal.IDGenerator` interface to the `sdk/trace`
package.
* Added `trace.WithIDGenerator()` `TracerProviderOption`.
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Update CHANGELOG.md with PR info
* Address PR feedback:
* Fix IDGenerator godoc comment
* rename type defaultIDGenerator to randomIDGenerator
* rename defIDGenerator() to defaultIDGenerator()
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Rework trace.IDGenerator interface
* NewTraceID() -> NewIDs(ctx)
** Returns both TraceID and SpanID
* NewSpanID() -> NewSpanID(ctx, traceID)
** Returns only SpanID, has access to TraceID
* Both methods now receive a context, from which they may extract
information
* startSpanInternal() updated to receive a context to pass to the ID
generator
* Drop outdated comment from docblock
Co-authored-by: Krzesimir Nowak <qdlacz@gmail.com>
Co-authored-by: Krzesimir Nowak <qdlacz@gmail.com>
* Rework proto generation
The changes here are:
- Fix the default goal (using "default" target is not doing it).
- Bail out with a useful message if proto submodule is not checked
out.
- Replace the use of docker image with downloading the protoc binary
and building the gogofast plugin ourselves. This gives us a greater
control over the invocation of protoc.
- Use rsync to copy the generated code, instead of pax. Pax did not
work for me (it was complaining about the unknown -0 flag).
The control over the protoc invocation will be useful later, when we
will want to generate a code with data structures in one place and the
collector code elsewhere. The collector code may or may not depend on
gRPC, but data structures have no need for it. This split will happen
when we move the gRPC code out of the OTLP exporter module into a
submodule.
Getting rid of docker has the upside that the generated files do not
belong to root, so there is no hassle of changing the ownership of the
files, and it is not requires to use sudo for the `clean` target. And
not using docker is faster.
The downside of this work is that it depends on more tools: rsync,
unzip and wget. I can only hope that macOS users have those tools too,
and that those tools are invoked the same.
* Update protogen workflow
* chore(zipkin-exporter): relay on the status code for the request but still read the response body.
* fix(zipkin-exporter): fix tests.
* chore(zipkin-exporter): adds changelog.
* chore: 202 -> http.StatusAccepted
Co-authored-by: Chris Bandy <bandy.chris@gmail.com>
* chore: 202 -> http.StatusAccepted
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
Co-authored-by: Chris Bandy <bandy.chris@gmail.com>
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Examples are "leaf" packages, that pull some other packages. So build
the other packages first to get and fix all the errors there, before
building the examples.
* Move connection logic into grpcConnection object
If we will need to maintain more than one connection in future, this
splitting off will come in handy.
Co-authored-by: Stefan Prisca <stefan.prisca@gmail.com>
* Make another channel a signal channel
There is another channel that serves as a one-time signal, where
channel's data type does not matter.
* Reorder and document connection members
This is to make clear that the lock is guarding only the connection
since it can be changed by multiple goroutines, and other members are
either atomic or read-only.
* Move stop signal into connection
The stop channel was rather useless on the exporter side - the primary
reason for existence of this channel is to stop a background
reconnecting goroutine. Since the goroutine lives entirely within
grpcConnection object, move the stop channel here. Also expose a
function to unify the stop channel with the context cancellation, so
exporter can use it without knowing anything about stop channels.
Also make export functions a bit more consistent.
* Do not run reconnection routine when being stopped too
It's possible that both disconnected channel and stop channel will be
triggered around the same time, so the goroutine is as likely to start
reconnecting as to return from the goroutine. Make sure we return if
the stop channel is closed.
* Nil clients on connection error
Set clients to nil on connection error, so we don't try to send the
data over a bad connection, but return a "no client" error
immediately.
* Do not call new connection handler within critical section
It's rather risky to call a callback coming from outside within a
critical section. Move it out.
* Add context parameter to connection routines
Connecting to the collector may also take its time, so it can be
useful in some cases to pass a context with a deadline. Currently we
just pass a background context, so this commit does not really change
any behavior. The follow-up commits will make a use of it, though.
* Add context parameter to NewExporter and Start
It makes it possible to limit the time spent on connecting to the
collector.
* Stop connecting on shutdown
Dialling to grpc service ignored the closing of the stop channel, but
this can be easily changed.
* Close connection after background is shut down
That way we can make sure that there won't be a window between closing
a connection and waiting for the background goroutine to return, where
the new connection could be established.
* Remove unnecessary nil check
This member is never nil, unless the Exporter is created like
&Exporter{}, which is not a thing we support anyway.
* Update changelog
Co-authored-by: Stefan Prisca <stefan.prisca@gmail.com>
* Drop WorkerCount option
This is not a good option - the user isn't likely to know how many
worker goroutines is optimal. This should be something that an
exporter should figure out itself. The second problem with the option
is that it is specific to the metric transformation from SDK export
format into protobuf. When the exporter starts supporting other
protocols (HTTP/JSON for example), this option may be of no use. So
the option should rather belong to the protocol, not to the
exporter. Currently both mean the same, but later they will be
separated, and this option breaks the separation.
* Make stop channel a typical signalling channel
Signalling channels are idiomatically defined as chan struct{}, so
let's make it so, to avoid confusion about the meaning of the bool
type.
* Close a race when grpc connection is closed multiple times
If several goroutines call Shutdown at the same time, then the
following scenario is possible:
goroutine A locks a mutex, reads a started member, unlocks the mutex
and gets preempted
goroutine B locks a mutex, reads a started member, unlocks the mutex
and gets preempted
goroutine A does not return early in the "if !started" conditional and
continues to close the connection and execute the rest of the function
(where it finally sets the started member to false), gets preempted
goroutine B also does not return early, because it got a copy of
started before goroutine A set it to false, so it tries to close the
connection again.
* Update changelog
* support exact kind in OTLP metrics exporter
* add change log
* rename function
* inline start time and end time variables
* fix test
* add test for exact int data points
* add test for exact float data points
* use newly introduced number package for numbers according to upstream change
* fix package ref
* Move global code to toplevel package
* Move version function to toplevel package
* Update changelog
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Add parent context to SpanProcessor.OnStart
The spec requires doing so. Right now SpanProcessor implementations
aren't doing anything with this argument.
* Update changelog
* Fix typo in test name
* Move registry package under metric
* Move Number type to the metric/number subpackage
This also renames NumberKind type to Kind.
* Update changelog
* Drop outdated comment
* Export non monotonic counters as gauge values from the prometheus exporter
* Add a test to ensure the pre-existing LastValue pathway on the collector exports the last value
* Add a TODO around refactoring the prometheus test to verify metadata as well
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Update Span End method documentation
Updates to the Span after End is called result it potentially
inconsistent views of the Span between the code defining it and the
ultimate receiver of the Span data. This corrects the documented
language of the API to prevent this from happening.
* Add changes to changelog
Remove cruft about spanStore.
Update documentation about how span.mu is used (related to #1311).
Reformat to conform with idiomatic field documentation.
* Update README
Move project status to top of project documentation and add explicit
warnings that this project may introduce breaking changes.
* Add disclaimer to public packages docs
* Use explicit warning in README
* Remove quotes from UnmarshalJSON
Signed-off-by: Daniil Rutskiy <dstdfx@gmail.com>
* Update CHANGELOG.md
Signed-off-by: Daniil Rutskiy <dstdfx@gmail.com>
* Fix issue number in CHANGELOG.md
* Fix 'Code.UnmarshalJSON' to work with valid json only
Signed-off-by: Daniil Rutskiy <dstdfx@gmail.com>
* Extend test data for TestCodeUnmarshalJSONErrorInvalidData
Signed-off-by: Daniil Rutskiy <dstdfx@gmail.com>
* Delete useless cond, extend test data
Signed-off-by: Daniil Rutskiy <dstdfx@gmail.com>