* Rename `otlp.WithAddress` to `otlp.WithEndpoint`
* Unify the term of the endpoint from exporter
* Update CHANGELOG
* Update example/otel-collector/main.go
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Switch to the full word collector
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Tyler Yahn <codingalias@gmail.com>
* Add a split protocol driver
This is a wrapper around two other protocol drivers, so it makes it
possible to send traces using a different protocol than the one used
for metrics.
* Add an example and tests for multi GRPC endpoint driver
* Update changelog
* Document the split driver
* Add TraceState to API
* Add tests for TraceState
* Update related tests
- stdout exporter test
- SDK test
* Update OTLP span transform
* Update CHANGELOG
* Change TraceState to struct instead of pointer
- Adjust tests for trace API
- Adjust adjacent parts of codebase (test utils, SDK etc.)
* Add methods to assert equality
- for type SpanContext, if SpanID, TraceID, TraceFlag and TraceState are
equal
- for type TraceState, if entries of both respective trace states are
equal
Signed-off-by: Matej Gera <matejgera@gmail.com>
* Copy values for new TraceState, adjust tests
* Use IsEqualWith in remaining tests instead of assertion func
* Further feedback, minor improvements
- Move IsEqualWith method to be only in test package
- Minor improvements, typos etc.
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Split protocol handling away from exporter
This commits adds a ProtocolDriver interface, which the exporter
will use to connect to the collector and send both metrics and traces
to it. That way, the Exporter type is free from dealing with any
connection/protocol details, as this business is taken over by the
implementations of the ProtocolDriver interface.
The gRPC code from the exporter is moved into the implementation of
ProtocolDriver. Currently it only maintains a single connection,
just as the Exporter used to do.
With the split, most of the Exporter options became actually gRPC
connection manager's options. Currently the only option that remained
to be Exporter's is about setting the export kind selector.
* Update changelog
* Increase the test coverage of GRPC driver
* Do not close a channel with multiple senders
The disconnected channel can be used for sending by multiple
goroutines (for example, by metric controller and span processor), so
this channel should not be closed at all. Dropping this line closes a
race between closing a channel and sending to it.
* Simplify new connection handler
The callbacks never return an error, so drop the return type from it.
* Access clients under a lock
The client may change as a result on reconnection in background, so
guard against a racy access.
* Simplify the GRPC driver a bit
The config type was exported earlier to have a consistent way of
configuring the driver, when also the multiple connection driver would
appear. Since we are not going to add a multiple connection driver,
pass the options directly to the driver constructor. Also shorten the
name of the constructor to `NewGRPCDriver`.
* Merge common gRPC code back into the driver
The common code was supposed to be shared between single connection
driver and multiple connection driver, but since the latter won't be
happening, it makes no sense to keep the not-so-common code in a
separate file. Also drop some abstraction too.
* Rename the file with gRPC driver implementation
* Update changelog
* Sleep for a second to trigger the timeout
Sometimes CI has it's better moments, so it's blazing fast and manages
to finish shutting the exporter down within the 1 microsecond timeout.
* Increase the timeout for shutting down the exporter
One millisecond is quite short, and I was getting failures locally or
in CI:
go test ./... + race in ./exporters/otlp
2020/12/14 18:27:54 rpc error: code = Canceled desc = context canceled
2020/12/14 18:27:54 context deadline exceeded
--- FAIL: TestNewExporter_withMultipleAttributeTypes (0.37s)
otlp_integration_test.go:541: resource span count: got 0, want 1
FAIL
FAIL go.opentelemetry.io/otel/exporters/otlp 5.278s
or
go test ./... + coverage in ./exporters/otlp
2020/12/14 17:41:16 rpc error: code = Canceled desc = context canceled
2020/12/14 17:41:16 exporter disconnected
--- FAIL: TestNewExporter_endToEnd (1.53s)
--- FAIL: TestNewExporter_endToEnd/WithCompressor (0.41s)
otlp_integration_test.go:246: span counts: got 3, want 4
2020/12/14 17:41:18 context canceled
FAIL
coverage: 35.3% of statements in ./...
FAIL go.opentelemetry.io/otel/exporters/otlp 4.753s
* Shut down the providers in end to end test
This is to make sure that all batched spans are actually flushed
before closing the exporter.
* Store span data directly in the span
- Nesting only some of a span's data in a `data` field (with the rest
of the data living direclty in the `span` struct) is confusing.
- export.SpanData is meant to be an immutable *snapshot* of a span,
not the "authoritative" state of the span.
- Refactor attributesMap.toSpanData into toKeyValue and make it
return a []label.KeyValue which is clearer than modifying a struct
passed to the function.
- Read droppedCount from the attributesMap as a separate operation
instead of setting it from within attributesMap.toSpanData.
- Set a span's end time in the span itself rather than in the
SpanData to allow reading the span's end time after a span has
ended.
- Set a span's end time as soon as possible within span.End so that
we don't influence the span's end time with operations such as
fetching span processors and generating span data.
- Remove error handling for uninitialized spans. This check seems to
be necessary only because we used to have an *export.SpanData field
which could be nil. Now that we no longer have this field I think we
can safely remove the check. The error isn't used anywhere else so
remove it, too.
* Store parent as trace.SpanContext
The spec requires that the parent field of a Span be a Span, a
SpanContext or null.
Rather than extracting the parent's span ID from the trace.SpanContext
which we get from the tracer, store the trace.SpanContext as is and
explicitly extract the parent's span ID where necessary.
* Add ReadOnlySpan interface
Use this interface instead of export.SpanData in places where reading
information from a span is necessary. Use export.SpanData only when
exporting spans.
* Add ReadWriteSpan interface
Use this interface instead of export.SpanData in places where it is
necessary to read information from a span and write to it at the same
time.
* Rename export.SpanData to SpanSnapshot
SpanSnapshot represents the nature of this type as well as its
intended use more accurately.
Clarify the purpose of SpanSnapshot in the docs and emphasize what
should and should not be done with it.
* Rephrase attributesMap doc comment
"refreshes" is wrong for plural ("updates").
* Refactor span.End()
- Improve accuracy of span duration. Record span end time ASAP. We
want to measure a user operation as accurately as possible, which
means we want to mark the end time of a span as soon as possible
after span.End() is called. Any operations we do inside span.End()
before storing the end time affect the total duration of the span,
and although these operations are rather fast at the moment they
still seem to affect the duration of the span by "artificially"
adding time between the start and end timestamps. This is relevant
only in cases where the end time isn't explicitly specified.
- Remove redundant idempotence check. Now that IsRecording() is based
on the value of span.endTime, IsRecording() will always return
false after span.End() had been called because span.endTime won't
be zero. This means we no longer need span.endOnce.
- Improve TestEndSpanTwice so that it also ensures subsequent calls
to span.End() don't modify the span's end time.
* Update changelog
Co-authored-by: Tyler Yahn <codingalias@gmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* 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>
* 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>
* 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 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
* Add a Shutdown method to api TraceProvider
- sdktraceprovider shutdown span processors
- In examples, replace processosr shutdown with
traceprovider's shutdown
Signed-off-by: Hui Kang <kangh@us.ibm.com>
* remove shutdown in the api provider interface
* Add context in parameter and return error
* handle error in shutdown
* Update CHANGELOG.md
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Update metric Kind to InstrumentKind
* Update all the other modules with Kind rename
* Update metric Descriptor with instrument Kind rename
* Update other modules with Descriptor method rename
* Update OTLP exporter test field name
* Rename kind filenames
* Add changes to CHANGELOG
* Fix documentation for Grouping and PrecomputedSum
* Rename meter.go to metric.go
* Move descriptor.go into metric.go
* Move must.go into metric.go
* Move instruments into metric_instrument.go
* Rename metric api_test.go to metric_test.go
* Move instrumentkind_test.go into metric_test.go
* Rename sdkapi.go metric_sdkapi.go
* Move api/metric into otel
* Update to use moved packages
* Rename otel.go to error_handler.go
* Add changes to CHANGELOG
* Fix merge conflict resolution error
* Update metric Kind to InstrumentKind
* Update all the other modules with Kind rename
* Update metric Descriptor with instrument Kind rename
* Update other modules with Descriptor method rename
* Update OTLP exporter test field name
* Rename kind filenames
* Add changes to CHANGELOG
* Fix documentation for Grouping and PrecomputedSum
* Update documentation for the OTLP exporter
Update package documentation to reflect the contents of the package.
Fix lint issues by adding documentation for all exported types.
Update file comment location in otlp.go so golint does not interpret it
as package documentation.
* Apply suggestions from code review
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
* Updating version of OTLP to 0.5.0
* updating trace transform to use latest protos
* update otlp span test
* forgot one test
* finishing the rest of the implementation
In this change:
- MetricDescriptor is no longer a member of the metric
- splitting Sum, Gauge, Histogram by Int/Float
- SummaryDataPoints are no longer around, MinMaxSumCount is now a Histogram
* update changelog
* Update CHANGELOG.md
Move changes to the Unreleased section. This is to account for the recent release.
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Move trace API to otel
* Move tracetest to oteltest
* Update package documentation
* Remove old api/trace package
* Lint
* Add changes to CHANGELOG
* Add tests for rest of trace API
* Apply suggestions from code review
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
* Documentation fixes
Includes resolutions for review issues.
* Correct CHANGELOG post release
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
* Update label.ArrayValue to store copies of 1D arrays
* Update OTLP transform of array attributes
* Add changes to CHANGELOG
* Add PR number to changes
* Update value function documentation
* Remove redundant checks
* Add Array test for invalid array types
* Add test to ensure return from AsArray is a type
* Clean up iteration
* Update codes to match specification
* Add changes to changelog
* go mod tidy
* Add unit tests for codes
* Update SetStatus methods to only filter Unset
* Update apitest code being tested
* Rename *Provider names
There is overlap in naming with MeterProviders and TracerProviders. This
is means the specification is not implemented and these types can not
exist in the same package (#1179). This makes each type and related
functions and types explicit.
* Add changes to CHANGELOG
* Update trace export interface
Move to conforming to the specification.
* Update documentation in export trace
* Update sdk trace provider to support new trace exporter
* Update SpanProcessors
Support the Provider changes and new trace exporter.
* Update the SDK to support the changes
* Update trace Provider to not return an error
* Update sdk with new Provider return
Also fix the testExporter ExportSpans method
* Update exporters with changes
* Update examples with changes
* Update Changelog
* Move error handling to end of shutdown
* Update exporter interface
Rename to SpanExporter to match specification. Add an error return value
to the Shutdown method based on feedback. Propagate these changes.
Remove the Stop method from the OTLP exporter to avoid confusion and
redundancy.
* Add test to check OTLP Shutdown honors context
* Add Jaeger exporter test for shutdown
* Fix race in Jaeger test
* Unify shutdown behavior and testing
* Update sdk/trace/simple_span_processor.go
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>