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

791 Commits

Author SHA1 Message Date
Robert Pająk
088ac8e179
Fix panic, deadlock and race in BatchSpanProcessor (#4353) 2023-07-25 10:13:45 +02:00
Tyler Yahn
e26d8bd8f8
Remove benchmark dev files mistakenly added in #4349 (#4358) 2023-07-24 11:03:09 -07:00
Tyler Yahn
ab61991465
Log a view suggestion for duplicate instrument conflicts (#4349)
* Log a view suggestion for duplicate instrument conflicts

* Add change to changelog

* Update changelog entry
2023-07-24 07:47:56 -07:00
Robert Pająk
fd5284f75c
styleguide: tests goroutine leaks and naming (#4348)
* internal/global: Fix goroutine leaks in tests
2023-07-24 09:35:06 +02:00
Tyler Yahn
cbc5890d9c
Simplify the last-value aggregate (#4343)
Instead of treating the returned *lastValue as an aggregator from
newLastValue, just use the type directly to construct the Measure and
ComputeAggregation functions returned from the Builder.

Accept a destination type for the underlying computeAggregation. This
allows memory reuse for collections which adds a considerable
optimization.

Simplify the integration testing of the last-value aggregate.

Update benchmarking.
2023-07-21 08:30:11 +02:00
Tyler Yahn
a37cb0504a
Replace filter aggregator with direct filter on measure (#4342)
* Replace filter aggregator with direct filter on measure

Part of #4220

Instead of using an aggregator to filter measured attributes, directly
filter the attributes in the constructed Measure function the Builder
creates.

Include unit and integration testing of new filtering.

* Update sdk/metric/internal/aggregate/aggregate.go

Co-authored-by: David Ashpole <dashpole@google.com>

---------

Co-authored-by: David Ashpole <dashpole@google.com>
2023-07-20 13:53:50 -07:00
Tyler Yahn
e08359f30c
Detect duplicate instruments for case-insensitive names (#4338)
* Detect dup inst for case-insensitive names

Resolve #3835

Detect duplicate instrument registrations for instruments that have the
same case-insensitive names. Continue to return the instruments with
different names, but log a warning. This is the solution proposed in
https://github.com/open-telemetry/opentelemetry-specification/pull/3606.

* Add changes to changelog

* Reset global logger after test
2023-07-19 10:17:38 -07:00
Tyler Yahn
84b2e54671
Use inst ID for agg cache key (#4337)
* Use inst ID for agg cache key

Resolve #4201

The specification requires the duplicate instrument conflicts to be
identified based on the instrument identifying fields:

- name
- instrument kind
- unit
- description
- language-level features such as the number type (int64 and float64)

Currently, the conflict detection and aggregation caching are done based
on the stream IDs which include an aggregation name, monotonicity, and
temporality instead of the instrument kind.

This changes the conflict detection and aggregation caching to use the
OpenTelemetry specified fields. This is effectively a no-op given there
is a 1-to-1 mapping of aggregation-name/monotonicity/temporality to
instrument kind (they are all resolved based on the instrument kind).

Additionally, this adds a stringer representation of the
`InstrumentKind`. This is needed for the logging of duplicate instrument
conflicts.

* Add changes to changelog
2023-07-19 09:59:07 -07:00
David Ashpole
c197fe9305
Metric SDK: Sum duplicate async observations regardless of filtering (#4289)
* Metric SDK: Remove the distinction between filtered and unfiltered attributes.
2023-07-19 10:52:11 -05:00
Tyler Yahn
f2a9f2f2be
Restrict Meters to only register and collect instruments it created (#4333)
* Add acceptance test

* Update Meter Register and collect only inst from itself

* Add change to changelog

* Fix spelling error

* Update changelog entry wording

* Simplify the partial success code path
2023-07-19 07:31:11 -07:00
Tyler Yahn
f194fb0c6c
Allow histogram for all instruments (#4332)
* Allow histogram for all instruments

Any instrument that can record negative values, do not include a sum in
the produced aggregation (like the specification recommends).

Resolves #4161

* Add changes to changelog

* Fix TestBucketsSum
2023-07-19 07:12:00 -07:00
Matthew Wear
9b0c4d2caf
Fix empty host.id (#4317) 2023-07-18 17:37:20 +02:00
Aaron Clawson
f6a658c6c2
Remove out of date example of internal usage. (#4334) 2023-07-18 10:10:34 +02:00
Tyler Yahn
63dfc4c2f1
Update the instrument agg comp table (#4330)
Use a check mark to indicate compatible instead of an "X" which can be
misinterpreted as incompatible.
2023-07-17 11:17:35 -07:00
Tyler Yahn
7467923a51
Add info/debug logging to the metric SDK (#4315)
* Add debug logging to the metric SDK

Resolves #3722

* Log MeterProvider and Meter setup at info level

* Add changelog entry

---------

Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
Co-authored-by: Robert Pająk <pellared@hotmail.com>
2023-07-17 07:57:01 -07:00
Tyler Yahn
d18f20179e
Replace internal aggregate Aggregator with Measure/ComputeAggregation and a Builder (#4304) 2023-07-17 16:15:50 +02:00
Tyler Yahn
55fb2bb57b
Log an error for an empty view criteria (#4307)
* Log an error for an empty view

Resolves #4149

* Add changelog entry
2023-07-12 15:10:40 -07:00
Tyler Yahn
fcc67096b5
Add test for multi-inst view error (#4308) 2023-07-12 15:01:14 -07:00
David Ashpole
de26aaa52e
Metric SDK: Do not export non-observed attribute sets for async instruments (#4290)
* drop non-observed attribute sets

* fix test comment

* add documentation for async callbacks dropping unobserved attributes
2023-07-11 07:19:38 -07:00
OpenTelemetry Bot
8b7bffc8b9
dependabot updates Sun Jul 9 14:40:56 UTC 2023 (#4301)
Bump google.golang.org/grpc from 1.56.1 to 1.56.2 in /bridge/opentracing/test
Bump google.golang.org/grpc from 1.56.1 to 1.56.2 in /exporters/otlp/otlptrace/otlptracegrpc
Bump golang.org/x/tools from 0.10.0 to 0.11.0 in /internal/tools
Bump google.golang.org/grpc from 1.56.1 to 1.56.2 in /exporters/otlp/otlptrace
Bump benchmark-action/github-action-benchmark from 1.17.0 to 1.18.0
Bump google.golang.org/grpc from 1.56.1 to 1.56.2 in /exporters/otlp/otlpmetric/otlpmetricgrpc
Bump google.golang.org/grpc from 1.56.1 to 1.56.2 in /example/otel-collector
Bump google.golang.org/grpc from 1.56.1 to 1.56.2 in /exporters/otlp/otlpmetric
Bump golang.org/x/sys from 0.9.0 to 0.10.0 in /sdk
2023-07-09 20:25:46 +02:00
Tyler Yahn
1633c74aea
Replace Stream.AttributeFilter with AllowAttributeKeys (#4288)
* Replace Stream AttributeFilter with AttributeKeys

* Rename Stream field AttributeKeys to AllowAttributeKeys

Ensure forward compatibility if a deny-list of attribute keys is ever
added.

* Add change to changelog

* Update PR number in changelog

* Update CHANGELOG.md

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

---------

Co-authored-by: Damien Mathieu <42@dmathieu.com>
2023-07-08 08:01:47 -07:00
Tyler Yahn
10c3445543
Move aggs to internal/aggregate (#4283) 2023-07-03 10:53:00 +02:00
Tyler Yahn
97273da7c9
Use newPipeline instead of direct construction (#4285)
* Use newPipeline instead of direct construction

The newPipeline function exists to create a new pipeline, but it is not
currently used. This switches to using that as the default creation
method and removes the test for construction of a pipeline directly.

* Update sdk/metric/pipeline.go
2023-07-02 07:17:46 -07:00
Damien Mathieu
64e76f8be4
Document and test honoring context in metric readers Collect (#4267) 2023-06-29 13:20:47 +02:00
Damien Mathieu
3b124b39d1
Count the Collect duration towards the PeriodicReader timeout, and document the behavior (#4221) 2023-06-26 08:47:39 +02:00
Robert Pająk
0396b9b7ac
sdk/metric: Document concurrent safety (#4252) 2023-06-23 16:25:54 +02:00
Robert Pająk
6b262b44ac
sdk/metric: Reader factories return structs (#4244) 2023-06-22 09:09:00 +02:00
OpenTelemetry Bot
e3f547fedd
dependabot updates Tue Jun 20 09:20:10 UTC 2023 (#4240)
Bump google.golang.org/grpc from 1.55.0 to 1.56.0 in /bridge/opentracing/test
Bump github.com/prometheus/client_golang from 1.15.1 to 1.16.0 in /example/view
Bump github.com/golangci/golangci-lint from 1.53.2 to 1.53.3 in /internal/tools
Bump github.com/prometheus/client_golang from 1.15.1 to 1.16.0 in /exporters/prometheus
Bump golang.org/x/tools from 0.9.3 to 0.10.0 in /internal/tools
Bump google.golang.org/grpc from 1.55.0 to 1.56.0 in /exporters/otlp/otlpmetric/otlpmetricgrpc
Bump google.golang.org/grpc from 1.55.0 to 1.56.0 in /exporters/otlp/otlpmetric
Bump google.golang.org/grpc from 1.55.0 to 1.56.0 in /exporters/otlp/otlptrace/otlptracegrpc
Bump google.golang.org/grpc from 1.55.0 to 1.56.0 in /exporters/otlp/otlptrace
Bump github.com/prometheus/client_golang from 1.15.1 to 1.16.0 in /example/prometheus
Bump google.golang.org/grpc from 1.55.0 to 1.56.0 in /example/otel-collector
Bump golang.org/x/sys from 0.8.0 to 0.9.0 in /sdk
2023-06-20 11:38:28 +02:00
Aaron Clawson
b757c7083b
Exponential Histogram Datatypes (#4165)
* Adds the Exponential histogram data type.

* Changelog

* Updated comments

* Apply suggestions from code review

Co-authored-by: Robert Pająk <pellared@hotmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

* Split Exponential Buckets into it's own type

---------

Co-authored-by: Robert Pająk <pellared@hotmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2023-06-14 07:36:13 -07:00
Damien Mathieu
844b107e98
Validate instrument names when creating them (#4210)
* validate instrument names when creating them

* add changelog entry

* remove now invalid instrument name from prometheus test

* fix invalid names in meter_test

* keep returning the instrument even if its name is invalid

* make invalid instrument name a known error

* bring back prometheus invalid instrument name test

* remove warning

* fix lint

* move name validation into the lookup method

* fix lint again

* Revert "move name validation into the lookup method"

This reverts commit ec8ccc5fa0.

* rename ErrInvalidInstrumentName to ErrInstrumentName

* switch to explicit validations, instead of a regexp

* Update CHANGELOG.md

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

* remove double check for empty name

* test validation shortcut with a single character

---------

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Aaron Clawson <3766680+MadVikingGod@users.noreply.github.com>
2023-06-09 08:32:56 -07:00
Tyler Yahn
ce46eb5f85
Warn instead of Info log instrument conflict (#4202)
* Warn instead of Info log instrument conflict

* Add change to changelog
2023-06-06 15:22:34 -07:00
OpenTelemetry Bot
135c64f289
dependabot updates Mon Jun 5 09:32:52 UTC 2023 (#4198)
Bump go.opentelemetry.io/build-tools/crosslink from 0.7.0 to 0.8.0 in /internal/tools
Bump go.opentelemetry.io/build-tools/dbotconf from 0.7.0 to 0.8.0 in /internal/tools
Bump go.opentelemetry.io/build-tools/multimod from 0.7.0 to 0.8.0 in /internal/tools
Bump go.opentelemetry.io/build-tools/semconvgen from 0.7.0 to 0.8.0 in /internal/tools
Bump github.com/stretchr/testify from 1.8.3 to 1.8.4 in /exporters/otlp/otlptrace
Bump github.com/stretchr/testify from 1.8.3 to 1.8.4 in /exporters/zipkin
Bump github.com/stretchr/testify from 1.8.3 to 1.8.4 in /exporters/otlp/otlptrace/otlptracehttp
Bump github.com/stretchr/testify from 1.8.3 to 1.8.4 in /bridge/opentracing/test
Bump github.com/stretchr/testify from 1.8.3 to 1.8.4 in /exporters/otlp/internal/retry
Bump github.com/stretchr/testify from 1.8.3 to 1.8.4 in /exporters/otlp/otlpmetric/otlpmetrichttp
Bump github.com/stretchr/testify from 1.8.3 to 1.8.4 in /exporters/otlp/otlptrace/otlptracegrpc
Bump github.com/stretchr/testify from 1.8.3 to 1.8.4 in /exporters/jaeger
Bump github.com/stretchr/testify from 1.8.3 to 1.8.4 in /exporters/stdout/stdouttrace
Bump github.com/stretchr/testify from 1.8.3 to 1.8.4 in /exporters/stdout/stdoutmetric
Bump github.com/stretchr/testify from 1.8.3 to 1.8.4 in /exporters/otlp/otlpmetric
Bump github.com/stretchr/testify from 1.8.3 to 1.8.4 in /schema
Bump github.com/itchyny/gojq from 0.12.12 to 0.12.13 in /internal/tools
Bump github.com/stretchr/testify from 1.8.3 to 1.8.4 in /metric
Bump github.com/stretchr/testify from 1.8.3 to 1.8.4 in /trace
Bump github.com/stretchr/testify from 1.8.3 to 1.8.4 in /exporters/prometheus
Bump github.com/stretchr/testify from 1.8.3 to 1.8.4 in /exporters/otlp/otlpmetric/otlpmetricgrpc
Bump github.com/stretchr/testify from 1.8.3 to 1.8.4 in /bridge/opencensus
Bump github.com/stretchr/testify from 1.8.3 to 1.8.4 in /sdk/metric
Bump github.com/stretchr/testify from 1.8.3 to 1.8.4 in /bridge/opentracing
Bump github.com/stretchr/testify from 1.8.3 to 1.8.4
Bump github.com/stretchr/testify from 1.8.3 to 1.8.4 in /sdk
2023-06-05 11:41:23 +02:00
Damien Mathieu
be82610b44
Return noop meters once the provider has been shutdown (#4154) 2023-06-05 09:51:21 +02:00
Robert Pająk
8cddf8cf1f
sdk/metric: Log empty meter name (#4153)
* sdk/metric: Log empty meter name

* Avoid magic numbers

* Lint

* Apply suggestions from code review

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

* Update log message

* Apply suggestion

---------

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2023-06-01 09:56:17 +02:00
Robert Pająk
f9565872df
sdk/metrics: Fix MeterProvider.Meter Go doc (#4152) 2023-06-01 09:28:29 +02:00
Tyler Yahn
e0852d609c
Release v1.16.0/v0.39.0 -- Stable Metric API (#4100)
* Update versions

* Prepare stable-v1 for version v1.16.0

* Prepare experimental-metrics for version v0.39.0

* Update changelog
2023-05-22 12:06:21 -07:00
OpenTelemetry Bot
3fca55af7a
dependabot updates Sun May 21 15:20:04 UTC 2023 (#4126)
Bump github.com/stretchr/testify from 1.8.2 to 1.8.3 in /exporters/zipkin
Bump github.com/stretchr/testify from 1.8.2 to 1.8.3 in /bridge/opentracing/test
Bump github.com/stretchr/testify from 1.8.2 to 1.8.3 in /schema
Bump github.com/stretchr/testify from 1.8.2 to 1.8.3 in /exporters/otlp/internal/retry
Bump github.com/stretchr/testify from 1.8.2 to 1.8.3 in /exporters/prometheus
Bump github.com/stretchr/testify from 1.8.2 to 1.8.3 in /exporters/stdout/stdoutmetric
Bump github.com/stretchr/testify from 1.8.2 to 1.8.3 in /exporters/otlp/otlptrace
Bump github.com/stretchr/testify from 1.8.2 to 1.8.3 in /exporters/otlp/otlpmetric
Bump github.com/stretchr/testify from 1.8.2 to 1.8.3 in /exporters/otlp/otlpmetric/otlpmetricgrpc
Bump github.com/stretchr/testify from 1.8.2 to 1.8.3 in /exporters/otlp/otlpmetric/otlpmetrichttp
Bump github.com/stretchr/testify from 1.8.2 to 1.8.3 in /exporters/otlp/otlptrace/otlptracegrpc
Bump github.com/stretchr/testify from 1.8.2 to 1.8.3 in /exporters/stdout/stdouttrace
Bump github.com/stretchr/testify from 1.8.2 to 1.8.3 in /exporters/otlp/otlptrace/otlptracehttp
Bump github.com/stretchr/testify from 1.8.2 to 1.8.3 in /metric
Bump github.com/stretchr/testify from 1.8.2 to 1.8.3 in /trace
Bump github.com/stretchr/testify from 1.8.2 to 1.8.3 in /exporters/jaeger
Bump codecov/codecov-action from 3.1.3 to 3.1.4
Bump github.com/stretchr/testify from 1.8.2 to 1.8.3 in /sdk/metric
Bump github.com/stretchr/testify from 1.8.2 to 1.8.3 in /bridge/opencensus
Bump github.com/stretchr/testify from 1.8.2 to 1.8.3 in /bridge/opentracing
Bump github.com/stretchr/testify from 1.8.2 to 1.8.3 in /sdk
Bump github.com/stretchr/testify from 1.8.2 to 1.8.3
2023-05-21 08:45:32 -07:00
Andrew Womeldorf
987422d55f
sdk/metric: Fix import comments (#4086)
* Resolve inconsistent import comments in sdk/metric

* update changelog

* Apply suggestions from code review

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

* Update CHANGELOG.md

---------

Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Robert Pająk <pellared@hotmail.com>
2023-05-19 09:25:11 -07:00
Mikhail Mazurskiy
f95bee22b9
Use strings.Cut() instead of string.SplitN() (#4049)
strings.Cut() generates less garbage as it does not allocate the slice to hold parts.
2023-05-17 09:28:44 -07:00
Chen Xu
fadd3d6a63
[SDK][Trace] Add tests for default id generator (#4043)
Signed-off-by: Chen Xu <chen.x@uber.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2023-05-15 07:18:43 -07:00
Robert Pająk
24e8d2e574
sdk/resource: Add Telemetry Stability label (#4080)
* Add Telemetry Stability label

* Update sdk/resource/doc.go

* Update doc.go

---------

Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
2023-05-11 07:25:32 -07:00
Robert Pająk
7dea2225a2
sdk/resource: Fix build for BSD OSes (#4077)
* sdk/resource: Fix build for BSD OSes

* Add changelog

* Update header in changelog

---------

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2023-05-10 07:47:41 -07:00
Robert Pająk
4d473d105a
[chore] Pin otel-specification hyperlinks (#4033)
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2023-05-09 08:45:39 -07:00
Rakshit Parashar
c338d8eb8a
added version.go and test file for issue 2143 (#3677)
* added version.go and test file for issue 2143

* added license in metric versiont_test

* goimport file linting

* update trace version to v.1.13.0 and metric to 0.36.0

* Update sdk/metric/version.go

Co-authored-by: Robert Pająk <pellared@hotmail.com>

* using asser.Regxp

* changing regex string as per recommendations

Signed-off-by: ChillOrb <rakshitparashar1@gmail.com>

* changing regex string as per recommendations

Signed-off-by: ChillOrb <rakshitparashar1@gmail.com>

* reverting go mod and go sum changes

Signed-off-by: ChillOrb <rakshitparashar1@gmail.com>

* trace and metric version bump up

Signed-off-by: ChillOrb <rakshitparashar1@gmail.com>

* version update in sdk/metric , sdk/trace

Signed-off-by: ChillOrb <rakshitparashar1@gmail.com>

* doc typo fix

Signed-off-by: ChillOrb <rakshitparashar1@gmail.com>

* Apply suggestions from code review

---------

Signed-off-by: ChillOrb <rakshitparashar1@gmail.com>
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
Co-authored-by: Robert Pająk <pellared@hotmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2023-05-09 08:29:19 -07:00
OpenTelemetry Bot
1b04bbc681
dependabot updates Sun May 7 14:59:33 UTC 2023 (#4072)
Bump google.golang.org/grpc from 1.54.0 to 1.55.0 in /bridge/opentracing/test
Bump github.com/prometheus/client_golang from 1.15.0 to 1.15.1 in /example/view
Bump github.com/prometheus/client_model from 0.3.0 to 0.4.0 in /exporters/prometheus
Bump github.com/prometheus/client_golang from 1.15.0 to 1.15.1 in /exporters/prometheus
Bump google.golang.org/grpc from 1.54.0 to 1.55.0 in /exporters/otlp/otlptrace
Bump google.golang.org/grpc from 1.54.0 to 1.55.0 in /exporters/otlp/otlpmetric/otlpmetricgrpc
Bump google.golang.org/grpc from 1.54.0 to 1.55.0 in /exporters/otlp/otlptrace/otlptracegrpc
Bump google.golang.org/grpc from 1.54.0 to 1.55.0 in /exporters/otlp/otlpmetric
Bump google.golang.org/grpc from 1.54.0 to 1.55.0 in /example/otel-collector
Bump github.com/prometheus/client_golang from 1.15.0 to 1.15.1 in /example/prometheus
Bump golang.org/x/sys from 0.7.0 to 0.8.0 in /sdk
2023-05-07 08:11:23 -07:00
Tyler Yahn
e6839571d2
Release v1.16.0-rc.1/v0.39.0-rc.1 (#4048)
* Bump versions

* Prepare stable-v1 for version v1.16.0-rc.1

* Prepare experimental-metrics for version v0.39.0-rc.1

* Update changelog

* Update CHANGELOG.md
2023-05-03 19:39:01 -07:00
Tyler Yahn
17903bcdb6
Revert "Move global metric back to otel/metric/global for minor release (#3986)" (#4039)
* Revert "Move global metric back to `otel/metric/global` for minor release (#3986)"

This reverts commit 8dba38e02f.

* Add changes to changelog

* Fix versions and go mod tidy

* Run go-mod-tidy
2023-05-02 11:15:39 -07:00
Tyler Yahn
fc96138629
Release v1.15.1/v0.38.1 (#4046)
* Bump versions

* Prepare stable-v1 for version v1.15.1

* Prepare experimental-metrics for version v0.38.1

* Update changelog
2023-05-02 10:18:20 -07:00
Ashvitha
dde1930477
Remove unused imports in host_id_bsd.go (#4041)
* remove unused imports in host_id_bsd.go

* Add changelog entry

---------

Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
2023-05-01 08:07:05 -07:00
Tyler Yahn
8e76ab23b4
Release v1.15.0/v0.38.0 (#4035)
* Bump versions

* Prepare stable-v1 for version v1.15.0

* Prepare experimental-metrics for version v0.38.0

* Fix otlpmetric tests

Check pre 1.0 as well

* Update the chagelog
2023-04-28 07:48:08 -07:00
Robert Pająk
180b35513a
Move readFile and execCommand to seperate files (#4015)
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2023-04-27 11:39:09 -07:00
Tyler Yahn
15d6ba2921
Unify metric API into the one otel/metric package (#4018)
* Move instrument into metric

* Update metric docs to include instrument

* Update package names

* Update all imports of sdk/metric/instrument

* Rename Option to InstrumentOption

* Deprecate otel/metric/instrument

* Add changelog entry
2023-04-27 11:25:48 -07:00
Tyler Yahn
f8fcfda872
Add options to measurement methods (#3971)
* Add options to measurement methods

* Update noop

* Update global impl

* Update SDK impl

* Fix metric API example

* Update prometheus exporter tests

* Update examples

* WithAttributes and WithAttributeSet

* Add changes to changelog

* Accept slice instead of variadic to new conf funcs

* Clarify WithAttributes performance in docs

* Address feedback about WithAttributes comment

* Add changelog entry for WithAttribute{s,Set}

* Remove number scope from measure opts

* Update changelog

* Remove left-over test cases

---------

Co-authored-by: Robert Pająk <pellared@hotmail.com>
2023-04-18 07:16:06 -07:00
Tyler Yahn
4b5abe06d2
Refactor the metric SDK benchmarks (#3992)
Benchmark all instruments, not just an int64 counter.

Include benchmarks for all synchronous measurement methods.

Include benchmarks for all collections.
2023-04-14 07:51:10 -07:00
Remy Chantenay
cf8367f711
Fix Version test in otel/sdk (#3994)
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2023-04-14 07:41:27 -07:00
Kaushal Shah
37388599eb
Fixed race condition in OnEnd and added a unit test (#3951)
* Fixed race condition in OnEnd and added a test

* fixed code review comments

* fixed lint

* Update CHANGELOG.md

Co-authored-by: Robert Pająk <pellared@hotmail.com>

* Update sdk/trace/simple_span_processor_test.go

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

* Update sdk/trace/simple_span_processor_test.go

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

* Update sdk/trace/simple_span_processor_test.go

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

* fixed panic check

---------

Co-authored-by: Robert Pająk <pellared@hotmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2023-04-14 07:23:47 -07:00
Tyler Yahn
8dba38e02f
Move global metric back to otel/metric/global for minor release (#3986)
* Revert "Remove the deprecated `otel/metric/global` pkg (#3829)"

This reverts commit 60f7d42d1e.

* Revert "Support a global MeterProvider in `go.opentelemetry.io/otel` (#3818)"

This reverts commit 813936187e.

* Remove top level metric global

* Add change to changelog
2023-04-13 07:39:39 -07:00
Charlie Le
1b55281859
docs(typos): Run codespell to fix typos (#3980)
* docs(typos): Run codespell to fix typos

There were a lot of typos through the repository, so I ran
[codespell][], a tool for automatically fixing typos, to fix them.

```console
make codespell
```

There's already a tool called [misspell][] that's supposed to take care
of this, but misspell hasn't been updated for 6 years, and it doesn't
seem to be catching any of the typos that codespell can.

[codespell]: https://github.com/codespell-project/codespell
[misspell]: https://github.com/client9/misspell

* Revert and ignore spelling for Consequentially

* Add GH workflow for codespell

* Revert GH Workflow and Makefile for codespell

Per @pellared, since there's no instructions for setting up codespell,
it was suggested that the changes for setting up a workflow and section
in Makefile include instructions for setting up codespell as well.

* Revert spelling on consequently

---------

Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2023-04-11 17:28:13 -07:00
Remy Chantenay
1b97d78324
Add Version func to otlpmetric and otlptrace (#3956)
* Add Version func to otel/exporters/otlp/otlpmetric

* Add Version func to otel/exporters/otlp/otlptrace

* Remove Version func from otel/exporters/otlp/internal

* Update CHANGELOG.md

* Add nolint rule to hostid readFile

* Move GetUserAgentHeader to internal packages

* Update exporters/otlp/otlpmetric/version.go

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

* Update exporters/otlp/otlptrace/version.go

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

---------

Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2023-04-10 14:19:49 -07:00
OpenTelemetry Bot
a261a0f869
dependabot updates Sun Apr 9 14:31:33 UTC 2023 (#3979)
Bump golang.org/x/tools from 0.7.0 to 0.8.0 in /internal/tools
Bump golang.org/x/sys from 0.6.0 to 0.7.0 in /sdk
2023-04-09 07:43:00 -07:00
Damien Mathieu
02fa1e2a8d
Fix aggregation.Default to properly return the default one (#3967)
* fix aggregation.Default to properly return the default one

* add changelog entry

* default aggregation does not error anymore

* test all instrument kinds
2023-04-05 07:44:48 -07:00
Tyler Yahn
65ebe5e50f
Add embedded private method interfaces in metric API (#3916)
* PoC of embedded private method ifaces

* Rename embed to embedded

* Add an embedded iface for all instruments

* Fix metric/instrument tests

* Fix global and otel

* Fix SDK

* Comment the embedded pkg types

* Update the embedded pkg docs

* Update otel/metric docs about impls

* Update otel/metric type docs on impl

* Update docs in otel/metric/instrument on default

* Add changes to changelog

* Apply suggestions from code review

Co-authored-by: Robert Pająk <pellared@hotmail.com>

* Apply feedback on URLs

* Reword based on feedback

* Make it clear we only recommended embedding noop

* Ignore links with godot linter

---------

Co-authored-by: Robert Pająk <pellared@hotmail.com>
2023-04-03 07:33:19 -07:00
OpenTelemetry Bot
5f13db5ca6
dependabot updates Sun Apr 2 15:32:08 UTC 2023 (#3963)
Bump github.com/go-logr/logr from 1.2.3 to 1.2.4 in /exporters/zipkin
Bump github.com/go-logr/logr from 1.2.3 to 1.2.4 in /exporters/jaeger
Bump github.com/go-logr/logr from 1.2.3 to 1.2.4 in /sdk/metric
Bump github.com/go-logr/logr from 1.2.3 to 1.2.4 in /sdk
Bump github.com/go-logr/logr from 1.2.3 to 1.2.4
2023-04-02 12:10:19 -04:00
Mikhail Mazurskiy
22fd10447d
Unify TracerProvider span processor lookups (#3942)
* Pre-allocate spanProcessorStates slice

* Make sync.Once a non-pointer

It doesn't need to be a pointer, can be part of the struct to avoid allocating a separate object for it

* getSpanProcessors() helper

* Add tests for UnregisterSpanProcessor()
2023-04-01 07:57:35 -07:00
Tyler Yahn
271df1dc01
Add Version func to otel/sdk (#3949)
* Add Version func to otel/sdk

* Update sdk/resource to use sdk version

* Remove unused UserAgent from sdk/internal

* Add changes to changelog

* Update CHANGELOG.md

Co-authored-by: Robert Pająk <pellared@hotmail.com>

---------

Co-authored-by: Robert Pająk <pellared@hotmail.com>
2023-03-30 12:49:39 -07:00
Tyler Yahn
f4a9d78e7f
Update Histogram Extrema and Sum to be generic (#3870)
* Update Histogram Extrema and Sum to be generic

* Update metric SDK

* Update exporters

* Add changes to changelog
2023-03-29 11:24:25 -07:00
Mikhail Mazurskiy
c4940f3b43
TracerProvider allows calling Tracer() while it's shutting down (#3924) 2023-03-27 17:05:44 -07:00
Damien Mathieu
ae90c4402e
switch atomic.Value to atomic.Pointer for spanProcessorStates (#3926)
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2023-03-27 09:38:47 -07:00
Eduardo Bonzi da Conceição
b73a33c487
Warn on intitialization of Simple SpanProcessor (#3854)
* add warning log about using simpleSpanProcessor in production

* add changelog entry

* fix changelog

* switch to using the new Warn logging function

* revert alignment formatting in changelog

---------

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2023-03-24 08:29:52 -07:00
Tyler Yahn
7ad0ae4da1
Release v1.15.0-rc.2/v0.38.0-rc.2 (#3923)
* Bump versions

* Prepare stable-v1 for version v1.15.0-rc.2

* Prepare experimental-metrics for version v0.38.0-rc.2

* Update changelog

* Update CHANGELOG.md

Co-authored-by: Robert Pająk <pellared@hotmail.com>

---------

Co-authored-by: Robert Pająk <pellared@hotmail.com>
2023-03-23 07:47:46 -07:00
Mikhail Mazurskiy
e4cc478c02
TracerProvider doesn't allow to register a SpanProcessor after shutdown (#3845) 2023-03-22 09:47:42 -07:00
Matthew Wear
282a47e3d3
add host.id to resource auto-detection (#3812)
* add platform specific hostIDReaders

* add WithHostID option to Resource

* add changelog entry

* Apply suggestions from code review

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

* linting

* combine platform specific readers and tests

This allows us to run tests for the BSD, Darwin, and Linux readers
on all platforms.

* add todo to use assert.AnError after resource.Detect error handling is updated

* move HostID test utilities to host_id_test

* return assert.AnError from mockHostIDProviderWithError

* use assert.ErrorIs

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

---------

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Aaron Clawson <3766680+MadVikingGod@users.noreply.github.com>
2023-03-21 14:45:30 -05:00
Tyler Yahn
90df52586b
Split metric configuration down to instrument (#3895)
* Split metric configuration down to instrument

* Rename *ObserverOptions to *ObservableOption

* Update option docs with links
2023-03-21 08:16:57 -05:00
Tyler Yahn
b7b53bba40
Remove Synchronous and rename Asynchronous (#3892)
* Remove the Synchronous interface

* Rename Asynchronous to Observable

* Update PR number
2023-03-20 13:26:17 -07:00
Sinan Ülker
7fc24d2b14
Update the metric Export interface to accept a *ResourceMetrics instead of ResourceMetrics (#3853)
* Change the signature of Export method

* Pass tests for otlp exporter

* Pass tests for otlp grpc and http packages

* Update opencensus bridge

* Refactor and pass tests for stdoutmetric package

* Update periodic reader tests

* Update changelog

* Apply suggestions

* Apply suggestions

* Update CHANGELOG.md

---------

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2023-03-16 10:58:43 -07:00
Mori
3a40e65a38
Update go directive value in go.mod files to 1.19 (#3850)
* remove go 1.18 in go.mod, add go 1.19

* revert //+build directives

* remove +build directives

---------

Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2023-03-15 09:52:04 -07:00
Tyler Yahn
01b8f15a72
Add Exemplar to metricdata package (#3849)
* Add Exemplar to metricdata pkg

* Update histogram Aggregator

* Update opencensus bridge

* Update prometheus exporter

* Update OTLP exporter

* Update stdoutmetric exporter

* Add changes to changelog

* Update fail tests

* Add tests for IgnoreExemplars

* Fix merge
2023-03-14 07:56:18 -07:00
Tyler Yahn
b62eb2ca88
Pool sortables used to create attribute sets (#3832)
* Pool sortables used to create attribute sets

* Move sync pool to attribute pkg

* Add change to changelog

* Fix comment

* Apply suggestions from code review

Co-authored-by: Peter Liu <lpfvip2008@gmail.com>

* Update sdk/metric/instrument.go

Co-authored-by: Robert Pająk <pellared@hotmail.com>

* Update comment based on feedback

* Apply feedback

---------

Co-authored-by: Peter Liu <lpfvip2008@gmail.com>
Co-authored-by: Robert Pająk <pellared@hotmail.com>
2023-03-13 11:19:28 -07:00
Aaron Clawson
e463505da7
Reuse memory in metric pipelines (#3760)
* Have pipelines reuse memory

* truncate Metric slice

* Apply suggestions from code review

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

* Use rm pool on periodic shutdown.

* zero out RM on ctx error

* Update sdk/metric/pipeline.go

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

* Apply suggestions from code review

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

* Fix lint

---------

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Peter Liu <lpfvip2008@gmail.com>
Co-authored-by: Tyler Yahn <codingalias@gmail.com>
2023-03-09 09:43:16 -08:00
Tyler Yahn
7dc7b30405
Remove unneeded type argument from metric SDK (#3831)
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
2023-03-09 07:33:18 -08:00
Tyler Yahn
1626ff746f
Wrap errors returned from Detect and New in sdk/resource (#3844)
* Update Detect and New to wrap errors

* Add TestNewWrapedError

Test that New returns an error that can be unwrapped.

* Add changes to changelog

* Clarify and simplify errors
2023-03-08 15:15:27 -08:00
OpenTelemetry Bot
3df561e644
dependabot updates Mon Mar 6 15:33:46 UTC 2023 (#3840)
Bump github.com/itchyny/gojq from 0.12.11 to 0.12.12 in /internal/tools
Bump golang.org/x/sys from 0.5.0 to 0.6.0 in /sdk
2023-03-06 07:40:41 -08:00
Tyler Yahn
34aacd95ff
Release v1.15.0-rc.1 (#3825)
* Bump module set versions

* Prepare stable-v1 for version v1.15.0-rc.1

* Prepare experimental-metrics for version v0.38.0-rc.1

* Update changelog
2023-03-02 07:43:27 -08:00
Tyler Yahn
813936187e
Support a global MeterProvider in go.opentelemetry.io/otel (#3818)
* Move ErrorHandler impl to internal

To avoid the import cycle, the otel/metric package needs to not import
otel. To achieve this, the error handling implementation is moved to the
otel/internal/global package where both can import the needed
functionality.

* Add global metric to go.opentelemetry.io/otel

* Crosslink and update to global metric in otel

* Add changes to changelog

* Set PR number in changelog

* Add global metric unit tests

* Rename MeterProivder() to GetMeterProivder()

* Add TODO to remove nolint comments
2023-03-01 11:16:03 -08:00
Robert Pająk
d0e4a438ef
Handle empty env vars as it they were not set (#3764)
* Handle empty env vars as it they were not set

* Add changelog entry

* Add missing unit test
2023-02-28 12:43:48 -08:00
Tyler Yahn
2e54fbb3fe
Release v1.14.0/v0.37.0/v0.0.4 (#3810)
* Bump mod versions

* Add bridge/opentracing/test to versions.yaml

* Prepare stable-v1 for version v1.14.0

* Prepare experimental-metrics for version v0.37.0

* Prepare experimental-schema for version v0.0.4

* Update changelog
2023-02-27 13:57:23 -08:00
Tyler Yahn
fe6856e804
Deprecate metric/unit and use a string for units in the metric API/SDK (#3776)
* Replace Unit from metric/unit with string

Deprecate the units package. This package will not be included in the
metric GA.

* Add changes to changelog
2023-02-27 08:10:56 -08:00
Aaron Clawson
17e5d0f549
Do not wrap error if multierror does not have one. (#3772) 2023-02-27 09:10:55 -06:00
OpenTelemetry Bot
0a75c5bd8a
dependabot updates Sun Feb 26 15:49:13 UTC 2023 (#3804)
Bump github.com/stretchr/testify from 1.8.1 to 1.8.2 in /bridge/opentracing/test
Bump github.com/stretchr/testify from 1.8.1 to 1.8.2 in /exporters/otlp/internal/retry
Bump github.com/stretchr/testify from 1.8.1 to 1.8.2 in /schema
Bump github.com/stretchr/testify from 1.8.1 to 1.8.2 in /exporters/otlp/otlpmetric/otlpmetrichttp
Bump github.com/stretchr/testify from 1.8.1 to 1.8.2 in /exporters/prometheus
Bump github.com/stretchr/testify from 1.8.1 to 1.8.2 in /metric
Bump github.com/stretchr/testify from 1.8.1 to 1.8.2 in /exporters/jaeger
Bump github.com/stretchr/testify from 1.8.1 to 1.8.2 in /exporters/otlp/otlpmetric/otlpmetricgrpc
Bump github.com/stretchr/testify from 1.8.1 to 1.8.2 in /exporters/zipkin
Bump github.com/stretchr/testify from 1.8.1 to 1.8.2 in /trace
Bump github.com/stretchr/testify from 1.8.1 to 1.8.2 in /exporters/otlp/otlpmetric
Bump github.com/stretchr/testify from 1.8.1 to 1.8.2 in /exporters/stdout/stdouttrace
Bump github.com/stretchr/testify from 1.8.1 to 1.8.2 in /exporters/otlp/otlptrace/otlptracegrpc
Bump github.com/stretchr/testify from 1.8.1 to 1.8.2 in /exporters/otlp/otlptrace
Bump github.com/stretchr/testify from 1.8.1 to 1.8.2 in /exporters/otlp/otlptrace/otlptracehttp
Bump github.com/stretchr/testify from 1.8.1 to 1.8.2 in /exporters/stdout/stdoutmetric
Bump github.com/golangci/golangci-lint from 1.51.1 to 1.51.2 in /internal/tools
Bump github.com/stretchr/testify from 1.8.1 to 1.8.2 in /sdk/metric
Bump github.com/stretchr/testify from 1.8.1 to 1.8.2 in /bridge/opencensus
Bump github.com/stretchr/testify from 1.8.1 to 1.8.2 in /sdk
Bump github.com/stretchr/testify from 1.8.1 to 1.8.2
Bump golang.org/x/sys from 0.0.0-20220919091848-fb04ddd9f9c8 to 0.5.0 in /sdk
Bump github.com/stretchr/testify from 1.8.1 to 1.8.2 in /bridge/opentracing
Bump lycheeverse/lychee-action from 1.5.4 to 1.6.1
2023-02-26 07:58:24 -08:00
Robert Pająk
1d6704c8fc
Support OTEL_METRIC_EXPORT_INTERVAL and OTEL_METRIC_EXPORT_TIMEOUT (#3763)
* Support OTEL_METRIC_EXPORT_INTERVAL and OTEL_METRIC_EXPORT_TIMEOUT

* Fix non-positive duration error log


Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2023-02-24 09:26:47 -06:00
Tyler Yahn
f78f72d66c
Merge instrument cache to inserter (#3724)
* Merge instrument cache to inserter

The current pipeline resolution path will only add the resolved
aggregators to the pipeline when it creates one (cache miss). It will
not add it if there is a cache hit. This means (since we cache
instruments at the meter level, not the pipeline level) the first reader
in a multiple-reader setup is the only one that will collect data for
that aggregator. All other readers will have a cache hit and nothing is
added to the pipeline. This is causing #3720.

This resolves #3720 by moving the instrument caching into the inserter.
This means aggregators are cached at the reader level, not the meter.

* Rename aggCV to aggVal

---------

Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
2023-02-21 08:07:37 -08:00
Aaron Clawson
cc8bdaaad4
Change the Reader.Collect Signature. (#3732)
* Changes the signature of Collect().

This DOES NOT make the SDK reuse memory, but it does enable it to be added.
2023-02-21 09:04:27 -06:00
Tyler Yahn
0252734309
Rename instrumentID to streamID in metric SDK (#3735)
An instrument is defined by a name, description, unit, and kind. The
instrumentID contains more identifying information than these fields.
The additional information it contains relate to what the OTel metric
data-model calls a stream. Match the terminology and remove using the
instrumentID name in case we want to use it for something else (say,
when caching instruments).
2023-02-16 13:33:56 -08:00
Anthony Regeda
441a173514
No memory leakage in attributes filter (#3695)
The attributes filter collects seen attributes in order to avoid
filtration on the same attribute set. However, the `attribute.Set` is
not comparable type and new allocations of sets with same attributes will be
considered as new sets.

Metrics with a high cardinality of attributes consume a lot of memory
even if we set a filter to reduce that cardinality.

Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2023-02-13 08:07:06 -08:00
Mackenzie
e9bdda0e68
WithContainerID: Document ECS limitation. (#3639)
* WithContainerID: Document ECS limitation.

WithContainerID is not able to extract the correct container id in an ECS environment. The ECS resource detector should be used instead (https://pkg.go.dev/go.opentelemetry.io/contrib/detectors/aws/ecs).
See #3633.

* fix lint

* Update sdk/resource/config.go

---------

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2023-02-09 11:03:39 -08:00
Tyler Yahn
ddf393886c
Use semconv creation functions (#3683) 2023-02-07 13:42:47 -08:00
Anthony Mirabella
f2fd476f43
Prepare v1.13.0/v0.36.0 release (#3688)
* update versions.yaml for release

Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>

* Prepare stable-v1 for version v1.13.0

* Prepare experimental-metrics for version v0.36.0

* Update CHANGELOG

Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>

---------

Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
2023-02-07 14:34:41 -05:00
Aaron Clawson
5e8eb855bf
Add a benchmark for histogram allocations (#3635)
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
2023-02-02 10:16:25 -08:00
Tyler Yahn
6cb5718eaa
Release v1.12.0/v0.35.0 (#3623)
* Update module versions

* Prepare stable-v1 for version v1.12.0

* Prepare experimental-metrics for version v0.35.0

* Prepare experimental-schema for version v0.0.4

* Update the CHANGELOG

* Undo bump to experimental-schema

Revert to original version as nothing has changed.

* Fix PR number in changelog

* Move change from #3497 into current release
2023-01-29 07:41:22 -08:00
Tyler Yahn
7f4d76ab7a
Use Extrema type for Histogram min/max (#3550)
* Use Extrema type for Histogram min/max

* Add case for Extrema in AssertHasAttributes

* Add changes to changelog

* Add NewExtrema

* Add metricdatatest tests

* Use getter for Extrema

* Fix Extrema doc language

* Correct dataset to be one word

* Ensure multiple extrema are tested in a dataset
2023-01-26 10:49:58 -08:00