* Deprecate Array attribute in favor of *Slice types
* Use new attr types in Jaeger exporter
* Use slice attr types in otlpmetric
* Use slice attr types in otlptrace
* Use slice attr types in zipkin exporter
* Remove array attr test from deprectated oteltest func
* Use StringSlice for cmd arg resource attr
* Add changes to the changelog
* Remove use of deprecated Array func
* Move InstrumentKind into the new metric/sdkapi package
* remove the alias
* remove the alias (everywhere)
* Changelog
* Add a test
* merge updates
* fix changelog
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Add benchmarks for error handler
* All multiple global ErrorHandler sets
* Use ioutil instead of io for Discard
* Add changes to changelog
* Add unit tests for delegation
* fix(2138): add guard to constructOTResources to return an empty resource when attributes are not supplied
Fixes: https://github.com/open-telemetry/opentelemetry-go/issues/2138
* Update CHANGELOG.md
Co-authored-by: Robert Pająk <pellared@hotmail.com>
Co-authored-by: Robert Pająk <pellared@hotmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Deprecate oteltest.Harness for removal
* Add changes to changelog
* Alias oteltest.Harness to internaltest
* Update oteltest/tracer_test.go
remove `oteltest` import.
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
* Removed DroppedAttributeCount field from Link struct
* Reintroduced DroppedAttributeCount with a wrapper struct
* Added Link type in otel/sdk package and used it instead of Trace API equivalent
* Added changelog entry
* Linting fix in changelog
* Deleted duplicated changelog section added by mistake
* Expanded changelog entry and moved it under the 'Added' section
* Explicitly mentioned otel/trace library in changelog entry under 'Removed' section to avoid ambiguity
* Add retry internal package
* Use retry package in connection
* Use retry package for otlpconfig
* Use the retry package in otlptracegrpc
* Use the retry package in otlptracehttp
* Add changes to CHANGELOG
* Lint internal
* Update otlptracehttp tests
* Update dependencies
* Add retry tests to otlptracehttp
* Remove TestRetry from otlptracehttp
* API: create new linked span from current context
* ran make precommit
* Update trace/trace.go
* Updated CHANGELOG
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* remove resource.WithBuiltinDetectors() which has not been maintained
* add changelog file
* Update CHANGELOG.md
Co-authored-by: Joshua MacDonald <jmacd@users.noreply.github.com>
* resolved a repeated conflict
* fix unittest error
* fix unittest error
* fix the PR according to suggestion
* fix unittest fail and del repeated testcase in CI system
* Update CHANGELOG.md
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Joshua MacDonald <jmacd@users.noreply.github.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Simplify trace_context tests
Refactor the propagation/trace_context tests to be targeted at testing
the propagator functionality only and remove extraneous dependencies.
Fix the TraceContext Inject method from injecting the tracestate header
if no value exists.
* Add changes to changelog
* Added explicit mapping between GOOS and semconv OS type attribute value
* Added tests for OS type mappings
* Added changelog entry
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Added Linux-specific detector for the os.description attribute
* Generalized OS description detector with placeholder function for unimplemented OSes
* Extended osDescription function to *nix OSes based on golang.org/x/sys/unix
* Added WithOS resource configuration function to configure all of the OS resource attributes
* Implemented osDescription funtion for Windows OS
* Improved documentation header for *nix version of the osDescription function
* Added support for reading os-release file
* Added/updated documentation headers for *nix implementation of osDescription and related functions
* Changelog update
* Added support for reading macOS version information
* Mock approach to test OS description attribute
* Extracted common function getFirstAvailableFile to read the first available file from a list of candidates
* Upgraded golang.org/x/sys
* Changelog update
* Fixed wrong function name in documentation header for WithOSDescription
* Updated documentation header for platformOSDescription function
* Renamed restoreProcessAttributesProviders test helper function
The function restoreProcessAttributesProviders was renamed to simply
restoreAttributesProviders to better reflect its broader scope, which
not only applies to process attribute's providers.
* Fixed os_linux.go overriding build tags defined inside the file
The suffix on os_linux.go was overriding the build tags already defined
in that file. The file was renamed to os_release_unix.go, reflecting
the main function defined in the file.
For consistency, os_darwin.go was renamed to os_release_darwing.go, as
its primary purpose is to also define the osRelease function.
* Removed use of discontinued function resource.WithoutBuiltin
* Added PR number to changelog entries
* Updated go.sum files after run of make lint
* Linux implementation: ignore lines with an empty key
* Linux implementation: avoid unquoting strings less than two chars
* WIP: added tests for Linux support functions
* WIP: added tests for charsToString and getFirstAvailableFile functions
* Replaced os.CreateTemp with ioutil.TempFile as the former only exists in Go 1.16
* Added unameProvider type to decouple direct reference to unix.Uname function inside Uname()
* Added tests for Uname() function
* Replaced *os.File with io.Reader in parseOSReleaseFile to ease testing
* Added tests for parseOSReleaseFile function
* Darwin implementation: added tests for buildOSRelease function
* Replaced *os.File with io.Reader in parsePlistFile to ease testing
* Darwin implementation: added tests for parsePlistFile function
* Type in documentation header for Linux osRelease function
* Extracted logic for reading specific registry values into helper functions
* Added basic tests for Windows version of platformOSDescription and helper functions
* Manually formatted uint64 to strings to have an uniform interface for test assertions
* Asserts there's no error when opening registry key for testing
Co-authored-by: Robert Pająk <pellared@hotmail.com>
* Simplified subtests by using a single test with multiple asserts
* go.sum update after running make
* Fix typo
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* WIP: added placeholder implementation of platformOSDescription for unsupported OSes
* Fixed typo on osRelease documentation header
Co-authored-by: Chris Bandy <bandy.chris@gmail.com>
* Fixed typo on test case name for ParsePlistFile tests
Co-authored-by: Chris Bandy <bandy.chris@gmail.com>
* Linter fix in changelog
* go.sum updates after running make
* Used strings.Replacer instead of multiple strings.ReplaceAll calls
* Optimized implementation of charsToString
* Safer temporary file deletion with t.TempDir()
* Used t.Cleanup() for safer mocking of runtime providers in OS resource tests
* Handled optionality of DisplayVersion registry key.
For example, CI machine runs on:
Windows Server 2019 Datacenter (1809) [Version 10.0.17763.1999]
So, to not add an extra white space due to missing DisplayVersion,
this value is checked to be not empty, and only in such case a
trailing space is added for that component.
* Workaround to handle the case of DisplayVersion registry key not present
* Excluded unsupported GOOSes by negation of supported ones
* go.sum update after running make
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
Co-authored-by: Robert Pająk <pellared@hotmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Chris Bandy <bandy.chris@gmail.com>
* add HTTP support for OTLP metrics exporter
* add to changelog
* fix unit test not covered before
* add otlpmetrichttp module to .github/dependabot.yml
* add test file for client.go
* run make commit to clean repository
* fix err occurs in TestCancelledContext
* fix err in TestCancelledContext which is nil
* fix err in TestCancelledContext which is nil, occurs occasionally
* fix unittest err in TestCancelledContext which occurs occasionally
* fix ineffectual assignment to err when running lint
* Update CHANGELOG.md
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Update exporters/otlp/otlpmetric/otlpmetrichttp/doc.go
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Update exporters/otlp/otlpmetric/otlpmetrichttp/doc.go
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* del options that not used in http exporter metrics
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Ensure that no-op tracer still progates non-recording spans
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Add `TracerProvider` to the `trace.Span` interface
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Remove config from oteltest.Tracer as it can be accessed through the provider
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Split stdout exporter into stdouttrace and stdoutmetric
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Remove unused options from stdouttrace and stdoutmetric exporters
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Update stdout exporter references in website docs
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Update docs to include correct import paths, properly describe exporter scope
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Remove pointless options to disable signals from what are now single-signal exporters
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Rename exporters/metric/prometheus
* Rename exporters/trace/jaeger
* Rename exporters/trace/zipkin
* Fix dependabot config and make test
* Update README docs
* Deprecate exporters instead of remove them
* Update dependabot with old modules
* Run crosslink
* Add lint override for known deprecated pkg
* Update PR number
* Remove trace export support from exporters/otlp
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Update otlp exporter example test to use metric/global package
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Update CHANGELOG
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* completely excise exporters/otlp
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Declare internal/metric module to version it separately
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Remove dependency on metrics module from soon-to-be-stable modules
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Add PR ID to CHANGELOG
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* rename metric/oteltest to metric/metrictest
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Fix metrictest package name in CHANGELOG
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
This implements specification requirement:
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md#resource-creation
- Changes `resource.NewWithAttributes` to require a schema URL. The old function
is still available as `resource.NewSchemaless`. This is a breaking change.
We want to encourage using schema URL and make it a conscious choice to have a
resource without schema.
- Merge schema URLs acccording to the spec in resource.Merge.
- Several builtin resource detectors now correctly populate the schema URL.
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Rename baggage context file
* Initial baggage implementation
* Initial tests
* More tests
* Update baggage context functionality
* Add New method to baggage pkg
* Update namedtracer example
* URL encode baggage values
* Refactor and use internal baggage pkg
* Update OpenTracing bridge
* Update baggage propagator
* Fix lint and test errors
* Add changes to changelog
* Apply suggestions from code review
* Rename testcase field per suggestion
* Update test to verify last-one-wins semantics
* Explicitly seed random numbers with static seed in tests
* Parse Member key/value with string split
* Add test for member parse with equal signs in value
* Trim whitespaces for member key/value
* sdk/resource: honor OTEL_SERVICE_NAME in fromEnv resource detector
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* go fmt is still my friend, even if I forget about it occasionally
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Fix import ordering
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
This adds support for schema URL to the Tracer according to the specification:
https://github.com/open-telemetry/opentelemetry-specification/pull/1666
(Link to replaced by the link to the spec after that PR is merged)
For the future: once the proto is updated we will need to populate the
schema_url field in the messages.
* Refactor TraceState
* Update tracecontext propagator to use new TraceState
* Add TraceStateFromKeyValues to oteltest
* Use oteltest to test TraceState
* Replace IsEmpty with Len for TraceState
* Replace ParseTraceState with ParseTraceStateString
* Clean up naming
* Add immutability test for TraceState
* Add changes to changelog
* Fixes
* Document argument type change in changelog
* Address feedback
Remove circularity of TestTraceStateLen.
* Add support for scheme in OTEL_EXPORTER_OTLP_ENDPOINT according to the spec
* Changes after review from pellared
* Changes after review from pellared - 2
* Changes after review from pellared - 3
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
* Add semantic convention generator
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Update semantic conventions from generator
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Use existing internal/tools module
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Fix lint issues, more initialisms
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Update changelog
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* semconvgen: Faas->FaaS
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Fix a few more key names with replacements
* Update replacements from PR feedback
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* rename commonInitialisms to capitalizations, move some capitalizations there
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Regenerate semantic conventions with updated capitalizations and replacements
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Generate semantic conventions from spec v1.3.0
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Cleanup semconv generator util a bit
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* No need to put internal tooling additions in the CHANGELOG
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Fix HTTP semconv tests
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Add semconv generation notes to RELEASING.md
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Remove the Tracer method from the Span API
* Update CHANGELOG with changes
* Update CHANGELOG.md
* Fix misspell
* Address feedback
* Implement global default non-recording span
* Add changes to CHANGELOG
* Update PR number in changelog
* Remove TODO from ReadOnlySpan interface
* Remove the Tracer method from the ReadOnlySpan
This is not required by the specification nor the use of this interface.
* Remove IsRecording from the ReadOnlySpan interface
A read-only span value does not need to know if updates to it will be
recorded. It by definition cannot be updated so no point in
communicating if an update would be recorded.
* Document the ReadOnlySpan interface
* Rename messageEvent* to just event*
* Move the SpanSnapshot into its own file
* Update ReadOnlySpan interface with meta info methods
Add the DroppedAttributes, DroppedLinks, DroppedEvents, and
ChildSpanCount methods to the interface to return additional information
about the span not specified by the specification, but that we are
already providing.
* Add SpanStub to the sdk/trace/tracetest pkg
* Redefine ExportSpans of SpanExporter with ReadOnlySpan
* Rename SpanSnapshot to snapshot and purge docs
* Remove Snapshot method from snapshot type
This method is a hold-over from previous version of the ReadOnlySpan
interface is not needed.
* Update CHANGELOG with changes
* Split large jaeger span batch to admire the udp packet size
* Refactory EmitBatch and produce complaining error msg when serialization fails
* Add tests for large jaeger spans
Update CHANGELOG.md
* Update CHANGELOG.md
* Fix compatibility-test on windows.
* Add test case for exporting spans with multiple errors.
Add Status type to SDK
Use this type to encapsulate the Span status similar to the Event type
encapsulating a Span event and the Link type a span link.
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
* Removed different types of Detectors for Resources.
This change simplifies different types of collectors into one list. The
order of this list determines how they are applied. Defaults are
applied when the user does not supply any detectors. To achieve
default behavior and additional behavior a DefaultDetectors struct has been
created
* missed prometheus test.
* Changed behavior around WithDetectors(nil)
Added examples of use of WithDetectors.
* Added NoOp example
* Changed test to reflect acutal default case
This changes because WithDetector() no longer is the same as not using WithDetector()
* Unexports the noOp detector
* Updated changelog
* Fixes to spelling mistakes.
* Added NewEmptyResouce and unexported builtin detectors
* Fix for prometheus example
* Resource has two Rs
I need to get a new R key it seems.
Co-authored-by: Sam Xie <xsambundy@gmail.com>
* Replaced NewEmptyResource() with New()
* Fix test function name
* Comment fixups.
* Apply suggestions from code review
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Sam Xie <xsambundy@gmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Move the Event type from the API to the SDK
This type is not used in the API. It is used in the SDK and then through
the processing pipelines. Move it to the package that originates its use.
* Add changes to changelog
* Update CHANGELOG.md
Co-authored-by: Gustavo Silva Paiva <guustavo.paiva@gmail.com>
Co-authored-by: Gustavo Silva Paiva <guustavo.paiva@gmail.com>
* drop failed to exporter batches and return error when forcing flush a span processor
* changelog
* changelog
* change should export condition
* cleanup
* Honor context Done in SSP Shutdown
* Update PR number in changelog
* Update comment
* Add tests
* Make tests more concise
* Restructure tests for readability
* WIP: OS and Process resource detectors
* Completed documentation headers
* Added empty test files for OS and Process resource functions
* Split long line
* Added resource.WithOS function test
* Added resource.WithProcess* functions tests
* Renamed osDetector and WithOS function to better reflect they only add the os.type attribute
* Updated changelog
* WIP: possible use of wrappers for getting attribute values
* Refined implementation of wrapper functions providing os/runtime/user information
* Added PR number to new changelog entries
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Fix wrong function name in documentation header
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Fixed wording in WithProcessOwner documentation header
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Updated osTypeDetector
* Replaced ToUpper with ToLower to match the current convention.
* Used runtimeOS provider to get the OS name.
* Adapted WithOSType test to mock runtime providers
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* updated controller to merge default resource with environment resource
* updated TracerProvider to merge default resource with environment resource
* Added Changelog entry
* Added resource.Environment(), modified resource.Default() for environment vairable and WithResource() configuration for TracerProvider and Controller
* Update CHANGELOG.md
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
* Moved environment detector to defaultResource initialization, added test cases
* Changes to default resource initialization
* made changes to the test cases
* added merging of resource with environment resource
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
* Wrap TCP listener
The mock collector listener now signals when it receives a connection
instead of waiting an arbitrary time an hoping the event happens.
* Only close the listener C chan once
* Apply PR feedback
* Backwards compatible support for closed listener check
* Cleanup
* Changes stdout to expose the actual tracerProvider
This enables flushing and stopping the exporter.
* updated changelog
* Update CHANGELOG.md
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* docs: update InstallNewPipeline example comment
* docs: update changelog after PR submit
* fix: wrap issue number in parens
* docs: use test example to document prometheus.InstallNewPipeline
* fix: update CHANGELOG to reflect PR state
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Adjust instrumentation lib name / version key
* Adjust array attribute serialization
* Adjust span status mapping
- remove `otel.status_description`; use `error` instead for description
- do not report status code if unset
- do not report description if OK or unset
- omit tags if no tag has been mapped
- adjust tests
* Set remote endpoint according to the spec
- See
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk_exporters/zipkin.md#remote-endpoint
* Fix remaining tests
* Update CHANGELOG
* Add some more tests
* Address PR feedback
- Simplify deletion of redundant error code
- Simplify endpoint rank determination
* More tests for remote endpoint
* remove process config for Jaeger exporter
* remove process config for Jaeger exporter
* Add CHANGELOG.md back
* Add CHANGLOG.md changes back
* fill in PR number in CHANGELOG
* Update CHANGELOG.md
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Add test to check bsp ignores OnEnd and ForceFlush post shutdown
* Add to CHANGELOG
* Check for err return value
* Stop test execution if there's error with shutting down bsp
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Use assert to check there's no error calling bsp.ForceFlush()
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Import require
* Add error message for assertion on be.len()
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Make ExportSpans for Jaeger honor deadline
* Make variable name more descriptive
* new commit
* Revert "new commit"
This reverts commit 06e24cc38d.
* Change PR number in changelog
* Take out separate goroutine and add back TODO
* Check error string
* Fix error assert
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Make TraceFlags spec-compliant
* Remove `trace.FlagsDebug` and `trace.FlagsDeferred`
* These are used only by the B3 propagator and will be handled there in the `context.Context`
* Make `trace.TraceFlags` a defined type, aliasing `byte`
* Move `IsSampled` method from `trace.SpanContext` to `trace.TraceFlags`
* Add `Sampled(bool)` method to `trace.TraceFlags`
* Implement `Stringer` and `json.Marshaler` for `trace.TraceFlags`
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Rename `TraceFlags.Sampled()` to `TraceFlags.WithSampled()` for consistency
* Restore `SpanContext.IsSampled()` method.
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Update precedence of event name in Jaeger exporter
The OTel specification states that the event needs to be recorded as a
log with its name set to a tag having the "event" key. That key needs to
be overridden when there is an attribute with the same key. This updates
to implement this.
Resolves#1767
* Add changes to changelog
* Update PR number in changelog
* lint
Adds support for the opentelemetry exceptions semantic conventions. In
short, this has RecordError produce an exception event with exception
attributes instead of using the error event and error attributes.
While golang does not have exceptions, the spec itself does not
differentiate between errors and exceptions for recording purposes.
RecordError was kept as the method name, both for backwards
compatibility and to reduce confusion (the method signature takes in a
golang error object). The spec appears to allow this, as it suggests the
method is optional and signature may reflect whatever is most appropriate
for the language implementing it.
It may seem non-intuitive to log an exception event from a method called
RecordError, but it's beneficial to have consistent behavior across all
opentelemetry SDKs. Downstream projects like the opentelemetry-collector
can build off of the published API and not special case behaviors from
individual languages.
* Fix Jaeger span status reporting and unify tag keys
Move all tag key strings to be consts defined in a unified location.
Fix the status code and message tag keys to conform with the
specification.
Do not set the span status message if it is not set to conform with the
specification.
* Add changes to changelog
* Update CHANGELOG.md
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
* Fix misspell
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
* Adjust TestRecording fucntion to validate with and without sampling. correct span.isRecording logic to return false when not being sampled
* Changed to TestExectutionTracerTaskEnd to only expect 1 span to increment instead of all 3
* added changelog entry
* Updated CHANGELOG.md
* Remove newline from isRecording()
* Rewrite TestSpanIsRecording to include table based
tests and check for when span is ended immediately
* Update sdk/trace/trace_test.go
Improve readability of test name
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
* Update sdk/trace/trace_test.go
Improve readability of test name
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
* Update CHANGELOG.md
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Update sdk/trace_test.go test comments
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Update SamplingParameters
Remove HasRemoteParent fields from SamplingParameters. The
HasRemoteParent field is a duplicate of the Remote field of the parent
span context contained in the ParentContext.
Change the `ParentContext` field from storing a `SpanContext` to a
`context.Context` that holds the parent span. This is to conform with
the OpenTelemetry specification and resolve#1727.
* Update PR number
* Update SpanSnapshot to use parent SpanContext
Having only the parent span ID and a separate field to communicate if
the parent was remote does not provide a comprehensive view of the
parent span nor is it an efficient way to transmit this information.
Update the SpanSnapshot to have a `Parent` field that contains the
parent span context. This field replaces the ParentSpanID and
HasRemoteParent fields.
* Revert SamplingParameters span change
* Update CHANGELOG with PR number
* Store Span instead of local/remote SpanContext in Context
Now that the SpanContext has a remote identifier, storing a Span's
SpanContext two separate ways in a Context (one for local another for
remote) is unnecessary and adds complication throughout the project when
determining heredity of a Span. This moves to storing the Span directly
in the Context uniformly (for both local and remote) as current Span. In
the process, it updates the getter/setter functionality the `trace`
package provides and replaces the distributed heredity logic throughout
the project with just using the current Span as the parent if it exists.
* Update trace/context.go
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
* Assert propagators context remote state
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
* Remove links on NewRoot spans
To ensure forwards compatibility, remove the unspecified links currently
set on `NewRoot` spans.
Resolves#461
* Remove links from oteltest tracer to match
This patch removes `ApplyConfig` method and `Config` struct from
`go.opentelemetry.io/otel/sdk/trace` package. To ensure valid config
for TracerProvider, it adds `ensureValidTracerProviderConfig` private
function.
Jaeger and Zipkin have been used the `Config` directly across package
boundaries. Since `Config` is removed, they can't use it. This change,
thus, replaces `WithSDK` with `WithSDKOptions`.
Resolves#1636, #1705.
* Rename WithDefaultSampler TracerProvider option to WithSampler
The term "DefaultSampler" comes from early ideas of this project where
there would be overriding samplers lower in the trace SDK. This
overriding does not exist and if it is going to be introduced in the
future the sampler associated with the TracerProvider is already scoped
based on that association (no need to scope with a name). This renames
the TracerProvider option to not include this anachronism.
* Update PR number in CHANGELOG
* Propagate rename
* Update defaults documentation for TracerProvider
* Update sdk/trace/provider.go
Co-authored-by: Steven E. Harris <seh@panix.com>
* Update sdk/trace/provider.go
Co-authored-by: Steven E. Harris <seh@panix.com>
* Add remote property to SpanContext
* Set SpanContext.remote when extracting context in TraceContext propagator
* Ensure remote flag is set when inserting remote SpanContext into context
* Ensure tests are expecting remote flag in SpanContext where appropriate
* Update CHANGELOG.md
* Apply PR feedback
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Add Valid method to KeyValue
* Use KeyValue.Valid in attribute add on Span
* Resource StringDetector errors for invalid attribute
* Ignore invalid attr in NewWithAttributes
The OpenTelemetry specification requires attributes conform to a
standard evaluated and returned by attribute.KeyValue.Valid. To comply
with the specification, Resources created from NewWithAttributes need to
only contain valid attributes. This adds a check to ensure this and
drops invalid attributes passed as arguments.
* Add changes to changelog
* Add nolint comment
The attribute.Set is (possibly overly) optimized to avoid allocations.
The returned value from the constructor is a value of a Set, not a
pointer to the Set. A Set contains a lock value and pointer methods so
passing the Set value raises the copylock go vet error. This copies the
same nolint comment from the `NewSet` method this used to use.
* Apply suggestions from code review
Co-authored-by: Sam Xie <xsambundy@gmail.com>
Co-authored-by: Sam Xie <xsambundy@gmail.com>
* Jaeger exporter now populate Jaeger's Span Process from Resource
* Remove jaeger.WithProcess
* Fix tests
* Change the type of default service name into string
* Add tests
* Update CHANGELOG
* Use the API from `Set` to fetch service name in exporter
* Fix nits
* Add more test cases for jaegerBatchList function
* precommit
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
* Rename resource pkg label vars and methods
The former `labels` package is now named `attributes` to conform with
the specification requirement. This removes the lingering `label` term
from the `resource` package.
Resolve https://github.com/open-telemetry/opentelemetry-go/issues/1691
* Update PR number in CHANGELOG
* Propagate rename to the prometheus exporter pkg
* Do not set status message if reason can be inferred
* Update CHANGELOG
* Add comment on validation func
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Remove `WithRecord()` option from SpanConfig options
This brings the trace API into conformance with the specification.
* Add entry to CHANGELOG
Fixes#192
* Updated CHANGELOG with PR#
* Cleaned up CHANGELOG notes
* fixup! Merge remote-tracking branch 'upstream/main' into remove-with-record
* Use new spanContext API to set traceflags, tracestate
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Make SpanContext Immutable
* Adds NewSpanContext() constructor and SpanContextConfig{} struct for
constructing a new SpanContext when all fields are known
* Adds With<field>() methods to SpanContext for deriving a SpanContext
with a single field changed.
* Updates all uses of SpanContext to use the new API
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Update CHANGELOG.md
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Add tests for new SpanContext constructor and derivation
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Address PR feedback
* Fix new uses of SpanContext from main
* sdk/trace: add missing options to tracer provider
This change adds `WithDefaultSampler` and `WithSpanLimits` to the tracer
provider and removed `WithConfig` from it.
Before this change, `WithConfig` is the only way to set sampler or
limits of a span. However, it is prone to misuse, since `WithConfig` can
override tracing configurations that are configured by `WithResource` or
`WithIDGenerator`. Thus to fix this, it adds new functional options -
`WithDefaultSampler` and `WithSpanLimits` and removes `WithConfig`.
Resolves#1631.
* Update sdk/trace/provider.go
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Update sdk/trace/provider.go
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* rebase and remove WithConfig
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Add ForceFlush method to TracerProvider
The specification requires that a TracerProvider have a ForceFlush
method that can be set with a timeout, return any error to the caller,
and have all the registered span processors export their spans. This
updates the SpanProcessor.ForceFlush method to accept a context and
return an error and plumbs this method into a new ForceFlush method of
the SDK TracerProvider.
Additionally, this corrects the TracerProvider Shutdown method. This
method as well needs to return to the caller any failure it encounters
according to the specification. This returns an error if it cannot type
assert the spanProcessorStates or if shutting down a span processor
results in an error.
Resolves#1606
* Add changes to changelog
* Apply suggestions from code review
Co-authored-by: Steven E. Harris <seh@panix.com>
* Cancel export context when BSP stops
* Defer cancel call in BSP span processor funcs
Co-authored-by: Steven E. Harris <seh@panix.com>
to provide consistent naming across the code base, deprecate pusher in
favor of exporter naming convention.
Signed-off-by: ldelossa <ldelossa@redhat.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Update the SimpleSpanProcessor
Subsequent calls to OnStart, OnEnd, and ForceFlush should be ignored
gracefully once Shutdown has been called. This implements that behavior
by shutting down the exporter and removing it from the
SimpleSpanProcessor so subsequent calls to OnEnd will be no-ops.
* Add changes to changelog
* Lock in sync.Once of shutdown instead of Shutdown scope
* Update CHANGELOG.md
Co-authored-by: Steven E. Harris <seh@panix.com>
* Release exporterMu before shutdown exporter
* Move changes to unreleased section of changelog
* Update simple_span_processor.go
revert comment change from merge
Co-authored-by: Steven E. Harris <seh@panix.com>
* Fix#1658 SpanStatus description set only when status code is set to error
* Update CHANGELOG.md
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Set span status code, message and ref types according to the spec
* Serialize array attributes as string
* Use correct lib name / version key
* Add new and adjust existing tests
* Update CHANGELOG
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Add tests for propagation of Sampler Tracestate changes
Sampler specification indicates that SamplingResult.Tracestate
should be associated with the SpanContext of the newly created span.
See
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#sampler
* Fix SamplingResult TraceState propagation
* Add Changelog entry
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Add HTTP/JSON to the otlp exporter
Co-Authored-By: Roy van de Water <72016+royvandewater@users.noreply.github.com>
* PR fixup
Co-authored-by: Roy van de Water <72016+royvandewater@users.noreply.github.com>
* Add compatibility tests to CI
* Increase timeout to 60s
Some of the aggregator tests are running just over 30 seconds when
testing on Windows. Bump this to allow for it.
* Remove cache setup jobs
Having a unified job setup the cache when none exists so packages are
only downloaded once is ideal, but these steps are taking too long. In
some situations they are doubling the run time. Remove them and prefer
to have multiple downloads when dependencies change.
* Add changes to changelog
* Remove mod-download target from Makefile
Unused now that the cache jobs are removed.
* Add compatibility testing table to changelog
* Add change about precommit to changelog
* Update README
* Correct examples target in lint job
* Make timestamps sequential in lastvalue agg check
* Set PR number in changelog
* Fix location of sleep
The lastvalue timestamp is set on update. Correct the location of the
sleep to bridge the update of the two different aggregators.
* Updating documentation with an working example for creating NewExporter
* Updated Changelog
* Moved examples in README to testing example
* ExampleTest shouldn't log anything if working as expected
* Fixing the lint
* Fixing the lint
* Review comments
* Changes done moved to Fixed section of Changelog
* Fix Windows build of Jaeger tests
The Jaeger tests use the low-level syscall package. The Windows specific
function called in that package has a different function signature than
the unix version. Add a windows specific file using the build flags to
isolate this OS specific functionality.
* Add changes to changelog
* Blind succeed to account for unimplemented functionality on Windows
* Fix stdout TestStdoutTimestamp failure with sleep
Ensure the test condition is valid by introducing minimal sleep
durations before and after a timestamp is measured.
Resolves#1571
* Add changes to changelog
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
* Stagger timestamps in exact aggregator tests
Fixes#1559.
* Missed one
* Yield while you wait
* Just sleep for a teeny tiny bit
* Oops, wrong PR in Changelog
* Make sure that *some* time passes
* Keep time comparisons relaxed
* add code attributes to semconv package
* update changelog
* update comment for code semconv attributes
Adds a full-stop at the end of the comment.
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Vendor Thrift dependency
* Fix build
* Changelog entry
* Ignore third_party for coverage purposes
* Re-run tests
* Re-run tests
* Re-run tests
* Re-run tests
* Relax time comparisons
Fixes#1559.
Some unit tests were flaking in CI because they expected the timestamp
to advance during a test, when it's possible for it to be unchanged
instead. This change switches the offending "<" comparisons to "<=".
* Re-run tests
* Relax more time comparisons
* Re-run tests
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
The spec makes it optional to attempt resampling when changing the name
of a span and we're not sure whether it can be done in an appropriate
manner, so it's best to not do it at all for now. We can try again
later if we find a good way to do it.
* Add a tool to auto-generate replace directives
* Auto-generated changes from previous commit
* Create new modules required for trace release
* otel/metric
* otel/trace
* otel/oteltest
* otel/sdk/export/metric
* otel/sdk/metric
Relates to #1467
* Move metric-related public API out of otel/ pkg
Move GetMeterProvider, Meter and SetMeterProvider to new package
otel/metric/global in the otel/metric module.
This will allow otel/ module to be released as v1.0.
* Include PR references in CHANGELOG
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Check for root dir
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Update README master branch URL to main
* Remove master branch from workflow triggers
The master branch has been renamed to main.
* Add changes to CHANGELOG
* Rename other projects default branch
All of OpenTelemetry is moving to rename `master` to `main`, this
updates all other URLs for those projects.
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
* Add a Config/Option for histogram
* Just one option here
* Test fixes
* Support and test int64 histograms
* Changelog
* Lint
* Un-export three things.
* Push->basic
* Repackage
* Rename away from push
* Make exporter optional; export from a separate goroutine
* Move pull_test into controller_test
* Precommit pass
* New OTLP/Prom example
* Precommit
* Fix the example
* Shorten the example
* Test starting controller w/o exporter
* Test export timeout
* Remove ancient example & lint
* go.mod revert & tidy
* Comments
* Tidy a diff
* Tidy a diff
* Move export kind selector in the new example
* Split this test into its original parts
* Reduce diff size
* Changelog
* Remove extra Add/Done pair
* Remove unused stopCh param; document the Stop behavior
* Typo
* Use ctx
* Missed v0.15
* Apply PR feedback
* Precommit pass
* 0.14 -> 0.15 in new file
* Remove diff chunk markers
* Fix OTLP example
* Upstream
* dashpole comments
* aneurysm9 feedback
* Tidy go.sum
* TraceContext propagator now handles `tracestate`.
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Prevent invalid tracestate from invalidating traceparent.
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Fail tests early if unable to construct expected TraceContext
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Move grpc stuff to separate package
* Drop duplicated retryable status code
* Set default port to 4317
This is what the specification says for both gRPC and HTTP.
* Document gRPC option type
* Add an HTTP protocol driver for OTLP exporter
Currently it supports only binary protobuf payloads.
* Move end to end test to a separate package
It also adds some common code mock collectors can use. This will be
useful for testing the HTTP driver.
* Move export data creators to otlptest
It also extends the one record checkpointer a bit. This will be useful
for testing the HTTP driver.
* Add an HTTP mock collector and tests for HTTP driver
* Update changelog
* Do not depend on DefaultTransport
We create our own instance of the transport, which is based on
golang's DefaultTransport. That way we sidestep the issue of the
DefaultTransport being modified/overwritten. We won't have any panics
at init. The cost of it is to keep the transport fields in sync with
DefaultTransport.
* Read the whole response body before closing it
This may help with connection reuse.
* Change options to conform to our style guide
* Add jitter to backoff time
* Test TLS option
* Test extra headers
* Fix a comment
* Increase coverage
* Add a source of the backoff strategy
* Add Tracestate into the SamplingResult struct
Add `trace.Tracestate` field into the SDK `trace.SamplingResult` struct.
Use ParentContext from SamplingParameters to return Tracestate in
`traceIDRatioSampler`, `alwaysOnSampler` and `alwaysOffSampler`.
Add a new test to check that Tracestate is passed.
* Updated CHANGELOG.md for #1432 PR
Added changes description for #1432.
* Update sdk/trace/sampling_test.go
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* 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.
* migrating CircleCI jobs to GitHub Actions
* using container matrix instead
* prevent entire workflow from stopping if one go version job fails
* updating github ci to use setup-go
* updating changelog
* 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>
* 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>
* 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>
* 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 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>
* 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 Span API event methods
Remove the context argument from the event methods. It is unused and can
be added back in as a passed option if needed in the future.
Update AddEvent to accept a required name and a set of options. These
options are the new EventOption type that can be used to configure a
SpanConfig Timestamp and Attributes.
Remove the AddEventWithTimestamp method as it is redundant to calling
AddEvent with a WithTimestamp option.
Update RecordError to also accept the EventOptions.
* Add changes to CHANGELOG
* Add LifeCycleOption
Use the LifeCycleOption to encapsulate the options passed to a span for
life cycle events.
* Add delegating global propagator
* Add Changes to CHANGELOG
* Add PR number to CHANGELOG
* Add tests using new test framework
* Revert "Add tests using new test framework"
This reverts commit af7ae17436.
* Add oteltest text map propagator and carrier
* Add changes to CHANGELOG
* Add PR number to CHANGELOG
* Add test for empty newState
Gotta farm that codecov
* 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
* Fix lint issues in otel package
Add documentation for the shadowed `Meter` for the time being.
Do not export `ErrInvalidHexID`, `ErrInvalidTraceIDLength`,
`ErrInvalidSpanIDLength`, `ErrInvalidSpanIDLength`, or `ErrNilSpanID`.
These are not used externally and we should reduce the API prior to a GA
release to allow flexibility going forward.
Add and update comments for all SpanKind conforming to golint spec.
* Update CHANGELOG
Rename MergeItererator to MergeIterator to correct the spelling mistake.
Add comment for exported `EmptySet`.
Fix comments on the exported label `Type`s to conform to Go standards.
* Call sampler on local child spans.
* Update CHANGELOG.md
* Adding a test for calling the sampler on local child spans
* Add clarifying comment to test
* 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
* Move api/baggage to the propagators package
* Create Baggage API to match specification
* Update CHANGELOG.md
* Baggage API unit tests
* Rename and add unit test
* Update unit test value checking
* Update TODO with issue tracking work.
- add set propagator to examples
Signed-off-by: Hui Kang <kangh@us.ibm.com>
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>