* 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>
* Unexport NoopXXX trace types
The change unexports the noop implementations and provide the NoopProvider function for user to construct noop providers. Users can access noop tracer and noop spans by using the provider.
This change removes the types users should never be directly using from the package. It improves the usability of the API by reducing the API surface to half and helping the user to focus on the canonical APIs.
Fixes#1133
* Provide noop tracer and span for internal use
* Remove obsolete doc
* Use noop span instead of nil
* Fix the broken build
* port reconnecting udp client from jaeger-client-go
* Fix precommit issues
* Fix license check
* Add initial value for max packet size
* Fix for atomic usage on 386 arch
* Modify reconnecting option to an affirmative
* Add changelog entry
* Dont hold rlock for writes
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Move proto to OTLP exporter
* Update OTLP exporter import of proto
* Use gogo protobuf
To stop using the deprecated github.com/golang/protobuf and match what
the collector is doing, switch to generating OTLP with the
github.com/gogo/protobuf/proto instead of
github.com/golang/protobuf/proto.
* Clean dependencies
Remove all protobuf dependencies from otel package and all of its
dependencies.
* Update CHANGELOG
* Clean OTLP exporter go mod
Remove submodule beforehand to avoid unneeded direct dependencies.
* Use default ref for GitHub workflow
* Update path that triggers proto gen action
* Correct license-check exclusion for OTLP
* Update commented location of the OTLP and code
* Clean stale indirect dependency requirements
In the recent changes to isolate the main `otel` package there were many
indirect dependencies of the package that were removed, however, the
go.mod was not automatically cleaned of these. This removes those (and
similar ones in the otel-collector example and otel exporter) and prunes
the go.sum files accordingly.
* Run in a clean system to reproduce build
* Make opentracing bridge into own Go module
* Update dependabot config
* Clean dependencies of project
Now the bridge is a module, clean all upstream modules that no longer
implicitly depend on it.
* Update Changelog
* go mod tidy
* Fix instrumentation lib version in spanDataToThrift
* Update CHANGELOG.md
* Use test value for lib version in accordance with the spec
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Add int array attribute support
* Export int32, int64 and bool arrays
* Export all other array attributes
* Remove array test case from simple attr test
* Addressed feedback
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
http.ResponseWriters may implement additional interfaces
(http.CloseNotifier, http.Flusher, http.Hijacker, http.Pusher,
io.ReaderFrom) that get lost when the ResponseWriter is wrapped in
another object. This change uses the httpsnoop package to wrap the
ResponseWriter so that the resulting object implements any of the
optional interfaces that the original ResponseWriter implements as
well as using the replacement ResponseWriter methods that gather
information for tracing.
* Remove otel/sdk dependency from grpctrace
Use otel/trace/testtrace instead and cleanup testing code.
* Update httptrace to not depend on the SDK
Update testing to use api/trace/testtrace instead.
* Add changes to Changelog
* Make the SDK its own Go module
* Upgrade go.mod to 1.14 project wide
* go mod tidy
* Make the stdout exporter its own package
Follow the pattern of the other exporters.
* Update dependabot with stdout exporter
* Add replace directives for stdout exporter
* Remove outdated example test from metric SDK
* go mod tidy
* Update othttp example test
Remove unused stdout exporter.
* Remove tests in API that depend on stdout exporter
The global package does not need to be validated with the SDK. A more
properly constructed end-to-end integration test should be built if this
is actually needed.
* Add replace clause for otel in stdout go.mod
* Consolidate stdout exporter
* Move config to own file and match project standard
* Abstract Exporter into unified struct
* Rename trace part of the exporter
* Update import paths and configuration
* Update tests
* Update InstallNewPipeline to not return traceProvider
It is a registered global, access it that way.
* Update example_test
* Update docs
* Update example to be for whole package
* Update metric output
Closer match the span output.
* Clean up span output
Print as a batch and cleanup marshaling.
* Correct spelling error in doc
* Add Exporters README
* Update Changelog
* Propagate changes to rest of project
* Lint fixes
* Fix example test in metric SDK
* Add disable config options for trace and metric
Co-authored-by: Liz Fong-Jones <lizf@honeycomb.io>
* Adjust Jaeger and Zipkin exporters helper methods
* Update and add tests, examples, various minor improvements
* Update changelog
* Correct the Zipkin example
- wait for the spans to be exported
- rebuild the example
* Zipkin service name as argument
* Rework Jaeger and Zipkin tests
* Include more detailed Changelog
Co-authored-by: ET <evantorrie@users.noreply.github.com>
Co-authored-by: Liz Fong-Jones <lizf@honeycomb.io>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Currently there is no way to report errors using the global handlers for spans in the OTLP exporter, this change fixes that. Errors for the metrics exporter are already handled by the global handler.
Co-authored-by: Liz Fong-Jones <lizf@honeycomb.io>
* Import open-telemetry/opentelemetry-proto submodule under internal
* Commit changes in updated/new protobuf files
* Refer to new location of .pb.go files after rewrite from import
* Describe in CHANGELOG
* Avoid applying stale udpates; add a test
* Add Memory option to basic processor
* Always use memory in the pull controller
* Test the memory option
* Precommit
* Add a Prometheus-specific test
* More comment on Memory option
* Link to 862
* Remove sleep
* Update changelog
* Comment on stale and stateless aggregators
* Update sdk/metric/processor/basic/config.go
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Liz Fong-Jones <lizf@honeycomb.io>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Update OTLP to v0.4.0
* Update attribute transforms to use new KeyValue
* Update metric transforms
The labels are no longer included in the MetricDescriptor
Use new types.
* Fix OTLP integration tests
* Update example otel-collector go.sum
* Update metric integration testing
* Fix type error introduced in conflict resolution
* Deep clean of go.sum
Recreate go.sum for otel-collector example and OTLP exporter.
fixes#851
This includes all of the associated methods, such as
AsUint64, AsUint64Atomic, AsUint64Ptr, CoerceToUint64, SetUint64
SetUint64Atomic, SwapUint64, SwapUint64Atomic, AddUint64,
AddUint64Atomic, CompamreAndSwapUint64, CompareUint64
Only significant change as a result was converting the histogram
aggregator's `count` state field into an int64 from a `metric.Number`.
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Support instrumentation library in metrics
* Update stdout exporter to display instrumentation info
* Fix tests that use the STDOUT exporter
* Refactor to keep SDK out of API
* Update global Meter and test Meter version
* Revert unneeded import syntax change
* Fix Unit comment
* Update comments
* Update comment
* Revert no-op change to import
* Update Tracer API with instrumentation version
Add option to the `Provider.Tracer` method to specify the
instrumentation version.
Update the global, noop, opentracing bridge, and default SDK
implementations.
This does not propagate the instrumentation library version to the
exported span. That is left for a follow-on PR.
* Revert trace_test.go
This is for the next PR.
* Support instrumentation library in SDK trace exports
* Update Jaeger exporter to export instrumentation
Needs to be run `GRPC_GO_RETRY=on go test .` to not fail the failing
tests because retries are not enabled by default, nor can they be
enabled programmatically.
* Remove the push controller named Meter map
* Checkpoint
* Remove Provider impls
* Add a test
* Expose Provider() getter instead of implementing the interface
* Add a key benchmark, optimize SDK SetAttribute
* Use reflect in key.Infer
* Move to separate benchmark file; remove pointer test; remove dead comment
* Run go mod tidy
* Add license header
* Use the reflect scalar accessors
Co-authored-by: Liz Fong-Jones <lizf@honeycomb.io>
* New label set API
* Checkpoint
* Remove label.Labels interface
* Fix trace
* Remove label storage
* Restore metric_test.go
* Tidy tests
* More comments
* More comments
* Same changes as 654
* Checkpoint
* Fix batch labels
* Avoid Resource.Attributes() where possible
* Update comments and restore order in resource.go
* From feedback
* From feedback
* Move iterator_test & feedback
* Strenghten the label.Set test
* Feedback on typos
* Fix the set test per @krnowak
* Nit
* 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>