Skip to content

Commit

Permalink
OTel-Go-Contrib 0.24 release (#1144)
Browse files Browse the repository at this point in the history
* update dogstatsd

* update datadog

* update cortex

* update cortex

* update instrumentation/host

* update instrumentation/runtime

* update instrumentation/gocql

* naming: replace pusher with controller

* Add multimod management targets to Makefile

Signed-off-by: Anthony J Mirabella <[email protected]>

* Update core modules to v1.0.1/v0.24.0

Signed-off-by: Anthony J Mirabella <[email protected]>

* more fixes

* Update to shirou/gopsutil-v3.21.9 for host instrumentation

* Add Changelog entry

* bump module set versions and CHANGELOG

Signed-off-by: Anthony J Mirabella <[email protected]>

* Prepare stable-v1 for version v1.0.0

* Prepare experimental-instrumentation for version v0.25.0

Signed-off-by: Anthony J Mirabella <[email protected]>

* Prepare experimental-metrics for version v0.25.0

Signed-off-by: Anthony J Mirabella <[email protected]>

* Fix lint issue

Signed-off-by: Anthony J Mirabella <[email protected]>

Co-authored-by: Anthony J Mirabella <[email protected]>
Co-authored-by: Evan Torrie <[email protected]>
  • Loading branch information
3 people authored Oct 6, 2021
1 parent 8e44f3f commit 1412a89
Show file tree
Hide file tree
Showing 204 changed files with 1,223 additions and 1,142 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased]

## [1.0.0/0.25.0] - 2021-10-06

- Resource detectors and propagators (with the exception of `go.
opentelemetry.io/contrib/propagators/opencensus`) are now stable and
released at v1.0.0.
- Update dependency on the `go.opentelemetry.io/otel` project to `v1.0.1`.
- Update dependency on `go.opentelemetry.io/otel/metric` to `v0.24.0`.

## [0.24.0] - 2021-09-21

Update dependency on the `go.opentelemetry.io/otel` project to `v1.0.0`.
- Update dependency on the `go.opentelemetry.io/otel` project to `v1.0.0`.

## [0.23.0] - 2021-09-08

