1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2024-12-12 10:04:29 +02:00
Commit Graph

60 Commits

Author SHA1 Message Date
Joshua MacDonald
587cde3352
Remove NewKey and update doc comment (#721)
* Update doc comment

* Remove NewKey

* NewKey->Key
2020-05-13 16:21:23 -07:00
Chen Yixiao
1301b6f3e4
Move core and key to kv package (#720)
* Move core to kv

* Move kv.Value to kv.value.Value

* Move key to kv
2020-05-13 16:06:03 -07:00
Joshua MacDonald
3008c1bf02
Pass Resources through the metrics export pipeline (#659) 2020-04-24 09:44:21 -07:00
Joshua MacDonald
0bb12d9b1b
New api/label package, common label set impl (#651)
* 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
2020-04-23 12:10:58 -07:00
Joshua MacDonald
acb350b8f3
Support JSON marshal of Resources (#654)
* Support JSON marshal of Resources

* Add a test

* Another test

* Fix arch bug

* Fix other test
2020-04-22 14:32:58 -07:00
Krzesimir Nowak
927d9155ae
Increase the visibility of the api/key package (#650)
* 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>
2020-04-21 20:26:51 -07:00
Tyler Yahn
8e97011ea8
Update Resource (#613)
* 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>
2020-04-07 12:15:36 -07:00
Tyler Yahn
c97b4f726c
Update project License headers and checking (#596)
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.
2020-03-25 14:47:17 -07:00
Tyler Yahn
f7df68b68b
Add support for Resources in the SDK (#552)
* 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>
2020-03-20 08:58:32 -07:00
Rahul Patel
1ff0f2a26a
add resource type. (#528)
* add resource type.

* sort attributes in test to fix ci.

* add resource keys and update test.
2020-03-09 09:30:42 -07:00