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

539 Commits

Author SHA1 Message Date
Aaron Clawson
289a612e6a
Adds an Attribute assertion to metric data test (#3487)
* Adds an Attribute assertion to metric data test

Signed-off-by: Aaron Clawson <3766680+MadVikingGod@users.noreply.github.com>
2022-11-29 14:32:15 -06:00
Aaron Clawson
d7b31155b5
Make the AsType functions not panic (#3489)
* Make the AsType functions not panic

* Adds changelog

Signed-off-by: Aaron Clawson <3766680+MadVikingGod@users.noreply.github.com>

Signed-off-by: Aaron Clawson <3766680+MadVikingGod@users.noreply.github.com>
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
2022-11-25 15:27:47 -08:00
Aaron Clawson
e36a361b68
Move otlpmetrics Client to an internal package. (#3486)
* Move otlp client to an internal package

* update changelog

* Apply suggestions from code review

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

* Update CHANGELOG.md

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2022-11-22 16:01:53 -08:00
Tyler Yahn
c4333a9687
Deprecate the sdk/metric/view package (#3476)
* Deprecate the sdk/metric/view package

* Add deprecation to changelog
2022-11-21 08:05:07 -08:00
Tyler Yahn
2e780d8e39
Add View, NewView, Instrument, Stream, and InstrumentKind to sdk/metric with unit tests (#3459)
* 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>
2022-11-16 08:18:02 -08:00
Tyler Yahn
308d0362e6
Only registers callbacks if non-drop aggregation is used (#3408)
* 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>
2022-11-11 09:10:59 -08:00
Tyler Yahn
d091ba88e4
Do not export aggregations without any data points (#3436)
* 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
2022-11-11 07:22:27 -08:00
Tyler Yahn
484c8bd8d8
Handle partial success response from OTLP server in otlpmetric exporters (#3440)
* Handle partial success resp from OTLP server

* Test partial success response handling

* Add changes to changelog

Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
2022-11-09 07:44:06 -08:00
Sean Liao
2694dbfdba
add new env config options for OTLP exporter (#3363)
* add new env config options for OTLP exporter

* error path

* Update exporters/otlp/internal/envconfig/envconfig.go

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

* Update exporters/otlp/internal/envconfig/envconfig.go

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

* Update exporters/otlp/internal/envconfig/envconfig.go

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

* Update exporters/otlp/internal/envconfig/envconfig.go

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

* Update exporters/otlp/internal/envconfig/envconfig.go

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

* Update exporters/otlp/internal/envconfig/envconfig.go

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

* add error logging

* add missing early returns

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
2022-11-08 10:53:59 -08:00
Aaron Clawson
c21b6b6bb3
Adds attribute filter logic (#3396)
* Adds attribute filter logic

* Apply PR feedback

* Use updated MP options

* Update Changelog and TODO numbers

Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
2022-11-08 07:45:23 -08:00
Tyler Yahn
b5b685249c
Do not handle empty partial OTLP successes (#3438)
* Do not handle empty partial OTLP successes

Fix #3432.

The OTLP server will respond with empty partial success responses (i.e.
empty messages and 0 count). Treat these as equivalent to it not being
set/present like the documentation specifies in the proto:
724e427879/opentelemetry/proto/collector/trace/v1/trace_service.proto (L58)

* Fix tests

* Add changes to changelog
2022-11-03 09:02:39 -07:00
Ziqi Zhao
e8023fab22
prometheus exporter convert instrumentation scope to otel_scope_info metric (#3357)
* prometheus exporter convert instrumentation scope to otel_scope_info metric

Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>

* fix for commits

Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>

* fix for ci failed

Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>

* add multi scopes test

Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>

* fix ci failed

Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>

Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>
2022-11-02 07:50:37 -07:00
Tyler Yahn
48a05478e2
Move Aggregation/Temporality selection to the Exporter interface (#3260)
* Add Aggregation/Temporality to Exporter iface

* Use Exporter selectors in periodic reader

* Move selector opts to just manual reader

* Simplify periodic reader ref to Exporter selectors

* Fix the periodic reader tests

* Add Aggregation/Temporality method to stdoutmetric

* Add Temporality/Aggregation to otlpmetric exp

* Add Temporality/Aggregation to http/grpc otlp clients

* Add oconf tests for selector opts

* Add tests to stdoutmetric for opts

* Correct comment subject

* Add changes to changelog

* Fix otest test client
2022-11-01 07:56:18 -07:00
Tyler Yahn
d1aca7b167
Associate views with MeterProvider instead of Reader (#3387)
* 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
2022-10-31 07:55:54 -07:00
ReStartercc
3dd4e816a6
fix wrong representation of status value in zipkin exporter (#3340)
* export status codes to upper case in zipkin exporter

* add test cases for status UNSET and ERROR

* Update exporters/zipkin/model.go

correct the usage of case-sensitive terms

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

* change unit test cases to test exact behavior

* move this PR to unrelease section in the CHANGELOG.md

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2022-10-27 21:22:18 -07:00
Kuisong Tong
94ae231180
Set IsMonotonic to true for opencensus sum (#3389)
* Set IsMonotonic to true for opencensus sum 

fix #3388

* Update metric_test.go

* fix test

* add changelog

* Update CHANGELOG.md

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2022-10-27 14:29:01 -07:00
Tyler Yahn
40f19009b0
Calculate delta sums for delta async counter/up-down-counter types (#3398)
* 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
2022-10-27 08:47:27 -07:00
Tony Han
ccbc38e66e
Fix prometheus name duplicate _total suffix (#3369)
Signed-off-by: Bing Han <h.bing612@gmail.com>

Signed-off-by: Bing Han <h.bing612@gmail.com>
2022-10-21 08:12:23 -07:00
Tyler Yahn
2fe8861a24
Release v1.11.1/v0.33.0 (#3367)
* 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
2022-10-19 12:55:44 -07:00
David Ashpole
510910e92d
Add unit suffixes to prometheus metric names (#3352)
* add unit suffixes to prometheus metric names

* Update CHANGELOG.md

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

* remove unneccessary variable

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2022-10-19 15:25:18 -04:00
David Ashpole
1d9d4b2124
add _total suffixes to prometheus counters (#3360) 2022-10-19 11:23:34 -07:00
Tyler Yahn
715631d35f
Fix Asynchronous Counters Recording (#3350)
* 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
2022-10-19 10:35:13 -07:00
Gustavo Paiva
2d02a2f126
converts Resource into a target_info metric on the prometheus exporter (#3285)
* converts `Resource` into a `target_info` metric on the prometheus exporter
2022-10-19 11:22:46 -05:00
Luiz Aoqui
05aca23c19
Decode values from OTEL_RESOURCE_ATTRIBUTES (#2963)
* 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>
2022-10-19 09:13:20 -07:00
David Ashpole
430f55878b
Convert UpDownCounters to Prometheus gauges (#3358)
* updown counters are now converted to prometheus gauges

* Update CHANGELOG.md

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2022-10-19 09:07:53 -07:00
Aaron Clawson
99153429d5
Added WithAggregationSelector to prometheus (#3341)
* Added WithAggregationSelector to prometheus

* Update CHANGELOG.md

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

* Address PR comments

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2022-10-18 14:07:24 -07:00
Aaron Clawson
8b25cb2a85
Removes the functionality of the Describe in prometheus exporter. (#3342)
* remove prom exporter Describe

* Apply suggestions from code review

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2022-10-18 13:02:46 -07:00
ReStartercc
0963f59955
Fix baggage.NewMember to decode the accepted value (#3226)
* Fix baggage.NewMember to decode the accepted value

`value` is decoded and stored after validating the input parameters.

Corresponding test cases are modified so that we can make sure `value` is properly encoded before creating Member.

* fix md lint

* add function document to NewMember for value encoding and decoding

* remove redundant comments and fix CHANGELOG.md

* fix wrong PR number in the changelog

* fix wrong PR number

* fix md-lint

Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
2022-10-18 12:45:04 -07:00
Tyler Yahn
042d938989
Fix HistogramDataPoints transform in otlpmetric (#3293)
* Fix HistogramDataPoints transform in otlpmetric

Fixes #3284

The transform uses the same reference a histogram datapoint sum value
for all transformed metrics. This results in all transformed metrics
being exported with the same sum (see #3284). This changes the transform
to correctly reference a unique sum for each datapoint.
2022-10-17 08:13:07 -05:00
Aaron Clawson
b6a22abab7
Refactor Prometheus exporter (#3239)
This change will automatically register a created exporter with a prometheus registerer, if none are provided it will use prometheus' DefaultRegisterer.

Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
2022-10-14 09:22:43 -05:00
Albert
1e72af45a9
promtheus exporter will sum hist buckets (#3281) (#3282)
Signed-off-by: albertlockett <albert.lockett@gmail.com>
2022-10-14 09:13:35 -05:00
Alan Protasio
84e28fd3bd
Fix Http Status Code with Otel Bridge (#3265)
* Fix Http Status Code with Otel Bridge

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2022-10-13 10:44:40 -05:00
Ziqi Zhao
a8b9ddc7f6
attribute: fix slice related function bug (#3252)
* attribute: fix slice related function bug

Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
2022-10-13 09:34:02 -05:00
Bogdan Drutu
e4bdfe7b56
Fix sdktrace.TraceProvider Shutdown/ForceFlush when no processor register (#3268)
* Fix sdktrace.TraceProvider Shutdown/ForceFlush when no processor register

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

* Update CHANGELOG.md

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2022-10-12 13:44:18 -07:00
Tyler Yahn
ff18552791
Release v1.11.0/v0.32.3 (#3275)
* 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}
2022-10-12 10:19:51 -07:00
Tyler Yahn
29511a0078
Release Metric v0.32.2 (#3270)
* Bump experimental-metrics version to v0.32.2

* Prepare experimental-metrics for version v0.32.2

* Update changelog
2022-10-11 14:55:18 -07:00
Tyler Yahn
b5292b8459
Handle duplicate Aggregators and log instrument conflicts (#3251)
* 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>
2022-10-11 15:41:47 -04:00
David Ashpole
ffa94ca529
Improve test coverage, and don't send empty batches in OC bridge (#3263)
* improve test coverage, and don't send empty batches in OC bridge

* Update bridge/opencensus/metric_test.go

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

* remove 1.18 rule

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2022-10-11 08:50:09 -07:00
copy rogers
4ec2ae60f2
Add User-Agent header to OTLP exporter requests (#3261)
* Add User-Agent header to OTLP exporter requests
* allow override grpc user-agent

Signed-off-by: rogerogers <rogers@rogerogers.com>
2022-10-11 09:55:50 -05:00
Tyler Yahn
c5ebbc4d4b
Use default view if instrument does not match any pipeline view (#3237)
* 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.
2022-10-07 00:40:54 -04:00
Damien Mathieu
697d245b9c
Update bucket default bounds (#3222)
* 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>
2022-10-04 15:41:18 -07:00
Tyler Yahn
12e16d41e7
Bump golang.org/x/sys/unix (#3235)
* 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
2022-09-27 09:08:34 -07:00
Tyler Yahn
111a1d7bbd
Flush pending telemetry when ForceFlush or Shutdown are called on a PeriodicReader (#3220)
* 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>
2022-09-27 08:05:41 -07:00
Tony Han
8c6e6c4bac
Add an example of view (#3177)
* Add an example of view

* Update meter name in view example

Co-authored-by: Sam Xie <sam@samxie.me>

* Update dependabot and versions.yaml

* Fix code review and add CHANGELOG

Co-authored-by: Sam Xie <sam@samxie.me>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2022-09-26 09:04:09 -07:00
wdullaer
b369e59ba1
Improve trace status handling (#3214)
* Implement specification compliant trace status handling

* Update trace/trace.go

Co-authored-by: Damien Mathieu <42@dmathieu.com>

* Update CHANGELOG.md

Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>

* chore: Make linter happy

Co-authored-by: Damien Mathieu <42@dmathieu.com>
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2022-09-23 11:39:53 -07:00
Aaron Clawson
d7bfe6675f
Prerelease metrics/v0.32.1 (#3228)
* Prepare for v0.32.1 release

* Prepare experimental-metrics for version v0.32.1

* Update Changelog

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2022-09-22 14:47:08 -05:00
Aaron Clawson
c979be08e4
Update sdk/metric go.mod version to latest (#3216)
* 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>
2022-09-22 09:36:24 -07:00
Tyler Yahn
4eea5db998
Set MeterProvider resource for all pipelines (#3218)
* Set MeterProvider resource for all pipelines

Resolves #3208

* Add change to changelog
2022-09-22 09:18:18 -07:00
Damien Mathieu
bfaff3a097
Sanitize metric names in the prometheus exporter (#3212)
* sanitize metric names in the prometheus exporter

* add changelog entry

* fix now invalid comment

* replace sanitizeName algorithm with one based on strings.Map

* check that digits as first characters are replaced

* Update exporters/prometheus/exporter.go

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

* add missing utf8 import

* add explicit tests for sanitizeName

* fix testdata with digit prepend

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
2022-09-22 07:23:16 -07:00
David Ashpole
2ae5922848
reintroduce opencensus bridge example (#3206)
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2022-09-21 14:45:24 -07:00