* 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>
* Update Resource
When looking at grouping telemetry in an exporter based on the Resource
it is ideal if a map can be make with the key being represented by a
Resource. However, given the Resource is not hashable, this is not
possible.
This add a `String` method that can be used as a map key during
grouping. Additionally, this means the Resource now implements the
`Stringer` interface providing human-readable info when prited.
The internal structure of the Resource is changed. A static slice
containing all key-values in a sorted order replaces the existing map.
Additionally a set of keys is added to accommodate lookup during
`Merge`. Also, the string representation is kept in an internal field so
as to save processing for the `String` method (all fields are assumed to
be static after creation).
The `Attributes` method now returns a sorted slice of the associated
key-values.
The `Merge` method has been updated to support the changed structure of
the Resource.
New tests are added to validate the `String` method.
* Update comment
* Change loop into returned append
* Update key-value less func
Keys are unique in this package, treat them that way.
* Remove unnecessary allocation on empty attributes
* Update `Merge` method
Remove incomplete sorting of merged slices. Instead use the `sort`
package.
Add tests to catch sorting failure identified.
* Apply suggestions from code review
Co-Authored-By: ET <evantorrie@users.noreply.github.com>
* Escape Resource string representation
To ensure uniqueness of the string representation, the key-value content
needs to be escaped.
* Switch to an eager evaluation for the `String` method
* Refactor `Merge` method
Leave optimization to the future and simplify the merge.
* Add AttributeIterator
Include a method for a user of the Resource to iterate over the related
attributes without needed to copy the attributes.
* Fix ineffectual
* Fix lint
* Add licenses
* keys -> keySet for Resource
Co-authored-by: ET <evantorrie@users.noreply.github.com>
Co-authored-by: Rahul Patel <rahulpa@google.com>
Update license header to standard format for source files missed prior.
Add license header to new source files.
Add Makefile check to test all `*.go` and `*.sh` files have a copyright
notice (or comment about them being auto-generated) within the first few
lines.
* Add support for Resources in the SDK
Add `Config` types for the push `Controller` and the `SDK`. Included
with this are helper functions to configure the `ErrorHandler` and
`Resource`.
Add a `Resource` to the Meter `Descriptor`. The choice to add the
`Resource` here (instead of say a `Record` or the `Instrument` itself)
was motivated by the definition of the `Descriptor` as the way to
uniquely describe a metric instrument.
Update the push `Controller` and default `SDK` to pass down their configured
`Resource` from instantiation to the metric instruments.
* Update New SDK constructor documentation
* Change NewDescriptor constructor to take opts
Add DescriptorConfig and DescriptorOption to configure the metric
Descriptor with the description, unit, keys, and resource.
Update all function calls to NewDescriptor to use new function
signature.
* Apply suggestions from code review
Co-Authored-By: Rahul Patel <rghetia@yahoo.com>
* Update and add copyright notices
* Update push controller creator func
Pass the configured ErrorHandler for the controller to the SDK.
* Update Resource integration with the SDK
Add back the Resource field to the Descriptor that was moved in the
last merge with master.
Add a resource.Provider interface.
Have the default SDK implement the new resource.Provider interface and
integrate the new interface into the newSync/newAsync workflows. Now, if
the SDK has a Resource defined it will be passed to all Descriptors
created for the instruments it creates.
* Remove nil check for metric SDK config
* Fix and add test for API Options
Add an `Equal` method to the Resource so it can be compared with
github.com/google/go-cmp/cmp.
Add additional test of the API Option unit tests to ensure WithResource
correctly sets a new resource.
* Move the resource.Provider interface to the API package
Move the interface to where it is used.
Fix spelling.
* Remove errant line
* Remove nil checks for the push controller config
* Fix check SDK implements Resourcer
* Apply suggestions from code review
Co-Authored-By: Rahul Patel <rghetia@yahoo.com>
Co-authored-by: Rahul Patel <rghetia@yahoo.com>