To potentially optimize the collection code path (#3047) ResourceMetrics
sent to the Exporter may be reused in the future. Warn users of this.
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
* Update Meter RegisterCallback method
Return a Registration from the method that can be used by the caller to
unregister their callback.
Update documentation of the method to better explain expectations of
use and implementation.
* Update noop impl
* Update global impl
* Test global Unregister concurrent safe
* Use a map to track reg in global impl
* Update sdk impl
* Use a list for global impl
* Fix prom example
* Lint metric/meter.go
* Fix metric example
* Placeholder for changelog
* Update PR number in changelog
* Update sdk/metric/pipeline.go
Co-authored-by: Aaron Clawson <3766680+MadVikingGod@users.noreply.github.com>
* Add test unregistered callback is not called
Co-authored-by: Aaron Clawson <3766680+MadVikingGod@users.noreply.github.com>
* add RegisterProducer method and metric.Producer interface
* rename testProducer to testSDKProducer
* rename testMetrics to testResourceMetrics
* add testExternalProducer for testing bridges
* add test data for testing external producers
* clean up help text
* unit tests for external Producer
* changelog
* improve test coverage
* Update CHANGELOG.md
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* support partial errors
* fix lint
* add additional test
* unallocate producers on shutdown
* don't register Producers after shutdown
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Add the InstrumentKind type and vars to sdk/metric
* Add the Instrument type to sdk/metric
* Add the Stream type to sdk/metric
* Add the View type to sdk/metric
* Add NewView to create Views matching OTel spec
* Add unit tests for NewView
* Add changes to changelog
* Apply suggestions from code review
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
* Update CHANGELOG.md
* Update match and mask comments of Instrument
* Explain wildcard logic in NewView with comment
* Drop views that replace name for multi-inst match
* Comment how users are expected to match zero-vals
* Remove InstrumentKind and Scope from Stream
* Fix redundant word in NewView comment
* Add view example tests
* Update comments to examples
* Fix broken English
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
* Replace view usage in sdk/metric
* Replace view use in stdoutmetric
* Replace view use in prometheus exporter
* Replace view use in otlpmetric exporters
* Replace view use in view example
* Add the InstrumentKind type and vars to sdk/metric
* Add the Instrument type to sdk/metric
* Add the Stream type to sdk/metric
* Add the View type to sdk/metric
* Add NewView to create Views matching OTel spec
* Add unit tests for NewView
* Add changes to changelog
* Apply suggestions from code review
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
* Update CHANGELOG.md
* Update match and mask comments of Instrument
* Explain wildcard logic in NewView with comment
* Drop views that replace name for multi-inst match
* Comment how users are expected to match zero-vals
* Remove InstrumentKind and Scope from Stream
* Fix redundant word in NewView comment
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
* Do not return an error for Drop aggs
The async instruments currently return an error if and only if there are
no aggregators returned from a resolve. Returning no aggregators means
the instrument aggregation is drop. Do not include this in the error
reporting decision.
* Only registers callbacks if non-drop agg is used
The instruments passed to RegisterCallback need to have some aggregation
defined otherwise it is implied they have a Drop aggregation. Check that
at least one instrument passed has an aggregation other than Drop before
registering the callback with the pipelines.
Also, return an error if the user passed another API implementation of
an asynchronous instrument.
* Remove unneeded TODO from pipeline
* Add changes to changelog
* Test callback not called for all drop instruments
* Test RegisterCallback returns err for non-SDK inst
* Fail gracefully for non-SDK instruments
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
* Return empty nil aggs if no meas
* Update tests with new expected behavior
* Add change to changelog
* Set PR number in changelog
* Run lint
* Fix pipeline_test
* Scope change in changelog to pkg
* Clean up init of agg types
Bump github.com/stretchr/testify from 1.8.0 to 1.8.1 in /exporters/otlp/internal/retry
Bump github.com/stretchr/testify from 1.8.0 to 1.8.1 in /schema
Bump github.com/stretchr/testify from 1.8.0 to 1.8.1 in /exporters/otlp/otlpmetric/otlpmetrichttp
Bump github.com/stretchr/testify from 1.8.0 to 1.8.1 in /exporters/stdout/stdouttrace
Bump github.com/stretchr/testify from 1.8.0 to 1.8.1 in /exporters/otlp/otlpmetric/otlpmetricgrpc
Bump github.com/stretchr/testify from 1.8.0 to 1.8.1 in /exporters/stdout/stdoutmetric
Bump github.com/stretchr/testify from 1.8.0 to 1.8.1 in /exporters/prometheus
Bump github.com/stretchr/testify from 1.8.0 to 1.8.1 in /exporters/zipkin
Bump github.com/stretchr/testify from 1.8.0 to 1.8.1 in /trace
Bump github.com/stretchr/testify from 1.8.0 to 1.8.1 in /exporters/otlp/otlpmetric
Bump github.com/stretchr/testify from 1.8.0 to 1.8.1 in /exporters/jaeger
Bump github.com/stretchr/testify from 1.8.0 to 1.8.1 in /exporters/otlp/otlptrace/otlptracehttp
Bump github.com/stretchr/testify from 1.8.0 to 1.8.1 in /metric
Bump github.com/stretchr/testify from 1.8.0 to 1.8.1 in /exporters/otlp/otlptrace/otlptracegrpc
Bump github.com/stretchr/testify from 1.8.0 to 1.8.1 in /exporters/otlp/otlptrace
Bump github.com/stretchr/testify from 1.8.0 to 1.8.1 in /sdk/metric
Bump github.com/stretchr/testify from 1.8.0 to 1.8.1 in /bridge/opencensus
Bump github.com/stretchr/testify from 1.8.0 to 1.8.1 in /sdk
Bump github.com/stretchr/testify from 1.8.0 to 1.8.1
Co-authored-by: MrAlias <MrAlias@users.noreply.github.com>
* Split WithView from WithReader
* Accept readers and views params in newPipelines
* Update MeterProvider pipes init
* Fix WithView comment
* Fix view example MeterProvider option
* Fix With{View,Reader} option in prom exporter test
* Test Reader not required to be comparable
* Add changes to changelog
* Fix changelog option name
* dependabot updates Thu Oct 27 19:57:50 UTC 2022
Bump github.com/golangci/golangci-lint from 1.48.0 to 1.50.1 in /internal/tools
Bump golang.org/x/tools from 0.1.12 to 0.2.0 in /internal/tools
* Ignore errors in Prom exporter's sanitizeName
* Omit type from inferred var decl
Co-authored-by: MrAlias <MrAlias@users.noreply.github.com>
Co-authored-by: Tyler Yahn <codingalias@gmail.com>
* Update API docs
Update the async instrument docs for the counters types to explain that
the value recorded is assumed by implementations to be the cumulative
sum.
* Refactor precomputed delta sum aggregation
Report the delta Aggregation while supporting cumulative Aggregate
values.
* Add changes to changelog
* Bump module versions
* Prepare stable-v1 for version v1.11.1
* Prepare experimental-metrics for version v0.33.0
* Update the changelog
* Update CHANGELOG.md
* Update Asynchronous API docs
Clarify the Counter and UpDownCounter Observe values are the exact
counter value, not increments to the previous measurements.
* Add the pre-computed sum Aggregator
* Test the PreComputedSum
* Use the PrecomputedSum for async counters
* Add changes to changelog
* Ignore false-positive lint error
* Split NewPrecomputedSum into delta/cumulative vers
* Decode values from OTEL_RESOURCE_ATTRIBUTES
The W3C spec specifies that values must be percent-encoded so when
reading the environment variable `OTEL_RESOURCE_ATTRIBUTES` the SDK
should decode them.
This is done by the `baggage` package, but its behaviour in case of
errors is slightly different from the current implementation of the SDK,
more specifically in cases where a key is missing a value. The SDK
returns a partial resource while the `bagage` package returns nil.
This may be considered a breaking change, so this commit fixes the
current implementation instead of using `baggage.Parse`.
* Add changelog entry for #2963
* Use otel.Handle on OTEL_RESOURCE_ATTRIBUTES decode error
* retain original value when decoding fails
* docs: update CHANGELOG
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Bump github.com/stretchr/testify from 1.7.1 to 1.8.0 in /exporters/otlp/internal/retry
Bump github.com/stretchr/testify from 1.7.1 to 1.8.0 in /exporters/otlp/otlpmetric/otlpmetrichttp
Bump google.golang.org/protobuf from 1.28.0 to 1.28.1 in /exporters/otlp/otlpmetric/otlpmetrichttp
Bump github.com/stretchr/testify from 1.7.1 to 1.8.0 in /schema
Bump github.com/stretchr/testify from 1.7.1 to 1.8.0 in /exporters/zipkin
Bump github.com/openzipkin/zipkin-go from 0.4.0 to 0.4.1 in /exporters/zipkin
Bump github.com/google/go-cmp from 0.5.8 to 0.5.9 in /exporters/zipkin
Bump google.golang.org/grpc from 1.46.2 to 1.50.1 in /exporters/otlp/otlpmetric/otlpmetricgrpc
Bump github.com/stretchr/testify from 1.7.1 to 1.8.0 in /exporters/otlp/otlpmetric/otlpmetricgrpc
Bump google.golang.org/grpc from 1.46.2 to 1.50.1 in /exporters/otlp/otlptrace
Bump google.golang.org/protobuf from 1.28.0 to 1.28.1 in /exporters/otlp/otlpmetric/otlpmetricgrpc
Bump github.com/stretchr/testify from 1.7.1 to 1.8.0 in /exporters/otlp/otlptrace
Bump google.golang.org/protobuf from 1.27.1 to 1.28.1 in /exporters/otlp/otlpmetric
Bump github.com/google/go-cmp from 0.5.8 to 0.5.9 in /exporters/otlp/otlptrace
Bump google.golang.org/protobuf from 1.28.0 to 1.28.1 in /exporters/otlp/otlptrace
Bump github.com/google/go-cmp from 0.5.8 to 0.5.9 in /exporters/otlp/otlpmetric
Bump google.golang.org/grpc from 1.42.0 to 1.50.1 in /exporters/otlp/otlpmetric
Bump github.com/stretchr/testify from 1.7.1 to 1.8.0 in /exporters/stdout/stdouttrace
Bump github.com/stretchr/testify from 1.7.1 to 1.8.0 in /exporters/prometheus
Bump google.golang.org/protobuf from 1.28.0 to 1.28.1 in /exporters/otlp/otlptrace/otlptracegrpc
Bump github.com/stretchr/testify from 1.7.1 to 1.8.0 in /exporters/otlp/otlpmetric
Bump github.com/stretchr/testify from 1.7.1 to 1.8.0 in /exporters/otlp/otlptrace/otlptracegrpc
Bump google.golang.org/grpc from 1.46.2 to 1.50.1 in /exporters/otlp/otlptrace/otlptracegrpc
Bump go.uber.org/goleak from 1.1.12 to 1.2.0 in /exporters/otlp/otlptrace/otlptracegrpc
Bump github.com/google/go-cmp from 0.5.8 to 0.5.9 in /exporters/jaeger
Bump github.com/stretchr/testify from 1.7.1 to 1.8.0 in /trace
Bump github.com/stretchr/testify from 1.7.1 to 1.8.0 in /exporters/jaeger
Bump github.com/stretchr/testify from 1.7.1 to 1.8.0 in /metric
Bump github.com/stretchr/testify from 1.7.1 to 1.8.0 in /exporters/otlp/otlptrace/otlptracehttp
Bump github.com/google/go-cmp from 0.5.8 to 0.5.9 in /trace
Co-authored-by: Aneurysm9 <Aneurysm9@users.noreply.github.com>
* Bump stable-v1 and experimental-metrics vers
* Prepare stable-v1 for version v1.11.0
* Prepare experimental-metrics for version v0.32.3
* Update changelog for release
* Retract v0.32.2 of otlpmetric{http,grpc}
* Add the cache type
* Add cache unit tests
* Test cache concurrency
* Add the instrumentCache
* Use the instrumentCache to deduplicate creation
* Drop unique check from addAggregator
* Fix aggregatorCache* docs
* Update cachedAggregator and aggregator method docs
* Remove unnecessary type constraint
* Remove unused errAlreadyRegistered
* Rename to not shadow imports
* Add changes to changelog
* Fix changelog English
* Store resolvers in the meter instead of caches
* Test all Aggregator[N] impls are comparable
* Fix lint
* Add documentation that Aggregators need to be comparable
* Update sdk/metric/internal/aggregator.go
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
* Update sdk/metric/instrument.go
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
* Update sdk/metric/instrument.go
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
* Update sdk/metric/internal/aggregator_test.go
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
* Fix pipeline_test.go use of newInstrumentCache
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
* Use default view if inst matches no other
Fix#3224
* Test default view applied if no match
* Add changes to changelog
* Remove unneeded views len check in WithReader
* Do not return agg if adding err-ed
* Revert "Do not return agg if adding err-ed"
This reverts commit b56efb06a7.
* update bucket default bounds to match the specification
* add changelog entry
* test custom boundaries with valid histogram
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Add views field to pipeline
Redundant maps tracking readers to views and readers to pipelines exist
in the pipelineRegistry. Unify these maps by tracing views in pipelines.
* Rename newPipelineRegistries->newPipelineRegistry
* Add Reader as field to pipeline
* Replace createAggregators with resolver facilitator
* Replace create agg funcs with inserter facilitator
* Correct documentation
* Replace pipelineRegistry with []pipeline type
* Rename newPipelineRegistry->newPipelines
* Fix pipeline_registry_test
* Flatten isMonotonic into only use
* Update FIXME into TODO
* Rename instrument provider resolver field to resolve
* Fix comment English
* Fix drop aggregator detection
* Bump golang.org/x/sys/unix
Fix#3234
Address GO-2022-0493 by upgrading golang.org/x/sys/unix from
v0.0.0-20210423185535-09eb48e85fd7 to
v0.0.0-20220919091848-fb04ddd9f9c8.
* Add changes to changelog
* Flush pending telemetry when ForceFlush called
* Test flush of periodic reader
* Flush pending telemetry on Shutdown
* Fix things
* Rename pHolder to p
* Add testing for Shutdown
* Fix doc for collect method
* Fix collectAndExport doc
* Fix collectAndExport English
* Remove stdoutmetric example expected output
* Add changes to changelog
* Revert inadvertent change to golangci conf
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
* update the metric mod version to latest
* update additional go.mods
* Unify the Fixed section of Unreleased
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
Co-authored-by: Tyler Yahn <codingalias@gmail.com>