Expand Down
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ $(TOOLS_DIR)/stringer: $(TOOLS_MOD_DIR)/go.mod $(TOOLS_MOD_DIR)/go.sum $(TOOLS_M
cd $(TOOLS_MOD_DIR) && \
go build -o $(TOOLS_DIR)/stringer golang.org/x/tools/cmd/stringer

MULTIMOD=$(TOOLS_DIR)/multimod
$(TOOLS_DIR)/multimod: $(TOOLS_MOD_DIR)/go.mod $(TOOLS_MOD_DIR)/go.sum $(TOOLS_MOD_DIR)/tools.go
cd $(TOOLS_MOD_DIR) && \
go build -o $(TOOLS_DIR)/multimod go.opentelemetry.io/build-tools/multimod

precommit: dependabot-check license-check generate lint build test

.PHONY: test-with-coverage
Expand Down Expand Up @@ -200,3 +205,21 @@ dependabot-check:
echo "missing go.mod dependabot check:"; echo "$$result"; \
exit 1; \
fi

COREPATH ?= "../opentelemetry-go"
.PHONY: sync-core
sync-core: | $(MULTIMOD)
@[ ! -d $COREPATH ] || ( echo ">> Path to core repository must be set in COREPATH and must exist"; exit 1 )
$(MULTIMOD) verify && $(MULTIMOD) sync -a -o ${COREPATH}


.PHONY: prerelease
prerelease: | $(MULTIMOD)
@[ "${MODSET}" ] || ( echo ">> env var MODSET is not set"; exit 1 )
$(MULTIMOD) verify && $(MULTIMOD) prerelease -m ${MODSET}

COMMIT ?= "HEAD"
.PHONY: add-tags
add-tags: | $(MULTIMOD)
@[ "${MODSET}" ] || ( echo ">> env var MODSET is not set"; exit 1 )
$(MULTIMOD) verify && $(MULTIMOD) tag -m ${MODSET} -c ${COMMIT}
4 changes: 2 additions & 2 deletions detectors/aws/ec2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ go 1.15
require (
github.com/aws/aws-sdk-go v1.40.41
github.com/stretchr/testify v1.7.0
go.opentelemetry.io/otel v1.0.0
go.opentelemetry.io/otel/sdk v1.0.0
go.opentelemetry.io/otel v1.0.1
go.opentelemetry.io/otel/sdk v1.0.1
)
12 changes: 6 additions & 6 deletions detectors/aws/ec2/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
go.opentelemetry.io/otel v1.0.0 h1:qTTn6x71GVBvoafHK/yaRUmFzI4LcONZD0/kXxl5PHI=
go.opentelemetry.io/otel v1.0.0/go.mod h1:AjRVh9A5/5DE7S+mZtTR6t8vpKKryam+0lREnfmS4cg=
go.opentelemetry.io/otel/sdk v1.0.0 h1:BNPMYUONPNbLneMttKSjQhOTlFLOD9U22HNG1KrIN2Y=
go.opentelemetry.io/otel/sdk v1.0.0/go.mod h1:PCrDHlSy5x1kjezSdL37PhbFUMjrsLRshJ2zCzeXwbM=
go.opentelemetry.io/otel/trace v1.0.0 h1:TSBr8GTEtKevYMG/2d21M989r5WJYVimhTHBKVEZuh4=
go.opentelemetry.io/otel/trace v1.0.0/go.mod h1:PXTWqayeFUlJV1YDNhsJYB184+IvAH814St6o6ajzIs=
go.opentelemetry.io/otel v1.0.1 h1:4XKyXmfqJLOQ7feyV5DB6gsBFZ0ltB8vLtp6pj4JIcc=
go.opentelemetry.io/otel v1.0.1/go.mod h1:OPEOD4jIT2SlZPMmwT6FqZz2C0ZNdQqiWcoK6M0SNFU=
go.opentelemetry.io/otel/sdk v1.0.1 h1:wXxFEWGo7XfXupPwVJvTBOaPBC9FEg0wB8hMNrKk+cA=
go.opentelemetry.io/otel/sdk v1.0.1/go.mod h1:HrdXne+BiwsOHYYkBE5ysIcv2bvdZstxzmCQhxTcZkI=
go.opentelemetry.io/otel/trace v1.0.1 h1:StTeIH6Q3G4r0Fiw34LTokUFESZgIDUr0qIJ7mKmAfw=
go.opentelemetry.io/otel/trace v1.0.1/go.mod h1:5g4i4fKLaX2BQpSBsxw8YYcgKpMMSW3x7ZTuYBr3sUk=
golang.org/x/net v0.0.0-20210614182718-04defd469f4e h1:XpT3nA5TvE525Ne3hInMh6+GETgn27Zfm9dxsThnX2Q=
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down
2 changes: 1 addition & 1 deletion detectors/aws/ec2/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package ec2

// Version is the current release version of the EC2 resource detector.
func Version() string {
return "0.24.0"
return "1.0.0"
// This string is updated by the pre_release.sh script during release
}

Expand Down
4 changes: 2 additions & 2 deletions detectors/aws/ecs/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ go 1.15

require (
github.com/stretchr/testify v1.7.0
go.opentelemetry.io/otel v1.0.0
go.opentelemetry.io/otel/sdk v1.0.0
go.opentelemetry.io/otel v1.0.1
go.opentelemetry.io/otel/sdk v1.0.1
)
12 changes: 6 additions & 6 deletions detectors/aws/ecs/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
go.opentelemetry.io/otel v1.0.0 h1:qTTn6x71GVBvoafHK/yaRUmFzI4LcONZD0/kXxl5PHI=
go.opentelemetry.io/otel v1.0.0/go.mod h1:AjRVh9A5/5DE7S+mZtTR6t8vpKKryam+0lREnfmS4cg=
go.opentelemetry.io/otel/sdk v1.0.0 h1:BNPMYUONPNbLneMttKSjQhOTlFLOD9U22HNG1KrIN2Y=
go.opentelemetry.io/otel/sdk v1.0.0/go.mod h1:PCrDHlSy5x1kjezSdL37PhbFUMjrsLRshJ2zCzeXwbM=
go.opentelemetry.io/otel/trace v1.0.0 h1:TSBr8GTEtKevYMG/2d21M989r5WJYVimhTHBKVEZuh4=
go.opentelemetry.io/otel/trace v1.0.0/go.mod h1:PXTWqayeFUlJV1YDNhsJYB184+IvAH814St6o6ajzIs=
go.opentelemetry.io/otel v1.0.1 h1:4XKyXmfqJLOQ7feyV5DB6gsBFZ0ltB8vLtp6pj4JIcc=
go.opentelemetry.io/otel v1.0.1/go.mod h1:OPEOD4jIT2SlZPMmwT6FqZz2C0ZNdQqiWcoK6M0SNFU=
go.opentelemetry.io/otel/sdk v1.0.1 h1:wXxFEWGo7XfXupPwVJvTBOaPBC9FEg0wB8hMNrKk+cA=
go.opentelemetry.io/otel/sdk v1.0.1/go.mod h1:HrdXne+BiwsOHYYkBE5ysIcv2bvdZstxzmCQhxTcZkI=
go.opentelemetry.io/otel/trace v1.0.1 h1:StTeIH6Q3G4r0Fiw34LTokUFESZgIDUr0qIJ7mKmAfw=
go.opentelemetry.io/otel/trace v1.0.1/go.mod h1:5g4i4fKLaX2BQpSBsxw8YYcgKpMMSW3x7ZTuYBr3sUk=
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7 h1:iGu644GcxtEcrInvDsQRCwJjtCIOlT2V7IRt6ah2Whw=
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
Expand Down
2 changes: 1 addition & 1 deletion detectors/aws/ecs/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package ecs

// Version is the current release version of the ECS resource detector.
func Version() string {
return "0.24.0"
return "1.0.0"
// This string is updated by the pre_release.sh script during release
}

Expand Down
4 changes: 2 additions & 2 deletions detectors/aws/eks/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.15

require (
github.com/stretchr/testify v1.7.0
go.opentelemetry.io/otel v1.0.0
go.opentelemetry.io/otel/sdk v1.0.0
go.opentelemetry.io/otel v1.0.1
go.opentelemetry.io/otel/sdk v1.0.1
k8s.io/apimachinery v0.21.3
k8s.io/client-go v0.21.3
)
12 changes: 6 additions & 6 deletions detectors/aws/eks/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,12 @@ go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opentelemetry.io/otel v1.0.0 h1:qTTn6x71GVBvoafHK/yaRUmFzI4LcONZD0/kXxl5PHI=
go.opentelemetry.io/otel v1.0.0/go.mod h1:AjRVh9A5/5DE7S+mZtTR6t8vpKKryam+0lREnfmS4cg=
go.opentelemetry.io/otel/sdk v1.0.0 h1:BNPMYUONPNbLneMttKSjQhOTlFLOD9U22HNG1KrIN2Y=
go.opentelemetry.io/otel/sdk v1.0.0/go.mod h1:PCrDHlSy5x1kjezSdL37PhbFUMjrsLRshJ2zCzeXwbM=
go.opentelemetry.io/otel/trace v1.0.0 h1:TSBr8GTEtKevYMG/2d21M989r5WJYVimhTHBKVEZuh4=
go.opentelemetry.io/otel/trace v1.0.0/go.mod h1:PXTWqayeFUlJV1YDNhsJYB184+IvAH814St6o6ajzIs=
go.opentelemetry.io/otel v1.0.1 h1:4XKyXmfqJLOQ7feyV5DB6gsBFZ0ltB8vLtp6pj4JIcc=
go.opentelemetry.io/otel v1.0.1/go.mod h1:OPEOD4jIT2SlZPMmwT6FqZz2C0ZNdQqiWcoK6M0SNFU=
go.opentelemetry.io/otel/sdk v1.0.1 h1:wXxFEWGo7XfXupPwVJvTBOaPBC9FEg0wB8hMNrKk+cA=
go.opentelemetry.io/otel/sdk v1.0.1/go.mod h1:HrdXne+BiwsOHYYkBE5ysIcv2bvdZstxzmCQhxTcZkI=
go.opentelemetry.io/otel/trace v1.0.1 h1:StTeIH6Q3G4r0Fiw34LTokUFESZgIDUr0qIJ7mKmAfw=
go.opentelemetry.io/otel/trace v1.0.1/go.mod h1:5g4i4fKLaX2BQpSBsxw8YYcgKpMMSW3x7ZTuYBr3sUk=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
Expand Down
2 changes: 1 addition & 1 deletion detectors/aws/eks/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package eks

// Version is the current release version of the EKS resource detector.
func Version() string {
return "0.24.0"
return "1.0.0"
// This string is updated by the pre_release.sh script during release
}

Expand Down
4 changes: 2 additions & 2 deletions detectors/gcp/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ go 1.15
require (
cloud.google.com/go v0.94.1
github.com/google/go-cmp v0.5.6
go.opentelemetry.io/otel v1.0.0
go.opentelemetry.io/otel/sdk v1.0.0
go.opentelemetry.io/otel v1.0.1
go.opentelemetry.io/otel/sdk v1.0.1
)
12 changes: 6 additions & 6 deletions detectors/gcp/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
go.opentelemetry.io/otel v1.0.0 h1:qTTn6x71GVBvoafHK/yaRUmFzI4LcONZD0/kXxl5PHI=
go.opentelemetry.io/otel v1.0.0/go.mod h1:AjRVh9A5/5DE7S+mZtTR6t8vpKKryam+0lREnfmS4cg=
go.opentelemetry.io/otel/sdk v1.0.0 h1:BNPMYUONPNbLneMttKSjQhOTlFLOD9U22HNG1KrIN2Y=
go.opentelemetry.io/otel/sdk v1.0.0/go.mod h1:PCrDHlSy5x1kjezSdL37PhbFUMjrsLRshJ2zCzeXwbM=
go.opentelemetry.io/otel/trace v1.0.0 h1:TSBr8GTEtKevYMG/2d21M989r5WJYVimhTHBKVEZuh4=
go.opentelemetry.io/otel/trace v1.0.0/go.mod h1:PXTWqayeFUlJV1YDNhsJYB184+IvAH814St6o6ajzIs=
go.opentelemetry.io/otel v1.0.1 h1:4XKyXmfqJLOQ7feyV5DB6gsBFZ0ltB8vLtp6pj4JIcc=
go.opentelemetry.io/otel v1.0.1/go.mod h1:OPEOD4jIT2SlZPMmwT6FqZz2C0ZNdQqiWcoK6M0SNFU=
go.opentelemetry.io/otel/sdk v1.0.1 h1:wXxFEWGo7XfXupPwVJvTBOaPBC9FEg0wB8hMNrKk+cA=
go.opentelemetry.io/otel/sdk v1.0.1/go.mod h1:HrdXne+BiwsOHYYkBE5ysIcv2bvdZstxzmCQhxTcZkI=
go.opentelemetry.io/otel/trace v1.0.1 h1:StTeIH6Q3G4r0Fiw34LTokUFESZgIDUr0qIJ7mKmAfw=
go.opentelemetry.io/otel/trace v1.0.1/go.mod h1:5g4i4fKLaX2BQpSBsxw8YYcgKpMMSW3x7ZTuYBr3sUk=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
Expand Down
2 changes: 1 addition & 1 deletion detectors/gcp/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package gcp

// Version is the current release version of the GCP resource detector.
func Version() string {
return "0.24.0"
return "1.0.0"
// This string is updated by the pre_release.sh script during release
}

Expand Down
5 changes: 3 additions & 2 deletions exporters/metric/cortex/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ needed.
```go
// Create a Config struct named `config`.

pusher, err := cortex.InstallNewPipeline(config)
controller, err := cortex.InstallNewPipeline(config)
if err != nil {
return err
}
defer controller.Stop(context.Background())

// Make instruments and record data using `global.MeterProvider`.
```
Expand Down Expand Up @@ -319,4 +320,4 @@ size of the overall repo significantly.
* Add configuration option for different selectors

Users may not want to use the default Histogram selector and should be able to choose
which selector they want to use.
which selector they want to use.
97 changes: 50 additions & 47 deletions exporters/metric/cortex/cortex.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"go.opentelemetry.io/otel/sdk/export/metric"
export "go.opentelemetry.io/otel/sdk/export/metric"
"go.opentelemetry.io/otel/sdk/export/metric/aggregation"
"go.opentelemetry.io/otel/sdk/instrumentation"
"go.opentelemetry.io/otel/sdk/metric/aggregator/histogram"
controller "go.opentelemetry.io/otel/sdk/metric/controller/basic"
processor "go.opentelemetry.io/otel/sdk/metric/processor/basic"
Expand All @@ -58,7 +59,7 @@ func (e *Exporter) ExportKindFor(*apimetric.Descriptor, aggregation.Kind) metric
}

// Export forwards metrics to Cortex from the SDK
func (e *Exporter) Export(_ context.Context, res *resource.Resource, checkpointSet metric.CheckpointSet) error {
func (e *Exporter) Export(_ context.Context, res *resource.Resource, checkpointSet metric.InstrumentationLibraryReader) error {
timeseries, err := e.ConvertToTimeSeries(res, checkpointSet)
if err != nil {
return err
Expand Down Expand Up @@ -102,8 +103,8 @@ func NewExportPipeline(config Config, options ...controller.Option) (*controller
return nil, err
}

pusher := controller.New(
processor.New(
cont := controller.New(
processor.NewFactory(
simple.NewWithHistogramDistribution(
histogram.WithExplicitBoundaries(config.HistogramBoundaries),
),
Expand All @@ -112,72 +113,74 @@ func NewExportPipeline(config Config, options ...controller.Option) (*controller
append(options, controller.WithExporter(exporter))...,
)

return pusher, pusher.Start(context.TODO())
return cont, cont.Start(context.TODO())
}

// InstallNewPipeline registers a push Controller's MeterProvider globally.
func InstallNewPipeline(config Config, options ...controller.Option) (*controller.Controller, error) {
pusher, err := NewExportPipeline(config, options...)
cont, err := NewExportPipeline(config, options...)
if err != nil {
return nil, err
}
global.SetMeterProvider(pusher.MeterProvider())
return pusher, nil
global.SetMeterProvider(cont)
return cont, nil
}

// ConvertToTimeSeries converts a CheckpointSet to a slice of TimeSeries pointers
// ConvertToTimeSeries converts a InstrumentationLibraryReader to a slice of TimeSeries pointers
// Based on the aggregation type, ConvertToTimeSeries will call helper functions like
// convertFromSum to generate the correct number of TimeSeries.
func (e *Exporter) ConvertToTimeSeries(res *resource.Resource, checkpointSet export.CheckpointSet) ([]*prompb.TimeSeries, error) {
func (e *Exporter) ConvertToTimeSeries(res *resource.Resource, checkpointSet export.InstrumentationLibraryReader) ([]*prompb.TimeSeries, error) {
var aggError error
var timeSeries []*prompb.TimeSeries

// Iterate over each record in the checkpoint set and convert to TimeSeries
aggError = checkpointSet.ForEach(e, func(record metric.Record) error {
// Convert based on aggregation type
edata := exportData{
Resource: res,
Record: record,
}
agg := record.Aggregation()

// The following section uses loose type checking to determine how to
// convert aggregations to timeseries. More "expensive" timeseries are
// checked first.
//
// See the Aggregator Kind for more information
// https://github.com/open-telemetry/opentelemetry-go/blob/main/sdk/export/metric/aggregation/aggregation.go#L123-L138
if histogram, ok := agg.(aggregation.Histogram); ok {
tSeries, err := convertFromHistogram(edata, histogram)
if err != nil {
return err
}
timeSeries = append(timeSeries, tSeries...)
} else if sum, ok := agg.(aggregation.Sum); ok {
tSeries, err := convertFromSum(edata, sum)
if err != nil {
return err
aggError = checkpointSet.ForEach(func(library instrumentation.Library, reader export.Reader) error {
return reader.ForEach(e, func(record metric.Record) error {
// Convert based on aggregation type
edata := exportData{
Resource: res,
Record: record,
}
timeSeries = append(timeSeries, tSeries)
if minMaxSumCount, ok := agg.(aggregation.MinMaxSumCount); ok {
tSeries, err := convertFromMinMaxSumCount(edata, minMaxSumCount)
agg := record.Aggregation()

// The following section uses loose type checking to determine how to
// convert aggregations to timeseries. More "expensive" timeseries are
// checked first.
//
// See the Aggregator Kind for more information
// https://github.com/open-telemetry/opentelemetry-go/blob/main/sdk/export/metric/aggregation/aggregation.go#L123-L138
if histogram, ok := agg.(aggregation.Histogram); ok {
tSeries, err := convertFromHistogram(edata, histogram)
if err != nil {
return err
}
timeSeries = append(timeSeries, tSeries...)
} else if sum, ok := agg.(aggregation.Sum); ok {
tSeries, err := convertFromSum(edata, sum)
if err != nil {
return err
}
timeSeries = append(timeSeries, tSeries)
if minMaxSumCount, ok := agg.(aggregation.MinMaxSumCount); ok {
tSeries, err := convertFromMinMaxSumCount(edata, minMaxSumCount)
if err != nil {
return err
}
timeSeries = append(timeSeries, tSeries...)
}
} else if lastValue, ok := agg.(aggregation.LastValue); ok {
tSeries, err := convertFromLastValue(edata, lastValue)
if err != nil {
return err
}
timeSeries = append(timeSeries, tSeries)
} else {
// Report to the user when no conversion was found
fmt.Printf("No conversion found for record: %s\n", edata.Descriptor().Name())
}
} else if lastValue, ok := agg.(aggregation.LastValue); ok {
tSeries, err := convertFromLastValue(edata, lastValue)
if err != nil {
return err
}
timeSeries = append(timeSeries, tSeries)
} else {
// Report to the user when no conversion was found
fmt.Printf("No conversion found for record: %s\n", edata.Descriptor().Name())
}

return nil
return nil
})
})

// Check if error was returned in checkpointSet.ForEach()
Expand Down
Loading

0 comments on commit 1412a89

Please sign in to comment.