diff --git a/.chloggen/codeboten_add-mdatagen-meter-method-2.yaml b/.chloggen/codeboten_add-mdatagen-meter-method-2.yaml new file mode 100755 index 000000000000..f2d91a9d905b --- /dev/null +++ b/.chloggen/codeboten_add-mdatagen-meter-method-2.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: mdatagen + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: add Meter/Tracer methods to simplify instrumenting components + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [29927] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [] diff --git a/.chloggen/codeboten_rm-census-servicegraph.yaml b/.chloggen/codeboten_rm-census-servicegraph.yaml new file mode 100755 index 000000000000..bfdd7a64540f --- /dev/null +++ b/.chloggen/codeboten_rm-census-servicegraph.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: servicegraphprocessor + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: update own telemetry to use otel + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [29917] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [] diff --git a/.chloggen/elasticsearchexporter_add_missing_trace_status_description_in_span.yaml b/.chloggen/elasticsearchexporter_add_missing_trace_status_description_in_span.yaml new file mode 100644 index 000000000000..215f4fe29f10 --- /dev/null +++ b/.chloggen/elasticsearchexporter_add_missing_trace_status_description_in_span.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: elasticsearchexporter + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: "add missing trace status description in span" + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [27645] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [user] \ No newline at end of file diff --git a/.chloggen/fix_panic_supervisor.yaml b/.chloggen/fix_panic_supervisor.yaml new file mode 100755 index 000000000000..e6bb9266b6bf --- /dev/null +++ b/.chloggen/fix_panic_supervisor.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: bug_fix + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: opampsupervisor + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Fix panic on agent shutdown + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [29955] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [] diff --git a/.chloggen/honeycombmarker-set-the-User-Agent-header-in-the-outgoing-HTTP-requests.yaml b/.chloggen/honeycombmarker-set-the-User-Agent-header-in-the-outgoing-HTTP-requests.yaml new file mode 100755 index 000000000000..2f5674328249 --- /dev/null +++ b/.chloggen/honeycombmarker-set-the-User-Agent-header-in-the-outgoing-HTTP-requests.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: exporter/honeycombmarker + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: set the User-Agent header in the outgoing HTTP requests + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [29894] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [] diff --git a/.chloggen/ottl-hide-consts.yaml b/.chloggen/ottl-hide-consts.yaml new file mode 100755 index 000000000000..533d916be3f3 --- /dev/null +++ b/.chloggen/ottl-hide-consts.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: breaking + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: pkg/ottl + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Unexport `ADD`, `SUB`, `MULT`, `DIV`, `EQ`, `NE`, `LT`, `LTE`, `GT`, and `GTE` + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [29925] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [api] diff --git a/.chloggen/ottl-update-to-use-new-paths.yaml b/.chloggen/ottl-update-to-use-new-paths.yaml new file mode 100755 index 000000000000..bb8281e50210 --- /dev/null +++ b/.chloggen/ottl-update-to-use-new-paths.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: breaking + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: pkg/ottl + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Change `Path` to be an Interface instead of the grammar struct. + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [29897] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: Affects creators of custom contexts. + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [api] diff --git a/.chloggen/ottl-valid-path-used.yaml b/.chloggen/ottl-valid-path-used.yaml new file mode 100755 index 000000000000..b7cb63d491dc --- /dev/null +++ b/.chloggen/ottl-valid-path-used.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: breaking + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: pkg/ottl + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Now validates against extraneous path segments that a context does not know how to use. + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [30042] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [] diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index ba2ed93f8831..2effce78592e 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -68,6 +68,7 @@ jobs: with: name: collector-binary path: bin/ + - run: chmod +x bin/* - name: Build Docker Image run: | make docker-otelcontribcol diff --git a/cmd/configschema/go.mod b/cmd/configschema/go.mod index 8e60bf05f15b..21d0904a990f 100644 --- a/cmd/configschema/go.mod +++ b/cmd/configschema/go.mod @@ -258,7 +258,7 @@ require ( github.com/apache/thrift v0.19.0 // indirect github.com/ardielle/ardielle-go v1.5.2 // indirect github.com/armon/go-metrics v0.4.1 // indirect - github.com/aws/aws-sdk-go v1.49.1 // indirect + github.com/aws/aws-sdk-go v1.49.5 // indirect github.com/aws/aws-sdk-go-v2 v1.24.0 // indirect github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.5.4 // indirect github.com/aws/aws-sdk-go-v2/config v1.26.1 // indirect @@ -676,8 +676,8 @@ require ( go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect - golang.org/x/crypto v0.16.0 // indirect - golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect + golang.org/x/crypto v0.17.0 // indirect + golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/oauth2 v0.15.0 // indirect golang.org/x/sync v0.5.0 // indirect @@ -1155,3 +1155,11 @@ replace ( github.com/open-telemetry/opentelemetry-collector-contrib/connector/servicegraphconnector => ../../connector/servicegraphconnector github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector => ../../connector/spanmetricsconnector ) + +replace github.com/open-telemetry/opentelemetry-collector-contrib/testbed/mockdatasenders/mockdatadogagentexporter => ../../testbed/mockdatasenders/mockdatadogagentexporter + +replace github.com/open-telemetry/opentelemetry-collector-contrib/testbed/mockdatareceivers/mockawsxrayreceiver => ../../testbed/mockdatareceivers/mockawsxrayreceiver + +replace github.com/open-telemetry/opentelemetry-collector-contrib/testbed => ../../testbed + +replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/syslogexporter => ../../exporter/syslogexporter diff --git a/cmd/configschema/go.sum b/cmd/configschema/go.sum index 69c499d99fc4..696ced8ac9a1 100644 --- a/cmd/configschema/go.sum +++ b/cmd/configschema/go.sum @@ -319,8 +319,8 @@ github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN github.com/aws/aws-sdk-go v1.32.6/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go v1.38.35/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/aws/aws-sdk-go v1.44.263/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go v1.49.1 h1:Dsamcd8d/nNb3A+bZ0ucfGl0vGZsW5wlRW0vhoYGoeQ= -github.com/aws/aws-sdk-go v1.49.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.5 h1:y2yfBlwjPDi3/sBVKeznYEdDy6wIhjA2L5NCBMLUIYA= +github.com/aws/aws-sdk-go v1.49.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/aws/aws-sdk-go-v2 v1.17.7/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2 v1.18.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= @@ -1765,8 +1765,8 @@ golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1777,8 +1777,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= diff --git a/cmd/mdatagen/go.mod b/cmd/mdatagen/go.mod index 5d4958cbfdbb..6c9ec4e77d1f 100644 --- a/cmd/mdatagen/go.mod +++ b/cmd/mdatagen/go.mod @@ -10,6 +10,8 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 golang.org/x/text v0.14.0 @@ -34,8 +36,6 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect diff --git a/cmd/mdatagen/internal/metadata/generated_status.go b/cmd/mdatagen/internal/metadata/generated_status.go index e9ab937c5055..5fbfbc838263 100644 --- a/cmd/mdatagen/internal/metadata/generated_status.go +++ b/cmd/mdatagen/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( LogsStability = component.StabilityLevelDevelopment MetricsStability = component.StabilityLevelStable ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol") +} diff --git a/cmd/mdatagen/loader.go b/cmd/mdatagen/loader.go index 859b42cdbf36..701c008138be 100644 --- a/cmd/mdatagen/loader.go +++ b/cmd/mdatagen/loader.go @@ -267,22 +267,21 @@ func loadMetadata(filePath string) (metadata, error) { return md, nil } +var componentTypes = map[string]func(string) string{ + "connector": func(in string) string { return strings.TrimSuffix(in, "connector") }, + "exporter": func(in string) string { return strings.TrimSuffix(in, "exporter") }, + "extension": func(in string) string { return strings.TrimSuffix(in, "extension") }, + "processor": func(in string) string { return strings.TrimSuffix(in, "processor") }, + "scraper": func(in string) string { return strings.TrimSuffix(in, "scraper") }, + "receiver": func(in string) string { return in }, +} + func shortFolderName(filePath string) string { parentFolder := filepath.Base(filepath.Dir(filePath)) - if strings.HasSuffix(parentFolder, "connector") { - return strings.TrimSuffix(parentFolder, "connector") - } - if strings.HasSuffix(parentFolder, "exporter") { - return strings.TrimSuffix(parentFolder, "exporter") - } - if strings.HasSuffix(parentFolder, "extension") { - return strings.TrimSuffix(parentFolder, "extension") - } - if strings.HasSuffix(parentFolder, "processor") { - return strings.TrimSuffix(parentFolder, "processor") - } - if strings.HasSuffix(parentFolder, "receiver") { - return strings.TrimSuffix(parentFolder, "receiver") + for cType := range componentTypes { + if strings.HasSuffix(parentFolder, cType) { + return strings.TrimSuffix(parentFolder, cType) + } } return parentFolder } @@ -291,11 +290,18 @@ func scopeName(filePath string) string { sn := "otelcol" dirs := strings.Split(filepath.Dir(filePath), string(os.PathSeparator)) for _, dir := range dirs { - if dir != "receiver" && strings.HasSuffix(dir, "receiver") { - sn += "/" + dir + // skip directory names for component types + if _, ok := componentTypes[dir]; ok { + continue } - if dir != "scraper" && strings.HasSuffix(dir, "scraper") { - sn += "/" + strings.TrimSuffix(dir, "scraper") + // note here that the only component that receives a different + // treatment is receivers. this is to prevent breaking backwards + // compatibility for anyone that's using the generated metrics w/ + // scope names today. + for cType, normalizeFunc := range componentTypes { + if strings.HasSuffix(dir, cType) { + sn += "/" + normalizeFunc(dir) + } } } return sn diff --git a/cmd/mdatagen/main_test.go b/cmd/mdatagen/main_test.go index 821894d96dc3..2348aa8de804 100644 --- a/cmd/mdatagen/main_test.go +++ b/cmd/mdatagen/main_test.go @@ -324,12 +324,22 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "foo" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("") +} `, }, { @@ -348,12 +358,22 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "foo" MetricsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("") +} `, }, } diff --git a/cmd/mdatagen/templates/status.go.tmpl b/cmd/mdatagen/templates/status.go.tmpl index b9384570b8e6..654e6b1518a3 100644 --- a/cmd/mdatagen/templates/status.go.tmpl +++ b/cmd/mdatagen/templates/status.go.tmpl @@ -2,11 +2,11 @@ package {{ .Package }} -{{- if .Status.Stability }} import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) -{{- end }} const ( Type = "{{ .Type }}" @@ -15,4 +15,12 @@ const ( {{ toCamelCase $signal }}Stability = component.StabilityLevel{{ casesTitle $stability }} {{- end }} {{- end }} -) \ No newline at end of file +) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("{{ .ScopeName }}") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("{{ .ScopeName }}") +} \ No newline at end of file diff --git a/cmd/opampsupervisor/supervisor/commander/commander.go b/cmd/opampsupervisor/supervisor/commander/commander.go index 23ef147343b6..90901e0e7103 100644 --- a/cmd/opampsupervisor/supervisor/commander/commander.go +++ b/cmd/opampsupervisor/supervisor/commander/commander.go @@ -138,7 +138,8 @@ func (c *Commander) Stop(ctx context.Context) error { return nil } - c.logger.Debug("Stopping agent process", zap.Int("pid", c.cmd.Process.Pid)) + pid := c.cmd.Process.Pid + c.logger.Debug("Stopping agent process", zap.Int("pid", pid)) // Gracefully signal process to stop. if err := c.cmd.Process.Signal(syscall.SIGTERM); err != nil { @@ -154,14 +155,14 @@ func (c *Commander) Stop(ctx context.Context) error { <-waitCtx.Done() if !errors.Is(waitCtx.Err(), context.DeadlineExceeded) { - c.logger.Debug("Agent process successfully stopped.", zap.Int("pid", c.cmd.Process.Pid)) + c.logger.Debug("Agent process successfully stopped.", zap.Int("pid", pid)) return } // Time is out. Kill the process. c.logger.Debug( - "Agent process is not responding to SIGTERM. Sending SIGKILL to kill forcedly.", - zap.Int("pid", c.cmd.Process.Pid)) + "Agent process is not responding to SIGTERM. Sending SIGKILL to kill forcibly.", + zap.Int("pid", pid)) if innerErr = c.cmd.Process.Signal(syscall.SIGKILL); innerErr != nil { return } diff --git a/cmd/otelcontribcol/builder-config.yaml b/cmd/otelcontribcol/builder-config.yaml index a9bfa5978ebc..e6701623ea4c 100644 --- a/cmd/otelcontribcol/builder-config.yaml +++ b/cmd/otelcontribcol/builder-config.yaml @@ -432,3 +432,6 @@ replaces: - github.com/open-telemetry/opentelemetry-collector-contrib/internal/collectd => ../../internal/collectd - github.com/open-telemetry/opentelemetry-collector-contrib/extension/remotetapextension => ../../extension/remotetapextension - github.com/open-telemetry/opentelemetry-collector-contrib/extension/opampextension => ../../extension/opampextension + - github.com/open-telemetry/opentelemetry-collector-contrib/testbed/mockdatasenders/mockdatadogagentexporter => ../../testbed/mockdatasenders/mockdatadogagentexporter + - github.com/open-telemetry/opentelemetry-collector-contrib/testbed => ../../testbed + - github.com/open-telemetry/opentelemetry-collector-contrib/testbed/mockdatareceivers/mockawsxrayreceiver => ../../testbed/mockdatareceivers/mockawsxrayreceiver diff --git a/cmd/otelcontribcol/go.mod b/cmd/otelcontribcol/go.mod index 0b3929855f9b..b6bb0d972b1d 100644 --- a/cmd/otelcontribcol/go.mod +++ b/cmd/otelcontribcol/go.mod @@ -305,7 +305,7 @@ require ( github.com/apache/thrift v0.19.0 // indirect github.com/ardielle/ardielle-go v1.5.2 // indirect github.com/armon/go-metrics v0.4.1 // indirect - github.com/aws/aws-sdk-go v1.49.1 // indirect + github.com/aws/aws-sdk-go v1.49.5 // indirect github.com/aws/aws-sdk-go-v2 v1.24.0 // indirect github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.5.4 // indirect github.com/aws/aws-sdk-go-v2/config v1.26.1 // indirect @@ -684,8 +684,8 @@ require ( go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect - golang.org/x/crypto v0.16.0 // indirect - golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect + golang.org/x/crypto v0.17.0 // indirect + golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/oauth2 v0.15.0 // indirect @@ -1170,3 +1170,9 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/colle replace github.com/open-telemetry/opentelemetry-collector-contrib/extension/remotetapextension => ../../extension/remotetapextension replace github.com/open-telemetry/opentelemetry-collector-contrib/extension/opampextension => ../../extension/opampextension + +replace github.com/open-telemetry/opentelemetry-collector-contrib/testbed/mockdatasenders/mockdatadogagentexporter => ../../testbed/mockdatasenders/mockdatadogagentexporter + +replace github.com/open-telemetry/opentelemetry-collector-contrib/testbed => ../../testbed + +replace github.com/open-telemetry/opentelemetry-collector-contrib/testbed/mockdatareceivers/mockawsxrayreceiver => ../../testbed/mockdatareceivers/mockawsxrayreceiver diff --git a/cmd/otelcontribcol/go.sum b/cmd/otelcontribcol/go.sum index 8793f3c1c98d..fb1473b0cd98 100644 --- a/cmd/otelcontribcol/go.sum +++ b/cmd/otelcontribcol/go.sum @@ -318,8 +318,8 @@ github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN github.com/aws/aws-sdk-go v1.32.6/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go v1.38.35/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/aws/aws-sdk-go v1.44.263/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go v1.49.1 h1:Dsamcd8d/nNb3A+bZ0ucfGl0vGZsW5wlRW0vhoYGoeQ= -github.com/aws/aws-sdk-go v1.49.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.5 h1:y2yfBlwjPDi3/sBVKeznYEdDy6wIhjA2L5NCBMLUIYA= +github.com/aws/aws-sdk-go v1.49.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/aws/aws-sdk-go-v2 v1.17.7/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2 v1.18.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= @@ -1764,8 +1764,8 @@ golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1776,8 +1776,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= diff --git a/cmd/oteltestbedcol/go.mod b/cmd/oteltestbedcol/go.mod index 61ca58242d0b..4f699008444e 100644 --- a/cmd/oteltestbedcol/go.mod +++ b/cmd/oteltestbedcol/go.mod @@ -256,8 +256,8 @@ require ( go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect - golang.org/x/crypto v0.16.0 // indirect - golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect + golang.org/x/crypto v0.17.0 // indirect + golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/oauth2 v0.14.0 // indirect diff --git a/cmd/oteltestbedcol/go.sum b/cmd/oteltestbedcol/go.sum index 46a188c5913b..bcbace80eacc 100644 --- a/cmd/oteltestbedcol/go.sum +++ b/cmd/oteltestbedcol/go.sum @@ -766,8 +766,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -778,8 +778,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= diff --git a/confmap/provider/s3provider/go.mod b/confmap/provider/s3provider/go.mod index e89338588faa..c7760251eb4a 100644 --- a/confmap/provider/s3provider/go.mod +++ b/confmap/provider/s3provider/go.mod @@ -5,7 +5,7 @@ go 1.20 require ( github.com/aws/aws-sdk-go-v2 v1.24.0 github.com/aws/aws-sdk-go-v2/config v1.26.1 - github.com/aws/aws-sdk-go-v2/service/s3 v1.47.5 + github.com/aws/aws-sdk-go-v2/service/s3 v1.47.6 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/confmap v0.91.0 gopkg.in/yaml.v2 v2.4.0 diff --git a/confmap/provider/s3provider/go.sum b/confmap/provider/s3provider/go.sum index 858ee6c12ca0..1c4718956b87 100644 --- a/confmap/provider/s3provider/go.sum +++ b/confmap/provider/s3provider/go.sum @@ -24,8 +24,8 @@ github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.9 h1:Nf2sHxjMJ github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.9/go.mod h1:idky4TER38YIjr2cADF1/ugFMKvZV7p//pVeV5LZbF0= github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.16.9 h1:iEAeF6YC3l4FzlJPP9H3Ko1TXpdjdqWffxXjp8SY6uk= github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.16.9/go.mod h1:kjsXoK23q9Z/tLBrckZLLyvjhZoS+AGrzqzUfEClvMM= -github.com/aws/aws-sdk-go-v2/service/s3 v1.47.5 h1:Keso8lIOS+IzI2MkPZyK6G0LYcK3My2LQ+T5bxghEAY= -github.com/aws/aws-sdk-go-v2/service/s3 v1.47.5/go.mod h1:vADO6Jn+Rq4nDtfwNjhgR84qkZwiC6FqCaXdw/kYwjA= +github.com/aws/aws-sdk-go-v2/service/s3 v1.47.6 h1:bkmlzokzTJyrFNA0J+EPlsF8x4/wp+9D45HTHO/ZUiY= +github.com/aws/aws-sdk-go-v2/service/s3 v1.47.6/go.mod h1:vADO6Jn+Rq4nDtfwNjhgR84qkZwiC6FqCaXdw/kYwjA= github.com/aws/aws-sdk-go-v2/service/sso v1.18.5 h1:ldSFWz9tEHAwHNmjx2Cvy1MjP5/L9kNoR0skc6wyOOM= github.com/aws/aws-sdk-go-v2/service/sso v1.18.5/go.mod h1:CaFfXLYL376jgbP7VKC96uFcU8Rlavak0UlAwk1Dlhc= github.com/aws/aws-sdk-go-v2/service/ssooidc v1.21.5 h1:2k9KmFawS63euAkY4/ixVNsYYwrwnd5fIvgEKkfZFNM= diff --git a/connector/countconnector/go.mod b/connector/countconnector/go.mod index 86e4a914b935..e4d42f02496a 100644 --- a/connector/countconnector/go.mod +++ b/connector/countconnector/go.mod @@ -14,6 +14,8 @@ require ( go.opentelemetry.io/collector/connector v0.91.0 go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -43,10 +45,8 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect + golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/connector/countconnector/go.sum b/connector/countconnector/go.sum index d5cb537736c7..d919c1958223 100644 --- a/connector/countconnector/go.sum +++ b/connector/countconnector/go.sum @@ -90,8 +90,8 @@ go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= diff --git a/connector/countconnector/internal/metadata/generated_status.go b/connector/countconnector/internal/metadata/generated_status.go index 614bd16ddcdc..e624f25be5d4 100644 --- a/connector/countconnector/internal/metadata/generated_status.go +++ b/connector/countconnector/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsToMetricsStability = component.StabilityLevelDevelopment LogsToMetricsStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/count") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/count") +} diff --git a/connector/datadogconnector/go.mod b/connector/datadogconnector/go.mod index b7603aa5a5ad..cdeded72f62f 100644 --- a/connector/datadogconnector/go.mod +++ b/connector/datadogconnector/go.mod @@ -11,6 +11,8 @@ require ( go.opentelemetry.io/collector/connector v0.91.0 go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -74,8 +76,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/semconv v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect diff --git a/connector/datadogconnector/internal/metadata/generated_status.go b/connector/datadogconnector/internal/metadata/generated_status.go index 1e601630c741..9c9f28a16830 100644 --- a/connector/datadogconnector/internal/metadata/generated_status.go +++ b/connector/datadogconnector/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -11,3 +13,11 @@ const ( TracesToMetricsStability = component.StabilityLevelBeta TracesToTracesStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/datadog") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/datadog") +} diff --git a/connector/exceptionsconnector/go.mod b/connector/exceptionsconnector/go.mod index c0049be7127a..8df4586bf4a7 100644 --- a/connector/exceptionsconnector/go.mod +++ b/connector/exceptionsconnector/go.mod @@ -13,6 +13,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 google.golang.org/grpc v1.60.0 ) @@ -38,8 +40,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/connector/exceptionsconnector/internal/metadata/generated_status.go b/connector/exceptionsconnector/internal/metadata/generated_status.go index 70e4fef83c5c..0e7fc8ea336a 100644 --- a/connector/exceptionsconnector/internal/metadata/generated_status.go +++ b/connector/exceptionsconnector/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -11,3 +13,11 @@ const ( TracesToMetricsStability = component.StabilityLevelDevelopment TracesToLogsStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/exceptions") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/exceptions") +} diff --git a/connector/failoverconnector/go.mod b/connector/failoverconnector/go.mod index aa779afe8451..7eb1da529510 100644 --- a/connector/failoverconnector/go.mod +++ b/connector/failoverconnector/go.mod @@ -9,6 +9,8 @@ require ( go.opentelemetry.io/collector/connector v0.91.0 go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -31,8 +33,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/connector/failoverconnector/internal/metadata/generated_status.go b/connector/failoverconnector/internal/metadata/generated_status.go index 4c2a0465aa5f..c215cb121ec4 100644 --- a/connector/failoverconnector/internal/metadata/generated_status.go +++ b/connector/failoverconnector/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( TracesToTracesStability = component.StabilityLevelDevelopment LogsToLogsStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/failover") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/failover") +} diff --git a/connector/routingconnector/go.mod b/connector/routingconnector/go.mod index 77e6aab8f25b..87d9a896582b 100644 --- a/connector/routingconnector/go.mod +++ b/connector/routingconnector/go.mod @@ -10,6 +10,8 @@ require ( go.opentelemetry.io/collector/connector v0.91.0 go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -37,10 +39,8 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect + golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/connector/routingconnector/go.sum b/connector/routingconnector/go.sum index 924f3063fd2b..e74fee4a1bda 100644 --- a/connector/routingconnector/go.sum +++ b/connector/routingconnector/go.sum @@ -88,8 +88,8 @@ go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= diff --git a/connector/routingconnector/internal/metadata/generated_status.go b/connector/routingconnector/internal/metadata/generated_status.go index c118c256ee31..16465d9cc597 100644 --- a/connector/routingconnector/internal/metadata/generated_status.go +++ b/connector/routingconnector/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsToMetricsStability = component.StabilityLevelAlpha LogsToLogsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/routing") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/routing") +} diff --git a/connector/servicegraphconnector/go.mod b/connector/servicegraphconnector/go.mod index d2b7d166eeee..98ef36f12f0c 100644 --- a/connector/servicegraphconnector/go.mod +++ b/connector/servicegraphconnector/go.mod @@ -8,6 +8,8 @@ require ( go.opentelemetry.io/collector/component v0.91.0 go.opentelemetry.io/collector/connector v0.91.0 go.opentelemetry.io/collector/consumer v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 ) require ( @@ -35,8 +37,6 @@ require ( go.opentelemetry.io/collector/processor v0.91.0 // indirect go.opentelemetry.io/collector/semconv v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/net v0.19.0 // indirect @@ -55,3 +55,11 @@ retract ( ) replace github.com/open-telemetry/opentelemetry-collector-contrib/processor/servicegraphprocessor => ../../processor/servicegraphprocessor/ + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden + +replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil diff --git a/connector/servicegraphconnector/internal/metadata/generated_status.go b/connector/servicegraphconnector/internal/metadata/generated_status.go index 4c38438390fe..d2197167296b 100644 --- a/connector/servicegraphconnector/internal/metadata/generated_status.go +++ b/connector/servicegraphconnector/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "servicegraph" TracesToMetricsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/servicegraph") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/servicegraph") +} diff --git a/connector/spanmetricsconnector/go.mod b/connector/spanmetricsconnector/go.mod index 6291caf9d47b..8fdcbf4096c8 100644 --- a/connector/spanmetricsconnector/go.mod +++ b/connector/spanmetricsconnector/go.mod @@ -15,6 +15,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 google.golang.org/grpc v1.60.0 ) @@ -39,8 +41,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/connector/spanmetricsconnector/internal/metadata/generated_status.go b/connector/spanmetricsconnector/internal/metadata/generated_status.go index 19337d4e8a25..5672e2c0604f 100644 --- a/connector/spanmetricsconnector/internal/metadata/generated_status.go +++ b/connector/spanmetricsconnector/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "spanmetrics" TracesToMetricsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/spanmetrics") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/spanmetrics") +} diff --git a/exporter/alertmanagerexporter/go.mod b/exporter/alertmanagerexporter/go.mod index ebf691626642..7a87dc78551c 100644 --- a/exporter/alertmanagerexporter/go.mod +++ b/exporter/alertmanagerexporter/go.mod @@ -16,6 +16,8 @@ require ( go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -53,8 +55,6 @@ require ( go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/exporter/alertmanagerexporter/internal/metadata/generated_status.go b/exporter/alertmanagerexporter/internal/metadata/generated_status.go index a8c6c32b1f19..7e33d6317133 100644 --- a/exporter/alertmanagerexporter/internal/metadata/generated_status.go +++ b/exporter/alertmanagerexporter/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "alertmanager" TracesStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/alertmanager") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/alertmanager") +} diff --git a/exporter/alibabacloudlogserviceexporter/go.mod b/exporter/alibabacloudlogserviceexporter/go.mod index 56df6e6a41d2..bf0b7907370d 100644 --- a/exporter/alibabacloudlogserviceexporter/go.mod +++ b/exporter/alibabacloudlogserviceexporter/go.mod @@ -13,6 +13,8 @@ require ( go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -44,8 +46,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect diff --git a/exporter/alibabacloudlogserviceexporter/internal/metadata/generated_status.go b/exporter/alibabacloudlogserviceexporter/internal/metadata/generated_status.go index e4514de3aa91..b7d837dd70bc 100644 --- a/exporter/alibabacloudlogserviceexporter/internal/metadata/generated_status.go +++ b/exporter/alibabacloudlogserviceexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelUnmaintained LogsStability = component.StabilityLevelUnmaintained ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/alibabacloudlogservice") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/alibabacloudlogservice") +} diff --git a/exporter/awscloudwatchlogsexporter/go.mod b/exporter/awscloudwatchlogsexporter/go.mod index a9067162c575..16278323104d 100644 --- a/exporter/awscloudwatchlogsexporter/go.mod +++ b/exporter/awscloudwatchlogsexporter/go.mod @@ -3,7 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsclo go 1.20 require ( - github.com/aws/aws-sdk-go v1.49.1 + github.com/aws/aws-sdk-go v1.49.5 github.com/cenkalti/backoff/v4 v4.2.1 github.com/google/uuid v1.5.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil v0.91.0 @@ -14,6 +14,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -42,8 +44,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/exporter/awscloudwatchlogsexporter/go.sum b/exporter/awscloudwatchlogsexporter/go.sum index e7cf0b8c0c05..2915c4e52040 100644 --- a/exporter/awscloudwatchlogsexporter/go.sum +++ b/exporter/awscloudwatchlogsexporter/go.sum @@ -1,8 +1,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= contrib.go.opencensus.io/exporter/prometheus v0.4.2 h1:sqfsYl5GIY/L570iT+l93ehxaWJs2/OwXtiWwew3oAg= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/aws/aws-sdk-go v1.49.1 h1:Dsamcd8d/nNb3A+bZ0ucfGl0vGZsW5wlRW0vhoYGoeQ= -github.com/aws/aws-sdk-go v1.49.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.5 h1:y2yfBlwjPDi3/sBVKeznYEdDy6wIhjA2L5NCBMLUIYA= +github.com/aws/aws-sdk-go v1.49.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= diff --git a/exporter/awscloudwatchlogsexporter/internal/metadata/generated_status.go b/exporter/awscloudwatchlogsexporter/internal/metadata/generated_status.go index 85737d8480e2..7ca2f73ce53f 100644 --- a/exporter/awscloudwatchlogsexporter/internal/metadata/generated_status.go +++ b/exporter/awscloudwatchlogsexporter/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "awscloudwatchlogs" LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/awscloudwatchlogs") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/awscloudwatchlogs") +} diff --git a/exporter/awsemfexporter/go.mod b/exporter/awsemfexporter/go.mod index 955b15ec9369..3d6ac90ace77 100644 --- a/exporter/awsemfexporter/go.mod +++ b/exporter/awsemfexporter/go.mod @@ -3,7 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsemf go 1.20 require ( - github.com/aws/aws-sdk-go v1.49.1 + github.com/aws/aws-sdk-go v1.49.5 github.com/google/uuid v1.5.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil v0.91.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/cwlogs v0.91.0 @@ -18,9 +18,11 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 - golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb + golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 ) require ( @@ -47,8 +49,6 @@ require ( go.opentelemetry.io/collector/extension v0.91.0 // indirect go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/exporter/awsemfexporter/go.sum b/exporter/awsemfexporter/go.sum index 1d8874415e51..dba1433b2c68 100644 --- a/exporter/awsemfexporter/go.sum +++ b/exporter/awsemfexporter/go.sum @@ -1,8 +1,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= contrib.go.opencensus.io/exporter/prometheus v0.4.2 h1:sqfsYl5GIY/L570iT+l93ehxaWJs2/OwXtiWwew3oAg= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/aws/aws-sdk-go v1.49.1 h1:Dsamcd8d/nNb3A+bZ0ucfGl0vGZsW5wlRW0vhoYGoeQ= -github.com/aws/aws-sdk-go v1.49.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.5 h1:y2yfBlwjPDi3/sBVKeznYEdDy6wIhjA2L5NCBMLUIYA= +github.com/aws/aws-sdk-go v1.49.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= @@ -144,8 +144,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= diff --git a/exporter/awsemfexporter/internal/metadata/generated_status.go b/exporter/awsemfexporter/internal/metadata/generated_status.go index 4496ea408180..352cba3cdf7b 100644 --- a/exporter/awsemfexporter/internal/metadata/generated_status.go +++ b/exporter/awsemfexporter/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "awsemf" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/awsemf") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/awsemf") +} diff --git a/exporter/awskinesisexporter/go.mod b/exporter/awskinesisexporter/go.mod index fa6315a957e7..471d8c2bafbf 100644 --- a/exporter/awskinesisexporter/go.mod +++ b/exporter/awskinesisexporter/go.mod @@ -20,6 +20,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -59,8 +61,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/semconv v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/exporter/awskinesisexporter/internal/metadata/generated_status.go b/exporter/awskinesisexporter/internal/metadata/generated_status.go index 3f8213f8f2cf..3a15b19c63d4 100644 --- a/exporter/awskinesisexporter/internal/metadata/generated_status.go +++ b/exporter/awskinesisexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/awskinesis") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/awskinesis") +} diff --git a/exporter/awss3exporter/go.mod b/exporter/awss3exporter/go.mod index 13d224a54a8c..1a37bde11ffa 100644 --- a/exporter/awss3exporter/go.mod +++ b/exporter/awss3exporter/go.mod @@ -3,7 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awss3e go 1.20 require ( - github.com/aws/aws-sdk-go v1.49.1 + github.com/aws/aws-sdk-go v1.49.5 github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.91.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.91.0 @@ -12,6 +12,8 @@ require ( go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/otelcol v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -82,10 +84,8 @@ require ( go.opentelemetry.io/otel/exporters/prometheus v0.44.1-0.20231201153405-6027c1ae76f2 // indirect go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.44.0 // indirect go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/sdk v1.21.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/exporter/awss3exporter/go.sum b/exporter/awss3exporter/go.sum index ef72bdb49468..b7f8234f18ea 100644 --- a/exporter/awss3exporter/go.sum +++ b/exporter/awss3exporter/go.sum @@ -41,8 +41,8 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= -github.com/aws/aws-sdk-go v1.49.1 h1:Dsamcd8d/nNb3A+bZ0ucfGl0vGZsW5wlRW0vhoYGoeQ= -github.com/aws/aws-sdk-go v1.49.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.5 h1:y2yfBlwjPDi3/sBVKeznYEdDy6wIhjA2L5NCBMLUIYA= +github.com/aws/aws-sdk-go v1.49.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= diff --git a/exporter/awss3exporter/internal/metadata/generated_status.go b/exporter/awss3exporter/internal/metadata/generated_status.go index 37542f92cd7e..d2f6bc690f89 100644 --- a/exporter/awss3exporter/internal/metadata/generated_status.go +++ b/exporter/awss3exporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelAlpha LogsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/awss3") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/awss3") +} diff --git a/exporter/awsxrayexporter/go.mod b/exporter/awsxrayexporter/go.mod index e417b7fcf88d..c25a9f3082ee 100644 --- a/exporter/awsxrayexporter/go.mod +++ b/exporter/awsxrayexporter/go.mod @@ -3,7 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsxra go 1.20 require ( - github.com/aws/aws-sdk-go v1.49.1 + github.com/aws/aws-sdk-go v1.49.5 github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil v0.91.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/xray v0.91.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.91.0 @@ -15,6 +15,8 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -41,8 +43,6 @@ require ( go.opentelemetry.io/collector/extension v0.91.0 // indirect go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/exporter/awsxrayexporter/go.sum b/exporter/awsxrayexporter/go.sum index 83180fc4d9ea..379f71538af4 100644 --- a/exporter/awsxrayexporter/go.sum +++ b/exporter/awsxrayexporter/go.sum @@ -1,8 +1,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= contrib.go.opencensus.io/exporter/prometheus v0.4.2 h1:sqfsYl5GIY/L570iT+l93ehxaWJs2/OwXtiWwew3oAg= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/aws/aws-sdk-go v1.49.1 h1:Dsamcd8d/nNb3A+bZ0ucfGl0vGZsW5wlRW0vhoYGoeQ= -github.com/aws/aws-sdk-go v1.49.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.5 h1:y2yfBlwjPDi3/sBVKeznYEdDy6wIhjA2L5NCBMLUIYA= +github.com/aws/aws-sdk-go v1.49.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= diff --git a/exporter/awsxrayexporter/internal/metadata/generated_status.go b/exporter/awsxrayexporter/internal/metadata/generated_status.go index 12af796c7f9f..f60df3ca9ac5 100644 --- a/exporter/awsxrayexporter/internal/metadata/generated_status.go +++ b/exporter/awsxrayexporter/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "awsxray" TracesStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/awsxray") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/awsxray") +} diff --git a/exporter/azuredataexplorerexporter/go.mod b/exporter/azuredataexplorerexporter/go.mod index 980273d7853d..ad2bdfb392cb 100644 --- a/exporter/azuredataexplorerexporter/go.mod +++ b/exporter/azuredataexplorerexporter/go.mod @@ -13,6 +13,8 @@ require ( go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -61,10 +63,8 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.15.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/exporter/azuredataexplorerexporter/go.sum b/exporter/azuredataexplorerexporter/go.sum index cdc79ae9a9b7..ab35dcb369f6 100644 --- a/exporter/azuredataexplorerexporter/go.sum +++ b/exporter/azuredataexplorerexporter/go.sum @@ -200,8 +200,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= -golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= diff --git a/exporter/azuredataexplorerexporter/internal/metadata/generated_status.go b/exporter/azuredataexplorerexporter/internal/metadata/generated_status.go index 9e42ff39a993..22d1cf329f27 100644 --- a/exporter/azuredataexplorerexporter/internal/metadata/generated_status.go +++ b/exporter/azuredataexplorerexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/azuredataexplorer") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/azuredataexplorer") +} diff --git a/exporter/azuremonitorexporter/go.mod b/exporter/azuremonitorexporter/go.mod index 9c8c72a28d27..a6906e6f6245 100644 --- a/exporter/azuremonitorexporter/go.mod +++ b/exporter/azuremonitorexporter/go.mod @@ -13,6 +13,8 @@ require ( go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 golang.org/x/net v0.19.0 ) @@ -43,8 +45,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/exporter/azuremonitorexporter/internal/metadata/generated_status.go b/exporter/azuremonitorexporter/internal/metadata/generated_status.go index 5dd0580e914d..d8c79c8ea560 100644 --- a/exporter/azuremonitorexporter/internal/metadata/generated_status.go +++ b/exporter/azuremonitorexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/azuremonitor") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/azuremonitor") +} diff --git a/exporter/carbonexporter/exporter.go b/exporter/carbonexporter/exporter.go index a083b4fc7675..60026b6141b7 100644 --- a/exporter/carbonexporter/exporter.go +++ b/exporter/carbonexporter/exporter.go @@ -19,13 +19,13 @@ import ( ) // newCarbonExporter returns a new Carbon exporter. -func newCarbonExporter(cfg *Config, set exporter.CreateSettings) (exporter.Metrics, error) { +func newCarbonExporter(ctx context.Context, cfg *Config, set exporter.CreateSettings) (exporter.Metrics, error) { sender := carbonSender{ writer: newTCPConnPool(cfg.Endpoint, cfg.Timeout), } exp, err := exporterhelper.NewMetricsExporter( - context.TODO(), + ctx, set, cfg, sender.pushMetricsData, diff --git a/exporter/carbonexporter/exporter_test.go b/exporter/carbonexporter/exporter_test.go index 4a399272bc4d..6d1a021486b5 100644 --- a/exporter/carbonexporter/exporter_test.go +++ b/exporter/carbonexporter/exporter_test.go @@ -32,13 +32,14 @@ import ( func TestNewWithDefaultConfig(t *testing.T) { cfg := createDefaultConfig().(*Config) - got, err := newCarbonExporter(cfg, exportertest.NewNopCreateSettings()) + got, err := newCarbonExporter(context.TODO(), cfg, exportertest.NewNopCreateSettings()) assert.NotNil(t, got) assert.NoError(t, err) } func TestConsumeMetricsNoServer(t *testing.T) { exp, err := newCarbonExporter( + context.TODO(), &Config{ TCPAddr: confignet.TCPAddr{Endpoint: testutil.GetAvailableLocalAddress(t)}, TimeoutSettings: exporterhelper.TimeoutSettings{Timeout: 5 * time.Second}, @@ -58,6 +59,7 @@ func TestConsumeMetricsWithResourceToTelemetry(t *testing.T) { cs.start(t, 1) exp, err := newCarbonExporter( + context.TODO(), &Config{ TCPAddr: confignet.TCPAddr{Endpoint: addr}, TimeoutSettings: exporterhelper.TimeoutSettings{Timeout: 5 * time.Second}, @@ -122,6 +124,7 @@ func TestConsumeMetrics(t *testing.T) { cs.start(t, tt.numProducers*tt.writesPerProducer*tt.md.DataPointCount()) exp, err := newCarbonExporter( + context.TODO(), &Config{ TCPAddr: confignet.TCPAddr{Endpoint: addr}, TimeoutSettings: exporterhelper.TimeoutSettings{Timeout: 5 * time.Second}, diff --git a/exporter/carbonexporter/factory.go b/exporter/carbonexporter/factory.go index d4bdfed0e04e..62a1600e00d7 100644 --- a/exporter/carbonexporter/factory.go +++ b/exporter/carbonexporter/factory.go @@ -34,11 +34,11 @@ func createDefaultConfig() component.Config { } func createMetricsExporter( - _ context.Context, + ctx context.Context, params exporter.CreateSettings, config component.Config, ) (exporter.Metrics, error) { - exp, err := newCarbonExporter(config.(*Config), params) + exp, err := newCarbonExporter(ctx, config.(*Config), params) if err != nil { return nil, err diff --git a/exporter/carbonexporter/go.mod b/exporter/carbonexporter/go.mod index 574d549506af..df978a82c9d1 100644 --- a/exporter/carbonexporter/go.mod +++ b/exporter/carbonexporter/go.mod @@ -12,6 +12,8 @@ require ( go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 ) @@ -39,8 +41,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/exporter/carbonexporter/internal/metadata/generated_status.go b/exporter/carbonexporter/internal/metadata/generated_status.go index 6dbde87f829a..ce6617d16408 100644 --- a/exporter/carbonexporter/internal/metadata/generated_status.go +++ b/exporter/carbonexporter/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "carbon" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/carbon") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/carbon") +} diff --git a/exporter/cassandraexporter/go.mod b/exporter/cassandraexporter/go.mod index ba13ad611ecb..b199b48848ae 100644 --- a/exporter/cassandraexporter/go.mod +++ b/exporter/cassandraexporter/go.mod @@ -10,6 +10,8 @@ require ( go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -38,8 +40,6 @@ require ( go.opentelemetry.io/collector/extension v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/exporter/cassandraexporter/internal/metadata/generated_status.go b/exporter/cassandraexporter/internal/metadata/generated_status.go index 1cf5068630e7..a6831fe3a93e 100644 --- a/exporter/cassandraexporter/internal/metadata/generated_status.go +++ b/exporter/cassandraexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -11,3 +13,11 @@ const ( TracesStability = component.StabilityLevelAlpha LogsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/cassandra") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/cassandra") +} diff --git a/exporter/clickhouseexporter/go.mod b/exporter/clickhouseexporter/go.mod index 917e78dcb113..0c5a7219fd91 100644 --- a/exporter/clickhouseexporter/go.mod +++ b/exporter/clickhouseexporter/go.mod @@ -13,6 +13,8 @@ require ( go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -50,8 +52,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/exporter/clickhouseexporter/internal/metadata/generated_status.go b/exporter/clickhouseexporter/internal/metadata/generated_status.go index 4e0bd1ba6553..3f3c0c7cd032 100644 --- a/exporter/clickhouseexporter/internal/metadata/generated_status.go +++ b/exporter/clickhouseexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelAlpha LogsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/clickhouse") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/clickhouse") +} diff --git a/exporter/coralogixexporter/go.mod b/exporter/coralogixexporter/go.mod index 9a1dd4cc4f92..bf4144f6340c 100644 --- a/exporter/coralogixexporter/go.mod +++ b/exporter/coralogixexporter/go.mod @@ -14,6 +14,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 google.golang.org/grpc v1.60.0 ) @@ -53,8 +55,6 @@ require ( go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/net v0.18.0 // indirect diff --git a/exporter/coralogixexporter/internal/metadata/generated_status.go b/exporter/coralogixexporter/internal/metadata/generated_status.go index 05e13e21651b..cb2981f1b68a 100644 --- a/exporter/coralogixexporter/internal/metadata/generated_status.go +++ b/exporter/coralogixexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/coralogix") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/coralogix") +} diff --git a/exporter/datadogexporter/go.mod b/exporter/datadogexporter/go.mod index 18534db1ca46..2422d7e20172 100644 --- a/exporter/datadogexporter/go.mod +++ b/exporter/datadogexporter/go.mod @@ -15,7 +15,7 @@ require ( github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.9.0 github.com/DataDog/sketches-go v1.4.3 github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.21.0 - github.com/aws/aws-sdk-go v1.49.1 + github.com/aws/aws-sdk-go v1.49.5 github.com/cenkalti/backoff/v4 v4.2.1 github.com/open-telemetry/opentelemetry-collector-contrib/connector/datadogconnector v0.91.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/ecsutil v0.91.0 @@ -47,6 +47,8 @@ require ( go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/receiver/otlpreceiver v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 google.golang.org/protobuf v1.31.0 gopkg.in/yaml.v2 v2.4.0 @@ -249,15 +251,13 @@ require ( go.opentelemetry.io/otel/exporters/prometheus v0.44.1-0.20231201153405-6027c1ae76f2 // indirect go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.44.0 // indirect go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/sdk v1.21.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.16.0 // indirect - golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect + golang.org/x/crypto v0.17.0 // indirect + golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/oauth2 v0.14.0 // indirect diff --git a/exporter/datadogexporter/go.sum b/exporter/datadogexporter/go.sum index b17dcd5a29fe..38cf5bad763b 100644 --- a/exporter/datadogexporter/go.sum +++ b/exporter/datadogexporter/go.sum @@ -133,8 +133,8 @@ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/aws/aws-sdk-go v1.38.35/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= -github.com/aws/aws-sdk-go v1.49.1 h1:Dsamcd8d/nNb3A+bZ0ucfGl0vGZsW5wlRW0vhoYGoeQ= -github.com/aws/aws-sdk-go v1.49.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.5 h1:y2yfBlwjPDi3/sBVKeznYEdDy6wIhjA2L5NCBMLUIYA= +github.com/aws/aws-sdk-go v1.49.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -856,8 +856,8 @@ golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -868,8 +868,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= diff --git a/exporter/datadogexporter/integrationtest/go.mod b/exporter/datadogexporter/integrationtest/go.mod index 2ce01929bc68..79e89a077498 100644 --- a/exporter/datadogexporter/integrationtest/go.mod +++ b/exporter/datadogexporter/integrationtest/go.mod @@ -52,7 +52,7 @@ require ( github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.21.0 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/alecthomas/participle/v2 v2.1.1 // indirect - github.com/aws/aws-sdk-go v1.49.1 // indirect + github.com/aws/aws-sdk-go v1.49.5 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cenkalti/backoff v2.2.1+incompatible // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect @@ -180,7 +180,7 @@ require ( go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect - golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect + golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/oauth2 v0.14.0 // indirect diff --git a/exporter/datadogexporter/integrationtest/go.sum b/exporter/datadogexporter/integrationtest/go.sum index 2ce47e0a0501..6e0f358193a2 100644 --- a/exporter/datadogexporter/integrationtest/go.sum +++ b/exporter/datadogexporter/integrationtest/go.sum @@ -117,8 +117,8 @@ github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 h1:s6gZFSlWYmbqAu github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= github.com/armon/go-metrics v0.4.1 h1:hR91U9KYmb6bLBYLQjyM+3j+rcd/UhE+G78SFnF8gJA= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= -github.com/aws/aws-sdk-go v1.49.1 h1:Dsamcd8d/nNb3A+bZ0ucfGl0vGZsW5wlRW0vhoYGoeQ= -github.com/aws/aws-sdk-go v1.49.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.5 h1:y2yfBlwjPDi3/sBVKeznYEdDy6wIhjA2L5NCBMLUIYA= +github.com/aws/aws-sdk-go v1.49.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -704,7 +704,7 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -715,8 +715,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= diff --git a/exporter/datadogexporter/internal/metadata/generated_status.go b/exporter/datadogexporter/internal/metadata/generated_status.go index 0c8a1b30a60b..2b54718b6486 100644 --- a/exporter/datadogexporter/internal/metadata/generated_status.go +++ b/exporter/datadogexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( TracesStability = component.StabilityLevelBeta MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/datadog") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/datadog") +} diff --git a/exporter/datasetexporter/go.mod b/exporter/datasetexporter/go.mod index e5836b735fb0..28aa293338b2 100644 --- a/exporter/datasetexporter/go.mod +++ b/exporter/datasetexporter/go.mod @@ -19,6 +19,8 @@ require ( require ( github.com/cenkalti/backoff/v4 v4.2.1 go.opentelemetry.io/collector/config/configopaque v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 ) require ( @@ -46,8 +48,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect golang.org/x/net v0.18.0 // indirect diff --git a/exporter/datasetexporter/internal/metadata/generated_status.go b/exporter/datasetexporter/internal/metadata/generated_status.go index 8b046b1fbb8a..f1fb14c3c227 100644 --- a/exporter/datasetexporter/internal/metadata/generated_status.go +++ b/exporter/datasetexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -11,3 +13,11 @@ const ( LogsStability = component.StabilityLevelAlpha TracesStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/dataset") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/dataset") +} diff --git a/exporter/dynatraceexporter/go.mod b/exporter/dynatraceexporter/go.mod index 2115378acc83..5b3897d8e7fc 100644 --- a/exporter/dynatraceexporter/go.mod +++ b/exporter/dynatraceexporter/go.mod @@ -16,6 +16,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -54,8 +56,6 @@ require ( go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/exporter/dynatraceexporter/internal/metadata/generated_status.go b/exporter/dynatraceexporter/internal/metadata/generated_status.go index c7553b5d7b66..74b946fecc17 100644 --- a/exporter/dynatraceexporter/internal/metadata/generated_status.go +++ b/exporter/dynatraceexporter/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "dynatrace" MetricsStability = component.StabilityLevelDeprecated ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/dynatrace") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/dynatrace") +} diff --git a/exporter/elasticsearchexporter/go.mod b/exporter/elasticsearchexporter/go.mod index a6376e235f3c..1d00945eb3a7 100644 --- a/exporter/elasticsearchexporter/go.mod +++ b/exporter/elasticsearchexporter/go.mod @@ -17,6 +17,8 @@ require ( go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -45,8 +47,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/exporter/elasticsearchexporter/internal/metadata/generated_status.go b/exporter/elasticsearchexporter/internal/metadata/generated_status.go index 68d85c28d943..a583a1963043 100644 --- a/exporter/elasticsearchexporter/internal/metadata/generated_status.go +++ b/exporter/elasticsearchexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -11,3 +13,11 @@ const ( TracesStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/elasticsearch") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/elasticsearch") +} diff --git a/exporter/elasticsearchexporter/model.go b/exporter/elasticsearchexporter/model.go index 74737b7d1b32..c727de45e644 100644 --- a/exporter/elasticsearchexporter/model.go +++ b/exporter/elasticsearchexporter/model.go @@ -72,6 +72,7 @@ func (m *encodeModel) encodeSpan(resource pcommon.Resource, span ptrace.Span, sc document.AddString("Name", span.Name()) document.AddString("Kind", traceutil.SpanKindStr(span.Kind())) document.AddInt("TraceStatus", int64(span.Status().Code())) + document.AddString("TraceStatusDescription", span.Status().Message()) document.AddString("Link", spanLinksToString(span.Links())) document.AddAttributes("Attributes", span.Attributes()) document.AddAttributes("Resource", resource.Attributes()) diff --git a/exporter/elasticsearchexporter/model_test.go b/exporter/elasticsearchexporter/model_test.go index 4ee35f74e819..e76d1f39e491 100644 --- a/exporter/elasticsearchexporter/model_test.go +++ b/exporter/elasticsearchexporter/model_test.go @@ -13,7 +13,7 @@ import ( semconv "go.opentelemetry.io/collector/semconv/v1.18.0" ) -var expectedSpanBody = `{"@timestamp":"2023-04-19T03:04:05.000000006Z","Attributes.service.instance.id":"23","Duration":1000000,"EndTimestamp":"2023-04-19T03:04:06.000000006Z","Events.fooEvent.evnetMockBar":"bar","Events.fooEvent.evnetMockFoo":"foo","Events.fooEvent.time":"2023-04-19T03:04:05.000000006Z","Kind":"SPAN_KIND_CLIENT","Link":"[{\"attribute\":{},\"spanID\":\"\",\"traceID\":\"01020304050607080807060504030200\"}]","Name":"client span","Resource.cloud.platform":"aws_elastic_beanstalk","Resource.cloud.provider":"aws","Resource.deployment.environment":"BETA","Resource.service.instance.id":"23","Resource.service.name":"some-service","Resource.service.version":"env-version-1234","Scope.lib-foo":"lib-bar","Scope.name":"io.opentelemetry.rabbitmq-2.7","Scope.version":"1.30.0-alpha","SpanId":"1920212223242526","TraceId":"01020304050607080807060504030201","TraceStatus":0}` +var expectedSpanBody = `{"@timestamp":"2023-04-19T03:04:05.000000006Z","Attributes.service.instance.id":"23","Duration":1000000,"EndTimestamp":"2023-04-19T03:04:06.000000006Z","Events.fooEvent.evnetMockBar":"bar","Events.fooEvent.evnetMockFoo":"foo","Events.fooEvent.time":"2023-04-19T03:04:05.000000006Z","Kind":"SPAN_KIND_CLIENT","Link":"[{\"attribute\":{},\"spanID\":\"\",\"traceID\":\"01020304050607080807060504030200\"}]","Name":"client span","Resource.cloud.platform":"aws_elastic_beanstalk","Resource.cloud.provider":"aws","Resource.deployment.environment":"BETA","Resource.service.instance.id":"23","Resource.service.name":"some-service","Resource.service.version":"env-version-1234","Scope.lib-foo":"lib-bar","Scope.name":"io.opentelemetry.rabbitmq-2.7","Scope.version":"1.30.0-alpha","SpanId":"1920212223242526","TraceId":"01020304050607080807060504030201","TraceStatus":2,"TraceStatusDescription":"Test"}` func TestEncodeSpan(t *testing.T) { model := &encodeModel{dedup: true, dedot: false} @@ -51,6 +51,8 @@ func mockResourceSpans() ptrace.Traces { span.SetKind(ptrace.SpanKindClient) span.SetStartTimestamp(pcommon.NewTimestampFromTime(tStart)) span.SetEndTimestamp(pcommon.NewTimestampFromTime(tEnd)) + span.Status().SetCode(2) + span.Status().SetMessage("Test") span.Attributes().PutStr("service.instance.id", "23") span.Links().AppendEmpty().SetTraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 0}) diff --git a/exporter/f5cloudexporter/go.mod b/exporter/f5cloudexporter/go.mod index 99263070adbc..e875294e1da3 100644 --- a/exporter/f5cloudexporter/go.mod +++ b/exporter/f5cloudexporter/go.mod @@ -12,6 +12,8 @@ require ( go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/exporter/otlphttpexporter v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 golang.org/x/oauth2 v0.15.0 google.golang.org/api v0.154.0 ) @@ -58,11 +60,9 @@ require ( go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect - golang.org/x/crypto v0.16.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/exporter/f5cloudexporter/go.sum b/exporter/f5cloudexporter/go.sum index 47280f88599f..889a4b8a5341 100644 --- a/exporter/f5cloudexporter/go.sum +++ b/exporter/f5cloudexporter/go.sum @@ -181,8 +181,8 @@ go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= diff --git a/exporter/f5cloudexporter/internal/metadata/generated_status.go b/exporter/f5cloudexporter/internal/metadata/generated_status.go index 7b47f7437e60..79d17e465073 100644 --- a/exporter/f5cloudexporter/internal/metadata/generated_status.go +++ b/exporter/f5cloudexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/f5cloud") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/f5cloud") +} diff --git a/exporter/fileexporter/go.mod b/exporter/fileexporter/go.mod index 2c2defd9e6d4..78b75a5651dd 100644 --- a/exporter/fileexporter/go.mod +++ b/exporter/fileexporter/go.mod @@ -12,6 +12,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 gopkg.in/natefinch/lumberjack.v2 v2.2.1 ) @@ -38,8 +40,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/net v0.18.0 // indirect diff --git a/exporter/fileexporter/internal/metadata/generated_status.go b/exporter/fileexporter/internal/metadata/generated_status.go index 3ca3f1406dd1..ee908154b9df 100644 --- a/exporter/fileexporter/internal/metadata/generated_status.go +++ b/exporter/fileexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelAlpha LogsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/file") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/file") +} diff --git a/exporter/googlecloudexporter/go.mod b/exporter/googlecloudexporter/go.mod index d13b577bb665..7523a5625a00 100644 --- a/exporter/googlecloudexporter/go.mod +++ b/exporter/googlecloudexporter/go.mod @@ -9,6 +9,8 @@ require ( go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/featuregate v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 ) require ( @@ -57,13 +59,11 @@ require ( go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/collector/semconv v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/sdk v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect - golang.org/x/crypto v0.15.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/oauth2 v0.14.0 // indirect golang.org/x/sync v0.5.0 // indirect diff --git a/exporter/googlecloudexporter/go.sum b/exporter/googlecloudexporter/go.sum index db5e38ee2f37..e81ff0a4ba17 100644 --- a/exporter/googlecloudexporter/go.sum +++ b/exporter/googlecloudexporter/go.sum @@ -182,8 +182,8 @@ go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= -golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= diff --git a/exporter/googlecloudexporter/internal/metadata/generated_status.go b/exporter/googlecloudexporter/internal/metadata/generated_status.go index b4520b594593..c3d96226894c 100644 --- a/exporter/googlecloudexporter/internal/metadata/generated_status.go +++ b/exporter/googlecloudexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/googlecloud") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/googlecloud") +} diff --git a/exporter/googlecloudpubsubexporter/go.mod b/exporter/googlecloudpubsubexporter/go.mod index 4098c746c91d..c07bde2dbb93 100644 --- a/exporter/googlecloudpubsubexporter/go.mod +++ b/exporter/googlecloudpubsubexporter/go.mod @@ -11,6 +11,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 google.golang.org/api v0.154.0 google.golang.org/grpc v1.60.0 @@ -53,10 +55,8 @@ require ( go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.16.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/oauth2 v0.15.0 // indirect golang.org/x/sync v0.5.0 // indirect diff --git a/exporter/googlecloudpubsubexporter/go.sum b/exporter/googlecloudpubsubexporter/go.sum index 62edcc011fe7..69f37b7fefc3 100644 --- a/exporter/googlecloudpubsubexporter/go.sum +++ b/exporter/googlecloudpubsubexporter/go.sum @@ -166,8 +166,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= diff --git a/exporter/googlecloudpubsubexporter/internal/metadata/generated_status.go b/exporter/googlecloudpubsubexporter/internal/metadata/generated_status.go index 48d4414d0182..74600824e34b 100644 --- a/exporter/googlecloudpubsubexporter/internal/metadata/generated_status.go +++ b/exporter/googlecloudpubsubexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/googlecloudpubsub") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/googlecloudpubsub") +} diff --git a/exporter/googlemanagedprometheusexporter/go.mod b/exporter/googlemanagedprometheusexporter/go.mod index 9a4db1e64884..bf37a56619e1 100644 --- a/exporter/googlemanagedprometheusexporter/go.mod +++ b/exporter/googlemanagedprometheusexporter/go.mod @@ -9,6 +9,8 @@ require ( go.opentelemetry.io/collector/component v0.91.0 go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/otelcol v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 ) require ( @@ -98,15 +100,13 @@ require ( go.opentelemetry.io/otel/exporters/prometheus v0.44.1-0.20231201153405-6027c1ae76f2 // indirect go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.44.0 // indirect go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/sdk v1.21.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect - golang.org/x/crypto v0.15.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/oauth2 v0.14.0 // indirect golang.org/x/sync v0.5.0 // indirect diff --git a/exporter/googlemanagedprometheusexporter/go.sum b/exporter/googlemanagedprometheusexporter/go.sum index 31024cb758ef..ab3e6d30f945 100644 --- a/exporter/googlemanagedprometheusexporter/go.sum +++ b/exporter/googlemanagedprometheusexporter/go.sum @@ -418,8 +418,8 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= -golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/exporter/googlemanagedprometheusexporter/internal/metadata/generated_status.go b/exporter/googlemanagedprometheusexporter/internal/metadata/generated_status.go index fe5ab47c090a..5eb21959873f 100644 --- a/exporter/googlemanagedprometheusexporter/internal/metadata/generated_status.go +++ b/exporter/googlemanagedprometheusexporter/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "googlemanagedprometheus" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/googlemanagedprometheus") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/googlemanagedprometheus") +} diff --git a/exporter/honeycombmarkerexporter/factory.go b/exporter/honeycombmarkerexporter/factory.go index e40f3240e83e..950fbdf34f10 100644 --- a/exporter/honeycombmarkerexporter/factory.go +++ b/exporter/honeycombmarkerexporter/factory.go @@ -34,7 +34,7 @@ func createLogsExporter( ) (exporter.Logs, error) { cf := cfg.(*Config) - logsExp, err := newHoneycombLogsExporter(set.TelemetrySettings, cf) + logsExp, err := newHoneycombLogsExporter(set, cf) if err != nil { return nil, err } diff --git a/exporter/honeycombmarkerexporter/go.mod b/exporter/honeycombmarkerexporter/go.mod index ed1d3b5e5bf2..a825990f62bd 100644 --- a/exporter/honeycombmarkerexporter/go.mod +++ b/exporter/honeycombmarkerexporter/go.mod @@ -12,6 +12,8 @@ require ( go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -58,10 +60,8 @@ require ( go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect + golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/exporter/honeycombmarkerexporter/go.sum b/exporter/honeycombmarkerexporter/go.sum index 1e373d184989..fca02fc08eba 100644 --- a/exporter/honeycombmarkerexporter/go.sum +++ b/exporter/honeycombmarkerexporter/go.sum @@ -175,8 +175,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= diff --git a/exporter/honeycombmarkerexporter/internal/metadata/generated_status.go b/exporter/honeycombmarkerexporter/internal/metadata/generated_status.go index bcebacec01e5..d8c0b3122036 100644 --- a/exporter/honeycombmarkerexporter/internal/metadata/generated_status.go +++ b/exporter/honeycombmarkerexporter/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "honeycombmarker" LogsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/honeycombmarker") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/honeycombmarker") +} diff --git a/exporter/honeycombmarkerexporter/logs_exporter.go b/exporter/honeycombmarkerexporter/logs_exporter.go index 07c595acbd6e..aa65d005a5ec 100644 --- a/exporter/honeycombmarkerexporter/logs_exporter.go +++ b/exporter/honeycombmarkerexporter/logs_exporter.go @@ -10,9 +10,11 @@ import ( "fmt" "io" "net/http" + "runtime" "strings" "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/exporter" "go.opentelemetry.io/collector/pdata/plog" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter/filterottl" @@ -22,22 +24,27 @@ import ( const ( defaultDatasetSlug = "__all__" + userAgentHeaderKey = "User-Agent" + contentType = "Content-Type" + honeycombTeam = "X-Honeycomb-Team" ) type honeycombLogsExporter struct { - set component.TelemetrySettings - markers []Marker - client *http.Client - config *Config + set component.TelemetrySettings + markers []Marker + client *http.Client + config *Config + userAgentHeader string } -func newHoneycombLogsExporter(set component.TelemetrySettings, config *Config) (*honeycombLogsExporter, error) { +func newHoneycombLogsExporter(set exporter.CreateSettings, config *Config) (*honeycombLogsExporter, error) { if config == nil { return nil, fmt.Errorf("unable to create honeycombLogsExporter without config") } + telemetrySettings := set.TelemetrySettings for i, m := range config.Markers { - matchLogConditions, err := filterottl.NewBoolExprForLog(m.Rules.LogConditions, filterottl.StandardLogFuncs(), ottl.PropagateError, set) + matchLogConditions, err := filterottl.NewBoolExprForLog(m.Rules.LogConditions, filterottl.StandardLogFuncs(), ottl.PropagateError, telemetrySettings) if err != nil { return nil, fmt.Errorf("failed to parse log conditions: %w", err) } @@ -45,9 +52,10 @@ func newHoneycombLogsExporter(set component.TelemetrySettings, config *Config) ( config.Markers[i].Rules.logBoolExpr = matchLogConditions } logsExp := &honeycombLogsExporter{ - set: set, - markers: config.Markers, - config: config, + set: telemetrySettings, + markers: config.Markers, + config: config, + userAgentHeader: fmt.Sprintf("%s/%s (%s/%s)", set.BuildInfo.Description, set.BuildInfo.Version, runtime.GOOS, runtime.GOARCH), } return logsExp, nil } @@ -111,8 +119,9 @@ func (e *honeycombLogsExporter) sendMarker(ctx context.Context, marker Marker, l return err } - req.Header.Set("Content-Type", "application/json") - req.Header.Set("X-Honeycomb-Team", fmt.Sprint(e.config.APIKey)) + req.Header.Set(contentType, "application/json") + req.Header.Set(honeycombTeam, fmt.Sprint(e.config.APIKey)) + req.Header.Set(userAgentHeaderKey, e.userAgentHeader) resp, err := e.client.Do(req) if err != nil { diff --git a/exporter/honeycombmarkerexporter/logs_exporter_test.go b/exporter/honeycombmarkerexporter/logs_exporter_test.go index 4a69de22b57f..9dd716f482be 100644 --- a/exporter/honeycombmarkerexporter/logs_exporter_test.go +++ b/exporter/honeycombmarkerexporter/logs_exporter_test.go @@ -8,6 +8,7 @@ import ( "encoding/json" "net/http" "net/http/httptest" + "strings" "testing" "github.com/stretchr/testify/assert" @@ -132,9 +133,13 @@ func TestExportMarkers(t *testing.T) { } assert.Contains(t, req.URL.Path, tt.expectedURL) - apiKey := req.Header.Get("X-Honeycomb-Team") + apiKey := req.Header.Get(honeycombTeam) assert.Equal(t, apiKey, string(tt.config.APIKey)) + userAgent := req.Header.Get(userAgentHeaderKey) + assert.NotEmpty(t, userAgent) + assert.Equal(t, strings.Contains(userAgent, "OpenTelemetry Collector"), true) + rw.WriteHeader(http.StatusAccepted) })) defer markerServer.Close() diff --git a/exporter/influxdbexporter/go.mod b/exporter/influxdbexporter/go.mod index fdd807cba378..ea6269548fd8 100644 --- a/exporter/influxdbexporter/go.mod +++ b/exporter/influxdbexporter/go.mod @@ -14,8 +14,10 @@ require ( go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/exporter v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 - golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb + golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 ) require ( @@ -55,8 +57,6 @@ require ( go.opentelemetry.io/collector/semconv v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/exporter/influxdbexporter/go.sum b/exporter/influxdbexporter/go.sum index 3c406d34061a..2ee1372ff1c5 100644 --- a/exporter/influxdbexporter/go.sum +++ b/exporter/influxdbexporter/go.sum @@ -190,8 +190,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= diff --git a/exporter/influxdbexporter/internal/metadata/generated_status.go b/exporter/influxdbexporter/internal/metadata/generated_status.go index 05e0acae4912..978e4fcacc45 100644 --- a/exporter/influxdbexporter/internal/metadata/generated_status.go +++ b/exporter/influxdbexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/influxdb") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/influxdb") +} diff --git a/exporter/instanaexporter/go.mod b/exporter/instanaexporter/go.mod index 8687e8143e6b..8742731b56b7 100644 --- a/exporter/instanaexporter/go.mod +++ b/exporter/instanaexporter/go.mod @@ -14,6 +14,8 @@ require ( go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -52,8 +54,6 @@ require ( go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/exporter/instanaexporter/internal/metadata/generated_status.go b/exporter/instanaexporter/internal/metadata/generated_status.go index 35003719e88e..5d6a5bb5cfc9 100644 --- a/exporter/instanaexporter/internal/metadata/generated_status.go +++ b/exporter/instanaexporter/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "instana" TracesStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/instana") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/instana") +} diff --git a/exporter/kafkaexporter/go.mod b/exporter/kafkaexporter/go.mod index c5ec228408f7..296edfc8dd43 100644 --- a/exporter/kafkaexporter/go.mod +++ b/exporter/kafkaexporter/go.mod @@ -21,13 +21,15 @@ require ( go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) require ( github.com/apache/thrift v0.19.0 // indirect - github.com/aws/aws-sdk-go v1.49.1 // indirect + github.com/aws/aws-sdk-go v1.49.5 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/eapache/go-resiliency v1.4.0 // indirect github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect @@ -69,9 +71,7 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect - golang.org/x/crypto v0.16.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/exporter/kafkaexporter/go.sum b/exporter/kafkaexporter/go.sum index 3532ee53f7cf..8186d007e03e 100644 --- a/exporter/kafkaexporter/go.sum +++ b/exporter/kafkaexporter/go.sum @@ -5,8 +5,8 @@ github.com/IBM/sarama v1.42.1 h1:wugyWa15TDEHh2kvq2gAy1IHLjEjuYOYgXz/ruC/OSQ= github.com/IBM/sarama v1.42.1/go.mod h1:Xxho9HkHd4K/MDUo/T/sOqwtX/17D33++E9Wib6hUdQ= github.com/apache/thrift v0.19.0 h1:sOqkWPzMj7w6XaYbJQG7m4sGqVolaW/0D28Ln7yPzMk= github.com/apache/thrift v0.19.0/go.mod h1:SUALL216IiaOw2Oy+5Vs9lboJ/t9g40C+G07Dc0QC1I= -github.com/aws/aws-sdk-go v1.49.1 h1:Dsamcd8d/nNb3A+bZ0ucfGl0vGZsW5wlRW0vhoYGoeQ= -github.com/aws/aws-sdk-go v1.49.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.5 h1:y2yfBlwjPDi3/sBVKeznYEdDy6wIhjA2L5NCBMLUIYA= +github.com/aws/aws-sdk-go v1.49.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= @@ -204,8 +204,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= diff --git a/exporter/kafkaexporter/internal/metadata/generated_status.go b/exporter/kafkaexporter/internal/metadata/generated_status.go index 73c17c03bbba..25c68a3f1504 100644 --- a/exporter/kafkaexporter/internal/metadata/generated_status.go +++ b/exporter/kafkaexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/kafka") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/kafka") +} diff --git a/exporter/kineticaexporter/go.mod b/exporter/kineticaexporter/go.mod index ea806660352b..6187ee128056 100644 --- a/exporter/kineticaexporter/go.mod +++ b/exporter/kineticaexporter/go.mod @@ -9,6 +9,8 @@ require ( go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -36,8 +38,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/exporter/kineticaexporter/internal/metadata/generated_status.go b/exporter/kineticaexporter/internal/metadata/generated_status.go index 8ce647f25c4b..f6e80b70a532 100644 --- a/exporter/kineticaexporter/internal/metadata/generated_status.go +++ b/exporter/kineticaexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( TracesStability = component.StabilityLevelDevelopment LogsStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/kinetica") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/kinetica") +} diff --git a/exporter/loadbalancingexporter/go.mod b/exporter/loadbalancingexporter/go.mod index 2eb3f727ddca..f2992c3d2971 100644 --- a/exporter/loadbalancingexporter/go.mod +++ b/exporter/loadbalancingexporter/go.mod @@ -14,6 +14,8 @@ require ( go.opentelemetry.io/collector/otelcol v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 k8s.io/api v0.28.4 @@ -113,10 +115,8 @@ require ( go.opentelemetry.io/otel/exporters/prometheus v0.44.1-0.20231201153405-6027c1ae76f2 // indirect go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.44.0 // indirect go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/sdk v1.21.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/oauth2 v0.14.0 // indirect diff --git a/exporter/loadbalancingexporter/internal/metadata/generated_status.go b/exporter/loadbalancingexporter/internal/metadata/generated_status.go index 411eca7c5497..bef8141df0b6 100644 --- a/exporter/loadbalancingexporter/internal/metadata/generated_status.go +++ b/exporter/loadbalancingexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( LogsStability = component.StabilityLevelBeta MetricsStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/loadbalancing") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/loadbalancing") +} diff --git a/exporter/logicmonitorexporter/go.mod b/exporter/logicmonitorexporter/go.mod index db6d3bb5a0ee..54391cfb6989 100644 --- a/exporter/logicmonitorexporter/go.mod +++ b/exporter/logicmonitorexporter/go.mod @@ -14,6 +14,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -54,8 +56,6 @@ require ( go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/exporter/logicmonitorexporter/internal/metadata/generated_status.go b/exporter/logicmonitorexporter/internal/metadata/generated_status.go index 0ebb1cbf0f50..500274c984d5 100644 --- a/exporter/logicmonitorexporter/internal/metadata/generated_status.go +++ b/exporter/logicmonitorexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -11,3 +13,11 @@ const ( TracesStability = component.StabilityLevelAlpha LogsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/logicmonitor") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/logicmonitor") +} diff --git a/exporter/logzioexporter/go.mod b/exporter/logzioexporter/go.mod index 34865617679d..b933bfa84007 100644 --- a/exporter/logzioexporter/go.mod +++ b/exporter/logzioexporter/go.mod @@ -17,6 +17,8 @@ require ( go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 google.golang.org/protobuf v1.31.0 @@ -61,8 +63,6 @@ require ( go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/exporter/logzioexporter/internal/metadata/generated_status.go b/exporter/logzioexporter/internal/metadata/generated_status.go index ed3745023f0c..e3b8317919b2 100644 --- a/exporter/logzioexporter/internal/metadata/generated_status.go +++ b/exporter/logzioexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -11,3 +13,11 @@ const ( TracesStability = component.StabilityLevelUnmaintained LogsStability = component.StabilityLevelUnmaintained ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/logzio") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/logzio") +} diff --git a/exporter/lokiexporter/go.mod b/exporter/lokiexporter/go.mod index d10ca72ec693..f0642793a085 100644 --- a/exporter/lokiexporter/go.mod +++ b/exporter/lokiexporter/go.mod @@ -20,6 +20,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -69,8 +71,6 @@ require ( go.opentelemetry.io/collector/semconv v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/atomic v1.11.0 // indirect golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect golang.org/x/net v0.19.0 // indirect diff --git a/exporter/lokiexporter/internal/metadata/generated_status.go b/exporter/lokiexporter/internal/metadata/generated_status.go index 8ac8d582873a..9b18cf1bd294 100644 --- a/exporter/lokiexporter/internal/metadata/generated_status.go +++ b/exporter/lokiexporter/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "loki" LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/loki") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/loki") +} diff --git a/exporter/mezmoexporter/go.mod b/exporter/mezmoexporter/go.mod index cfe6e7f5dd1e..9a4d683786cf 100644 --- a/exporter/mezmoexporter/go.mod +++ b/exporter/mezmoexporter/go.mod @@ -12,6 +12,8 @@ require ( go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -51,8 +53,6 @@ require ( go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/exporter/mezmoexporter/internal/metadata/generated_status.go b/exporter/mezmoexporter/internal/metadata/generated_status.go index 0cd555eb9901..21d69fb2ea3c 100644 --- a/exporter/mezmoexporter/internal/metadata/generated_status.go +++ b/exporter/mezmoexporter/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "mezmo" LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/mezmo") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/mezmo") +} diff --git a/exporter/opencensusexporter/go.mod b/exporter/opencensusexporter/go.mod index 117e997f30fb..95fba678d68c 100644 --- a/exporter/opencensusexporter/go.mod +++ b/exporter/opencensusexporter/go.mod @@ -18,6 +18,8 @@ require ( go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 google.golang.org/grpc v1.60.0 ) @@ -62,8 +64,6 @@ require ( go.opentelemetry.io/collector/semconv v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/net v0.18.0 // indirect diff --git a/exporter/opencensusexporter/internal/metadata/generated_status.go b/exporter/opencensusexporter/internal/metadata/generated_status.go index 081df994310b..115becf76053 100644 --- a/exporter/opencensusexporter/internal/metadata/generated_status.go +++ b/exporter/opencensusexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -11,3 +13,11 @@ const ( TracesStability = component.StabilityLevelBeta MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/opencensus") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/opencensus") +} diff --git a/exporter/opensearchexporter/go.mod b/exporter/opensearchexporter/go.mod index bbdd3d98eea0..3c59560e44e7 100644 --- a/exporter/opensearchexporter/go.mod +++ b/exporter/opensearchexporter/go.mod @@ -59,8 +59,8 @@ require ( go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/exporter/opensearchexporter/internal/metadata/generated_status.go b/exporter/opensearchexporter/internal/metadata/generated_status.go index 6ae2bfa847b3..c53afddec134 100644 --- a/exporter/opensearchexporter/internal/metadata/generated_status.go +++ b/exporter/opensearchexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -11,3 +13,11 @@ const ( TracesStability = component.StabilityLevelAlpha LogsStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/opensearch") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/opensearch") +} diff --git a/exporter/prometheusexporter/go.mod b/exporter/prometheusexporter/go.mod index aab7c5e099fe..da74980b0004 100644 --- a/exporter/prometheusexporter/go.mod +++ b/exporter/prometheusexporter/go.mod @@ -21,6 +21,8 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 gopkg.in/yaml.v2 v2.4.0 ) @@ -146,11 +148,9 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.16.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect diff --git a/exporter/prometheusexporter/go.sum b/exporter/prometheusexporter/go.sum index c423fb916509..a6d8929a988e 100644 --- a/exporter/prometheusexporter/go.sum +++ b/exporter/prometheusexporter/go.sum @@ -599,8 +599,8 @@ golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3 golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/exporter/prometheusexporter/internal/metadata/generated_status.go b/exporter/prometheusexporter/internal/metadata/generated_status.go index 793e897d7681..10a5927c12fc 100644 --- a/exporter/prometheusexporter/internal/metadata/generated_status.go +++ b/exporter/prometheusexporter/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "prometheus" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/prometheus") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/prometheus") +} diff --git a/exporter/prometheusremotewriteexporter/go.mod b/exporter/prometheusremotewriteexporter/go.mod index 879689d1a033..b9f473ea80c9 100644 --- a/exporter/prometheusremotewriteexporter/go.mod +++ b/exporter/prometheusremotewriteexporter/go.mod @@ -22,6 +22,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -63,8 +65,6 @@ require ( go.opentelemetry.io/collector/semconv v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/exporter/prometheusremotewriteexporter/internal/metadata/generated_status.go b/exporter/prometheusremotewriteexporter/internal/metadata/generated_status.go index 2d3635acb0f4..c39a01b314d5 100644 --- a/exporter/prometheusremotewriteexporter/internal/metadata/generated_status.go +++ b/exporter/prometheusremotewriteexporter/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "prometheusremotewrite" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/prometheusremotewrite") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/prometheusremotewrite") +} diff --git a/exporter/pulsarexporter/go.mod b/exporter/pulsarexporter/go.mod index 40ef618bdc91..143187034ae5 100644 --- a/exporter/pulsarexporter/go.mod +++ b/exporter/pulsarexporter/go.mod @@ -17,6 +17,8 @@ require ( go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -72,10 +74,8 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/atomic v1.11.0 // indirect - golang.org/x/crypto v0.16.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/oauth2 v0.14.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/exporter/pulsarexporter/go.sum b/exporter/pulsarexporter/go.sum index 032b2f1a4b48..9f209a1505cf 100644 --- a/exporter/pulsarexporter/go.sum +++ b/exporter/pulsarexporter/go.sum @@ -475,8 +475,8 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/exporter/pulsarexporter/internal/metadata/generated_status.go b/exporter/pulsarexporter/internal/metadata/generated_status.go index ca71c889e14d..8bf9ab55567d 100644 --- a/exporter/pulsarexporter/internal/metadata/generated_status.go +++ b/exporter/pulsarexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelAlpha LogsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/pulsar") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/pulsar") +} diff --git a/exporter/sapmexporter/go.mod b/exporter/sapmexporter/go.mod index d63656150e65..1c4e616c84aa 100644 --- a/exporter/sapmexporter/go.mod +++ b/exporter/sapmexporter/go.mod @@ -17,6 +17,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -49,8 +51,6 @@ require ( go.opentelemetry.io/collector/semconv v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/exporter/sapmexporter/internal/metadata/generated_status.go b/exporter/sapmexporter/internal/metadata/generated_status.go index b623b108ae12..f71a1a39589e 100644 --- a/exporter/sapmexporter/internal/metadata/generated_status.go +++ b/exporter/sapmexporter/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "sapm" TracesStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/sapm") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/sapm") +} diff --git a/exporter/sentryexporter/go.mod b/exporter/sentryexporter/go.mod index 5fc440243800..5aeed40948f0 100644 --- a/exporter/sentryexporter/go.mod +++ b/exporter/sentryexporter/go.mod @@ -12,6 +12,8 @@ require ( go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 ) require ( @@ -38,8 +40,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/net v0.18.0 // indirect diff --git a/exporter/sentryexporter/internal/metadata/generated_status.go b/exporter/sentryexporter/internal/metadata/generated_status.go index c524afd062e5..0c9c75ed831c 100644 --- a/exporter/sentryexporter/internal/metadata/generated_status.go +++ b/exporter/sentryexporter/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "sentry" TracesStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/sentry") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/sentry") +} diff --git a/exporter/signalfxexporter/go.mod b/exporter/signalfxexporter/go.mod index a80de1dbd6d6..aac4d8ba9bda 100644 --- a/exporter/signalfxexporter/go.mod +++ b/exporter/signalfxexporter/go.mod @@ -25,6 +25,8 @@ require ( go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 golang.org/x/sys v0.15.0 @@ -73,8 +75,6 @@ require ( go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect diff --git a/exporter/signalfxexporter/internal/metadata/generated_status.go b/exporter/signalfxexporter/internal/metadata/generated_status.go index 5b483082c64c..a794bb5c1a07 100644 --- a/exporter/signalfxexporter/internal/metadata/generated_status.go +++ b/exporter/signalfxexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/signalfx") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/signalfx") +} diff --git a/exporter/skywalkingexporter/go.mod b/exporter/skywalkingexporter/go.mod index c93ba82333b3..b62cbf2e6599 100644 --- a/exporter/skywalkingexporter/go.mod +++ b/exporter/skywalkingexporter/go.mod @@ -16,6 +16,8 @@ require ( go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 google.golang.org/grpc v1.60.0 skywalking.apache.org/repo/goapi v0.0.0-20231026090926-09378dd56587 ) @@ -55,8 +57,6 @@ require ( go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/net v0.18.0 // indirect diff --git a/exporter/skywalkingexporter/internal/metadata/generated_status.go b/exporter/skywalkingexporter/internal/metadata/generated_status.go index 1f86caa24833..5d50300492f4 100644 --- a/exporter/skywalkingexporter/internal/metadata/generated_status.go +++ b/exporter/skywalkingexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -11,3 +13,11 @@ const ( MetricsStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/skywalking") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/skywalking") +} diff --git a/exporter/splunkhecexporter/go.mod b/exporter/splunkhecexporter/go.mod index 0dab22fe86f5..d023a163bf3f 100644 --- a/exporter/splunkhecexporter/go.mod +++ b/exporter/splunkhecexporter/go.mod @@ -22,6 +22,8 @@ require ( go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 gopkg.in/yaml.v3 v3.0.1 @@ -91,8 +93,6 @@ require ( go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect diff --git a/exporter/splunkhecexporter/internal/metadata/generated_status.go b/exporter/splunkhecexporter/internal/metadata/generated_status.go index d3e300fe92eb..0e76454b0b83 100644 --- a/exporter/splunkhecexporter/internal/metadata/generated_status.go +++ b/exporter/splunkhecexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/splunkhec") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/splunkhec") +} diff --git a/exporter/sumologicexporter/go.mod b/exporter/sumologicexporter/go.mod index 5e8023ecd67a..10f6d367d55e 100644 --- a/exporter/sumologicexporter/go.mod +++ b/exporter/sumologicexporter/go.mod @@ -9,6 +9,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 ) require ( @@ -48,8 +50,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/net v0.19.0 // indirect diff --git a/exporter/sumologicexporter/internal/metadata/generated_status.go b/exporter/sumologicexporter/internal/metadata/generated_status.go index c230f2f43bf5..93028fb0fa89 100644 --- a/exporter/sumologicexporter/internal/metadata/generated_status.go +++ b/exporter/sumologicexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -11,3 +13,11 @@ const ( MetricsStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/sumologic") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/sumologic") +} diff --git a/exporter/syslogexporter/go.mod b/exporter/syslogexporter/go.mod index 002f7e379095..288257e8b944 100644 --- a/exporter/syslogexporter/go.mod +++ b/exporter/syslogexporter/go.mod @@ -41,8 +41,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/exporter/syslogexporter/internal/metadata/generated_status.go b/exporter/syslogexporter/internal/metadata/generated_status.go index 7b226c8c8706..eedc10a8c608 100644 --- a/exporter/syslogexporter/internal/metadata/generated_status.go +++ b/exporter/syslogexporter/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "syslog" LogsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/syslog") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/syslog") +} diff --git a/exporter/tanzuobservabilityexporter/go.mod b/exporter/tanzuobservabilityexporter/go.mod index c08598391272..ffa2bbd8fe4b 100644 --- a/exporter/tanzuobservabilityexporter/go.mod +++ b/exporter/tanzuobservabilityexporter/go.mod @@ -15,6 +15,8 @@ require ( go.opentelemetry.io/collector/otelcol v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -96,10 +98,8 @@ require ( go.opentelemetry.io/otel/exporters/prometheus v0.44.1-0.20231201153405-6027c1ae76f2 // indirect go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.44.0 // indirect go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/sdk v1.21.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/exporter/tanzuobservabilityexporter/internal/metadata/generated_status.go b/exporter/tanzuobservabilityexporter/internal/metadata/generated_status.go index a5a6b8f99230..16776d5cb790 100644 --- a/exporter/tanzuobservabilityexporter/internal/metadata/generated_status.go +++ b/exporter/tanzuobservabilityexporter/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -11,3 +13,11 @@ const ( TracesStability = component.StabilityLevelDeprecated MetricsStability = component.StabilityLevelDeprecated ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/tanzuobservability") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/tanzuobservability") +} diff --git a/exporter/tencentcloudlogserviceexporter/go.mod b/exporter/tencentcloudlogserviceexporter/go.mod index 9b0e109585b8..cd0f15fad2ca 100644 --- a/exporter/tencentcloudlogserviceexporter/go.mod +++ b/exporter/tencentcloudlogserviceexporter/go.mod @@ -13,6 +13,8 @@ require ( go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 google.golang.org/protobuf v1.31.0 ) @@ -42,8 +44,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/exporter/tencentcloudlogserviceexporter/internal/metadata/generated_status.go b/exporter/tencentcloudlogserviceexporter/internal/metadata/generated_status.go index f6b1e640367d..caf09d25481d 100644 --- a/exporter/tencentcloudlogserviceexporter/internal/metadata/generated_status.go +++ b/exporter/tencentcloudlogserviceexporter/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "tencentcloud_logservice" LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/tencentcloudlogservice") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/tencentcloudlogservice") +} diff --git a/exporter/zipkinexporter/go.mod b/exporter/zipkinexporter/go.mod index b480b21ce192..6cac2514af9e 100644 --- a/exporter/zipkinexporter/go.mod +++ b/exporter/zipkinexporter/go.mod @@ -17,6 +17,8 @@ require ( go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 ) require ( @@ -57,8 +59,6 @@ require ( go.opentelemetry.io/collector/semconv v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/net v0.19.0 // indirect diff --git a/exporter/zipkinexporter/internal/metadata/generated_status.go b/exporter/zipkinexporter/internal/metadata/generated_status.go index 7304d293cd3f..5b0e3c11bcd4 100644 --- a/exporter/zipkinexporter/internal/metadata/generated_status.go +++ b/exporter/zipkinexporter/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "zipkin" TracesStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/zipkin") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/zipkin") +} diff --git a/extension/asapauthextension/go.mod b/extension/asapauthextension/go.mod index 305e0ff6dbe7..12b9bd8098d1 100644 --- a/extension/asapauthextension/go.mod +++ b/extension/asapauthextension/go.mod @@ -11,6 +11,8 @@ require ( go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 go.opentelemetry.io/collector/extension/auth v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 google.golang.org/grpc v1.60.0 ) @@ -34,8 +36,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/pdata v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.14.0 // indirect diff --git a/extension/asapauthextension/internal/metadata/generated_status.go b/extension/asapauthextension/internal/metadata/generated_status.go index ae4abcd49b64..e08bdeb8f9c4 100644 --- a/extension/asapauthextension/internal/metadata/generated_status.go +++ b/extension/asapauthextension/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "asapclient" ExtensionStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/asapauth") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/asapauth") +} diff --git a/extension/awsproxy/go.mod b/extension/awsproxy/go.mod index 74b945bc9c4d..4aeb865caf60 100644 --- a/extension/awsproxy/go.mod +++ b/extension/awsproxy/go.mod @@ -11,11 +11,13 @@ require ( go.opentelemetry.io/collector/config/configtls v0.91.0 go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) require ( - github.com/aws/aws-sdk-go v1.49.1 // indirect + github.com/aws/aws-sdk-go v1.49.5 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect @@ -34,8 +36,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/pdata v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.14.0 // indirect diff --git a/extension/awsproxy/go.sum b/extension/awsproxy/go.sum index af99224a85e9..e72992b3df3d 100644 --- a/extension/awsproxy/go.sum +++ b/extension/awsproxy/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.49.1 h1:Dsamcd8d/nNb3A+bZ0ucfGl0vGZsW5wlRW0vhoYGoeQ= -github.com/aws/aws-sdk-go v1.49.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.5 h1:y2yfBlwjPDi3/sBVKeznYEdDy6wIhjA2L5NCBMLUIYA= +github.com/aws/aws-sdk-go v1.49.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/extension/awsproxy/internal/metadata/generated_status.go b/extension/awsproxy/internal/metadata/generated_status.go index 8c305a556020..6433c1a6ae78 100644 --- a/extension/awsproxy/internal/metadata/generated_status.go +++ b/extension/awsproxy/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "awsproxy" ExtensionStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol") +} diff --git a/extension/basicauthextension/go.mod b/extension/basicauthextension/go.mod index 9f0ab31c74ab..3a953b00c529 100644 --- a/extension/basicauthextension/go.mod +++ b/extension/basicauthextension/go.mod @@ -11,6 +11,8 @@ require ( go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 go.opentelemetry.io/collector/extension/auth v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 google.golang.org/grpc v1.60.0 ) @@ -31,11 +33,9 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/pdata v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect - golang.org/x/crypto v0.15.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/extension/basicauthextension/go.sum b/extension/basicauthextension/go.sum index 0004ea290b56..89616d36be9a 100644 --- a/extension/basicauthextension/go.sum +++ b/extension/basicauthextension/go.sum @@ -74,8 +74,8 @@ go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= -golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= diff --git a/extension/basicauthextension/internal/metadata/generated_status.go b/extension/basicauthextension/internal/metadata/generated_status.go index 5b11a88fbacf..18ba36c75092 100644 --- a/extension/basicauthextension/internal/metadata/generated_status.go +++ b/extension/basicauthextension/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "basicauth" ExtensionStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/basicauth") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/basicauth") +} diff --git a/extension/bearertokenauthextension/go.mod b/extension/bearertokenauthextension/go.mod index e1619b68a3d4..1b4f8bba6f6f 100644 --- a/extension/bearertokenauthextension/go.mod +++ b/extension/bearertokenauthextension/go.mod @@ -10,6 +10,8 @@ require ( go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 go.opentelemetry.io/collector/extension/auth v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 google.golang.org/grpc v1.60.0 ) @@ -30,8 +32,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/pdata v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.14.0 // indirect diff --git a/extension/bearertokenauthextension/internal/metadata/generated_status.go b/extension/bearertokenauthextension/internal/metadata/generated_status.go index 0017ef5c73f8..66d374e7df67 100644 --- a/extension/bearertokenauthextension/internal/metadata/generated_status.go +++ b/extension/bearertokenauthextension/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "bearertokenauth" ExtensionStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/bearertokenauth") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/bearertokenauth") +} diff --git a/extension/encoding/jaegerencodingextension/go.mod b/extension/encoding/jaegerencodingextension/go.mod index ef5282421a26..0e77240ed54b 100644 --- a/extension/encoding/jaegerencodingextension/go.mod +++ b/extension/encoding/jaegerencodingextension/go.mod @@ -10,6 +10,8 @@ require ( go.opentelemetry.io/collector/component v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 ) require ( @@ -34,8 +36,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/semconv v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/net v0.19.0 // indirect diff --git a/extension/encoding/jaegerencodingextension/internal/metadata/generated_status.go b/extension/encoding/jaegerencodingextension/internal/metadata/generated_status.go index f04bd76b80c4..37d988f4f22f 100644 --- a/extension/encoding/jaegerencodingextension/internal/metadata/generated_status.go +++ b/extension/encoding/jaegerencodingextension/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "jaeger_encoding" ExtensionStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/jaegerencoding") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/jaegerencoding") +} diff --git a/extension/encoding/otlpencodingextension/go.mod b/extension/encoding/otlpencodingextension/go.mod index 681b4ee6bb10..1e3d8d2d01ee 100644 --- a/extension/encoding/otlpencodingextension/go.mod +++ b/extension/encoding/otlpencodingextension/go.mod @@ -8,6 +8,8 @@ require ( go.opentelemetry.io/collector/component v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 ) require ( @@ -29,8 +31,6 @@ require ( go.opentelemetry.io/collector/confmap v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/net v0.18.0 // indirect diff --git a/extension/encoding/otlpencodingextension/internal/metadata/generated_status.go b/extension/encoding/otlpencodingextension/internal/metadata/generated_status.go index a0b350bda0c2..dcc396955595 100644 --- a/extension/encoding/otlpencodingextension/internal/metadata/generated_status.go +++ b/extension/encoding/otlpencodingextension/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "otlp_encoding" ExtensionStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/otlpencoding") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/otlpencoding") +} diff --git a/extension/encoding/textencodingextension/go.mod b/extension/encoding/textencodingextension/go.mod index 6e6fe3160040..15a0a7bdda38 100644 --- a/extension/encoding/textencodingextension/go.mod +++ b/extension/encoding/textencodingextension/go.mod @@ -9,6 +9,8 @@ require ( go.opentelemetry.io/collector/component v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 ) require ( @@ -30,8 +32,6 @@ require ( go.opentelemetry.io/collector/confmap v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/net v0.18.0 // indirect diff --git a/extension/encoding/textencodingextension/internal/metadata/generated_status.go b/extension/encoding/textencodingextension/internal/metadata/generated_status.go index 5b0c8d846c36..5f6d4fa6ad26 100644 --- a/extension/encoding/textencodingextension/internal/metadata/generated_status.go +++ b/extension/encoding/textencodingextension/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "text_encoding" ExtensionStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/textencoding") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/textencoding") +} diff --git a/extension/encoding/zipkinencodingextension/go.mod b/extension/encoding/zipkinencodingextension/go.mod index 83563d9ebd29..aafb79104720 100644 --- a/extension/encoding/zipkinencodingextension/go.mod +++ b/extension/encoding/zipkinencodingextension/go.mod @@ -9,6 +9,8 @@ require ( go.opentelemetry.io/collector/component v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 ) require ( @@ -35,8 +37,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/semconv v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/net v0.19.0 // indirect diff --git a/extension/encoding/zipkinencodingextension/internal/metadata/generated_status.go b/extension/encoding/zipkinencodingextension/internal/metadata/generated_status.go index 5c297f34b405..66313c4e7459 100644 --- a/extension/encoding/zipkinencodingextension/internal/metadata/generated_status.go +++ b/extension/encoding/zipkinencodingextension/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "zipkin_encoding" ExtensionStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/zipkinencoding") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/zipkinencoding") +} diff --git a/extension/headerssetterextension/go.mod b/extension/headerssetterextension/go.mod index 95685d7fdb3e..5c26206c3192 100644 --- a/extension/headerssetterextension/go.mod +++ b/extension/headerssetterextension/go.mod @@ -9,6 +9,8 @@ require ( go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 go.opentelemetry.io/collector/extension/auth v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 google.golang.org/grpc v1.60.0 ) @@ -29,8 +31,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/pdata v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/extension/headerssetterextension/internal/metadata/generated_status.go b/extension/headerssetterextension/internal/metadata/generated_status.go index 2c4aab24ea27..735e095cc297 100644 --- a/extension/headerssetterextension/internal/metadata/generated_status.go +++ b/extension/headerssetterextension/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "headers_setter" ExtensionStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/headerssetter") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/headerssetter") +} diff --git a/extension/healthcheckextension/go.mod b/extension/healthcheckextension/go.mod index 90870246b9ba..34094141b120 100644 --- a/extension/healthcheckextension/go.mod +++ b/extension/healthcheckextension/go.mod @@ -4,6 +4,7 @@ go 1.20 require ( github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.91.0 + github.com/open-telemetry/opentelemetry-collector-contrib/testbed v0.91.0 github.com/stretchr/testify v1.8.4 go.opencensus.io v0.24.0 go.opentelemetry.io/collector/component v0.91.0 @@ -11,48 +12,142 @@ require ( go.opentelemetry.io/collector/config/configtls v0.91.0 go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) require ( - github.com/davecgh/go-spew v1.1.1 // indirect + cloud.google.com/go/compute/metadata v0.2.4-0.20230617002413-005d2dfb6b68 // indirect + contrib.go.opencensus.io/exporter/prometheus v0.4.2 // indirect + github.com/apache/thrift v0.19.0 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/cenkalti/backoff/v4 v4.2.1 // indirect + github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect + github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/expr-lang/expr v1.15.7 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect + github.com/go-kit/log v0.2.1 // indirect + github.com/go-logfmt/logfmt v0.6.0 // indirect github.com/go-logr/logr v1.3.0 // indirect github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-ole/go-ole v1.2.6 // indirect + github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/golang/snappy v0.0.4 // indirect + github.com/google/uuid v1.4.0 // indirect + github.com/gorilla/mux v1.8.1 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1 // indirect github.com/hashicorp/go-version v1.6.0 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/influxdata/go-syslog/v3 v3.0.1-0.20230911200830-875f5bc594a4 // indirect + github.com/jaegertracing/jaeger v1.52.0 // indirect + github.com/jpillora/backoff v1.0.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.17.4 // indirect github.com/knadh/koanf/maps v0.1.1 // indirect github.com/knadh/koanf/providers/confmap v0.1.0 // indirect github.com/knadh/koanf/v2 v2.0.1 // indirect + github.com/leodido/ragel-machinery v0.0.0-20181214104525-299bdde78165 // indirect + github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c // indirect + github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/mostynb/go-grpc-compression v1.2.2 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opencensusexporter v0.91.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/exporter/syslogexporter v0.91.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/exporter/zipkinexporter v0.91.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.91.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/internal/sharedcomponent v0.91.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.91.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.91.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza v0.91.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/jaeger v0.91.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/opencensus v0.91.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/zipkin v0.91.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaegerreceiver v0.91.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/receiver/opencensusreceiver v0.91.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/receiver/syslogreceiver v0.91.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.91.0 // indirect + github.com/openzipkin/zipkin-go v0.4.2 // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect + github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c // indirect + github.com/prometheus/client_golang v1.17.0 // indirect + github.com/prometheus/client_model v0.5.0 // indirect + github.com/prometheus/common v0.45.0 // indirect + github.com/prometheus/procfs v0.12.0 // indirect + github.com/prometheus/statsd_exporter v0.22.7 // indirect github.com/rs/cors v1.10.1 // indirect + github.com/shirou/gopsutil/v3 v3.23.11 // indirect + github.com/shoenig/go-m1cpu v0.1.6 // indirect + github.com/soheilhy/cmux v0.1.5 // indirect + github.com/spf13/cobra v1.8.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/tklauser/go-sysconf v0.3.12 // indirect + github.com/tklauser/numcpus v0.6.1 // indirect + github.com/yusufpapurcu/wmi v1.2.3 // indirect go.opentelemetry.io/collector v0.91.0 // indirect go.opentelemetry.io/collector/config/configauth v0.91.0 // indirect go.opentelemetry.io/collector/config/configcompression v0.91.0 // indirect + go.opentelemetry.io/collector/config/configgrpc v0.91.0 // indirect + go.opentelemetry.io/collector/config/confignet v0.91.0 // indirect go.opentelemetry.io/collector/config/configopaque v0.91.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/config/internal v0.91.0 // indirect + go.opentelemetry.io/collector/connector v0.91.0 // indirect + go.opentelemetry.io/collector/consumer v0.91.0 // indirect + go.opentelemetry.io/collector/exporter v0.91.0 // indirect + go.opentelemetry.io/collector/exporter/loggingexporter v0.91.0 // indirect + go.opentelemetry.io/collector/exporter/otlpexporter v0.91.0 // indirect + go.opentelemetry.io/collector/exporter/otlphttpexporter v0.91.0 // indirect go.opentelemetry.io/collector/extension/auth v0.91.0 // indirect + go.opentelemetry.io/collector/extension/ballastextension v0.91.0 // indirect + go.opentelemetry.io/collector/extension/zpagesextension v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect + go.opentelemetry.io/collector/otelcol v0.91.0 // indirect go.opentelemetry.io/collector/pdata v1.0.0 // indirect + go.opentelemetry.io/collector/processor v0.91.0 // indirect + go.opentelemetry.io/collector/processor/batchprocessor v0.91.0 // indirect + go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.91.0 // indirect + go.opentelemetry.io/collector/receiver v0.91.0 // indirect + go.opentelemetry.io/collector/receiver/otlpreceiver v0.91.0 // indirect + go.opentelemetry.io/collector/semconv v0.91.0 // indirect + go.opentelemetry.io/collector/service v0.91.0 // indirect + go.opentelemetry.io/contrib/config v0.1.1 // indirect + go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect + go.opentelemetry.io/contrib/propagators/b3 v1.21.1 // indirect + go.opentelemetry.io/contrib/zpages v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect + go.opentelemetry.io/otel/bridge/opencensus v0.44.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.44.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v0.44.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0 // indirect + go.opentelemetry.io/otel/exporters/prometheus v0.44.1-0.20231201153405-6027c1ae76f2 // indirect + go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.44.0 // indirect + go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 // indirect + go.opentelemetry.io/otel/sdk v1.21.0 // indirect + go.opentelemetry.io/otel/sdk/metric v1.21.0 // indirect + go.opentelemetry.io/proto/otlp v1.0.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect - google.golang.org/grpc v1.59.0 // indirect + gonum.org/v1/gonum v0.14.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 // indirect + google.golang.org/grpc v1.60.0 // indirect google.golang.org/protobuf v1.31.0 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) @@ -63,3 +158,81 @@ retract ( v0.76.1 v0.65.0 ) + +replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/carbonreceiver => ../../receiver/carbonreceiver + +replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/sapmexporter => ../../exporter/sapmexporter + +replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/opencensusreceiver => ../../receiver/opencensusreceiver + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourcetotelemetry => ../../pkg/resourcetotelemetry + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/experimentalmetricmetadata => ../../pkg/experimentalmetricmetadata + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus => ../../pkg/translator/prometheus + +replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/splunkhecreceiver => ../../receiver/splunkhecreceiver + +replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/splunkhecexporter => ../../exporter/splunkhecexporter + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/opencensus => ../../pkg/translator/opencensus + +replace github.com/open-telemetry/opentelemetry-collector-contrib/testbed => ../../testbed + +replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusexporter => ../../exporter/prometheusexporter + +replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opencensusexporter => ../../exporter/opencensusexporter + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/signalfx => ../../pkg/translator/signalfx + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/batchperresourceattr => ../../pkg/batchperresourceattr + +replace github.com/open-telemetry/opentelemetry-collector-contrib/testbed/mockdatasenders/mockdatadogagentexporter => ../../testbed/mockdatasenders/mockdatadogagentexporter + +replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/signalfxreceiver => ../../receiver/signalfxreceiver + +replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/syslogreceiver => ../../receiver/syslogreceiver + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza => ../../pkg/stanza + +replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/sharedcomponent => ../../internal/sharedcomponent + +replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/splunk => ../../internal/splunk + +replace github.com/open-telemetry/opentelemetry-collector-contrib/extension/storage => ../storage + +replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal + +replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/sapmreceiver => ../../receiver/sapmreceiver + +replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter => ../../exporter/signalfxexporter + +replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver => ../../receiver/zipkinreceiver + +replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaegerreceiver => ../../receiver/jaegerreceiver + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/jaeger => ../../pkg/translator/jaeger + +replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/datadogreceiver => ../../receiver/datadogreceiver + +replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/carbonexporter => ../../exporter/carbonexporter + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheusremotewrite => ../../pkg/translator/prometheusremotewrite + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil + +replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/syslogexporter => ../../exporter/syslogexporter + +replace github.com/open-telemetry/opentelemetry-collector-contrib/testbed/mockdatareceivers/mockawsxrayreceiver => ../../testbed/mockdatareceivers/mockawsxrayreceiver + +replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/zipkinexporter => ../../exporter/zipkinexporter + +replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver => ../../receiver/prometheusreceiver + +replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusremotewriteexporter => ../../exporter/prometheusremotewriteexporter + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/zipkin => ../../pkg/translator/zipkin + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden diff --git a/extension/healthcheckextension/go.sum b/extension/healthcheckextension/go.sum index 198819526f8e..3010acb285a8 100644 --- a/extension/healthcheckextension/go.sum +++ b/extension/healthcheckextension/go.sum @@ -1,56 +1,213 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= +cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= +cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= +cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= +cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= +cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= +cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= +cloud.google.com/go v0.65.0 h1:Dg9iHVQfrhq82rUNu9ZxUDrJLaxFUe/HlCVaLyRruq8= +cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= +cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= +cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= +cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= +cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= +cloud.google.com/go/compute v1.23.3 h1:6sVlXXBmbd7jNX0Ipq0trII3e4n1/MsADLK6a+aiVlk= +cloud.google.com/go/compute/metadata v0.2.4-0.20230617002413-005d2dfb6b68 h1:aRVqY1p2IJaBGStWMsQMpkAa83cPkCDLl80eOj0Rbz4= +cloud.google.com/go/compute/metadata v0.2.4-0.20230617002413-005d2dfb6b68/go.mod h1:1a3eRNYX12fs5UABBIXS8HXVvQbX9hRB/RkEBPORpe8= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= +cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= +cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= +cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= +cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= +cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= +cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= +cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +contrib.go.opencensus.io/exporter/prometheus v0.4.2 h1:sqfsYl5GIY/L570iT+l93ehxaWJs2/OwXtiWwew3oAg= +contrib.go.opencensus.io/exporter/prometheus v0.4.2/go.mod h1:dvEHbiKmgvbr5pjaF9fpw1KeYcjrnC1J8B+JKjsZyRQ= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/HdrHistogram/hdrhistogram-go v1.1.2 h1:5IcZpTvzydCQeHzK4Ef/D5rrSqwxob0t8PQPMybUNFM= +github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= +github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= +github.com/apache/thrift v0.19.0 h1:sOqkWPzMj7w6XaYbJQG7m4sGqVolaW/0D28Ln7yPzMk= +github.com/apache/thrift v0.19.0/go.mod h1:SUALL216IiaOw2Oy+5Vs9lboJ/t9g40C+G07Dc0QC1I= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= +github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/census-instrumentation/opencensus-proto v0.4.1 h1:iKLQ0xPNFxR/2hzXZMrBo8f1j86j5WHzznCCQxV/b8g= +github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4 h1:/inchEIKaYC1Akx+H+gqO04wryn5h75LSazbRlnya1k= +github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/envoyproxy/protoc-gen-validate v1.0.2 h1:QkIBuU5k+x7/QXPvPPnWXWlCdaBFApVqftFV6k087DA= +github.com/expr-lang/expr v1.15.7 h1:BK0JcWUkoW6nrbLBo6xCKhz4BvH5DSOOu1Gx5lucyZo= +github.com/expr-lang/expr v1.15.7/go.mod h1:uCkhfG+x7fcZ5A5sXHKuQ07jGZRl6J0FCAaf2k4PtVQ= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.13.0 h1:OoneCcHKHQ03LfBpoQCUfCluwd2Vt3ohz+kvbJneZAU= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= +github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= +github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= +github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= +github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0= +github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6xDCrzib4= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= +github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= +github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= +github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= +github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1 h1:6UKoz5ujsI55KNpsJH3UwCq3T8kKbZwNZBNPuTTje8U= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1/go.mod h1:YvJ2f6MplWDhfxiUC3KpyTy76kYUZA4W3pTv/wdKQ9Y= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= +github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/influxdata/go-syslog/v3 v3.0.1-0.20230911200830-875f5bc594a4 h1:2r2WiFeAwiJ/uyx1qIKnV1L4C9w/2V8ehlbJY4gjFaM= +github.com/influxdata/go-syslog/v3 v3.0.1-0.20230911200830-875f5bc594a4/go.mod h1:1yEQhaLb/cETXCqQmdh7lDjupNAReO7c83AHyK2dJ48= +github.com/jaegertracing/jaeger v1.52.0 h1:cNrp6WlcNbOY3zUdhG3Le4BOUUYSqekkMj12qHhVUB4= +github.com/jaegertracing/jaeger v1.52.0/go.mod h1:jLC2AtimHE86nJYzOOd9Qxg8PULaE1OblN+DVr9Z+Gc= +github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4= @@ -61,32 +218,144 @@ github.com/knadh/koanf/providers/confmap v0.1.0 h1:gOkxhHkemwG4LezxxN8DMOFopOPgh github.com/knadh/koanf/providers/confmap v0.1.0/go.mod h1:2uLhxQzJnyHKfxG927awZC7+fyHFdQkd697K4MdLnIU= github.com/knadh/koanf/v2 v2.0.1 h1:1dYGITt1I23x8cfx8ZnldtezdyaZtfAuRtIFOiRzK7g= github.com/knadh/koanf/v2 v2.0.1/go.mod h1:ZeiIlIDXTE7w1lMT6UVcNiRAS2/rCeLn/GdLNvY1Dus= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/leodido/ragel-machinery v0.0.0-20181214104525-299bdde78165 h1:bCiVCRCs1Heq84lurVinUPy19keqGEe4jh5vtK37jcg= +github.com/leodido/ragel-machinery v0.0.0-20181214104525-299bdde78165/go.mod h1:WZxr2/6a/Ar9bMDc2rN/LJrE/hF6bXE4LPyDSIxwAfg= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= +github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c h1:VtwQ41oftZwlMnOEbMWQtSEUgU64U4s+GHk7hZK+jtY= +github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c/go.mod h1:JKx41uQRwqlTZabZc+kILPrO/3jlKnQ2Z8b7YiVw5cE= +github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg= +github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4 h1:BpfhmLKZf+SjVanKKhCgf3bg+511DmU9eDQTen7LLbY= github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/mostynb/go-grpc-compression v1.2.2 h1:XaDbnRvt2+1vgr0b/l0qh4mJAfIxE0bKXtz2Znl3GGI= +github.com/mostynb/go-grpc-compression v1.2.2/go.mod h1:GOCr2KBxXcblCuczg3YdLQlcin1/NfyDA348ckuCH6w= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/openzipkin/zipkin-go v0.4.2 h1:zjqfqHjUpPmB3c1GlCvvgsM1G4LkvqQbBDueDOCg/jA= +github.com/openzipkin/zipkin-go v0.4.2/go.mod h1:ZeVkFjuuBiSy13y8vpSDCjMi9GoI3hPpCJSBx/EYFhY= +github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= +github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c h1:NRoLoZvkBTKvR5gQLgA3e0hqjkY9u1wm+iOL45VN/qI= +github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= +github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= +github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= +github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= +github.com/prometheus/client_golang v1.13.0/go.mod h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ= +github.com/prometheus/client_golang v1.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q= +github.com/prometheus/client_golang v1.17.0/go.mod h1:VeL+gMmOAxkS2IqfCq0ZmHSL+LjWfWDUmp1mBz9JgUY= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= +github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= +github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= +github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/common v0.35.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= +github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= +github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM= +github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= +github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= +github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= +github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= +github.com/prometheus/statsd_exporter v0.22.7 h1:7Pji/i2GuhK6Lu7DHrtTkFmNBCudCPT1pX2CziuyQR0= +github.com/prometheus/statsd_exporter v0.22.7/go.mod h1:N/TevpjkIh9ccs6nuzY3jQn9dFqnUakOjnEuMPJJJnI= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rs/cors v1.10.1 h1:L0uuZVXIKlI1SShY2nhFfo44TYvDPQ1w4oFkUJNfhyo= github.com/rs/cors v1.10.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/sagikazarmark/locafero v0.3.0 h1:zT7VEGWC2DTflmccN/5T1etyKvxSxpHsjb9cJvm4SvQ= +github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= +github.com/shirou/gopsutil/v3 v3.23.11 h1:i3jP9NjCPUz7FiZKxlMnODZkdSIp2gnzfrvsu9CuWEQ= +github.com/shirou/gopsutil/v3 v3.23.11/go.mod h1:1FrWgea594Jp7qmjHUUPlJDTPgcsb9mGnXDxavtikzM= +github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= +github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= +github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= +github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js= +github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0= +github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= +github.com/spf13/afero v1.10.0 h1:EaGW2JJh15aKOejeuJ+wpFSHnbd7GE6Wvp3TsNhb6LY= +github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= +github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= +github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.17.0 h1:I5txKw7MJasPL/BrfkbA0Jyo/oELqVmux4pR/UxOMfI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stvp/go-udp-testing v0.0.0-20201019212854-469649b16807/go.mod h1:7jxmlfBCDBXRzr0eAQJ48XC1hBu1np4CS5+cHEYfwpc= +github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= +github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= +github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= +github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= +github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= +github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= +github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= +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.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= go.opentelemetry.io/collector v0.91.0 h1:C7sGUJDJ5nwm+CkWpAaVP3lNsuYpwSRbkmLncFjkmO8= @@ -97,8 +366,12 @@ go.opentelemetry.io/collector/config/configauth v0.91.0 h1:SjWKimuqlpfS3sIlFpfzd go.opentelemetry.io/collector/config/configauth v0.91.0/go.mod h1:wmmMYqv6PxwY+/h7qqvd/LP0XN/wzXoECDu6PYz2Of0= go.opentelemetry.io/collector/config/configcompression v0.91.0 h1:v+jEpFhLgfJDCUCPsSF03gjoFEvm77PofTCqHKKgXTs= go.opentelemetry.io/collector/config/configcompression v0.91.0/go.mod h1:LaavoxZsro5lL7qh1g9DMifG0qixWPEecW18Qr8bpag= +go.opentelemetry.io/collector/config/configgrpc v0.91.0 h1:+2zPmgVOhKgelluGaGwE3OMKqwi56i6OiU0+7xWTetM= +go.opentelemetry.io/collector/config/configgrpc v0.91.0/go.mod h1:iWDbg9vYaayewmbKfM2zEk4YvaOOwrs0eiUffypcZFk= go.opentelemetry.io/collector/config/confighttp v0.91.0 h1:YAOyXcDaLDnF3UqPHH4kYU8lx8BqXJ7hS3Ou8GcmqpQ= go.opentelemetry.io/collector/config/confighttp v0.91.0/go.mod h1:R6y8KSJzqDe6CE6JsYwt4CTZ2B4AlqRA+V74OJPX3vE= +go.opentelemetry.io/collector/config/confignet v0.91.0 h1:3huNXh04O3wXaN4qPhmmiefyz4dYbOlNcR/OKMByqig= +go.opentelemetry.io/collector/config/confignet v0.91.0/go.mod h1:cpO8JYWGONaViOygKVw+Hd2UoBcn2cUiyi0WWeFTwJY= go.opentelemetry.io/collector/config/configopaque v0.91.0 h1:bQgJPyARbuXAsU2p6h2YbEm1kHb1stS6hg42ekyMZmI= go.opentelemetry.io/collector/config/configopaque v0.91.0/go.mod h1:TPCHaU+QXiEV+JXbgyr6mSErTI9chwQyasDVMdJr3eY= go.opentelemetry.io/collector/config/configtelemetry v0.91.0 h1:mEwvqrYfwUJ7LwYfpcF9M8z7LHFoYaKhEPhnERD/88E= @@ -109,90 +382,373 @@ go.opentelemetry.io/collector/config/internal v0.91.0 h1:Yx17oFdXOPnY83Jfe1oiXhv go.opentelemetry.io/collector/config/internal v0.91.0/go.mod h1:42VsQ/1kP2qnvzjNi+dfNP+KyCFRADejyrJ8m2GVL3M= go.opentelemetry.io/collector/confmap v0.91.0 h1:7U2MT+u74oEzq/WWrpXSLKB7nX5jPNC4drwtQdYfwKk= go.opentelemetry.io/collector/confmap v0.91.0/go.mod h1:uxV+fZ85kG31oovL6Cl3fAMQ3RRPwUvfAbbA9WT1Yhk= +go.opentelemetry.io/collector/connector v0.91.0 h1:p2YsgBtr26guCib99ExQHtGuNmX+awgmH1Mbz23wYGU= +go.opentelemetry.io/collector/connector v0.91.0/go.mod h1:dG34jAOATtXFdqzp8IxZJsFwFLaUIkYK69WT1WQ03ZY= go.opentelemetry.io/collector/consumer v0.91.0 h1:0nU1lUe2S0b8iOmF3w3R/9Dt24n413thRTbXz/nJgrM= +go.opentelemetry.io/collector/consumer v0.91.0/go.mod h1:phTUQmr7hpYfwXyDXo4mFHVjYrlSbZE+nZYlKlbVxGs= +go.opentelemetry.io/collector/exporter v0.91.0 h1:guWcGflFjaenp3BMxAmAKjb8RQG80jQQKjuUFouS+z8= +go.opentelemetry.io/collector/exporter v0.91.0/go.mod h1:hkOBunNNWu6CaTtkRsCJ/OJ509REJZg+DDElevFIQCQ= +go.opentelemetry.io/collector/exporter/loggingexporter v0.91.0 h1:mwKepKvfGciI6n/jLBYYH4bkbAVTr9RsNfzB3x66bCQ= +go.opentelemetry.io/collector/exporter/loggingexporter v0.91.0/go.mod h1:7UTIR8N+Aw/8lT6mJWLqtbum8Yu/ZFznUq6fdNtPxxM= +go.opentelemetry.io/collector/exporter/otlpexporter v0.91.0 h1:PEVJgEZIUMQ/M2/aQ9uuEfjptW4t0bmm91LeeNpa8mc= +go.opentelemetry.io/collector/exporter/otlpexporter v0.91.0/go.mod h1:ebWRIZhk6zere5QnvUpPHjfTvbapscwI6QfCial/X0Y= +go.opentelemetry.io/collector/exporter/otlphttpexporter v0.91.0 h1:rjRSdUn4hmEtupjFjzp6z59dOgx2tH8dyYXyTSEheJY= +go.opentelemetry.io/collector/exporter/otlphttpexporter v0.91.0/go.mod h1:bETucYAkbcUjsNQSZ1ulwD7amKZWiWXAkWV1zCR2Bts= go.opentelemetry.io/collector/extension v0.91.0 h1:bkoSLgnWm4g6n+RLmyKG6Up7dr8KmJy68quonoLZnr0= go.opentelemetry.io/collector/extension v0.91.0/go.mod h1:F3r0fVTTh4sYR0GVv51Qez8lk8v77kTDPdyMOp6A2kg= go.opentelemetry.io/collector/extension/auth v0.91.0 h1:28Hv5W0GZgv2jR5IiFdJzutTs91KmXFh8DUfVTjwwmI= go.opentelemetry.io/collector/extension/auth v0.91.0/go.mod h1:diY6Sw7cOAn2qivKipZk4niBFzCCFBj7swAXiG2h9ro= +go.opentelemetry.io/collector/extension/ballastextension v0.91.0 h1:/Ihh4FXFQH3LiDcQc28I5vqRzy8FMDMifRUQ4Tr15lc= +go.opentelemetry.io/collector/extension/ballastextension v0.91.0/go.mod h1:D37HFnuhMtrCINliIoz2KzWid1wQQjEacT8CSIF3KwY= +go.opentelemetry.io/collector/extension/zpagesextension v0.91.0 h1:d787uZ6cNHN1uaJ3pIgFlcrkHVB4ML6AlXBiCQRJ9t0= +go.opentelemetry.io/collector/extension/zpagesextension v0.91.0/go.mod h1:S1T9YKuxRqCKFENC+GuEZhz0fzuUBACOrScNY13Y96w= go.opentelemetry.io/collector/featuregate v1.0.0 h1:5MGqe2v5zxaoo73BUOvUTunftX5J8RGrbFsC2Ha7N3g= go.opentelemetry.io/collector/featuregate v1.0.0/go.mod h1:xGbRuw+GbutRtVVSEy3YR2yuOlEyiUMhN2M9DJljgqY= +go.opentelemetry.io/collector/otelcol v0.91.0 h1:gq/PY/tHgkTr2fuMLp+F+NAm+03iiU+j/Eilvx38p5w= +go.opentelemetry.io/collector/otelcol v0.91.0/go.mod h1:9j8gKdZvuEgZoeUhz5f5D/fwCxx7M7Tg+6D207/KjNs= go.opentelemetry.io/collector/pdata v1.0.0 h1:ECP2jnLztewsHmL1opL8BeMtWVc7/oSlKNhfY9jP8ec= go.opentelemetry.io/collector/pdata v1.0.0/go.mod h1:TsDFgs4JLNG7t6x9D8kGswXUz4mme+MyNChHx8zSF6k= +go.opentelemetry.io/collector/processor v0.91.0 h1:Xi52gYMXTG4zYmNhsqJ8ly/9f7b0n0crMhKxVVI9HpY= +go.opentelemetry.io/collector/processor v0.91.0/go.mod h1:naTuusZNfzM5MSqoTVzkKbR1MaJ8oD8v5ginR5JreDE= +go.opentelemetry.io/collector/processor/batchprocessor v0.91.0 h1:YuPG52D7otNr4lNd8KGsIIBHvawAAaOqGoNTK9799ko= +go.opentelemetry.io/collector/processor/batchprocessor v0.91.0/go.mod h1:U2ZVSMwgr4OsaKKMfvX9OGaurG83zAPKjVdpTgmj0ok= +go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.91.0 h1:7QVCd9NzpC0DMDeX5ZNhcUOS8qO5sRM1Cj8h5na3a4Y= +go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.91.0/go.mod h1:O1hcC0DZv5ak3eWML2NphwdLl5PESVeHN6QIi5j2bwU= +go.opentelemetry.io/collector/receiver v0.91.0 h1:0TZF/0OXoJtxgm+mvOinRRXo9LgVyOsOgCQfWkNGXJA= +go.opentelemetry.io/collector/receiver v0.91.0/go.mod h1:d5qo2mpovqKoi47hrMxj5BLdLzOXM0mUHL5CKrjfWNM= +go.opentelemetry.io/collector/receiver/otlpreceiver v0.91.0 h1:1Eyc1uR8yr3heKkC4YXFoZip0JqgOXuOiN/tXvl9WUo= +go.opentelemetry.io/collector/receiver/otlpreceiver v0.91.0/go.mod h1:7am8EW0xmHLxeeGIb0xTcsoVc6+1LfNCGdc+b7OvE8k= +go.opentelemetry.io/collector/semconv v0.91.0 h1:TRd+yDDfKQl+aNtS24wmEbJp1/QE/xAFV9SB5zWGxpE= +go.opentelemetry.io/collector/semconv v0.91.0/go.mod h1:j/8THcqVxFna1FpvA2zYIsUperEtOaRaqoLYIN4doWw= +go.opentelemetry.io/collector/service v0.91.0 h1:AQS6YAiZO6V+ohcMX4upfyp/Ydi6y862yQEbFt8t+fQ= +go.opentelemetry.io/collector/service v0.91.0/go.mod h1:8Pf8mPo3YqcTNwOzXa0Ok/o+g2+d8hSCaGxRqR/c6CY= +go.opentelemetry.io/contrib/config v0.1.1 h1:lIUTrMWkfDE0GvzBLhwv6ATDB1vntrnTsRvUMkZKnfQ= +go.opentelemetry.io/contrib/config v0.1.1/go.mod h1:rDrK4+PS6Cs+WIphU/GO5Sk4TGV36lEQqk/Z1vZkaLI= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 h1:SpGay3w+nEwMpfVnbqOLH5gY52/foP8RE8UzTZ1pdSE= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1/go.mod h1:4UoMYEZOC0yN/sPGH76KPkkU7zgiEWYWL9vwmbnTJPE= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 h1:aFJWCqJMNjENlcleuuOkGAPH82y0yULBScfXcIEdS24= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1/go.mod h1:sEGXWArGqc3tVa+ekntsN65DmVbVeW+7lTKTjZF3/Fo= +go.opentelemetry.io/contrib/propagators/b3 v1.21.1 h1:WPYiUgmw3+b7b3sQ1bFBFAf0q+Di9dvNc3AtYfnT4RQ= +go.opentelemetry.io/contrib/propagators/b3 v1.21.1/go.mod h1:EmzokPoSqsYMBVK4nRnhsfm5mbn8J1eDuz/U1UaQaWg= +go.opentelemetry.io/contrib/zpages v0.46.1 h1:U8Hh84dc+vJTVgRnL+QKWtWD2iqTSKibrQ85EeQqsNg= +go.opentelemetry.io/contrib/zpages v0.46.1/go.mod h1:1Wq9YTzkhr3Jkyi/sVrasFSppVzJQcvFf2Vc2ExZd6c= go.opentelemetry.io/otel v1.21.0 h1:hzLeKBZEL7Okw2mGzZ0cc4k/A7Fta0uoPgaJCr8fsFc= go.opentelemetry.io/otel v1.21.0/go.mod h1:QZzNPQPm1zLX4gZK4cMi+71eaorMSGT3A4znnUvNNEo= +go.opentelemetry.io/otel/bridge/opencensus v0.44.0 h1:/inELPJztkn6Xx3ap9qw8i8XdeWF0B/OjGHOdRTePZ8= +go.opentelemetry.io/otel/bridge/opencensus v0.44.0/go.mod h1:dQTBJVBx1xahrXEFBV1BGPAnGuXC92LCj55fxIrtj7I= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.44.0 h1:jd0+5t/YynESZqsSyPz+7PAFdEop0dlN0+PkyHYo8oI= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.44.0/go.mod h1:U707O40ee1FpQGyhvqnzmCJm1Wh6OX6GGBVn0E6Uyyk= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v0.44.0 h1:bflGWrfYyuulcdxf14V6n9+CoQcu5SAAdHmDPAJnlps= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v0.44.0/go.mod h1:qcTO4xHAxZLaLxPd60TdE88rxtItPHgHWqOhOGRr0as= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 h1:cl5P5/GIfFh4t6xyruOgJP5QiA1pw4fYYdv6nc6CBWw= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0/go.mod h1:zgBdWWAu7oEEMC06MMKc5NLbA/1YDXV1sMpSqEeLQLg= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0 h1:tIqheXEFWAZ7O8A7m+J0aPTmpJN3YQ7qetUAdkkkKpk= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0/go.mod h1:nUeKExfxAQVbiVFn32YXpXZZHZ61Cc3s3Rn1pDBGAb0= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0 h1:digkEZCJWobwBqMwC0cwCq8/wkkRy/OowZg5OArWZrM= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0/go.mod h1:/OpE/y70qVkndM0TrxT4KBoN3RsFZP0QaofcfYrj76I= +go.opentelemetry.io/otel/exporters/prometheus v0.44.1-0.20231201153405-6027c1ae76f2 h1:TnhkxGJ5qPHAMIMI4r+HPT/BbpoHxqn4xONJrok054o= +go.opentelemetry.io/otel/exporters/prometheus v0.44.1-0.20231201153405-6027c1ae76f2/go.mod h1:ERL2uIeBtg4TxZdojHUwzZfIFlUIjZtxubT5p4h1Gjg= +go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.44.0 h1:dEZWPjVN22urgYCza3PXRUGEyCB++y1sAqm6guWFesk= +go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.44.0/go.mod h1:sTt30Evb7hJB/gEk27qLb1+l9n4Tb8HvHkR0Wx3S6CU= +go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 h1:VhlEQAPp9R1ktYfrPk5SOryw1e9LDDTZCbIPFrho0ec= +go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0/go.mod h1:kB3ufRbfU+CQ4MlUcqtW8Z7YEOBeK2DJ6CmR5rYYF3E= go.opentelemetry.io/otel/metric v1.21.0 h1:tlYWfeo+Bocx5kLEloTjbcDwBuELRrIFxwdQ36PlJu4= go.opentelemetry.io/otel/metric v1.21.0/go.mod h1:o1p3CA8nNHW8j5yuQLdc1eeqEaPfzug24uvsyIEJRWM= +go.opentelemetry.io/otel/sdk v1.21.0 h1:FTt8qirL1EysG6sTQRZ5TokkU8d0ugCj8htOgThZXQ8= +go.opentelemetry.io/otel/sdk v1.21.0/go.mod h1:Nna6Yv7PWTdgJHVRD9hIYywQBRx7pbox6nwBnZIxl/E= +go.opentelemetry.io/otel/sdk/metric v1.21.0 h1:smhI5oD714d6jHE6Tie36fPx4WDFIg+Y6RfAY4ICcR0= +go.opentelemetry.io/otel/sdk/metric v1.21.0/go.mod h1:FJ8RAsoPGv/wYMgBdUJXOm+6pzFY3YdljnXtv1SBE8Q= go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8fpfLc= go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= -go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= +go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I= +go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= +go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 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= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= +golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= +golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/oauth2 v0.14.0 h1:P0Vrf/2538nmC0H+pEQ3MNFRRnVR7RlqyVw+bvm26z0= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gonum.org/v1/gonum v0.14.0 h1:2NiG67LD1tEH0D7kM+ps2V+fXmsAnpUeec7n8tcr4S0= +gonum.org/v1/gonum v0.14.0/go.mod h1:AoWeoz0becf9QMWtE8iWXNXc27fK4fNeHNf/oMejGfU= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= +google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= +google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= +google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= +google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20231120223509-83a465c0220f h1:Vn+VyHU5guc9KjB5KrjI2q0wCOWEOIh0OEsleqakHJg= +google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 h1:JpwMPBpFN3uKhdaekDpiNlImDdkUAyiJ6ez/uxGaUSo= +google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:0xJLfVdJqpAPl8tDg1ujOCGzx6LFLttXT5NhllGOXY4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 h1:DC7wcm+i+P1rN3Ff07vL+OndGg5OhNddHyTA+ocPqYE= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4/go.mod h1:eJVxU6o+4G1PSczBr85xmyvSNYAKvAYgkub40YGomFM= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= -google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= +google.golang.org/grpc v1.60.0 h1:6FQAR0kM31P6MRdeluor2w2gPaS4SVNrD/DNTxrQ15k= +google.golang.org/grpc v1.60.0/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -201,15 +757,38 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/extension/healthcheckextension/healthcheckextension.go b/extension/healthcheckextension/healthcheckextension.go index b3c0634bec97..df8c40ece692 100644 --- a/extension/healthcheckextension/healthcheckextension.go +++ b/extension/healthcheckextension/healthcheckextension.go @@ -54,7 +54,7 @@ func (hc *healthCheckExtension) Start(_ context.Context, host component.Host) er // The listener ownership goes to the server. if err = hc.server.Serve(ln); !errors.Is(err, http.ErrServerClosed) && err != nil { - host.ReportFatalError(err) + _ = hc.settings.ReportComponentStatus(component.NewFatalErrorEvent(err)) } }() } else { diff --git a/extension/healthcheckextension/integration_test.go b/extension/healthcheckextension/integration_test.go new file mode 100644 index 000000000000..76c96022d995 --- /dev/null +++ b/extension/healthcheckextension/integration_test.go @@ -0,0 +1,50 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package healthcheckextension + +import ( + "bytes" + "context" + "fmt" + "io" + "net/http" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component/componenttest" + "go.opentelemetry.io/collector/extension/extensiontest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/testbed/testbed" +) + +func Test_SimpleHealthCheck(t *testing.T) { + f := NewFactory() + port := testbed.GetAvailablePort(t) + cfg := f.CreateDefaultConfig().(*Config) + cfg.Endpoint = fmt.Sprintf("localhost:%d", port) + e, err := f.CreateExtension(context.Background(), extensiontest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = e.Start(context.Background(), componenttest.NewNopHost()) + require.NoError(t, err) + t.Cleanup(func() { + require.NoError(t, e.Shutdown(context.Background())) + }) + resp, err := http.DefaultClient.Get(fmt.Sprintf("http://localhost:%d/", port)) + require.NoError(t, err) + assert.Equal(t, "503 Service Unavailable", resp.Status) + var buf bytes.Buffer + _, err = io.Copy(&buf, resp.Body) + require.NoError(t, err) + assert.Equal(t, `{"status":"Server not available","upSince":"0001-01-01T00:00:00Z","uptime":""}`, buf.String()) + err = e.(*healthCheckExtension).Ready() + require.NoError(t, err) + resp, err = http.DefaultClient.Get(fmt.Sprintf("http://localhost:%d/", port)) + require.NoError(t, err) + assert.Equal(t, "200 OK", resp.Status) + buf.Reset() + _, err = io.Copy(&buf, resp.Body) + require.NoError(t, err) + assert.Contains(t, buf.String(), `{"status":"Server available","upSince":"`) +} diff --git a/extension/healthcheckextension/internal/metadata/generated_status.go b/extension/healthcheckextension/internal/metadata/generated_status.go index ea6c8c94e349..6c3782ef60fd 100644 --- a/extension/healthcheckextension/internal/metadata/generated_status.go +++ b/extension/healthcheckextension/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "health_check" ExtensionStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/healthcheck") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/healthcheck") +} diff --git a/extension/httpforwarder/go.mod b/extension/httpforwarder/go.mod index 1ae0f793f89b..55a4a70b012f 100644 --- a/extension/httpforwarder/go.mod +++ b/extension/httpforwarder/go.mod @@ -11,6 +11,8 @@ require ( go.opentelemetry.io/collector/config/configtls v0.91.0 go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -43,8 +45,6 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/extension/httpforwarder/internal/metadata/generated_status.go b/extension/httpforwarder/internal/metadata/generated_status.go index 652f394f99f8..3432bfd95132 100644 --- a/extension/httpforwarder/internal/metadata/generated_status.go +++ b/extension/httpforwarder/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "http_forwarder" ExtensionStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol") +} diff --git a/extension/jaegerremotesampling/go.mod b/extension/jaegerremotesampling/go.mod index e3ed1c833f6a..587d11b9ce12 100644 --- a/extension/jaegerremotesampling/go.mod +++ b/extension/jaegerremotesampling/go.mod @@ -16,6 +16,8 @@ require ( go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 go.opentelemetry.io/collector/featuregate v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 google.golang.org/grpc v1.60.0 ) @@ -63,8 +65,6 @@ require ( go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/net v0.19.0 // indirect diff --git a/extension/jaegerremotesampling/internal/http.go b/extension/jaegerremotesampling/internal/http.go index 9f848d0106d5..bdb8e6356936 100644 --- a/extension/jaegerremotesampling/internal/http.go +++ b/extension/jaegerremotesampling/internal/http.go @@ -72,7 +72,7 @@ func (h *SamplingHTTPServer) Start(_ context.Context, host component.Host) error defer h.shutdownWG.Done() if err := h.srv.Serve(hln); err != nil && !errors.Is(err, http.ErrServerClosed) { - host.ReportFatalError(err) + _ = h.telemetry.ReportComponentStatus(component.NewFatalErrorEvent(err)) } }() diff --git a/extension/jaegerremotesampling/internal/metadata/generated_status.go b/extension/jaegerremotesampling/internal/metadata/generated_status.go index 7a0b3224ccbc..0d7d1103a074 100644 --- a/extension/jaegerremotesampling/internal/metadata/generated_status.go +++ b/extension/jaegerremotesampling/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "jaegerremotesampling" ExtensionStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol") +} diff --git a/extension/oauth2clientauthextension/go.mod b/extension/oauth2clientauthextension/go.mod index bca7d757855d..5a08bdec9aab 100644 --- a/extension/oauth2clientauthextension/go.mod +++ b/extension/oauth2clientauthextension/go.mod @@ -11,6 +11,8 @@ require ( go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 go.opentelemetry.io/collector/extension/auth v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 golang.org/x/oauth2 v0.15.0 @@ -47,8 +49,6 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/extension/oauth2clientauthextension/internal/metadata/generated_status.go b/extension/oauth2clientauthextension/internal/metadata/generated_status.go index 47de0aaab60f..131f64f8b661 100644 --- a/extension/oauth2clientauthextension/internal/metadata/generated_status.go +++ b/extension/oauth2clientauthextension/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "oauth2client" ExtensionStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/oauth2clientauth") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/oauth2clientauth") +} diff --git a/extension/observer/dockerobserver/go.mod b/extension/observer/dockerobserver/go.mod index 636393bf8894..1e1a3eeec14b 100644 --- a/extension/observer/dockerobserver/go.mod +++ b/extension/observer/dockerobserver/go.mod @@ -13,6 +13,8 @@ require ( go.opentelemetry.io/collector/component v0.91.0 go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -63,8 +65,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/pdata v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/goleak v1.3.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea // indirect diff --git a/extension/observer/dockerobserver/internal/metadata/generated_status.go b/extension/observer/dockerobserver/internal/metadata/generated_status.go index 37cb96c3ff7b..cae5dd01f61d 100644 --- a/extension/observer/dockerobserver/internal/metadata/generated_status.go +++ b/extension/observer/dockerobserver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "docker_observer" ExtensionStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol") +} diff --git a/extension/observer/ecsobserver/go.mod b/extension/observer/ecsobserver/go.mod index b4e53c2fffe5..a435019f9aaf 100644 --- a/extension/observer/ecsobserver/go.mod +++ b/extension/observer/ecsobserver/go.mod @@ -3,12 +3,14 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/extension/obser go 1.20 require ( - github.com/aws/aws-sdk-go v1.49.1 + github.com/aws/aws-sdk-go v1.49.5 github.com/hashicorp/golang-lru v1.0.2 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.91.0 go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 gopkg.in/yaml.v2 v2.4.0 @@ -31,8 +33,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/pdata v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.14.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/extension/observer/ecsobserver/go.sum b/extension/observer/ecsobserver/go.sum index 04cef70064a8..b732dc2d6816 100644 --- a/extension/observer/ecsobserver/go.sum +++ b/extension/observer/ecsobserver/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.49.1 h1:Dsamcd8d/nNb3A+bZ0ucfGl0vGZsW5wlRW0vhoYGoeQ= -github.com/aws/aws-sdk-go v1.49.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.5 h1:y2yfBlwjPDi3/sBVKeznYEdDy6wIhjA2L5NCBMLUIYA= +github.com/aws/aws-sdk-go v1.49.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/extension/observer/ecsobserver/internal/metadata/generated_status.go b/extension/observer/ecsobserver/internal/metadata/generated_status.go index 6379aea62869..1b625e1518d8 100644 --- a/extension/observer/ecsobserver/internal/metadata/generated_status.go +++ b/extension/observer/ecsobserver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "ecs_observer" ExtensionStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol") +} diff --git a/extension/observer/ecstaskobserver/go.mod b/extension/observer/ecstaskobserver/go.mod index b7b3f3f1ec45..841eb3449a83 100644 --- a/extension/observer/ecstaskobserver/go.mod +++ b/extension/observer/ecstaskobserver/go.mod @@ -11,6 +11,8 @@ require ( go.opentelemetry.io/collector/config/confighttp v0.91.0 go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -45,8 +47,6 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/extension/observer/ecstaskobserver/internal/metadata/generated_status.go b/extension/observer/ecstaskobserver/internal/metadata/generated_status.go index 809117881999..f974af534ae0 100644 --- a/extension/observer/ecstaskobserver/internal/metadata/generated_status.go +++ b/extension/observer/ecstaskobserver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "ecs_task_observer" ExtensionStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol") +} diff --git a/extension/observer/hostobserver/go.mod b/extension/observer/hostobserver/go.mod index 4ca3c2d5dcc2..d245d3735042 100644 --- a/extension/observer/hostobserver/go.mod +++ b/extension/observer/hostobserver/go.mod @@ -9,6 +9,8 @@ require ( go.opentelemetry.io/collector/component v0.91.0 go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -35,8 +37,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/pdata v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/extension/observer/hostobserver/internal/metadata/generated_status.go b/extension/observer/hostobserver/internal/metadata/generated_status.go index 0a782df70f39..3ee2f0a00785 100644 --- a/extension/observer/hostobserver/internal/metadata/generated_status.go +++ b/extension/observer/hostobserver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "host_observer" ExtensionStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol") +} diff --git a/extension/observer/k8sobserver/go.mod b/extension/observer/k8sobserver/go.mod index 93ffa994cc5a..ccd3d86e9a36 100644 --- a/extension/observer/k8sobserver/go.mod +++ b/extension/observer/k8sobserver/go.mod @@ -9,6 +9,8 @@ require ( go.opentelemetry.io/collector/component v0.91.0 go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 k8s.io/api v0.28.4 k8s.io/apimachinery v0.28.4 @@ -50,8 +52,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/pdata v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/oauth2 v0.14.0 // indirect diff --git a/extension/observer/k8sobserver/internal/metadata/generated_status.go b/extension/observer/k8sobserver/internal/metadata/generated_status.go index 43b785971030..16bedcf3b84d 100644 --- a/extension/observer/k8sobserver/internal/metadata/generated_status.go +++ b/extension/observer/k8sobserver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "k8s_observer" ExtensionStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol") +} diff --git a/extension/oidcauthextension/go.mod b/extension/oidcauthextension/go.mod index f10b54ca7757..c8f5695d3184 100644 --- a/extension/oidcauthextension/go.mod +++ b/extension/oidcauthextension/go.mod @@ -9,6 +9,8 @@ require ( go.opentelemetry.io/collector/component v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 go.opentelemetry.io/collector/extension/auth v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -30,10 +32,8 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/pdata v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.15.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/oauth2 v0.14.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/extension/oidcauthextension/go.sum b/extension/oidcauthextension/go.sum index c3a6777d1269..fcf1e900e622 100644 --- a/extension/oidcauthextension/go.sum +++ b/extension/oidcauthextension/go.sum @@ -76,8 +76,8 @@ go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= -golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= diff --git a/extension/oidcauthextension/internal/metadata/generated_status.go b/extension/oidcauthextension/internal/metadata/generated_status.go index 066f76118d5a..1de474710847 100644 --- a/extension/oidcauthextension/internal/metadata/generated_status.go +++ b/extension/oidcauthextension/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "oidc" ExtensionStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/oidcauth") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/oidcauth") +} diff --git a/extension/opampextension/go.mod b/extension/opampextension/go.mod index a880ddcfab12..500381d6a02a 100644 --- a/extension/opampextension/go.mod +++ b/extension/opampextension/go.mod @@ -14,6 +14,8 @@ require ( go.opentelemetry.io/collector/extension v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -36,8 +38,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/goleak v1.3.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect diff --git a/extension/opampextension/internal/metadata/generated_status.go b/extension/opampextension/internal/metadata/generated_status.go index cf21386a85ea..e77772cbb7cf 100644 --- a/extension/opampextension/internal/metadata/generated_status.go +++ b/extension/opampextension/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "opamp" ExtensionStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/opamp") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/opamp") +} diff --git a/extension/pprofextension/go.mod b/extension/pprofextension/go.mod index 75dd7bc0b83e..9ba53e199c7f 100644 --- a/extension/pprofextension/go.mod +++ b/extension/pprofextension/go.mod @@ -9,6 +9,8 @@ require ( go.opentelemetry.io/collector/config/confignet v0.91.0 go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -28,8 +30,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/pdata v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.14.0 // indirect diff --git a/extension/pprofextension/internal/metadata/generated_status.go b/extension/pprofextension/internal/metadata/generated_status.go index 2eee7f5e63dc..e46176baca68 100644 --- a/extension/pprofextension/internal/metadata/generated_status.go +++ b/extension/pprofextension/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "pprof" ExtensionStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/pprof") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/pprof") +} diff --git a/extension/remotetapextension/go.mod b/extension/remotetapextension/go.mod index 125f5a3ec603..12c156855e0f 100644 --- a/extension/remotetapextension/go.mod +++ b/extension/remotetapextension/go.mod @@ -6,6 +6,8 @@ require ( go.opentelemetry.io/collector/component v0.91.0 go.opentelemetry.io/collector/config/confighttp v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 ) require ( @@ -38,8 +40,6 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/net v0.19.0 // indirect diff --git a/extension/remotetapextension/internal/metadata/generated_status.go b/extension/remotetapextension/internal/metadata/generated_status.go index 28b063c935ab..b1c23d73c7d3 100644 --- a/extension/remotetapextension/internal/metadata/generated_status.go +++ b/extension/remotetapextension/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "remotetap" ExtensionStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/remotetap") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/remotetap") +} diff --git a/extension/sigv4authextension/go.mod b/extension/sigv4authextension/go.mod index 41e94e389e5b..6564bdc6b860 100644 --- a/extension/sigv4authextension/go.mod +++ b/extension/sigv4authextension/go.mod @@ -12,6 +12,8 @@ require ( go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 go.opentelemetry.io/collector/extension/auth v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 google.golang.org/grpc v1.60.0 ) @@ -41,8 +43,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/pdata v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.14.0 // indirect diff --git a/extension/sigv4authextension/internal/metadata/generated_status.go b/extension/sigv4authextension/internal/metadata/generated_status.go index dc66d270b99e..7c9413ae0959 100644 --- a/extension/sigv4authextension/internal/metadata/generated_status.go +++ b/extension/sigv4authextension/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "sigv4auth" ExtensionStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/sigv4auth") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/sigv4auth") +} diff --git a/extension/storage/dbstorage/internal/metadata/generated_status.go b/extension/storage/dbstorage/internal/metadata/generated_status.go index 057cd7cd31a2..0aa21eec2fb2 100644 --- a/extension/storage/dbstorage/internal/metadata/generated_status.go +++ b/extension/storage/dbstorage/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "db_storage" ExtensionStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol") +} diff --git a/extension/storage/filestorage/internal/metadata/generated_status.go b/extension/storage/filestorage/internal/metadata/generated_status.go index 90881ccc1de1..2d1aafeea932 100644 --- a/extension/storage/filestorage/internal/metadata/generated_status.go +++ b/extension/storage/filestorage/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "file_storage" ExtensionStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol") +} diff --git a/extension/storage/go.mod b/extension/storage/go.mod index 3affee7b965a..4a12ccf61f5d 100644 --- a/extension/storage/go.mod +++ b/extension/storage/go.mod @@ -11,6 +11,8 @@ require ( go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 go.opentelemetry.io/collector/featuregate v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -36,12 +38,10 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/pdata v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.15.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/net v0.18.0 // indirect - golang.org/x/sys v0.14.0 // indirect + golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect google.golang.org/grpc v1.59.0 // indirect diff --git a/extension/storage/go.sum b/extension/storage/go.sum index 5a3c4997e569..12c3200eda7e 100644 --- a/extension/storage/go.sum +++ b/extension/storage/go.sum @@ -189,8 +189,8 @@ golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= -golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= @@ -228,8 +228,8 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= -golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= diff --git a/go.mod b/go.mod index 717c8ec86d50..8b6194666771 100644 --- a/go.mod +++ b/go.mod @@ -282,7 +282,7 @@ require ( github.com/apache/thrift v0.19.0 // indirect github.com/ardielle/ardielle-go v1.5.2 // indirect github.com/armon/go-metrics v0.4.1 // indirect - github.com/aws/aws-sdk-go v1.49.1 // indirect + github.com/aws/aws-sdk-go v1.49.5 // indirect github.com/aws/aws-sdk-go-v2 v1.24.0 // indirect github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.5.4 // indirect github.com/aws/aws-sdk-go-v2/config v1.26.1 // indirect @@ -671,8 +671,8 @@ require ( go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect - golang.org/x/crypto v0.16.0 // indirect - golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect + golang.org/x/crypto v0.17.0 // indirect + golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/oauth2 v0.15.0 // indirect @@ -1159,3 +1159,11 @@ replace ( github.com/open-telemetry/opentelemetry-collector-contrib/connector/servicegraphconnector => ./connector/servicegraphconnector github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector => ./connector/spanmetricsconnector ) + +replace github.com/open-telemetry/opentelemetry-collector-contrib/testbed/mockdatareceivers/mockawsxrayreceiver => ./testbed/mockdatareceivers/mockawsxrayreceiver + +replace github.com/open-telemetry/opentelemetry-collector-contrib/testbed/mockdatasenders/mockdatadogagentexporter => ./testbed/mockdatasenders/mockdatadogagentexporter + +replace github.com/open-telemetry/opentelemetry-collector-contrib/testbed => ./testbed + +replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/syslogexporter => ./exporter/syslogexporter diff --git a/go.sum b/go.sum index 00bf4ab5df1c..c30a77f194eb 100644 --- a/go.sum +++ b/go.sum @@ -324,8 +324,8 @@ github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN github.com/aws/aws-sdk-go v1.32.6/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go v1.38.35/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/aws/aws-sdk-go v1.44.263/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go v1.49.1 h1:Dsamcd8d/nNb3A+bZ0ucfGl0vGZsW5wlRW0vhoYGoeQ= -github.com/aws/aws-sdk-go v1.49.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.5 h1:y2yfBlwjPDi3/sBVKeznYEdDy6wIhjA2L5NCBMLUIYA= +github.com/aws/aws-sdk-go v1.49.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/aws/aws-sdk-go-v2 v1.17.7/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2 v1.18.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= @@ -1771,8 +1771,8 @@ golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1783,8 +1783,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= diff --git a/internal/aws/awsutil/go.mod b/internal/aws/awsutil/go.mod index 389a469b4fca..8c12c5985fc4 100644 --- a/internal/aws/awsutil/go.mod +++ b/internal/aws/awsutil/go.mod @@ -3,7 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/aw go 1.20 require ( - github.com/aws/aws-sdk-go v1.49.1 + github.com/aws/aws-sdk-go v1.49.5 github.com/stretchr/testify v1.8.4 go.uber.org/zap v1.26.0 golang.org/x/net v0.19.0 diff --git a/internal/aws/awsutil/go.sum b/internal/aws/awsutil/go.sum index 9eaa86b391ae..46a81cdde7c0 100644 --- a/internal/aws/awsutil/go.sum +++ b/internal/aws/awsutil/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.49.1 h1:Dsamcd8d/nNb3A+bZ0ucfGl0vGZsW5wlRW0vhoYGoeQ= -github.com/aws/aws-sdk-go v1.49.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.5 h1:y2yfBlwjPDi3/sBVKeznYEdDy6wIhjA2L5NCBMLUIYA= +github.com/aws/aws-sdk-go v1.49.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/internal/aws/cwlogs/go.mod b/internal/aws/cwlogs/go.mod index df9c04324191..2f80cd42a115 100644 --- a/internal/aws/cwlogs/go.mod +++ b/internal/aws/cwlogs/go.mod @@ -3,7 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/cw go 1.20 require ( - github.com/aws/aws-sdk-go v1.49.1 + github.com/aws/aws-sdk-go v1.49.5 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.91.0 go.uber.org/zap v1.26.0 diff --git a/internal/aws/cwlogs/go.sum b/internal/aws/cwlogs/go.sum index f6d2a17b62eb..2c82caeb274c 100644 --- a/internal/aws/cwlogs/go.sum +++ b/internal/aws/cwlogs/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.49.1 h1:Dsamcd8d/nNb3A+bZ0ucfGl0vGZsW5wlRW0vhoYGoeQ= -github.com/aws/aws-sdk-go v1.49.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.5 h1:y2yfBlwjPDi3/sBVKeznYEdDy6wIhjA2L5NCBMLUIYA= +github.com/aws/aws-sdk-go v1.49.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/internal/aws/k8s/go.mod b/internal/aws/k8s/go.mod index 43c3a459476a..b35e802ba00f 100644 --- a/internal/aws/k8s/go.mod +++ b/internal/aws/k8s/go.mod @@ -3,7 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/k8 go 1.20 require ( - github.com/aws/aws-sdk-go v1.49.1 + github.com/aws/aws-sdk-go v1.49.5 github.com/stretchr/testify v1.8.4 go.uber.org/zap v1.26.0 k8s.io/api v0.28.4 diff --git a/internal/aws/k8s/go.sum b/internal/aws/k8s/go.sum index b117c79edfa2..f0bdb7c5fbf8 100644 --- a/internal/aws/k8s/go.sum +++ b/internal/aws/k8s/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.49.1 h1:Dsamcd8d/nNb3A+bZ0ucfGl0vGZsW5wlRW0vhoYGoeQ= -github.com/aws/aws-sdk-go v1.49.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.5 h1:y2yfBlwjPDi3/sBVKeznYEdDy6wIhjA2L5NCBMLUIYA= +github.com/aws/aws-sdk-go v1.49.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/internal/aws/proxy/go.mod b/internal/aws/proxy/go.mod index 3dd418df80b3..35c45fee223d 100644 --- a/internal/aws/proxy/go.mod +++ b/internal/aws/proxy/go.mod @@ -3,7 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/pr go 1.20 require ( - github.com/aws/aws-sdk-go v1.49.1 + github.com/aws/aws-sdk-go v1.49.5 github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.91.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/config/confignet v0.91.0 diff --git a/internal/aws/proxy/go.sum b/internal/aws/proxy/go.sum index 9356776e310e..712e73fb2f0f 100644 --- a/internal/aws/proxy/go.sum +++ b/internal/aws/proxy/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.49.1 h1:Dsamcd8d/nNb3A+bZ0ucfGl0vGZsW5wlRW0vhoYGoeQ= -github.com/aws/aws-sdk-go v1.49.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.5 h1:y2yfBlwjPDi3/sBVKeznYEdDy6wIhjA2L5NCBMLUIYA= +github.com/aws/aws-sdk-go v1.49.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/internal/aws/xray/go.mod b/internal/aws/xray/go.mod index 0945421d0525..8dc72ff8fd81 100644 --- a/internal/aws/xray/go.mod +++ b/internal/aws/xray/go.mod @@ -3,7 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/xr go 1.20 require ( - github.com/aws/aws-sdk-go v1.49.1 + github.com/aws/aws-sdk-go v1.49.5 github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil v0.91.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.91.0 diff --git a/internal/aws/xray/go.sum b/internal/aws/xray/go.sum index 9d0342b635f4..89596f5a548e 100644 --- a/internal/aws/xray/go.sum +++ b/internal/aws/xray/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.49.1 h1:Dsamcd8d/nNb3A+bZ0ucfGl0vGZsW5wlRW0vhoYGoeQ= -github.com/aws/aws-sdk-go v1.49.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.5 h1:y2yfBlwjPDi3/sBVKeznYEdDy6wIhjA2L5NCBMLUIYA= +github.com/aws/aws-sdk-go v1.49.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/internal/aws/xray/testdata/sampleapp/go.mod b/internal/aws/xray/testdata/sampleapp/go.mod index fa1808d8e440..8c3d879f687b 100644 --- a/internal/aws/xray/testdata/sampleapp/go.mod +++ b/internal/aws/xray/testdata/sampleapp/go.mod @@ -3,7 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/xr go 1.20 require ( - github.com/aws/aws-sdk-go v1.49.1 + github.com/aws/aws-sdk-go v1.49.5 github.com/aws/aws-xray-sdk-go v1.8.3 ) diff --git a/internal/aws/xray/testdata/sampleapp/go.sum b/internal/aws/xray/testdata/sampleapp/go.sum index cb43749a2aa9..02a6d8b407c5 100644 --- a/internal/aws/xray/testdata/sampleapp/go.sum +++ b/internal/aws/xray/testdata/sampleapp/go.sum @@ -1,8 +1,8 @@ github.com/DATA-DOG/go-sqlmock v1.4.1 h1:ThlnYciV1iM/V0OSF/dtkqWb6xo5qITT1TJBG1MRDJM= github.com/andybalholm/brotli v1.0.6 h1:Yf9fFpf49Zrxb9NlQaluyE92/+X7UVHlhMNJN2sxfOI= github.com/andybalholm/brotli v1.0.6/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= -github.com/aws/aws-sdk-go v1.49.1 h1:Dsamcd8d/nNb3A+bZ0ucfGl0vGZsW5wlRW0vhoYGoeQ= -github.com/aws/aws-sdk-go v1.49.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.5 h1:y2yfBlwjPDi3/sBVKeznYEdDy6wIhjA2L5NCBMLUIYA= +github.com/aws/aws-sdk-go v1.49.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/aws/aws-xray-sdk-go v1.8.3 h1:S8GdgVncBRhzbNnNUgTPwhEqhwt2alES/9rLASyhxjU= github.com/aws/aws-xray-sdk-go v1.8.3/go.mod h1:tv8uLMOSCABolrIF8YCcp3ghyswArsan8dfLCA1ZATk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/internal/filter/go.mod b/internal/filter/go.mod index d8d55d9d7576..0d4170ff9b23 100644 --- a/internal/filter/go.mod +++ b/internal/filter/go.mod @@ -42,7 +42,7 @@ require ( go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect + golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/internal/filter/go.sum b/internal/filter/go.sum index c3ffc2d7fff1..71513efa76d0 100644 --- a/internal/filter/go.sum +++ b/internal/filter/go.sum @@ -88,8 +88,8 @@ go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= diff --git a/internal/k8stest/go.mod b/internal/k8stest/go.mod index b989b2948e75..17879954fcc0 100644 --- a/internal/k8stest/go.mod +++ b/internal/k8stest/go.mod @@ -5,6 +5,7 @@ go 1.20 require ( github.com/docker/docker v24.0.7+incompatible github.com/stretchr/testify v1.8.4 + k8s.io/api v0.28.4 k8s.io/apimachinery v0.28.4 k8s.io/client-go v0.28.4 ) @@ -20,7 +21,6 @@ require ( github.com/golang/protobuf v1.5.3 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/kr/text v0.2.0 // indirect github.com/moby/term v0.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect @@ -39,7 +39,6 @@ require ( golang.org/x/tools v0.15.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/protobuf v1.31.0 // indirect - gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/internal/k8stest/go.sum b/internal/k8stest/go.sum index 046c73d6b153..3b2a5b65ba42 100644 --- a/internal/k8stest/go.sum +++ b/internal/k8stest/go.sum @@ -1,7 +1,6 @@ github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -38,12 +37,8 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= @@ -125,7 +120,6 @@ google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -136,6 +130,7 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.4.0 h1:ZazjZUfuVeZGLAmlKKuyv3IKP5orXcwtOwDQH6YVr6o= gotest.tools/v3 v3.4.0/go.mod h1:CtbdzLSsqVhDgMtKsx03ird5YTGB3ar27v0u/yKBW5g= k8s.io/api v0.28.4 h1:8ZBrLjwosLl/NYgv1P7EQLqoO8MGQApnbgH8tu3BMzY= +k8s.io/api v0.28.4/go.mod h1:axWTGrY88s/5YE+JSt4uUi6NMM+gur1en2REMR7IRj0= k8s.io/apimachinery v0.28.4 h1:zOSJe1mc+GxuMnFzD4Z/U1wst50X28ZNsn5bhgIIao8= k8s.io/apimachinery v0.28.4/go.mod h1:wI37ncBvfAoswfq626yPTe6Bz1c22L7uaJ8dho83mgg= k8s.io/client-go v0.28.4 h1:Np5ocjlZcTrkyRJ3+T3PkXDpe4UpatQxj85+xjaD2wY= diff --git a/internal/k8stest/k8s_collector.go b/internal/k8stest/k8s_collector.go index ebfe5035b28e..0530e9caeac3 100644 --- a/internal/k8stest/k8s_collector.go +++ b/internal/k8stest/k8s_collector.go @@ -13,8 +13,10 @@ import ( "time" "github.com/stretchr/testify/require" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/dynamic" ) @@ -36,7 +38,8 @@ func CreateCollectorObjects(t *testing.T, client *dynamic.DynamicClient, testID })) obj, err := CreateObject(client, manifest.Bytes()) require.NoErrorf(t, err, "failed to create collector object from manifest %s", manifestFile.Name()) - if obj.GetKind() == "Deployment" { + objKind := obj.GetKind() + if objKind == "Deployment" || objKind == "DaemonSet" { podNamespace = obj.GetNamespace() selector := obj.Object["spec"].(map[string]any)["selector"] podLabels = selector.(map[string]any)["matchLabels"].(map[string]any) @@ -53,15 +56,49 @@ func WaitForCollectorToStart(t *testing.T, client *dynamic.DynamicClient, podNam podGVR := schema.GroupVersionResource{Version: "v1", Resource: "pods"} listOptions := metav1.ListOptions{LabelSelector: SelectorFromMap(podLabels).String()} podTimeoutMinutes := 3 - var podPhase string - require.Eventually(t, func() bool { + t.Logf("waiting for collector pods to be ready") + require.Eventuallyf(t, func() bool { list, err := client.Resource(podGVR).Namespace(podNamespace).List(context.Background(), listOptions) require.NoError(t, err, "failed to list collector pods") - if len(list.Items) == 0 { + podsNotReady := len(list.Items) + if podsNotReady == 0 { + t.Log("did not find collector pods") return false } - podPhase = list.Items[0].Object["status"].(map[string]any)["phase"].(string) - return podPhase == "Running" - }, time.Duration(podTimeoutMinutes)*time.Minute, 50*time.Millisecond, - "collector pod haven't started within %d minutes, latest pod phase is %s", podTimeoutMinutes, podPhase) + + var pods v1.PodList + err = runtime.DefaultUnstructuredConverter.FromUnstructured(list.UnstructuredContent(), &pods) + require.NoError(t, err, "failed to convert unstructured to podList") + + for _, pod := range pods.Items { + podReady := false + if pod.Status.Phase != v1.PodRunning { + t.Logf("pod %v is not running, current phase: %v", pod.Name, pod.Status.Phase) + continue + } + for _, cond := range pod.Status.Conditions { + if cond.Type == v1.PodReady && cond.Status == v1.ConditionTrue { + podsNotReady-- + podReady = true + } + } + // Add some debug logs for crashing pods + if !podReady { + for _, cs := range pod.Status.ContainerStatuses { + restartCount := cs.RestartCount + if restartCount > 0 && cs.LastTerminationState.Terminated != nil { + t.Logf("restart count = %d for container %s in pod %s, last terminated reason: %s", restartCount, cs.Name, pod.Name, cs.LastTerminationState.Terminated.Reason) + t.Logf("termination message: %s", cs.LastTerminationState.Terminated.Message) + } + } + } + } + if podsNotReady == 0 { + t.Logf("collector pods are ready") + return true + } + return false + + }, time.Duration(podTimeoutMinutes)*time.Minute, 2*time.Second, + "collector pods were not ready within %d minutes", podTimeoutMinutes) } diff --git a/internal/k8stest/k8s_objects.go b/internal/k8stest/k8s_objects.go index e3e4455e9ba8..bbbff8d6e56b 100644 --- a/internal/k8stest/k8s_objects.go +++ b/internal/k8stest/k8s_objects.go @@ -36,5 +36,12 @@ func DeleteObject(client *dynamic.DynamicClient, obj *unstructured.Unstructured) Version: gvk.Version, Resource: strings.ToLower(gvk.Kind + "s"), } - return client.Resource(gvr).Namespace(obj.GetNamespace()).Delete(context.Background(), obj.GetName(), metav1.DeleteOptions{}) + + options := metav1.DeleteOptions{} + policy := metav1.DeletePropagationBackground + if gvk.Kind == "Job" { + options.PropagationPolicy = &policy + } + + return client.Resource(gvr).Namespace(obj.GetNamespace()).Delete(context.Background(), obj.GetName(), options) } diff --git a/internal/kafka/go.mod b/internal/kafka/go.mod index 58139ed90047..063a9a844768 100644 --- a/internal/kafka/go.mod +++ b/internal/kafka/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/IBM/sarama v1.42.1 - github.com/aws/aws-sdk-go v1.49.1 + github.com/aws/aws-sdk-go v1.49.5 github.com/stretchr/testify v1.8.4 github.com/xdg-go/scram v1.1.2 go.opentelemetry.io/collector/config/configtls v0.91.0 @@ -34,9 +34,9 @@ require ( github.com/xdg-go/pbkdf2 v1.0.0 // indirect github.com/xdg-go/stringprep v1.0.4 // indirect go.opentelemetry.io/collector/config/configopaque v0.91.0 // indirect - golang.org/x/crypto v0.15.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/net v0.18.0 // indirect - golang.org/x/sys v0.14.0 // indirect + golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/internal/kafka/go.sum b/internal/kafka/go.sum index 7f7d863efea0..ee95b50a2897 100644 --- a/internal/kafka/go.sum +++ b/internal/kafka/go.sum @@ -1,7 +1,7 @@ github.com/IBM/sarama v1.42.1 h1:wugyWa15TDEHh2kvq2gAy1IHLjEjuYOYgXz/ruC/OSQ= github.com/IBM/sarama v1.42.1/go.mod h1:Xxho9HkHd4K/MDUo/T/sOqwtX/17D33++E9Wib6hUdQ= -github.com/aws/aws-sdk-go v1.49.1 h1:Dsamcd8d/nNb3A+bZ0ucfGl0vGZsW5wlRW0vhoYGoeQ= -github.com/aws/aws-sdk-go v1.49.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.5 h1:y2yfBlwjPDi3/sBVKeznYEdDy6wIhjA2L5NCBMLUIYA= +github.com/aws/aws-sdk-go v1.49.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= @@ -80,8 +80,8 @@ go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN8 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= -golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -100,8 +100,8 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= -golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= diff --git a/internal/metadataproviders/go.mod b/internal/metadataproviders/go.mod index 25dd8258781b..119ebe75d574 100644 --- a/internal/metadataproviders/go.mod +++ b/internal/metadataproviders/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/Showmax/go-fqdn v1.0.0 - github.com/aws/aws-sdk-go v1.49.1 + github.com/aws/aws-sdk-go v1.49.5 github.com/docker/docker v24.0.7+incompatible github.com/hashicorp/consul/api v1.26.1 github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8sconfig v0.91.0 diff --git a/internal/metadataproviders/go.sum b/internal/metadataproviders/go.sum index ae234041d095..6b58c9dbe7fd 100644 --- a/internal/metadataproviders/go.sum +++ b/internal/metadataproviders/go.sum @@ -51,8 +51,8 @@ github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= -github.com/aws/aws-sdk-go v1.49.1 h1:Dsamcd8d/nNb3A+bZ0ucfGl0vGZsW5wlRW0vhoYGoeQ= -github.com/aws/aws-sdk-go v1.49.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.5 h1:y2yfBlwjPDi3/sBVKeznYEdDy6wIhjA2L5NCBMLUIYA= +github.com/aws/aws-sdk-go v1.49.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= diff --git a/internal/tools/go.mod b/internal/tools/go.mod index 9f31f77e50ed..fb2575503f7b 100644 --- a/internal/tools/go.mod +++ b/internal/tools/go.mod @@ -218,7 +218,7 @@ require ( go.tmz.dev/musttag v0.7.2 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect - golang.org/x/crypto v0.16.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/exp/typeparams v0.0.0-20230307190834-24139beb5833 // indirect golang.org/x/mod v0.14.0 // indirect diff --git a/internal/tools/go.sum b/internal/tools/go.sum index ac00de9d2123..b6d31dad99b2 100644 --- a/internal/tools/go.sum +++ b/internal/tools/go.sum @@ -674,8 +674,8 @@ golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/pkg/ottl/boolean_value_test.go b/pkg/ottl/boolean_value_test.go index a7843429406f..ad42555e192f 100644 --- a/pkg/ottl/boolean_value_test.go +++ b/pkg/ottl/boolean_value_test.go @@ -28,8 +28,8 @@ func valueFor(x any) value { case v == "NAME": // if the string is NAME construct a path of "name". val.Literal = &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -38,11 +38,11 @@ func valueFor(x any) value { } case strings.Contains(v, "ENUM"): // if the string contains ENUM construct an EnumSymbol from it. - val.Enum = (*EnumSymbol)(ottltest.Strp(v)) + val.Enum = (*enumSymbol)(ottltest.Strp(v)) case v == "dur1" || v == "dur2": val.Literal = &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: v, }, @@ -51,8 +51,8 @@ func valueFor(x any) value { } case v == "time1" || v == "time2": val.Literal = &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: v, }, @@ -93,7 +93,7 @@ func comparisonHelper(left any, right any, op string) *comparison { func Test_newComparisonEvaluator(t *testing.T) { p, _ := NewParser( defaultFunctionsForTests(), - testParsePath, + testParsePath[any], componenttest.NewNopTelemetrySettings(), WithEnumParser[any](testParseEnum), ) @@ -185,7 +185,7 @@ func Test_newComparisonEvaluator(t *testing.T) { func Test_newConditionEvaluator_invalid(t *testing.T) { p, _ := NewParser( defaultFunctionsForTests(), - testParsePath, + testParsePath[any], componenttest.NewNopTelemetrySettings(), WithEnumParser[any](testParseEnum), ) @@ -195,12 +195,12 @@ func Test_newConditionEvaluator_invalid(t *testing.T) { comparison *comparison }{ { - name: "unknown Path", + name: "unknown path", comparison: &comparison{ Left: value{ - Enum: (*EnumSymbol)(ottltest.Strp("SYMBOL_NOT_FOUND")), + Enum: (*enumSymbol)(ottltest.Strp("SYMBOL_NOT_FOUND")), }, - Op: EQ, + Op: eq, Right: value{ String: ottltest.Strp("trash"), }, @@ -233,7 +233,7 @@ func Test_newBooleanExpressionEvaluator(t *testing.T) { p, _ := NewParser( functions, - testParsePath, + testParsePath[any], componenttest.NewNopTelemetrySettings(), WithEnumParser[any](testParseEnum), ) @@ -488,7 +488,7 @@ func Test_newBooleanExpressionEvaluator(t *testing.T) { Left: value{ String: ottltest.Strp("test"), }, - Op: EQ, + Op: eq, Right: value{ String: ottltest.Strp("not test"), }, @@ -616,7 +616,7 @@ func Test_newBooleanExpressionEvaluator_invalid(t *testing.T) { p, _ := NewParser( functions, - testParsePath, + testParsePath[any], componenttest.NewNopTelemetrySettings(), WithEnumParser[any](testParseEnum), ) diff --git a/pkg/ottl/compare.go b/pkg/ottl/compare.go index fc93186c4985..50d1109f00ca 100644 --- a/pkg/ottl/compare.go +++ b/pkg/ottl/compare.go @@ -15,29 +15,29 @@ import ( // values of type any, which for the purposes of OTTL mean values that are one of // int, float, string, bool, or pointers to those, or []byte, or nil. -// invalidComparison returns false for everything except NE (where it returns true to indicate that the +// invalidComparison returns false for everything except ne (where it returns true to indicate that the // objects were definitely not equivalent). // It also gives us an opportunity to log something. func (p *Parser[K]) invalidComparison(msg string, op compareOp) bool { p.telemetrySettings.Logger.Debug(msg, zap.Any("op", op)) - return op == NE + return op == ne } // comparePrimitives implements a generic comparison helper for all Ordered types (derived from Float, Int, or string). // According to benchmarks, it's faster than explicit comparison functions for these types. func comparePrimitives[T constraints.Ordered](a T, b T, op compareOp) bool { switch op { - case EQ: + case eq: return a == b - case NE: + case ne: return a != b - case LT: + case lt: return a < b - case LTE: + case lte: return a <= b - case GTE: + case gte: return a >= b - case GT: + case gt: return a > b default: return false @@ -46,17 +46,17 @@ func comparePrimitives[T constraints.Ordered](a T, b T, op compareOp) bool { func compareBools(a bool, b bool, op compareOp) bool { switch op { - case EQ: + case eq: return a == b - case NE: + case ne: return a != b - case LT: + case lt: return !a && b - case LTE: + case lte: return !a || b - case GTE: + case gte: return a || !b - case GT: + case gt: return a && !b default: return false @@ -65,17 +65,17 @@ func compareBools(a bool, b bool, op compareOp) bool { func compareBytes(a []byte, b []byte, op compareOp) bool { switch op { - case EQ: + case eq: return bytes.Equal(a, b) - case NE: + case ne: return !bytes.Equal(a, b) - case LT: + case lt: return bytes.Compare(a, b) < 0 - case LTE: + case lte: return bytes.Compare(a, b) <= 0 - case GTE: + case gte: return bytes.Compare(a, b) >= 0 - case GT: + case gt: return bytes.Compare(a, b) > 0 default: return false @@ -103,10 +103,10 @@ func (p *Parser[K]) compareString(a string, b any, op compareOp) bool { func (p *Parser[K]) compareByte(a []byte, b any, op compareOp) bool { switch v := b.(type) { case nil: - return op == NE + return op == ne case []byte: if v == nil { - return op == NE + return op == ne } return compareBytes(a, v, op) default: @@ -151,17 +151,17 @@ func (p *Parser[K]) compareTime(a time.Time, b any, op compareOp) bool { switch v := b.(type) { case time.Time: switch op { - case EQ: + case eq: return a.Equal(v) - case NE: + case ne: return !a.Equal(v) - case LT: + case lt: return a.Before(v) - case LTE: + case lte: return a.Before(v) || a.Equal(v) - case GTE: + case gte: return a.After(v) || a.Equal(v) - case GT: + case gt: return a.After(v) default: return p.invalidComparison("invalid comparison operator", op) @@ -177,7 +177,7 @@ func (p *Parser[K]) compare(a any, b any, op compareOp) bool { // nils are equal to each other and never equal to anything else, // so if they're both nil, report equality. if a == nil && b == nil { - return op == EQ || op == LTE || op == GTE + return op == eq || op == lte || op == gte } // Anything else, we switch on the left side first. switch v := a.(type) { @@ -206,9 +206,9 @@ func (p *Parser[K]) compare(a any, b any, op compareOp) bool { // If we don't know what type it is, we can't do inequalities yet. So we can fall back to the old behavior where we just // use Go's standard equality. switch op { - case EQ: + case eq: return a == b - case NE: + case ne: return a != b default: return p.invalidComparison("unsupported type for inequality on left", op) diff --git a/pkg/ottl/compare_test.go b/pkg/ottl/compare_test.go index b2dffba38a4f..e051ececb739 100644 --- a/pkg/ottl/compare_test.go +++ b/pkg/ottl/compare_test.go @@ -45,7 +45,7 @@ func Test_compare(t *testing.T) { name string a any b any - want []bool // in order of EQ, NE, LT, LTE, GTE, GT. + want []bool // in order of eq, ne, lt, lte, gte, gt. }{ {"identity string", sa, sa, []bool{true, false, false, true, true, false}}, {"identity int64", i64a, i64a, []bool{true, false, false, true, true, false}}, @@ -101,7 +101,7 @@ func Test_compare(t *testing.T) { {"non-prim, int type", testA{"hi"}, 5, []bool{false, true, false, false, false, false}}, {"int, non-prim", 5, testA{"hi"}, []bool{false, true, false, false, false, false}}, } - ops := []compareOp{EQ, NE, LT, LTE, GTE, GT} + ops := []compareOp{eq, ne, lt, lte, gte, gt} for _, tt := range tests { for _, op := range ops { t.Run(fmt.Sprintf("%s %v", tt.name, op), func(t *testing.T) { @@ -123,7 +123,7 @@ func BenchmarkCompareEQInt64(b *testing.B) { b.ReportAllocs() b.ResetTimer() for i := 0; i < b.N; i++ { - testParser.compare(i64a, i64b, EQ) + testParser.compare(i64a, i64b, eq) } } @@ -132,7 +132,7 @@ func BenchmarkCompareEQFloat(b *testing.B) { b.ReportAllocs() b.ResetTimer() for i := 0; i < b.N; i++ { - testParser.compare(f64a, f64b, EQ) + testParser.compare(f64a, f64b, eq) } } @@ -141,7 +141,7 @@ func BenchmarkCompareEQString(b *testing.B) { b.ReportAllocs() b.ResetTimer() for i := 0; i < b.N; i++ { - testParser.compare(sa, sb, EQ) + testParser.compare(sa, sb, eq) } } @@ -150,7 +150,7 @@ func BenchmarkCompareEQPString(b *testing.B) { b.ReportAllocs() b.ResetTimer() for i := 0; i < b.N; i++ { - testParser.compare(&sa, &sb, EQ) + testParser.compare(&sa, &sb, eq) } } @@ -159,7 +159,7 @@ func BenchmarkCompareEQBytes(b *testing.B) { b.ReportAllocs() b.ResetTimer() for i := 0; i < b.N; i++ { - testParser.compare(ba, bb, EQ) + testParser.compare(ba, bb, eq) } } @@ -168,7 +168,7 @@ func BenchmarkCompareEQNil(b *testing.B) { b.ReportAllocs() b.ResetTimer() for i := 0; i < b.N; i++ { - testParser.compare(nil, nil, EQ) + testParser.compare(nil, nil, eq) } } @@ -177,7 +177,7 @@ func BenchmarkCompareNEInt(b *testing.B) { b.ReportAllocs() b.ResetTimer() for i := 0; i < b.N; i++ { - testParser.compare(i64a, i64b, NE) + testParser.compare(i64a, i64b, ne) } } @@ -186,7 +186,7 @@ func BenchmarkCompareNEFloat(b *testing.B) { b.ReportAllocs() b.ResetTimer() for i := 0; i < b.N; i++ { - testParser.compare(f64a, f64b, NE) + testParser.compare(f64a, f64b, ne) } } @@ -195,7 +195,7 @@ func BenchmarkCompareNEString(b *testing.B) { b.ReportAllocs() b.ResetTimer() for i := 0; i < b.N; i++ { - testParser.compare(sa, sb, NE) + testParser.compare(sa, sb, ne) } } @@ -204,7 +204,7 @@ func BenchmarkCompareLTFloat(b *testing.B) { b.ReportAllocs() b.ResetTimer() for i := 0; i < b.N; i++ { - testParser.compare(f64a, f64b, LT) + testParser.compare(f64a, f64b, lt) } } @@ -213,7 +213,7 @@ func BenchmarkCompareLTString(b *testing.B) { b.ReportAllocs() b.ResetTimer() for i := 0; i < b.N; i++ { - testParser.compare(sa, sb, LT) + testParser.compare(sa, sb, lt) } } @@ -222,17 +222,17 @@ func BenchmarkCompareLTNil(b *testing.B) { b.ReportAllocs() b.ResetTimer() for i := 0; i < b.N; i++ { - testParser.compare(nil, nil, LT) + testParser.compare(nil, nil, lt) } } // this is only used for benchmarking, and is a rough equivalent of the original compare function -// before adding LT, LTE, GTE, and GT. +// before adding lt, lte, gte, and gt. func compareEq(a any, b any, op compareOp) bool { switch op { - case EQ: + case eq: return a == b - case NE: + case ne: return a != b default: return false @@ -241,6 +241,6 @@ func compareEq(a any, b any, op compareOp) bool { func BenchmarkCompareEQFunction(b *testing.B) { for i := 0; i < b.N; i++ { - compareEq(sa, sb, EQ) + compareEq(sa, sb, eq) } } diff --git a/pkg/ottl/contexts/internal/map.go b/pkg/ottl/contexts/internal/map.go index b45d61c177d6..a3dea84a0e0c 100644 --- a/pkg/ottl/contexts/internal/map.go +++ b/pkg/ottl/contexts/internal/map.go @@ -4,6 +4,7 @@ package internal // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/internal" import ( + "context" "fmt" "go.opentelemetry.io/collector/pdata/pcommon" @@ -11,33 +12,43 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl" ) -func GetMapValue(m pcommon.Map, keys []ottl.Key) (any, error) { - if len(keys) == 0 { +func GetMapValue[K any](ctx context.Context, tCtx K, m pcommon.Map, key ottl.Key[K]) (any, error) { + if key == nil { return nil, fmt.Errorf("cannot get map value without key") } - if keys[0].String == nil { + + s, err := key.String(ctx, tCtx) + if err != nil { + return nil, err + } + if s == nil { return nil, fmt.Errorf("non-string indexing is not supported") } - val, ok := m.Get(*keys[0].String) + val, ok := m.Get(*s) if !ok { return nil, nil } - return getIndexableValue(val, keys[1:]) + + return getIndexableValue[K](ctx, tCtx, val, key.Next()) } -func SetMapValue(m pcommon.Map, keys []ottl.Key, val any) error { - if len(keys) == 0 { +func SetMapValue[K any](ctx context.Context, tCtx K, m pcommon.Map, key ottl.Key[K], val any) error { + if key == nil { return fmt.Errorf("cannot set map value without key") } - if keys[0].String == nil { + + s, err := key.String(ctx, tCtx) + if err != nil { + return err + } + if s == nil { return fmt.Errorf("non-string indexing is not supported") } - currentValue, ok := m.Get(*keys[0].String) + currentValue, ok := m.Get(*s) if !ok { - currentValue = m.PutEmpty(*keys[0].String) + currentValue = m.PutEmpty(*s) } - - return setIndexableValue(currentValue, val, keys[1:]) + return setIndexableValue[K](ctx, tCtx, currentValue, val, key.Next()) } diff --git a/pkg/ottl/contexts/internal/map_test.go b/pkg/ottl/contexts/internal/map_test.go index 582167559186..ca51dfe73a7b 100644 --- a/pkg/ottl/contexts/internal/map_test.go +++ b/pkg/ottl/contexts/internal/map_test.go @@ -4,92 +4,76 @@ package internal import ( + "context" "fmt" "testing" "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/pcommon" - "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/ottltest" ) func Test_GetMapValue_Invalid(t *testing.T) { tests := []struct { name string - keys []ottl.Key + keys *TestKey[any] err error }{ - { - name: "no keys", - keys: []ottl.Key{}, - err: fmt.Errorf("cannot get map value without key"), - }, { name: "first key not a string", - keys: []ottl.Key{ - { - Int: ottltest.Intp(0), - }, + keys: &TestKey[any]{ + I: ottltest.Intp(0), }, err: fmt.Errorf("non-string indexing is not supported"), }, { name: "index map with int", - keys: []ottl.Key{ - { - String: ottltest.Strp("map"), - }, - { - Int: ottltest.Intp(0), + keys: &TestKey[any]{ + S: ottltest.Strp("map"), + NextKey: &TestKey[any]{ + I: ottltest.Intp(0), }, }, err: fmt.Errorf("map must be indexed by a string"), }, { name: "index slice with string", - keys: []ottl.Key{ - { - String: ottltest.Strp("slice"), - }, - { - String: ottltest.Strp("invalid"), + keys: &TestKey[any]{ + + S: ottltest.Strp("slice"), + NextKey: &TestKey[any]{ + S: ottltest.Strp("invalid"), }, }, err: fmt.Errorf("slice must be indexed by an int"), }, { name: "index too large", - keys: []ottl.Key{ - { - String: ottltest.Strp("slice"), - }, - { - Int: ottltest.Intp(1), + keys: &TestKey[any]{ + S: ottltest.Strp("slice"), + NextKey: &TestKey[any]{ + I: ottltest.Intp(1), }, }, err: fmt.Errorf("index 1 out of bounds"), }, { name: "index too small", - keys: []ottl.Key{ - { - String: ottltest.Strp("slice"), - }, - { - Int: ottltest.Intp(-1), + keys: &TestKey[any]{ + S: ottltest.Strp("slice"), + NextKey: &TestKey[any]{ + I: ottltest.Intp(-1), }, }, err: fmt.Errorf("index -1 out of bounds"), }, { name: "invalid type", - keys: []ottl.Key{ - { - String: ottltest.Strp("string"), - }, - { - String: ottltest.Strp("string"), + keys: &TestKey[any]{ + S: ottltest.Strp("string"), + NextKey: &TestKey[any]{ + S: ottltest.Strp("string"), }, }, err: fmt.Errorf("type Str does not support string indexing"), @@ -105,7 +89,7 @@ func Test_GetMapValue_Invalid(t *testing.T) { s := m.PutEmptySlice("slice") s.AppendEmpty() - _, err := GetMapValue(m, tt.keys) + _, err := GetMapValue[any](context.Background(), nil, m, tt.keys) assert.Equal(t, tt.err, err) }) } @@ -114,95 +98,81 @@ func Test_GetMapValue_Invalid(t *testing.T) { func Test_GetMapValue_MissingKey(t *testing.T) { m := pcommon.NewMap() m.PutEmptyMap("map1").PutEmptyMap("map2") - keys := []ottl.Key{ - { - String: ottltest.Strp("map1"), - }, - { - String: ottltest.Strp("unknown key"), + keys := TestKey[any]{ + S: ottltest.Strp("map1"), + NextKey: &TestKey[any]{ + S: ottltest.Strp("unknown key"), }, } - result, err := GetMapValue(m, keys) + result, err := GetMapValue[any](context.Background(), nil, m, &keys) assert.Nil(t, err) assert.Nil(t, result) } +func Test_GetMapValue_NilKey(t *testing.T) { + _, err := GetMapValue[any](context.Background(), nil, pcommon.NewMap(), nil) + assert.Error(t, err) +} + func Test_SetMapValue_Invalid(t *testing.T) { tests := []struct { name string - keys []ottl.Key + keys *TestKey[any] err error }{ - { - name: "no keys", - keys: []ottl.Key{}, - err: fmt.Errorf("cannot set map value without key"), - }, { name: "first key not a string", - keys: []ottl.Key{ - { - Int: ottltest.Intp(0), - }, + keys: &TestKey[any]{ + I: ottltest.Intp(0), }, err: fmt.Errorf("non-string indexing is not supported"), }, { name: "index map with int", - keys: []ottl.Key{ - { - String: ottltest.Strp("map"), - }, - { - Int: ottltest.Intp(0), + keys: &TestKey[any]{ + S: ottltest.Strp("map"), + NextKey: &TestKey[any]{ + I: ottltest.Intp(0), }, }, err: fmt.Errorf("map must be indexed by a string"), }, { name: "index slice with string", - keys: []ottl.Key{ - { - String: ottltest.Strp("slice"), - }, - { - String: ottltest.Strp("map"), + keys: &TestKey[any]{ + S: ottltest.Strp("slice"), + NextKey: &TestKey[any]{ + S: ottltest.Strp("map"), }, }, err: fmt.Errorf("slice must be indexed by an int"), }, { name: "slice index too large", - keys: []ottl.Key{ - { - String: ottltest.Strp("slice"), - }, - { - Int: ottltest.Intp(1), + keys: &TestKey[any]{ + S: ottltest.Strp("slice"), + NextKey: &TestKey[any]{ + I: ottltest.Intp(1), }, }, err: fmt.Errorf("index 1 out of bounds"), }, { name: "slice index too small", - keys: []ottl.Key{ - { - String: ottltest.Strp("slice"), - }, - { - Int: ottltest.Intp(-1), + keys: &TestKey[any]{ + S: ottltest.Strp("slice"), + NextKey: &TestKey[any]{ + I: ottltest.Intp(-1), }, }, err: fmt.Errorf("index -1 out of bounds"), }, { name: "slice index too small", - keys: []ottl.Key{ - { - String: ottltest.Strp("string"), - }, - { - String: ottltest.Strp("string"), + keys: &TestKey[any]{ + S: ottltest.Strp("string"), + NextKey: &TestKey[any]{ + S: ottltest.Strp("string"), }, }, err: fmt.Errorf("type Str does not support string indexing"), @@ -218,7 +188,7 @@ func Test_SetMapValue_Invalid(t *testing.T) { s := m.PutEmptySlice("slice") s.AppendEmpty() - err := SetMapValue(m, tt.keys, "value") + err := SetMapValue[any](context.Background(), nil, m, tt.keys, "value") assert.Equal(t, tt.err, err) }) } @@ -227,18 +197,16 @@ func Test_SetMapValue_Invalid(t *testing.T) { func Test_SetMapValue_AddingNewSubMap(t *testing.T) { m := pcommon.NewMap() m.PutEmptyMap("map1").PutStr("test", "test") - keys := []ottl.Key{ - { - String: ottltest.Strp("map1"), - }, - { - String: ottltest.Strp("map2"), - }, - { - String: ottltest.Strp("foo"), + keys := TestKey[any]{ + S: ottltest.Strp("map1"), + NextKey: &TestKey[any]{ + S: ottltest.Strp("map2"), + NextKey: &TestKey[any]{ + S: ottltest.Strp("foo"), + }, }, } - err := SetMapValue(m, keys, "bar") + err := SetMapValue[any](context.Background(), nil, m, &keys, "bar") assert.Nil(t, err) expected := pcommon.NewMap() @@ -251,18 +219,16 @@ func Test_SetMapValue_AddingNewSubMap(t *testing.T) { func Test_SetMapValue_EmptyMap(t *testing.T) { m := pcommon.NewMap() - keys := []ottl.Key{ - { - String: ottltest.Strp("map1"), - }, - { - String: ottltest.Strp("map2"), - }, - { - String: ottltest.Strp("foo"), + keys := TestKey[any]{ + S: ottltest.Strp("map1"), + NextKey: &TestKey[any]{ + S: ottltest.Strp("map2"), + NextKey: &TestKey[any]{ + S: ottltest.Strp("foo"), + }, }, } - err := SetMapValue(m, keys, "bar") + err := SetMapValue[any](context.Background(), nil, m, &keys, "bar") assert.Nil(t, err) expected := pcommon.NewMap() @@ -270,3 +236,8 @@ func Test_SetMapValue_EmptyMap(t *testing.T) { assert.Equal(t, expected, m) } + +func Test_SetMapValue_NilKey(t *testing.T) { + err := SetMapValue[any](context.Background(), nil, pcommon.NewMap(), nil, "bar") + assert.Error(t, err) +} diff --git a/pkg/ottl/contexts/internal/metric.go b/pkg/ottl/contexts/internal/metric.go index e34afd8854f6..d4823c71ef0f 100644 --- a/pkg/ottl/contexts/internal/metric.go +++ b/pkg/ottl/contexts/internal/metric.go @@ -28,11 +28,11 @@ var MetricSymbolTable = map[ottl.EnumSymbol]ottl.Enum{ "METRIC_DATA_TYPE_SUMMARY": ottl.Enum(pmetric.MetricTypeSummary), } -func MetricPathGetSetter[K MetricContext](path []ottl.Field) (ottl.GetSetter[K], error) { - if len(path) == 0 { +func MetricPathGetSetter[K MetricContext](path ottl.Path[K]) (ottl.GetSetter[K], error) { + if path == nil { return accessMetric[K](), nil } - switch path[0].Name { + switch path.Name() { case "name": return accessName[K](), nil case "description": @@ -47,9 +47,9 @@ func MetricPathGetSetter[K MetricContext](path []ottl.Field) (ottl.GetSetter[K], return accessIsMonotonic[K](), nil case "data_points": return accessDataPoints[K](), nil + default: + return nil, fmt.Errorf("invalid metric path expression %v", path) } - - return nil, fmt.Errorf("invalid metric path expression %v", path) } func accessMetric[K MetricContext]() ottl.StandardGetSetter[K] { @@ -177,7 +177,6 @@ func accessDataPoints[K MetricContext]() ottl.StandardGetSetter[K] { return ottl.StandardGetSetter[K]{ Getter: func(ctx context.Context, tCtx K) (any, error) { metric := tCtx.GetMetric() - //exhaustive:enforce switch metric.Type() { case pmetric.MetricTypeSum: return metric.Sum().DataPoints(), nil @@ -194,7 +193,6 @@ func accessDataPoints[K MetricContext]() ottl.StandardGetSetter[K] { }, Setter: func(ctx context.Context, tCtx K, val any) error { metric := tCtx.GetMetric() - //exhaustive:enforce switch metric.Type() { case pmetric.MetricTypeSum: if newDataPoints, ok := val.(pmetric.NumberDataPointSlice); ok { diff --git a/pkg/ottl/contexts/internal/metric_test.go b/pkg/ottl/contexts/internal/metric_test.go index 8bbcb1d7d1df..401a07705071 100644 --- a/pkg/ottl/contexts/internal/metric_test.go +++ b/pkg/ottl/contexts/internal/metric_test.go @@ -26,17 +26,15 @@ func Test_MetricPathGetSetter(t *testing.T) { tests := []struct { name string - path []ottl.Field + path ottl.Path[*metricContext] orig any newVal any modified func(metric pmetric.Metric) }{ { name: "metric name", - path: []ottl.Field{ - { - Name: "name", - }, + path: &TestPath[*metricContext]{ + N: "name", }, orig: "name", newVal: "new name", @@ -46,10 +44,8 @@ func Test_MetricPathGetSetter(t *testing.T) { }, { name: "metric description", - path: []ottl.Field{ - { - Name: "description", - }, + path: &TestPath[*metricContext]{ + N: "description", }, orig: "description", newVal: "new description", @@ -59,10 +55,8 @@ func Test_MetricPathGetSetter(t *testing.T) { }, { name: "metric unit", - path: []ottl.Field{ - { - Name: "unit", - }, + path: &TestPath[*metricContext]{ + N: "unit", }, orig: "unit", newVal: "new unit", @@ -72,10 +66,8 @@ func Test_MetricPathGetSetter(t *testing.T) { }, { name: "metric type", - path: []ottl.Field{ - { - Name: "type", - }, + path: &TestPath[*metricContext]{ + N: "type", }, orig: int64(pmetric.MetricTypeSum), newVal: int64(pmetric.MetricTypeSum), @@ -84,10 +76,8 @@ func Test_MetricPathGetSetter(t *testing.T) { }, { name: "metric aggregation_temporality", - path: []ottl.Field{ - { - Name: "aggregation_temporality", - }, + path: &TestPath[*metricContext]{ + N: "aggregation_temporality", }, orig: int64(2), newVal: int64(1), @@ -97,10 +87,8 @@ func Test_MetricPathGetSetter(t *testing.T) { }, { name: "metric is_monotonic", - path: []ottl.Field{ - { - Name: "is_monotonic", - }, + path: &TestPath[*metricContext]{ + N: "is_monotonic", }, orig: true, newVal: false, @@ -110,10 +98,8 @@ func Test_MetricPathGetSetter(t *testing.T) { }, { name: "metric data points", - path: []ottl.Field{ - { - Name: "data_points", - }, + path: &TestPath[*metricContext]{ + N: "data_points", }, orig: refMetric.Sum().DataPoints(), newVal: newDataPoints, diff --git a/pkg/ottl/contexts/internal/path.go b/pkg/ottl/contexts/internal/path.go new file mode 100644 index 000000000000..a3b909719073 --- /dev/null +++ b/pkg/ottl/contexts/internal/path.go @@ -0,0 +1,56 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package internal // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/internal" + +import ( + "context" + + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl" +) + +var _ ottl.Path[any] = &TestPath[any]{} + +type TestPath[K any] struct { + N string + Keys ottl.Key[K] + NextPath *TestPath[K] +} + +func (p *TestPath[K]) Name() string { + return p.N +} + +func (p *TestPath[K]) Next() ottl.Path[K] { + if p.NextPath == nil { + return nil + } + return p.NextPath +} + +func (p *TestPath[K]) Key() ottl.Key[K] { + return p.Keys +} + +var _ ottl.Key[any] = &TestKey[any]{} + +type TestKey[K any] struct { + S *string + I *int64 + NextKey *TestKey[K] +} + +func (k *TestKey[K]) String(_ context.Context, _ K) (*string, error) { + return k.S, nil +} + +func (k *TestKey[K]) Int(_ context.Context, _ K) (*int64, error) { + return k.I, nil +} + +func (k *TestKey[K]) Next() ottl.Key[K] { + if k.NextKey == nil { + return nil + } + return k.NextKey +} diff --git a/pkg/ottl/contexts/internal/resource.go b/pkg/ottl/contexts/internal/resource.go index 0303a4acd7b7..61638996c89e 100644 --- a/pkg/ottl/contexts/internal/resource.go +++ b/pkg/ottl/contexts/internal/resource.go @@ -16,22 +16,21 @@ type ResourceContext interface { GetResource() pcommon.Resource } -func ResourcePathGetSetter[K ResourceContext](path []ottl.Field) (ottl.GetSetter[K], error) { - if len(path) == 0 { +func ResourcePathGetSetter[K ResourceContext](path ottl.Path[K]) (ottl.GetSetter[K], error) { + if path == nil { return accessResource[K](), nil } - switch path[0].Name { + switch path.Name() { case "attributes": - mapKeys := path[0].Keys - if mapKeys == nil { + if path.Key() == nil { return accessResourceAttributes[K](), nil } - return accessResourceAttributesKey[K](mapKeys), nil + return accessResourceAttributesKey[K](path.Key()), nil case "dropped_attributes_count": return accessResourceDroppedAttributesCount[K](), nil + default: + return nil, fmt.Errorf("invalid resource path expression %v", path) } - - return nil, fmt.Errorf("invalid resource path expression %v", path) } func accessResource[K ResourceContext]() ottl.StandardGetSetter[K] { @@ -62,13 +61,13 @@ func accessResourceAttributes[K ResourceContext]() ottl.StandardGetSetter[K] { } } -func accessResourceAttributesKey[K ResourceContext](keys []ottl.Key) ottl.StandardGetSetter[K] { +func accessResourceAttributesKey[K ResourceContext](keys ottl.Key[K]) ottl.StandardGetSetter[K] { return ottl.StandardGetSetter[K]{ Getter: func(ctx context.Context, tCtx K) (any, error) { - return GetMapValue(tCtx.GetResource().Attributes(), keys) + return GetMapValue[K](ctx, tCtx, tCtx.GetResource().Attributes(), keys) }, Setter: func(ctx context.Context, tCtx K, val any) error { - return SetMapValue(tCtx.GetResource().Attributes(), keys, val) + return SetMapValue[K](ctx, tCtx, tCtx.GetResource().Attributes(), keys, val) }, } } diff --git a/pkg/ottl/contexts/internal/resource_test.go b/pkg/ottl/contexts/internal/resource_test.go index 97f93c044d46..a9f689c2c234 100644 --- a/pkg/ottl/contexts/internal/resource_test.go +++ b/pkg/ottl/contexts/internal/resource_test.go @@ -22,14 +22,14 @@ func TestResourcePathGetSetter(t *testing.T) { tests := []struct { name string - path []ottl.Field + path ottl.Path[*resourceContext] orig any newVal any modified func(resource pcommon.Resource) }{ { name: "resource", - path: []ottl.Field{}, + path: nil, orig: refResource, newVal: pcommon.NewResource(), modified: func(resource pcommon.Resource) { @@ -38,10 +38,8 @@ func TestResourcePathGetSetter(t *testing.T) { }, { name: "attributes", - path: []ottl.Field{ - { - Name: "attributes", - }, + path: &TestPath[*resourceContext]{ + N: "attributes", }, orig: refResource.Attributes(), newVal: newAttrs, @@ -51,14 +49,10 @@ func TestResourcePathGetSetter(t *testing.T) { }, { name: "attributes string", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("str"), - }, - }, + path: &TestPath[*resourceContext]{ + N: "attributes", + Keys: &TestKey[*resourceContext]{ + S: ottltest.Strp("str"), }, }, orig: "val", @@ -69,14 +63,10 @@ func TestResourcePathGetSetter(t *testing.T) { }, { name: "attributes bool", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("bool"), - }, - }, + path: &TestPath[*resourceContext]{ + N: "attributes", + Keys: &TestKey[*resourceContext]{ + S: ottltest.Strp("bool"), }, }, orig: true, @@ -87,14 +77,10 @@ func TestResourcePathGetSetter(t *testing.T) { }, { name: "attributes int", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("int"), - }, - }, + path: &TestPath[*resourceContext]{ + N: "attributes", + Keys: &TestKey[*resourceContext]{ + S: ottltest.Strp("int"), }, }, orig: int64(10), @@ -105,14 +91,10 @@ func TestResourcePathGetSetter(t *testing.T) { }, { name: "attributes float", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("double"), - }, - }, + path: &TestPath[*resourceContext]{ + N: "attributes", + Keys: &TestKey[*resourceContext]{ + S: ottltest.Strp("double"), }, }, orig: 1.2, @@ -123,14 +105,10 @@ func TestResourcePathGetSetter(t *testing.T) { }, { name: "attributes bytes", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("bytes"), - }, - }, + path: &TestPath[*resourceContext]{ + N: "attributes", + Keys: &TestKey[*resourceContext]{ + S: ottltest.Strp("bytes"), }, }, orig: []byte{1, 3, 2}, @@ -141,14 +119,10 @@ func TestResourcePathGetSetter(t *testing.T) { }, { name: "attributes array empty", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_empty"), - }, - }, + path: &TestPath[*resourceContext]{ + N: "attributes", + Keys: &TestKey[*resourceContext]{ + S: ottltest.Strp("arr_empty"), }, }, orig: func() pcommon.Slice { @@ -162,14 +136,10 @@ func TestResourcePathGetSetter(t *testing.T) { }, { name: "attributes array string", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_str"), - }, - }, + path: &TestPath[*resourceContext]{ + N: "attributes", + Keys: &TestKey[*resourceContext]{ + S: ottltest.Strp("arr_str"), }, }, orig: func() pcommon.Slice { @@ -183,14 +153,10 @@ func TestResourcePathGetSetter(t *testing.T) { }, { name: "attributes array bool", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_bool"), - }, - }, + path: &TestPath[*resourceContext]{ + N: "attributes", + Keys: &TestKey[*resourceContext]{ + S: ottltest.Strp("arr_bool"), }, }, orig: func() pcommon.Slice { @@ -204,14 +170,10 @@ func TestResourcePathGetSetter(t *testing.T) { }, { name: "attributes array int", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_int"), - }, - }, + path: &TestPath[*resourceContext]{ + N: "attributes", + Keys: &TestKey[*resourceContext]{ + S: ottltest.Strp("arr_int"), }, }, orig: func() pcommon.Slice { @@ -225,14 +187,10 @@ func TestResourcePathGetSetter(t *testing.T) { }, { name: "attributes array float", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_float"), - }, - }, + path: &TestPath[*resourceContext]{ + N: "attributes", + Keys: &TestKey[*resourceContext]{ + S: ottltest.Strp("arr_float"), }, }, orig: func() pcommon.Slice { @@ -246,14 +204,10 @@ func TestResourcePathGetSetter(t *testing.T) { }, { name: "attributes array bytes", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_bytes"), - }, - }, + path: &TestPath[*resourceContext]{ + N: "attributes", + Keys: &TestKey[*resourceContext]{ + S: ottltest.Strp("arr_bytes"), }, }, orig: func() pcommon.Slice { @@ -267,18 +221,14 @@ func TestResourcePathGetSetter(t *testing.T) { }, { name: "attributes nested", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("slice"), - }, - { - Int: ottltest.Intp(0), - }, - { - String: ottltest.Strp("map"), + path: &TestPath[*resourceContext]{ + N: "attributes", + Keys: &TestKey[*resourceContext]{ + S: ottltest.Strp("slice"), + NextKey: &TestKey[*resourceContext]{ + I: ottltest.Intp(0), + NextKey: &TestKey[*resourceContext]{ + S: ottltest.Strp("map"), }, }, }, @@ -295,18 +245,14 @@ func TestResourcePathGetSetter(t *testing.T) { }, { name: "attributes nested new values", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("new"), - }, - { - Int: ottltest.Intp(2), - }, - { - Int: ottltest.Intp(0), + path: &TestPath[*resourceContext]{ + N: "attributes", + Keys: &TestKey[*resourceContext]{ + S: ottltest.Strp("new"), + NextKey: &TestKey[*resourceContext]{ + I: ottltest.Intp(2), + NextKey: &TestKey[*resourceContext]{ + I: ottltest.Intp(0), }, }, }, @@ -324,10 +270,8 @@ func TestResourcePathGetSetter(t *testing.T) { }, { name: "dropped_attributes_count", - path: []ottl.Field{ - { - Name: "dropped_attributes_count", - }, + path: &TestPath[*resourceContext]{ + N: "dropped_attributes_count", }, orig: int64(10), newVal: int64(20), diff --git a/pkg/ottl/contexts/internal/scope.go b/pkg/ottl/contexts/internal/scope.go index 3ed068602f53..dc0f44e5dd2d 100644 --- a/pkg/ottl/contexts/internal/scope.go +++ b/pkg/ottl/contexts/internal/scope.go @@ -16,27 +16,26 @@ type InstrumentationScopeContext interface { GetInstrumentationScope() pcommon.InstrumentationScope } -func ScopePathGetSetter[K InstrumentationScopeContext](path []ottl.Field) (ottl.GetSetter[K], error) { - if len(path) == 0 { +func ScopePathGetSetter[K InstrumentationScopeContext](path ottl.Path[K]) (ottl.GetSetter[K], error) { + if path == nil { return accessInstrumentationScope[K](), nil } - - switch path[0].Name { + switch path.Name() { case "name": return accessInstrumentationScopeName[K](), nil case "version": return accessInstrumentationScopeVersion[K](), nil case "attributes": - mapKeys := path[0].Keys + mapKeys := path.Key() if mapKeys == nil { return accessInstrumentationScopeAttributes[K](), nil } return accessInstrumentationScopeAttributesKey[K](mapKeys), nil case "dropped_attributes_count": return accessInstrumentationScopeDroppedAttributesCount[K](), nil + default: + return nil, fmt.Errorf("invalid scope path expression %v", path) } - - return nil, fmt.Errorf("invalid scope path expression %v", path) } func accessInstrumentationScope[K InstrumentationScopeContext]() ottl.StandardGetSetter[K] { @@ -67,13 +66,13 @@ func accessInstrumentationScopeAttributes[K InstrumentationScopeContext]() ottl. } } -func accessInstrumentationScopeAttributesKey[K InstrumentationScopeContext](keys []ottl.Key) ottl.StandardGetSetter[K] { +func accessInstrumentationScopeAttributesKey[K InstrumentationScopeContext](key ottl.Key[K]) ottl.StandardGetSetter[K] { return ottl.StandardGetSetter[K]{ Getter: func(ctx context.Context, tCtx K) (any, error) { - return GetMapValue(tCtx.GetInstrumentationScope().Attributes(), keys) + return GetMapValue[K](ctx, tCtx, tCtx.GetInstrumentationScope().Attributes(), key) }, Setter: func(ctx context.Context, tCtx K, val any) error { - return SetMapValue(tCtx.GetInstrumentationScope().Attributes(), keys, val) + return SetMapValue[K](ctx, tCtx, tCtx.GetInstrumentationScope().Attributes(), key, val) }, } } diff --git a/pkg/ottl/contexts/internal/scope_test.go b/pkg/ottl/contexts/internal/scope_test.go index 1560ddb024ca..5ac20b188e32 100644 --- a/pkg/ottl/contexts/internal/scope_test.go +++ b/pkg/ottl/contexts/internal/scope_test.go @@ -21,14 +21,14 @@ func TestScopePathGetSetter(t *testing.T) { newAttrs.PutStr("hello", "world") tests := []struct { name string - path []ottl.Field + path ottl.Path[*instrumentationScopeContext] orig any newVal any modified func(is pcommon.InstrumentationScope) }{ { name: "instrumentation_scope", - path: []ottl.Field{}, + path: nil, orig: refIS, newVal: pcommon.NewInstrumentationScope(), modified: func(is pcommon.InstrumentationScope) { @@ -37,10 +37,8 @@ func TestScopePathGetSetter(t *testing.T) { }, { name: "instrumentation_scope name", - path: []ottl.Field{ - { - Name: "name", - }, + path: &TestPath[*instrumentationScopeContext]{ + N: "name", }, orig: refIS.Name(), newVal: "newname", @@ -50,10 +48,8 @@ func TestScopePathGetSetter(t *testing.T) { }, { name: "instrumentation_scope version", - path: []ottl.Field{ - { - Name: "version", - }, + path: &TestPath[*instrumentationScopeContext]{ + N: "version", }, orig: refIS.Version(), newVal: "next", @@ -63,10 +59,8 @@ func TestScopePathGetSetter(t *testing.T) { }, { name: "attributes", - path: []ottl.Field{ - { - Name: "attributes", - }, + path: &TestPath[*instrumentationScopeContext]{ + N: "attributes", }, orig: refIS.Attributes(), newVal: newAttrs, @@ -76,14 +70,10 @@ func TestScopePathGetSetter(t *testing.T) { }, { name: "attributes string", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("str"), - }, - }, + path: &TestPath[*instrumentationScopeContext]{ + N: "attributes", + Keys: &TestKey[*instrumentationScopeContext]{ + S: ottltest.Strp("str"), }, }, orig: "val", @@ -94,10 +84,8 @@ func TestScopePathGetSetter(t *testing.T) { }, { name: "dropped_attributes_count", - path: []ottl.Field{ - { - Name: "dropped_attributes_count", - }, + path: &TestPath[*instrumentationScopeContext]{ + N: "dropped_attributes_count", }, orig: int64(10), newVal: int64(20), @@ -107,14 +95,10 @@ func TestScopePathGetSetter(t *testing.T) { }, { name: "attributes bool", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("bool"), - }, - }, + path: &TestPath[*instrumentationScopeContext]{ + N: "attributes", + Keys: &TestKey[*instrumentationScopeContext]{ + S: ottltest.Strp("bool"), }, }, orig: true, @@ -125,14 +109,10 @@ func TestScopePathGetSetter(t *testing.T) { }, { name: "attributes int", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("int"), - }, - }, + path: &TestPath[*instrumentationScopeContext]{ + N: "attributes", + Keys: &TestKey[*instrumentationScopeContext]{ + S: ottltest.Strp("int"), }, }, orig: int64(10), @@ -143,14 +123,10 @@ func TestScopePathGetSetter(t *testing.T) { }, { name: "attributes float", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("double"), - }, - }, + path: &TestPath[*instrumentationScopeContext]{ + N: "attributes", + Keys: &TestKey[*instrumentationScopeContext]{ + S: ottltest.Strp("double"), }, }, orig: 1.2, @@ -161,14 +137,10 @@ func TestScopePathGetSetter(t *testing.T) { }, { name: "attributes bytes", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("bytes"), - }, - }, + path: &TestPath[*instrumentationScopeContext]{ + N: "attributes", + Keys: &TestKey[*instrumentationScopeContext]{ + S: ottltest.Strp("bytes"), }, }, orig: []byte{1, 3, 2}, @@ -179,14 +151,10 @@ func TestScopePathGetSetter(t *testing.T) { }, { name: "attributes array empty", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_empty"), - }, - }, + path: &TestPath[*instrumentationScopeContext]{ + N: "attributes", + Keys: &TestKey[*instrumentationScopeContext]{ + S: ottltest.Strp("arr_empty"), }, }, orig: func() pcommon.Slice { @@ -200,14 +168,10 @@ func TestScopePathGetSetter(t *testing.T) { }, { name: "attributes array string", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_str"), - }, - }, + path: &TestPath[*instrumentationScopeContext]{ + N: "attributes", + Keys: &TestKey[*instrumentationScopeContext]{ + S: ottltest.Strp("arr_str"), }, }, orig: func() pcommon.Slice { @@ -222,14 +186,10 @@ func TestScopePathGetSetter(t *testing.T) { }, { name: "attributes array bool", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_bool"), - }, - }, + path: &TestPath[*instrumentationScopeContext]{ + N: "attributes", + Keys: &TestKey[*instrumentationScopeContext]{ + S: ottltest.Strp("arr_bool"), }, }, orig: func() pcommon.Slice { @@ -244,14 +204,10 @@ func TestScopePathGetSetter(t *testing.T) { }, { name: "attributes array int", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_int"), - }, - }, + path: &TestPath[*instrumentationScopeContext]{ + N: "attributes", + Keys: &TestKey[*instrumentationScopeContext]{ + S: ottltest.Strp("arr_int"), }, }, orig: func() pcommon.Slice { @@ -266,14 +222,10 @@ func TestScopePathGetSetter(t *testing.T) { }, { name: "attributes array float", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_float"), - }, - }, + path: &TestPath[*instrumentationScopeContext]{ + N: "attributes", + Keys: &TestKey[*instrumentationScopeContext]{ + S: ottltest.Strp("arr_float"), }, }, orig: func() pcommon.Slice { @@ -288,14 +240,10 @@ func TestScopePathGetSetter(t *testing.T) { }, { name: "attributes array bytes", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_bytes"), - }, - }, + path: &TestPath[*instrumentationScopeContext]{ + N: "attributes", + Keys: &TestKey[*instrumentationScopeContext]{ + S: ottltest.Strp("arr_bytes"), }, }, orig: func() pcommon.Slice { @@ -310,18 +258,14 @@ func TestScopePathGetSetter(t *testing.T) { }, { name: "attributes nested", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("slice"), - }, - { - Int: ottltest.Intp(0), - }, - { - String: ottltest.Strp("map"), + path: &TestPath[*instrumentationScopeContext]{ + N: "attributes", + Keys: &TestKey[*instrumentationScopeContext]{ + S: ottltest.Strp("slice"), + NextKey: &TestKey[*instrumentationScopeContext]{ + I: ottltest.Intp(0), + NextKey: &TestKey[*instrumentationScopeContext]{ + S: ottltest.Strp("map"), }, }, }, @@ -338,18 +282,14 @@ func TestScopePathGetSetter(t *testing.T) { }, { name: "attributes nested new values", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("new"), - }, - { - Int: ottltest.Intp(2), - }, - { - Int: ottltest.Intp(0), + path: &TestPath[*instrumentationScopeContext]{ + N: "attributes", + Keys: &TestKey[*instrumentationScopeContext]{ + S: ottltest.Strp("new"), + NextKey: &TestKey[*instrumentationScopeContext]{ + I: ottltest.Intp(2), + NextKey: &TestKey[*instrumentationScopeContext]{ + I: ottltest.Intp(0), }, }, }, diff --git a/pkg/ottl/contexts/internal/slice.go b/pkg/ottl/contexts/internal/slice.go index da846c61f05e..ed6c9ae7b322 100644 --- a/pkg/ottl/contexts/internal/slice.go +++ b/pkg/ottl/contexts/internal/slice.go @@ -4,6 +4,7 @@ package internal // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/internal" import ( + "context" "fmt" "go.opentelemetry.io/collector/pdata/pcommon" @@ -11,34 +12,46 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl" ) -func GetSliceValue(s pcommon.Slice, keys []ottl.Key) (any, error) { - if len(keys) == 0 { +func GetSliceValue[K any](ctx context.Context, tCtx K, s pcommon.Slice, key ottl.Key[K]) (any, error) { + if key == nil { return nil, fmt.Errorf("cannot get slice value without key") } - if keys[0].Int == nil { + + i, err := key.Int(ctx, tCtx) + if err != nil { + return nil, err + } + if i == nil { return nil, fmt.Errorf("non-integer indexing is not supported") } - idx := int(*keys[0].Int) + + idx := int(*i) if idx < 0 || idx >= s.Len() { return nil, fmt.Errorf("index %d out of bounds", idx) } - return getIndexableValue(s.At(int(*keys[0].Int)), keys[1:]) + return getIndexableValue[K](ctx, tCtx, s.At(idx), key.Next()) } -func SetSliceValue(s pcommon.Slice, keys []ottl.Key, val any) error { - if len(keys) == 0 { +func SetSliceValue[K any](ctx context.Context, tCtx K, s pcommon.Slice, key ottl.Key[K], val any) error { + if key == nil { return fmt.Errorf("cannot set slice value without key") } - if keys[0].Int == nil { + + i, err := key.Int(ctx, tCtx) + if err != nil { + return err + } + if i == nil { return fmt.Errorf("non-integer indexing is not supported") } - idx := int(*keys[0].Int) + + idx := int(*i) if idx < 0 || idx >= s.Len() { return fmt.Errorf("index %d out of bounds", idx) } - return setIndexableValue(s.At(int(*keys[0].Int)), val, keys[1:]) + return setIndexableValue[K](ctx, tCtx, s.At(idx), val, key.Next()) } diff --git a/pkg/ottl/contexts/internal/slice_test.go b/pkg/ottl/contexts/internal/slice_test.go index b0d6d23b9997..85a7b416c2eb 100644 --- a/pkg/ottl/contexts/internal/slice_test.go +++ b/pkg/ottl/contexts/internal/slice_test.go @@ -4,6 +4,7 @@ package internal import ( + "context" "fmt" "testing" @@ -17,49 +18,36 @@ import ( func Test_GetSliceValue_Invalid(t *testing.T) { tests := []struct { name string - keys []ottl.Key + keys ottl.Key[any] err error }{ - { - name: "no keys", - keys: []ottl.Key{}, - err: fmt.Errorf("cannot get slice value without key"), - }, { name: "first key not an integer", - keys: []ottl.Key{ - { - String: ottltest.Strp("key"), - }, + keys: &TestKey[any]{ + S: ottltest.Strp("key"), }, err: fmt.Errorf("non-integer indexing is not supported"), }, { name: "index too large", - keys: []ottl.Key{ - { - Int: ottltest.Intp(1), - }, + keys: &TestKey[any]{ + I: ottltest.Intp(1), }, err: fmt.Errorf("index 1 out of bounds"), }, { name: "index too small", - keys: []ottl.Key{ - { - Int: ottltest.Intp(-1), - }, + keys: &TestKey[any]{ + I: ottltest.Intp(-1), }, err: fmt.Errorf("index -1 out of bounds"), }, { name: "invalid type", - keys: []ottl.Key{ - { - Int: ottltest.Intp(0), - }, - { - String: ottltest.Strp("string"), + keys: &TestKey[any]{ + I: ottltest.Intp(0), + NextKey: &TestKey[any]{ + S: ottltest.Strp("string"), }, }, err: fmt.Errorf("type Str does not support string indexing"), @@ -71,58 +59,50 @@ func Test_GetSliceValue_Invalid(t *testing.T) { s := pcommon.NewSlice() s.AppendEmpty().SetStr("val") - _, err := GetSliceValue(s, tt.keys) + _, err := GetSliceValue[any](context.Background(), nil, s, tt.keys) assert.Equal(t, tt.err, err) }) } } +func Test_GetSliceValue_NilKey(t *testing.T) { + _, err := GetSliceValue[any](context.Background(), nil, pcommon.NewSlice(), nil) + assert.Error(t, err) +} + func Test_SetSliceValue_Invalid(t *testing.T) { tests := []struct { name string - keys []ottl.Key + keys ottl.Key[any] err error }{ - { - name: "no keys", - keys: []ottl.Key{}, - err: fmt.Errorf("cannot set slice value without key"), - }, { name: "first key not an integer", - keys: []ottl.Key{ - { - String: ottltest.Strp("key"), - }, + keys: &TestKey[any]{ + S: ottltest.Strp("key"), }, err: fmt.Errorf("non-integer indexing is not supported"), }, { name: "index too large", - keys: []ottl.Key{ - { - Int: ottltest.Intp(1), - }, + keys: &TestKey[any]{ + I: ottltest.Intp(1), }, err: fmt.Errorf("index 1 out of bounds"), }, { name: "index too small", - keys: []ottl.Key{ - { - Int: ottltest.Intp(-1), - }, + keys: &TestKey[any]{ + I: ottltest.Intp(-1), }, err: fmt.Errorf("index -1 out of bounds"), }, { name: "invalid type", - keys: []ottl.Key{ - { - Int: ottltest.Intp(0), - }, - { - String: ottltest.Strp("string"), + keys: &TestKey[any]{ + I: ottltest.Intp(0), + NextKey: &TestKey[any]{ + S: ottltest.Strp("string"), }, }, err: fmt.Errorf("type Str does not support string indexing"), @@ -134,8 +114,13 @@ func Test_SetSliceValue_Invalid(t *testing.T) { s := pcommon.NewSlice() s.AppendEmpty().SetStr("val") - err := SetSliceValue(s, tt.keys, "value") + err := SetSliceValue[any](context.Background(), nil, s, tt.keys, "value") assert.Equal(t, tt.err, err) }) } } + +func Test_SetSliceValue_NilKey(t *testing.T) { + err := SetSliceValue[any](context.Background(), nil, pcommon.NewSlice(), nil, "value") + assert.Error(t, err) +} diff --git a/pkg/ottl/contexts/internal/span.go b/pkg/ottl/contexts/internal/span.go index 0c6c48601f71..165ce14777fd 100644 --- a/pkg/ottl/contexts/internal/span.go +++ b/pkg/ottl/contexts/internal/span.go @@ -33,51 +33,57 @@ var SpanSymbolTable = map[ottl.EnumSymbol]ottl.Enum{ "STATUS_CODE_ERROR": ottl.Enum(ptrace.StatusCodeError), } -func SpanPathGetSetter[K SpanContext](path []ottl.Field) (ottl.GetSetter[K], error) { - if len(path) == 0 { +func SpanPathGetSetter[K SpanContext](path ottl.Path[K]) (ottl.GetSetter[K], error) { + if path == nil { return accessSpan[K](), nil } - - switch path[0].Name { + switch path.Name() { case "trace_id": - if len(path) == 1 { + if path.Next() != nil { + if path.Next().Name() == "string" { + return accessStringTraceID[K](), nil + } + } else { return accessTraceID[K](), nil } - if path[1].Name == "string" { - return accessStringTraceID[K](), nil - } case "span_id": - if len(path) == 1 { + if path.Next() != nil { + if path.Next().Name() == "string" { + return accessStringSpanID[K](), nil + } + } else { return accessSpanID[K](), nil } - if path[1].Name == "string" { - return accessStringSpanID[K](), nil - } case "trace_state": - mapKey := path[0].Keys + mapKey := path.Key() if mapKey == nil { return accessTraceState[K](), nil } return accessTraceStateKey[K](mapKey) case "parent_span_id": - if len(path) == 1 { + if path.Next() != nil { + if path.Next().Name() == "string" { + return accessStringParentSpanID[K](), nil + } + } else { return accessParentSpanID[K](), nil } - if path[1].Name == "string" { - return accessStringParentSpanID[K](), nil - } case "name": return accessSpanName[K](), nil case "kind": - if len(path) == 1 { + nextPath := path.Next() + if nextPath != nil { + switch nextPath.Name() { + case "string": + return accessStringKind[K](), nil + case "deprecated_string": + return accessDeprecatedStringKind[K](), nil + default: + return nil, fmt.Errorf("invalid span path expression %v", nextPath.Name()) + } + } else { return accessKind[K](), nil } - if path[1].Name == "string" { - return accessStringKind[K](), nil - } - if path[1].Name == "deprecated_string" { - return accessDeprecatedStringKind[K](), nil - } case "start_time_unix_nano": return accessStartTimeUnixNano[K](), nil case "end_time_unix_nano": @@ -87,7 +93,7 @@ func SpanPathGetSetter[K SpanContext](path []ottl.Field) (ottl.GetSetter[K], err case "end_time": return accessEndTime[K](), nil case "attributes": - mapKeys := path[0].Keys + mapKeys := path.Key() if mapKeys == nil { return accessAttributes[K](), nil } @@ -103,17 +109,20 @@ func SpanPathGetSetter[K SpanContext](path []ottl.Field) (ottl.GetSetter[K], err case "dropped_links_count": return accessDroppedLinksCount[K](), nil case "status": - if len(path) == 1 { + nextPath := path.Next() + if nextPath != nil { + switch nextPath.Name() { + case "code": + return accessStatusCode[K](), nil + case "message": + return accessStatusMessage[K](), nil + default: + return nil, fmt.Errorf("invalid span path expression %v", nextPath.Name()) + } + } else { return accessStatus[K](), nil } - switch path[1].Name { - case "code": - return accessStatusCode[K](), nil - case "message": - return accessStatusMessage[K](), nil - } } - return nil, fmt.Errorf("invalid span path expression %v", path) } @@ -211,27 +220,35 @@ func accessTraceState[K SpanContext]() ottl.StandardGetSetter[K] { } } -func accessTraceStateKey[K SpanContext](keys []ottl.Key) (ottl.StandardGetSetter[K], error) { - if len(keys) != 1 { +func accessTraceStateKey[K SpanContext](keys ottl.Key[K]) (ottl.StandardGetSetter[K], error) { + if keys.Next() != nil { return ottl.StandardGetSetter[K]{}, fmt.Errorf("must provide exactly 1 key when accessing trace_state") } - if keys[0].String == nil { - return ottl.StandardGetSetter[K]{}, fmt.Errorf("trace_state indexing type must be a string") - } return ottl.StandardGetSetter[K]{ Getter: func(ctx context.Context, tCtx K) (any, error) { if ts, err := trace.ParseTraceState(tCtx.GetSpan().TraceState().AsRaw()); err == nil { - if keys[0].String == nil { + s, err := keys.String(ctx, tCtx) + if err != nil { return nil, err } - return ts.Get(*keys[0].String), nil + if s == nil { + return nil, fmt.Errorf("trace_state indexing type must be a string") + } + return ts.Get(*s), nil } return nil, nil }, Setter: func(ctx context.Context, tCtx K, val any) error { if str, ok := val.(string); ok { if ts, err := trace.ParseTraceState(tCtx.GetSpan().TraceState().AsRaw()); err == nil { - if updated, err := ts.Insert(*keys[0].String, str); err == nil { + s, err := keys.String(ctx, tCtx) + if err != nil { + return err + } + if s == nil { + return fmt.Errorf("trace_state indexing type must be a string") + } + if updated, err := ts.Insert(*s, str); err == nil { tCtx.GetSpan().TraceState().FromRaw(updated.String()) } } @@ -434,13 +451,13 @@ func accessAttributes[K SpanContext]() ottl.StandardGetSetter[K] { } } -func accessAttributesKey[K SpanContext](keys []ottl.Key) ottl.StandardGetSetter[K] { +func accessAttributesKey[K SpanContext](keys ottl.Key[K]) ottl.StandardGetSetter[K] { return ottl.StandardGetSetter[K]{ Getter: func(ctx context.Context, tCtx K) (any, error) { - return GetMapValue(tCtx.GetSpan().Attributes(), keys) + return GetMapValue[K](ctx, tCtx, tCtx.GetSpan().Attributes(), keys) }, Setter: func(ctx context.Context, tCtx K, val any) error { - return SetMapValue(tCtx.GetSpan().Attributes(), keys, val) + return SetMapValue[K](ctx, tCtx, tCtx.GetSpan().Attributes(), keys, val) }, } } diff --git a/pkg/ottl/contexts/internal/span_test.go b/pkg/ottl/contexts/internal/span_test.go index 6ccbf92e4a93..a0c695944d4d 100644 --- a/pkg/ottl/contexts/internal/span_test.go +++ b/pkg/ottl/contexts/internal/span_test.go @@ -41,17 +41,15 @@ func TestSpanPathGetSetter(t *testing.T) { tests := []struct { name string - path []ottl.Field + path ottl.Path[*spanContext] orig any newVal any modified func(span ptrace.Span) }{ { name: "trace_id", - path: []ottl.Field{ - { - Name: "trace_id", - }, + path: &TestPath[*spanContext]{ + N: "trace_id", }, orig: pcommon.TraceID(traceID), newVal: pcommon.TraceID(traceID2), @@ -61,10 +59,8 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "span_id", - path: []ottl.Field{ - { - Name: "span_id", - }, + path: &TestPath[*spanContext]{ + N: "span_id", }, orig: pcommon.SpanID(spanID), newVal: pcommon.SpanID(spanID2), @@ -74,12 +70,10 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "trace_id string", - path: []ottl.Field{ - { - Name: "trace_id", - }, - { - Name: "string", + path: &TestPath[*spanContext]{ + N: "trace_id", + NextPath: &TestPath[*spanContext]{ + N: "string", }, }, orig: hex.EncodeToString(traceID[:]), @@ -90,12 +84,10 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "span_id string", - path: []ottl.Field{ - { - Name: "span_id", - }, - { - Name: "string", + path: &TestPath[*spanContext]{ + N: "span_id", + NextPath: &TestPath[*spanContext]{ + N: "string", }, }, orig: hex.EncodeToString(spanID[:]), @@ -106,10 +98,8 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "trace_state", - path: []ottl.Field{ - { - Name: "trace_state", - }, + path: &TestPath[*spanContext]{ + N: "trace_state", }, orig: "key1=val1,key2=val2", newVal: "key=newVal", @@ -119,14 +109,10 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "trace_state key", - path: []ottl.Field{ - { - Name: "trace_state", - Keys: []ottl.Key{ - { - String: ottltest.Strp("key1"), - }, - }, + path: &TestPath[*spanContext]{ + N: "trace_state", + Keys: &TestKey[*spanContext]{ + S: ottltest.Strp("key1"), }, }, orig: "val1", @@ -137,10 +123,8 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "parent_span_id", - path: []ottl.Field{ - { - Name: "parent_span_id", - }, + path: &TestPath[*spanContext]{ + N: "parent_span_id", }, orig: pcommon.SpanID(spanID2), newVal: pcommon.SpanID(spanID), @@ -150,12 +134,10 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "parent_span_id string", - path: []ottl.Field{ - { - Name: "parent_span_id", - }, - { - Name: "string", + path: &TestPath[*spanContext]{ + N: "parent_span_id", + NextPath: &TestPath[*spanContext]{ + N: "string", }, }, orig: hex.EncodeToString(spanID2[:]), @@ -166,10 +148,8 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "name", - path: []ottl.Field{ - { - Name: "name", - }, + path: &TestPath[*spanContext]{ + N: "name", }, orig: "bear", newVal: "cat", @@ -179,10 +159,8 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "kind", - path: []ottl.Field{ - { - Name: "kind", - }, + path: &TestPath[*spanContext]{ + N: "kind", }, orig: int64(2), newVal: int64(3), @@ -192,12 +170,10 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "string kind", - path: []ottl.Field{ - { - Name: "kind", - }, - { - Name: "string", + path: &TestPath[*spanContext]{ + N: "kind", + NextPath: &TestPath[*spanContext]{ + N: "string", }, }, orig: "Server", @@ -208,12 +184,10 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "deprecated string kind", - path: []ottl.Field{ - { - Name: "kind", - }, - { - Name: "deprecated_string", + path: &TestPath[*spanContext]{ + N: "kind", + NextPath: &TestPath[*spanContext]{ + N: "deprecated_string", }, }, orig: "SPAN_KIND_SERVER", @@ -224,10 +198,8 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "start_time_unix_nano", - path: []ottl.Field{ - { - Name: "start_time_unix_nano", - }, + path: &TestPath[*spanContext]{ + N: "start_time_unix_nano", }, orig: int64(100_000_000), newVal: int64(200_000_000), @@ -237,10 +209,8 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "end_time_unix_nano", - path: []ottl.Field{ - { - Name: "end_time_unix_nano", - }, + path: &TestPath[*spanContext]{ + N: "end_time_unix_nano", }, orig: int64(500_000_000), newVal: int64(200_000_000), @@ -250,10 +220,8 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "attributes", - path: []ottl.Field{ - { - Name: "attributes", - }, + path: &TestPath[*spanContext]{ + N: "attributes", }, orig: refSpan.Attributes(), newVal: newAttrs, @@ -263,14 +231,10 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "attributes string", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("str"), - }, - }, + path: &TestPath[*spanContext]{ + N: "attributes", + Keys: &TestKey[*spanContext]{ + S: ottltest.Strp("str"), }, }, orig: "val", @@ -281,14 +245,10 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "attributes bool", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("bool"), - }, - }, + path: &TestPath[*spanContext]{ + N: "attributes", + Keys: &TestKey[*spanContext]{ + S: ottltest.Strp("bool"), }, }, orig: true, @@ -299,14 +259,10 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "attributes int", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("int"), - }, - }, + path: &TestPath[*spanContext]{ + N: "attributes", + Keys: &TestKey[*spanContext]{ + S: ottltest.Strp("int"), }, }, orig: int64(10), @@ -317,14 +273,10 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "attributes float", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("double"), - }, - }, + path: &TestPath[*spanContext]{ + N: "attributes", + Keys: &TestKey[*spanContext]{ + S: ottltest.Strp("double"), }, }, orig: float64(1.2), @@ -335,14 +287,10 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "attributes bytes", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("bytes"), - }, - }, + path: &TestPath[*spanContext]{ + N: "attributes", + Keys: &TestKey[*spanContext]{ + S: ottltest.Strp("bytes"), }, }, orig: []byte{1, 3, 2}, @@ -353,14 +301,10 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "attributes array empty", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_empty"), - }, - }, + path: &TestPath[*spanContext]{ + N: "attributes", + Keys: &TestKey[*spanContext]{ + S: ottltest.Strp("arr_empty"), }, }, orig: func() pcommon.Slice { @@ -374,14 +318,10 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "attributes array string", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_str"), - }, - }, + path: &TestPath[*spanContext]{ + N: "attributes", + Keys: &TestKey[*spanContext]{ + S: ottltest.Strp("arr_str"), }, }, orig: func() pcommon.Slice { @@ -395,14 +335,10 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "attributes array bool", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_bool"), - }, - }, + path: &TestPath[*spanContext]{ + N: "attributes", + Keys: &TestKey[*spanContext]{ + S: ottltest.Strp("arr_bool"), }, }, orig: func() pcommon.Slice { @@ -416,14 +352,10 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "attributes array int", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_int"), - }, - }, + path: &TestPath[*spanContext]{ + N: "attributes", + Keys: &TestKey[*spanContext]{ + S: ottltest.Strp("arr_int"), }, }, orig: func() pcommon.Slice { @@ -437,14 +369,10 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "attributes array float", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_float"), - }, - }, + path: &TestPath[*spanContext]{ + N: "attributes", + Keys: &TestKey[*spanContext]{ + S: ottltest.Strp("arr_float"), }, }, orig: func() pcommon.Slice { @@ -458,14 +386,10 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "attributes array bytes", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_bytes"), - }, - }, + path: &TestPath[*spanContext]{ + N: "attributes", + Keys: &TestKey[*spanContext]{ + S: ottltest.Strp("arr_bytes"), }, }, orig: func() pcommon.Slice { @@ -479,18 +403,14 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "attributes nested", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("slice"), - }, - { - Int: ottltest.Intp(0), - }, - { - String: ottltest.Strp("map"), + path: &TestPath[*spanContext]{ + N: "attributes", + Keys: &TestKey[*spanContext]{ + S: ottltest.Strp("slice"), + NextKey: &TestKey[*spanContext]{ + I: ottltest.Intp(0), + NextKey: &TestKey[*spanContext]{ + S: ottltest.Strp("map"), }, }, }, @@ -507,18 +427,14 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "attributes nested new values", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("new"), - }, - { - Int: ottltest.Intp(2), - }, - { - Int: ottltest.Intp(0), + path: &TestPath[*spanContext]{ + N: "attributes", + Keys: &TestKey[*spanContext]{ + S: ottltest.Strp("new"), + NextKey: &TestKey[*spanContext]{ + I: ottltest.Intp(2), + NextKey: &TestKey[*spanContext]{ + I: ottltest.Intp(0), }, }, }, @@ -536,10 +452,8 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "dropped_attributes_count", - path: []ottl.Field{ - { - Name: "dropped_attributes_count", - }, + path: &TestPath[*spanContext]{ + N: "dropped_attributes_count", }, orig: int64(10), newVal: int64(20), @@ -549,10 +463,8 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "events", - path: []ottl.Field{ - { - Name: "events", - }, + path: &TestPath[*spanContext]{ + N: "events", }, orig: refSpan.Events(), newVal: newEvents, @@ -565,10 +477,8 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "dropped_events_count", - path: []ottl.Field{ - { - Name: "dropped_events_count", - }, + path: &TestPath[*spanContext]{ + N: "dropped_events_count", }, orig: int64(20), newVal: int64(30), @@ -578,10 +488,8 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "links", - path: []ottl.Field{ - { - Name: "links", - }, + path: &TestPath[*spanContext]{ + N: "links", }, orig: refSpan.Links(), newVal: newLinks, @@ -594,10 +502,8 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "dropped_links_count", - path: []ottl.Field{ - { - Name: "dropped_links_count", - }, + path: &TestPath[*spanContext]{ + N: "dropped_links_count", }, orig: int64(30), newVal: int64(40), @@ -607,10 +513,8 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "status", - path: []ottl.Field{ - { - Name: "status", - }, + path: &TestPath[*spanContext]{ + N: "status", }, orig: refSpan.Status(), newVal: newStatus, @@ -620,12 +524,10 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "status code", - path: []ottl.Field{ - { - Name: "status", - }, - { - Name: "code", + path: &TestPath[*spanContext]{ + N: "status", + NextPath: &TestPath[*spanContext]{ + N: "code", }, }, orig: int64(ptrace.StatusCodeOk), @@ -636,12 +538,10 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "status message", - path: []ottl.Field{ - { - Name: "status", - }, - { - Name: "message", + path: &TestPath[*spanContext]{ + N: "status", + NextPath: &TestPath[*spanContext]{ + N: "message", }, }, orig: "good span", @@ -652,10 +552,8 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "start_time", - path: []ottl.Field{ - { - Name: "start_time", - }, + path: &TestPath[*spanContext]{ + N: "start_time", }, orig: time.Date(1970, 1, 1, 0, 0, 0, 100000000, time.UTC), newVal: time.Date(1970, 1, 1, 0, 0, 0, 200000000, time.UTC), @@ -665,10 +563,8 @@ func TestSpanPathGetSetter(t *testing.T) { }, { name: "end_time", - path: []ottl.Field{ - { - Name: "end_time", - }, + path: &TestPath[*spanContext]{ + N: "end_time", }, orig: time.Date(1970, 1, 1, 0, 0, 0, 500000000, time.UTC), newVal: time.Date(1970, 1, 1, 0, 0, 0, 200000000, time.UTC), diff --git a/pkg/ottl/contexts/internal/value.go b/pkg/ottl/contexts/internal/value.go index 24df36d9783a..ccd96f2befc2 100644 --- a/pkg/ottl/contexts/internal/value.go +++ b/pkg/ottl/contexts/internal/value.go @@ -4,6 +4,7 @@ package internal // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/internal" import ( + "context" "errors" "fmt" @@ -62,43 +63,49 @@ func SetValue(value pcommon.Value, val any) error { case pcommon.Map: v.CopyTo(value.SetEmptyMap()) case map[string]any: - value.SetEmptyMap() - for mk, mv := range v { - err = SetMapValue(value.Map(), []ottl.Key{{String: &mk}}, mv) - } + err = value.FromRaw(v) } return err } -func getIndexableValue(value pcommon.Value, keys []ottl.Key) (any, error) { - val := value +func getIndexableValue[K any](ctx context.Context, tCtx K, value pcommon.Value, key ottl.Key[K]) (any, error) { + val, currentKey := value, key var ok bool - for i := 0; i < len(keys); i++ { + for currentKey != nil { switch val.Type() { case pcommon.ValueTypeMap: - if keys[i].String == nil { + s, err := currentKey.String(ctx, tCtx) + if err != nil { + return nil, err + } + if s == nil { return nil, fmt.Errorf("map must be indexed by a string") } - val, ok = val.Map().Get(*keys[i].String) + val, ok = val.Map().Get(*s) if !ok { return nil, nil } case pcommon.ValueTypeSlice: - if keys[i].Int == nil { + i, err := currentKey.Int(ctx, tCtx) + if err != nil { + return nil, err + } + if i == nil { return nil, fmt.Errorf("slice must be indexed by an int") } - if int(*keys[i].Int) >= val.Slice().Len() || int(*keys[i].Int) < 0 { - return nil, fmt.Errorf("index %v out of bounds", *keys[i].Int) + if int(*i) >= val.Slice().Len() || int(*i) < 0 { + return nil, fmt.Errorf("index %v out of bounds", *i) } - val = val.Slice().At(int(*keys[i].Int)) + val = val.Slice().At(int(*i)) default: return nil, fmt.Errorf("type %v does not support string indexing", val.Type()) } + currentKey = currentKey.Next() } return ottlcommon.GetValue(val), nil } -func setIndexableValue(currentValue pcommon.Value, val any, keys []ottl.Key) error { +func setIndexableValue[K any](ctx context.Context, tCtx K, currentValue pcommon.Value, val any, key ottl.Key[K]) error { var newValue pcommon.Value switch val.(type) { case []string, []bool, []int64, []float64, [][]byte, []any: @@ -111,33 +118,50 @@ func setIndexableValue(currentValue pcommon.Value, val any, keys []ottl.Key) err return err } - for i := 0; i < len(keys); i++ { + currentKey := key + for currentKey != nil { switch currentValue.Type() { case pcommon.ValueTypeMap: - if keys[i].String == nil { + s, err := currentKey.String(ctx, tCtx) + if err != nil { + return err + } + if s == nil { return errors.New("map must be indexed by a string") } - potentialValue, ok := currentValue.Map().Get(*keys[i].String) + potentialValue, ok := currentValue.Map().Get(*s) if !ok { - currentValue = currentValue.Map().PutEmpty(*keys[i].String) + currentValue = currentValue.Map().PutEmpty(*s) } else { currentValue = potentialValue } case pcommon.ValueTypeSlice: - if keys[i].Int == nil { + i, err := currentKey.Int(ctx, tCtx) + if err != nil { + return err + } + if i == nil { return errors.New("slice must be indexed by an int") } - if int(*keys[i].Int) >= currentValue.Slice().Len() || int(*keys[i].Int) < 0 { - return fmt.Errorf("index %v out of bounds", *keys[i].Int) + if int(*i) >= currentValue.Slice().Len() || int(*i) < 0 { + return fmt.Errorf("index %v out of bounds", *i) } - currentValue = currentValue.Slice().At(int(*keys[i].Int)) + currentValue = currentValue.Slice().At(int(*i)) case pcommon.ValueTypeEmpty: + s, err := currentKey.String(ctx, tCtx) + if err != nil { + return err + } + i, err := currentKey.Int(ctx, tCtx) + if err != nil { + return err + } switch { - case keys[i].String != nil: - currentValue = currentValue.SetEmptyMap().PutEmpty(*keys[i].String) - case keys[i].Int != nil: + case s != nil: + currentValue = currentValue.SetEmptyMap().PutEmpty(*s) + case i != nil: currentValue.SetEmptySlice() - for k := 0; k < int(*keys[i].Int); k++ { + for k := 0; k < int(*i); k++ { currentValue.Slice().AppendEmpty() } currentValue = currentValue.Slice().AppendEmpty() @@ -147,6 +171,7 @@ func setIndexableValue(currentValue pcommon.Value, val any, keys []ottl.Key) err default: return fmt.Errorf("type %v does not support string indexing", currentValue.Type()) } + currentKey = currentKey.Next() } newValue.CopyTo(currentValue) return nil diff --git a/pkg/ottl/contexts/internal/value_test.go b/pkg/ottl/contexts/internal/value_test.go index ca3aa95442c7..df7c77362a02 100644 --- a/pkg/ottl/contexts/internal/value_test.go +++ b/pkg/ottl/contexts/internal/value_test.go @@ -4,18 +4,15 @@ package internal // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/internal" import ( + "context" "testing" "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/pcommon" - - "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl" ) func Test_SetIndexableValue_EmptyValueNoIndex(t *testing.T) { - keys := []ottl.Key{ - {}, - } - err := setIndexableValue(pcommon.NewValueEmpty(), nil, keys) + keys := TestKey[any]{} + err := setIndexableValue[any](context.Background(), nil, pcommon.NewValueEmpty(), nil, &keys) assert.Error(t, err) } diff --git a/pkg/ottl/contexts/ottldatapoint/datapoint.go b/pkg/ottl/contexts/ottldatapoint/datapoint.go index d2f432a2bb20..c977abfff037 100644 --- a/pkg/ottl/contexts/ottldatapoint/datapoint.go +++ b/pkg/ottl/contexts/ottldatapoint/datapoint.go @@ -66,10 +66,10 @@ func (tCtx TransformContext) getCache() pcommon.Map { } func NewParser(functions map[string]ottl.Factory[TransformContext], telemetrySettings component.TelemetrySettings, options ...Option) (ottl.Parser[TransformContext], error) { - pathExpressionParser := pathExpressionParser{telemetrySettings} + pep := pathExpressionParser{telemetrySettings} p, err := ottl.NewParser[TransformContext]( functions, - pathExpressionParser.parsePath, + pep.parsePath, telemetrySettings, ottl.WithEnumParser[TransformContext](parseEnum), ) @@ -139,33 +139,27 @@ type pathExpressionParser struct { telemetrySettings component.TelemetrySettings } -func (pep *pathExpressionParser) parsePath(val *ottl.Path) (ottl.GetSetter[TransformContext], error) { - if val != nil && len(val.Fields) > 0 { - return newPathGetSetter(val.Fields) +func (pep *pathExpressionParser) parsePath(path ottl.Path[TransformContext]) (ottl.GetSetter[TransformContext], error) { + if path == nil { + return nil, fmt.Errorf("path cannot be nil") } - return nil, fmt.Errorf("bad path %v", val) -} - -func newPathGetSetter(path []ottl.Field) (ottl.GetSetter[TransformContext], error) { - switch path[0].Name { + switch path.Name() { case "cache": - mapKey := path[0].Keys - if mapKey == nil { + if path.Key() == nil { return accessCache(), nil } - return accessCacheKey(mapKey), nil + return accessCacheKey(path.Key()), nil case "resource": - return internal.ResourcePathGetSetter[TransformContext](path[1:]) + return internal.ResourcePathGetSetter[TransformContext](path.Next()) case "instrumentation_scope": - return internal.ScopePathGetSetter[TransformContext](path[1:]) + return internal.ScopePathGetSetter[TransformContext](path.Next()) case "metric": - return internal.MetricPathGetSetter[TransformContext](path[1:]) + return internal.MetricPathGetSetter[TransformContext](path.Next()) case "attributes": - mapKey := path[0].Keys - if mapKey == nil { + if path.Key() == nil { return accessAttributes(), nil } - return accessAttributesKey(mapKey), nil + return accessAttributesKey(path.Key()), nil case "start_time_unix_nano": return accessStartTimeUnixNano(), nil case "time_unix_nano": @@ -195,25 +189,33 @@ func newPathGetSetter(path []ottl.Field) (ottl.GetSetter[TransformContext], erro case "zero_count": return accessZeroCount(), nil case "positive": - if len(path) == 1 { + nextPath := path.Next() + if nextPath != nil { + switch nextPath.Name() { + case "offset": + return accessPositiveOffset(), nil + case "bucket_counts": + return accessPositiveBucketCounts(), nil + default: + return nil, fmt.Errorf("invalid span path expression %v", nextPath.Name()) + } + } else { return accessPositive(), nil } - switch path[1].Name { - case "offset": - return accessPositiveOffset(), nil - case "bucket_counts": - return accessPositiveBucketCounts(), nil - } case "negative": - if len(path) == 1 { + nextPath := path.Next() + if nextPath != nil { + switch nextPath.Name() { + case "offset": + return accessNegativeOffset(), nil + case "bucket_counts": + return accessNegativeBucketCounts(), nil + default: + return nil, fmt.Errorf("invalid span path expression %v", nextPath.Name()) + } + } else { return accessNegative(), nil } - switch path[1].Name { - case "offset": - return accessNegativeOffset(), nil - case "bucket_counts": - return accessNegativeBucketCounts(), nil - } case "quantile_values": return accessQuantileValues(), nil } @@ -234,13 +236,13 @@ func accessCache() ottl.StandardGetSetter[TransformContext] { } } -func accessCacheKey(keys []ottl.Key) ottl.StandardGetSetter[TransformContext] { +func accessCacheKey(key ottl.Key[TransformContext]) ottl.StandardGetSetter[TransformContext] { return ottl.StandardGetSetter[TransformContext]{ Getter: func(ctx context.Context, tCtx TransformContext) (any, error) { - return internal.GetMapValue(tCtx.getCache(), keys) + return internal.GetMapValue[TransformContext](ctx, tCtx, tCtx.getCache(), key) }, Setter: func(ctx context.Context, tCtx TransformContext, val any) error { - return internal.SetMapValue(tCtx.getCache(), keys, val) + return internal.SetMapValue[TransformContext](ctx, tCtx, tCtx.getCache(), key, val) }, } } @@ -284,31 +286,31 @@ func accessAttributes() ottl.StandardGetSetter[TransformContext] { } } -func accessAttributesKey(keys []ottl.Key) ottl.StandardGetSetter[TransformContext] { +func accessAttributesKey(key ottl.Key[TransformContext]) ottl.StandardGetSetter[TransformContext] { return ottl.StandardGetSetter[TransformContext]{ Getter: func(ctx context.Context, tCtx TransformContext) (any, error) { switch tCtx.GetDataPoint().(type) { case pmetric.NumberDataPoint: - return internal.GetMapValue(tCtx.GetDataPoint().(pmetric.NumberDataPoint).Attributes(), keys) + return internal.GetMapValue[TransformContext](ctx, tCtx, tCtx.GetDataPoint().(pmetric.NumberDataPoint).Attributes(), key) case pmetric.HistogramDataPoint: - return internal.GetMapValue(tCtx.GetDataPoint().(pmetric.HistogramDataPoint).Attributes(), keys) + return internal.GetMapValue[TransformContext](ctx, tCtx, tCtx.GetDataPoint().(pmetric.HistogramDataPoint).Attributes(), key) case pmetric.ExponentialHistogramDataPoint: - return internal.GetMapValue(tCtx.GetDataPoint().(pmetric.ExponentialHistogramDataPoint).Attributes(), keys) + return internal.GetMapValue[TransformContext](ctx, tCtx, tCtx.GetDataPoint().(pmetric.ExponentialHistogramDataPoint).Attributes(), key) case pmetric.SummaryDataPoint: - return internal.GetMapValue(tCtx.GetDataPoint().(pmetric.SummaryDataPoint).Attributes(), keys) + return internal.GetMapValue[TransformContext](ctx, tCtx, tCtx.GetDataPoint().(pmetric.SummaryDataPoint).Attributes(), key) } return nil, nil }, Setter: func(ctx context.Context, tCtx TransformContext, val any) error { switch tCtx.GetDataPoint().(type) { case pmetric.NumberDataPoint: - return internal.SetMapValue(tCtx.GetDataPoint().(pmetric.NumberDataPoint).Attributes(), keys, val) + return internal.SetMapValue[TransformContext](ctx, tCtx, tCtx.GetDataPoint().(pmetric.NumberDataPoint).Attributes(), key, val) case pmetric.HistogramDataPoint: - return internal.SetMapValue(tCtx.GetDataPoint().(pmetric.HistogramDataPoint).Attributes(), keys, val) + return internal.SetMapValue[TransformContext](ctx, tCtx, tCtx.GetDataPoint().(pmetric.HistogramDataPoint).Attributes(), key, val) case pmetric.ExponentialHistogramDataPoint: - return internal.SetMapValue(tCtx.GetDataPoint().(pmetric.ExponentialHistogramDataPoint).Attributes(), keys, val) + return internal.SetMapValue[TransformContext](ctx, tCtx, tCtx.GetDataPoint().(pmetric.ExponentialHistogramDataPoint).Attributes(), key, val) case pmetric.SummaryDataPoint: - return internal.SetMapValue(tCtx.GetDataPoint().(pmetric.SummaryDataPoint).Attributes(), keys, val) + return internal.SetMapValue[TransformContext](ctx, tCtx, tCtx.GetDataPoint().(pmetric.SummaryDataPoint).Attributes(), key, val) } return nil }, diff --git a/pkg/ottl/contexts/ottldatapoint/datapoint_test.go b/pkg/ottl/contexts/ottldatapoint/datapoint_test.go index bac2de90d839..3c26db075b25 100644 --- a/pkg/ottl/contexts/ottldatapoint/datapoint_test.go +++ b/pkg/ottl/contexts/ottldatapoint/datapoint_test.go @@ -13,6 +13,7 @@ import ( "go.opentelemetry.io/collector/pdata/pmetric" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/internal" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/ottltest" ) @@ -22,19 +23,16 @@ func Test_newPathGetSetter_Cache(t *testing.T) { tests := []struct { name string - path []ottl.Field + path ottl.Path[TransformContext] orig any newVal any modified func(cache pcommon.Map) valueType pmetric.NumberDataPointValueType }{ - { name: "cache", - path: []ottl.Field{ - { - Name: "cache", - }, + path: &internal.TestPath[TransformContext]{ + N: "cache", }, orig: pcommon.NewMap(), newVal: newCache, @@ -44,14 +42,10 @@ func Test_newPathGetSetter_Cache(t *testing.T) { }, { name: "cache access", - path: []ottl.Field{ - { - Name: "cache", - Keys: []ottl.Key{ - { - String: ottltest.Strp("temp"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "cache", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("temp"), }, }, orig: nil, @@ -63,7 +57,8 @@ func Test_newPathGetSetter_Cache(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - accessor, err := newPathGetSetter(tt.path) + pep := pathExpressionParser{} + accessor, err := pep.parsePath(tt.path) assert.NoError(t, err) numberDataPoint := createNumberDataPointTelemetry(tt.valueType) @@ -101,7 +96,7 @@ func Test_newPathGetSetter_NumberDataPoint(t *testing.T) { tests := []struct { name string - path []ottl.Field + path ottl.Path[TransformContext] orig any newVal any modified func(pmetric.NumberDataPoint) @@ -109,10 +104,8 @@ func Test_newPathGetSetter_NumberDataPoint(t *testing.T) { }{ { name: "start_time_unix_nano", - path: []ottl.Field{ - { - Name: "start_time_unix_nano", - }, + path: &internal.TestPath[TransformContext]{ + N: "start_time_unix_nano", }, orig: int64(100_000_000), newVal: int64(200_000_000), @@ -122,10 +115,8 @@ func Test_newPathGetSetter_NumberDataPoint(t *testing.T) { }, { name: "start_time", - path: []ottl.Field{ - { - Name: "start_time", - }, + path: &internal.TestPath[TransformContext]{ + N: "start_time", }, orig: time.Date(1970, 1, 1, 0, 0, 0, 100000000, time.UTC), newVal: time.Date(1970, 1, 1, 0, 0, 0, 86400000000000, time.UTC), @@ -135,10 +126,8 @@ func Test_newPathGetSetter_NumberDataPoint(t *testing.T) { }, { name: "time", - path: []ottl.Field{ - { - Name: "time", - }, + path: &internal.TestPath[TransformContext]{ + N: "time", }, orig: time.Date(1970, 1, 1, 0, 0, 0, 500000000, time.UTC), newVal: time.Date(1970, 1, 1, 0, 0, 0, 200000000, time.UTC), @@ -148,10 +137,8 @@ func Test_newPathGetSetter_NumberDataPoint(t *testing.T) { }, { name: "time_unix_nano", - path: []ottl.Field{ - { - Name: "time_unix_nano", - }, + path: &internal.TestPath[TransformContext]{ + N: "time_unix_nano", }, orig: int64(500_000_000), newVal: int64(200_000_000), @@ -161,10 +148,8 @@ func Test_newPathGetSetter_NumberDataPoint(t *testing.T) { }, { name: "value_double", - path: []ottl.Field{ - { - Name: "value_double", - }, + path: &internal.TestPath[TransformContext]{ + N: "value_double", }, orig: 1.1, newVal: 2.2, @@ -175,10 +160,8 @@ func Test_newPathGetSetter_NumberDataPoint(t *testing.T) { }, { name: "value_int", - path: []ottl.Field{ - { - Name: "value_int", - }, + path: &internal.TestPath[TransformContext]{ + N: "value_int", }, orig: int64(1), newVal: int64(2), @@ -188,10 +171,8 @@ func Test_newPathGetSetter_NumberDataPoint(t *testing.T) { }, { name: "flags", - path: []ottl.Field{ - { - Name: "flags", - }, + path: &internal.TestPath[TransformContext]{ + N: "flags", }, orig: int64(0), newVal: int64(1), @@ -201,10 +182,8 @@ func Test_newPathGetSetter_NumberDataPoint(t *testing.T) { }, { name: "exemplars", - path: []ottl.Field{ - { - Name: "exemplars", - }, + path: &internal.TestPath[TransformContext]{ + N: "exemplars", }, orig: refNumberDataPoint.Exemplars(), newVal: newExemplars, @@ -214,10 +193,8 @@ func Test_newPathGetSetter_NumberDataPoint(t *testing.T) { }, { name: "attributes", - path: []ottl.Field{ - { - Name: "attributes", - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", }, orig: refNumberDataPoint.Attributes(), newVal: newAttrs, @@ -227,14 +204,10 @@ func Test_newPathGetSetter_NumberDataPoint(t *testing.T) { }, { name: "attributes string", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("str"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("str"), }, }, orig: "val", @@ -245,14 +218,10 @@ func Test_newPathGetSetter_NumberDataPoint(t *testing.T) { }, { name: "attributes bool", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("bool"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("bool"), }, }, orig: true, @@ -263,14 +232,10 @@ func Test_newPathGetSetter_NumberDataPoint(t *testing.T) { }, { name: "attributes int", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("int"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("int"), }, }, orig: int64(10), @@ -281,14 +246,10 @@ func Test_newPathGetSetter_NumberDataPoint(t *testing.T) { }, { name: "attributes float", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("double"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("double"), }, }, orig: float64(1.2), @@ -299,14 +260,10 @@ func Test_newPathGetSetter_NumberDataPoint(t *testing.T) { }, { name: "attributes bytes", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("bytes"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("bytes"), }, }, orig: []byte{1, 3, 2}, @@ -317,14 +274,10 @@ func Test_newPathGetSetter_NumberDataPoint(t *testing.T) { }, { name: "attributes array string", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_str"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_str"), }, }, orig: func() pcommon.Slice { @@ -338,14 +291,10 @@ func Test_newPathGetSetter_NumberDataPoint(t *testing.T) { }, { name: "attributes array bool", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_bool"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_bool"), }, }, orig: func() pcommon.Slice { @@ -359,14 +308,10 @@ func Test_newPathGetSetter_NumberDataPoint(t *testing.T) { }, { name: "attributes array int", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_int"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_int"), }, }, orig: func() pcommon.Slice { @@ -380,14 +325,10 @@ func Test_newPathGetSetter_NumberDataPoint(t *testing.T) { }, { name: "attributes array float", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_float"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_float"), }, }, orig: func() pcommon.Slice { @@ -401,14 +342,10 @@ func Test_newPathGetSetter_NumberDataPoint(t *testing.T) { }, { name: "attributes array bytes", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_bytes"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_bytes"), }, }, orig: func() pcommon.Slice { @@ -422,14 +359,10 @@ func Test_newPathGetSetter_NumberDataPoint(t *testing.T) { }, { name: "attributes pcommon.Map", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("pMap"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("pMap"), }, }, orig: func() pcommon.Map { @@ -445,14 +378,10 @@ func Test_newPathGetSetter_NumberDataPoint(t *testing.T) { }, { name: "attributes map[string]any", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("map"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("map"), }, }, orig: func() pcommon.Map { @@ -468,18 +397,14 @@ func Test_newPathGetSetter_NumberDataPoint(t *testing.T) { }, { name: "attributes nested", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("slice"), - }, - { - Int: ottltest.Intp(0), - }, - { - String: ottltest.Strp("map"), + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("slice"), + NextKey: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(0), + NextKey: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("map"), }, }, }, @@ -496,18 +421,14 @@ func Test_newPathGetSetter_NumberDataPoint(t *testing.T) { }, { name: "attributes nested new values", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("new"), - }, - { - Int: ottltest.Intp(2), - }, - { - Int: ottltest.Intp(0), + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("new"), + NextKey: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(2), + NextKey: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(0), }, }, }, @@ -526,7 +447,8 @@ func Test_newPathGetSetter_NumberDataPoint(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - accessor, err := newPathGetSetter(tt.path) + pep := pathExpressionParser{} + accessor, err := pep.parsePath(tt.path) assert.NoError(t, err) numberDataPoint := createNumberDataPointTelemetry(tt.valueType) @@ -583,17 +505,15 @@ func Test_newPathGetSetter_HistogramDataPoint(t *testing.T) { tests := []struct { name string - path []ottl.Field + path ottl.Path[TransformContext] orig any newVal any modified func(pmetric.HistogramDataPoint) }{ { name: "start_time_unix_nano", - path: []ottl.Field{ - { - Name: "start_time_unix_nano", - }, + path: &internal.TestPath[TransformContext]{ + N: "start_time_unix_nano", }, orig: int64(100_000_000), newVal: int64(200_000_000), @@ -603,10 +523,8 @@ func Test_newPathGetSetter_HistogramDataPoint(t *testing.T) { }, { name: "time_unix_nano", - path: []ottl.Field{ - { - Name: "time_unix_nano", - }, + path: &internal.TestPath[TransformContext]{ + N: "time_unix_nano", }, orig: int64(500_000_000), newVal: int64(200_000_000), @@ -616,10 +534,8 @@ func Test_newPathGetSetter_HistogramDataPoint(t *testing.T) { }, { name: "flags", - path: []ottl.Field{ - { - Name: "flags", - }, + path: &internal.TestPath[TransformContext]{ + N: "flags", }, orig: int64(0), newVal: int64(1), @@ -629,10 +545,8 @@ func Test_newPathGetSetter_HistogramDataPoint(t *testing.T) { }, { name: "count", - path: []ottl.Field{ - { - Name: "count", - }, + path: &internal.TestPath[TransformContext]{ + N: "count", }, orig: int64(2), newVal: int64(3), @@ -642,10 +556,8 @@ func Test_newPathGetSetter_HistogramDataPoint(t *testing.T) { }, { name: "sum", - path: []ottl.Field{ - { - Name: "sum", - }, + path: &internal.TestPath[TransformContext]{ + N: "sum", }, orig: 10.1, newVal: 10.2, @@ -655,10 +567,8 @@ func Test_newPathGetSetter_HistogramDataPoint(t *testing.T) { }, { name: "bucket_counts", - path: []ottl.Field{ - { - Name: "bucket_counts", - }, + path: &internal.TestPath[TransformContext]{ + N: "bucket_counts", }, orig: []uint64{1, 1}, newVal: []uint64{1, 2}, @@ -668,10 +578,8 @@ func Test_newPathGetSetter_HistogramDataPoint(t *testing.T) { }, { name: "explicit_bounds", - path: []ottl.Field{ - { - Name: "explicit_bounds", - }, + path: &internal.TestPath[TransformContext]{ + N: "explicit_bounds", }, orig: []float64{1, 2}, newVal: []float64{1, 2, 3}, @@ -681,10 +589,8 @@ func Test_newPathGetSetter_HistogramDataPoint(t *testing.T) { }, { name: "exemplars", - path: []ottl.Field{ - { - Name: "exemplars", - }, + path: &internal.TestPath[TransformContext]{ + N: "exemplars", }, orig: refHistogramDataPoint.Exemplars(), newVal: newExemplars, @@ -694,10 +600,8 @@ func Test_newPathGetSetter_HistogramDataPoint(t *testing.T) { }, { name: "attributes", - path: []ottl.Field{ - { - Name: "attributes", - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", }, orig: refHistogramDataPoint.Attributes(), newVal: newAttrs, @@ -707,14 +611,10 @@ func Test_newPathGetSetter_HistogramDataPoint(t *testing.T) { }, { name: "attributes string", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("str"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("str"), }, }, orig: "val", @@ -725,14 +625,10 @@ func Test_newPathGetSetter_HistogramDataPoint(t *testing.T) { }, { name: "attributes bool", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("bool"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("bool"), }, }, orig: true, @@ -743,14 +639,10 @@ func Test_newPathGetSetter_HistogramDataPoint(t *testing.T) { }, { name: "attributes int", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("int"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("int"), }, }, orig: int64(10), @@ -761,14 +653,10 @@ func Test_newPathGetSetter_HistogramDataPoint(t *testing.T) { }, { name: "attributes float", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("double"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("double"), }, }, orig: float64(1.2), @@ -779,14 +667,10 @@ func Test_newPathGetSetter_HistogramDataPoint(t *testing.T) { }, { name: "attributes bytes", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("bytes"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("bytes"), }, }, orig: []byte{1, 3, 2}, @@ -797,14 +681,10 @@ func Test_newPathGetSetter_HistogramDataPoint(t *testing.T) { }, { name: "attributes array string", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_str"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_str"), }, }, orig: func() pcommon.Slice { @@ -818,14 +698,10 @@ func Test_newPathGetSetter_HistogramDataPoint(t *testing.T) { }, { name: "attributes array bool", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_bool"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_bool"), }, }, orig: func() pcommon.Slice { @@ -839,14 +715,10 @@ func Test_newPathGetSetter_HistogramDataPoint(t *testing.T) { }, { name: "attributes array int", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_int"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_int"), }, }, orig: func() pcommon.Slice { @@ -860,14 +732,10 @@ func Test_newPathGetSetter_HistogramDataPoint(t *testing.T) { }, { name: "attributes array float", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_float"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_float"), }, }, orig: func() pcommon.Slice { @@ -881,14 +749,10 @@ func Test_newPathGetSetter_HistogramDataPoint(t *testing.T) { }, { name: "attributes array bytes", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_bytes"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_bytes"), }, }, orig: func() pcommon.Slice { @@ -902,14 +766,10 @@ func Test_newPathGetSetter_HistogramDataPoint(t *testing.T) { }, { name: "attributes pcommon.Map", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("pMap"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("pMap"), }, }, orig: func() pcommon.Map { @@ -925,14 +785,10 @@ func Test_newPathGetSetter_HistogramDataPoint(t *testing.T) { }, { name: "attributes map[string]any", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("map"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("map"), }, }, orig: func() pcommon.Map { @@ -948,18 +804,14 @@ func Test_newPathGetSetter_HistogramDataPoint(t *testing.T) { }, { name: "attributes nested", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("slice"), - }, - { - Int: ottltest.Intp(0), - }, - { - String: ottltest.Strp("map"), + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("slice"), + NextKey: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(0), + NextKey: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("map"), }, }, }, @@ -976,18 +828,14 @@ func Test_newPathGetSetter_HistogramDataPoint(t *testing.T) { }, { name: "attributes nested new values", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("new"), - }, - { - Int: ottltest.Intp(2), - }, - { - Int: ottltest.Intp(0), + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("new"), + NextKey: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(2), + NextKey: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(0), }, }, }, @@ -1006,7 +854,8 @@ func Test_newPathGetSetter_HistogramDataPoint(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - accessor, err := newPathGetSetter(tt.path) + pep := pathExpressionParser{} + accessor, err := pep.parsePath(tt.path) assert.NoError(t, err) histogramDataPoint := createHistogramDataPointTelemetry() @@ -1068,17 +917,15 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { tests := []struct { name string - path []ottl.Field + path ottl.Path[TransformContext] orig any newVal any modified func(pmetric.ExponentialHistogramDataPoint) }{ { name: "start_time_unix_nano", - path: []ottl.Field{ - { - Name: "start_time_unix_nano", - }, + path: &internal.TestPath[TransformContext]{ + N: "start_time_unix_nano", }, orig: int64(100_000_000), newVal: int64(200_000_000), @@ -1088,10 +935,8 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "time_unix_nano", - path: []ottl.Field{ - { - Name: "time_unix_nano", - }, + path: &internal.TestPath[TransformContext]{ + N: "time_unix_nano", }, orig: int64(500_000_000), newVal: int64(200_000_000), @@ -1101,10 +946,8 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "flags", - path: []ottl.Field{ - { - Name: "flags", - }, + path: &internal.TestPath[TransformContext]{ + N: "flags", }, orig: int64(0), newVal: int64(1), @@ -1114,10 +957,8 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "count", - path: []ottl.Field{ - { - Name: "count", - }, + path: &internal.TestPath[TransformContext]{ + N: "count", }, orig: int64(2), newVal: int64(3), @@ -1127,10 +968,8 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "sum", - path: []ottl.Field{ - { - Name: "sum", - }, + path: &internal.TestPath[TransformContext]{ + N: "sum", }, orig: 10.1, newVal: 10.2, @@ -1140,10 +979,8 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "scale", - path: []ottl.Field{ - { - Name: "scale", - }, + path: &internal.TestPath[TransformContext]{ + N: "scale", }, orig: int64(1), newVal: int64(2), @@ -1153,10 +990,8 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "zero_count", - path: []ottl.Field{ - { - Name: "zero_count", - }, + path: &internal.TestPath[TransformContext]{ + N: "zero_count", }, orig: int64(1), newVal: int64(2), @@ -1166,10 +1001,8 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "positive", - path: []ottl.Field{ - { - Name: "positive", - }, + path: &internal.TestPath[TransformContext]{ + N: "positive", }, orig: refExpoHistogramDataPoint.Positive(), newVal: newPositive, @@ -1179,12 +1012,10 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "positive offset", - path: []ottl.Field{ - { - Name: "positive", - }, - { - Name: "offset", + path: &internal.TestPath[TransformContext]{ + N: "positive", + NextPath: &internal.TestPath[TransformContext]{ + N: "offset", }, }, orig: int64(1), @@ -1195,12 +1026,10 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "positive bucket_counts", - path: []ottl.Field{ - { - Name: "positive", - }, - { - Name: "bucket_counts", + path: &internal.TestPath[TransformContext]{ + N: "positive", + NextPath: &internal.TestPath[TransformContext]{ + N: "bucket_counts", }, }, orig: []uint64{1, 1}, @@ -1211,10 +1040,8 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "negative", - path: []ottl.Field{ - { - Name: "negative", - }, + path: &internal.TestPath[TransformContext]{ + N: "negative", }, orig: refExpoHistogramDataPoint.Negative(), newVal: newPositive, @@ -1224,12 +1051,10 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "negative offset", - path: []ottl.Field{ - { - Name: "negative", - }, - { - Name: "offset", + path: &internal.TestPath[TransformContext]{ + N: "negative", + NextPath: &internal.TestPath[TransformContext]{ + N: "offset", }, }, orig: int64(1), @@ -1240,12 +1065,10 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "negative bucket_counts", - path: []ottl.Field{ - { - Name: "negative", - }, - { - Name: "bucket_counts", + path: &internal.TestPath[TransformContext]{ + N: "negative", + NextPath: &internal.TestPath[TransformContext]{ + N: "bucket_counts", }, }, orig: []uint64{1, 1}, @@ -1256,10 +1079,8 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "exemplars", - path: []ottl.Field{ - { - Name: "exemplars", - }, + path: &internal.TestPath[TransformContext]{ + N: "exemplars", }, orig: refExpoHistogramDataPoint.Exemplars(), newVal: newExemplars, @@ -1269,10 +1090,8 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "attributes", - path: []ottl.Field{ - { - Name: "attributes", - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", }, orig: refExpoHistogramDataPoint.Attributes(), newVal: newAttrs, @@ -1282,14 +1101,10 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "attributes string", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("str"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("str"), }, }, orig: "val", @@ -1300,14 +1115,10 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "attributes bool", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("bool"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("bool"), }, }, orig: true, @@ -1318,14 +1129,10 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "attributes int", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("int"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("int"), }, }, orig: int64(10), @@ -1336,14 +1143,10 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "attributes float", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("double"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("double"), }, }, orig: 1.2, @@ -1354,14 +1157,10 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "attributes bytes", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("bytes"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("bytes"), }, }, orig: []byte{1, 3, 2}, @@ -1372,14 +1171,10 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "attributes array string", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_str"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_str"), }, }, orig: func() pcommon.Slice { @@ -1393,14 +1188,10 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "attributes array bool", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_bool"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_bool"), }, }, orig: func() pcommon.Slice { @@ -1414,14 +1205,10 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "attributes array int", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_int"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_int"), }, }, orig: func() pcommon.Slice { @@ -1435,14 +1222,10 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "attributes array float", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_float"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_float"), }, }, orig: func() pcommon.Slice { @@ -1456,14 +1239,10 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "attributes array bytes", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_bytes"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_bytes"), }, }, orig: func() pcommon.Slice { @@ -1477,14 +1256,10 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "attributes pcommon.Map", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("pMap"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("pMap"), }, }, orig: func() pcommon.Map { @@ -1500,14 +1275,10 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "attributes map[string]any", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("map"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("map"), }, }, orig: func() pcommon.Map { @@ -1523,18 +1294,14 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "attributes nested", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("slice"), - }, - { - Int: ottltest.Intp(0), - }, - { - String: ottltest.Strp("map"), + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("slice"), + NextKey: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(0), + NextKey: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("map"), }, }, }, @@ -1551,18 +1318,14 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { }, { name: "attributes nested new values", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("new"), - }, - { - Int: ottltest.Intp(2), - }, - { - Int: ottltest.Intp(0), + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("new"), + NextKey: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(2), + NextKey: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(0), }, }, }, @@ -1581,7 +1344,8 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - accessor, err := newPathGetSetter(tt.path) + pep := pathExpressionParser{} + accessor, err := pep.parsePath(tt.path) assert.NoError(t, err) expoHistogramDataPoint := createExpoHistogramDataPointTelemetry() @@ -1644,17 +1408,15 @@ func Test_newPathGetSetter_SummaryDataPoint(t *testing.T) { tests := []struct { name string - path []ottl.Field + path ottl.Path[TransformContext] orig any newVal any modified func(pmetric.SummaryDataPoint) }{ { name: "start_time_unix_nano", - path: []ottl.Field{ - { - Name: "start_time_unix_nano", - }, + path: &internal.TestPath[TransformContext]{ + N: "start_time_unix_nano", }, orig: int64(100_000_000), newVal: int64(200_000_000), @@ -1664,10 +1426,8 @@ func Test_newPathGetSetter_SummaryDataPoint(t *testing.T) { }, { name: "time_unix_nano", - path: []ottl.Field{ - { - Name: "time_unix_nano", - }, + path: &internal.TestPath[TransformContext]{ + N: "time_unix_nano", }, orig: int64(500_000_000), newVal: int64(200_000_000), @@ -1677,10 +1437,8 @@ func Test_newPathGetSetter_SummaryDataPoint(t *testing.T) { }, { name: "flags", - path: []ottl.Field{ - { - Name: "flags", - }, + path: &internal.TestPath[TransformContext]{ + N: "flags", }, orig: int64(0), newVal: int64(1), @@ -1690,10 +1448,8 @@ func Test_newPathGetSetter_SummaryDataPoint(t *testing.T) { }, { name: "count", - path: []ottl.Field{ - { - Name: "count", - }, + path: &internal.TestPath[TransformContext]{ + N: "count", }, orig: int64(2), newVal: int64(3), @@ -1703,10 +1459,8 @@ func Test_newPathGetSetter_SummaryDataPoint(t *testing.T) { }, { name: "sum", - path: []ottl.Field{ - { - Name: "sum", - }, + path: &internal.TestPath[TransformContext]{ + N: "sum", }, orig: 10.1, newVal: 10.2, @@ -1716,10 +1470,8 @@ func Test_newPathGetSetter_SummaryDataPoint(t *testing.T) { }, { name: "quantile_values", - path: []ottl.Field{ - { - Name: "quantile_values", - }, + path: &internal.TestPath[TransformContext]{ + N: "quantile_values", }, orig: refSummaryDataPoint.QuantileValues(), newVal: newQuartileValues, @@ -1729,10 +1481,8 @@ func Test_newPathGetSetter_SummaryDataPoint(t *testing.T) { }, { name: "attributes", - path: []ottl.Field{ - { - Name: "attributes", - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", }, orig: refSummaryDataPoint.Attributes(), newVal: newAttrs, @@ -1742,14 +1492,10 @@ func Test_newPathGetSetter_SummaryDataPoint(t *testing.T) { }, { name: "attributes string", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("str"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("str"), }, }, orig: "val", @@ -1760,14 +1506,10 @@ func Test_newPathGetSetter_SummaryDataPoint(t *testing.T) { }, { name: "attributes bool", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("bool"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("bool"), }, }, orig: true, @@ -1778,14 +1520,10 @@ func Test_newPathGetSetter_SummaryDataPoint(t *testing.T) { }, { name: "attributes int", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("int"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("int"), }, }, orig: int64(10), @@ -1796,14 +1534,10 @@ func Test_newPathGetSetter_SummaryDataPoint(t *testing.T) { }, { name: "attributes float", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("double"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("double"), }, }, orig: 1.2, @@ -1814,14 +1548,10 @@ func Test_newPathGetSetter_SummaryDataPoint(t *testing.T) { }, { name: "attributes bytes", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("bytes"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("bytes"), }, }, orig: []byte{1, 3, 2}, @@ -1832,14 +1562,10 @@ func Test_newPathGetSetter_SummaryDataPoint(t *testing.T) { }, { name: "attributes array string", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_str"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_str"), }, }, orig: func() pcommon.Slice { @@ -1853,14 +1579,10 @@ func Test_newPathGetSetter_SummaryDataPoint(t *testing.T) { }, { name: "attributes array bool", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_bool"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_bool"), }, }, orig: func() pcommon.Slice { @@ -1874,14 +1596,10 @@ func Test_newPathGetSetter_SummaryDataPoint(t *testing.T) { }, { name: "attributes array int", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_int"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_int"), }, }, orig: func() pcommon.Slice { @@ -1895,14 +1613,10 @@ func Test_newPathGetSetter_SummaryDataPoint(t *testing.T) { }, { name: "attributes array float", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_float"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_float"), }, }, orig: func() pcommon.Slice { @@ -1916,14 +1630,10 @@ func Test_newPathGetSetter_SummaryDataPoint(t *testing.T) { }, { name: "attributes array bytes", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_bytes"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_bytes"), }, }, orig: func() pcommon.Slice { @@ -1937,14 +1647,10 @@ func Test_newPathGetSetter_SummaryDataPoint(t *testing.T) { }, { name: "attributes pcommon.Map", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("pMap"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("pMap"), }, }, orig: func() pcommon.Map { @@ -1960,14 +1666,10 @@ func Test_newPathGetSetter_SummaryDataPoint(t *testing.T) { }, { name: "attributes map[string]any", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("map"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("map"), }, }, orig: func() pcommon.Map { @@ -1983,18 +1685,14 @@ func Test_newPathGetSetter_SummaryDataPoint(t *testing.T) { }, { name: "attributes nested", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("slice"), - }, - { - Int: ottltest.Intp(0), - }, - { - String: ottltest.Strp("map"), + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("slice"), + NextKey: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(0), + NextKey: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("map"), }, }, }, @@ -2011,18 +1709,14 @@ func Test_newPathGetSetter_SummaryDataPoint(t *testing.T) { }, { name: "attributes nested new values", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("new"), - }, - { - Int: ottltest.Intp(2), - }, - { - Int: ottltest.Intp(0), + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("new"), + NextKey: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(2), + NextKey: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(0), }, }, }, @@ -2041,7 +1735,8 @@ func Test_newPathGetSetter_SummaryDataPoint(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - accessor, err := newPathGetSetter(tt.path) + pep := pathExpressionParser{} + accessor, err := pep.parsePath(tt.path) assert.NoError(t, err) summaryDataPoint := createSummaryDataPointTelemetry() @@ -2122,17 +1817,15 @@ func Test_newPathGetSetter_Metric(t *testing.T) { tests := []struct { name string - path []ottl.Field + path ottl.Path[TransformContext] orig any newVal any modified func(metric pmetric.Metric) }{ { name: "metric", - path: []ottl.Field{ - { - Name: "metric", - }, + path: &internal.TestPath[TransformContext]{ + N: "metric", }, orig: refMetric, newVal: newMetric, @@ -2142,12 +1835,10 @@ func Test_newPathGetSetter_Metric(t *testing.T) { }, { name: "metric name", - path: []ottl.Field{ - { - Name: "metric", - }, - { - Name: "name", + path: &internal.TestPath[TransformContext]{ + N: "metric", + NextPath: &internal.TestPath[TransformContext]{ + N: "name", }, }, orig: "name", @@ -2158,12 +1849,10 @@ func Test_newPathGetSetter_Metric(t *testing.T) { }, { name: "metric description", - path: []ottl.Field{ - { - Name: "metric", - }, - { - Name: "description", + path: &internal.TestPath[TransformContext]{ + N: "metric", + NextPath: &internal.TestPath[TransformContext]{ + N: "description", }, }, orig: "description", @@ -2174,12 +1863,10 @@ func Test_newPathGetSetter_Metric(t *testing.T) { }, { name: "metric unit", - path: []ottl.Field{ - { - Name: "metric", - }, - { - Name: "unit", + path: &internal.TestPath[TransformContext]{ + N: "metric", + NextPath: &internal.TestPath[TransformContext]{ + N: "unit", }, }, orig: "unit", @@ -2190,12 +1877,10 @@ func Test_newPathGetSetter_Metric(t *testing.T) { }, { name: "metric type", - path: []ottl.Field{ - { - Name: "metric", - }, - { - Name: "type", + path: &internal.TestPath[TransformContext]{ + N: "metric", + NextPath: &internal.TestPath[TransformContext]{ + N: "type", }, }, orig: int64(pmetric.MetricTypeSum), @@ -2205,12 +1890,10 @@ func Test_newPathGetSetter_Metric(t *testing.T) { }, { name: "metric aggregation_temporality", - path: []ottl.Field{ - { - Name: "metric", - }, - { - Name: "aggregation_temporality", + path: &internal.TestPath[TransformContext]{ + N: "metric", + NextPath: &internal.TestPath[TransformContext]{ + N: "aggregation_temporality", }, }, orig: int64(2), @@ -2221,12 +1904,10 @@ func Test_newPathGetSetter_Metric(t *testing.T) { }, { name: "metric is_monotonic", - path: []ottl.Field{ - { - Name: "metric", - }, - { - Name: "is_monotonic", + path: &internal.TestPath[TransformContext]{ + N: "metric", + NextPath: &internal.TestPath[TransformContext]{ + N: "is_monotonic", }, }, orig: true, @@ -2238,7 +1919,8 @@ func Test_newPathGetSetter_Metric(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - accessor, err := newPathGetSetter(tt.path) + pep := pathExpressionParser{} + accessor, err := pep.parsePath(tt.path) assert.NoError(t, err) metric := createMetricTelemetry() diff --git a/pkg/ottl/contexts/ottllog/log.go b/pkg/ottl/contexts/ottllog/log.go index bc7954ea6614..a1eeed624364 100644 --- a/pkg/ottl/contexts/ottllog/log.go +++ b/pkg/ottl/contexts/ottllog/log.go @@ -56,10 +56,10 @@ func (tCtx TransformContext) getCache() pcommon.Map { } func NewParser(functions map[string]ottl.Factory[TransformContext], telemetrySettings component.TelemetrySettings, options ...Option) (ottl.Parser[TransformContext], error) { - pathExpressionParser := pathExpressionParser{telemetrySettings} + pep := pathExpressionParser{telemetrySettings} p, err := ottl.NewParser[TransformContext]( functions, - pathExpressionParser.parsePath, + pep.parsePath, telemetrySettings, ottl.WithEnumParser[TransformContext](parseEnum), ) @@ -146,25 +146,20 @@ type pathExpressionParser struct { telemetrySettings component.TelemetrySettings } -func (pep *pathExpressionParser) parsePath(val *ottl.Path) (ottl.GetSetter[TransformContext], error) { - if val != nil && len(val.Fields) > 0 { - return newPathGetSetter(val.Fields) +func (pep *pathExpressionParser) parsePath(path ottl.Path[TransformContext]) (ottl.GetSetter[TransformContext], error) { + if path == nil { + return nil, fmt.Errorf("path cannot be nil") } - return nil, fmt.Errorf("bad path %v", val) -} - -func newPathGetSetter(path []ottl.Field) (ottl.GetSetter[TransformContext], error) { - switch path[0].Name { + switch path.Name() { case "cache": - mapKey := path[0].Keys - if mapKey == nil { + if path.Key() == nil { return accessCache(), nil } - return accessCacheKey(mapKey), nil + return accessCacheKey(path.Key()), nil case "resource": - return internal.ResourcePathGetSetter[TransformContext](path[1:]) + return internal.ResourcePathGetSetter[TransformContext](path.Next()) case "instrumentation_scope": - return internal.ScopePathGetSetter[TransformContext](path[1:]) + return internal.ScopePathGetSetter[TransformContext](path.Next()) case "time_unix_nano": return accessTimeUnixNano(), nil case "observed_time_unix_nano": @@ -178,42 +173,42 @@ func newPathGetSetter(path []ottl.Field) (ottl.GetSetter[TransformContext], erro case "severity_text": return accessSeverityText(), nil case "body": - if len(path) == 1 { - keys := path[0].Keys - if keys == nil { + if path.Next() != nil { + if path.Next().Name() == "string" { + return accessStringBody(), nil + } + } else { + if path.Key() == nil { return accessBody(), nil } - return accessBodyKey(keys), nil - } - if path[1].Name == "string" { - return accessStringBody(), nil + return accessBodyKey(path.Key()), nil } case "attributes": - mapKey := path[0].Keys - if mapKey == nil { + if path.Key() == nil { return accessAttributes(), nil } - return accessAttributesKey(mapKey), nil + return accessAttributesKey(path.Key()), nil case "dropped_attributes_count": return accessDroppedAttributesCount(), nil case "flags": return accessFlags(), nil case "trace_id": - if len(path) == 1 { + if path.Next() != nil { + if path.Next().Name() == "string" { + return accessStringTraceID(), nil + } + } else { return accessTraceID(), nil } - if path[1].Name == "string" { - return accessStringTraceID(), nil - } case "span_id": - if len(path) == 1 { + if path.Next() != nil { + if path.Next().Name() == "string" { + return accessStringSpanID(), nil + } + } else { return accessSpanID(), nil } - if path[1].Name == "string" { - return accessStringSpanID(), nil - } } - return nil, fmt.Errorf("invalid path expression %v", path) } @@ -231,13 +226,13 @@ func accessCache() ottl.StandardGetSetter[TransformContext] { } } -func accessCacheKey(keys []ottl.Key) ottl.StandardGetSetter[TransformContext] { +func accessCacheKey(key ottl.Key[TransformContext]) ottl.StandardGetSetter[TransformContext] { return ottl.StandardGetSetter[TransformContext]{ Getter: func(ctx context.Context, tCtx TransformContext) (any, error) { - return internal.GetMapValue(tCtx.getCache(), keys) + return internal.GetMapValue[TransformContext](ctx, tCtx, tCtx.getCache(), key) }, Setter: func(ctx context.Context, tCtx TransformContext, val any) error { - return internal.SetMapValue(tCtx.getCache(), keys, val) + return internal.SetMapValue[TransformContext](ctx, tCtx, tCtx.getCache(), key, val) }, } } @@ -337,15 +332,15 @@ func accessBody() ottl.StandardGetSetter[TransformContext] { } } -func accessBodyKey(keys []ottl.Key) ottl.StandardGetSetter[TransformContext] { +func accessBodyKey(key ottl.Key[TransformContext]) ottl.StandardGetSetter[TransformContext] { return ottl.StandardGetSetter[TransformContext]{ Getter: func(ctx context.Context, tCtx TransformContext) (any, error) { body := tCtx.GetLogRecord().Body() switch body.Type() { case pcommon.ValueTypeMap: - return internal.GetMapValue(tCtx.GetLogRecord().Body().Map(), keys) + return internal.GetMapValue[TransformContext](ctx, tCtx, tCtx.GetLogRecord().Body().Map(), key) case pcommon.ValueTypeSlice: - return internal.GetSliceValue(tCtx.GetLogRecord().Body().Slice(), keys) + return internal.GetSliceValue[TransformContext](ctx, tCtx, tCtx.GetLogRecord().Body().Slice(), key) default: return nil, fmt.Errorf("log bodies of type %s cannot be indexed", body.Type().String()) } @@ -354,9 +349,9 @@ func accessBodyKey(keys []ottl.Key) ottl.StandardGetSetter[TransformContext] { body := tCtx.GetLogRecord().Body() switch body.Type() { case pcommon.ValueTypeMap: - return internal.SetMapValue(tCtx.GetLogRecord().Body().Map(), keys, val) + return internal.SetMapValue[TransformContext](ctx, tCtx, tCtx.GetLogRecord().Body().Map(), key, val) case pcommon.ValueTypeSlice: - return internal.SetSliceValue(tCtx.GetLogRecord().Body().Slice(), keys, val) + return internal.SetSliceValue[TransformContext](ctx, tCtx, tCtx.GetLogRecord().Body().Slice(), key, val) default: return fmt.Errorf("log bodies of type %s cannot be indexed", body.Type().String()) } @@ -392,13 +387,13 @@ func accessAttributes() ottl.StandardGetSetter[TransformContext] { } } -func accessAttributesKey(keys []ottl.Key) ottl.StandardGetSetter[TransformContext] { +func accessAttributesKey(key ottl.Key[TransformContext]) ottl.StandardGetSetter[TransformContext] { return ottl.StandardGetSetter[TransformContext]{ Getter: func(ctx context.Context, tCtx TransformContext) (any, error) { - return internal.GetMapValue(tCtx.GetLogRecord().Attributes(), keys) + return internal.GetMapValue[TransformContext](ctx, tCtx, tCtx.GetLogRecord().Attributes(), key) }, Setter: func(ctx context.Context, tCtx TransformContext, val any) error { - return internal.SetMapValue(tCtx.GetLogRecord().Attributes(), keys, val) + return internal.SetMapValue[TransformContext](ctx, tCtx, tCtx.GetLogRecord().Attributes(), key, val) }, } } diff --git a/pkg/ottl/contexts/ottllog/log_test.go b/pkg/ottl/contexts/ottllog/log_test.go index 6a1b7fbbebc7..1a9a214aa430 100644 --- a/pkg/ottl/contexts/ottllog/log_test.go +++ b/pkg/ottl/contexts/ottllog/log_test.go @@ -15,6 +15,7 @@ import ( "go.opentelemetry.io/collector/pdata/plog" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/internal" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/ottltest" ) @@ -51,7 +52,7 @@ func Test_newPathGetSetter(t *testing.T) { tests := []struct { name string - path []ottl.Field + path ottl.Path[TransformContext] orig any newVal any modified func(log plog.LogRecord, il pcommon.InstrumentationScope, resource pcommon.Resource, cache pcommon.Map) @@ -59,10 +60,8 @@ func Test_newPathGetSetter(t *testing.T) { }{ { name: "time", - path: []ottl.Field{ - { - Name: "time", - }, + path: &internal.TestPath[TransformContext]{ + N: "time", }, orig: time.Date(1970, 1, 1, 0, 0, 0, 100000000, time.UTC), newVal: time.Date(1970, 1, 1, 0, 0, 0, 200000000, time.UTC), @@ -72,10 +71,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "time_unix_nano", - path: []ottl.Field{ - { - Name: "time_unix_nano", - }, + path: &internal.TestPath[TransformContext]{ + N: "time_unix_nano", }, orig: int64(100_000_000), newVal: int64(200_000_000), @@ -85,10 +82,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "observed_time_unix_nano", - path: []ottl.Field{ - { - Name: "observed_time_unix_nano", - }, + path: &internal.TestPath[TransformContext]{ + N: "observed_time_unix_nano", }, orig: int64(500_000_000), newVal: int64(200_000_000), @@ -98,10 +93,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "observed time", - path: []ottl.Field{ - { - Name: "observed_time", - }, + path: &internal.TestPath[TransformContext]{ + N: "observed_time", }, orig: time.Date(1970, 1, 1, 0, 0, 0, 500000000, time.UTC), newVal: time.Date(1970, 1, 1, 0, 0, 0, 200000000, time.UTC), @@ -111,10 +104,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "severity_number", - path: []ottl.Field{ - { - Name: "severity_number", - }, + path: &internal.TestPath[TransformContext]{ + N: "severity_number", }, orig: int64(plog.SeverityNumberFatal), newVal: int64(3), @@ -124,10 +115,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "severity_text", - path: []ottl.Field{ - { - Name: "severity_text", - }, + path: &internal.TestPath[TransformContext]{ + N: "severity_text", }, orig: "blue screen of death", newVal: "black screen of death", @@ -137,10 +126,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "body", - path: []ottl.Field{ - { - Name: "body", - }, + path: &internal.TestPath[TransformContext]{ + N: "body", }, orig: "body", newVal: "head", @@ -150,10 +137,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "map body", - path: []ottl.Field{ - { - Name: "body", - }, + path: &internal.TestPath[TransformContext]{ + N: "body", }, orig: func() pcommon.Map { log, _, _ := createTelemetry("map") @@ -167,14 +152,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "map body index", - path: []ottl.Field{ - { - Name: "body", - Keys: []ottl.Key{ - { - String: ottltest.Strp("key"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "body", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("key"), }, }, orig: "val", @@ -186,10 +167,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "slice body", - path: []ottl.Field{ - { - Name: "body", - }, + path: &internal.TestPath[TransformContext]{ + N: "body", }, orig: func() pcommon.Slice { log, _, _ := createTelemetry("slice") @@ -206,14 +185,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "slice body index", - path: []ottl.Field{ - { - Name: "body", - Keys: []ottl.Key{ - { - Int: ottltest.Intp(0), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "body", + Keys: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(0), }, }, orig: "body", @@ -225,12 +200,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "body string", - path: []ottl.Field{ - { - Name: "body", - }, - { - Name: "string", + path: &internal.TestPath[TransformContext]{ + N: "body", + NextPath: &internal.TestPath[TransformContext]{ + N: "string", }, }, orig: "1", @@ -242,10 +215,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "flags", - path: []ottl.Field{ - { - Name: "flags", - }, + path: &internal.TestPath[TransformContext]{ + N: "flags", }, orig: int64(4), newVal: int64(5), @@ -255,10 +226,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "trace_id", - path: []ottl.Field{ - { - Name: "trace_id", - }, + path: &internal.TestPath[TransformContext]{ + N: "trace_id", }, orig: pcommon.TraceID(traceID), newVal: pcommon.TraceID(traceID2), @@ -268,10 +237,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "span_id", - path: []ottl.Field{ - { - Name: "span_id", - }, + path: &internal.TestPath[TransformContext]{ + N: "span_id", }, orig: pcommon.SpanID(spanID), newVal: pcommon.SpanID(spanID2), @@ -281,12 +248,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "trace_id string", - path: []ottl.Field{ - { - Name: "trace_id", - }, - { - Name: "string", + path: &internal.TestPath[TransformContext]{ + N: "trace_id", + NextPath: &internal.TestPath[TransformContext]{ + N: "string", }, }, orig: hex.EncodeToString(traceID[:]), @@ -297,12 +262,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "span_id string", - path: []ottl.Field{ - { - Name: "span_id", - }, - { - Name: "string", + path: &internal.TestPath[TransformContext]{ + N: "span_id", + NextPath: &internal.TestPath[TransformContext]{ + N: "string", }, }, orig: hex.EncodeToString(spanID[:]), @@ -313,10 +276,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "cache", - path: []ottl.Field{ - { - Name: "cache", - }, + path: &internal.TestPath[TransformContext]{ + N: "cache", }, orig: pcommon.NewMap(), newVal: newCache, @@ -326,14 +287,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "cache access", - path: []ottl.Field{ - { - Name: "cache", - Keys: []ottl.Key{ - { - String: ottltest.Strp("temp"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "cache", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("temp"), }, }, orig: nil, @@ -344,10 +301,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes", - path: []ottl.Field{ - { - Name: "attributes", - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", }, orig: refLog.Attributes(), newVal: newAttrs, @@ -357,14 +312,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes string", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("str"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("str"), }, }, orig: "val", @@ -375,14 +326,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes bool", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("bool"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("bool"), }, }, orig: true, @@ -393,14 +340,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes int", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("int"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("int"), }, }, orig: int64(10), @@ -411,14 +354,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes float", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("double"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("double"), }, }, orig: float64(1.2), @@ -429,14 +368,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes bytes", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("bytes"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("bytes"), }, }, orig: []byte{1, 3, 2}, @@ -447,14 +382,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes array string", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_str"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_str"), }, }, orig: func() pcommon.Slice { @@ -468,14 +399,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes array bool", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_bool"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_bool"), }, }, orig: func() pcommon.Slice { @@ -489,14 +416,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes array int", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_int"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_int"), }, }, orig: func() pcommon.Slice { @@ -510,14 +433,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes array float", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_float"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_float"), }, }, orig: func() pcommon.Slice { @@ -531,14 +450,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes array bytes", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_bytes"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_bytes"), }, }, orig: func() pcommon.Slice { @@ -552,14 +467,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes pcommon.Map", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("pMap"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("pMap"), }, }, orig: func() pcommon.Map { @@ -575,14 +486,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes map[string]any", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("map"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("map"), }, }, orig: func() pcommon.Map { @@ -598,18 +505,14 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes nested", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("slice"), - }, - { - Int: ottltest.Intp(0), - }, - { - String: ottltest.Strp("map"), + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("slice"), + NextKey: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(0), + NextKey: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("map"), }, }, }, @@ -626,18 +529,14 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes nested new values", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("new"), - }, - { - Int: ottltest.Intp(2), - }, - { - Int: ottltest.Intp(0), + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("new"), + NextKey: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(2), + NextKey: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(0), }, }, }, @@ -655,10 +554,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "dropped_attributes_count", - path: []ottl.Field{ - { - Name: "dropped_attributes_count", - }, + path: &internal.TestPath[TransformContext]{ + N: "dropped_attributes_count", }, orig: int64(10), newVal: int64(20), @@ -668,10 +565,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "instrumentation_scope", - path: []ottl.Field{ - { - Name: "instrumentation_scope", - }, + path: &internal.TestPath[TransformContext]{ + N: "instrumentation_scope", }, orig: refIS, newVal: pcommon.NewInstrumentationScope(), @@ -681,10 +576,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "resource", - path: []ottl.Field{ - { - Name: "resource", - }, + path: &internal.TestPath[TransformContext]{ + N: "resource", }, orig: refResource, newVal: pcommon.NewResource(), @@ -695,7 +588,8 @@ func Test_newPathGetSetter(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - accessor, err := newPathGetSetter(tt.path) + pep := pathExpressionParser{} + accessor, err := pep.parsePath(tt.path) assert.NoError(t, err) log, il, resource := createTelemetry(tt.bodyType) @@ -793,18 +687,15 @@ func createTelemetry(bodyType string) (plog.LogRecord, pcommon.InstrumentationSc } func Test_InvalidBodyIndexing(t *testing.T) { - path := []ottl.Field{ - { - Name: "body", - Keys: []ottl.Key{ - { - String: ottltest.Strp("key"), - }, - }, + path := internal.TestPath[TransformContext]{ + N: "body", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("key"), }, } - accessor, err := newPathGetSetter(path) + pep := pathExpressionParser{} + accessor, err := pep.parsePath(&path) assert.NoError(t, err) log, il, resource := createTelemetry("string") diff --git a/pkg/ottl/contexts/ottlmetric/metrics.go b/pkg/ottl/contexts/ottlmetric/metrics.go index db3cbb625107..d17a6640f6f4 100644 --- a/pkg/ottl/contexts/ottlmetric/metrics.go +++ b/pkg/ottl/contexts/ottlmetric/metrics.go @@ -60,10 +60,10 @@ func (tCtx TransformContext) getCache() pcommon.Map { } func NewParser(functions map[string]ottl.Factory[TransformContext], telemetrySettings component.TelemetrySettings, options ...Option) (ottl.Parser[TransformContext], error) { - pathExpressionParser := pathExpressionParser{telemetrySettings} + pep := pathExpressionParser{telemetrySettings} p, err := ottl.NewParser[TransformContext]( functions, - pathExpressionParser.parsePath, + pep.parsePath, telemetrySettings, ottl.WithEnumParser[TransformContext](parseEnum), ) @@ -124,25 +124,20 @@ type pathExpressionParser struct { telemetrySettings component.TelemetrySettings } -func (pep *pathExpressionParser) parsePath(val *ottl.Path) (ottl.GetSetter[TransformContext], error) { - if val != nil && len(val.Fields) > 0 { - return newPathGetSetter(val.Fields) +func (pep *pathExpressionParser) parsePath(path ottl.Path[TransformContext]) (ottl.GetSetter[TransformContext], error) { + if path == nil { + return nil, fmt.Errorf("path cannot be nil") } - return nil, fmt.Errorf("bad path %v", val) -} - -func newPathGetSetter(path []ottl.Field) (ottl.GetSetter[TransformContext], error) { - switch path[0].Name { + switch path.Name() { case "cache": - mapKey := path[0].Keys - if mapKey == nil { + if path.Key() == nil { return accessCache(), nil } - return accessCacheKey(mapKey), nil + return accessCacheKey(path.Key()), nil case "resource": - return internal.ResourcePathGetSetter[TransformContext](path[1:]) + return internal.ResourcePathGetSetter[TransformContext](path.Next()) case "instrumentation_scope": - return internal.ScopePathGetSetter[TransformContext](path[1:]) + return internal.ScopePathGetSetter[TransformContext](path.Next()) default: return internal.MetricPathGetSetter[TransformContext](path) } @@ -162,13 +157,13 @@ func accessCache() ottl.StandardGetSetter[TransformContext] { } } -func accessCacheKey(keys []ottl.Key) ottl.StandardGetSetter[TransformContext] { +func accessCacheKey(key ottl.Key[TransformContext]) ottl.StandardGetSetter[TransformContext] { return ottl.StandardGetSetter[TransformContext]{ Getter: func(ctx context.Context, tCtx TransformContext) (any, error) { - return internal.GetMapValue(tCtx.getCache(), keys) + return internal.GetMapValue[TransformContext](ctx, tCtx, tCtx.getCache(), key) }, Setter: func(ctx context.Context, tCtx TransformContext, val any) error { - return internal.SetMapValue(tCtx.getCache(), keys, val) + return internal.SetMapValue[TransformContext](ctx, tCtx, tCtx.getCache(), key, val) }, } } diff --git a/pkg/ottl/contexts/ottlmetric/metrics_test.go b/pkg/ottl/contexts/ottlmetric/metrics_test.go index f2480ac51ced..8735573b9790 100644 --- a/pkg/ottl/contexts/ottlmetric/metrics_test.go +++ b/pkg/ottl/contexts/ottlmetric/metrics_test.go @@ -12,6 +12,7 @@ import ( "go.opentelemetry.io/collector/pdata/pmetric" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/internal" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/ottltest" ) @@ -31,17 +32,15 @@ func Test_newPathGetSetter(t *testing.T) { tests := []struct { name string - path []ottl.Field + path ottl.Path[TransformContext] orig any newVal any modified func(metric pmetric.Metric, cache pcommon.Map) }{ { name: "metric name", - path: []ottl.Field{ - { - Name: "name", - }, + path: &internal.TestPath[TransformContext]{ + N: "name", }, orig: "name", newVal: "new name", @@ -51,10 +50,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "metric description", - path: []ottl.Field{ - { - Name: "description", - }, + path: &internal.TestPath[TransformContext]{ + N: "description", }, orig: "description", newVal: "new description", @@ -64,10 +61,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "metric unit", - path: []ottl.Field{ - { - Name: "unit", - }, + path: &internal.TestPath[TransformContext]{ + N: "unit", }, orig: "unit", newVal: "new unit", @@ -77,10 +72,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "metric type", - path: []ottl.Field{ - { - Name: "type", - }, + path: &internal.TestPath[TransformContext]{ + N: "type", }, orig: int64(pmetric.MetricTypeSum), newVal: int64(pmetric.MetricTypeSum), @@ -89,10 +82,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "metric aggregation_temporality", - path: []ottl.Field{ - { - Name: "aggregation_temporality", - }, + path: &internal.TestPath[TransformContext]{ + N: "aggregation_temporality", }, orig: int64(2), newVal: int64(1), @@ -102,10 +93,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "metric is_monotonic", - path: []ottl.Field{ - { - Name: "is_monotonic", - }, + path: &internal.TestPath[TransformContext]{ + N: "is_monotonic", }, orig: true, newVal: false, @@ -115,10 +104,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "metric data points", - path: []ottl.Field{ - { - Name: "data_points", - }, + path: &internal.TestPath[TransformContext]{ + N: "data_points", }, orig: refMetric.Sum().DataPoints(), newVal: newDataPoints, @@ -128,10 +115,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "cache", - path: []ottl.Field{ - { - Name: "cache", - }, + path: &internal.TestPath[TransformContext]{ + N: "cache", }, orig: pcommon.NewMap(), newVal: newCache, @@ -141,14 +126,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "cache access", - path: []ottl.Field{ - { - Name: "cache", - Keys: []ottl.Key{ - { - String: ottltest.Strp("temp"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "cache", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("temp"), }, }, orig: nil, @@ -160,7 +141,8 @@ func Test_newPathGetSetter(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - accessor, err := newPathGetSetter(tt.path) + pep := pathExpressionParser{} + accessor, err := pep.parsePath(tt.path) assert.NoError(t, err) metric := createMetricTelemetry() diff --git a/pkg/ottl/contexts/ottlresource/resource.go b/pkg/ottl/contexts/ottlresource/resource.go index 552c192e8b56..99d55a02314a 100644 --- a/pkg/ottl/contexts/ottlresource/resource.go +++ b/pkg/ottl/contexts/ottlresource/resource.go @@ -39,10 +39,10 @@ func (tCtx TransformContext) getCache() pcommon.Map { } func NewParser(functions map[string]ottl.Factory[TransformContext], telemetrySettings component.TelemetrySettings, options ...Option) (ottl.Parser[TransformContext], error) { - pathExpressionParser := pathExpressionParser{telemetrySettings} + pep := pathExpressionParser{telemetrySettings} p, err := ottl.NewParser[TransformContext]( functions, - pathExpressionParser.parsePath, + pep.parsePath, telemetrySettings, ottl.WithEnumParser[TransformContext](parseEnum), ) @@ -95,21 +95,16 @@ type pathExpressionParser struct { telemetrySettings component.TelemetrySettings } -func (pep *pathExpressionParser) parsePath(val *ottl.Path) (ottl.GetSetter[TransformContext], error) { - if val != nil && len(val.Fields) > 0 { - return newPathGetSetter(val.Fields) +func (pep *pathExpressionParser) parsePath(path ottl.Path[TransformContext]) (ottl.GetSetter[TransformContext], error) { + if path == nil { + return nil, fmt.Errorf("path cannot be nil") } - return nil, fmt.Errorf("bad path %v", val) -} - -func newPathGetSetter(path []ottl.Field) (ottl.GetSetter[TransformContext], error) { - switch path[0].Name { + switch path.Name() { case "cache": - mapKey := path[0].Keys - if mapKey == nil { + if path.Key() == nil { return accessCache(), nil } - return accessCacheKey(mapKey), nil + return accessCacheKey(path.Key()), nil default: return internal.ResourcePathGetSetter[TransformContext](path) } @@ -129,13 +124,13 @@ func accessCache() ottl.StandardGetSetter[TransformContext] { } } -func accessCacheKey(keys []ottl.Key) ottl.StandardGetSetter[TransformContext] { +func accessCacheKey(key ottl.Key[TransformContext]) ottl.StandardGetSetter[TransformContext] { return ottl.StandardGetSetter[TransformContext]{ Getter: func(ctx context.Context, tCtx TransformContext) (any, error) { - return internal.GetMapValue(tCtx.getCache(), keys) + return internal.GetMapValue[TransformContext](ctx, tCtx, tCtx.getCache(), key) }, Setter: func(ctx context.Context, tCtx TransformContext, val any) error { - return internal.SetMapValue(tCtx.getCache(), keys, val) + return internal.SetMapValue[TransformContext](ctx, tCtx, tCtx.getCache(), key, val) }, } } diff --git a/pkg/ottl/contexts/ottlresource/resource_test.go b/pkg/ottl/contexts/ottlresource/resource_test.go index 87d8cb397f2c..a891835d2cc4 100644 --- a/pkg/ottl/contexts/ottlresource/resource_test.go +++ b/pkg/ottl/contexts/ottlresource/resource_test.go @@ -11,6 +11,7 @@ import ( "go.opentelemetry.io/collector/pdata/pcommon" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/internal" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/ottltest" ) @@ -34,17 +35,15 @@ func Test_newPathGetSetter(t *testing.T) { tests := []struct { name string - path []ottl.Field + path ottl.Path[TransformContext] orig any newVal any modified func(resource pcommon.Resource, cache pcommon.Map) }{ { name: "cache", - path: []ottl.Field{ - { - Name: "cache", - }, + path: &internal.TestPath[TransformContext]{ + N: "cache", }, orig: pcommon.NewMap(), newVal: newCache, @@ -54,14 +53,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "cache access", - path: []ottl.Field{ - { - Name: "cache", - Keys: []ottl.Key{ - { - String: ottltest.Strp("temp"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "cache", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("temp"), }, }, orig: nil, @@ -72,10 +67,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes", - path: []ottl.Field{ - { - Name: "attributes", - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", }, orig: refResource.Attributes(), newVal: newAttrs, @@ -85,14 +78,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes string", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("str"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("str"), }, }, orig: "val", @@ -103,14 +92,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes bool", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("bool"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("bool"), }, }, orig: true, @@ -121,14 +106,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes int", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("int"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("int"), }, }, orig: int64(10), @@ -139,14 +120,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes float", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("double"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("double"), }, }, orig: float64(1.2), @@ -157,14 +134,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes bytes", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("bytes"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("bytes"), }, }, orig: []byte{1, 3, 2}, @@ -175,14 +148,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes array string", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_str"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_str"), }, }, orig: func() pcommon.Slice { @@ -196,14 +165,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes array bool", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_bool"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_bool"), }, }, orig: func() pcommon.Slice { @@ -217,14 +182,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes array int", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_int"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_int"), }, }, orig: func() pcommon.Slice { @@ -238,14 +199,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes array float", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_float"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_float"), }, }, orig: func() pcommon.Slice { @@ -259,14 +216,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes array bytes", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_bytes"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_bytes"), }, }, orig: func() pcommon.Slice { @@ -280,14 +233,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes pcommon.Map", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("pMap"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("pMap"), }, }, orig: func() pcommon.Map { @@ -303,14 +252,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes mpa[string]interface", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("map"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("map"), }, }, orig: func() pcommon.Map { @@ -326,18 +271,14 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes nested", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("slice"), - }, - { - Int: ottltest.Intp(0), - }, - { - String: ottltest.Strp("map"), + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("slice"), + NextKey: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(0), + NextKey: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("map"), }, }, }, @@ -354,18 +295,14 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes nested new values", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("new"), - }, - { - Int: ottltest.Intp(2), - }, - { - Int: ottltest.Intp(0), + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("new"), + NextKey: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(2), + NextKey: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(0), }, }, }, @@ -383,10 +320,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "dropped_attributes_count", - path: []ottl.Field{ - { - Name: "dropped_attributes_count", - }, + path: &internal.TestPath[TransformContext]{ + N: "dropped_attributes_count", }, orig: int64(10), newVal: int64(20), @@ -397,7 +332,8 @@ func Test_newPathGetSetter(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - accessor, err := newPathGetSetter(tt.path) + pep := pathExpressionParser{} + accessor, err := pep.parsePath(tt.path) assert.NoError(t, err) resource := createTelemetry() diff --git a/pkg/ottl/contexts/ottlscope/scope.go b/pkg/ottl/contexts/ottlscope/scope.go index 1ac78993a646..c175c80400ea 100644 --- a/pkg/ottl/contexts/ottlscope/scope.go +++ b/pkg/ottl/contexts/ottlscope/scope.go @@ -46,10 +46,10 @@ func (tCtx TransformContext) getCache() pcommon.Map { } func NewParser(functions map[string]ottl.Factory[TransformContext], telemetrySettings component.TelemetrySettings, options ...Option) (ottl.Parser[TransformContext], error) { - pathExpressionParser := pathExpressionParser{telemetrySettings} + pep := pathExpressionParser{telemetrySettings} p, err := ottl.NewParser[TransformContext]( functions, - pathExpressionParser.parsePath, + pep.parsePath, telemetrySettings, ottl.WithEnumParser[TransformContext](parseEnum), ) @@ -102,23 +102,18 @@ type pathExpressionParser struct { telemetrySettings component.TelemetrySettings } -func (pep *pathExpressionParser) parsePath(val *ottl.Path) (ottl.GetSetter[TransformContext], error) { - if val != nil && len(val.Fields) > 0 { - return newPathGetSetter(val.Fields) +func (pep *pathExpressionParser) parsePath(path ottl.Path[TransformContext]) (ottl.GetSetter[TransformContext], error) { + if path == nil { + return nil, fmt.Errorf("path cannot be nil") } - return nil, fmt.Errorf("bad path %v", val) -} - -func newPathGetSetter(path []ottl.Field) (ottl.GetSetter[TransformContext], error) { - switch path[0].Name { + switch path.Name() { case "cache": - mapKey := path[0].Keys - if mapKey == nil { + if path.Key() == nil { return accessCache(), nil } - return accessCacheKey(mapKey), nil + return accessCacheKey(path.Key()), nil case "resource": - return internal.ResourcePathGetSetter[TransformContext](path[1:]) + return internal.ResourcePathGetSetter[TransformContext](path.Next()) default: return internal.ScopePathGetSetter[TransformContext](path) } @@ -138,13 +133,13 @@ func accessCache() ottl.StandardGetSetter[TransformContext] { } } -func accessCacheKey(keys []ottl.Key) ottl.StandardGetSetter[TransformContext] { +func accessCacheKey(key ottl.Key[TransformContext]) ottl.StandardGetSetter[TransformContext] { return ottl.StandardGetSetter[TransformContext]{ Getter: func(ctx context.Context, tCtx TransformContext) (any, error) { - return internal.GetMapValue(tCtx.getCache(), keys) + return internal.GetMapValue[TransformContext](ctx, tCtx, tCtx.getCache(), key) }, Setter: func(ctx context.Context, tCtx TransformContext, val any) error { - return internal.SetMapValue(tCtx.getCache(), keys, val) + return internal.SetMapValue[TransformContext](ctx, tCtx, tCtx.getCache(), key, val) }, } } diff --git a/pkg/ottl/contexts/ottlscope/scope_test.go b/pkg/ottl/contexts/ottlscope/scope_test.go index 6c799558d1f2..a65d17a25a0a 100644 --- a/pkg/ottl/contexts/ottlscope/scope_test.go +++ b/pkg/ottl/contexts/ottlscope/scope_test.go @@ -11,6 +11,7 @@ import ( "go.opentelemetry.io/collector/pdata/pcommon" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/internal" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/ottltest" ) @@ -34,17 +35,15 @@ func Test_newPathGetSetter(t *testing.T) { tests := []struct { name string - path []ottl.Field + path ottl.Path[TransformContext] orig any newVal any modified func(is pcommon.InstrumentationScope, resource pcommon.Resource, cache pcommon.Map) }{ { name: "cache", - path: []ottl.Field{ - { - Name: "cache", - }, + path: &internal.TestPath[TransformContext]{ + N: "cache", }, orig: pcommon.NewMap(), newVal: newCache, @@ -54,14 +53,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "cache access", - path: []ottl.Field{ - { - Name: "cache", - Keys: []ottl.Key{ - { - String: ottltest.Strp("temp"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "cache", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("temp"), }, }, orig: nil, @@ -72,10 +67,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes", - path: []ottl.Field{ - { - Name: "attributes", - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", }, orig: refIS.Attributes(), newVal: newAttrs, @@ -85,14 +78,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes string", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("str"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("str"), }, }, orig: "val", @@ -103,14 +92,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes bool", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("bool"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("bool"), }, }, orig: true, @@ -121,14 +106,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes int", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("int"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("int"), }, }, orig: int64(10), @@ -139,14 +120,11 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes float", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("double"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + + S: ottltest.Strp("double"), }, }, orig: float64(1.2), @@ -157,14 +135,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes bytes", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("bytes"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("bytes"), }, }, orig: []byte{1, 3, 2}, @@ -175,14 +149,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes array string", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_str"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_str"), }, }, orig: func() pcommon.Slice { @@ -196,14 +166,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes array bool", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_bool"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_bool"), }, }, orig: func() pcommon.Slice { @@ -217,14 +183,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes array int", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_int"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_int"), }, }, orig: func() pcommon.Slice { @@ -238,14 +200,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes array float", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_float"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_float"), }, }, orig: func() pcommon.Slice { @@ -259,14 +217,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes array bytes", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_bytes"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_bytes"), }, }, orig: func() pcommon.Slice { @@ -280,14 +234,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes pcommon.Map", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("pMap"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("pMap"), }, }, orig: func() pcommon.Map { @@ -303,14 +253,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes map[string]any", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("map"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("map"), }, }, orig: func() pcommon.Map { @@ -326,18 +272,14 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes nested", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("slice"), - }, - { - Int: ottltest.Intp(0), - }, - { - String: ottltest.Strp("map"), + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("slice"), + NextKey: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(0), + NextKey: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("map"), }, }, }, @@ -354,18 +296,14 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes nested new values", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("new"), - }, - { - Int: ottltest.Intp(2), - }, - { - Int: ottltest.Intp(0), + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("new"), + NextKey: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(2), + NextKey: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(0), }, }, }, @@ -383,10 +321,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "dropped_attributes_count", - path: []ottl.Field{ - { - Name: "dropped_attributes_count", - }, + path: &internal.TestPath[TransformContext]{ + N: "dropped_attributes_count", }, orig: int64(10), newVal: int64(20), @@ -396,10 +332,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "name", - path: []ottl.Field{ - { - Name: "name", - }, + path: &internal.TestPath[TransformContext]{ + N: "name", }, orig: refIS.Name(), newVal: "newname", @@ -409,10 +343,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "version", - path: []ottl.Field{ - { - Name: "version", - }, + path: &internal.TestPath[TransformContext]{ + N: "version", }, orig: refIS.Version(), newVal: "next", @@ -422,10 +354,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "resource", - path: []ottl.Field{ - { - Name: "resource", - }, + path: &internal.TestPath[TransformContext]{ + N: "resource", }, orig: refResource, newVal: pcommon.NewResource(), @@ -436,7 +366,8 @@ func Test_newPathGetSetter(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - accessor, err := newPathGetSetter(tt.path) + pep := pathExpressionParser{} + accessor, err := pep.parsePath(tt.path) assert.NoError(t, err) il, resource := createTelemetry() diff --git a/pkg/ottl/contexts/ottlspan/span.go b/pkg/ottl/contexts/ottlspan/span.go index df2f2ddc2623..501e9bcc2a86 100644 --- a/pkg/ottl/contexts/ottlspan/span.go +++ b/pkg/ottl/contexts/ottlspan/span.go @@ -53,10 +53,10 @@ func (tCtx TransformContext) getCache() pcommon.Map { } func NewParser(functions map[string]ottl.Factory[TransformContext], telemetrySettings component.TelemetrySettings, options ...Option) (ottl.Parser[TransformContext], error) { - pathExpressionParser := pathExpressionParser{telemetrySettings} + pep := pathExpressionParser{telemetrySettings} p, err := ottl.NewParser[TransformContext]( functions, - pathExpressionParser.parsePath, + pep.parsePath, telemetrySettings, ottl.WithEnumParser[TransformContext](parseEnum), ) @@ -115,25 +115,20 @@ type pathExpressionParser struct { telemetrySettings component.TelemetrySettings } -func (pep *pathExpressionParser) parsePath(val *ottl.Path) (ottl.GetSetter[TransformContext], error) { - if val != nil && len(val.Fields) > 0 { - return newPathGetSetter(val.Fields) +func (pep *pathExpressionParser) parsePath(path ottl.Path[TransformContext]) (ottl.GetSetter[TransformContext], error) { + if path == nil { + return nil, fmt.Errorf("path cannot be nil") } - return nil, fmt.Errorf("bad path %v", val) -} - -func newPathGetSetter(path []ottl.Field) (ottl.GetSetter[TransformContext], error) { - switch path[0].Name { + switch path.Name() { case "cache": - mapKey := path[0].Keys - if mapKey == nil { + if path.Key() == nil { return accessCache(), nil } - return accessCacheKey(mapKey), nil + return accessCacheKey(path.Key()), nil case "resource": - return internal.ResourcePathGetSetter[TransformContext](path[1:]) + return internal.ResourcePathGetSetter[TransformContext](path.Next()) case "instrumentation_scope": - return internal.ScopePathGetSetter[TransformContext](path[1:]) + return internal.ScopePathGetSetter[TransformContext](path.Next()) default: return internal.SpanPathGetSetter[TransformContext](path) } @@ -153,13 +148,13 @@ func accessCache() ottl.StandardGetSetter[TransformContext] { } } -func accessCacheKey(keys []ottl.Key) ottl.StandardGetSetter[TransformContext] { +func accessCacheKey(key ottl.Key[TransformContext]) ottl.StandardGetSetter[TransformContext] { return ottl.StandardGetSetter[TransformContext]{ Getter: func(ctx context.Context, tCtx TransformContext) (any, error) { - return internal.GetMapValue(tCtx.getCache(), keys) + return internal.GetMapValue[TransformContext](ctx, tCtx, tCtx.getCache(), key) }, Setter: func(ctx context.Context, tCtx TransformContext, val any) error { - return internal.SetMapValue(tCtx.getCache(), keys, val) + return internal.SetMapValue[TransformContext](ctx, tCtx, tCtx.getCache(), key, val) }, } } diff --git a/pkg/ottl/contexts/ottlspan/span_test.go b/pkg/ottl/contexts/ottlspan/span_test.go index 0a195fff813d..49eecc988b94 100644 --- a/pkg/ottl/contexts/ottlspan/span_test.go +++ b/pkg/ottl/contexts/ottlspan/span_test.go @@ -14,6 +14,7 @@ import ( "go.opentelemetry.io/collector/pdata/ptrace" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/internal" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/ottltest" ) @@ -53,17 +54,15 @@ func Test_newPathGetSetter(t *testing.T) { tests := []struct { name string - path []ottl.Field + path ottl.Path[TransformContext] orig any newVal any modified func(span ptrace.Span, il pcommon.InstrumentationScope, resource pcommon.Resource, cache pcommon.Map) }{ { name: "cache", - path: []ottl.Field{ - { - Name: "cache", - }, + path: &internal.TestPath[TransformContext]{ + N: "cache", }, orig: pcommon.NewMap(), newVal: newCache, @@ -73,14 +72,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "cache access", - path: []ottl.Field{ - { - Name: "cache", - Keys: []ottl.Key{ - { - String: ottltest.Strp("temp"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "cache", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("temp"), }, }, orig: nil, @@ -91,10 +86,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "trace_id", - path: []ottl.Field{ - { - Name: "trace_id", - }, + path: &internal.TestPath[TransformContext]{ + N: "trace_id", }, orig: pcommon.TraceID(traceID), newVal: pcommon.TraceID(traceID2), @@ -104,10 +97,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "span_id", - path: []ottl.Field{ - { - Name: "span_id", - }, + path: &internal.TestPath[TransformContext]{ + N: "span_id", }, orig: pcommon.SpanID(spanID), newVal: pcommon.SpanID(spanID2), @@ -117,12 +108,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "trace_id string", - path: []ottl.Field{ - { - Name: "trace_id", - }, - { - Name: "string", + path: &internal.TestPath[TransformContext]{ + N: "trace_id", + NextPath: &internal.TestPath[TransformContext]{ + N: "string", }, }, orig: hex.EncodeToString(traceID[:]), @@ -133,12 +122,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "span_id string", - path: []ottl.Field{ - { - Name: "span_id", - }, - { - Name: "string", + path: &internal.TestPath[TransformContext]{ + N: "span_id", + NextPath: &internal.TestPath[TransformContext]{ + N: "string", }, }, orig: hex.EncodeToString(spanID[:]), @@ -149,10 +136,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "trace_state", - path: []ottl.Field{ - { - Name: "trace_state", - }, + path: &internal.TestPath[TransformContext]{ + N: "trace_state", }, orig: "key1=val1,key2=val2", newVal: "key=newVal", @@ -162,14 +147,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "trace_state key", - path: []ottl.Field{ - { - Name: "trace_state", - Keys: []ottl.Key{ - { - String: ottltest.Strp("key1"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "trace_state", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("key1"), }, }, orig: "val1", @@ -180,10 +161,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "parent_span_id", - path: []ottl.Field{ - { - Name: "parent_span_id", - }, + path: &internal.TestPath[TransformContext]{ + N: "parent_span_id", }, orig: pcommon.SpanID(spanID2), newVal: pcommon.SpanID(spanID), @@ -193,10 +172,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "name", - path: []ottl.Field{ - { - Name: "name", - }, + path: &internal.TestPath[TransformContext]{ + N: "name", }, orig: "bear", newVal: "cat", @@ -206,10 +183,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "kind", - path: []ottl.Field{ - { - Name: "kind", - }, + path: &internal.TestPath[TransformContext]{ + N: "kind", }, orig: int64(2), newVal: int64(3), @@ -219,12 +194,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "string kind", - path: []ottl.Field{ - { - Name: "kind", - }, - { - Name: "string", + path: &internal.TestPath[TransformContext]{ + N: "kind", + NextPath: &internal.TestPath[TransformContext]{ + N: "string", }, }, orig: "Server", @@ -235,12 +208,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "deprecated string kind", - path: []ottl.Field{ - { - Name: "kind", - }, - { - Name: "deprecated_string", + path: &internal.TestPath[TransformContext]{ + N: "kind", + NextPath: &internal.TestPath[TransformContext]{ + N: "deprecated_string", }, }, orig: "SPAN_KIND_SERVER", @@ -251,10 +222,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "start_time_unix_nano", - path: []ottl.Field{ - { - Name: "start_time_unix_nano", - }, + path: &internal.TestPath[TransformContext]{ + N: "start_time_unix_nano", }, orig: int64(100_000_000), newVal: int64(200_000_000), @@ -264,10 +233,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "end_time_unix_nano", - path: []ottl.Field{ - { - Name: "end_time_unix_nano", - }, + path: &internal.TestPath[TransformContext]{ + N: "end_time_unix_nano", }, orig: int64(500_000_000), newVal: int64(200_000_000), @@ -277,10 +244,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "start_time", - path: []ottl.Field{ - { - Name: "start_time", - }, + path: &internal.TestPath[TransformContext]{ + N: "start_time", }, orig: time.Date(1970, 1, 1, 0, 0, 0, 100000000, time.UTC), newVal: time.Date(1970, 1, 1, 0, 0, 0, 200000000, time.UTC), @@ -290,10 +255,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "end_time", - path: []ottl.Field{ - { - Name: "end_time", - }, + path: &internal.TestPath[TransformContext]{ + N: "end_time", }, orig: time.Date(1970, 1, 1, 0, 0, 0, 500000000, time.UTC), newVal: time.Date(1970, 1, 1, 0, 0, 0, 200000000, time.UTC), @@ -303,10 +266,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes", - path: []ottl.Field{ - { - Name: "attributes", - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", }, orig: refSpan.Attributes(), newVal: newAttrs, @@ -316,14 +277,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes string", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("str"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("str"), }, }, orig: "val", @@ -334,14 +291,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes bool", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("bool"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("bool"), }, }, orig: true, @@ -352,14 +305,11 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes int", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("int"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + + S: ottltest.Strp("int"), }, }, orig: int64(10), @@ -370,14 +320,12 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes float", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("double"), - }, - }, + path: &internal.TestPath[TransformContext]{ + + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + + S: ottltest.Strp("double"), }, }, orig: float64(1.2), @@ -388,14 +336,12 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes bytes", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("bytes"), - }, - }, + path: &internal.TestPath[TransformContext]{ + + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + + S: ottltest.Strp("bytes"), }, }, orig: []byte{1, 3, 2}, @@ -406,14 +352,12 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes array string", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_str"), - }, - }, + path: &internal.TestPath[TransformContext]{ + + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + + S: ottltest.Strp("arr_str"), }, }, orig: func() pcommon.Slice { @@ -427,14 +371,12 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes array bool", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_bool"), - }, - }, + path: &internal.TestPath[TransformContext]{ + + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + + S: ottltest.Strp("arr_bool"), }, }, orig: func() pcommon.Slice { @@ -448,14 +390,12 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes array int", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_int"), - }, - }, + path: &internal.TestPath[TransformContext]{ + + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + + S: ottltest.Strp("arr_int"), }, }, orig: func() pcommon.Slice { @@ -469,14 +409,12 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes array float", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_float"), - }, - }, + path: &internal.TestPath[TransformContext]{ + + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + + S: ottltest.Strp("arr_float"), }, }, orig: func() pcommon.Slice { @@ -490,14 +428,12 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes array bytes", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_bytes"), - }, - }, + path: &internal.TestPath[TransformContext]{ + + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + + S: ottltest.Strp("arr_bytes"), }, }, orig: func() pcommon.Slice { @@ -511,14 +447,12 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes pcommon.Map", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("pMap"), - }, - }, + path: &internal.TestPath[TransformContext]{ + + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + + S: ottltest.Strp("pMap"), }, }, orig: func() pcommon.Map { @@ -534,14 +468,12 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes map[string]any", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("map"), - }, - }, + path: &internal.TestPath[TransformContext]{ + + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + + S: ottltest.Strp("map"), }, }, orig: func() pcommon.Map { @@ -557,18 +489,16 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes nested", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("slice"), - }, - { - Int: ottltest.Intp(0), - }, - { - String: ottltest.Strp("map"), + path: &internal.TestPath[TransformContext]{ + + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + + S: ottltest.Strp("slice"), + NextKey: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(0), + NextKey: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("map"), }, }, }, @@ -585,18 +515,14 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes nested new values", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("new"), - }, - { - Int: ottltest.Intp(2), - }, - { - Int: ottltest.Intp(0), + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("new"), + NextKey: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(2), + NextKey: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(0), }, }, }, @@ -614,10 +540,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "dropped_attributes_count", - path: []ottl.Field{ - { - Name: "dropped_attributes_count", - }, + path: &internal.TestPath[TransformContext]{ + N: "dropped_attributes_count", }, orig: int64(10), newVal: int64(20), @@ -627,10 +551,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "events", - path: []ottl.Field{ - { - Name: "events", - }, + path: &internal.TestPath[TransformContext]{ + N: "events", }, orig: refSpan.Events(), newVal: newEvents, @@ -643,10 +565,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "dropped_events_count", - path: []ottl.Field{ - { - Name: "dropped_events_count", - }, + path: &internal.TestPath[TransformContext]{ + N: "dropped_events_count", }, orig: int64(20), newVal: int64(30), @@ -656,10 +576,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "links", - path: []ottl.Field{ - { - Name: "links", - }, + path: &internal.TestPath[TransformContext]{ + N: "links", }, orig: refSpan.Links(), newVal: newLinks, @@ -672,10 +590,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "dropped_links_count", - path: []ottl.Field{ - { - Name: "dropped_links_count", - }, + path: &internal.TestPath[TransformContext]{ + N: "dropped_links_count", }, orig: int64(30), newVal: int64(40), @@ -685,10 +601,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "status", - path: []ottl.Field{ - { - Name: "status", - }, + path: &internal.TestPath[TransformContext]{ + N: "status", }, orig: refSpan.Status(), newVal: newStatus, @@ -698,12 +612,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "status code", - path: []ottl.Field{ - { - Name: "status", - }, - { - Name: "code", + path: &internal.TestPath[TransformContext]{ + N: "status", + NextPath: &internal.TestPath[TransformContext]{ + N: "code", }, }, orig: int64(ptrace.StatusCodeOk), @@ -714,12 +626,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "status message", - path: []ottl.Field{ - { - Name: "status", - }, - { - Name: "message", + path: &internal.TestPath[TransformContext]{ + N: "status", + NextPath: &internal.TestPath[TransformContext]{ + N: "message", }, }, orig: "good span", @@ -730,10 +640,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "instrumentation_scope", - path: []ottl.Field{ - { - Name: "instrumentation_scope", - }, + path: &internal.TestPath[TransformContext]{ + N: "instrumentation_scope", }, orig: refIS, newVal: pcommon.NewInstrumentationScope(), @@ -743,10 +651,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "resource", - path: []ottl.Field{ - { - Name: "resource", - }, + path: &internal.TestPath[TransformContext]{ + N: "resource", }, orig: refResource, newVal: pcommon.NewResource(), @@ -754,36 +660,11 @@ func Test_newPathGetSetter(t *testing.T) { pcommon.NewResource().CopyTo(resource) }, }, - { - name: "start_time", - path: []ottl.Field{ - { - Name: "start_time", - }, - }, - orig: time.Date(1970, 1, 1, 0, 0, 0, 100000000, time.UTC), - newVal: time.Date(1970, 1, 1, 0, 0, 0, 200000000, time.UTC), - modified: func(span ptrace.Span, il pcommon.InstrumentationScope, resource pcommon.Resource, cache pcommon.Map) { - span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(200))) - }, - }, - { - name: "end_time", - path: []ottl.Field{ - { - Name: "end_time", - }, - }, - orig: time.Date(1970, 1, 1, 0, 0, 0, 500000000, time.UTC), - newVal: time.Date(1970, 1, 1, 0, 0, 0, 200000000, time.UTC), - modified: func(span ptrace.Span, il pcommon.InstrumentationScope, resource pcommon.Resource, cache pcommon.Map) { - span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(200))) - }, - }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - accessor, err := newPathGetSetter(tt.path) + pep := pathExpressionParser{} + accessor, err := pep.parsePath(tt.path) assert.NoError(t, err) span, il, resource := createTelemetry() diff --git a/pkg/ottl/contexts/ottlspanevent/span_events.go b/pkg/ottl/contexts/ottlspanevent/span_events.go index 8748ef2467c8..b16ebb1e74c4 100644 --- a/pkg/ottl/contexts/ottlspanevent/span_events.go +++ b/pkg/ottl/contexts/ottlspanevent/span_events.go @@ -61,10 +61,10 @@ func (tCtx TransformContext) getCache() pcommon.Map { } func NewParser(functions map[string]ottl.Factory[TransformContext], telemetrySettings component.TelemetrySettings, options ...Option) (ottl.Parser[TransformContext], error) { - pathExpressionParser := pathExpressionParser{telemetrySettings} + pep := pathExpressionParser{telemetrySettings} p, err := ottl.NewParser[TransformContext]( functions, - pathExpressionParser.parsePath, + pep.parsePath, telemetrySettings, ottl.WithEnumParser[TransformContext](parseEnum), ) @@ -123,27 +123,22 @@ type pathExpressionParser struct { telemetrySettings component.TelemetrySettings } -func (pep *pathExpressionParser) parsePath(val *ottl.Path) (ottl.GetSetter[TransformContext], error) { - if val != nil && len(val.Fields) > 0 { - return newPathGetSetter(val.Fields) +func (pep *pathExpressionParser) parsePath(path ottl.Path[TransformContext]) (ottl.GetSetter[TransformContext], error) { + if path == nil { + return nil, fmt.Errorf("path cannot be nil") } - return nil, fmt.Errorf("bad path %v", val) -} - -func newPathGetSetter(path []ottl.Field) (ottl.GetSetter[TransformContext], error) { - switch path[0].Name { + switch path.Name() { case "cache": - mapKey := path[0].Keys - if mapKey == nil { + if path.Key() == nil { return accessCache(), nil } - return accessCacheKey(mapKey), nil + return accessCacheKey(path.Key()), nil case "resource": - return internal.ResourcePathGetSetter[TransformContext](path[1:]) + return internal.ResourcePathGetSetter[TransformContext](path.Next()) case "instrumentation_scope": - return internal.ScopePathGetSetter[TransformContext](path[1:]) + return internal.ScopePathGetSetter[TransformContext](path.Next()) case "span": - return internal.SpanPathGetSetter[TransformContext](path[1:]) + return internal.SpanPathGetSetter[TransformContext](path.Next()) case "time_unix_nano": return accessSpanEventTimeUnixNano(), nil case "time": @@ -151,18 +146,16 @@ func newPathGetSetter(path []ottl.Field) (ottl.GetSetter[TransformContext], erro case "name": return accessSpanEventName(), nil case "attributes": - mapKey := path[0].Keys - if mapKey == nil { + if path.Key() == nil { return accessSpanEventAttributes(), nil } - return accessSpanEventAttributesKey(mapKey), nil + return accessSpanEventAttributesKey(path.Key()), nil case "dropped_attributes_count": return accessSpanEventDroppedAttributeCount(), nil } return nil, fmt.Errorf("invalid scope path expression %v", path) } - func accessCache() ottl.StandardGetSetter[TransformContext] { return ottl.StandardGetSetter[TransformContext]{ Getter: func(ctx context.Context, tCtx TransformContext) (any, error) { @@ -177,13 +170,13 @@ func accessCache() ottl.StandardGetSetter[TransformContext] { } } -func accessCacheKey(keys []ottl.Key) ottl.StandardGetSetter[TransformContext] { +func accessCacheKey(key ottl.Key[TransformContext]) ottl.StandardGetSetter[TransformContext] { return ottl.StandardGetSetter[TransformContext]{ Getter: func(ctx context.Context, tCtx TransformContext) (any, error) { - return internal.GetMapValue(tCtx.getCache(), keys) + return internal.GetMapValue[TransformContext](ctx, tCtx, tCtx.getCache(), key) }, Setter: func(ctx context.Context, tCtx TransformContext, val any) error { - return internal.SetMapValue(tCtx.getCache(), keys, val) + return internal.SetMapValue[TransformContext](ctx, tCtx, tCtx.getCache(), key, val) }, } } @@ -244,13 +237,13 @@ func accessSpanEventAttributes() ottl.StandardGetSetter[TransformContext] { } } -func accessSpanEventAttributesKey(keys []ottl.Key) ottl.StandardGetSetter[TransformContext] { +func accessSpanEventAttributesKey(key ottl.Key[TransformContext]) ottl.StandardGetSetter[TransformContext] { return ottl.StandardGetSetter[TransformContext]{ Getter: func(ctx context.Context, tCtx TransformContext) (any, error) { - return internal.GetMapValue(tCtx.GetSpanEvent().Attributes(), keys) + return internal.GetMapValue[TransformContext](ctx, tCtx, tCtx.GetSpanEvent().Attributes(), key) }, Setter: func(ctx context.Context, tCtx TransformContext, val any) error { - return internal.SetMapValue(tCtx.GetSpanEvent().Attributes(), keys, val) + return internal.SetMapValue[TransformContext](ctx, tCtx, tCtx.GetSpanEvent().Attributes(), key, val) }, } } diff --git a/pkg/ottl/contexts/ottlspanevent/span_events_test.go b/pkg/ottl/contexts/ottlspanevent/span_events_test.go index 1cb71ad73108..afa4322f7ab8 100644 --- a/pkg/ottl/contexts/ottlspanevent/span_events_test.go +++ b/pkg/ottl/contexts/ottlspanevent/span_events_test.go @@ -13,6 +13,7 @@ import ( "go.opentelemetry.io/collector/pdata/ptrace" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/internal" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/ottltest" ) @@ -49,17 +50,15 @@ func Test_newPathGetSetter(t *testing.T) { tests := []struct { name string - path []ottl.Field + path ottl.Path[TransformContext] orig any newVal any modified func(spanEvent ptrace.SpanEvent, span ptrace.Span, il pcommon.InstrumentationScope, resource pcommon.Resource, cache pcommon.Map) }{ { name: "span event time", - path: []ottl.Field{ - { - Name: "time", - }, + path: &internal.TestPath[TransformContext]{ + N: "time", }, orig: time.Date(1970, 1, 1, 0, 0, 0, 100000000, time.UTC), newVal: time.Date(1970, 1, 1, 0, 0, 0, 200000000, time.UTC), @@ -69,10 +68,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "cache", - path: []ottl.Field{ - { - Name: "cache", - }, + path: &internal.TestPath[TransformContext]{ + N: "cache", }, orig: pcommon.NewMap(), newVal: newCache, @@ -82,14 +79,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "cache access", - path: []ottl.Field{ - { - Name: "cache", - Keys: []ottl.Key{ - { - String: ottltest.Strp("temp"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "cache", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("temp"), }, }, orig: nil, @@ -100,10 +93,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "name", - path: []ottl.Field{ - { - Name: "name", - }, + path: &internal.TestPath[TransformContext]{ + N: "name", }, orig: "bear", newVal: "cat", @@ -113,10 +104,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "time_unix_nano", - path: []ottl.Field{ - { - Name: "time_unix_nano", - }, + path: &internal.TestPath[TransformContext]{ + N: "time_unix_nano", }, orig: int64(100_000_000), newVal: int64(200_000_000), @@ -126,10 +115,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes", - path: []ottl.Field{ - { - Name: "attributes", - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", }, orig: refSpanEvent.Attributes(), newVal: newAttrs, @@ -139,14 +126,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes string", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("str"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("str"), }, }, orig: "val", @@ -157,14 +140,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes bool", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("bool"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("bool"), }, }, orig: true, @@ -175,14 +154,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes int", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("int"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("int"), }, }, orig: int64(10), @@ -193,14 +168,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes float", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("double"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("double"), }, }, orig: float64(1.2), @@ -211,14 +182,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes bytes", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("bytes"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("bytes"), }, }, orig: []byte{1, 3, 2}, @@ -229,14 +196,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes array string", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_str"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_str"), }, }, orig: func() pcommon.Slice { @@ -250,14 +213,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes array bool", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_bool"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_bool"), }, }, orig: func() pcommon.Slice { @@ -271,14 +230,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes array int", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_int"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_int"), }, }, orig: func() pcommon.Slice { @@ -292,14 +247,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes array float", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_float"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_float"), }, }, orig: func() pcommon.Slice { @@ -313,14 +264,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes array bytes", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("arr_bytes"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("arr_bytes"), }, }, orig: func() pcommon.Slice { @@ -334,14 +281,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes pcommon.Map", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("pMap"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("pMap"), }, }, orig: func() pcommon.Map { @@ -357,14 +300,10 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes map[string]any", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("map"), - }, - }, + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("map"), }, }, orig: func() pcommon.Map { @@ -380,18 +319,14 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes nested", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("slice"), - }, - { - Int: ottltest.Intp(0), - }, - { - String: ottltest.Strp("map"), + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("slice"), + NextKey: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(0), + NextKey: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("map"), }, }, }, @@ -408,18 +343,14 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "attributes nested new values", - path: []ottl.Field{ - { - Name: "attributes", - Keys: []ottl.Key{ - { - String: ottltest.Strp("new"), - }, - { - Int: ottltest.Intp(2), - }, - { - Int: ottltest.Intp(0), + path: &internal.TestPath[TransformContext]{ + N: "attributes", + Keys: &internal.TestKey[TransformContext]{ + S: ottltest.Strp("new"), + NextKey: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(2), + NextKey: &internal.TestKey[TransformContext]{ + I: ottltest.Intp(0), }, }, }, @@ -437,10 +368,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "dropped_attributes_count", - path: []ottl.Field{ - { - Name: "dropped_attributes_count", - }, + path: &internal.TestPath[TransformContext]{ + N: "dropped_attributes_count", }, orig: int64(10), newVal: int64(20), @@ -450,10 +379,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "instrumentation_scope", - path: []ottl.Field{ - { - Name: "instrumentation_scope", - }, + path: &internal.TestPath[TransformContext]{ + N: "instrumentation_scope", }, orig: refIS, newVal: pcommon.NewInstrumentationScope(), @@ -463,10 +390,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "resource", - path: []ottl.Field{ - { - Name: "resource", - }, + path: &internal.TestPath[TransformContext]{ + N: "resource", }, orig: refResource, newVal: pcommon.NewResource(), @@ -476,10 +401,8 @@ func Test_newPathGetSetter(t *testing.T) { }, { name: "span", - path: []ottl.Field{ - { - Name: "span", - }, + path: &internal.TestPath[TransformContext]{ + N: "span", }, orig: refSpan, newVal: ptrace.NewSpan(), @@ -490,7 +413,8 @@ func Test_newPathGetSetter(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - accessor, err := newPathGetSetter(tt.path) + pep := pathExpressionParser{} + accessor, err := pep.parsePath(tt.path) assert.NoError(t, err) spanEvent, span, il, resource := createTelemetry() diff --git a/pkg/ottl/expression.go b/pkg/ottl/expression.go index 1c5ac3f69b17..f1adaa161e8d 100644 --- a/pkg/ottl/expression.go +++ b/pkg/ottl/expression.go @@ -63,7 +63,7 @@ func (l literal[K]) Get(context.Context, K) (any, error) { type exprGetter[K any] struct { expr Expr[K] - keys []Key + keys []key } func (g exprGetter[K]) Get(ctx context.Context, tCtx K) (any, error) { @@ -616,7 +616,7 @@ func (p *Parser[K]) newGetter(val value) (Getter[K], error) { } if val.Enum != nil { - enum, err := p.enumParser(val.Enum) + enum, err := p.enumParser((*EnumSymbol)(val.Enum)) if err != nil { return nil, err } @@ -631,7 +631,11 @@ func (p *Parser[K]) newGetter(val value) (Getter[K], error) { return &literal[K]{value: *i}, nil } if eL.Path != nil { - return p.pathParser(eL.Path) + np, err := newPath[K](eL.Path.Fields) + if err != nil { + return nil, err + } + return p.parsePath(np) } if eL.Converter != nil { return p.newGetterFromConverter(*eL.Converter) diff --git a/pkg/ottl/expression_test.go b/pkg/ottl/expression_test.go index 478d56defead..4e18958d3822 100644 --- a/pkg/ottl/expression_test.go +++ b/pkg/ottl/expression_test.go @@ -116,8 +116,8 @@ func Test_newGetter(t *testing.T) { name: "path expression", val: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -131,11 +131,11 @@ func Test_newGetter(t *testing.T) { name: "complex path expression", val: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "attributes", - Keys: []Key{ + Keys: []key{ { String: ottltest.Strp("foo"), }, @@ -167,7 +167,7 @@ func Test_newGetter(t *testing.T) { Literal: &mathExprLiteral{ Converter: &converter{ Function: "PMap", - Keys: []Key{ + Keys: []key{ { String: ottltest.Strp("foo"), }, @@ -186,7 +186,7 @@ func Test_newGetter(t *testing.T) { Literal: &mathExprLiteral{ Converter: &converter{ Function: "Map", - Keys: []Key{ + Keys: []key{ { String: ottltest.Strp("foo"), }, @@ -205,7 +205,7 @@ func Test_newGetter(t *testing.T) { Literal: &mathExprLiteral{ Converter: &converter{ Function: "PSlice", - Keys: []Key{ + Keys: []key{ { Int: ottltest.Intp(0), }, @@ -224,7 +224,7 @@ func Test_newGetter(t *testing.T) { Literal: &mathExprLiteral{ Converter: &converter{ Function: "Slice", - Keys: []Key{ + Keys: []key{ { Int: ottltest.Intp(0), }, @@ -240,7 +240,7 @@ func Test_newGetter(t *testing.T) { { name: "enum", val: value{ - Enum: (*EnumSymbol)(ottltest.Strp("TEST_ENUM_ONE")), + Enum: (*enumSymbol)(ottltest.Strp("TEST_ENUM_ONE")), }, want: int64(1), }, @@ -348,8 +348,8 @@ func Test_newGetter(t *testing.T) { Values: []value{ { Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -426,7 +426,7 @@ func Test_newGetter(t *testing.T) { p, _ := NewParser[any]( functions, - testParsePath, + testParsePath[any], componenttest.NewNopTelemetrySettings(), WithEnumParser[any](testParseEnum), ) @@ -465,7 +465,7 @@ func Test_exprGetter_Get_Invalid(t *testing.T) { Literal: &mathExprLiteral{ Converter: &converter{ Function: "PMap", - Keys: []Key{ + Keys: []key{ { String: ottltest.Strp("unknown key"), }, @@ -481,7 +481,7 @@ func Test_exprGetter_Get_Invalid(t *testing.T) { Literal: &mathExprLiteral{ Converter: &converter{ Function: "Map", - Keys: []Key{ + Keys: []key{ { String: ottltest.Strp("unknown key"), }, @@ -497,7 +497,7 @@ func Test_exprGetter_Get_Invalid(t *testing.T) { Literal: &mathExprLiteral{ Converter: &converter{ Function: "PSlice", - Keys: []Key{ + Keys: []key{ { Int: ottltest.Intp(100), }, @@ -513,7 +513,7 @@ func Test_exprGetter_Get_Invalid(t *testing.T) { Literal: &mathExprLiteral{ Converter: &converter{ Function: "PSlice", - Keys: []Key{ + Keys: []key{ { Int: ottltest.Intp(-1), }, @@ -529,7 +529,7 @@ func Test_exprGetter_Get_Invalid(t *testing.T) { Literal: &mathExprLiteral{ Converter: &converter{ Function: "Slice", - Keys: []Key{ + Keys: []key{ { Int: ottltest.Intp(100), }, @@ -545,7 +545,7 @@ func Test_exprGetter_Get_Invalid(t *testing.T) { Literal: &mathExprLiteral{ Converter: &converter{ Function: "Slice", - Keys: []Key{ + Keys: []key{ { Int: ottltest.Intp(-1), }, @@ -561,7 +561,7 @@ func Test_exprGetter_Get_Invalid(t *testing.T) { Literal: &mathExprLiteral{ Converter: &converter{ Function: "Hello", - Keys: []Key{ + Keys: []key{ { Int: ottltest.Intp(-1), }, @@ -577,7 +577,7 @@ func Test_exprGetter_Get_Invalid(t *testing.T) { Literal: &mathExprLiteral{ Converter: &converter{ Function: "Hello", - Keys: []Key{ + Keys: []key{ { String: ottltest.Strp("test"), }, @@ -599,7 +599,7 @@ func Test_exprGetter_Get_Invalid(t *testing.T) { p, _ := NewParser[any]( functions, - testParsePath, + testParsePath[any], componenttest.NewNopTelemetrySettings(), WithEnumParser[any](testParseEnum), ) diff --git a/pkg/ottl/functions.go b/pkg/ottl/functions.go index 483f205eec17..6a10b915efe3 100644 --- a/pkg/ottl/functions.go +++ b/pkg/ottl/functions.go @@ -13,15 +13,17 @@ import ( "github.com/iancoleman/strcase" ) -type PathExpressionParser[K any] func(*Path) (GetSetter[K], error) +type PathExpressionParser[K any] func(Path[K]) (GetSetter[K], error) type EnumParser func(*EnumSymbol) (*Enum, error) type Enum int64 -func newPath[K any](fields []Field) *basePath[K] { +type EnumSymbol string + +func newPath[K any](fields []field) (*basePath[K], error) { if len(fields) == 0 { - return nil + return nil, fmt.Errorf("cannot make a path from zero fields") } var current *basePath[K] for i := len(fields) - 1; i >= 0; i-- { @@ -32,20 +34,30 @@ func newPath[K any](fields []Field) *basePath[K] { } } current.fetched = true - return current + return current, nil } -type path[K any] interface { +// Path represents a chain of path parts in an OTTL statement, such as `body.string`. +// A Path has a name, and potentially a set of keys. +// If the path in the OTTL statement contains multiple parts (separated by a dot (`.`)), then the Path will have a pointer to the next Path. +type Path[K any] interface { + // Name is the name of this segment of the path. Name() string - Next() path[K] - Key() key[K] + + // Next provides the next path segment for this Path. + // Will return nil if there is no next path. + Next() Path[K] + + // Key provides the Key for this Path. + // Will return nil if there is no Key. + Key() Key[K] } -var _ path[any] = &basePath[any]{} +var _ Path[any] = &basePath[any]{} type basePath[K any] struct { name string - key key[K] + key *baseKey[K] nextPath *basePath[K] fetched bool } @@ -54,7 +66,7 @@ func (p *basePath[K]) Name() string { return p.name } -func (p *basePath[K]) Next() path[K] { +func (p *basePath[K]) Next() Path[K] { if p.nextPath == nil { return nil } @@ -62,7 +74,10 @@ func (p *basePath[K]) Next() path[K] { return p.nextPath } -func (p *basePath[K]) Key() key[K] { +func (p *basePath[K]) Key() Key[K] { + if p.key == nil { + return nil + } return p.key } @@ -76,7 +91,7 @@ func (p *basePath[K]) isComplete() error { return p.nextPath.isComplete() } -func newKey[K any](keys []Key) *baseKey[K] { +func newKey[K any](keys []key) *baseKey[K] { if len(keys) == 0 { return nil } @@ -88,23 +103,34 @@ func newKey[K any](keys []Key) *baseKey[K] { nextKey: current, } } - current.fetched = true return current } -type key[K any] interface { +// Key represents a chain of keys in an OTTL statement, such as `attributes["foo"]["bar"]`. +// A Key has a String or Int, and potentially the next Key. +// If the path in the OTTL statement contains multiple keys, then the Key will have a pointer to the next Key. +type Key[K any] interface { + // String returns a pointer to the Key's string value. + // If the Key does not have a string value the returned value is nil. + // If Key experiences an error retrieving the value it is returned. String(context.Context, K) (*string, error) + + // Int returns a pointer to the Key's int value. + // If the Key does not have a int value the returned value is nil. + // If Key experiences an error retrieving the value it is returned. Int(context.Context, K) (*int64, error) - Next() key[K] + + // Next provides the next Key. + // Will return nil if there is no next Key. + Next() Key[K] } -var _ key[any] = &baseKey[any]{} +var _ Key[any] = &baseKey[any]{} type baseKey[K any] struct { s *string i *int64 nextKey *baseKey[K] - fetched bool } func (k *baseKey[K]) String(_ context.Context, _ K) (*string, error) { @@ -115,28 +141,23 @@ func (k *baseKey[K]) Int(_ context.Context, _ K) (*int64, error) { return k.i, nil } -func (k *baseKey[K]) Next() key[K] { +func (k *baseKey[K]) Next() Key[K] { if k.nextKey == nil { return nil } - k.nextKey.fetched = true return k.nextKey } -func (k *baseKey[K]) isComplete() error { - if !k.fetched { - var val any - if k.s != nil { - val = *k.s - } else if k.i != nil { - val = *k.i - } - return fmt.Errorf("the key %q was not used by the context during indexing", val) +func (p *Parser[K]) parsePath(ip *basePath[K]) (GetSetter[K], error) { + g, err := p.pathParser(ip) + if err != nil { + return nil, err } - if k.nextKey == nil { - return nil + err = ip.isComplete() + if err != nil { + return nil, err } - return k.nextKey.isComplete() + return g, nil } func (p *Parser[K]) newFunctionCall(ed editor) (Expr[K], error) { @@ -362,9 +383,13 @@ func (p *Parser[K]) buildArg(argVal value, argType reflect.Type) (any, error) { fallthrough case strings.HasPrefix(name, "GetSetter"): if argVal.Literal == nil || argVal.Literal.Path == nil { - return nil, fmt.Errorf("must be a Path") + return nil, fmt.Errorf("must be a path") + } + np, err := newPath[K](argVal.Literal.Path.Fields) + if err != nil { + return nil, err } - arg, err := p.pathParser(argVal.Literal.Path) + arg, err := p.parsePath(np) if err != nil { return nil, err } @@ -430,7 +455,7 @@ func (p *Parser[K]) buildArg(argVal value, argType reflect.Type) (any, error) { } return StandardTimeGetter[K]{Getter: arg.Get}, nil case name == "Enum": - arg, err := p.enumParser(argVal.Enum) + arg, err := p.enumParser((*EnumSymbol)(argVal.Enum)) if err != nil { return nil, fmt.Errorf("must be an Enum") } diff --git a/pkg/ottl/functions_test.go b/pkg/ottl/functions_test.go index 8327396403e7..fe9c309fecb5 100644 --- a/pkg/ottl/functions_test.go +++ b/pkg/ottl/functions_test.go @@ -83,7 +83,7 @@ func Test_NewFunctionCall_invalid(t *testing.T) { p, _ := NewParser( functions, - testParsePath, + testParsePath[any], componenttest.NewNopTelemetrySettings(), WithEnumParser[any](testParseEnum), ) @@ -150,8 +150,8 @@ func Test_NewFunctionCall_invalid(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -176,8 +176,8 @@ func Test_NewFunctionCall_invalid(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -283,8 +283,8 @@ func Test_NewFunctionCall_invalid(t *testing.T) { Name: "get_setter_arg", Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -323,8 +323,8 @@ func Test_NewFunctionCall_invalid(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -368,7 +368,7 @@ func Test_NewFunctionCall_invalid(t *testing.T) { Arguments: []argument{ { Value: value{ - Enum: (*EnumSymbol)(ottltest.Strp("SYMBOL_NOT_FOUND")), + Enum: (*enumSymbol)(ottltest.Strp("SYMBOL_NOT_FOUND")), }, }, }, @@ -393,6 +393,30 @@ func Test_NewFunctionCall_invalid(t *testing.T) { Function: "non_pointer", }, }, + { + name: "path parts not all used", + inv: editor{ + Function: "testing_getsetter", + Arguments: []argument{ + { + Value: value{ + Literal: &mathExprLiteral{ + Path: &path{ + Fields: []field{ + { + Name: "name", + }, + { + Name: "not-used", + }, + }, + }, + }, + }, + }, + }, + }, + }, } for _, tt := range tests { @@ -407,7 +431,7 @@ func Test_NewFunctionCall_invalid(t *testing.T) { func Test_NewFunctionCall(t *testing.T) { p, _ := NewParser( defaultFunctionsForTests(), - testParsePath, + testParsePath[any], componenttest.NewNopTelemetrySettings(), WithEnumParser[any](testParseEnum), ) @@ -542,8 +566,8 @@ func Test_NewFunctionCall(t *testing.T) { Values: []value{ { Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -568,7 +592,7 @@ func Test_NewFunctionCall(t *testing.T) { Bool: (*boolean)(ottltest.Boolp(true)), }, { - Enum: (*EnumSymbol)(ottltest.Strp("TEST_ENUM")), + Enum: (*enumSymbol)(ottltest.Strp("TEST_ENUM")), }, { List: &list{ @@ -620,8 +644,8 @@ func Test_NewFunctionCall(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -766,8 +790,8 @@ func Test_NewFunctionCall(t *testing.T) { Values: []value{ { Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -777,8 +801,8 @@ func Test_NewFunctionCall(t *testing.T) { }, { Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -877,8 +901,8 @@ func Test_NewFunctionCall(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -899,8 +923,8 @@ func Test_NewFunctionCall(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -921,8 +945,8 @@ func Test_NewFunctionCall(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -979,8 +1003,8 @@ func Test_NewFunctionCall(t *testing.T) { }, { Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -996,8 +1020,8 @@ func Test_NewFunctionCall(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -1168,8 +1192,8 @@ func Test_NewFunctionCall(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -1264,8 +1288,8 @@ func Test_NewFunctionCall(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -1305,8 +1329,8 @@ func Test_NewFunctionCall(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -1344,8 +1368,8 @@ func Test_NewFunctionCall(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -1384,7 +1408,37 @@ func Test_NewFunctionCall(t *testing.T) { Arguments: []argument{ { Value: value{ - Enum: (*EnumSymbol)(ottltest.Strp("TEST_ENUM")), + Enum: (*enumSymbol)(ottltest.Strp("TEST_ENUM")), + }, + }, + }, + }, + want: nil, + }, + { + name: "Complex Indexing", + inv: editor{ + Function: "testing_getsetter", + Arguments: []argument{ + { + Value: value{ + Literal: &mathExprLiteral{ + Path: &path{ + Fields: []field{ + { + Name: "name", + Keys: []key{ + { + String: ottltest.Strp("foo"), + }, + { + String: ottltest.Strp("bar"), + }, + }, + }, + }, + }, + }, }, }, }, @@ -1414,7 +1468,7 @@ func Test_ArgumentsNotMutated(t *testing.T) { ) p, _ := NewParser( CreateFactoryMap[any](fact), - testParsePath, + testParsePath[any], componenttest.NewNopTelemetrySettings(), WithEnumParser[any](testParseEnum), ) @@ -1425,8 +1479,8 @@ func Test_ArgumentsNotMutated(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -1461,8 +1515,8 @@ func Test_ArgumentsNotMutated(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -2220,7 +2274,7 @@ func Test_basePath_NextWithIsComplete(t *testing.T) { } func Test_newPath(t *testing.T) { - fields := []Field{ + fields := []field{ { Name: "body", }, @@ -2228,11 +2282,15 @@ func Test_newPath(t *testing.T) { Name: "string", }, } - p := newPath[any](fields) - assert.Equal(t, "body", p.name) - p = p.nextPath - assert.Equal(t, "string", p.name) - assert.Nil(t, p.nextPath) + np, err := newPath[any](fields) + assert.NoError(t, err) + p := Path[any](np) + assert.Equal(t, "body", p.Name()) + assert.Nil(t, p.Key()) + p = p.Next() + assert.Equal(t, "string", p.Name()) + assert.Nil(t, p.Key()) + assert.Nil(t, p.Next()) } func Test_baseKey_String(t *testing.T) { @@ -2264,108 +2322,8 @@ func Test_baseKey_Next(t *testing.T) { assert.Nil(t, next.Next()) } -func Test_baseKey_isComplete(t *testing.T) { - tests := []struct { - name string - p baseKey[any] - expectedError bool - }{ - { - name: "fetched no next", - p: baseKey[any]{ - fetched: true, - }, - }, - { - name: "fetched with next", - p: baseKey[any]{ - fetched: true, - nextKey: &baseKey[any]{ - fetched: true, - }, - }, - }, - { - name: "not fetched no next", - p: baseKey[any]{ - fetched: false, - }, - expectedError: true, - }, - { - name: "not fetched with next", - p: baseKey[any]{ - fetched: true, - nextKey: &baseKey[any]{ - fetched: false, - }, - }, - expectedError: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - err := tt.p.isComplete() - if tt.expectedError { - assert.Error(t, err) - } else { - assert.NoError(t, err) - } - }) - } -} - -func Test_baseKey_NextWithIsComplete(t *testing.T) { - tests := []struct { - name string - keyFunc func() *baseKey[any] - expectedError bool - }{ - { - name: "fetched", - keyFunc: func() *baseKey[any] { - bk := baseKey[any]{ - fetched: true, - nextKey: &baseKey[any]{ - fetched: false, - }, - } - bk.Next() - return &bk - }, - }, - { - name: "not fetched enough", - keyFunc: func() *baseKey[any] { - bk := baseKey[any]{ - fetched: true, - nextKey: &baseKey[any]{ - fetched: false, - nextKey: &baseKey[any]{ - fetched: false, - }, - }, - } - bk.Next() - return &bk - }, - expectedError: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - err := tt.keyFunc().isComplete() - if tt.expectedError { - assert.Error(t, err) - } else { - assert.NoError(t, err) - } - }) - } -} - func Test_newKey(t *testing.T) { - keys := []Key{ + keys := []key{ { String: ottltest.Strp("foo"), }, @@ -2373,9 +2331,15 @@ func Test_newKey(t *testing.T) { String: ottltest.Strp("bar"), }, } - k := newKey[any](keys) - assert.Equal(t, "foo", *k.s) - k = k.nextKey - assert.Equal(t, "bar", *k.s) - assert.Nil(t, k.nextKey) + k := Key[any](newKey[any](keys)) + s, err := k.String(context.Background(), nil) + assert.NoError(t, err) + assert.NotNil(t, s) + assert.Equal(t, "foo", *s) + k = k.Next() + s, err = k.String(context.Background(), nil) + assert.NoError(t, err) + assert.NotNil(t, s) + assert.Equal(t, "bar", *s) + assert.Nil(t, k.Next()) } diff --git a/pkg/ottl/go.mod b/pkg/ottl/go.mod index 80761aca220f..fbb8682b3f51 100644 --- a/pkg/ottl/go.mod +++ b/pkg/ottl/go.mod @@ -14,7 +14,7 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 - golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb + golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 ) require ( diff --git a/pkg/ottl/go.sum b/pkg/ottl/go.sum index de9902d5b8cc..24e6fbb3cc94 100644 --- a/pkg/ottl/go.sum +++ b/pkg/ottl/go.sum @@ -80,8 +80,8 @@ go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= diff --git a/pkg/ottl/grammar.go b/pkg/ottl/grammar.go index e8381292cc13..cbcfdf39256c 100644 --- a/pkg/ottl/grammar.go +++ b/pkg/ottl/grammar.go @@ -123,22 +123,22 @@ type compareOp int // These are the allowed values of a compareOp const ( - EQ compareOp = iota - NE - LT - LTE - GTE - GT + eq compareOp = iota + ne + lt + lte + gte + gt ) // a fast way to get from a string to a compareOp var compareOpTable = map[string]compareOp{ - "==": EQ, - "!=": NE, - "<": LT, - "<=": LTE, - ">": GT, - ">=": GTE, + "==": eq, + "!=": ne, + "<": lt, + "<=": lte, + ">": gt, + ">=": gte, } // Capture is how the parser converts an operator string to a compareOp. @@ -154,18 +154,18 @@ func (c *compareOp) Capture(values []string) error { // String() for compareOp gives us more legible test results and error messages. func (c *compareOp) String() string { switch *c { - case EQ: - return "EQ" - case NE: - return "NE" - case LT: - return "LT" - case LTE: - return "LTE" - case GTE: - return "GTE" - case GT: - return "GT" + case eq: + return "eq" + case ne: + return "ne" + case lt: + return "lt" + case lte: + return "lte" + case gte: + return "gte" + case gt: + return "gt" default: return "UNKNOWN OP!" } @@ -192,7 +192,7 @@ type editor struct { Function string `parser:"@(Lowercase(Uppercase | Lowercase)*)"` Arguments []argument `parser:"'(' ( @@ ( ',' @@ )* )? ')'"` // If keys are matched return an error - Keys []Key `parser:"( @@ )*"` + Keys []key `parser:"( @@ )*"` } func (i *editor) checkForCustomError() error { @@ -214,7 +214,7 @@ func (i *editor) checkForCustomError() error { type converter struct { Function string `parser:"@(Uppercase(Uppercase | Lowercase)*)"` Arguments []argument `parser:"'(' ( @@ ( ',' @@ )* )? ')'"` - Keys []Key `parser:"( @@ )*"` + Keys []key `parser:"( @@ )*"` } type argument struct { @@ -235,7 +235,7 @@ type value struct { Bytes *byteSlice `parser:"| @Bytes"` String *string `parser:"| @String"` Bool *boolean `parser:"| @Boolean"` - Enum *EnumSymbol `parser:"| @Uppercase (?! Lowercase)"` + Enum *enumSymbol `parser:"| @Uppercase (?! Lowercase)"` FunctionName *string `parser:"| @(Uppercase(Uppercase | Lowercase)*)"` List *list `parser:"| @@)"` } @@ -250,18 +250,18 @@ func (v *value) checkForCustomError() error { return nil } -// Path represents a telemetry path mathExpression. -type Path struct { - Fields []Field `parser:"@@ ( '.' @@ )*"` +// path represents a telemetry path mathExpression. +type path struct { + Fields []field `parser:"@@ ( '.' @@ )*"` } -// Field is an item within a Path. -type Field struct { +// field is an item within a path. +type field struct { Name string `parser:"@Lowercase"` - Keys []Key `parser:"( @@ )*"` + Keys []key `parser:"( @@ )*"` } -type Key struct { +type key struct { String *string `parser:"'[' (@String "` Int *int64 `parser:"| @Int) ']'"` } @@ -305,7 +305,7 @@ type mathExprLiteral struct { Converter *converter `parser:"| @@"` Float *float64 `parser:"| @Float"` Int *int64 `parser:"| @Int"` - Path *Path `parser:"| @@ )"` + Path *path `parser:"| @@ )"` } func (m *mathExprLiteral) checkForCustomError() error { @@ -386,17 +386,17 @@ func (m *mathExpression) checkForCustomError() error { type mathOp int const ( - ADD mathOp = iota - SUB - MULT - DIV + add mathOp = iota + sub + mult + div ) var mathOpTable = map[string]mathOp{ - "+": ADD, - "-": SUB, - "*": MULT, - "/": DIV, + "+": add, + "-": sub, + "*": mult, + "/": div, } func (m *mathOp) Capture(values []string) error { @@ -410,20 +410,20 @@ func (m *mathOp) Capture(values []string) error { func (m *mathOp) String() string { switch *m { - case ADD: + case add: return "+" - case SUB: + case sub: return "-" - case MULT: + case mult: return "*" - case DIV: + case div: return "/" default: return "UNKNOWN OP!" } } -type EnumSymbol string +type enumSymbol string // buildLexer constructs a SimpleLexer definition. // Note that the ordering of these rules matters. diff --git a/pkg/ottl/math.go b/pkg/ottl/math.go index eae661e639ef..9c9dd3dc18d6 100644 --- a/pkg/ottl/math.go +++ b/pkg/ottl/math.go @@ -113,7 +113,7 @@ func attemptMathOperation[K any](lhs Getter[K], op mathOp, rhs Getter[K]) Getter func performOpTime(x time.Time, y any, op mathOp) (any, error) { switch op { - case ADD: + case add: switch newY := y.(type) { case time.Duration: result := x.Add(newY) @@ -121,7 +121,7 @@ func performOpTime(x time.Time, y any, op mathOp) (any, error) { default: return nil, fmt.Errorf("time.Time must be added to time.Duration; found %v instead", y) } - case SUB: + case sub: switch newY := y.(type) { case time.Time: result := x.Sub(newY) @@ -138,7 +138,7 @@ func performOpTime(x time.Time, y any, op mathOp) (any, error) { func performOpDuration(x time.Duration, y any, op mathOp) (any, error) { switch op { - case ADD: + case add: switch newY := y.(type) { case time.Duration: result := x + newY @@ -149,7 +149,7 @@ func performOpDuration(x time.Duration, y any, op mathOp) (any, error) { default: return nil, fmt.Errorf("time.Duration must be added to time.Duration or time.Time; found %v instead", y) } - case SUB: + case sub: switch newY := y.(type) { case time.Duration: result := x - newY @@ -163,13 +163,13 @@ func performOpDuration(x time.Duration, y any, op mathOp) (any, error) { func performOp[N int64 | float64](x N, y N, op mathOp) (N, error) { switch op { - case ADD: + case add: return x + y, nil - case SUB: + case sub: return x - y, nil - case MULT: + case mult: return x * y, nil - case DIV: + case div: if y == 0 { return 0, fmt.Errorf("attempted to divide by 0") } diff --git a/pkg/ottl/math_test.go b/pkg/ottl/math_test.go index e993b3dd8d53..3fc73ca10c7e 100644 --- a/pkg/ottl/math_test.go +++ b/pkg/ottl/math_test.go @@ -18,29 +18,29 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/ottltest" ) -func mathParsePath(val *Path) (GetSetter[any], error) { - if val != nil && len(val.Fields) > 0 && val.Fields[0].Name == "one" { +func mathParsePath[K any](p Path[K]) (GetSetter[any], error) { + if p != nil && p.Name() == "one" { return &StandardGetSetter[any]{ Getter: func(context.Context, any) (any, error) { return int64(1), nil }, }, nil } - if val != nil && len(val.Fields) > 0 && val.Fields[0].Name == "two" { + if p != nil && p.Name() == "two" { return &StandardGetSetter[any]{ Getter: func(context.Context, any) (any, error) { return int64(2), nil }, }, nil } - if val != nil && len(val.Fields) > 0 && val.Fields[0].Name == "three" && val.Fields[1].Name == "one" { + if p != nil && p.Name() == "three" && p.Next() != nil && p.Next().Name() == "one" { return &StandardGetSetter[any]{ Getter: func(context.Context, any) (any, error) { return 3.1, nil }, }, nil } - return nil, fmt.Errorf("bad path %v", val) + return nil, fmt.Errorf("bad path %v", p) } func one[K any]() (ExprFunc[K], error) { @@ -234,7 +234,7 @@ func Test_evaluateMathExpression(t *testing.T) { p, _ := NewParser[any]( functions, - mathParsePath, + mathParsePath[any], componenttest.NewNopTelemetrySettings(), WithEnumParser[any](testParseEnum), ) @@ -269,7 +269,7 @@ func Test_evaluateMathExpression_error(t *testing.T) { input: "1 / 0", }, { - name: "time DIV time", + name: "time div time", mathExpr: &mathExpression{ Left: &addSubTerm{ Left: &mathValue{ @@ -294,7 +294,7 @@ func Test_evaluateMathExpression_error(t *testing.T) { }, Right: []*opAddSubTerm{ { - Operator: DIV, + Operator: div, Term: &addSubTerm{ Left: &mathValue{ Literal: &mathExprLiteral{ @@ -322,7 +322,7 @@ func Test_evaluateMathExpression_error(t *testing.T) { errorMsg: "only addition and subtraction supported", }, { - name: "dur MULT dur", + name: "dur mult dur", mathExpr: &mathExpression{ Left: &addSubTerm{ Left: &mathValue{ @@ -342,7 +342,7 @@ func Test_evaluateMathExpression_error(t *testing.T) { }, Right: []*opAddSubTerm{ { - Operator: MULT, + Operator: mult, Term: &addSubTerm{ Left: &mathValue{ Literal: &mathExprLiteral{ @@ -365,7 +365,7 @@ func Test_evaluateMathExpression_error(t *testing.T) { errorMsg: "only addition and subtraction supported", }, { - name: "time ADD int", + name: "time add int", mathExpr: &mathExpression{ Left: &addSubTerm{ Left: &mathValue{ @@ -390,7 +390,7 @@ func Test_evaluateMathExpression_error(t *testing.T) { }, Right: []*opAddSubTerm{ { - Operator: ADD, + Operator: add, Term: &addSubTerm{ Left: &mathValue{ Literal: &mathExprLiteral{ @@ -404,7 +404,7 @@ func Test_evaluateMathExpression_error(t *testing.T) { errorMsg: "time.Time must be added to time.Duration", }, { - name: "dur SUB int", + name: "dur sub int", mathExpr: &mathExpression{ Left: &addSubTerm{ Left: &mathValue{ @@ -424,7 +424,7 @@ func Test_evaluateMathExpression_error(t *testing.T) { }, Right: []*opAddSubTerm{ { - Operator: SUB, + Operator: sub, Term: &addSubTerm{ Left: &mathValue{ Literal: &mathExprLiteral{ @@ -438,7 +438,7 @@ func Test_evaluateMathExpression_error(t *testing.T) { errorMsg: "time.Duration must be subtracted from time.Duration", }, { - name: "time ADD time", + name: "time add time", mathExpr: &mathExpression{ Left: &addSubTerm{ Left: &mathValue{ @@ -463,7 +463,7 @@ func Test_evaluateMathExpression_error(t *testing.T) { }, Right: []*opAddSubTerm{ { - Operator: ADD, + Operator: add, Term: &addSubTerm{ Left: &mathValue{ Literal: &mathExprLiteral{ @@ -491,7 +491,7 @@ func Test_evaluateMathExpression_error(t *testing.T) { errorMsg: "time.Time must be added to time.Duration", }, { - name: "dur SUB time", + name: "dur sub time", mathExpr: &mathExpression{ Left: &addSubTerm{ Left: &mathValue{ @@ -511,7 +511,7 @@ func Test_evaluateMathExpression_error(t *testing.T) { }, Right: []*opAddSubTerm{ { - Operator: SUB, + Operator: sub, Term: &addSubTerm{ Left: &mathValue{ Literal: &mathExprLiteral{ @@ -556,7 +556,7 @@ func Test_evaluateMathExpression_error(t *testing.T) { p, _ := NewParser[any]( functions, - mathParsePath, + mathParsePath[any], componenttest.NewNopTelemetrySettings(), WithEnumParser[any](testParseEnum), ) @@ -606,7 +606,7 @@ func Test_evaluateMathExpressionTimeDuration(t *testing.T) { p, _ := NewParser( functions, - mathParsePath, + mathParsePath[any], componenttest.NewNopTelemetrySettings(), WithEnumParser[any](testParseEnum), ) @@ -629,7 +629,7 @@ func Test_evaluateMathExpressionTimeDuration(t *testing.T) { expected any }{ { - name: "time SUB time, no difference", + name: "time sub time, no difference", mathExpr: &mathExpression{ Left: &addSubTerm{ Left: &mathValue{ @@ -654,7 +654,7 @@ func Test_evaluateMathExpressionTimeDuration(t *testing.T) { }, Right: []*opAddSubTerm{ { - Operator: SUB, + Operator: sub, Term: &addSubTerm{ Left: &mathValue{ Literal: &mathExprLiteral{ @@ -682,7 +682,7 @@ func Test_evaluateMathExpressionTimeDuration(t *testing.T) { expected: zeroSecs, }, { - name: "time SUB time", + name: "time sub time", mathExpr: &mathExpression{ Left: &addSubTerm{ Left: &mathValue{ @@ -707,7 +707,7 @@ func Test_evaluateMathExpressionTimeDuration(t *testing.T) { }, Right: []*opAddSubTerm{ { - Operator: SUB, + Operator: sub, Term: &addSubTerm{ Left: &mathValue{ Literal: &mathExprLiteral{ @@ -735,7 +735,7 @@ func Test_evaluateMathExpressionTimeDuration(t *testing.T) { expected: -fourtySevenHourseFourtyTwoMinutesTwentySevenSecs, }, { - name: "dur ADD time", + name: "dur add time", mathExpr: &mathExpression{ Left: &addSubTerm{ Left: &mathValue{ @@ -755,7 +755,7 @@ func Test_evaluateMathExpressionTimeDuration(t *testing.T) { }, Right: []*opAddSubTerm{ { - Operator: ADD, + Operator: add, Term: &addSubTerm{ Left: &mathValue{ Literal: &mathExprLiteral{ @@ -783,7 +783,7 @@ func Test_evaluateMathExpressionTimeDuration(t *testing.T) { expected: time.Date(2000, 1, 1, 10, 0, 0, 0, time.Local), }, { - name: "time ADD dur", + name: "time add dur", mathExpr: &mathExpression{ Left: &addSubTerm{ Left: &mathValue{ @@ -808,7 +808,7 @@ func Test_evaluateMathExpressionTimeDuration(t *testing.T) { }, Right: []*opAddSubTerm{ { - Operator: ADD, + Operator: add, Term: &addSubTerm{ Left: &mathValue{ Literal: &mathExprLiteral{ @@ -831,7 +831,7 @@ func Test_evaluateMathExpressionTimeDuration(t *testing.T) { expected: time.Date(2023, 2, 15, 10, 0, 0, 0, time.Local), }, { - name: "time ADD dur, complex dur", + name: "time add dur, complex dur", mathExpr: &mathExpression{ Left: &addSubTerm{ Left: &mathValue{ @@ -856,7 +856,7 @@ func Test_evaluateMathExpressionTimeDuration(t *testing.T) { }, Right: []*opAddSubTerm{ { - Operator: ADD, + Operator: add, Term: &addSubTerm{ Left: &mathValue{ Literal: &mathExprLiteral{ @@ -879,7 +879,7 @@ func Test_evaluateMathExpressionTimeDuration(t *testing.T) { expected: time.Date(2023, 2, 4, 1, 2, 3, 0, time.Local), }, { - name: "time SUB dur, complex dur", + name: "time sub dur, complex dur", mathExpr: &mathExpression{ Left: &addSubTerm{ Left: &mathValue{ @@ -904,7 +904,7 @@ func Test_evaluateMathExpressionTimeDuration(t *testing.T) { }, Right: []*opAddSubTerm{ { - Operator: SUB, + Operator: sub, Term: &addSubTerm{ Left: &mathValue{ Literal: &mathExprLiteral{ @@ -927,7 +927,7 @@ func Test_evaluateMathExpressionTimeDuration(t *testing.T) { expected: time.Date(2023, 3, 14, 6, 0, 1, 0, time.Local), }, { - name: "time SUB dur, nanosecs", + name: "time sub dur, nanosecs", mathExpr: &mathExpression{ Left: &addSubTerm{ Left: &mathValue{ @@ -952,7 +952,7 @@ func Test_evaluateMathExpressionTimeDuration(t *testing.T) { }, Right: []*opAddSubTerm{ { - Operator: SUB, + Operator: sub, Term: &addSubTerm{ Left: &mathValue{ Literal: &mathExprLiteral{ @@ -975,7 +975,7 @@ func Test_evaluateMathExpressionTimeDuration(t *testing.T) { expected: time.Date(2023, 4, 30, 23, 59, 59, 999999900, time.Local), }, { - name: "dur ADD dur, complex durs", + name: "dur add dur, complex durs", mathExpr: &mathExpression{ Left: &addSubTerm{ Left: &mathValue{ @@ -995,7 +995,7 @@ func Test_evaluateMathExpressionTimeDuration(t *testing.T) { }, Right: []*opAddSubTerm{ { - Operator: ADD, + Operator: add, Term: &addSubTerm{ Left: &mathValue{ Literal: &mathExprLiteral{ @@ -1018,7 +1018,7 @@ func Test_evaluateMathExpressionTimeDuration(t *testing.T) { expected: oneHundredOne, }, { - name: "dur ADD dur, zero dur", + name: "dur add dur, zero dur", mathExpr: &mathExpression{ Left: &addSubTerm{ Left: &mathValue{ @@ -1038,7 +1038,7 @@ func Test_evaluateMathExpressionTimeDuration(t *testing.T) { }, Right: []*opAddSubTerm{ { - Operator: ADD, + Operator: add, Term: &addSubTerm{ Left: &mathValue{ Literal: &mathExprLiteral{ @@ -1061,7 +1061,7 @@ func Test_evaluateMathExpressionTimeDuration(t *testing.T) { expected: oneThousandHours, }, { - name: "dur SUB dur, zero dur", + name: "dur sub dur, zero dur", mathExpr: &mathExpression{ Left: &addSubTerm{ Left: &mathValue{ @@ -1081,7 +1081,7 @@ func Test_evaluateMathExpressionTimeDuration(t *testing.T) { }, Right: []*opAddSubTerm{ { - Operator: SUB, + Operator: sub, Term: &addSubTerm{ Left: &mathValue{ Literal: &mathExprLiteral{ @@ -1104,7 +1104,7 @@ func Test_evaluateMathExpressionTimeDuration(t *testing.T) { expected: -threeTwentyEightMins, }, { - name: "dur SUB dur, complex durs", + name: "dur sub dur, complex durs", mathExpr: &mathExpression{ Left: &addSubTerm{ Left: &mathValue{ @@ -1124,7 +1124,7 @@ func Test_evaluateMathExpressionTimeDuration(t *testing.T) { }, Right: []*opAddSubTerm{ { - Operator: SUB, + Operator: sub, Term: &addSubTerm{ Left: &mathValue{ Literal: &mathExprLiteral{ diff --git a/pkg/ottl/parser_test.go b/pkg/ottl/parser_test.go index c818203d0671..fa09f3253077 100644 --- a/pkg/ottl/parser_test.go +++ b/pkg/ottl/parser_test.go @@ -105,8 +105,8 @@ func Test_parse(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "bear", }, @@ -138,14 +138,14 @@ func Test_parse(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "foo", }, { Name: "attributes", - Keys: []Key{ + Keys: []key{ { String: ottltest.Strp("bar"), }, @@ -179,11 +179,11 @@ func Test_parse(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "attributes", - Keys: []Key{ + Keys: []key{ { String: ottltest.Strp("message"), }, @@ -202,11 +202,11 @@ func Test_parse(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "attributes", - Keys: []Key{ + Keys: []key{ { String: ottltest.Strp("device_name"), }, @@ -219,7 +219,7 @@ func Test_parse(t *testing.T) { }, { Value: value{ - Enum: (*EnumSymbol)(ottltest.Strp("SHA256")), + Enum: (*enumSymbol)(ottltest.Strp("SHA256")), }, }, }, @@ -237,11 +237,11 @@ func Test_parse(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "attributes", - Keys: []Key{ + Keys: []key{ { String: ottltest.Strp("message"), }, @@ -272,11 +272,11 @@ func Test_parse(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "attributes", - Keys: []Key{ + Keys: []key{ { String: ottltest.Strp("message"), }, @@ -289,7 +289,7 @@ func Test_parse(t *testing.T) { }, { Value: value{ - Enum: (*EnumSymbol)(ottltest.Strp("S")), + Enum: (*enumSymbol)(ottltest.Strp("S")), }, }, }, @@ -307,14 +307,14 @@ func Test_parse(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "foo", }, { Name: "bar", - Keys: []Key{ + Keys: []key{ { String: ottltest.Strp("x"), }, @@ -336,7 +336,7 @@ func Test_parse(t *testing.T) { Literal: &mathExprLiteral{ Converter: &converter{ Function: "Test", - Keys: []Key{ + Keys: []key{ { Int: ottltest.Intp(0), }, @@ -363,14 +363,14 @@ func Test_parse(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "foo", }, { Name: "attributes", - Keys: []Key{ + Keys: []key{ { String: ottltest.Strp("bar"), }, @@ -397,8 +397,8 @@ func Test_parse(t *testing.T) { Comparison: &comparison{ Left: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -406,7 +406,7 @@ func Test_parse(t *testing.T) { }, }, }, - Op: EQ, + Op: eq, Right: value{ String: ottltest.Strp("fido"), }, @@ -426,14 +426,14 @@ func Test_parse(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "foo", }, { Name: "attributes", - Keys: []Key{ + Keys: []key{ { String: ottltest.Strp("bar"), }, @@ -460,8 +460,8 @@ func Test_parse(t *testing.T) { Comparison: &comparison{ Left: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -469,7 +469,7 @@ func Test_parse(t *testing.T) { }, }, }, - Op: NE, + Op: ne, Right: value{ String: ottltest.Strp("fido"), }, @@ -489,14 +489,14 @@ func Test_parse(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "foo", }, { Name: "attributes", - Keys: []Key{ + Keys: []key{ { String: ottltest.Strp("bar"), }, @@ -523,8 +523,8 @@ func Test_parse(t *testing.T) { Comparison: &comparison{ Left: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -532,7 +532,7 @@ func Test_parse(t *testing.T) { }, }, }, - Op: EQ, + Op: eq, Right: value{ String: ottltest.Strp("fido"), }, @@ -613,11 +613,11 @@ func Test_parse(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "attributes", - Keys: []Key{ + Keys: []key{ { String: ottltest.Strp("bytes"), }, @@ -648,11 +648,11 @@ func Test_parse(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "attributes", - Keys: []Key{ + Keys: []key{ { String: ottltest.Strp("test"), }, @@ -683,11 +683,11 @@ func Test_parse(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "attributes", - Keys: []Key{ + Keys: []key{ { String: ottltest.Strp("test"), }, @@ -700,7 +700,7 @@ func Test_parse(t *testing.T) { }, { Value: value{ - Enum: (*EnumSymbol)(ottltest.Strp("TEST_ENUM")), + Enum: (*enumSymbol)(ottltest.Strp("TEST_ENUM")), }, }, }, @@ -718,11 +718,11 @@ func Test_parse(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "attributes", - Keys: []Key{ + Keys: []key{ { String: ottltest.Strp("test"), }, @@ -755,11 +755,11 @@ func Test_parse(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "attributes", - Keys: []Key{ + Keys: []key{ { String: ottltest.Strp("test"), }, @@ -796,11 +796,11 @@ func Test_parse(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "attributes", - Keys: []Key{ + Keys: []key{ { String: ottltest.Strp("test"), }, @@ -840,11 +840,11 @@ func Test_parse(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "attributes", - Keys: []Key{ + Keys: []key{ { String: ottltest.Strp("test"), }, @@ -911,11 +911,11 @@ func Test_parse(t *testing.T) { }, { Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "attributes", - Keys: []Key{ + Keys: []key{ { String: ottltest.Strp("test"), }, @@ -944,11 +944,11 @@ func Test_parse(t *testing.T) { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "attributes", - Keys: []Key{ + Keys: []key{ { String: ottltest.Strp("test"), }, @@ -971,7 +971,7 @@ func Test_parse(t *testing.T) { }, Right: []*opAddSubTerm{ { - Operator: SUB, + Operator: sub, Term: &addSubTerm{ Left: &mathValue{ Literal: &mathExprLiteral{ @@ -1001,7 +1001,7 @@ func Test_parse(t *testing.T) { }, Right: []*opAddSubTerm{ { - Operator: ADD, + Operator: add, Term: &addSubTerm{ Left: &mathValue{ Literal: &mathExprLiteral{ @@ -1010,7 +1010,7 @@ func Test_parse(t *testing.T) { }, Right: []*opMultDivValue{ { - Operator: MULT, + Operator: mult, Value: &mathValue{ Literal: &mathExprLiteral{ Int: ottltest.Intp(2), @@ -1023,14 +1023,14 @@ func Test_parse(t *testing.T) { }, }, }, - Op: EQ, + Op: eq, Right: value{ MathExpression: &mathExpression{ Left: &addSubTerm{ Left: &mathValue{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "three", }, @@ -1040,7 +1040,7 @@ func Test_parse(t *testing.T) { }, Right: []*opMultDivValue{ { - Operator: DIV, + Operator: div, Value: &mathValue{ Literal: &mathExprLiteral{ Converter: &converter{ @@ -1103,8 +1103,8 @@ func Test_parseCondition_full(t *testing.T) { Comparison: &comparison{ Left: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -1112,7 +1112,7 @@ func Test_parseCondition_full(t *testing.T) { }, }, }, - Op: EQ, + Op: eq, Right: value{ String: ottltest.Strp("fido"), }, @@ -1130,8 +1130,8 @@ func Test_parseCondition_full(t *testing.T) { Comparison: &comparison{ Left: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -1139,7 +1139,7 @@ func Test_parseCondition_full(t *testing.T) { }, }, }, - Op: NE, + Op: ne, Right: value{ String: ottltest.Strp("fido"), }, @@ -1166,7 +1166,7 @@ func Test_parseCondition_full(t *testing.T) { }, Right: []*opAddSubTerm{ { - Operator: ADD, + Operator: add, Term: &addSubTerm{ Left: &mathValue{ Literal: &mathExprLiteral{ @@ -1175,7 +1175,7 @@ func Test_parseCondition_full(t *testing.T) { }, Right: []*opMultDivValue{ { - Operator: MULT, + Operator: mult, Value: &mathValue{ Literal: &mathExprLiteral{ Int: ottltest.Intp(2), @@ -1188,14 +1188,14 @@ func Test_parseCondition_full(t *testing.T) { }, }, }, - Op: EQ, + Op: eq, Right: value{ MathExpression: &mathExpression{ Left: &addSubTerm{ Left: &mathValue{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "three", }, @@ -1205,7 +1205,7 @@ func Test_parseCondition_full(t *testing.T) { }, Right: []*opMultDivValue{ { - Operator: DIV, + Operator: div, Value: &mathValue{ Literal: &mathExprLiteral{ Converter: &converter{ @@ -1234,8 +1234,8 @@ func Test_parseCondition_full(t *testing.T) { } } -func testParsePath(val *Path) (GetSetter[any], error) { - if val != nil && len(val.Fields) > 0 && (val.Fields[0].Name == "name" || val.Fields[0].Name == "attributes") { +func testParsePath[K any](p Path[K]) (GetSetter[any], error) { + if p != nil && (p.Name() == "name" || p.Name() == "attributes") { return &StandardGetSetter[any]{ Getter: func(ctx context.Context, tCtx any) (any, error) { return tCtx, nil @@ -1246,14 +1246,14 @@ func testParsePath(val *Path) (GetSetter[any], error) { }, }, nil } - if val.Fields[0].Name == "dur1" || val.Fields[0].Name == "dur2" { + if p != nil && (p.Name() == "dur1" || p.Name() == "dur2") { return &StandardGetSetter[any]{ Getter: func(ctx context.Context, tCtx any) (any, error) { m, ok := tCtx.(map[string]time.Duration) if !ok { return nil, fmt.Errorf("unable to convert transform context to map of strings to times") } - return m[val.Fields[0].Name], nil + return m[p.Name()], nil }, Setter: func(ctx context.Context, tCtx any, val any) error { reflect.DeepEqual(tCtx, val) @@ -1261,14 +1261,14 @@ func testParsePath(val *Path) (GetSetter[any], error) { }, }, nil } - if val.Fields[0].Name == "time1" || val.Fields[0].Name == "time2" { + if p != nil && (p.Name() == "time1" || p.Name() == "time2") { return &StandardGetSetter[any]{ Getter: func(ctx context.Context, tCtx any) (any, error) { m, ok := tCtx.(map[string]time.Time) if !ok { return nil, fmt.Errorf("unable to convert transform context to map of strings to times") } - return m[val.Fields[0].Name], nil + return m[p.Name()], nil }, Setter: func(ctx context.Context, tCtx any, val any) error { reflect.DeepEqual(tCtx, val) @@ -1276,7 +1276,7 @@ func testParsePath(val *Path) (GetSetter[any], error) { }, }, nil } - return nil, fmt.Errorf("bad path %v", val) + return nil, fmt.Errorf("bad path %v", p) } // Helper for test cases where the WHERE clause is all that matters. @@ -1289,8 +1289,8 @@ func setNameTest(b *booleanExpression) *parsedStatement { { Value: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -1525,8 +1525,8 @@ func Test_parseWhere(t *testing.T) { Comparison: &comparison{ Left: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -1534,7 +1534,7 @@ func Test_parseWhere(t *testing.T) { }, }, }, - Op: NE, + Op: ne, Right: value{ String: ottltest.Strp("foo"), }, @@ -1547,8 +1547,8 @@ func Test_parseWhere(t *testing.T) { Comparison: &comparison{ Left: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -1556,7 +1556,7 @@ func Test_parseWhere(t *testing.T) { }, }, }, - Op: NE, + Op: ne, Right: value{ String: ottltest.Strp("bar"), }, @@ -1575,8 +1575,8 @@ func Test_parseWhere(t *testing.T) { Comparison: &comparison{ Left: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -1584,7 +1584,7 @@ func Test_parseWhere(t *testing.T) { }, }, }, - Op: EQ, + Op: eq, Right: value{ String: ottltest.Strp("foo"), }, @@ -1599,8 +1599,8 @@ func Test_parseWhere(t *testing.T) { Comparison: &comparison{ Left: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -1608,7 +1608,7 @@ func Test_parseWhere(t *testing.T) { }, }, }, - Op: EQ, + Op: eq, Right: value{ String: ottltest.Strp("bar"), }, @@ -1651,8 +1651,8 @@ func Test_parseWhere(t *testing.T) { Comparison: &comparison{ Left: value{ Literal: &mathExprLiteral{ - Path: &Path{ - Fields: []Field{ + Path: &path{ + Fields: []field{ { Name: "name", }, @@ -1660,7 +1660,7 @@ func Test_parseWhere(t *testing.T) { }, }, }, - Op: EQ, + Op: eq, Right: value{ String: ottltest.Strp("bar"), }, @@ -1780,7 +1780,7 @@ func Test_ParseStatements_Error(t *testing.T) { p, _ := NewParser( CreateFactoryMap[any](), - testParsePath, + testParsePath[any], componenttest.NewNopTelemetrySettings(), WithEnumParser[any](testParseEnum), ) @@ -1810,7 +1810,7 @@ func Test_ParseConditions_Error(t *testing.T) { p, _ := NewParser( CreateFactoryMap[any](), - testParsePath, + testParsePath[any], componenttest.NewNopTelemetrySettings(), WithEnumParser[any](testParseEnum), ) diff --git a/pkg/translator/azure/go.mod b/pkg/translator/azure/go.mod index 1c6a6facdc1d..e80ce1ec991b 100644 --- a/pkg/translator/azure/go.mod +++ b/pkg/translator/azure/go.mod @@ -11,7 +11,7 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/semconv v0.91.0 go.uber.org/zap v1.26.0 - golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb + golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 ) require ( diff --git a/pkg/translator/azure/go.sum b/pkg/translator/azure/go.sum index fc20296221e8..d7b91fb23e27 100644 --- a/pkg/translator/azure/go.sum +++ b/pkg/translator/azure/go.sum @@ -75,8 +75,8 @@ go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= diff --git a/processor/attributesprocessor/go.mod b/processor/attributesprocessor/go.mod index a2af19e0fb79..b7d2692791db 100644 --- a/processor/attributesprocessor/go.mod +++ b/processor/attributesprocessor/go.mod @@ -14,6 +14,8 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/processor v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -45,10 +47,8 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect + golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/processor/attributesprocessor/go.sum b/processor/attributesprocessor/go.sum index 235199b20fe7..74d45a3477de 100644 --- a/processor/attributesprocessor/go.sum +++ b/processor/attributesprocessor/go.sum @@ -145,8 +145,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= diff --git a/processor/attributesprocessor/internal/metadata/generated_status.go b/processor/attributesprocessor/internal/metadata/generated_status.go index c58df00f609a..7f25676321bb 100644 --- a/processor/attributesprocessor/internal/metadata/generated_status.go +++ b/processor/attributesprocessor/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/attributes") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/attributes") +} diff --git a/processor/cumulativetodeltaprocessor/generated_component_test.go b/processor/cumulativetodeltaprocessor/generated_component_test.go new file mode 100644 index 000000000000..6a7e376c6333 --- /dev/null +++ b/processor/cumulativetodeltaprocessor/generated_component_test.go @@ -0,0 +1,108 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package cumulativetodeltaprocessor + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/collector/processor/processortest" + + "go.opentelemetry.io/collector/confmap/confmaptest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + err = c.Start(context.Background(), host) + require.NoError(t, err) + assert.NotPanics(t, func() { + switch e := c.(type) { + case processor.Logs: + logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + if !e.Capabilities().MutatesData { + logs.MarkReadOnly() + } + err = e.ConsumeLogs(context.Background(), logs) + case processor.Metrics: + metrics := testdata.GenerateMetricsTwoMetrics() + if !e.Capabilities().MutatesData { + metrics.MarkReadOnly() + } + err = e.ConsumeMetrics(context.Background(), metrics) + case processor.Traces: + traces := testdata.GenerateTracesTwoSpansSameResource() + if !e.Capabilities().MutatesData { + traces.MarkReadOnly() + } + err = e.ConsumeTraces(context.Background(), traces) + } + }) + assert.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + } +} diff --git a/processor/cumulativetodeltaprocessor/go.mod b/processor/cumulativetodeltaprocessor/go.mod index cccef242d078..f3081b71c02d 100644 --- a/processor/cumulativetodeltaprocessor/go.mod +++ b/processor/cumulativetodeltaprocessor/go.mod @@ -3,6 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/processor/cumul go 1.20 require ( + github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.91.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter v0.91.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.91.0 github.com/stretchr/testify v1.8.4 @@ -11,6 +12,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/processor v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -36,8 +39,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/processor/cumulativetodeltaprocessor/internal/metadata/generated_status.go b/processor/cumulativetodeltaprocessor/internal/metadata/generated_status.go index 02f7c11ae467..55f2ef61b3a1 100644 --- a/processor/cumulativetodeltaprocessor/internal/metadata/generated_status.go +++ b/processor/cumulativetodeltaprocessor/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "cumulativetodelta" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/cumulativetodelta") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/cumulativetodelta") +} diff --git a/processor/cumulativetodeltaprocessor/metadata.yaml b/processor/cumulativetodeltaprocessor/metadata.yaml index 271bf37805c7..1df1b1db7906 100644 --- a/processor/cumulativetodeltaprocessor/metadata.yaml +++ b/processor/cumulativetodeltaprocessor/metadata.yaml @@ -7,4 +7,6 @@ status: distributions: [contrib, observiq, sumo, aws] warnings: [Statefulness] codeowners: - active: [TylerHelmuth] \ No newline at end of file + active: [TylerHelmuth] +tests: + config: diff --git a/processor/datadogprocessor/generated_component_test.go b/processor/datadogprocessor/generated_component_test.go new file mode 100644 index 000000000000..98e9c9027e28 --- /dev/null +++ b/processor/datadogprocessor/generated_component_test.go @@ -0,0 +1,111 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package datadogprocessor + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/collector/processor/processortest" + + "go.opentelemetry.io/collector/confmap/confmaptest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "traces", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + // TODO support lifecycle + t.SkipNow() + + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + err = c.Start(context.Background(), host) + require.NoError(t, err) + assert.NotPanics(t, func() { + switch e := c.(type) { + case processor.Logs: + logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + if !e.Capabilities().MutatesData { + logs.MarkReadOnly() + } + err = e.ConsumeLogs(context.Background(), logs) + case processor.Metrics: + metrics := testdata.GenerateMetricsTwoMetrics() + if !e.Capabilities().MutatesData { + metrics.MarkReadOnly() + } + err = e.ConsumeMetrics(context.Background(), metrics) + case processor.Traces: + traces := testdata.GenerateTracesTwoSpansSameResource() + if !e.Capabilities().MutatesData { + traces.MarkReadOnly() + } + err = e.ConsumeTraces(context.Background(), traces) + } + }) + assert.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + } +} diff --git a/processor/datadogprocessor/go.mod b/processor/datadogprocessor/go.mod index 4030b605d479..f3b4c59a7a71 100644 --- a/processor/datadogprocessor/go.mod +++ b/processor/datadogprocessor/go.mod @@ -7,14 +7,18 @@ require ( github.com/DataDog/datadog-agent/pkg/proto v0.50.0-rc.7 github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.9.0 github.com/DataDog/sketches-go v1.4.3 + github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.91.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/datadog v0.91.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.91.0 + go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/processor v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 google.golang.org/protobuf v1.31.0 ) @@ -66,22 +70,20 @@ require ( github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c // indirect github.com/secure-systems-lab/go-securesystemslib v0.7.0 // indirect - github.com/shirou/gopsutil/v3 v3.23.10 // indirect + github.com/shirou/gopsutil/v3 v3.23.11 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/tinylib/msgp v1.1.9 // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect github.com/yusufpapurcu/wmi v1.2.3 // indirect + go.opentelemetry.io/collector v0.91.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect - go.opentelemetry.io/collector/confmap v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/semconv v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect + golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect @@ -103,3 +105,11 @@ retract ( v0.76.2 v0.76.1 ) + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden + +replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest diff --git a/processor/datadogprocessor/go.sum b/processor/datadogprocessor/go.sum index 07b88e5baddd..9e7558781f67 100644 --- a/processor/datadogprocessor/go.sum +++ b/processor/datadogprocessor/go.sum @@ -126,8 +126,8 @@ github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c/go.mod h1:Om github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/secure-systems-lab/go-securesystemslib v0.7.0 h1:OwvJ5jQf9LnIAS83waAjPbcMsODrTQUpJ02eNLUoxBg= github.com/secure-systems-lab/go-securesystemslib v0.7.0/go.mod h1:/2gYnlnHVQ6xeGtfIqFy7Do03K4cdCY0A/GlJLDKLHI= -github.com/shirou/gopsutil/v3 v3.23.10 h1:/N42opWlYzegYaVkWejXWJpbzKv2JDy3mrgGzKsh9hM= -github.com/shirou/gopsutil/v3 v3.23.10/go.mod h1:JIE26kpucQi+innVlAUnIEOSBhBUkirr5b44yr55+WE= +github.com/shirou/gopsutil/v3 v3.23.11 h1:i3jP9NjCPUz7FiZKxlMnODZkdSIp2gnzfrvsu9CuWEQ= +github.com/shirou/gopsutil/v3 v3.23.11/go.mod h1:1FrWgea594Jp7qmjHUUPlJDTPgcsb9mGnXDxavtikzM= github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= @@ -158,6 +158,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= +go.opentelemetry.io/collector v0.91.0 h1:C7sGUJDJ5nwm+CkWpAaVP3lNsuYpwSRbkmLncFjkmO8= +go.opentelemetry.io/collector v0.91.0/go.mod h1:YhQpIDZsn+bICAAqgBwXk9wqK8GKZDv+aogfG52zUuE= go.opentelemetry.io/collector/component v0.91.0 h1:aBT1i2zGyfh9PalYJLfXVvQp+osHyalwyDFselI1CtA= go.opentelemetry.io/collector/component v0.91.0/go.mod h1:2KBHvjNFdU7oOjsObQeC4Ta2Ef607OISU5obznW00fw= go.opentelemetry.io/collector/config/configtelemetry v0.91.0 h1:mEwvqrYfwUJ7LwYfpcF9M8z7LHFoYaKhEPhnERD/88E= @@ -189,7 +191,7 @@ go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+ go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= -go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= +go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= @@ -198,8 +200,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= -golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= -golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 h1:FqrVOBQxQ8r/UwwXibI0KMolVhvFiGobSfdE33deHJM= +golang.org/x/exp v0.0.0-20230711023510-fffb14384f22/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -230,7 +232,6 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= diff --git a/processor/datadogprocessor/internal/metadata/generated_status.go b/processor/datadogprocessor/internal/metadata/generated_status.go index be67fe78208d..8fa9cfd3f68b 100644 --- a/processor/datadogprocessor/internal/metadata/generated_status.go +++ b/processor/datadogprocessor/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "datadog" TracesStability = component.StabilityLevelDeprecated ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/datadog") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/datadog") +} diff --git a/processor/datadogprocessor/metadata.yaml b/processor/datadogprocessor/metadata.yaml index 272fc149c8ae..df0115857325 100644 --- a/processor/datadogprocessor/metadata.yaml +++ b/processor/datadogprocessor/metadata.yaml @@ -8,3 +8,6 @@ status: codeowners: active: [mx-psi, dineshg13] emeritus: [gbbr] +tests: + config: + skip_lifecycle: true diff --git a/processor/deltatorateprocessor/generated_component_test.go b/processor/deltatorateprocessor/generated_component_test.go new file mode 100644 index 000000000000..44043e255536 --- /dev/null +++ b/processor/deltatorateprocessor/generated_component_test.go @@ -0,0 +1,108 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package deltatorateprocessor + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/collector/processor/processortest" + + "go.opentelemetry.io/collector/confmap/confmaptest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + err = c.Start(context.Background(), host) + require.NoError(t, err) + assert.NotPanics(t, func() { + switch e := c.(type) { + case processor.Logs: + logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + if !e.Capabilities().MutatesData { + logs.MarkReadOnly() + } + err = e.ConsumeLogs(context.Background(), logs) + case processor.Metrics: + metrics := testdata.GenerateMetricsTwoMetrics() + if !e.Capabilities().MutatesData { + metrics.MarkReadOnly() + } + err = e.ConsumeMetrics(context.Background(), metrics) + case processor.Traces: + traces := testdata.GenerateTracesTwoSpansSameResource() + if !e.Capabilities().MutatesData { + traces.MarkReadOnly() + } + err = e.ConsumeTraces(context.Background(), traces) + } + }) + assert.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + } +} diff --git a/processor/deltatorateprocessor/go.mod b/processor/deltatorateprocessor/go.mod index b3193a07a0fd..c482580a1d27 100644 --- a/processor/deltatorateprocessor/go.mod +++ b/processor/deltatorateprocessor/go.mod @@ -3,12 +3,15 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/processor/delta go 1.20 require ( + github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.91.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.91.0 go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/processor v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -32,8 +35,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect @@ -49,3 +50,11 @@ retract ( v0.76.1 v0.65.0 ) + +replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden diff --git a/processor/deltatorateprocessor/internal/metadata/generated_status.go b/processor/deltatorateprocessor/internal/metadata/generated_status.go index 899bb228db56..769ec74571a3 100644 --- a/processor/deltatorateprocessor/internal/metadata/generated_status.go +++ b/processor/deltatorateprocessor/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "deltatorate" MetricsStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/deltatorate") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/deltatorate") +} diff --git a/processor/deltatorateprocessor/metadata.yaml b/processor/deltatorateprocessor/metadata.yaml index 1198892cbc5f..b7d9a632c20c 100644 --- a/processor/deltatorateprocessor/metadata.yaml +++ b/processor/deltatorateprocessor/metadata.yaml @@ -6,4 +6,6 @@ status: development: [metrics] distributions: [contrib, observiq, sumo, aws] codeowners: - active: [Aneurysm9] \ No newline at end of file + active: [Aneurysm9] +tests: + config: diff --git a/processor/filterprocessor/generated_component_test.go b/processor/filterprocessor/generated_component_test.go new file mode 100644 index 000000000000..da8a1074738e --- /dev/null +++ b/processor/filterprocessor/generated_component_test.go @@ -0,0 +1,122 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package filterprocessor + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/collector/processor/processortest" + + "go.opentelemetry.io/collector/confmap/confmaptest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "metrics", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "traces", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + err = c.Start(context.Background(), host) + require.NoError(t, err) + assert.NotPanics(t, func() { + switch e := c.(type) { + case processor.Logs: + logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + if !e.Capabilities().MutatesData { + logs.MarkReadOnly() + } + err = e.ConsumeLogs(context.Background(), logs) + case processor.Metrics: + metrics := testdata.GenerateMetricsTwoMetrics() + if !e.Capabilities().MutatesData { + metrics.MarkReadOnly() + } + err = e.ConsumeMetrics(context.Background(), metrics) + case processor.Traces: + traces := testdata.GenerateTracesTwoSpansSameResource() + if !e.Capabilities().MutatesData { + traces.MarkReadOnly() + } + err = e.ConsumeTraces(context.Background(), traces) + } + }) + assert.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + } +} diff --git a/processor/filterprocessor/go.mod b/processor/filterprocessor/go.mod index 8b8cff1b4c2b..47abb4ed932d 100644 --- a/processor/filterprocessor/go.mod +++ b/processor/filterprocessor/go.mod @@ -12,6 +12,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/processor v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -45,9 +47,7 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/semconv v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect - golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect + golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/processor/filterprocessor/go.sum b/processor/filterprocessor/go.sum index 235199b20fe7..74d45a3477de 100644 --- a/processor/filterprocessor/go.sum +++ b/processor/filterprocessor/go.sum @@ -145,8 +145,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= diff --git a/processor/filterprocessor/internal/metadata/generated_status.go b/processor/filterprocessor/internal/metadata/generated_status.go index 806ad2fabe77..bcaeadcc46d2 100644 --- a/processor/filterprocessor/internal/metadata/generated_status.go +++ b/processor/filterprocessor/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelAlpha LogsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/filter") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/filter") +} diff --git a/processor/filterprocessor/metadata.yaml b/processor/filterprocessor/metadata.yaml index f53dfbb3e6d8..aab6454e8825 100644 --- a/processor/filterprocessor/metadata.yaml +++ b/processor/filterprocessor/metadata.yaml @@ -8,3 +8,5 @@ status: warnings: [Orphaned Telemetry, Other] codeowners: active: [TylerHelmuth, boostchicken] +tests: + config: diff --git a/processor/groupbyattrsprocessor/generated_component_test.go b/processor/groupbyattrsprocessor/generated_component_test.go new file mode 100644 index 000000000000..6657098dc872 --- /dev/null +++ b/processor/groupbyattrsprocessor/generated_component_test.go @@ -0,0 +1,122 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package groupbyattrsprocessor + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/collector/processor/processortest" + + "go.opentelemetry.io/collector/confmap/confmaptest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "metrics", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "traces", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + err = c.Start(context.Background(), host) + require.NoError(t, err) + assert.NotPanics(t, func() { + switch e := c.(type) { + case processor.Logs: + logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + if !e.Capabilities().MutatesData { + logs.MarkReadOnly() + } + err = e.ConsumeLogs(context.Background(), logs) + case processor.Metrics: + metrics := testdata.GenerateMetricsTwoMetrics() + if !e.Capabilities().MutatesData { + metrics.MarkReadOnly() + } + err = e.ConsumeMetrics(context.Background(), metrics) + case processor.Traces: + traces := testdata.GenerateTracesTwoSpansSameResource() + if !e.Capabilities().MutatesData { + traces.MarkReadOnly() + } + err = e.ConsumeTraces(context.Background(), traces) + } + }) + assert.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + } +} diff --git a/processor/groupbyattrsprocessor/go.mod b/processor/groupbyattrsprocessor/go.mod index 7caba27ccb67..6247d2b1b6aa 100644 --- a/processor/groupbyattrsprocessor/go.mod +++ b/processor/groupbyattrsprocessor/go.mod @@ -3,6 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/processor/group go 1.20 require ( + github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.91.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.91.0 github.com/stretchr/testify v1.8.4 go.opencensus.io v0.24.0 @@ -11,6 +12,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/processor v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -34,8 +37,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect @@ -53,3 +54,9 @@ retract ( v0.76.1 v0.65.0 ) + +replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden diff --git a/processor/groupbyattrsprocessor/internal/metadata/generated_status.go b/processor/groupbyattrsprocessor/internal/metadata/generated_status.go index aa4f0e185047..9dfa03f6433c 100644 --- a/processor/groupbyattrsprocessor/internal/metadata/generated_status.go +++ b/processor/groupbyattrsprocessor/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/groupbyattrs") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/groupbyattrs") +} diff --git a/processor/groupbyattrsprocessor/metadata.yaml b/processor/groupbyattrsprocessor/metadata.yaml index 665d2170653e..5697d1fcc9f7 100644 --- a/processor/groupbyattrsprocessor/metadata.yaml +++ b/processor/groupbyattrsprocessor/metadata.yaml @@ -7,4 +7,6 @@ status: distributions: [contrib, splunk, observiq, sumo] warnings: [] codeowners: - active: [rnishtala-sumo] \ No newline at end of file + active: [rnishtala-sumo] +tests: + config: diff --git a/processor/groupbytraceprocessor/generated_component_test.go b/processor/groupbytraceprocessor/generated_component_test.go new file mode 100644 index 000000000000..f62a39c1db1c --- /dev/null +++ b/processor/groupbytraceprocessor/generated_component_test.go @@ -0,0 +1,108 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package groupbytraceprocessor + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/collector/processor/processortest" + + "go.opentelemetry.io/collector/confmap/confmaptest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "traces", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + err = c.Start(context.Background(), host) + require.NoError(t, err) + assert.NotPanics(t, func() { + switch e := c.(type) { + case processor.Logs: + logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + if !e.Capabilities().MutatesData { + logs.MarkReadOnly() + } + err = e.ConsumeLogs(context.Background(), logs) + case processor.Metrics: + metrics := testdata.GenerateMetricsTwoMetrics() + if !e.Capabilities().MutatesData { + metrics.MarkReadOnly() + } + err = e.ConsumeMetrics(context.Background(), metrics) + case processor.Traces: + traces := testdata.GenerateTracesTwoSpansSameResource() + if !e.Capabilities().MutatesData { + traces.MarkReadOnly() + } + err = e.ConsumeTraces(context.Background(), traces) + } + }) + assert.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + } +} diff --git a/processor/groupbytraceprocessor/go.mod b/processor/groupbytraceprocessor/go.mod index 048dd0fe28b1..ce56886ec25b 100644 --- a/processor/groupbytraceprocessor/go.mod +++ b/processor/groupbytraceprocessor/go.mod @@ -3,13 +3,17 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/processor/group go 1.20 require ( + github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.91.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/batchpersignal v0.91.0 github.com/stretchr/testify v1.8.4 go.opencensus.io v0.24.0 go.opentelemetry.io/collector/component v0.91.0 + go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/processor v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -31,11 +35,8 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect go.opentelemetry.io/collector v0.91.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect - go.opentelemetry.io/collector/confmap v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect @@ -52,3 +53,11 @@ retract ( v0.76.1 v0.65.0 ) + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden + +replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal diff --git a/processor/groupbytraceprocessor/internal/metadata/generated_status.go b/processor/groupbytraceprocessor/internal/metadata/generated_status.go index 68ad8dd16624..86d36b72c8b5 100644 --- a/processor/groupbytraceprocessor/internal/metadata/generated_status.go +++ b/processor/groupbytraceprocessor/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "groupbytrace" TracesStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/groupbytrace") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/groupbytrace") +} diff --git a/processor/groupbytraceprocessor/metadata.yaml b/processor/groupbytraceprocessor/metadata.yaml index e24caa652793..bf9c46916f94 100644 --- a/processor/groupbytraceprocessor/metadata.yaml +++ b/processor/groupbytraceprocessor/metadata.yaml @@ -7,4 +7,6 @@ status: distributions: [contrib, observiq, sumo, aws] warnings: [Statefulness] codeowners: - active: [jpkrohling] \ No newline at end of file + active: [jpkrohling] +tests: + config: diff --git a/processor/k8sattributesprocessor/e2e_test.go b/processor/k8sattributesprocessor/e2e_test.go index 962ee19583a0..2f4a8cc4901b 100644 --- a/processor/k8sattributesprocessor/e2e_test.go +++ b/processor/k8sattributesprocessor/e2e_test.go @@ -57,11 +57,18 @@ func newExpectedValue(mode int, value string) *expectedValue { // make docker-otelcontribcol // KUBECONFIG=/tmp/kube-config-otelcol-e2e-testing kind load docker-image otelcontribcol:latest func TestE2E(t *testing.T) { + kubeConfig, err := clientcmd.BuildConfigFromFlags("", testKubeConfig) require.NoError(t, err) dynamicClient, err := dynamic.NewForConfig(kubeConfig) require.NoError(t, err) + metricsConsumer := new(consumertest.MetricsSink) + tracesConsumer := new(consumertest.TracesSink) + logsConsumer := new(consumertest.LogsSink) + shutdownSinks := startUpSinks(t, metricsConsumer, tracesConsumer, logsConsumer) + defer shutdownSinks() + testID := uuid.NewString()[:8] collectorObjs := k8stest.CreateCollectorObjects(t, dynamicClient, testID) telemetryGenObjs, telemetryGenObjInfos := k8stest.CreateTelemetryGenObjects(t, dynamicClient, testID) @@ -75,9 +82,6 @@ func TestE2E(t *testing.T) { k8stest.WaitForTelemetryGenToStart(t, dynamicClient, info.Namespace, info.PodLabelSelectors, info.Workload, info.DataType) } - metricsConsumer := new(consumertest.MetricsSink) - tracesConsumer := new(consumertest.TracesSink) - logsConsumer := new(consumertest.LogsSink) wantEntries := 128 // Minimal number of metrics/traces/logs to wait for. waitForData(t, wantEntries, metricsConsumer, tracesConsumer, logsConsumer) @@ -484,7 +488,7 @@ func resourceHasAttributes(resource pcommon.Resource, kvs map[string]*expectedVa return err } -func waitForData(t *testing.T, entriesNum int, mc *consumertest.MetricsSink, tc *consumertest.TracesSink, lc *consumertest.LogsSink) { +func startUpSinks(t *testing.T, mc *consumertest.MetricsSink, tc *consumertest.TracesSink, lc *consumertest.LogsSink) func() { f := otlpreceiver.NewFactory() cfg := f.CreateDefaultConfig().(*otlpreceiver.Config) @@ -495,10 +499,12 @@ func waitForData(t *testing.T, entriesNum int, mc *consumertest.MetricsSink, tc rcvr, err := f.CreateLogsReceiver(context.Background(), receivertest.NewNopCreateSettings(), cfg, lc) require.NoError(t, err, "failed creating logs receiver") require.NoError(t, rcvr.Start(context.Background(), componenttest.NewNopHost())) - defer func() { + return func() { assert.NoError(t, rcvr.Shutdown(context.Background())) - }() + } +} +func waitForData(t *testing.T, entriesNum int, mc *consumertest.MetricsSink, tc *consumertest.TracesSink, lc *consumertest.LogsSink) { timeoutMinutes := 3 require.Eventuallyf(t, func() bool { return len(mc.AllMetrics()) > entriesNum && len(tc.AllTraces()) > entriesNum && len(lc.AllLogs()) > entriesNum diff --git a/processor/k8sattributesprocessor/go.mod b/processor/k8sattributesprocessor/go.mod index 6b4f0e9741b6..60179e50d7c7 100644 --- a/processor/k8sattributesprocessor/go.mod +++ b/processor/k8sattributesprocessor/go.mod @@ -19,6 +19,8 @@ require ( go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/receiver/otlpreceiver v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 k8s.io/api v0.28.4 @@ -87,8 +89,6 @@ require ( go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/oauth2 v0.14.0 // indirect diff --git a/processor/k8sattributesprocessor/internal/metadata/generated_status.go b/processor/k8sattributesprocessor/internal/metadata/generated_status.go index b47f7c1962dc..9abe8c044b66 100644 --- a/processor/k8sattributesprocessor/internal/metadata/generated_status.go +++ b/processor/k8sattributesprocessor/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelBeta TracesStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/k8sattributes") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/k8sattributes") +} diff --git a/processor/k8sattributesprocessor/testdata/e2e/collector/deployment.yaml b/processor/k8sattributesprocessor/testdata/e2e/collector/deployment.yaml index f7f21c5d4856..841c472b04f4 100644 --- a/processor/k8sattributesprocessor/testdata/e2e/collector/deployment.yaml +++ b/processor/k8sattributesprocessor/testdata/e2e/collector/deployment.yaml @@ -37,10 +37,12 @@ spec: httpGet: path: / port: 13133 + initialDelaySeconds: 3 readinessProbe: httpGet: path: / port: 13133 + initialDelaySeconds: 3 resources: limits: cpu: 128m diff --git a/processor/logstransformprocessor/go.mod b/processor/logstransformprocessor/go.mod index 6e3a350316e3..ded2d060fba7 100644 --- a/processor/logstransformprocessor/go.mod +++ b/processor/logstransformprocessor/go.mod @@ -13,6 +13,8 @@ require ( go.opentelemetry.io/collector/extension v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/processor v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -43,8 +45,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/processor/logstransformprocessor/internal/metadata/generated_status.go b/processor/logstransformprocessor/internal/metadata/generated_status.go index 811b88331dd8..70eae1b85e34 100644 --- a/processor/logstransformprocessor/internal/metadata/generated_status.go +++ b/processor/logstransformprocessor/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "logstransform" LogsStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/logstransform") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/logstransform") +} diff --git a/processor/metricsgenerationprocessor/generated_component_test.go b/processor/metricsgenerationprocessor/generated_component_test.go new file mode 100644 index 000000000000..62c37e89b8ec --- /dev/null +++ b/processor/metricsgenerationprocessor/generated_component_test.go @@ -0,0 +1,108 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package metricsgenerationprocessor + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/collector/processor/processortest" + + "go.opentelemetry.io/collector/confmap/confmaptest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + err = c.Start(context.Background(), host) + require.NoError(t, err) + assert.NotPanics(t, func() { + switch e := c.(type) { + case processor.Logs: + logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + if !e.Capabilities().MutatesData { + logs.MarkReadOnly() + } + err = e.ConsumeLogs(context.Background(), logs) + case processor.Metrics: + metrics := testdata.GenerateMetricsTwoMetrics() + if !e.Capabilities().MutatesData { + metrics.MarkReadOnly() + } + err = e.ConsumeMetrics(context.Background(), metrics) + case processor.Traces: + traces := testdata.GenerateTracesTwoSpansSameResource() + if !e.Capabilities().MutatesData { + traces.MarkReadOnly() + } + err = e.ConsumeTraces(context.Background(), traces) + } + }) + assert.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + } +} diff --git a/processor/metricsgenerationprocessor/go.mod b/processor/metricsgenerationprocessor/go.mod index 1c5ed2d66896..36c0853618e7 100644 --- a/processor/metricsgenerationprocessor/go.mod +++ b/processor/metricsgenerationprocessor/go.mod @@ -3,12 +3,15 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/processor/metri go 1.20 require ( + github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.91.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.91.0 go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/processor v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -32,8 +35,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect @@ -49,3 +50,11 @@ retract ( v0.76.1 v0.65.0 ) + +replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden diff --git a/processor/metricsgenerationprocessor/internal/metadata/generated_status.go b/processor/metricsgenerationprocessor/internal/metadata/generated_status.go index aac624ff1064..253bfb8bd2e4 100644 --- a/processor/metricsgenerationprocessor/internal/metadata/generated_status.go +++ b/processor/metricsgenerationprocessor/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "experimental_metricsgeneration" MetricsStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/metricsgeneration") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/metricsgeneration") +} diff --git a/processor/metricsgenerationprocessor/metadata.yaml b/processor/metricsgenerationprocessor/metadata.yaml index 707bf2afe775..9be1a42fe448 100644 --- a/processor/metricsgenerationprocessor/metadata.yaml +++ b/processor/metricsgenerationprocessor/metadata.yaml @@ -6,4 +6,7 @@ status: development: [metrics] distributions: [contrib, sumo, aws] codeowners: - active: [Aneurysm9] \ No newline at end of file + active: [Aneurysm9] + +tests: + config: diff --git a/processor/metricstransformprocessor/generated_component_test.go b/processor/metricstransformprocessor/generated_component_test.go new file mode 100644 index 000000000000..990f605c4d89 --- /dev/null +++ b/processor/metricstransformprocessor/generated_component_test.go @@ -0,0 +1,108 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package metricstransformprocessor + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/collector/processor/processortest" + + "go.opentelemetry.io/collector/confmap/confmaptest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + err = c.Start(context.Background(), host) + require.NoError(t, err) + assert.NotPanics(t, func() { + switch e := c.(type) { + case processor.Logs: + logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + if !e.Capabilities().MutatesData { + logs.MarkReadOnly() + } + err = e.ConsumeLogs(context.Background(), logs) + case processor.Metrics: + metrics := testdata.GenerateMetricsTwoMetrics() + if !e.Capabilities().MutatesData { + metrics.MarkReadOnly() + } + err = e.ConsumeMetrics(context.Background(), metrics) + case processor.Traces: + traces := testdata.GenerateTracesTwoSpansSameResource() + if !e.Capabilities().MutatesData { + traces.MarkReadOnly() + } + err = e.ConsumeTraces(context.Background(), traces) + } + }) + assert.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + } +} diff --git a/processor/metricstransformprocessor/go.mod b/processor/metricstransformprocessor/go.mod index 77d7c41bd623..5aac30fbd68a 100644 --- a/processor/metricstransformprocessor/go.mod +++ b/processor/metricstransformprocessor/go.mod @@ -3,6 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/processor/metri go 1.20 require ( + github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.91.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.91.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.91.0 github.com/stretchr/testify v1.8.4 @@ -11,6 +12,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/processor v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -36,8 +39,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect @@ -59,3 +60,5 @@ retract ( ) replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden + +replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal diff --git a/processor/metricstransformprocessor/internal/metadata/generated_status.go b/processor/metricstransformprocessor/internal/metadata/generated_status.go index 3b1ac11a50e3..167c38cf3ed5 100644 --- a/processor/metricstransformprocessor/internal/metadata/generated_status.go +++ b/processor/metricstransformprocessor/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "metricstransform" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/metricstransform") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/metricstransform") +} diff --git a/processor/metricstransformprocessor/metadata.yaml b/processor/metricstransformprocessor/metadata.yaml index 8859d5492293..8680efedb6b3 100644 --- a/processor/metricstransformprocessor/metadata.yaml +++ b/processor/metricstransformprocessor/metadata.yaml @@ -6,4 +6,7 @@ status: beta: [metrics] distributions: [contrib, observiq, splunk, sumo, aws] codeowners: - active: [dmitryax] \ No newline at end of file + active: [dmitryax] + +tests: + config: diff --git a/processor/probabilisticsamplerprocessor/generated_component_test.go b/processor/probabilisticsamplerprocessor/generated_component_test.go new file mode 100644 index 000000000000..1f1858d78b8f --- /dev/null +++ b/processor/probabilisticsamplerprocessor/generated_component_test.go @@ -0,0 +1,115 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package probabilisticsamplerprocessor + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/collector/processor/processortest" + + "go.opentelemetry.io/collector/confmap/confmaptest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "traces", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + err = c.Start(context.Background(), host) + require.NoError(t, err) + assert.NotPanics(t, func() { + switch e := c.(type) { + case processor.Logs: + logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + if !e.Capabilities().MutatesData { + logs.MarkReadOnly() + } + err = e.ConsumeLogs(context.Background(), logs) + case processor.Metrics: + metrics := testdata.GenerateMetricsTwoMetrics() + if !e.Capabilities().MutatesData { + metrics.MarkReadOnly() + } + err = e.ConsumeMetrics(context.Background(), metrics) + case processor.Traces: + traces := testdata.GenerateTracesTwoSpansSameResource() + if !e.Capabilities().MutatesData { + traces.MarkReadOnly() + } + err = e.ConsumeTraces(context.Background(), traces) + } + }) + assert.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + } +} diff --git a/processor/probabilisticsamplerprocessor/go.mod b/processor/probabilisticsamplerprocessor/go.mod index c257df28bfc9..10c721b53f2b 100644 --- a/processor/probabilisticsamplerprocessor/go.mod +++ b/processor/probabilisticsamplerprocessor/go.mod @@ -14,6 +14,8 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/processor v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -79,10 +81,8 @@ require ( go.opentelemetry.io/otel/exporters/prometheus v0.44.1-0.20231201153405-6027c1ae76f2 // indirect go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.44.0 // indirect go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/sdk v1.21.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect diff --git a/processor/probabilisticsamplerprocessor/internal/metadata/generated_status.go b/processor/probabilisticsamplerprocessor/internal/metadata/generated_status.go index ce209dc8878e..72871b302449 100644 --- a/processor/probabilisticsamplerprocessor/internal/metadata/generated_status.go +++ b/processor/probabilisticsamplerprocessor/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -11,3 +13,11 @@ const ( LogsStability = component.StabilityLevelAlpha TracesStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/probabilisticsampler") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/probabilisticsampler") +} diff --git a/processor/probabilisticsamplerprocessor/metadata.yaml b/processor/probabilisticsamplerprocessor/metadata.yaml index ada3cb06affd..e805e633d9b1 100644 --- a/processor/probabilisticsamplerprocessor/metadata.yaml +++ b/processor/probabilisticsamplerprocessor/metadata.yaml @@ -8,3 +8,6 @@ status: distributions: [core, contrib, observiq, splunk, sumo, aws, grafana] codeowners: active: [jpkrohling] + +tests: + config: diff --git a/processor/redactionprocessor/generated_component_test.go b/processor/redactionprocessor/generated_component_test.go new file mode 100644 index 000000000000..3f74266fd44e --- /dev/null +++ b/processor/redactionprocessor/generated_component_test.go @@ -0,0 +1,108 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package redactionprocessor + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/collector/processor/processortest" + + "go.opentelemetry.io/collector/confmap/confmaptest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "traces", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + err = c.Start(context.Background(), host) + require.NoError(t, err) + assert.NotPanics(t, func() { + switch e := c.(type) { + case processor.Logs: + logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + if !e.Capabilities().MutatesData { + logs.MarkReadOnly() + } + err = e.ConsumeLogs(context.Background(), logs) + case processor.Metrics: + metrics := testdata.GenerateMetricsTwoMetrics() + if !e.Capabilities().MutatesData { + metrics.MarkReadOnly() + } + err = e.ConsumeMetrics(context.Background(), metrics) + case processor.Traces: + traces := testdata.GenerateTracesTwoSpansSameResource() + if !e.Capabilities().MutatesData { + traces.MarkReadOnly() + } + err = e.ConsumeTraces(context.Background(), traces) + } + }) + assert.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + } +} diff --git a/processor/redactionprocessor/go.mod b/processor/redactionprocessor/go.mod index d215515b8672..166727d75693 100644 --- a/processor/redactionprocessor/go.mod +++ b/processor/redactionprocessor/go.mod @@ -3,12 +3,15 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/processor/redac go 1.20 require ( + github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.91.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.91.0 go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/processor v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -32,8 +35,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect @@ -49,3 +50,11 @@ retract ( v0.76.1 v0.65.0 ) + +replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden diff --git a/processor/redactionprocessor/internal/metadata/generated_status.go b/processor/redactionprocessor/internal/metadata/generated_status.go index 62cade813037..5b23e5082e05 100644 --- a/processor/redactionprocessor/internal/metadata/generated_status.go +++ b/processor/redactionprocessor/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "redaction" TracesStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/redaction") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/redaction") +} diff --git a/processor/redactionprocessor/metadata.yaml b/processor/redactionprocessor/metadata.yaml index 709f5d49bcb4..880f1430c39f 100644 --- a/processor/redactionprocessor/metadata.yaml +++ b/processor/redactionprocessor/metadata.yaml @@ -6,4 +6,7 @@ status: beta: [traces] distributions: [contrib, sumo] codeowners: - active: [leonsp-ai, dmitryax, mx-psi, TylerHelmuth] \ No newline at end of file + active: [leonsp-ai, dmitryax, mx-psi, TylerHelmuth] + +tests: + config: diff --git a/processor/remotetapprocessor/generated_component_test.go b/processor/remotetapprocessor/generated_component_test.go new file mode 100644 index 000000000000..bb68166c7769 --- /dev/null +++ b/processor/remotetapprocessor/generated_component_test.go @@ -0,0 +1,122 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package remotetapprocessor + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/collector/processor/processortest" + + "go.opentelemetry.io/collector/confmap/confmaptest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "metrics", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "traces", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + err = c.Start(context.Background(), host) + require.NoError(t, err) + assert.NotPanics(t, func() { + switch e := c.(type) { + case processor.Logs: + logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + if !e.Capabilities().MutatesData { + logs.MarkReadOnly() + } + err = e.ConsumeLogs(context.Background(), logs) + case processor.Metrics: + metrics := testdata.GenerateMetricsTwoMetrics() + if !e.Capabilities().MutatesData { + metrics.MarkReadOnly() + } + err = e.ConsumeMetrics(context.Background(), metrics) + case processor.Traces: + traces := testdata.GenerateTracesTwoSpansSameResource() + if !e.Capabilities().MutatesData { + traces.MarkReadOnly() + } + err = e.ConsumeTraces(context.Background(), traces) + } + }) + assert.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + } +} diff --git a/processor/remotetapprocessor/go.mod b/processor/remotetapprocessor/go.mod index 64e2920d31fc..6ee3fd95840b 100644 --- a/processor/remotetapprocessor/go.mod +++ b/processor/remotetapprocessor/go.mod @@ -3,13 +3,17 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/processor/remot go 1.20 require ( + github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.91.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/sharedcomponent v0.91.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.91.0 go.opentelemetry.io/collector/config/confighttp v0.91.0 + go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/processor v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 golang.org/x/net v0.19.0 golang.org/x/time v0.5.0 @@ -45,14 +49,11 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/config/configtls v0.91.0 // indirect go.opentelemetry.io/collector/config/internal v0.91.0 // indirect - go.opentelemetry.io/collector/confmap v0.91.0 // indirect go.opentelemetry.io/collector/extension v0.91.0 // indirect go.opentelemetry.io/collector/extension/auth v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect @@ -63,3 +64,11 @@ require ( ) replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/sharedcomponent => ../../internal/sharedcomponent + +replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden diff --git a/processor/remotetapprocessor/internal/metadata/generated_status.go b/processor/remotetapprocessor/internal/metadata/generated_status.go index f3b5f933c20c..ecd8d35ad65d 100644 --- a/processor/remotetapprocessor/internal/metadata/generated_status.go +++ b/processor/remotetapprocessor/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelAlpha TracesStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/remotetap") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/remotetap") +} diff --git a/processor/remotetapprocessor/metadata.yaml b/processor/remotetapprocessor/metadata.yaml index 76f1f1d17303..4ebf87005f6a 100644 --- a/processor/remotetapprocessor/metadata.yaml +++ b/processor/remotetapprocessor/metadata.yaml @@ -6,4 +6,7 @@ status: alpha: [logs, metrics, traces] distributions: [contrib] codeowners: - active: [pmcollins] \ No newline at end of file + active: [pmcollins] + +tests: + config: diff --git a/processor/resourcedetectionprocessor/generated_component_test.go b/processor/resourcedetectionprocessor/generated_component_test.go new file mode 100644 index 000000000000..e5947f8a0ce7 --- /dev/null +++ b/processor/resourcedetectionprocessor/generated_component_test.go @@ -0,0 +1,122 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package resourcedetectionprocessor + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/collector/processor/processortest" + + "go.opentelemetry.io/collector/confmap/confmaptest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "metrics", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "traces", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + err = c.Start(context.Background(), host) + require.NoError(t, err) + assert.NotPanics(t, func() { + switch e := c.(type) { + case processor.Logs: + logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + if !e.Capabilities().MutatesData { + logs.MarkReadOnly() + } + err = e.ConsumeLogs(context.Background(), logs) + case processor.Metrics: + metrics := testdata.GenerateMetricsTwoMetrics() + if !e.Capabilities().MutatesData { + metrics.MarkReadOnly() + } + err = e.ConsumeMetrics(context.Background(), metrics) + case processor.Traces: + traces := testdata.GenerateTracesTwoSpansSameResource() + if !e.Capabilities().MutatesData { + traces.MarkReadOnly() + } + err = e.ConsumeTraces(context.Background(), traces) + } + }) + assert.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + } +} diff --git a/processor/resourcedetectionprocessor/go.mod b/processor/resourcedetectionprocessor/go.mod index 2db9e9082d20..014c371bba8c 100644 --- a/processor/resourcedetectionprocessor/go.mod +++ b/processor/resourcedetectionprocessor/go.mod @@ -5,11 +5,12 @@ go 1.20 require ( cloud.google.com/go/compute/metadata v0.2.3 github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.21.0 - github.com/aws/aws-sdk-go v1.49.1 + github.com/aws/aws-sdk-go v1.49.5 github.com/google/go-cmp v0.6.0 github.com/hashicorp/consul/api v1.26.1 github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/ecsutil v0.91.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.91.0 + github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.91.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8sconfig v0.91.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/metadataproviders v0.91.0 github.com/shirou/gopsutil/v3 v3.23.11 @@ -24,6 +25,8 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/processor v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 k8s.io/apimachinery v0.28.4 @@ -32,15 +35,14 @@ require ( require ( cloud.google.com/go/compute v1.23.0 // indirect - github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect - github.com/Microsoft/go-winio v0.5.2 // indirect + github.com/Microsoft/go-winio v0.6.1 // indirect github.com/Showmax/go-fqdn v1.0.0 // indirect github.com/armon/go-metrics v0.4.1 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/docker/distribution v2.8.2+incompatible // indirect github.com/docker/docker v24.0.7+incompatible // indirect github.com/docker/go-connections v0.4.0 // indirect - github.com/docker/go-units v0.4.0 // indirect + github.com/docker/go-units v0.5.0 // indirect github.com/emicklei/go-restful/v3 v3.9.0 // indirect github.com/fatih/color v1.14.1 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect @@ -86,7 +88,7 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect - github.com/opencontainers/image-spec v1.0.2 // indirect + github.com/opencontainers/image-spec v1.1.0-rc5 // indirect github.com/openshift/api v3.9.0+incompatible // indirect github.com/openshift/client-go v0.0.0-20210521082421-73d9475a9142 // indirect github.com/pkg/errors v0.9.1 // indirect @@ -109,16 +111,16 @@ require ( go.opentelemetry.io/collector/extension/auth v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/sdk v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect + golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/oauth2 v0.14.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/term v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.4.0 // indirect + golang.org/x/tools v0.15.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect google.golang.org/grpc v1.59.0 // indirect @@ -148,3 +150,11 @@ retract ( ) replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8sconfig => ../../internal/k8sconfig + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden + +replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil diff --git a/processor/resourcedetectionprocessor/go.sum b/processor/resourcedetectionprocessor/go.sum index 80919d4a7cb9..8d9278a8c6e6 100644 --- a/processor/resourcedetectionprocessor/go.sum +++ b/processor/resourcedetectionprocessor/go.sum @@ -27,7 +27,6 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl contrib.go.opencensus.io/exporter/prometheus v0.4.2 h1:sqfsYl5GIY/L570iT+l93ehxaWJs2/OwXtiWwew3oAg= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= -github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= github.com/Azure/go-autorest/autorest v0.11.12/go.mod h1:eipySxLmqSyC5s5k1CLupqet0PSENBEDP93LQ9a8QYw= github.com/Azure/go-autorest/autorest/adal v0.9.5/go.mod h1:B7KF7jKIeC9Mct5spmyCB/A8CG/sEz1vwIRGv/bbw7A= @@ -40,8 +39,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.21.0 h1:aNyyrkRcLMWFum5qgYbXl6Ut+MMOmfH/kLjZJ5YJP/I= github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.21.0/go.mod h1:BEOBnuYVyPt9wxVRQqqpKUK9FXVcL2+LOjZ8apLa9ao= -github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA= -github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= +github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= @@ -58,8 +57,8 @@ github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= -github.com/aws/aws-sdk-go v1.49.1 h1:Dsamcd8d/nNb3A+bZ0ucfGl0vGZsW5wlRW0vhoYGoeQ= -github.com/aws/aws-sdk-go v1.49.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.5 h1:y2yfBlwjPDi3/sBVKeznYEdDy6wIhjA2L5NCBMLUIYA= +github.com/aws/aws-sdk-go v1.49.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -86,8 +85,8 @@ github.com/docker/docker v24.0.7+incompatible h1:Wo6l37AuwP3JaMnZa226lzVXGA3F9Ig github.com/docker/docker v24.0.7+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= -github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= -github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= +github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= +github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= @@ -336,7 +335,7 @@ github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4/go.mod h1 github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= -github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 h1:dcztxKSvZ4Id8iPpHERQBbIJfabdt4wUm5qy3wOL2Zc= +github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -361,8 +360,8 @@ github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM= -github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= +github.com/opencontainers/image-spec v1.1.0-rc5 h1:Ygwkfw9bpDvs+c9E34SdgGOj41dX/cbdlwvlWt0pnFI= +github.com/opencontainers/image-spec v1.1.0-rc5/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= github.com/openshift/api v0.0.0-20210521075222-e273a339932a/go.mod h1:izBmoXbUu3z5kUa4FjZhvekTsyzIWiOoaIgJiZBBMQs= github.com/openshift/api v3.9.0+incompatible h1:fJ/KsefYuZAjmrr3+5U9yZIZbTOpVkDDLDLFresAeYs= github.com/openshift/api v3.9.0+incompatible/go.mod h1:dh9o4Fs58gpFXGSYfnVxGR9PnV53I8TW84pQaJDdGiY= @@ -416,7 +415,6 @@ github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -546,6 +544,8 @@ golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.1-0.20200828183125-ce943fd02449/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= +golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -591,6 +591,7 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -626,11 +627,9 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -696,7 +695,8 @@ golang.org/x/tools v0.0.0-20200505023115-26f46d2f7ef8/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 h1:Vve/L0v7CXXuxUmaMGIEK/dEeq7uiqb5qBgQrZzIE7E= +golang.org/x/tools v0.15.0 h1:zdAyfUGbYmuVokhzVmghFl2ZJh5QhcfebBgmVPFYA+8= +golang.org/x/tools v0.15.0/go.mod h1:hpksKq4dtpQWS1uQ61JkdqWM3LscIS6Slf+VVkm+wQk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/processor/resourcedetectionprocessor/internal/azure/internal/metadata/generated_status.go b/processor/resourcedetectionprocessor/internal/azure/internal/metadata/generated_status.go index ce3d0625ab32..eba06df2b1ad 100644 --- a/processor/resourcedetectionprocessor/internal/azure/internal/metadata/generated_status.go +++ b/processor/resourcedetectionprocessor/internal/azure/internal/metadata/generated_status.go @@ -2,6 +2,20 @@ package metadata +import ( + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" +) + const ( Type = "resourcedetectionprocessor/azure" ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/resourcedetection") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/resourcedetection") +} diff --git a/processor/resourcedetectionprocessor/internal/heroku/internal/metadata/generated_status.go b/processor/resourcedetectionprocessor/internal/heroku/internal/metadata/generated_status.go index b8fe4cf34870..beedf104c271 100644 --- a/processor/resourcedetectionprocessor/internal/heroku/internal/metadata/generated_status.go +++ b/processor/resourcedetectionprocessor/internal/heroku/internal/metadata/generated_status.go @@ -2,6 +2,20 @@ package metadata +import ( + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" +) + const ( Type = "resourcedetectionprocessor/heroku" ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/resourcedetection") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/resourcedetection") +} diff --git a/processor/resourcedetectionprocessor/internal/metadata/generated_status.go b/processor/resourcedetectionprocessor/internal/metadata/generated_status.go index 25982b141b86..23d96c5f25fd 100644 --- a/processor/resourcedetectionprocessor/internal/metadata/generated_status.go +++ b/processor/resourcedetectionprocessor/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/resourcedetection") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/resourcedetection") +} diff --git a/processor/resourcedetectionprocessor/internal/openshift/internal/metadata/generated_status.go b/processor/resourcedetectionprocessor/internal/openshift/internal/metadata/generated_status.go index 5b551af20c6b..2a1605dc295c 100644 --- a/processor/resourcedetectionprocessor/internal/openshift/internal/metadata/generated_status.go +++ b/processor/resourcedetectionprocessor/internal/openshift/internal/metadata/generated_status.go @@ -2,6 +2,20 @@ package metadata +import ( + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" +) + const ( Type = "resourcedetectionprocessor/openshift" ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/resourcedetection") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/resourcedetection") +} diff --git a/processor/resourcedetectionprocessor/metadata.yaml b/processor/resourcedetectionprocessor/metadata.yaml index 922971fc338c..9ca10b369dd9 100644 --- a/processor/resourcedetectionprocessor/metadata.yaml +++ b/processor/resourcedetectionprocessor/metadata.yaml @@ -7,3 +7,6 @@ status: distributions: [contrib, splunk, observiq, sumo, aws, redhat, liatrio] codeowners: active: [Aneurysm9, dashpole] + +tests: + config: diff --git a/processor/resourceprocessor/generated_component_test.go b/processor/resourceprocessor/generated_component_test.go new file mode 100644 index 000000000000..da97d9783fa9 --- /dev/null +++ b/processor/resourceprocessor/generated_component_test.go @@ -0,0 +1,122 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package resourceprocessor + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/collector/processor/processortest" + + "go.opentelemetry.io/collector/confmap/confmaptest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "metrics", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "traces", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + err = c.Start(context.Background(), host) + require.NoError(t, err) + assert.NotPanics(t, func() { + switch e := c.(type) { + case processor.Logs: + logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + if !e.Capabilities().MutatesData { + logs.MarkReadOnly() + } + err = e.ConsumeLogs(context.Background(), logs) + case processor.Metrics: + metrics := testdata.GenerateMetricsTwoMetrics() + if !e.Capabilities().MutatesData { + metrics.MarkReadOnly() + } + err = e.ConsumeMetrics(context.Background(), metrics) + case processor.Traces: + traces := testdata.GenerateTracesTwoSpansSameResource() + if !e.Capabilities().MutatesData { + traces.MarkReadOnly() + } + err = e.ConsumeTraces(context.Background(), traces) + } + }) + assert.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + } +} diff --git a/processor/resourceprocessor/go.mod b/processor/resourceprocessor/go.mod index 2e4ff0208433..42e3d6fa7c8e 100644 --- a/processor/resourceprocessor/go.mod +++ b/processor/resourceprocessor/go.mod @@ -11,6 +11,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/processor v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -36,8 +38,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/processor/resourceprocessor/internal/metadata/generated_status.go b/processor/resourceprocessor/internal/metadata/generated_status.go index 988d0f88154f..9ace4f7f196c 100644 --- a/processor/resourceprocessor/internal/metadata/generated_status.go +++ b/processor/resourceprocessor/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/resource") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/resource") +} diff --git a/processor/resourceprocessor/metadata.yaml b/processor/resourceprocessor/metadata.yaml index ec164d8508c7..58db2497e371 100644 --- a/processor/resourceprocessor/metadata.yaml +++ b/processor/resourceprocessor/metadata.yaml @@ -7,3 +7,6 @@ status: distributions: [core, contrib, splunk, observiq, sumo, aws, redhat, liatrio] codeowners: active: [dmitryax] + +tests: + config: diff --git a/processor/routingprocessor/generated_component_test.go b/processor/routingprocessor/generated_component_test.go new file mode 100644 index 000000000000..be5c78c6cbc0 --- /dev/null +++ b/processor/routingprocessor/generated_component_test.go @@ -0,0 +1,122 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package routingprocessor + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/collector/processor/processortest" + + "go.opentelemetry.io/collector/confmap/confmaptest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "metrics", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "traces", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + err = c.Start(context.Background(), host) + require.NoError(t, err) + assert.NotPanics(t, func() { + switch e := c.(type) { + case processor.Logs: + logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + if !e.Capabilities().MutatesData { + logs.MarkReadOnly() + } + err = e.ConsumeLogs(context.Background(), logs) + case processor.Metrics: + metrics := testdata.GenerateMetricsTwoMetrics() + if !e.Capabilities().MutatesData { + metrics.MarkReadOnly() + } + err = e.ConsumeMetrics(context.Background(), metrics) + case processor.Traces: + traces := testdata.GenerateTracesTwoSpansSameResource() + if !e.Capabilities().MutatesData { + traces.MarkReadOnly() + } + err = e.ConsumeTraces(context.Background(), traces) + } + }) + assert.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + } +} diff --git a/processor/routingprocessor/go.mod b/processor/routingprocessor/go.mod index 52783a240347..db39d66a86a6 100644 --- a/processor/routingprocessor/go.mod +++ b/processor/routingprocessor/go.mod @@ -3,6 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/processor/routi go 1.20 require ( + github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.91.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl v0.91.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector v0.91.0 @@ -48,7 +49,6 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/mostynb/go-grpc-compression v1.2.2 // indirect - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.91.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/collector/config/configauth v0.91.0 // indirect @@ -63,7 +63,7 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect - golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect + golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/processor/routingprocessor/go.sum b/processor/routingprocessor/go.sum index 1b741b931c16..7a617438d9c1 100644 --- a/processor/routingprocessor/go.sum +++ b/processor/routingprocessor/go.sum @@ -189,8 +189,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= diff --git a/processor/routingprocessor/internal/metadata/generated_status.go b/processor/routingprocessor/internal/metadata/generated_status.go index 2d0ef6f6ec1b..2dc74a64d0a0 100644 --- a/processor/routingprocessor/internal/metadata/generated_status.go +++ b/processor/routingprocessor/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/routing") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/routing") +} diff --git a/processor/routingprocessor/metadata.yaml b/processor/routingprocessor/metadata.yaml index 1022640b3c38..4d7d2df5a64f 100644 --- a/processor/routingprocessor/metadata.yaml +++ b/processor/routingprocessor/metadata.yaml @@ -6,4 +6,7 @@ status: beta: [traces, metrics, logs] distributions: [contrib, observiq, splunk, sumo, redhat] codeowners: - active: [jpkrohling] \ No newline at end of file + active: [jpkrohling] + +tests: + config: diff --git a/processor/schemaprocessor/generated_component_test.go b/processor/schemaprocessor/generated_component_test.go new file mode 100644 index 000000000000..6d8651940b1f --- /dev/null +++ b/processor/schemaprocessor/generated_component_test.go @@ -0,0 +1,122 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package schemaprocessor + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/collector/processor/processortest" + + "go.opentelemetry.io/collector/confmap/confmaptest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "metrics", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "traces", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + err = c.Start(context.Background(), host) + require.NoError(t, err) + assert.NotPanics(t, func() { + switch e := c.(type) { + case processor.Logs: + logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + if !e.Capabilities().MutatesData { + logs.MarkReadOnly() + } + err = e.ConsumeLogs(context.Background(), logs) + case processor.Metrics: + metrics := testdata.GenerateMetricsTwoMetrics() + if !e.Capabilities().MutatesData { + metrics.MarkReadOnly() + } + err = e.ConsumeMetrics(context.Background(), metrics) + case processor.Traces: + traces := testdata.GenerateTracesTwoSpansSameResource() + if !e.Capabilities().MutatesData { + traces.MarkReadOnly() + } + err = e.ConsumeTraces(context.Background(), traces) + } + }) + assert.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + } +} diff --git a/processor/schemaprocessor/go.mod b/processor/schemaprocessor/go.mod index 6dd6236647e4..e64afdaaad00 100644 --- a/processor/schemaprocessor/go.mod +++ b/processor/schemaprocessor/go.mod @@ -3,6 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/processor/schem go 1.20 require ( + github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.91.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.91.0 go.opentelemetry.io/collector/config/confighttp v0.91.0 @@ -10,7 +11,9 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/processor v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 go.opentelemetry.io/otel/schema v0.0.7 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -50,8 +53,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect @@ -66,3 +67,11 @@ retract ( v0.76.1 v0.65.0 ) + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden + +replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil diff --git a/processor/schemaprocessor/internal/metadata/generated_status.go b/processor/schemaprocessor/internal/metadata/generated_status.go index 8fed69bc2d47..e56e2c37e73a 100644 --- a/processor/schemaprocessor/internal/metadata/generated_status.go +++ b/processor/schemaprocessor/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelDevelopment LogsStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/schema") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/schema") +} diff --git a/processor/schemaprocessor/metadata.yaml b/processor/schemaprocessor/metadata.yaml index 4f1269f0c916..c8f010454265 100644 --- a/processor/schemaprocessor/metadata.yaml +++ b/processor/schemaprocessor/metadata.yaml @@ -6,4 +6,7 @@ status: development: [traces, metrics, logs] distributions: [sumo] codeowners: - active: [MovieStoreGuy] \ No newline at end of file + active: [MovieStoreGuy] + +tests: + config: diff --git a/processor/servicegraphprocessor/factory.go b/processor/servicegraphprocessor/factory.go index 219e3853321b..fb046d4baf9a 100644 --- a/processor/servicegraphprocessor/factory.go +++ b/processor/servicegraphprocessor/factory.go @@ -7,7 +7,6 @@ import ( "context" "time" - "go.opencensus.io/stats/view" "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/connector" "go.opentelemetry.io/collector/consumer" @@ -51,9 +50,6 @@ func init() { // NewFactory creates a factory for the servicegraph processor. func NewFactory() processor.Factory { - // TODO: Handle this err - _ = view.Register(serviceGraphProcessorViews()...) - return processor.NewFactory( typeStr, createDefaultConfig, @@ -63,8 +59,6 @@ func NewFactory() processor.Factory { // NewConnectorFactoryFunc creates a function that returns a factory for the servicegraph connector. var NewConnectorFactoryFunc = func(cfgType component.Type, tracesToMetricsStability component.StabilityLevel) connector.Factory { - // TODO: Handle this err - _ = view.Register(serviceGraphProcessorViews()...) return connector.NewFactory( cfgType, createDefaultConfig, @@ -84,13 +78,13 @@ func createDefaultConfig() component.Config { } func createTracesProcessor(_ context.Context, params processor.CreateSettings, cfg component.Config, nextConsumer consumer.Traces) (processor.Traces, error) { - p := newProcessor(params.Logger, cfg) + p := newProcessor(params.TelemetrySettings, cfg) p.tracesConsumer = nextConsumer return p, nil } func createTracesToMetricsConnector(_ context.Context, params connector.CreateSettings, cfg component.Config, nextConsumer consumer.Metrics) (connector.Traces, error) { - c := newProcessor(params.Logger, cfg) + c := newProcessor(params.TelemetrySettings, cfg) c.metricsConsumer = nextConsumer return c, nil } diff --git a/processor/servicegraphprocessor/generated_component_test.go b/processor/servicegraphprocessor/generated_component_test.go new file mode 100644 index 000000000000..fa9055a0d7c4 --- /dev/null +++ b/processor/servicegraphprocessor/generated_component_test.go @@ -0,0 +1,111 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package servicegraphprocessor + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/collector/processor/processortest" + + "go.opentelemetry.io/collector/confmap/confmaptest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "traces", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + // TODO support lifecycle + t.SkipNow() + + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + err = c.Start(context.Background(), host) + require.NoError(t, err) + assert.NotPanics(t, func() { + switch e := c.(type) { + case processor.Logs: + logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + if !e.Capabilities().MutatesData { + logs.MarkReadOnly() + } + err = e.ConsumeLogs(context.Background(), logs) + case processor.Metrics: + metrics := testdata.GenerateMetricsTwoMetrics() + if !e.Capabilities().MutatesData { + metrics.MarkReadOnly() + } + err = e.ConsumeMetrics(context.Background(), metrics) + case processor.Traces: + traces := testdata.GenerateTracesTwoSpansSameResource() + if !e.Capabilities().MutatesData { + traces.MarkReadOnly() + } + err = e.ConsumeTraces(context.Background(), traces) + } + }) + assert.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + } +} diff --git a/processor/servicegraphprocessor/go.mod b/processor/servicegraphprocessor/go.mod index 434f8b18a9be..04a8be9d3b9d 100644 --- a/processor/servicegraphprocessor/go.mod +++ b/processor/servicegraphprocessor/go.mod @@ -4,10 +4,12 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/processor/servi go 1.20 require ( + github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.91.0 github.com/stretchr/testify v1.8.4 - go.opencensus.io v0.24.0 go.opentelemetry.io/collector/component v0.91.0 go.opentelemetry.io/collector/config/configgrpc v0.91.0 + go.opentelemetry.io/collector/config/configtelemetry v0.91.0 + go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/connector v0.91.0 go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/exporter v0.91.0 @@ -17,6 +19,9 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/processor v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/sdk/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -67,15 +72,14 @@ require ( github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect github.com/yusufpapurcu/wmi v1.2.3 // indirect + go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/collector v0.91.0 // indirect go.opentelemetry.io/collector/config/configauth v0.91.0 // indirect go.opentelemetry.io/collector/config/configcompression v0.91.0 // indirect go.opentelemetry.io/collector/config/confignet v0.91.0 // indirect go.opentelemetry.io/collector/config/configopaque v0.91.0 // indirect - go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/config/configtls v0.91.0 // indirect go.opentelemetry.io/collector/config/internal v0.91.0 // indirect - go.opentelemetry.io/collector/confmap v0.91.0 // indirect go.opentelemetry.io/collector/extension v0.91.0 // indirect go.opentelemetry.io/collector/extension/auth v0.91.0 // indirect go.opentelemetry.io/collector/receiver v0.91.0 // indirect @@ -93,10 +97,7 @@ require ( go.opentelemetry.io/otel/exporters/prometheus v0.44.1-0.20231201153405-6027c1ae76f2 // indirect go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.44.0 // indirect go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/sdk v1.21.0 // indirect - go.opentelemetry.io/otel/sdk/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.19.0 // indirect @@ -119,3 +120,11 @@ retract ( // ambiguous import: found package cloud.google.com/go/compute/metadata in multiple modules replace cloud.google.com/go v0.65.0 => cloud.google.com/go v0.110.10 + +replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden diff --git a/processor/servicegraphprocessor/go.sum b/processor/servicegraphprocessor/go.sum index bbedd45c4f9a..8e53af03b557 100644 --- a/processor/servicegraphprocessor/go.sum +++ b/processor/servicegraphprocessor/go.sum @@ -1328,7 +1328,7 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20220827204233-334a2380cb91/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE= -golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= +golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 h1:FqrVOBQxQ8r/UwwXibI0KMolVhvFiGobSfdE33deHJM= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= diff --git a/processor/servicegraphprocessor/internal/metadata/generated_status.go b/processor/servicegraphprocessor/internal/metadata/generated_status.go index d0d787773e97..8b4f1a6ffb95 100644 --- a/processor/servicegraphprocessor/internal/metadata/generated_status.go +++ b/processor/servicegraphprocessor/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "servicegraph" TracesStability = component.StabilityLevelDeprecated ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/servicegraph") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/servicegraph") +} diff --git a/processor/servicegraphprocessor/metadata.yaml b/processor/servicegraphprocessor/metadata.yaml index 92d5e0065c7f..f2fb89d91606 100644 --- a/processor/servicegraphprocessor/metadata.yaml +++ b/processor/servicegraphprocessor/metadata.yaml @@ -7,4 +7,8 @@ status: distributions: [contrib, sumo] warnings: [] codeowners: - active: [jpkrohling, mapno] \ No newline at end of file + active: [jpkrohling, mapno] + +tests: + config: + skip_lifecycle: true diff --git a/processor/servicegraphprocessor/metrics.go b/processor/servicegraphprocessor/metrics.go deleted file mode 100644 index 73d23e496ee4..000000000000 --- a/processor/servicegraphprocessor/metrics.go +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package servicegraphprocessor // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/servicegraphprocessor" - -import ( - "go.opencensus.io/stats" - "go.opencensus.io/stats/view" - "go.opentelemetry.io/collector/processor/processorhelper" - - "github.com/open-telemetry/opentelemetry-collector-contrib/processor/servicegraphprocessor/internal/metadata" -) - -var ( - statDroppedSpans = stats.Int64("dropped_spans", "Number of spans dropped when trying to add edges", stats.UnitDimensionless) - statTotalEdges = stats.Int64("total_edges", "Total number of unique edges", stats.UnitDimensionless) - statExpiredEdges = stats.Int64("expired_edges", "Number of edges that expired before finding its matching span", stats.UnitDimensionless) -) - -func serviceGraphProcessorViews() []*view.View { - droppedSpansView := &view.View{ - Name: processorhelper.BuildCustomMetricName(metadata.Type, statDroppedSpans.Name()), - Description: statDroppedSpans.Description(), - Measure: statDroppedSpans, - Aggregation: view.Count(), - } - totalEdgesView := &view.View{ - Name: processorhelper.BuildCustomMetricName(metadata.Type, statTotalEdges.Name()), - Description: statTotalEdges.Description(), - Measure: statTotalEdges, - Aggregation: view.Count(), - } - expiredEdgesView := &view.View{ - Name: processorhelper.BuildCustomMetricName(metadata.Type, statExpiredEdges.Name()), - Description: statExpiredEdges.Description(), - Measure: statExpiredEdges, - Aggregation: view.Count(), - } - - return []*view.View{ - droppedSpansView, - totalEdgesView, - expiredEdgesView, - } -} diff --git a/processor/servicegraphprocessor/processor.go b/processor/servicegraphprocessor/processor.go index 866b49009647..0fde2f0c5ac6 100644 --- a/processor/servicegraphprocessor/processor.go +++ b/processor/servicegraphprocessor/processor.go @@ -12,7 +12,6 @@ import ( "sync" "time" - "go.opencensus.io/stats" "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/exporter" @@ -20,9 +19,12 @@ import ( "go.opentelemetry.io/collector/pdata/pmetric" "go.opentelemetry.io/collector/pdata/ptrace" "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/collector/processor/processorhelper" semconv "go.opentelemetry.io/collector/semconv/v1.13.0" + "go.opentelemetry.io/otel/metric" "go.uber.org/zap" + "github.com/open-telemetry/opentelemetry-collector-contrib/processor/servicegraphprocessor/internal/metadata" "github.com/open-telemetry/opentelemetry-collector-contrib/processor/servicegraphprocessor/internal/store" ) @@ -76,10 +78,14 @@ type serviceGraphProcessor struct { metricMutex sync.RWMutex keyToMetric map[string]metricSeries + statDroppedSpans metric.Int64Counter + statTotalEdges metric.Int64Counter + statExpiredEdges metric.Int64Counter + shutdownCh chan any } -func newProcessor(logger *zap.Logger, config component.Config) *serviceGraphProcessor { +func newProcessor(set component.TelemetrySettings, config component.Config) *serviceGraphProcessor { pConfig := config.(*Config) bounds := defaultLatencyHistogramBuckets @@ -102,9 +108,27 @@ func newProcessor(logger *zap.Logger, config component.Config) *serviceGraphProc pConfig.VirtualNodePeerAttributes = defaultPeerAttributes } + meter := metadata.Meter(set) + + droppedSpan, _ := meter.Int64Counter( + processorhelper.BuildCustomMetricName(metadata.Type, "dropped_spans"), + metric.WithDescription("Number of spans dropped when trying to add edges"), + metric.WithUnit("1"), + ) + totalEdges, _ := meter.Int64Counter( + processorhelper.BuildCustomMetricName(metadata.Type, "total_edges"), + metric.WithDescription("Total number of unique edges"), + metric.WithUnit("1"), + ) + expiredEdges, _ := meter.Int64Counter( + processorhelper.BuildCustomMetricName(metadata.Type, "expired_edges"), + metric.WithDescription("Number of edges that expired before finding its matching span"), + metric.WithUnit("1"), + ) + return &serviceGraphProcessor{ config: pConfig, - logger: logger, + logger: set.Logger, startTime: time.Now(), reqTotal: make(map[string]int64), reqFailedTotal: make(map[string]int64), @@ -117,6 +141,9 @@ func newProcessor(logger *zap.Logger, config component.Config) *serviceGraphProc reqDurationBounds: bounds, keyToMetric: make(map[string]metricSeries), shutdownCh: make(chan any), + statDroppedSpans: droppedSpan, + statTotalEdges: totalEdges, + statExpiredEdges: expiredEdges, } } @@ -299,7 +326,7 @@ func (p *serviceGraphProcessor) aggregateMetrics(ctx context.Context, td ptrace. if errors.Is(err, store.ErrTooManyItems) { totalDroppedSpans++ - stats.Record(ctx, statDroppedSpans.M(1)) + p.statDroppedSpans.Add(ctx, 1) continue } @@ -309,7 +336,7 @@ func (p *serviceGraphProcessor) aggregateMetrics(ctx context.Context, td ptrace. } if isNew { - stats.Record(ctx, statTotalEdges.M(1)) + p.statTotalEdges.Add(ctx, 1) } } } @@ -354,7 +381,7 @@ func (p *serviceGraphProcessor) onExpire(e *store.Edge) { zap.Stringer("trace_id", e.TraceID), ) - stats.Record(context.Background(), statExpiredEdges.M(1)) + p.statExpiredEdges.Add(context.Background(), 1) if virtualNodeFeatureGate.IsEnabled() { e.ConnectionType = store.VirtualNode diff --git a/processor/servicegraphprocessor/processor_test.go b/processor/servicegraphprocessor/processor_test.go index ab3e3f3051dc..8057519080fb 100644 --- a/processor/servicegraphprocessor/processor_test.go +++ b/processor/servicegraphprocessor/processor_test.go @@ -15,6 +15,7 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/config/configgrpc" + "go.opentelemetry.io/collector/config/configtelemetry" "go.opentelemetry.io/collector/connector/connectortest" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumertest" @@ -27,6 +28,9 @@ import ( "go.opentelemetry.io/collector/pdata/ptrace" "go.opentelemetry.io/collector/processor/processortest" semconv "go.opentelemetry.io/collector/semconv/v1.13.0" + sdkmetric "go.opentelemetry.io/otel/sdk/metric" + "go.opentelemetry.io/otel/sdk/metric/metricdata" + "go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest" "go.uber.org/zap/zaptest" ) @@ -99,7 +103,9 @@ func TestProcessorShutdown(t *testing.T) { // Test next := new(consumertest.TracesSink) - p := newProcessor(zaptest.NewLogger(t), cfg) + set := componenttest.NewNopTelemetrySettings() + set.Logger = zaptest.NewLogger(t) + p := newProcessor(set, cfg) p.tracesConsumer = next err := p.Shutdown(context.Background()) @@ -114,7 +120,9 @@ func TestConnectorShutdown(t *testing.T) { // Test next := new(consumertest.MetricsSink) - p := newProcessor(zaptest.NewLogger(t), cfg) + set := componenttest.NewNopTelemetrySettings() + set.Logger = zaptest.NewLogger(t) + p := newProcessor(set, cfg) p.metricsConsumer = next err := p.Shutdown(context.Background()) @@ -216,7 +224,9 @@ func TestProcessorConsume(t *testing.T) { } // Prepare - p := newProcessor(zaptest.NewLogger(t), tc.cfg) + set := componenttest.NewNopTelemetrySettings() + set.Logger = zaptest.NewLogger(t) + p := newProcessor(set, tc.cfg) p.tracesConsumer = consumertest.NewNop() metricsExporter := newMockMetricsExporter() @@ -259,7 +269,9 @@ func TestConnectorConsume(t *testing.T) { Store: StoreConfig{MaxItems: 10}, } - conn := newProcessor(zaptest.NewLogger(t), cfg) + set := componenttest.NewNopTelemetrySettings() + set.Logger = zaptest.NewLogger(t) + conn := newProcessor(set, cfg) conn.metricsConsumer = newMockMetricsExporter() assert.NoError(t, conn.Start(context.Background(), componenttest.NewNopHost())) @@ -281,7 +293,9 @@ func TestConnectorConsume(t *testing.T) { func TestProcessor_MetricsFlushInterval(t *testing.T) { // Prepare - p := newProcessor(zaptest.NewLogger(t), &Config{ + set := componenttest.NewNopTelemetrySettings() + set.Logger = zaptest.NewLogger(t) + p := newProcessor(set, &Config{ MetricsExporter: "mock", Dimensions: []string{"some-attribute", "non-existing-attribute"}, Store: StoreConfig{ @@ -599,7 +613,9 @@ func TestStaleSeriesCleanup(t *testing.T) { mockMetricsExporter := newMockMetricsExporter() - p := newProcessor(zaptest.NewLogger(t), cfg) + set := componenttest.NewNopTelemetrySettings() + set.Logger = zaptest.NewLogger(t) + p := newProcessor(set, cfg) p.tracesConsumer = consumertest.NewNop() mHost := newMockHost(map[component.DataType]map[component.ID]component.Component{ @@ -629,3 +645,76 @@ func TestStaleSeriesCleanup(t *testing.T) { // Shutdown the processor assert.NoError(t, p.Shutdown(context.Background())) } + +func setupTelemetry(reader *sdkmetric.ManualReader) component.TelemetrySettings { + settings := componenttest.NewNopTelemetrySettings() + settings.MetricsLevel = configtelemetry.LevelNormal + + settings.MeterProvider = sdkmetric.NewMeterProvider(sdkmetric.WithReader(reader)) + return settings +} + +func TestValidateOwnTelemetry(t *testing.T) { + cfg := &Config{ + MetricsExporter: "mock", + Dimensions: []string{"some-attribute", "non-existing-attribute"}, + Store: StoreConfig{ + MaxItems: 10, + TTL: time.Second, + }, + } + + mockMetricsExporter := newMockMetricsExporter() + + reader := sdkmetric.NewManualReader() + set := setupTelemetry(reader) + p := newProcessor(set, cfg) + p.tracesConsumer = consumertest.NewNop() + + mHost := newMockHost(map[component.DataType]map[component.ID]component.Component{ + component.DataTypeMetrics: { + component.NewID("mock"): mockMetricsExporter, + }, + }) + + assert.NoError(t, p.Start(context.Background(), mHost)) + + // ConsumeTraces + td := buildSampleTrace(t, "first") + assert.NoError(t, p.ConsumeTraces(context.Background(), td)) + + // Make series stale and force a cache cleanup + for key, metric := range p.keyToMetric { + metric.lastUpdated = 0 + p.keyToMetric[key] = metric + } + p.cleanCache() + assert.Equal(t, 0, len(p.keyToMetric)) + + // ConsumeTraces with a trace with different attribute value + td = buildSampleTrace(t, "second") + assert.NoError(t, p.ConsumeTraces(context.Background(), td)) + + // Shutdown the processor + assert.NoError(t, p.Shutdown(context.Background())) + + rm := metricdata.ResourceMetrics{} + assert.NoError(t, reader.Collect(context.Background(), &rm)) + require.Len(t, rm.ScopeMetrics, 1) + sm := rm.ScopeMetrics[0] + require.Len(t, sm.Metrics, 1) + got := sm.Metrics[0] + want := metricdata.Metrics{ + Name: "processor/servicegraph/total_edges", + Description: "Total number of unique edges", + Unit: "1", + Data: metricdata.Sum[int64]{ + Temporality: metricdata.CumulativeTemporality, + IsMonotonic: true, + DataPoints: []metricdata.DataPoint[int64]{ + {Value: 2}, + }, + }, + } + metricdatatest.AssertEqual(t, want, got, metricdatatest.IgnoreTimestamp()) +} diff --git a/processor/spanmetricsprocessor/generated_component_test.go b/processor/spanmetricsprocessor/generated_component_test.go new file mode 100644 index 000000000000..4ad9ec59fd2c --- /dev/null +++ b/processor/spanmetricsprocessor/generated_component_test.go @@ -0,0 +1,111 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package spanmetricsprocessor + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/collector/processor/processortest" + + "go.opentelemetry.io/collector/confmap/confmaptest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "traces", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + // TODO support lifecycle + t.SkipNow() + + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + err = c.Start(context.Background(), host) + require.NoError(t, err) + assert.NotPanics(t, func() { + switch e := c.(type) { + case processor.Logs: + logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + if !e.Capabilities().MutatesData { + logs.MarkReadOnly() + } + err = e.ConsumeLogs(context.Background(), logs) + case processor.Metrics: + metrics := testdata.GenerateMetricsTwoMetrics() + if !e.Capabilities().MutatesData { + metrics.MarkReadOnly() + } + err = e.ConsumeMetrics(context.Background(), metrics) + case processor.Traces: + traces := testdata.GenerateTracesTwoSpansSameResource() + if !e.Capabilities().MutatesData { + traces.MarkReadOnly() + } + err = e.ConsumeTraces(context.Background(), traces) + } + }) + assert.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + } +} diff --git a/processor/spanmetricsprocessor/go.mod b/processor/spanmetricsprocessor/go.mod index 5336276d0d2c..f0659557a1ca 100644 --- a/processor/spanmetricsprocessor/go.mod +++ b/processor/spanmetricsprocessor/go.mod @@ -18,6 +18,8 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/processor v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 google.golang.org/grpc v1.60.0 ) @@ -60,8 +62,6 @@ require ( go.opentelemetry.io/collector/receiver v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/processor/spanmetricsprocessor/internal/metadata/generated_status.go b/processor/spanmetricsprocessor/internal/metadata/generated_status.go index 737e528ab279..c10c80d870e4 100644 --- a/processor/spanmetricsprocessor/internal/metadata/generated_status.go +++ b/processor/spanmetricsprocessor/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "spanmetrics" TracesStability = component.StabilityLevelDeprecated ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/spanmetrics") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/spanmetrics") +} diff --git a/processor/spanmetricsprocessor/metadata.yaml b/processor/spanmetricsprocessor/metadata.yaml index 0317a0696c3f..eb040cf6e593 100644 --- a/processor/spanmetricsprocessor/metadata.yaml +++ b/processor/spanmetricsprocessor/metadata.yaml @@ -6,4 +6,8 @@ status: deprecated: [traces] distributions: [contrib, observiq, splunk, sumo] codeowners: - active: [albertteoh] \ No newline at end of file + active: [albertteoh] + +tests: + config: + skip_lifecycle: true diff --git a/processor/spanprocessor/generated_component_test.go b/processor/spanprocessor/generated_component_test.go new file mode 100644 index 000000000000..f439549bd444 --- /dev/null +++ b/processor/spanprocessor/generated_component_test.go @@ -0,0 +1,108 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package spanprocessor + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/collector/processor/processortest" + + "go.opentelemetry.io/collector/confmap/confmaptest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "traces", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + err = c.Start(context.Background(), host) + require.NoError(t, err) + assert.NotPanics(t, func() { + switch e := c.(type) { + case processor.Logs: + logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + if !e.Capabilities().MutatesData { + logs.MarkReadOnly() + } + err = e.ConsumeLogs(context.Background(), logs) + case processor.Metrics: + metrics := testdata.GenerateMetricsTwoMetrics() + if !e.Capabilities().MutatesData { + metrics.MarkReadOnly() + } + err = e.ConsumeMetrics(context.Background(), metrics) + case processor.Traces: + traces := testdata.GenerateTracesTwoSpansSameResource() + if !e.Capabilities().MutatesData { + traces.MarkReadOnly() + } + err = e.ConsumeTraces(context.Background(), traces) + } + }) + assert.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + } +} diff --git a/processor/spanprocessor/go.mod b/processor/spanprocessor/go.mod index 05bedc75bc4a..5fc372dafefa 100644 --- a/processor/spanprocessor/go.mod +++ b/processor/spanprocessor/go.mod @@ -14,6 +14,8 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/processor v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 ) require ( @@ -43,11 +45,9 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect - golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect + golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/processor/spanprocessor/go.sum b/processor/spanprocessor/go.sum index 84beecba2cfa..085bdf7c2370 100644 --- a/processor/spanprocessor/go.sum +++ b/processor/spanprocessor/go.sum @@ -143,8 +143,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= diff --git a/processor/spanprocessor/internal/metadata/generated_status.go b/processor/spanprocessor/internal/metadata/generated_status.go index 89baf8bd5dfe..730db7bf9779 100644 --- a/processor/spanprocessor/internal/metadata/generated_status.go +++ b/processor/spanprocessor/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "span" TracesStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/span") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/span") +} diff --git a/processor/spanprocessor/metadata.yaml b/processor/spanprocessor/metadata.yaml index 8a07f7407a59..d3348fc679c7 100644 --- a/processor/spanprocessor/metadata.yaml +++ b/processor/spanprocessor/metadata.yaml @@ -6,4 +6,9 @@ status: alpha: [traces] distributions: [core, contrib, observiq, splunk, sumo, aws, redhat, grafana] codeowners: - active: [boostchicken] \ No newline at end of file + active: [boostchicken] + +tests: + config: + name: + from_attributes: [db.svc, operation, id] diff --git a/processor/sumologicprocessor/generated_component_test.go b/processor/sumologicprocessor/generated_component_test.go new file mode 100644 index 000000000000..ba1f3efadce2 --- /dev/null +++ b/processor/sumologicprocessor/generated_component_test.go @@ -0,0 +1,122 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package sumologicprocessor + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/collector/processor/processortest" + + "go.opentelemetry.io/collector/confmap/confmaptest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "metrics", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "traces", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + err = c.Start(context.Background(), host) + require.NoError(t, err) + assert.NotPanics(t, func() { + switch e := c.(type) { + case processor.Logs: + logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + if !e.Capabilities().MutatesData { + logs.MarkReadOnly() + } + err = e.ConsumeLogs(context.Background(), logs) + case processor.Metrics: + metrics := testdata.GenerateMetricsTwoMetrics() + if !e.Capabilities().MutatesData { + metrics.MarkReadOnly() + } + err = e.ConsumeMetrics(context.Background(), metrics) + case processor.Traces: + traces := testdata.GenerateTracesTwoSpansSameResource() + if !e.Capabilities().MutatesData { + traces.MarkReadOnly() + } + err = e.ConsumeTraces(context.Background(), traces) + } + }) + assert.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + } +} diff --git a/processor/sumologicprocessor/go.mod b/processor/sumologicprocessor/go.mod index c84571842143..3d6a7124e861 100644 --- a/processor/sumologicprocessor/go.mod +++ b/processor/sumologicprocessor/go.mod @@ -3,13 +3,17 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/processor/sumol go 1.20 require ( + github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.91.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.91.0 + go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/otelcol v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/processor v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -59,7 +63,6 @@ require ( go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/collector v0.91.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect - go.opentelemetry.io/collector/confmap v0.91.0 // indirect go.opentelemetry.io/collector/connector v0.91.0 // indirect go.opentelemetry.io/collector/exporter v0.91.0 // indirect go.opentelemetry.io/collector/extension v0.91.0 // indirect @@ -78,10 +81,8 @@ require ( go.opentelemetry.io/otel/exporters/prometheus v0.44.1-0.20231201153405-6027c1ae76f2 // indirect go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.44.0 // indirect go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/sdk v1.21.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect @@ -95,3 +96,11 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden + +replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal diff --git a/processor/sumologicprocessor/go.sum b/processor/sumologicprocessor/go.sum index a36710981bd1..6b365325f17e 100644 --- a/processor/sumologicprocessor/go.sum +++ b/processor/sumologicprocessor/go.sum @@ -388,7 +388,7 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= +golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 h1:FqrVOBQxQ8r/UwwXibI0KMolVhvFiGobSfdE33deHJM= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= diff --git a/processor/sumologicprocessor/internal/metadata/generated_status.go b/processor/sumologicprocessor/internal/metadata/generated_status.go index a48e8d04a401..c70c8b7fb4bd 100644 --- a/processor/sumologicprocessor/internal/metadata/generated_status.go +++ b/processor/sumologicprocessor/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/sumologic") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/sumologic") +} diff --git a/processor/sumologicprocessor/metadata.yaml b/processor/sumologicprocessor/metadata.yaml index 8730a7d08605..a917f4feb391 100644 --- a/processor/sumologicprocessor/metadata.yaml +++ b/processor/sumologicprocessor/metadata.yaml @@ -7,3 +7,6 @@ status: distributions: [contrib, sumo] codeowners: active: [aboguszewski-sumo, astencel-sumo, sumo-drosiek] + +tests: + config: diff --git a/processor/tailsamplingprocessor/generated_component_test.go b/processor/tailsamplingprocessor/generated_component_test.go new file mode 100644 index 000000000000..7a61e03ae6bc --- /dev/null +++ b/processor/tailsamplingprocessor/generated_component_test.go @@ -0,0 +1,108 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package tailsamplingprocessor + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/collector/processor/processortest" + + "go.opentelemetry.io/collector/confmap/confmaptest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "traces", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + err = c.Start(context.Background(), host) + require.NoError(t, err) + assert.NotPanics(t, func() { + switch e := c.(type) { + case processor.Logs: + logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + if !e.Capabilities().MutatesData { + logs.MarkReadOnly() + } + err = e.ConsumeLogs(context.Background(), logs) + case processor.Metrics: + metrics := testdata.GenerateMetricsTwoMetrics() + if !e.Capabilities().MutatesData { + metrics.MarkReadOnly() + } + err = e.ConsumeMetrics(context.Background(), metrics) + case processor.Traces: + traces := testdata.GenerateTracesTwoSpansSameResource() + if !e.Capabilities().MutatesData { + traces.MarkReadOnly() + } + err = e.ConsumeTraces(context.Background(), traces) + } + }) + assert.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + } +} diff --git a/processor/tailsamplingprocessor/go.mod b/processor/tailsamplingprocessor/go.mod index 79a8c32baffb..098aca7d065c 100644 --- a/processor/tailsamplingprocessor/go.mod +++ b/processor/tailsamplingprocessor/go.mod @@ -16,6 +16,7 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/processor v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/goleak v1.3.0 go.uber.org/zap v1.26.0 @@ -43,9 +44,8 @@ require ( go.opentelemetry.io/collector v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect + golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/processor/tailsamplingprocessor/go.sum b/processor/tailsamplingprocessor/go.sum index a2fc44fe250a..5434b1ea6ab9 100644 --- a/processor/tailsamplingprocessor/go.sum +++ b/processor/tailsamplingprocessor/go.sum @@ -142,8 +142,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= diff --git a/processor/tailsamplingprocessor/internal/metadata/generated_status.go b/processor/tailsamplingprocessor/internal/metadata/generated_status.go index d76db8b400e9..06c076551b9a 100644 --- a/processor/tailsamplingprocessor/internal/metadata/generated_status.go +++ b/processor/tailsamplingprocessor/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "tail_sampling" TracesStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/tailsampling") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/tailsampling") +} diff --git a/processor/tailsamplingprocessor/metadata.yaml b/processor/tailsamplingprocessor/metadata.yaml index c68c47e447ad..d9fbdcd8e206 100644 --- a/processor/tailsamplingprocessor/metadata.yaml +++ b/processor/tailsamplingprocessor/metadata.yaml @@ -13,3 +13,6 @@ status: - sumo codeowners: active: [jpkrohling] + +tests: + config: diff --git a/processor/transformprocessor/generated_component_test.go b/processor/transformprocessor/generated_component_test.go new file mode 100644 index 000000000000..d9b4ad30b40b --- /dev/null +++ b/processor/transformprocessor/generated_component_test.go @@ -0,0 +1,122 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package transformprocessor + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/collector/processor/processortest" + + "go.opentelemetry.io/collector/confmap/confmaptest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "metrics", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "traces", + createFn: func(ctx context.Context, set processor.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + c, err := test.createFn(context.Background(), processortest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + err = c.Start(context.Background(), host) + require.NoError(t, err) + assert.NotPanics(t, func() { + switch e := c.(type) { + case processor.Logs: + logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + if !e.Capabilities().MutatesData { + logs.MarkReadOnly() + } + err = e.ConsumeLogs(context.Background(), logs) + case processor.Metrics: + metrics := testdata.GenerateMetricsTwoMetrics() + if !e.Capabilities().MutatesData { + metrics.MarkReadOnly() + } + err = e.ConsumeMetrics(context.Background(), metrics) + case processor.Traces: + traces := testdata.GenerateTracesTwoSpansSameResource() + if !e.Capabilities().MutatesData { + traces.MarkReadOnly() + } + err = e.ConsumeTraces(context.Background(), traces) + } + }) + assert.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + } +} diff --git a/processor/transformprocessor/go.mod b/processor/transformprocessor/go.mod index 4c62b6fddf16..401ca4fdaf63 100644 --- a/processor/transformprocessor/go.mod +++ b/processor/transformprocessor/go.mod @@ -4,6 +4,7 @@ go 1.20 require ( github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.91.0 + github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.91.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl v0.91.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.91.0 @@ -12,6 +13,8 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/processor v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -34,15 +37,12 @@ require ( github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.91.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/collector v0.91.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect - golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect + golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/processor/transformprocessor/go.sum b/processor/transformprocessor/go.sum index e7a6c51e9b7d..d5bbf8814307 100644 --- a/processor/transformprocessor/go.sum +++ b/processor/transformprocessor/go.sum @@ -138,8 +138,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= diff --git a/processor/transformprocessor/internal/logs/processor_test.go b/processor/transformprocessor/internal/logs/processor_test.go index 519e57ca65bb..5bceea2285c8 100644 --- a/processor/transformprocessor/internal/logs/processor_test.go +++ b/processor/transformprocessor/internal/logs/processor_test.go @@ -329,6 +329,10 @@ func Test_ProcessLogs_LogContext(t *testing.T) { td.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0).Attributes().PutDouble("test", 0.0) }, }, + { + statement: `replace_match(body["metadata"]["uid"], "*", "12345")`, + want: func(td plog.Logs) {}, + }, } for _, tt := range tests { diff --git a/processor/transformprocessor/internal/metadata/generated_status.go b/processor/transformprocessor/internal/metadata/generated_status.go index 245af46abae5..9ac7b26f2525 100644 --- a/processor/transformprocessor/internal/metadata/generated_status.go +++ b/processor/transformprocessor/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelAlpha LogsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/transform") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/transform") +} diff --git a/processor/transformprocessor/metadata.yaml b/processor/transformprocessor/metadata.yaml index 04d44fc33595..1503209aa717 100644 --- a/processor/transformprocessor/metadata.yaml +++ b/processor/transformprocessor/metadata.yaml @@ -8,3 +8,6 @@ status: warnings: [Unsound Transformations, Identity Conflict, Orphaned Telemetry, Other] codeowners: active: [TylerHelmuth, kentquirk, bogdandrutu, evan-bradley] + +tests: + config: diff --git a/receiver/activedirectorydsreceiver/go.mod b/receiver/activedirectorydsreceiver/go.mod index 71eebdee821a..194a654be62f 100644 --- a/receiver/activedirectorydsreceiver/go.mod +++ b/receiver/activedirectorydsreceiver/go.mod @@ -13,6 +13,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -39,8 +41,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/receiver/activedirectorydsreceiver/internal/metadata/generated_status.go b/receiver/activedirectorydsreceiver/internal/metadata/generated_status.go index d9a81b32daca..98a1160d8453 100644 --- a/receiver/activedirectorydsreceiver/internal/metadata/generated_status.go +++ b/receiver/activedirectorydsreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "active_directory_ds" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/activedirectorydsreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/activedirectorydsreceiver") +} diff --git a/receiver/aerospikereceiver/generated_component_test.go b/receiver/aerospikereceiver/generated_component_test.go new file mode 100644 index 000000000000..cc885c89f963 --- /dev/null +++ b/receiver/aerospikereceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package aerospikereceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/aerospikereceiver/go.mod b/receiver/aerospikereceiver/go.mod index cb77e02dea2f..f32d9d61f047 100644 --- a/receiver/aerospikereceiver/go.mod +++ b/receiver/aerospikereceiver/go.mod @@ -17,6 +17,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -78,8 +80,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.18.0 // indirect diff --git a/receiver/aerospikereceiver/internal/metadata/generated_status.go b/receiver/aerospikereceiver/internal/metadata/generated_status.go index 87677d32fbe2..78be7a216a94 100644 --- a/receiver/aerospikereceiver/internal/metadata/generated_status.go +++ b/receiver/aerospikereceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "aerospike" MetricsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/aerospikereceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/aerospikereceiver") +} diff --git a/receiver/aerospikereceiver/metadata.yaml b/receiver/aerospikereceiver/metadata.yaml index 5561dcb50d02..2bee22a609ab 100644 --- a/receiver/aerospikereceiver/metadata.yaml +++ b/receiver/aerospikereceiver/metadata.yaml @@ -248,3 +248,6 @@ metrics: input_type: string monotonic: true aggregation_temporality: cumulative + +tests: + config: diff --git a/receiver/apachereceiver/generated_component_test.go b/receiver/apachereceiver/generated_component_test.go new file mode 100644 index 000000000000..f1a0b57013eb --- /dev/null +++ b/receiver/apachereceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package apachereceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/apachereceiver/go.mod b/receiver/apachereceiver/go.mod index 90145b9c3006..8f60fcc364e3 100644 --- a/receiver/apachereceiver/go.mod +++ b/receiver/apachereceiver/go.mod @@ -16,6 +16,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -86,8 +88,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect golang.org/x/mod v0.14.0 // indirect diff --git a/receiver/apachereceiver/internal/metadata/generated_status.go b/receiver/apachereceiver/internal/metadata/generated_status.go index e736a3a1c284..870bb1c2a3ac 100644 --- a/receiver/apachereceiver/internal/metadata/generated_status.go +++ b/receiver/apachereceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "apache" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/apachereceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/apachereceiver") +} diff --git a/receiver/apachereceiver/metadata.yaml b/receiver/apachereceiver/metadata.yaml index a5bec812ed4a..83d51a319898 100644 --- a/receiver/apachereceiver/metadata.yaml +++ b/receiver/apachereceiver/metadata.yaml @@ -173,3 +173,6 @@ metrics: monotonic: false aggregation_temporality: cumulative attributes: [scoreboard_state] + +tests: + config: diff --git a/receiver/apachesparkreceiver/generated_component_test.go b/receiver/apachesparkreceiver/generated_component_test.go new file mode 100644 index 000000000000..fb96f448d67e --- /dev/null +++ b/receiver/apachesparkreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package apachesparkreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/apachesparkreceiver/go.mod b/receiver/apachesparkreceiver/go.mod index 2a75541966a5..07e494c88bc5 100644 --- a/receiver/apachesparkreceiver/go.mod +++ b/receiver/apachesparkreceiver/go.mod @@ -15,6 +15,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -87,8 +89,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect golang.org/x/mod v0.14.0 // indirect diff --git a/receiver/apachesparkreceiver/internal/metadata/generated_status.go b/receiver/apachesparkreceiver/internal/metadata/generated_status.go index 4c2ba72440c6..71eeacd3063f 100644 --- a/receiver/apachesparkreceiver/internal/metadata/generated_status.go +++ b/receiver/apachesparkreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "apachespark" MetricsStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/apachesparkreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/apachesparkreceiver") +} diff --git a/receiver/apachesparkreceiver/metadata.yaml b/receiver/apachesparkreceiver/metadata.yaml index 33bf28c6af4a..8f68afde24bf 100644 --- a/receiver/apachesparkreceiver/metadata.yaml +++ b/receiver/apachesparkreceiver/metadata.yaml @@ -688,3 +688,6 @@ metrics: value_type: int unit: ms attributes: [gc_type] + +tests: + config: diff --git a/receiver/awscloudwatchmetricsreceiver/generated_component_test.go b/receiver/awscloudwatchmetricsreceiver/generated_component_test.go new file mode 100644 index 000000000000..b9bf1a4ed688 --- /dev/null +++ b/receiver/awscloudwatchmetricsreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package awscloudwatchmetricsreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/awscloudwatchmetricsreceiver/go.mod b/receiver/awscloudwatchmetricsreceiver/go.mod index 2493ec438d2d..f1b09828cfbf 100644 --- a/receiver/awscloudwatchmetricsreceiver/go.mod +++ b/receiver/awscloudwatchmetricsreceiver/go.mod @@ -5,8 +5,11 @@ go 1.20 require ( github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.91.0 + go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -26,12 +29,9 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect - go.opentelemetry.io/collector/confmap v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/pdata v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/receiver/awscloudwatchmetricsreceiver/internal/metadata/generated_status.go b/receiver/awscloudwatchmetricsreceiver/internal/metadata/generated_status.go index 16e6bb8277cd..b8795e41e369 100644 --- a/receiver/awscloudwatchmetricsreceiver/internal/metadata/generated_status.go +++ b/receiver/awscloudwatchmetricsreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "awscloudwatchmetrics" MetricsStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/awscloudwatchmetricsreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/awscloudwatchmetricsreceiver") +} diff --git a/receiver/awscloudwatchmetricsreceiver/metadata.yaml b/receiver/awscloudwatchmetricsreceiver/metadata.yaml index 9dae2cb53b24..f7afd3faa98b 100644 --- a/receiver/awscloudwatchmetricsreceiver/metadata.yaml +++ b/receiver/awscloudwatchmetricsreceiver/metadata.yaml @@ -6,4 +6,7 @@ status: development: [metrics] distributions: [contrib] codeowners: - active: [jpkrohling] \ No newline at end of file + active: [jpkrohling] + +tests: + config: diff --git a/receiver/awscloudwatchreceiver/generated_component_test.go b/receiver/awscloudwatchreceiver/generated_component_test.go new file mode 100644 index 000000000000..c3f00644a6aa --- /dev/null +++ b/receiver/awscloudwatchreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package awscloudwatchreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/awscloudwatchreceiver/go.mod b/receiver/awscloudwatchreceiver/go.mod index 7150ed9c6af7..b18df4cc685a 100644 --- a/receiver/awscloudwatchreceiver/go.mod +++ b/receiver/awscloudwatchreceiver/go.mod @@ -3,7 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsclo go 1.20 require ( - github.com/aws/aws-sdk-go v1.49.1 + github.com/aws/aws-sdk-go v1.49.5 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.91.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.91.0 github.com/stretchr/testify v1.8.4 @@ -12,6 +12,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -37,8 +39,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/receiver/awscloudwatchreceiver/go.sum b/receiver/awscloudwatchreceiver/go.sum index 12e25faae8f8..56c3d5723c95 100644 --- a/receiver/awscloudwatchreceiver/go.sum +++ b/receiver/awscloudwatchreceiver/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.49.1 h1:Dsamcd8d/nNb3A+bZ0ucfGl0vGZsW5wlRW0vhoYGoeQ= -github.com/aws/aws-sdk-go v1.49.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.5 h1:y2yfBlwjPDi3/sBVKeznYEdDy6wIhjA2L5NCBMLUIYA= +github.com/aws/aws-sdk-go v1.49.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/receiver/awscloudwatchreceiver/internal/metadata/generated_status.go b/receiver/awscloudwatchreceiver/internal/metadata/generated_status.go index 0757ed842852..4e2b6df838a9 100644 --- a/receiver/awscloudwatchreceiver/internal/metadata/generated_status.go +++ b/receiver/awscloudwatchreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "awscloudwatch" LogsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/awscloudwatchreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/awscloudwatchreceiver") +} diff --git a/receiver/awscloudwatchreceiver/metadata.yaml b/receiver/awscloudwatchreceiver/metadata.yaml index 5d45699e2f81..11a375a93ad6 100644 --- a/receiver/awscloudwatchreceiver/metadata.yaml +++ b/receiver/awscloudwatchreceiver/metadata.yaml @@ -7,3 +7,6 @@ status: distributions: [contrib, observiq, sumo] codeowners: active: [djaglowski, schmikei] + +tests: + config: diff --git a/receiver/awscontainerinsightreceiver/generated_component_test.go b/receiver/awscontainerinsightreceiver/generated_component_test.go new file mode 100644 index 000000000000..017e7ed769f9 --- /dev/null +++ b/receiver/awscontainerinsightreceiver/generated_component_test.go @@ -0,0 +1,89 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package awscontainerinsightreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + // TODO support lifecycle + t.SkipNow() + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/awscontainerinsightreceiver/go.mod b/receiver/awscontainerinsightreceiver/go.mod index cf56b78f6d4d..fccca659b279 100644 --- a/receiver/awscontainerinsightreceiver/go.mod +++ b/receiver/awscontainerinsightreceiver/go.mod @@ -3,7 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscon go 1.20 require ( - github.com/aws/aws-sdk-go v1.49.1 + github.com/aws/aws-sdk-go v1.49.5 github.com/google/cadvisor v0.48.1 github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil v0.91.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/containerinsight v0.91.0 @@ -19,6 +19,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 k8s.io/api v0.28.4 k8s.io/apimachinery v0.28.4 @@ -121,8 +123,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/oauth2 v0.14.0 // indirect diff --git a/receiver/awscontainerinsightreceiver/go.sum b/receiver/awscontainerinsightreceiver/go.sum index 34da98e37279..370c36653bbd 100644 --- a/receiver/awscontainerinsightreceiver/go.sum +++ b/receiver/awscontainerinsightreceiver/go.sum @@ -38,8 +38,8 @@ github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb0 github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= -github.com/aws/aws-sdk-go v1.49.1 h1:Dsamcd8d/nNb3A+bZ0ucfGl0vGZsW5wlRW0vhoYGoeQ= -github.com/aws/aws-sdk-go v1.49.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.5 h1:y2yfBlwjPDi3/sBVKeznYEdDy6wIhjA2L5NCBMLUIYA= +github.com/aws/aws-sdk-go v1.49.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= diff --git a/receiver/awscontainerinsightreceiver/internal/metadata/generated_status.go b/receiver/awscontainerinsightreceiver/internal/metadata/generated_status.go index 3c8e95fb9a47..75b28f270687 100644 --- a/receiver/awscontainerinsightreceiver/internal/metadata/generated_status.go +++ b/receiver/awscontainerinsightreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "awscontainerinsightreceiver" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/awscontainerinsightreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/awscontainerinsightreceiver") +} diff --git a/receiver/awscontainerinsightreceiver/metadata.yaml b/receiver/awscontainerinsightreceiver/metadata.yaml index 6e86fe37b3d6..ab16d85dbf6f 100644 --- a/receiver/awscontainerinsightreceiver/metadata.yaml +++ b/receiver/awscontainerinsightreceiver/metadata.yaml @@ -7,4 +7,8 @@ status: distributions: [contrib, aws, observiq, sumo] warnings: [Other] codeowners: - active: [Aneurysm9, pxaws] \ No newline at end of file + active: [Aneurysm9, pxaws] + +tests: + config: + skip_lifecycle: true diff --git a/receiver/awsecscontainermetricsreceiver/go.mod b/receiver/awsecscontainermetricsreceiver/go.mod index 23581d8b54a0..bbb93c144974 100644 --- a/receiver/awsecscontainermetricsreceiver/go.mod +++ b/receiver/awsecscontainermetricsreceiver/go.mod @@ -3,7 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsecs go 1.20 require ( - github.com/aws/aws-sdk-go v1.49.1 + github.com/aws/aws-sdk-go v1.49.5 github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/ecsutil v0.91.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.91.0 github.com/stretchr/testify v1.8.4 @@ -14,6 +14,8 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -51,8 +53,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/receiver/awsecscontainermetricsreceiver/go.sum b/receiver/awsecscontainermetricsreceiver/go.sum index 1766cebb3820..f459a4d52e86 100644 --- a/receiver/awsecscontainermetricsreceiver/go.sum +++ b/receiver/awsecscontainermetricsreceiver/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.49.1 h1:Dsamcd8d/nNb3A+bZ0ucfGl0vGZsW5wlRW0vhoYGoeQ= -github.com/aws/aws-sdk-go v1.49.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.5 h1:y2yfBlwjPDi3/sBVKeznYEdDy6wIhjA2L5NCBMLUIYA= +github.com/aws/aws-sdk-go v1.49.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/receiver/awsecscontainermetricsreceiver/internal/metadata/generated_status.go b/receiver/awsecscontainermetricsreceiver/internal/metadata/generated_status.go index 2c61a860e37d..8f9401e2bb2f 100644 --- a/receiver/awsecscontainermetricsreceiver/internal/metadata/generated_status.go +++ b/receiver/awsecscontainermetricsreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "awsecscontainermetrics" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/awsecscontainermetricsreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/awsecscontainermetricsreceiver") +} diff --git a/receiver/awsfirehosereceiver/generated_component_test.go b/receiver/awsfirehosereceiver/generated_component_test.go new file mode 100644 index 000000000000..5190be074cbe --- /dev/null +++ b/receiver/awsfirehosereceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package awsfirehosereceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/awsfirehosereceiver/go.mod b/receiver/awsfirehosereceiver/go.mod index 37b6e11659a4..9d48a8181754 100644 --- a/receiver/awsfirehosereceiver/go.mod +++ b/receiver/awsfirehosereceiver/go.mod @@ -13,6 +13,8 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -48,8 +50,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/receiver/awsfirehosereceiver/internal/metadata/generated_status.go b/receiver/awsfirehosereceiver/internal/metadata/generated_status.go index 00036f12f462..ee52e719a041 100644 --- a/receiver/awsfirehosereceiver/internal/metadata/generated_status.go +++ b/receiver/awsfirehosereceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "awsfirehose" MetricsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/awsfirehosereceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/awsfirehosereceiver") +} diff --git a/receiver/awsfirehosereceiver/metadata.yaml b/receiver/awsfirehosereceiver/metadata.yaml index 9cb632b03e6b..cc49c2f86e80 100644 --- a/receiver/awsfirehosereceiver/metadata.yaml +++ b/receiver/awsfirehosereceiver/metadata.yaml @@ -7,3 +7,6 @@ status: distributions: [contrib, observiq, sumo] codeowners: active: [Aneurysm9] + +tests: + config: diff --git a/receiver/awsxrayreceiver/go.mod b/receiver/awsxrayreceiver/go.mod index 5444cf497273..0496319b75f4 100644 --- a/receiver/awsxrayreceiver/go.mod +++ b/receiver/awsxrayreceiver/go.mod @@ -3,7 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsxra go 1.20 require ( - github.com/aws/aws-sdk-go v1.49.1 + github.com/aws/aws-sdk-go v1.49.5 github.com/google/go-cmp v0.6.0 github.com/google/uuid v1.5.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/proxy v0.91.0 @@ -21,6 +21,8 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -63,10 +65,8 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect go.opentelemetry.io/otel/exporters/prometheus v0.44.1-0.20231201153405-6027c1ae76f2 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/sdk v1.21.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/receiver/awsxrayreceiver/go.sum b/receiver/awsxrayreceiver/go.sum index b37a3eb3b324..0ae95b40f829 100644 --- a/receiver/awsxrayreceiver/go.sum +++ b/receiver/awsxrayreceiver/go.sum @@ -41,8 +41,8 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= -github.com/aws/aws-sdk-go v1.49.1 h1:Dsamcd8d/nNb3A+bZ0ucfGl0vGZsW5wlRW0vhoYGoeQ= -github.com/aws/aws-sdk-go v1.49.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.5 h1:y2yfBlwjPDi3/sBVKeznYEdDy6wIhjA2L5NCBMLUIYA= +github.com/aws/aws-sdk-go v1.49.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= diff --git a/receiver/awsxrayreceiver/internal/metadata/generated_status.go b/receiver/awsxrayreceiver/internal/metadata/generated_status.go index 12af796c7f9f..dfb257d0fee3 100644 --- a/receiver/awsxrayreceiver/internal/metadata/generated_status.go +++ b/receiver/awsxrayreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "awsxray" TracesStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/awsxrayreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/awsxrayreceiver") +} diff --git a/receiver/azureblobreceiver/generated_component_test.go b/receiver/azureblobreceiver/generated_component_test.go new file mode 100644 index 000000000000..7ad60d743860 --- /dev/null +++ b/receiver/azureblobreceiver/generated_component_test.go @@ -0,0 +1,96 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package azureblobreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "traces", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + // TODO support lifecycle + t.SkipNow() + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/azureblobreceiver/go.mod b/receiver/azureblobreceiver/go.mod index 9e98b72a9053..64d0154b057f 100644 --- a/receiver/azureblobreceiver/go.mod +++ b/receiver/azureblobreceiver/go.mod @@ -8,10 +8,13 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/internal/sharedcomponent v0.91.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.91.0 + go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/otelcol v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -78,7 +81,6 @@ require ( go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/collector v0.91.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect - go.opentelemetry.io/collector/confmap v0.91.0 // indirect go.opentelemetry.io/collector/connector v0.91.0 // indirect go.opentelemetry.io/collector/exporter v0.91.0 // indirect go.opentelemetry.io/collector/extension v0.91.0 // indirect @@ -98,13 +100,11 @@ require ( go.opentelemetry.io/otel/exporters/prometheus v0.44.1-0.20231201153405-6027c1ae76f2 // indirect go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.44.0 // indirect go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/sdk v1.21.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.15.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/receiver/azureblobreceiver/go.sum b/receiver/azureblobreceiver/go.sum index 3a57203acec5..92f7c89a5200 100644 --- a/receiver/azureblobreceiver/go.sum +++ b/receiver/azureblobreceiver/go.sum @@ -433,8 +433,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= -golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/receiver/azureblobreceiver/internal/metadata/generated_status.go b/receiver/azureblobreceiver/internal/metadata/generated_status.go index 9a777de7ac84..167e958fe000 100644 --- a/receiver/azureblobreceiver/internal/metadata/generated_status.go +++ b/receiver/azureblobreceiver/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -11,3 +13,11 @@ const ( LogsStability = component.StabilityLevelDevelopment TracesStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/azureblobreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/azureblobreceiver") +} diff --git a/receiver/azureblobreceiver/metadata.yaml b/receiver/azureblobreceiver/metadata.yaml index 3cf4f6c83017..d9cbacf8e7d8 100644 --- a/receiver/azureblobreceiver/metadata.yaml +++ b/receiver/azureblobreceiver/metadata.yaml @@ -7,3 +7,8 @@ status: distributions: [contrib] codeowners: active: [eedorenko, mx-psi] + +tests: + config: + connection_string: DefaultEndpointsProtocol=https;AccountName=accountName;AccountKey=+idLkHYcL0MUWIKYHm2j4Q==;EndpointSuffix=core.windows.net + skip_lifecycle: true diff --git a/receiver/azureeventhubreceiver/generated_component_test.go b/receiver/azureeventhubreceiver/generated_component_test.go new file mode 100644 index 000000000000..c2e9b00abbca --- /dev/null +++ b/receiver/azureeventhubreceiver/generated_component_test.go @@ -0,0 +1,96 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package azureeventhubreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + // TODO support lifecycle + t.SkipNow() + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/azureeventhubreceiver/go.mod b/receiver/azureeventhubreceiver/go.mod index 488a03b88566..a978505663f5 100644 --- a/receiver/azureeventhubreceiver/go.mod +++ b/receiver/azureeventhubreceiver/go.mod @@ -12,12 +12,15 @@ require ( github.com/relvacode/iso8601 v1.3.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.91.0 + go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 go.opentelemetry.io/collector/otelcol v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -83,7 +86,6 @@ require ( go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/collector v0.91.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect - go.opentelemetry.io/collector/confmap v0.91.0 // indirect go.opentelemetry.io/collector/connector v0.91.0 // indirect go.opentelemetry.io/collector/exporter v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect @@ -101,14 +103,12 @@ require ( go.opentelemetry.io/otel/exporters/prometheus v0.44.1-0.20231201153405-6027c1ae76f2 // indirect go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.44.0 // indirect go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/sdk v1.21.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.15.0 // indirect - golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect + golang.org/x/crypto v0.17.0 // indirect + golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/receiver/azureeventhubreceiver/go.sum b/receiver/azureeventhubreceiver/go.sum index cdfadcb6e37d..4831998fe9c7 100644 --- a/receiver/azureeventhubreceiver/go.sum +++ b/receiver/azureeventhubreceiver/go.sum @@ -429,8 +429,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= -golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -441,8 +441,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= diff --git a/receiver/azureeventhubreceiver/internal/metadata/generated_status.go b/receiver/azureeventhubreceiver/internal/metadata/generated_status.go index 3d47cf2b77f5..a44b92d8eb82 100644 --- a/receiver/azureeventhubreceiver/internal/metadata/generated_status.go +++ b/receiver/azureeventhubreceiver/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -11,3 +13,11 @@ const ( MetricsStability = component.StabilityLevelAlpha LogsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/azureeventhubreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/azureeventhubreceiver") +} diff --git a/receiver/azureeventhubreceiver/metadata.yaml b/receiver/azureeventhubreceiver/metadata.yaml index ace512760f42..b090edac49f2 100644 --- a/receiver/azureeventhubreceiver/metadata.yaml +++ b/receiver/azureeventhubreceiver/metadata.yaml @@ -7,3 +7,7 @@ status: distributions: [contrib, splunk, observiq, sumo] codeowners: active: [atoulme, djaglowski] + +tests: + config: + skip_lifecycle: true diff --git a/receiver/azuremonitorreceiver/generated_component_test.go b/receiver/azuremonitorreceiver/generated_component_test.go new file mode 100644 index 000000000000..f4322abed4e0 --- /dev/null +++ b/receiver/azuremonitorreceiver/generated_component_test.go @@ -0,0 +1,89 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package azuremonitorreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + // TODO support lifecycle + t.SkipNow() + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/azuremonitorreceiver/go.mod b/receiver/azuremonitorreceiver/go.mod index c3dee665abb9..30bd3e66ce5a 100644 --- a/receiver/azuremonitorreceiver/go.mod +++ b/receiver/azuremonitorreceiver/go.mod @@ -16,6 +16,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -48,9 +50,7 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect - golang.org/x/crypto v0.16.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/receiver/azuremonitorreceiver/go.sum b/receiver/azuremonitorreceiver/go.sum index c741463eb4b7..f924b75ee8de 100644 --- a/receiver/azuremonitorreceiver/go.sum +++ b/receiver/azuremonitorreceiver/go.sum @@ -151,8 +151,8 @@ go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= diff --git a/receiver/azuremonitorreceiver/internal/metadata/generated_status.go b/receiver/azuremonitorreceiver/internal/metadata/generated_status.go index 3f47a0f2905a..4e756b90dab0 100644 --- a/receiver/azuremonitorreceiver/internal/metadata/generated_status.go +++ b/receiver/azuremonitorreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "azuremonitor" MetricsStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/azuremonitorreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/azuremonitorreceiver") +} diff --git a/receiver/azuremonitorreceiver/metadata.yaml b/receiver/azuremonitorreceiver/metadata.yaml index f0f5c34bdde1..8da29a730f9f 100644 --- a/receiver/azuremonitorreceiver/metadata.yaml +++ b/receiver/azuremonitorreceiver/metadata.yaml @@ -15,3 +15,7 @@ resource_attributes: azuremonitor.subscription_id: description: Azure subscription ID type: string + +tests: + config: + skip_lifecycle: true diff --git a/receiver/bigipreceiver/generated_component_test.go b/receiver/bigipreceiver/generated_component_test.go new file mode 100644 index 000000000000..992e1c525507 --- /dev/null +++ b/receiver/bigipreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package bigipreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/bigipreceiver/go.mod b/receiver/bigipreceiver/go.mod index 0c21476e8a98..5d331614126a 100644 --- a/receiver/bigipreceiver/go.mod +++ b/receiver/bigipreceiver/go.mod @@ -16,6 +16,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -88,8 +90,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect diff --git a/receiver/bigipreceiver/internal/metadata/generated_status.go b/receiver/bigipreceiver/internal/metadata/generated_status.go index e7b235d117b4..7e3d39fee4d9 100644 --- a/receiver/bigipreceiver/internal/metadata/generated_status.go +++ b/receiver/bigipreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "bigip" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/bigipreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/bigipreceiver") +} diff --git a/receiver/bigipreceiver/metadata.yaml b/receiver/bigipreceiver/metadata.yaml index cdd9a0ec52ad..da040235361a 100644 --- a/receiver/bigipreceiver/metadata.yaml +++ b/receiver/bigipreceiver/metadata.yaml @@ -286,3 +286,6 @@ metrics: value_type: int attributes: [enabled.status] enabled: true + +tests: + config: diff --git a/receiver/carbonreceiver/generated_component_test.go b/receiver/carbonreceiver/generated_component_test.go new file mode 100644 index 000000000000..8f4969ed04ac --- /dev/null +++ b/receiver/carbonreceiver/generated_component_test.go @@ -0,0 +1,89 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package carbonreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + // TODO support lifecycle + t.SkipNow() + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/carbonreceiver/go.mod b/receiver/carbonreceiver/go.mod index 298a0db9bd81..0f1c47d9772c 100644 --- a/receiver/carbonreceiver/go.mod +++ b/receiver/carbonreceiver/go.mod @@ -12,6 +12,7 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 go.opentelemetry.io/otel/sdk v1.21.0 go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 @@ -51,7 +52,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect go.opentelemetry.io/otel/exporters/prometheus v0.44.1-0.20231201153405-6027c1ae76f2 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect diff --git a/receiver/carbonreceiver/internal/metadata/generated_status.go b/receiver/carbonreceiver/internal/metadata/generated_status.go index 6dbde87f829a..8fa4e933ad9c 100644 --- a/receiver/carbonreceiver/internal/metadata/generated_status.go +++ b/receiver/carbonreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "carbon" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/carbonreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/carbonreceiver") +} diff --git a/receiver/carbonreceiver/metadata.yaml b/receiver/carbonreceiver/metadata.yaml index bbf85c50df99..194e14c46e45 100644 --- a/receiver/carbonreceiver/metadata.yaml +++ b/receiver/carbonreceiver/metadata.yaml @@ -8,3 +8,6 @@ status: codeowners: active: [aboguszewski-sumo] +tests: + config: + skip_lifecycle: true diff --git a/receiver/chronyreceiver/go.mod b/receiver/chronyreceiver/go.mod index ae07966b9aa3..59d99b975efe 100644 --- a/receiver/chronyreceiver/go.mod +++ b/receiver/chronyreceiver/go.mod @@ -12,6 +12,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -38,8 +40,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/receiver/chronyreceiver/internal/metadata/generated_status.go b/receiver/chronyreceiver/internal/metadata/generated_status.go index 4426039439b8..7a6939b6ca85 100644 --- a/receiver/chronyreceiver/internal/metadata/generated_status.go +++ b/receiver/chronyreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "chrony" MetricsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/chronyreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/chronyreceiver") +} diff --git a/receiver/cloudflarereceiver/generated_component_test.go b/receiver/cloudflarereceiver/generated_component_test.go new file mode 100644 index 000000000000..bacd62b90290 --- /dev/null +++ b/receiver/cloudflarereceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package cloudflarereceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/cloudflarereceiver/go.mod b/receiver/cloudflarereceiver/go.mod index 5e123edf7465..5d7f7459c39b 100644 --- a/receiver/cloudflarereceiver/go.mod +++ b/receiver/cloudflarereceiver/go.mod @@ -13,6 +13,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -39,8 +41,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/receiver/cloudflarereceiver/internal/metadata/generated_status.go b/receiver/cloudflarereceiver/internal/metadata/generated_status.go index 551aa5d9439f..83893156d838 100644 --- a/receiver/cloudflarereceiver/internal/metadata/generated_status.go +++ b/receiver/cloudflarereceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "cloudflare" LogsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/cloudflarereceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/cloudflarereceiver") +} diff --git a/receiver/cloudflarereceiver/logs.go b/receiver/cloudflarereceiver/logs.go index ad4256f57b9e..bcf53d824f76 100644 --- a/receiver/cloudflarereceiver/logs.go +++ b/receiver/cloudflarereceiver/logs.go @@ -8,6 +8,7 @@ import ( "compress/gzip" "context" "encoding/json" + "errors" "fmt" "io" "net" @@ -27,12 +28,13 @@ import ( ) type logsReceiver struct { - logger *zap.Logger - cfg *LogsConfig - server *http.Server - consumer consumer.Logs - wg *sync.WaitGroup - id component.ID // ID of the receiver component + logger *zap.Logger + cfg *LogsConfig + server *http.Server + consumer consumer.Logs + wg *sync.WaitGroup + id component.ID // ID of the receiver component + telemetrySettings component.TelemetrySettings } const secretHeaderName = "X-CF-Secret" @@ -40,11 +42,12 @@ const receiverScopeName = "otelcol/" + metadata.Type func newLogsReceiver(params rcvr.CreateSettings, cfg *Config, consumer consumer.Logs) (*logsReceiver, error) { recv := &logsReceiver{ - cfg: &cfg.Logs, - consumer: consumer, - logger: params.Logger, - wg: &sync.WaitGroup{}, - id: params.ID, + cfg: &cfg.Logs, + consumer: consumer, + logger: params.Logger, + wg: &sync.WaitGroup{}, + telemetrySettings: params.TelemetrySettings, + id: params.ID, } recv.server = &http.Server{ @@ -80,7 +83,7 @@ func (l *logsReceiver) Shutdown(ctx context.Context) error { return nil } -func (l *logsReceiver) startListening(ctx context.Context, host component.Host) error { +func (l *logsReceiver) startListening(ctx context.Context, _ component.Host) error { l.logger.Debug("starting receiver HTTP server") // We use l.server.Serve* over l.server.ListenAndServe* // So that we can catch and return errors relating to binding to network interface on start. @@ -105,9 +108,9 @@ func (l *logsReceiver) startListening(ctx context.Context, host component.Host) l.logger.Debug("ServeTLS done") - if err != http.ErrServerClosed { + if !errors.Is(err, http.ErrServerClosed) { l.logger.Error("ServeTLS failed", zap.Error(err)) - host.ReportFatalError(err) + _ = l.telemetrySettings.ReportComponentStatus(component.NewFatalErrorEvent(err)) } } else { @@ -118,9 +121,9 @@ func (l *logsReceiver) startListening(ctx context.Context, host component.Host) l.logger.Debug("Serve done") - if err != http.ErrServerClosed { + if !errors.Is(err, http.ErrServerClosed) { l.logger.Error("Serve failed", zap.Error(err)) - host.ReportFatalError(err) + _ = l.telemetrySettings.ReportComponentStatus(component.NewFatalErrorEvent(err)) } } diff --git a/receiver/cloudflarereceiver/metadata.yaml b/receiver/cloudflarereceiver/metadata.yaml index 031aae49d673..2742bce9107d 100644 --- a/receiver/cloudflarereceiver/metadata.yaml +++ b/receiver/cloudflarereceiver/metadata.yaml @@ -7,3 +7,6 @@ status: distributions: [contrib, observiq, sumo] codeowners: active: [dehaansa, djaglowski] + +tests: + config: diff --git a/receiver/cloudfoundryreceiver/generated_component_test.go b/receiver/cloudfoundryreceiver/generated_component_test.go new file mode 100644 index 000000000000..21cc8bd2f5ac --- /dev/null +++ b/receiver/cloudfoundryreceiver/generated_component_test.go @@ -0,0 +1,89 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package cloudfoundryreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + // TODO support lifecycle + t.SkipNow() + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/cloudfoundryreceiver/go.mod b/receiver/cloudfoundryreceiver/go.mod index 8d3ab9edaa1f..9729cf691a1d 100644 --- a/receiver/cloudfoundryreceiver/go.mod +++ b/receiver/cloudfoundryreceiver/go.mod @@ -14,6 +14,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -54,8 +56,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/receiver/cloudfoundryreceiver/internal/metadata/generated_status.go b/receiver/cloudfoundryreceiver/internal/metadata/generated_status.go index c9b0886f4d11..fd69ff02cda3 100644 --- a/receiver/cloudfoundryreceiver/internal/metadata/generated_status.go +++ b/receiver/cloudfoundryreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "cloudfoundry" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/cloudfoundryreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/cloudfoundryreceiver") +} diff --git a/receiver/cloudfoundryreceiver/metadata.yaml b/receiver/cloudfoundryreceiver/metadata.yaml index f1397246fc35..4992884ee6b5 100644 --- a/receiver/cloudfoundryreceiver/metadata.yaml +++ b/receiver/cloudfoundryreceiver/metadata.yaml @@ -7,3 +7,7 @@ status: distributions: [contrib, splunk, observiq, sumo] codeowners: active: [agoallikmaa, pellared, crobert-1] + +tests: + config: + skip_lifecycle: true diff --git a/receiver/collectdreceiver/generated_component_test.go b/receiver/collectdreceiver/generated_component_test.go new file mode 100644 index 000000000000..ad451c0bf1c6 --- /dev/null +++ b/receiver/collectdreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package collectdreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/collectdreceiver/go.mod b/receiver/collectdreceiver/go.mod index 92e6c52ce391..c212a91ba2cd 100644 --- a/receiver/collectdreceiver/go.mod +++ b/receiver/collectdreceiver/go.mod @@ -14,6 +14,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -54,8 +56,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/receiver/collectdreceiver/internal/metadata/generated_status.go b/receiver/collectdreceiver/internal/metadata/generated_status.go index 80ff48023625..9fa9bd1a1cfd 100644 --- a/receiver/collectdreceiver/internal/metadata/generated_status.go +++ b/receiver/collectdreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "collectd" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/collectdreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/collectdreceiver") +} diff --git a/receiver/collectdreceiver/metadata.yaml b/receiver/collectdreceiver/metadata.yaml index 04e7fb48825c..3796acd9422a 100644 --- a/receiver/collectdreceiver/metadata.yaml +++ b/receiver/collectdreceiver/metadata.yaml @@ -7,3 +7,6 @@ status: distributions: [contrib, splunk, observiq, sumo] codeowners: active: [atoulme] + +tests: + config: diff --git a/receiver/couchdbreceiver/generated_component_test.go b/receiver/couchdbreceiver/generated_component_test.go new file mode 100644 index 000000000000..723d9eefb86b --- /dev/null +++ b/receiver/couchdbreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package couchdbreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/couchdbreceiver/go.mod b/receiver/couchdbreceiver/go.mod index aab30beca41b..b18769b0767b 100644 --- a/receiver/couchdbreceiver/go.mod +++ b/receiver/couchdbreceiver/go.mod @@ -15,6 +15,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -55,8 +57,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/receiver/couchdbreceiver/internal/metadata/generated_status.go b/receiver/couchdbreceiver/internal/metadata/generated_status.go index 044ad40ad22e..3324981bbbe9 100644 --- a/receiver/couchdbreceiver/internal/metadata/generated_status.go +++ b/receiver/couchdbreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "couchdb" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/couchdbreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/couchdbreceiver") +} diff --git a/receiver/couchdbreceiver/metadata.yaml b/receiver/couchdbreceiver/metadata.yaml index 8e632765db37..06c5b700544b 100644 --- a/receiver/couchdbreceiver/metadata.yaml +++ b/receiver/couchdbreceiver/metadata.yaml @@ -98,3 +98,5 @@ metrics: monotonic: true aggregation_temporality: cumulative attributes: [ operation ] +tests: + config: \ No newline at end of file diff --git a/receiver/datadogreceiver/go.mod b/receiver/datadogreceiver/go.mod index b8c04e438dcf..48d2da7faf01 100644 --- a/receiver/datadogreceiver/go.mod +++ b/receiver/datadogreceiver/go.mod @@ -13,6 +13,8 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 google.golang.org/protobuf v1.31.0 ) @@ -56,8 +58,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/receiver/datadogreceiver/internal/metadata/generated_status.go b/receiver/datadogreceiver/internal/metadata/generated_status.go index bef0e6fe969e..a1e7e3ce0d44 100644 --- a/receiver/datadogreceiver/internal/metadata/generated_status.go +++ b/receiver/datadogreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "datadog" TracesStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/datadogreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/datadogreceiver") +} diff --git a/receiver/dockerstatsreceiver/go.mod b/receiver/dockerstatsreceiver/go.mod index 63478954d268..6be549798e50 100644 --- a/receiver/dockerstatsreceiver/go.mod +++ b/receiver/dockerstatsreceiver/go.mod @@ -17,6 +17,8 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -74,8 +76,6 @@ require ( go.opentelemetry.io/collector v0.91.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.18.0 // indirect diff --git a/receiver/dockerstatsreceiver/internal/metadata/generated_status.go b/receiver/dockerstatsreceiver/internal/metadata/generated_status.go index e6c42c0b3a41..1081bd85d0cb 100644 --- a/receiver/dockerstatsreceiver/internal/metadata/generated_status.go +++ b/receiver/dockerstatsreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "docker_stats" MetricsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/dockerstatsreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/dockerstatsreceiver") +} diff --git a/receiver/elasticsearchreceiver/go.mod b/receiver/elasticsearchreceiver/go.mod index 283b33938217..10e12ff51e2b 100644 --- a/receiver/elasticsearchreceiver/go.mod +++ b/receiver/elasticsearchreceiver/go.mod @@ -19,6 +19,8 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -88,8 +90,6 @@ require ( go.opentelemetry.io/collector/extension/auth v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect diff --git a/receiver/elasticsearchreceiver/internal/metadata/generated_status.go b/receiver/elasticsearchreceiver/internal/metadata/generated_status.go index 1e75fc8444fd..19508d0618a7 100644 --- a/receiver/elasticsearchreceiver/internal/metadata/generated_status.go +++ b/receiver/elasticsearchreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "elasticsearch" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/elasticsearchreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/elasticsearchreceiver") +} diff --git a/receiver/expvarreceiver/generated_component_test.go b/receiver/expvarreceiver/generated_component_test.go new file mode 100644 index 000000000000..e553119615de --- /dev/null +++ b/receiver/expvarreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package expvarreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/expvarreceiver/go.mod b/receiver/expvarreceiver/go.mod index 91c4b3b70ff2..3a29d1737712 100644 --- a/receiver/expvarreceiver/go.mod +++ b/receiver/expvarreceiver/go.mod @@ -13,6 +13,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -53,8 +55,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/receiver/expvarreceiver/internal/metadata/generated_status.go b/receiver/expvarreceiver/internal/metadata/generated_status.go index 82ab4ddd3281..3a161a54892c 100644 --- a/receiver/expvarreceiver/internal/metadata/generated_status.go +++ b/receiver/expvarreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "expvar" MetricsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/expvarreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/expvarreceiver") +} diff --git a/receiver/expvarreceiver/metadata.yaml b/receiver/expvarreceiver/metadata.yaml index 7fad22e4fcd6..d45631c63959 100644 --- a/receiver/expvarreceiver/metadata.yaml +++ b/receiver/expvarreceiver/metadata.yaml @@ -264,3 +264,5 @@ metrics: unit: 1 gauge: value_type: double +tests: + config: \ No newline at end of file diff --git a/receiver/filelogreceiver/go.mod b/receiver/filelogreceiver/go.mod index 1f96c4428114..b4af51bbcf07 100644 --- a/receiver/filelogreceiver/go.mod +++ b/receiver/filelogreceiver/go.mod @@ -13,6 +13,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -43,8 +45,6 @@ require ( go.opentelemetry.io/collector/extension v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/receiver/filelogreceiver/internal/metadata/generated_status.go b/receiver/filelogreceiver/internal/metadata/generated_status.go index e5af859f475c..af0ec1daee9b 100644 --- a/receiver/filelogreceiver/internal/metadata/generated_status.go +++ b/receiver/filelogreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "filelog" LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/filelogreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/filelogreceiver") +} diff --git a/receiver/filereceiver/go.mod b/receiver/filereceiver/go.mod index ea264d11eebf..2f0a5bb409c7 100644 --- a/receiver/filereceiver/go.mod +++ b/receiver/filereceiver/go.mod @@ -9,6 +9,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -30,8 +32,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/receiver/filereceiver/internal/metadata/generated_status.go b/receiver/filereceiver/internal/metadata/generated_status.go index 0078298d283c..52d9e4b70db5 100644 --- a/receiver/filereceiver/internal/metadata/generated_status.go +++ b/receiver/filereceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "file" MetricsStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/filereceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/filereceiver") +} diff --git a/receiver/filestatsreceiver/generated_component_test.go b/receiver/filestatsreceiver/generated_component_test.go new file mode 100644 index 000000000000..78762f052969 --- /dev/null +++ b/receiver/filestatsreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package filestatsreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/filestatsreceiver/go.mod b/receiver/filestatsreceiver/go.mod index fde4ca591931..b77cdf4603ea 100644 --- a/receiver/filestatsreceiver/go.mod +++ b/receiver/filestatsreceiver/go.mod @@ -11,6 +11,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -35,8 +37,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/receiver/filestatsreceiver/internal/metadata/generated_status.go b/receiver/filestatsreceiver/internal/metadata/generated_status.go index fb070282000e..fe2affc5b847 100644 --- a/receiver/filestatsreceiver/internal/metadata/generated_status.go +++ b/receiver/filestatsreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "filestats" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/filestatsreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/filestatsreceiver") +} diff --git a/receiver/filestatsreceiver/metadata.yaml b/receiver/filestatsreceiver/metadata.yaml index 7a83877f625f..1ad23d35a17c 100644 --- a/receiver/filestatsreceiver/metadata.yaml +++ b/receiver/filestatsreceiver/metadata.yaml @@ -57,3 +57,5 @@ metrics: gauge: value_type: int unit: "b" +tests: + config: \ No newline at end of file diff --git a/receiver/flinkmetricsreceiver/generated_component_test.go b/receiver/flinkmetricsreceiver/generated_component_test.go new file mode 100644 index 000000000000..e8e6bdbb2e89 --- /dev/null +++ b/receiver/flinkmetricsreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package flinkmetricsreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/flinkmetricsreceiver/go.mod b/receiver/flinkmetricsreceiver/go.mod index 5ae6450ef221..4b40f9cbff13 100644 --- a/receiver/flinkmetricsreceiver/go.mod +++ b/receiver/flinkmetricsreceiver/go.mod @@ -16,6 +16,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -87,8 +89,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect golang.org/x/mod v0.14.0 // indirect diff --git a/receiver/flinkmetricsreceiver/internal/metadata/generated_status.go b/receiver/flinkmetricsreceiver/internal/metadata/generated_status.go index 309aacce367b..c7c54c576fa5 100644 --- a/receiver/flinkmetricsreceiver/internal/metadata/generated_status.go +++ b/receiver/flinkmetricsreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "flinkmetrics" MetricsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/flinkmetricsreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/flinkmetricsreceiver") +} diff --git a/receiver/flinkmetricsreceiver/metadata.yaml b/receiver/flinkmetricsreceiver/metadata.yaml index 116f8481abc6..8454dc23fabd 100644 --- a/receiver/flinkmetricsreceiver/metadata.yaml +++ b/receiver/flinkmetricsreceiver/metadata.yaml @@ -342,3 +342,5 @@ metrics: value_type: int input_type: string attributes: [ operator_name ] +tests: + config: \ No newline at end of file diff --git a/receiver/fluentforwardreceiver/generated_component_test.go b/receiver/fluentforwardreceiver/generated_component_test.go new file mode 100644 index 000000000000..dfc243a9fab9 --- /dev/null +++ b/receiver/fluentforwardreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package fluentforwardreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/fluentforwardreceiver/go.mod b/receiver/fluentforwardreceiver/go.mod index 2b70c4b2ffaa..75c46ee66498 100644 --- a/receiver/fluentforwardreceiver/go.mod +++ b/receiver/fluentforwardreceiver/go.mod @@ -12,6 +12,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -37,8 +39,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/receiver/fluentforwardreceiver/internal/metadata/generated_status.go b/receiver/fluentforwardreceiver/internal/metadata/generated_status.go index 631e60f7a36e..af9b652c005f 100644 --- a/receiver/fluentforwardreceiver/internal/metadata/generated_status.go +++ b/receiver/fluentforwardreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "fluentforward" LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/fluentforwardreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/fluentforwardreceiver") +} diff --git a/receiver/fluentforwardreceiver/metadata.yaml b/receiver/fluentforwardreceiver/metadata.yaml index 6b55ad731e7e..b4a4c708d38a 100644 --- a/receiver/fluentforwardreceiver/metadata.yaml +++ b/receiver/fluentforwardreceiver/metadata.yaml @@ -7,3 +7,5 @@ status: distributions: [contrib, splunk, observiq, sumo] codeowners: active: [dmitryax] +tests: + config: \ No newline at end of file diff --git a/receiver/gitproviderreceiver/go.mod b/receiver/gitproviderreceiver/go.mod index 433469b7e8d2..1bd7b7d81f92 100644 --- a/receiver/gitproviderreceiver/go.mod +++ b/receiver/gitproviderreceiver/go.mod @@ -15,6 +15,8 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -96,10 +98,8 @@ require ( go.opentelemetry.io/otel/exporters/prometheus v0.44.1-0.20231201153405-6027c1ae76f2 // indirect go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.44.0 // indirect go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/sdk v1.21.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.19.0 // indirect diff --git a/receiver/gitproviderreceiver/internal/metadata/generated_status.go b/receiver/gitproviderreceiver/internal/metadata/generated_status.go index b3ad9b8e840c..7418c60fae43 100644 --- a/receiver/gitproviderreceiver/internal/metadata/generated_status.go +++ b/receiver/gitproviderreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "gitprovider" MetricsStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/gitproviderreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/gitproviderreceiver") +} diff --git a/receiver/googlecloudpubsubreceiver/generated_component_test.go b/receiver/googlecloudpubsubreceiver/generated_component_test.go new file mode 100644 index 000000000000..55c26fc43058 --- /dev/null +++ b/receiver/googlecloudpubsubreceiver/generated_component_test.go @@ -0,0 +1,103 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package googlecloudpubsubreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "traces", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + // TODO support lifecycle + t.SkipNow() + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/googlecloudpubsubreceiver/go.mod b/receiver/googlecloudpubsubreceiver/go.mod index 2390e0442009..bcb315ca545e 100644 --- a/receiver/googlecloudpubsubreceiver/go.mod +++ b/receiver/googlecloudpubsubreceiver/go.mod @@ -11,6 +11,8 @@ require ( go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 google.golang.org/api v0.154.0 google.golang.org/grpc v1.60.0 @@ -52,10 +54,8 @@ require ( go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.16.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/oauth2 v0.15.0 // indirect golang.org/x/sync v0.5.0 // indirect diff --git a/receiver/googlecloudpubsubreceiver/go.sum b/receiver/googlecloudpubsubreceiver/go.sum index 81bbe1228107..f188c008e148 100644 --- a/receiver/googlecloudpubsubreceiver/go.sum +++ b/receiver/googlecloudpubsubreceiver/go.sum @@ -165,8 +165,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= diff --git a/receiver/googlecloudpubsubreceiver/internal/metadata/generated_status.go b/receiver/googlecloudpubsubreceiver/internal/metadata/generated_status.go index 4ca213b9b990..6fbc953505eb 100644 --- a/receiver/googlecloudpubsubreceiver/internal/metadata/generated_status.go +++ b/receiver/googlecloudpubsubreceiver/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( LogsStability = component.StabilityLevelBeta MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/googlecloudpubsubreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/googlecloudpubsubreceiver") +} diff --git a/receiver/googlecloudpubsubreceiver/metadata.yaml b/receiver/googlecloudpubsubreceiver/metadata.yaml index 9837e28052d6..ca8b4d5a503d 100644 --- a/receiver/googlecloudpubsubreceiver/metadata.yaml +++ b/receiver/googlecloudpubsubreceiver/metadata.yaml @@ -7,3 +7,11 @@ status: distributions: [observiq, sumo] codeowners: active: [alexvanboxel] + +tests: + config: + project: my-project + user_agent: user-agent + timeout: 20s + subscription: projects/my-project/subscriptions/otlp-subscription + skip_lifecycle: true diff --git a/receiver/googlecloudpubsubreceiver/receiver.go b/receiver/googlecloudpubsubreceiver/receiver.go index e4fc2b073bb8..f5c51b9fc264 100644 --- a/receiver/googlecloudpubsubreceiver/receiver.go +++ b/receiver/googlecloudpubsubreceiver/receiver.go @@ -111,6 +111,9 @@ func (receiver *pubsubReceiver) Start(ctx context.Context, _ component.Host) err } func (receiver *pubsubReceiver) Shutdown(_ context.Context) error { + if receiver.handler == nil { + return nil + } receiver.logger.Info("Stopping Google Pubsub receiver") receiver.handler.CancelNow() receiver.logger.Info("Stopped Google Pubsub receiver") diff --git a/receiver/googlecloudspannerreceiver/generated_component_test.go b/receiver/googlecloudspannerreceiver/generated_component_test.go new file mode 100644 index 000000000000..229d5141834e --- /dev/null +++ b/receiver/googlecloudspannerreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package googlecloudspannerreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/googlecloudspannerreceiver/go.mod b/receiver/googlecloudspannerreceiver/go.mod index 2b9f25b29b7e..b54a4c140ea7 100644 --- a/receiver/googlecloudspannerreceiver/go.mod +++ b/receiver/googlecloudspannerreceiver/go.mod @@ -12,6 +12,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 google.golang.org/api v0.154.0 @@ -60,9 +62,7 @@ require ( go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect - golang.org/x/crypto v0.16.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/oauth2 v0.15.0 // indirect golang.org/x/sync v0.5.0 // indirect diff --git a/receiver/googlecloudspannerreceiver/go.sum b/receiver/googlecloudspannerreceiver/go.sum index db7a3e27c2ab..e4e52d9d8b4f 100644 --- a/receiver/googlecloudspannerreceiver/go.sum +++ b/receiver/googlecloudspannerreceiver/go.sum @@ -181,8 +181,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= diff --git a/receiver/googlecloudspannerreceiver/internal/metadata/generated_status.go b/receiver/googlecloudspannerreceiver/internal/metadata/generated_status.go index 4a8d2ff5bf1a..8a5b22791786 100644 --- a/receiver/googlecloudspannerreceiver/internal/metadata/generated_status.go +++ b/receiver/googlecloudspannerreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "googlecloudspanner" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/googlecloudspannerreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/googlecloudspannerreceiver") +} diff --git a/receiver/googlecloudspannerreceiver/metadata.yaml b/receiver/googlecloudspannerreceiver/metadata.yaml index 5083961d92f4..2d5f10f8ccc6 100644 --- a/receiver/googlecloudspannerreceiver/metadata.yaml +++ b/receiver/googlecloudspannerreceiver/metadata.yaml @@ -7,3 +7,5 @@ status: distributions: [contrib, observiq, sumo] codeowners: active: [architjugran, varunraiko, kiranmayib] +tests: + config: \ No newline at end of file diff --git a/receiver/haproxyreceiver/generated_component_test.go b/receiver/haproxyreceiver/generated_component_test.go new file mode 100644 index 000000000000..7f65e0d9a495 --- /dev/null +++ b/receiver/haproxyreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package haproxyreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/haproxyreceiver/go.mod b/receiver/haproxyreceiver/go.mod index 459b643a905e..b612333d42e2 100644 --- a/receiver/haproxyreceiver/go.mod +++ b/receiver/haproxyreceiver/go.mod @@ -15,6 +15,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -87,8 +89,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect diff --git a/receiver/haproxyreceiver/internal/metadata/generated_status.go b/receiver/haproxyreceiver/internal/metadata/generated_status.go index 800ca6321a73..f87f2a87d730 100644 --- a/receiver/haproxyreceiver/internal/metadata/generated_status.go +++ b/receiver/haproxyreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "haproxy" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/haproxyreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/haproxyreceiver") +} diff --git a/receiver/haproxyreceiver/metadata.yaml b/receiver/haproxyreceiver/metadata.yaml index 260f045184f4..c949ccb0938b 100644 --- a/receiver/haproxyreceiver/metadata.yaml +++ b/receiver/haproxyreceiver/metadata.yaml @@ -261,3 +261,6 @@ metrics: value_type: double input_type: string unit: "{sessions}" + +tests: + config: \ No newline at end of file diff --git a/receiver/hostmetricsreceiver/generated_component_test.go b/receiver/hostmetricsreceiver/generated_component_test.go new file mode 100644 index 000000000000..18c0861c732a --- /dev/null +++ b/receiver/hostmetricsreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package hostmetricsreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/hostmetricsreceiver/go.mod b/receiver/hostmetricsreceiver/go.mod index 212e240c8564..6c0cac4f93bd 100644 --- a/receiver/hostmetricsreceiver/go.mod +++ b/receiver/hostmetricsreceiver/go.mod @@ -19,6 +19,8 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 golang.org/x/sys v0.15.0 @@ -112,12 +114,10 @@ require ( go.opentelemetry.io/otel/exporters/prometheus v0.44.1-0.20231201153405-6027c1ae76f2 // indirect go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.44.0 // indirect go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/sdk v1.21.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect - golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect + golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/receiver/hostmetricsreceiver/go.sum b/receiver/hostmetricsreceiver/go.sum index e34cbaa15ac7..8acd132b3497 100644 --- a/receiver/hostmetricsreceiver/go.sum +++ b/receiver/hostmetricsreceiver/go.sum @@ -462,8 +462,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= diff --git a/receiver/hostmetricsreceiver/internal/metadata/generated_status.go b/receiver/hostmetricsreceiver/internal/metadata/generated_status.go index d3dd91c1d197..98c47b73ced1 100644 --- a/receiver/hostmetricsreceiver/internal/metadata/generated_status.go +++ b/receiver/hostmetricsreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "hostmetrics" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/hostmetricsreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/hostmetricsreceiver") +} diff --git a/receiver/hostmetricsreceiver/metadata.yaml b/receiver/hostmetricsreceiver/metadata.yaml index 0d456d7d06c8..3a0de618f3ec 100644 --- a/receiver/hostmetricsreceiver/metadata.yaml +++ b/receiver/hostmetricsreceiver/metadata.yaml @@ -7,3 +7,5 @@ status: distributions: [core, contrib, observiq, splunk, sumo] codeowners: active: [dmitryax, braydonk] +tests: + config: diff --git a/receiver/httpcheckreceiver/generated_component_test.go b/receiver/httpcheckreceiver/generated_component_test.go new file mode 100644 index 000000000000..411d3eff71c6 --- /dev/null +++ b/receiver/httpcheckreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package httpcheckreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/httpcheckreceiver/go.mod b/receiver/httpcheckreceiver/go.mod index 710c4c601573..ac93925dcfc4 100644 --- a/receiver/httpcheckreceiver/go.mod +++ b/receiver/httpcheckreceiver/go.mod @@ -14,6 +14,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -54,8 +56,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/receiver/httpcheckreceiver/internal/metadata/generated_status.go b/receiver/httpcheckreceiver/internal/metadata/generated_status.go index 75cc7ae53d9c..8428f435ef12 100644 --- a/receiver/httpcheckreceiver/internal/metadata/generated_status.go +++ b/receiver/httpcheckreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "httpcheck" MetricsStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/httpcheckreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/httpcheckreceiver") +} diff --git a/receiver/httpcheckreceiver/metadata.yaml b/receiver/httpcheckreceiver/metadata.yaml index d828bc5ce7f7..583e1d833e52 100644 --- a/receiver/httpcheckreceiver/metadata.yaml +++ b/receiver/httpcheckreceiver/metadata.yaml @@ -54,3 +54,6 @@ metrics: monotonic: false unit: "{error}" attributes: [http.url, error.message] + +tests: + config: diff --git a/receiver/iisreceiver/go.mod b/receiver/iisreceiver/go.mod index c0cd0bc7fcb1..637acf0b1da5 100644 --- a/receiver/iisreceiver/go.mod +++ b/receiver/iisreceiver/go.mod @@ -14,6 +14,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -73,8 +75,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.18.0 // indirect diff --git a/receiver/iisreceiver/internal/metadata/generated_status.go b/receiver/iisreceiver/internal/metadata/generated_status.go index 695b9dd0e71a..c3d3269a3932 100644 --- a/receiver/iisreceiver/internal/metadata/generated_status.go +++ b/receiver/iisreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "iis" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/iisreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/iisreceiver") +} diff --git a/receiver/influxdbreceiver/generated_component_test.go b/receiver/influxdbreceiver/generated_component_test.go new file mode 100644 index 000000000000..74328de5bdd0 --- /dev/null +++ b/receiver/influxdbreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package influxdbreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/influxdbreceiver/go.mod b/receiver/influxdbreceiver/go.mod index 8019e6d9a6d7..4daadfa297fe 100644 --- a/receiver/influxdbreceiver/go.mod +++ b/receiver/influxdbreceiver/go.mod @@ -12,9 +12,12 @@ require ( github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.91.0 go.opentelemetry.io/collector/config/confighttp v0.91.0 + go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -55,15 +58,12 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/config/configtls v0.91.0 // indirect go.opentelemetry.io/collector/config/internal v0.91.0 // indirect - go.opentelemetry.io/collector/confmap v0.91.0 // indirect go.opentelemetry.io/collector/extension v0.91.0 // indirect go.opentelemetry.io/collector/extension/auth v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/semconv v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/receiver/influxdbreceiver/internal/metadata/generated_status.go b/receiver/influxdbreceiver/internal/metadata/generated_status.go index 4e60cfc4242f..ab98f7407999 100644 --- a/receiver/influxdbreceiver/internal/metadata/generated_status.go +++ b/receiver/influxdbreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "influxdb" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/influxdbreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/influxdbreceiver") +} diff --git a/receiver/influxdbreceiver/metadata.yaml b/receiver/influxdbreceiver/metadata.yaml index 1778488433ff..1004879a5549 100644 --- a/receiver/influxdbreceiver/metadata.yaml +++ b/receiver/influxdbreceiver/metadata.yaml @@ -7,3 +7,5 @@ status: distributions: [contrib, observiq, sumo] codeowners: active: [jacobmarble] +tests: + config: diff --git a/receiver/jaegerreceiver/generated_component_test.go b/receiver/jaegerreceiver/generated_component_test.go new file mode 100644 index 000000000000..ea88b8b5e739 --- /dev/null +++ b/receiver/jaegerreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package jaegerreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "traces", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/jaegerreceiver/go.mod b/receiver/jaegerreceiver/go.mod index d921ddba801f..ad352a1a8091 100644 --- a/receiver/jaegerreceiver/go.mod +++ b/receiver/jaegerreceiver/go.mod @@ -20,6 +20,8 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 google.golang.org/grpc v1.60.0 @@ -63,8 +65,6 @@ require ( go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/oauth2 v0.14.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/receiver/jaegerreceiver/internal/metadata/generated_status.go b/receiver/jaegerreceiver/internal/metadata/generated_status.go index efc542c560a6..f41e9f271679 100644 --- a/receiver/jaegerreceiver/internal/metadata/generated_status.go +++ b/receiver/jaegerreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "jaeger" TracesStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/jaegerreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/jaegerreceiver") +} diff --git a/receiver/jaegerreceiver/metadata.yaml b/receiver/jaegerreceiver/metadata.yaml index 2667514c4002..cd49812a3952 100644 --- a/receiver/jaegerreceiver/metadata.yaml +++ b/receiver/jaegerreceiver/metadata.yaml @@ -16,3 +16,8 @@ status: - liatrio codeowners: active: [yurishkuro] + +tests: + config: + protocols: + grpc: diff --git a/receiver/jmxreceiver/go.mod b/receiver/jmxreceiver/go.mod index d345d0b9eaa7..e58beb21463f 100644 --- a/receiver/jmxreceiver/go.mod +++ b/receiver/jmxreceiver/go.mod @@ -17,6 +17,8 @@ require ( go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/receiver/otlpreceiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -93,8 +95,6 @@ require ( go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect golang.org/x/mod v0.14.0 // indirect diff --git a/receiver/jmxreceiver/internal/metadata/generated_status.go b/receiver/jmxreceiver/internal/metadata/generated_status.go index c65e91498686..5f33297d4bd4 100644 --- a/receiver/jmxreceiver/internal/metadata/generated_status.go +++ b/receiver/jmxreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "jmx" MetricsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/jmxreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/jmxreceiver") +} diff --git a/receiver/journaldreceiver/go.mod b/receiver/journaldreceiver/go.mod index 86b7669259fe..c871c38542de 100644 --- a/receiver/journaldreceiver/go.mod +++ b/receiver/journaldreceiver/go.mod @@ -10,6 +10,8 @@ require ( go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 ) require ( @@ -39,8 +41,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/pdata v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/net v0.18.0 // indirect diff --git a/receiver/journaldreceiver/internal/metadata/generated_status.go b/receiver/journaldreceiver/internal/metadata/generated_status.go index f7998abf9b44..8ae820cac5c0 100644 --- a/receiver/journaldreceiver/internal/metadata/generated_status.go +++ b/receiver/journaldreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "journald" LogsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/journaldreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/journaldreceiver") +} diff --git a/receiver/k8sclusterreceiver/e2e_test.go b/receiver/k8sclusterreceiver/e2e_test.go index 6a6ec8cbb6a2..d9216b494e23 100644 --- a/receiver/k8sclusterreceiver/e2e_test.go +++ b/receiver/k8sclusterreceiver/e2e_test.go @@ -39,6 +39,7 @@ const testKubeConfig = "/tmp/kube-config-otelcol-e2e-testing" // make docker-otelcontribcol // KUBECONFIG=/tmp/kube-config-otelcol-e2e-testing kind load docker-image otelcontribcol:latest func TestE2E(t *testing.T) { + var expected pmetric.Metrics expectedFile := filepath.Join("testdata", "e2e", "expected.yaml") expected, err := golden.ReadMetrics(expectedFile) @@ -48,6 +49,10 @@ func TestE2E(t *testing.T) { dynamicClient, err := dynamic.NewForConfig(kubeConfig) require.NoError(t, err) + metricsConsumer := new(consumertest.MetricsSink) + shutdownSink := startUpSink(t, metricsConsumer) + defer shutdownSink() + testID := uuid.NewString()[:8] collectorObjs := k8stest.CreateCollectorObjects(t, dynamicClient, testID) @@ -57,7 +62,6 @@ func TestE2E(t *testing.T) { } }() - metricsConsumer := new(consumertest.MetricsSink) wantEntries := 10 // Minimal number of metrics to wait for. waitForData(t, wantEntries, metricsConsumer) @@ -108,17 +112,19 @@ func TestE2E(t *testing.T) { ) } -func waitForData(t *testing.T, entriesNum int, mc *consumertest.MetricsSink) { +func startUpSink(t *testing.T, mc *consumertest.MetricsSink) func() { f := otlpreceiver.NewFactory() cfg := f.CreateDefaultConfig().(*otlpreceiver.Config) rcvr, err := f.CreateMetricsReceiver(context.Background(), receivertest.NewNopCreateSettings(), cfg, mc) require.NoError(t, rcvr.Start(context.Background(), componenttest.NewNopHost())) require.NoError(t, err, "failed creating metrics receiver") - defer func() { + return func() { assert.NoError(t, rcvr.Shutdown(context.Background())) - }() + } +} +func waitForData(t *testing.T, entriesNum int, mc *consumertest.MetricsSink) { timeoutMinutes := 3 require.Eventuallyf(t, func() bool { return len(mc.AllMetrics()) > entriesNum diff --git a/receiver/k8sclusterreceiver/go.mod b/receiver/k8sclusterreceiver/go.mod index 9e8aa9b6c55b..c8b4cfaa9080 100644 --- a/receiver/k8sclusterreceiver/go.mod +++ b/receiver/k8sclusterreceiver/go.mod @@ -24,6 +24,8 @@ require ( go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/receiver/otlpreceiver v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 k8s.io/api v0.28.4 k8s.io/apimachinery v0.28.4 @@ -105,10 +107,8 @@ require ( go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect go.opentelemetry.io/otel/exporters/prometheus v0.44.1-0.20231201153405-6027c1ae76f2 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/sdk v1.21.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect diff --git a/receiver/k8sclusterreceiver/internal/metadata/generated_status.go b/receiver/k8sclusterreceiver/internal/metadata/generated_status.go index 1eaeb822b837..784c87d59c29 100644 --- a/receiver/k8sclusterreceiver/internal/metadata/generated_status.go +++ b/receiver/k8sclusterreceiver/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -11,3 +13,11 @@ const ( MetricsStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/k8sclusterreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/k8sclusterreceiver") +} diff --git a/receiver/k8sclusterreceiver/testdata/e2e/collector/deployment.yaml b/receiver/k8sclusterreceiver/testdata/e2e/collector/deployment.yaml index f7f21c5d4856..841c472b04f4 100644 --- a/receiver/k8sclusterreceiver/testdata/e2e/collector/deployment.yaml +++ b/receiver/k8sclusterreceiver/testdata/e2e/collector/deployment.yaml @@ -37,10 +37,12 @@ spec: httpGet: path: / port: 13133 + initialDelaySeconds: 3 readinessProbe: httpGet: path: / port: 13133 + initialDelaySeconds: 3 resources: limits: cpu: 128m diff --git a/receiver/k8seventsreceiver/factory.go b/receiver/k8seventsreceiver/factory.go index d4bf18300779..5965f992bcf9 100644 --- a/receiver/k8seventsreceiver/factory.go +++ b/receiver/k8seventsreceiver/factory.go @@ -38,10 +38,5 @@ func createLogsReceiver( ) (receiver.Logs, error) { rCfg := cfg.(*Config) - k8sInterface, err := rCfg.getK8sClient() - if err != nil { - return nil, err - } - - return newReceiver(params, rCfg, consumer, k8sInterface) + return newReceiver(params, rCfg, consumer) } diff --git a/receiver/k8seventsreceiver/factory_test.go b/receiver/k8seventsreceiver/factory_test.go index 35cb96508de1..c79739ee58d9 100644 --- a/receiver/k8seventsreceiver/factory_test.go +++ b/receiver/k8seventsreceiver/factory_test.go @@ -10,6 +10,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/receiver/receivertest" k8s "k8s.io/client-go/kubernetes" @@ -42,8 +43,9 @@ func TestCreateReceiver(t *testing.T) { context.Background(), receivertest.NewNopCreateSettings(), rCfg, consumertest.NewNop(), ) + require.NoError(t, err) + err = r.Start(context.Background(), componenttest.NewNopHost()) assert.Error(t, err) - assert.Nil(t, r) // Override for test. rCfg.makeClient = func(apiConf k8sconfig.APIConfig) (k8s.Interface, error) { @@ -54,6 +56,7 @@ func TestCreateReceiver(t *testing.T) { receivertest.NewNopCreateSettings(), rCfg, consumertest.NewNop(), ) + require.NoError(t, err) + err = r.Start(context.Background(), componenttest.NewNopHost()) assert.NoError(t, err) - assert.NotNil(t, r) } diff --git a/receiver/k8seventsreceiver/generated_component_test.go b/receiver/k8seventsreceiver/generated_component_test.go new file mode 100644 index 000000000000..2a91346ba1e2 --- /dev/null +++ b/receiver/k8seventsreceiver/generated_component_test.go @@ -0,0 +1,89 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package k8seventsreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + // TODO support lifecycle + t.SkipNow() + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/k8seventsreceiver/go.mod b/receiver/k8seventsreceiver/go.mod index 9fdd76df4777..8555a87a3eff 100644 --- a/receiver/k8seventsreceiver/go.mod +++ b/receiver/k8seventsreceiver/go.mod @@ -11,6 +11,8 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 k8s.io/api v0.28.4 k8s.io/apimachinery v0.28.4 @@ -55,8 +57,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/oauth2 v0.14.0 // indirect diff --git a/receiver/k8seventsreceiver/internal/metadata/generated_status.go b/receiver/k8seventsreceiver/internal/metadata/generated_status.go index ac70184bc900..3c9e145082dc 100644 --- a/receiver/k8seventsreceiver/internal/metadata/generated_status.go +++ b/receiver/k8seventsreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "k8s_events" LogsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/k8seventsreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/k8seventsreceiver") +} diff --git a/receiver/k8seventsreceiver/metadata.yaml b/receiver/k8seventsreceiver/metadata.yaml index c8e1e10b1127..febae1aca702 100644 --- a/receiver/k8seventsreceiver/metadata.yaml +++ b/receiver/k8seventsreceiver/metadata.yaml @@ -7,3 +7,7 @@ status: distributions: [contrib, splunk, observiq, sumo] codeowners: active: [dmitryax, TylerHelmuth] + +tests: + config: + skip_lifecycle: true diff --git a/receiver/k8seventsreceiver/receiver.go b/receiver/k8seventsreceiver/receiver.go index acaf7d461c2b..dc0e6f2d6450 100644 --- a/receiver/k8seventsreceiver/receiver.go +++ b/receiver/k8seventsreceiver/receiver.go @@ -22,7 +22,6 @@ import ( type k8seventsReceiver struct { config *Config settings receiver.CreateSettings - client k8s.Interface logsConsumer consumer.Logs stopperChanList []chan struct{} startTime time.Time @@ -36,7 +35,6 @@ func newReceiver( set receiver.CreateSettings, config *Config, consumer consumer.Logs, - client k8s.Interface, ) (receiver.Logs, error) { transport := "http" @@ -52,7 +50,6 @@ func newReceiver( return &k8seventsReceiver{ settings: set, config: config, - client: client, logsConsumer: consumer, startTime: time.Now(), obsrecv: obsrecv, @@ -62,12 +59,17 @@ func newReceiver( func (kr *k8seventsReceiver) Start(ctx context.Context, _ component.Host) error { kr.ctx, kr.cancel = context.WithCancel(ctx) + k8sInterface, err := kr.config.getK8sClient() + if err != nil { + return err + } + kr.settings.Logger.Info("starting to watch namespaces for the events.") if len(kr.config.Namespaces) == 0 { - kr.startWatch(corev1.NamespaceAll) + kr.startWatch(corev1.NamespaceAll, k8sInterface) } else { for _, ns := range kr.config.Namespaces { - kr.startWatch(ns) + kr.startWatch(ns, k8sInterface) } } @@ -75,6 +77,9 @@ func (kr *k8seventsReceiver) Start(ctx context.Context, _ component.Host) error } func (kr *k8seventsReceiver) Shutdown(context.Context) error { + if kr.cancel == nil { + return nil + } // Stop watching all the namespaces by closing all the stopper channels. for _, stopperChan := range kr.stopperChanList { close(stopperChan) @@ -86,10 +91,10 @@ func (kr *k8seventsReceiver) Shutdown(context.Context) error { // Add the 'Event' handler and trigger the watch for a specific namespace. // For new and updated events, the code is relying on the following k8s code implementation: // https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/client-go/tools/record/events_cache.go#L327 -func (kr *k8seventsReceiver) startWatch(ns string) { +func (kr *k8seventsReceiver) startWatch(ns string, client k8s.Interface) { stopperChan := make(chan struct{}) kr.stopperChanList = append(kr.stopperChanList, stopperChan) - kr.startWatchingNamespace(kr.client, cache.ResourceEventHandlerFuncs{ + kr.startWatchingNamespace(client, cache.ResourceEventHandlerFuncs{ AddFunc: func(obj any) { ev := obj.(*corev1.Event) kr.handleEvent(ev) diff --git a/receiver/k8seventsreceiver/receiver_test.go b/receiver/k8seventsreceiver/receiver_test.go index 1f81b9082489..49cff154707f 100644 --- a/receiver/k8seventsreceiver/receiver_test.go +++ b/receiver/k8seventsreceiver/receiver_test.go @@ -16,17 +16,21 @@ import ( corev1 "k8s.io/api/core/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + k8s "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/fake" + + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8sconfig" ) func TestNewReceiver(t *testing.T) { rCfg := createDefaultConfig().(*Config) - client := fake.NewSimpleClientset() + rCfg.makeClient = func(apiConf k8sconfig.APIConfig) (k8s.Interface, error) { + return fake.NewSimpleClientset(), nil + } r, err := newReceiver( receivertest.NewNopCreateSettings(), rCfg, consumertest.NewNop(), - client, ) require.NoError(t, err) @@ -39,7 +43,6 @@ func TestNewReceiver(t *testing.T) { receivertest.NewNopCreateSettings(), rCfg, consumertest.NewNop(), - client, ) require.NoError(t, err) @@ -50,13 +53,11 @@ func TestNewReceiver(t *testing.T) { func TestHandleEvent(t *testing.T) { rCfg := createDefaultConfig().(*Config) - client := fake.NewSimpleClientset() sink := new(consumertest.LogsSink) r, err := newReceiver( receivertest.NewNopCreateSettings(), rCfg, sink, - client, ) require.NoError(t, err) require.NotNil(t, r) @@ -70,13 +71,11 @@ func TestHandleEvent(t *testing.T) { func TestDropEventsOlderThanStartupTime(t *testing.T) { rCfg := createDefaultConfig().(*Config) - client := fake.NewSimpleClientset() sink := new(consumertest.LogsSink) r, err := newReceiver( receivertest.NewNopCreateSettings(), rCfg, sink, - client, ) require.NoError(t, err) require.NotNil(t, r) @@ -108,12 +107,10 @@ func TestGetEventTimestamp(t *testing.T) { func TestAllowEvent(t *testing.T) { rCfg := createDefaultConfig().(*Config) - client := fake.NewSimpleClientset() r, err := newReceiver( receivertest.NewNopCreateSettings(), rCfg, consumertest.NewNop(), - client, ) require.NoError(t, err) require.NotNil(t, r) diff --git a/receiver/k8sobjectsreceiver/go.mod b/receiver/k8sobjectsreceiver/go.mod index 0e3492a2f1e3..68b7e96fe423 100644 --- a/receiver/k8sobjectsreceiver/go.mod +++ b/receiver/k8sobjectsreceiver/go.mod @@ -16,6 +16,8 @@ require ( go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/receiver/otlpreceiver v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 k8s.io/apimachinery v0.28.4 k8s.io/client-go v0.28.4 @@ -88,8 +90,6 @@ require ( go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect diff --git a/receiver/k8sobjectsreceiver/internal/metadata/generated_status.go b/receiver/k8sobjectsreceiver/internal/metadata/generated_status.go index 82fd3e358f34..33e5b5d2de8e 100644 --- a/receiver/k8sobjectsreceiver/internal/metadata/generated_status.go +++ b/receiver/k8sobjectsreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "k8sobjects" LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/k8sobjectsreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/k8sobjectsreceiver") +} diff --git a/receiver/k8sobjectsreceiver/testdata/e2e/expected/watch_events.yaml b/receiver/k8sobjectsreceiver/testdata/e2e/expected/watch_events.yaml index 1220124e949c..642bda8b3482 100644 --- a/receiver/k8sobjectsreceiver/testdata/e2e/expected/watch_events.yaml +++ b/receiver/k8sobjectsreceiver/testdata/e2e/expected/watch_events.yaml @@ -16,7 +16,7 @@ resourceLogs: values: - key: note value: - stringValue: test event + stringValue: test event of type warning - key: eventTime value: stringValue: "2023-01-01T00:00:00.000000Z" @@ -28,7 +28,7 @@ resourceLogs: stringValue: test - key: reason value: - stringValue: Test event of type warning + stringValue: TestEvent - key: regarding value: kvlistValue: diff --git a/receiver/k8sobjectsreceiver/testdata/e2e/expected/watch_events_core.yaml b/receiver/k8sobjectsreceiver/testdata/e2e/expected/watch_events_core.yaml index 755b3f5cf59f..a8d432c0d829 100644 --- a/receiver/k8sobjectsreceiver/testdata/e2e/expected/watch_events_core.yaml +++ b/receiver/k8sobjectsreceiver/testdata/e2e/expected/watch_events_core.yaml @@ -29,7 +29,7 @@ resourceLogs: stringValue: test - key: message value: - stringValue: test event + stringValue: test event of type warning - key: source value: kvlistValue: {} @@ -112,7 +112,7 @@ resourceLogs: stringValue: Warning - key: reason value: - stringValue: Test event of type warning + stringValue: TestEvent - key: kind value: stringValue: Event diff --git a/receiver/k8sobjectsreceiver/testdata/e2e/testobjects/event.yaml b/receiver/k8sobjectsreceiver/testdata/e2e/testobjects/event.yaml index 7f25edfdacd7..7bb741666186 100644 --- a/receiver/k8sobjectsreceiver/testdata/e2e/testobjects/event.yaml +++ b/receiver/k8sobjectsreceiver/testdata/e2e/testobjects/event.yaml @@ -5,8 +5,8 @@ kind: Event metadata: name: test-k8sobjects-receiver namespace: default -note: test event -reason: Test event of type warning +note: test event of type warning +reason: TestEvent reportingController: e2etest reportingInstance: k8sobjectsreceiver regarding: diff --git a/receiver/k8sobjectsreceiver/testdata/e2e/testobjects/event_core.yaml b/receiver/k8sobjectsreceiver/testdata/e2e/testobjects/event_core.yaml index ba286c7a8fe4..7a2c2f3138fa 100644 --- a/receiver/k8sobjectsreceiver/testdata/e2e/testobjects/event_core.yaml +++ b/receiver/k8sobjectsreceiver/testdata/e2e/testobjects/event_core.yaml @@ -5,8 +5,8 @@ kind: Event metadata: name: test-k8sobjects-receiver-events-core namespace: default -note: test event -reason: Test event of type warning +note: test event of type warning +reason: TestEvent reportingController: e2etest-events-core reportingInstance: k8sobjectsreceiver regarding: diff --git a/receiver/kafkametricsreceiver/generated_component_test.go b/receiver/kafkametricsreceiver/generated_component_test.go new file mode 100644 index 000000000000..cd9b4770733d --- /dev/null +++ b/receiver/kafkametricsreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package kafkametricsreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/kafkametricsreceiver/go.mod b/receiver/kafkametricsreceiver/go.mod index b15626c135ce..487b601be1e2 100644 --- a/receiver/kafkametricsreceiver/go.mod +++ b/receiver/kafkametricsreceiver/go.mod @@ -17,6 +17,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -26,7 +28,7 @@ require ( github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/Microsoft/hcsshim v0.11.1 // indirect - github.com/aws/aws-sdk-go v1.49.1 // indirect + github.com/aws/aws-sdk-go v1.49.5 // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/containerd/containerd v1.7.7 // indirect @@ -97,9 +99,7 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect - golang.org/x/crypto v0.15.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.18.0 // indirect diff --git a/receiver/kafkametricsreceiver/go.sum b/receiver/kafkametricsreceiver/go.sum index 167c7280b2b1..2f1c9b81ddb3 100644 --- a/receiver/kafkametricsreceiver/go.sum +++ b/receiver/kafkametricsreceiver/go.sum @@ -12,8 +12,8 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/Microsoft/hcsshim v0.11.1 h1:hJ3s7GbWlGK4YVV92sO88BQSyF4ZLVy7/awqOlPxFbA= github.com/Microsoft/hcsshim v0.11.1/go.mod h1:nFJmaO4Zr5Y7eADdFOpYswDDlNVbvcIJJNJLECr5JQg= -github.com/aws/aws-sdk-go v1.49.1 h1:Dsamcd8d/nNb3A+bZ0ucfGl0vGZsW5wlRW0vhoYGoeQ= -github.com/aws/aws-sdk-go v1.49.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.5 h1:y2yfBlwjPDi3/sBVKeznYEdDy6wIhjA2L5NCBMLUIYA= +github.com/aws/aws-sdk-go v1.49.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= @@ -291,8 +291,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= -golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 h1:FqrVOBQxQ8r/UwwXibI0KMolVhvFiGobSfdE33deHJM= golang.org/x/exp v0.0.0-20230711023510-fffb14384f22/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= diff --git a/receiver/kafkametricsreceiver/internal/metadata/generated_status.go b/receiver/kafkametricsreceiver/internal/metadata/generated_status.go index 1d4598439f8f..3cfff1ef398c 100644 --- a/receiver/kafkametricsreceiver/internal/metadata/generated_status.go +++ b/receiver/kafkametricsreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "kafkametrics" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/kafkametricsreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/kafkametricsreceiver") +} diff --git a/receiver/kafkametricsreceiver/metadata.yaml b/receiver/kafkametricsreceiver/metadata.yaml index 042d592db6c8..4e685ab7010e 100644 --- a/receiver/kafkametricsreceiver/metadata.yaml +++ b/receiver/kafkametricsreceiver/metadata.yaml @@ -108,4 +108,7 @@ metrics: unit: 1 gauge: value_type: int - attributes: [group, topic] \ No newline at end of file + attributes: [group, topic] + +tests: + config: diff --git a/receiver/kafkareceiver/factory_test.go b/receiver/kafkareceiver/factory_test.go index 25d999886b90..45386eca9657 100644 --- a/receiver/kafkareceiver/factory_test.go +++ b/receiver/kafkareceiver/factory_test.go @@ -35,9 +35,9 @@ func TestCreateTracesReceiver(t *testing.T) { cfg.ProtocolVersion = "2.0.0" f := kafkaReceiverFactory{tracesUnmarshalers: defaultTracesUnmarshalers()} r, err := f.createTracesReceiver(context.Background(), receivertest.NewNopCreateSettings(), cfg, nil) + require.NoError(t, err) // no available broker - require.Error(t, err) - assert.Nil(t, r) + require.Error(t, r.Start(context.Background(), componenttest.NewNopHost())) } func TestCreateTracesReceiver_error(t *testing.T) { @@ -79,9 +79,9 @@ func TestCreateMetricsReceiver(t *testing.T) { cfg.ProtocolVersion = "2.0.0" f := kafkaReceiverFactory{metricsUnmarshalers: defaultMetricsUnmarshalers()} r, err := f.createMetricsReceiver(context.Background(), receivertest.NewNopCreateSettings(), cfg, nil) + require.NoError(t, err) // no available broker - require.Error(t, err) - assert.Nil(t, r) + require.Error(t, r.Start(context.Background(), componenttest.NewNopHost())) } func TestCreateMetricsReceiver_error(t *testing.T) { @@ -123,9 +123,9 @@ func TestCreateLogsReceiver(t *testing.T) { cfg.ProtocolVersion = "2.0.0" f := kafkaReceiverFactory{logsUnmarshalers: defaultLogsUnmarshalers("Test Version", zap.NewNop())} r, err := f.createLogsReceiver(context.Background(), receivertest.NewNopCreateSettings(), cfg, nil) + require.NoError(t, err) // no available broker - require.Error(t, err) - assert.Nil(t, r) + require.Error(t, r.Start(context.Background(), componenttest.NewNopHost())) } func TestCreateLogsReceiver_error(t *testing.T) { diff --git a/receiver/kafkareceiver/generated_component_test.go b/receiver/kafkareceiver/generated_component_test.go new file mode 100644 index 000000000000..c7cce24e803f --- /dev/null +++ b/receiver/kafkareceiver/generated_component_test.go @@ -0,0 +1,103 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package kafkareceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "traces", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + // TODO support lifecycle + t.SkipNow() + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/kafkareceiver/go.mod b/receiver/kafkareceiver/go.mod index 3fc2322ec965..9cbc33199afc 100644 --- a/receiver/kafkareceiver/go.mod +++ b/receiver/kafkareceiver/go.mod @@ -24,11 +24,13 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) require ( - github.com/aws/aws-sdk-go v1.49.1 // indirect + github.com/aws/aws-sdk-go v1.49.5 // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/eapache/go-resiliency v1.4.0 // indirect @@ -71,11 +73,9 @@ require ( go.opentelemetry.io/collector/extension v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.16.0 // indirect - golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect + golang.org/x/crypto v0.17.0 // indirect + golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/receiver/kafkareceiver/go.sum b/receiver/kafkareceiver/go.sum index d10e5a654880..fd8d30099482 100644 --- a/receiver/kafkareceiver/go.sum +++ b/receiver/kafkareceiver/go.sum @@ -5,8 +5,8 @@ github.com/IBM/sarama v1.42.1 h1:wugyWa15TDEHh2kvq2gAy1IHLjEjuYOYgXz/ruC/OSQ= github.com/IBM/sarama v1.42.1/go.mod h1:Xxho9HkHd4K/MDUo/T/sOqwtX/17D33++E9Wib6hUdQ= github.com/apache/thrift v0.19.0 h1:sOqkWPzMj7w6XaYbJQG7m4sGqVolaW/0D28Ln7yPzMk= github.com/apache/thrift v0.19.0/go.mod h1:SUALL216IiaOw2Oy+5Vs9lboJ/t9g40C+G07Dc0QC1I= -github.com/aws/aws-sdk-go v1.49.1 h1:Dsamcd8d/nNb3A+bZ0ucfGl0vGZsW5wlRW0vhoYGoeQ= -github.com/aws/aws-sdk-go v1.49.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.49.5 h1:y2yfBlwjPDi3/sBVKeznYEdDy6wIhjA2L5NCBMLUIYA= +github.com/aws/aws-sdk-go v1.49.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= @@ -206,11 +206,11 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4= +golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= diff --git a/receiver/kafkareceiver/internal/metadata/generated_status.go b/receiver/kafkareceiver/internal/metadata/generated_status.go index 9e14972f8709..b8f06cb67437 100644 --- a/receiver/kafkareceiver/internal/metadata/generated_status.go +++ b/receiver/kafkareceiver/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( LogsStability = component.StabilityLevelBeta TracesStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/kafkareceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/kafkareceiver") +} diff --git a/receiver/kafkareceiver/kafka_receiver.go b/receiver/kafkareceiver/kafka_receiver.go index 8ae63f8c9e26..0e40c6ad6f08 100644 --- a/receiver/kafkareceiver/kafka_receiver.go +++ b/receiver/kafkareceiver/kafka_receiver.go @@ -28,6 +28,7 @@ var errInvalidInitialOffset = fmt.Errorf("invalid initial offset") // kafkaTracesConsumer uses sarama to consume and handle messages from kafka. type kafkaTracesConsumer struct { + config Config consumerGroup sarama.ConsumerGroup nextConsumer consumer.Traces topics []string @@ -44,6 +45,7 @@ type kafkaTracesConsumer struct { // kafkaMetricsConsumer uses sarama to consume and handle messages from kafka. type kafkaMetricsConsumer struct { + config Config consumerGroup sarama.ConsumerGroup nextConsumer consumer.Metrics topics []string @@ -60,6 +62,7 @@ type kafkaMetricsConsumer struct { // kafkaLogsConsumer uses sarama to consume and handle messages from kafka. type kafkaLogsConsumer struct { + config Config consumerGroup sarama.ConsumerGroup nextConsumer consumer.Logs topics []string @@ -83,37 +86,8 @@ func newTracesReceiver(config Config, set receiver.CreateSettings, unmarshaler T return nil, errUnrecognizedEncoding } - c := sarama.NewConfig() - c.ClientID = config.ClientID - c.Metadata.Full = config.Metadata.Full - c.Metadata.Retry.Max = config.Metadata.Retry.Max - c.Metadata.Retry.Backoff = config.Metadata.Retry.Backoff - c.Consumer.Offsets.AutoCommit.Enable = config.AutoCommit.Enable - c.Consumer.Offsets.AutoCommit.Interval = config.AutoCommit.Interval - if initialOffset, err := toSaramaInitialOffset(config.InitialOffset); err == nil { - c.Consumer.Offsets.Initial = initialOffset - } else { - return nil, err - } - if config.ResolveCanonicalBootstrapServersOnly { - c.Net.ResolveCanonicalBootstrapServers = true - } - if config.ProtocolVersion != "" { - version, err := sarama.ParseKafkaVersion(config.ProtocolVersion) - if err != nil { - return nil, err - } - c.Version = version - } - if err := kafka.ConfigureAuthentication(config.Authentication, c); err != nil { - return nil, err - } - client, err := sarama.NewConsumerGroup(config.Brokers, config.GroupID, c) - if err != nil { - return nil, err - } return &kafkaTracesConsumer{ - consumerGroup: client, + config: config, topics: []string{config.Topic}, nextConsumer: nextConsumer, unmarshaler: unmarshaler, @@ -125,6 +99,32 @@ func newTracesReceiver(config Config, set receiver.CreateSettings, unmarshaler T }, nil } +func createKafkaClient(config Config) (sarama.ConsumerGroup, error) { + saramaConfig := sarama.NewConfig() + saramaConfig.ClientID = config.ClientID + saramaConfig.Metadata.Full = config.Metadata.Full + saramaConfig.Metadata.Retry.Max = config.Metadata.Retry.Max + saramaConfig.Metadata.Retry.Backoff = config.Metadata.Retry.Backoff + saramaConfig.Consumer.Offsets.AutoCommit.Enable = config.AutoCommit.Enable + saramaConfig.Consumer.Offsets.AutoCommit.Interval = config.AutoCommit.Interval + var err error + if saramaConfig.Consumer.Offsets.Initial, err = toSaramaInitialOffset(config.InitialOffset); err != nil { + return nil, err + } + if config.ResolveCanonicalBootstrapServersOnly { + saramaConfig.Net.ResolveCanonicalBootstrapServers = true + } + if config.ProtocolVersion != "" { + if saramaConfig.Version, err = sarama.ParseKafkaVersion(config.ProtocolVersion); err != nil { + return nil, err + } + } + if err := kafka.ConfigureAuthentication(config.Authentication, saramaConfig); err != nil { + return nil, err + } + return sarama.NewConsumerGroup(config.Brokers, config.GroupID, saramaConfig) +} + func (c *kafkaTracesConsumer) Start(_ context.Context, host component.Host) error { ctx, cancel := context.WithCancel(context.Background()) c.cancelConsumeLoop = cancel @@ -136,6 +136,12 @@ func (c *kafkaTracesConsumer) Start(_ context.Context, host component.Host) erro if err != nil { return err } + // consumerGroup may be set in tests to inject fake implementation. + if c.consumerGroup == nil { + if c.consumerGroup, err = createKafkaClient(c.config); err != nil { + return err + } + } consumerGroup := &tracesConsumerGroupHandler{ logger: c.settings.Logger, unmarshaler: c.unmarshaler, @@ -178,6 +184,9 @@ func (c *kafkaTracesConsumer) consumeLoop(ctx context.Context, handler sarama.Co } func (c *kafkaTracesConsumer) Shutdown(context.Context) error { + if c.cancelConsumeLoop == nil { + return nil + } c.cancelConsumeLoop() return c.consumerGroup.Close() } @@ -187,34 +196,8 @@ func newMetricsReceiver(config Config, set receiver.CreateSettings, unmarshaler return nil, errUnrecognizedEncoding } - c := sarama.NewConfig() - c.ClientID = config.ClientID - c.Metadata.Full = config.Metadata.Full - c.Metadata.Retry.Max = config.Metadata.Retry.Max - c.Metadata.Retry.Backoff = config.Metadata.Retry.Backoff - c.Consumer.Offsets.AutoCommit.Enable = config.AutoCommit.Enable - c.Consumer.Offsets.AutoCommit.Interval = config.AutoCommit.Interval - if initialOffset, err := toSaramaInitialOffset(config.InitialOffset); err == nil { - c.Consumer.Offsets.Initial = initialOffset - } else { - return nil, err - } - if config.ProtocolVersion != "" { - version, err := sarama.ParseKafkaVersion(config.ProtocolVersion) - if err != nil { - return nil, err - } - c.Version = version - } - if err := kafka.ConfigureAuthentication(config.Authentication, c); err != nil { - return nil, err - } - client, err := sarama.NewConsumerGroup(config.Brokers, config.GroupID, c) - if err != nil { - return nil, err - } return &kafkaMetricsConsumer{ - consumerGroup: client, + config: config, topics: []string{config.Topic}, nextConsumer: nextConsumer, unmarshaler: unmarshaler, @@ -237,6 +220,12 @@ func (c *kafkaMetricsConsumer) Start(_ context.Context, host component.Host) err if err != nil { return err } + // consumerGroup may be set in tests to inject fake implementation. + if c.consumerGroup == nil { + if c.consumerGroup, err = createKafkaClient(c.config); err != nil { + return err + } + } metricsConsumerGroup := &metricsConsumerGroupHandler{ logger: c.settings.Logger, unmarshaler: c.unmarshaler, @@ -279,6 +268,9 @@ func (c *kafkaMetricsConsumer) consumeLoop(ctx context.Context, handler sarama.C } func (c *kafkaMetricsConsumer) Shutdown(context.Context) error { + if c.cancelConsumeLoop == nil { + return nil + } c.cancelConsumeLoop() return c.consumerGroup.Close() } @@ -287,35 +279,9 @@ func newLogsReceiver(config Config, set receiver.CreateSettings, unmarshaler Log if unmarshaler == nil { return nil, errUnrecognizedEncoding } - c := sarama.NewConfig() - c.ClientID = config.ClientID - c.Metadata.Full = config.Metadata.Full - c.Metadata.Retry.Max = config.Metadata.Retry.Max - c.Metadata.Retry.Backoff = config.Metadata.Retry.Backoff - c.Consumer.Offsets.AutoCommit.Enable = config.AutoCommit.Enable - c.Consumer.Offsets.AutoCommit.Interval = config.AutoCommit.Interval - if initialOffset, err := toSaramaInitialOffset(config.InitialOffset); err == nil { - c.Consumer.Offsets.Initial = initialOffset - } else { - return nil, err - } - if config.ProtocolVersion != "" { - var version sarama.KafkaVersion - version, err := sarama.ParseKafkaVersion(config.ProtocolVersion) - if err != nil { - return nil, err - } - c.Version = version - } - if err := kafka.ConfigureAuthentication(config.Authentication, c); err != nil { - return nil, err - } - client, err := sarama.NewConsumerGroup(config.Brokers, config.GroupID, c) - if err != nil { - return nil, err - } + return &kafkaLogsConsumer{ - consumerGroup: client, + config: config, topics: []string{config.Topic}, nextConsumer: nextConsumer, unmarshaler: unmarshaler, @@ -338,7 +304,12 @@ func (c *kafkaLogsConsumer) Start(_ context.Context, host component.Host) error if err != nil { return err } - + // consumerGroup may be set in tests to inject fake implementation. + if c.consumerGroup == nil { + if c.consumerGroup, err = createKafkaClient(c.config); err != nil { + return err + } + } logsConsumerGroup := &logsConsumerGroupHandler{ logger: c.settings.Logger, unmarshaler: c.unmarshaler, @@ -381,6 +352,9 @@ func (c *kafkaLogsConsumer) consumeLoop(ctx context.Context, handler sarama.Cons } func (c *kafkaLogsConsumer) Shutdown(context.Context) error { + if c.cancelConsumeLoop == nil { + return nil + } c.cancelConsumeLoop() return c.consumerGroup.Close() } diff --git a/receiver/kafkareceiver/kafka_receiver_test.go b/receiver/kafkareceiver/kafka_receiver_test.go index be46036d4ff7..ca4b5f544dc1 100644 --- a/receiver/kafkareceiver/kafka_receiver_test.go +++ b/receiver/kafkareceiver/kafka_receiver_test.go @@ -39,8 +39,9 @@ func TestNewTracesReceiver_version_err(t *testing.T) { } unmarshaler := defaultTracesUnmarshalers()[c.Encoding] r, err := newTracesReceiver(c, receivertest.NewNopCreateSettings(), unmarshaler, consumertest.NewNop()) + require.NoError(t, err) + err = r.Start(context.Background(), componenttest.NewNopHost()) assert.Error(t, err) - assert.Nil(t, r) } func TestNewTracesReceiver_encoding_err(t *testing.T) { @@ -71,9 +72,9 @@ func TestNewTracesReceiver_err_auth_type(t *testing.T) { } unmarshaler := defaultTracesUnmarshalers()[c.Encoding] r, err := newTracesReceiver(c, receivertest.NewNopCreateSettings(), unmarshaler, consumertest.NewNop()) - assert.Error(t, err) + require.NoError(t, err) + err = r.Start(context.Background(), componenttest.NewNopHost()) assert.Contains(t, err.Error(), "failed to load TLS config") - assert.Nil(t, r) } func TestNewTracesReceiver_initial_offset_err(t *testing.T) { @@ -83,8 +84,9 @@ func TestNewTracesReceiver_initial_offset_err(t *testing.T) { } unmarshaler := defaultTracesUnmarshalers()[c.Encoding] r, err := newTracesReceiver(c, receivertest.NewNopCreateSettings(), unmarshaler, consumertest.NewNop()) + require.NoError(t, err) + err = r.Start(context.Background(), componenttest.NewNopHost()) require.Error(t, err) - assert.Nil(t, r) assert.EqualError(t, err, errInvalidInitialOffset.Error()) } @@ -304,8 +306,9 @@ func TestNewMetricsReceiver_version_err(t *testing.T) { } unmarshaler := defaultMetricsUnmarshalers()[c.Encoding] r, err := newMetricsReceiver(c, receivertest.NewNopCreateSettings(), unmarshaler, consumertest.NewNop()) + require.NoError(t, err) + err = r.Start(context.Background(), componenttest.NewNopHost()) assert.Error(t, err) - assert.Nil(t, r) } func TestNewMetricsReceiver_encoding_err(t *testing.T) { @@ -313,9 +316,8 @@ func TestNewMetricsReceiver_encoding_err(t *testing.T) { Encoding: "foo", } unmarshaler := defaultMetricsUnmarshalers()[c.Encoding] - r, err := newMetricsReceiver(c, receivertest.NewNopCreateSettings(), unmarshaler, consumertest.NewNop()) + _, err := newMetricsReceiver(c, receivertest.NewNopCreateSettings(), unmarshaler, consumertest.NewNop()) require.Error(t, err) - assert.Nil(t, r) assert.EqualError(t, err, errUnrecognizedEncoding.Error()) } @@ -336,9 +338,10 @@ func TestNewMetricsExporter_err_auth_type(t *testing.T) { } unmarshaler := defaultMetricsUnmarshalers()[c.Encoding] r, err := newMetricsReceiver(c, receivertest.NewNopCreateSettings(), unmarshaler, consumertest.NewNop()) + require.NoError(t, err) + err = r.Start(context.Background(), componenttest.NewNopHost()) assert.Error(t, err) assert.Contains(t, err.Error(), "failed to load TLS config") - assert.Nil(t, r) } func TestNewMetricsReceiver_initial_offset_err(t *testing.T) { @@ -348,22 +351,12 @@ func TestNewMetricsReceiver_initial_offset_err(t *testing.T) { } unmarshaler := defaultMetricsUnmarshalers()[c.Encoding] r, err := newMetricsReceiver(c, receivertest.NewNopCreateSettings(), unmarshaler, consumertest.NewNop()) + require.NoError(t, err) + err = r.Start(context.Background(), componenttest.NewNopHost()) require.Error(t, err) - assert.Nil(t, r) assert.EqualError(t, err, errInvalidInitialOffset.Error()) } -func TestMetricsReceiverStart(t *testing.T) { - c := kafkaMetricsConsumer{ - nextConsumer: consumertest.NewNop(), - settings: receivertest.NewNopCreateSettings(), - consumerGroup: &testConsumerGroup{}, - } - - require.NoError(t, c.Start(context.Background(), componenttest.NewNopHost())) - require.NoError(t, c.Shutdown(context.Background())) -} - func TestMetricsReceiverStartConsume(t *testing.T) { c := kafkaMetricsConsumer{ nextConsumer: consumertest.NewNop(), @@ -567,8 +560,9 @@ func TestNewLogsReceiver_version_err(t *testing.T) { } unmarshaler := defaultLogsUnmarshalers("Test Version", zap.NewNop())[c.Encoding] r, err := newLogsReceiver(c, receivertest.NewNopCreateSettings(), unmarshaler, consumertest.NewNop()) + require.NoError(t, err) + err = r.Start(context.Background(), componenttest.NewNopHost()) assert.Error(t, err) - assert.Nil(t, r) } func TestNewLogsReceiver_encoding_err(t *testing.T) { @@ -599,9 +593,10 @@ func TestNewLogsExporter_err_auth_type(t *testing.T) { } unmarshaler := defaultLogsUnmarshalers("Test Version", zap.NewNop())[c.Encoding] r, err := newLogsReceiver(c, receivertest.NewNopCreateSettings(), unmarshaler, consumertest.NewNop()) + require.NoError(t, err) + err = r.Start(context.Background(), componenttest.NewNopHost()) assert.Error(t, err) assert.Contains(t, err.Error(), "failed to load TLS config") - assert.Nil(t, r) } func TestNewLogsReceiver_initial_offset_err(t *testing.T) { @@ -611,8 +606,9 @@ func TestNewLogsReceiver_initial_offset_err(t *testing.T) { } unmarshaler := defaultLogsUnmarshalers("Test Version", zap.NewNop())[c.Encoding] r, err := newLogsReceiver(c, receivertest.NewNopCreateSettings(), unmarshaler, consumertest.NewNop()) + require.NoError(t, err) + err = r.Start(context.Background(), componenttest.NewNopHost()) require.Error(t, err) - assert.Nil(t, r) assert.EqualError(t, err, errInvalidInitialOffset.Error()) } @@ -653,6 +649,7 @@ func TestLogsReceiver_error(t *testing.T) { nextConsumer: consumertest.NewNop(), settings: settings, consumerGroup: &testConsumerGroup{err: expectedErr}, + config: *createDefaultConfig().(*Config), } require.NoError(t, c.Start(context.Background(), componenttest.NewNopHost())) diff --git a/receiver/kafkareceiver/metadata.yaml b/receiver/kafkareceiver/metadata.yaml index 58c399f2171a..f8886ef0b32f 100644 --- a/receiver/kafkareceiver/metadata.yaml +++ b/receiver/kafkareceiver/metadata.yaml @@ -13,3 +13,7 @@ status: - sumo codeowners: active: [pavolloffay, MovieStoreGuy] + +tests: + config: + skip_lifecycle: true diff --git a/receiver/kubeletstatsreceiver/e2e_test.go b/receiver/kubeletstatsreceiver/e2e_test.go index e9a8bc35efe3..1cb44b0fa3f1 100644 --- a/receiver/kubeletstatsreceiver/e2e_test.go +++ b/receiver/kubeletstatsreceiver/e2e_test.go @@ -31,6 +31,7 @@ import ( const testKubeConfig = "/tmp/kube-config-otelcol-e2e-testing" func TestE2E(t *testing.T) { + var expected pmetric.Metrics expectedFile := filepath.Join("testdata", "e2e", "expected.yaml") expected, err := golden.ReadMetrics(expectedFile) @@ -40,6 +41,10 @@ func TestE2E(t *testing.T) { dynamicClient, err := dynamic.NewForConfig(kubeConfig) require.NoError(t, err) + metricsConsumer := new(consumertest.MetricsSink) + shutdownSink := startUpSink(t, metricsConsumer) + defer shutdownSink() + testID := uuid.NewString()[:8] collectorObjs := k8stest.CreateCollectorObjects(t, dynamicClient, testID) @@ -49,7 +54,6 @@ func TestE2E(t *testing.T) { } }() - metricsConsumer := new(consumertest.MetricsSink) wantEntries := 10 // Minimal number of metrics to wait for. waitForData(t, wantEntries, metricsConsumer) @@ -66,17 +70,19 @@ func TestE2E(t *testing.T) { ) } -func waitForData(t *testing.T, entriesNum int, mc *consumertest.MetricsSink) { +func startUpSink(t *testing.T, mc *consumertest.MetricsSink) func() { f := otlpreceiver.NewFactory() cfg := f.CreateDefaultConfig().(*otlpreceiver.Config) rcvr, err := f.CreateMetricsReceiver(context.Background(), receivertest.NewNopCreateSettings(), cfg, mc) require.NoError(t, rcvr.Start(context.Background(), componenttest.NewNopHost())) require.NoError(t, err, "failed creating metrics receiver") - defer func() { + return func() { assert.NoError(t, rcvr.Shutdown(context.Background())) - }() + } +} +func waitForData(t *testing.T, entriesNum int, mc *consumertest.MetricsSink) { timeoutMinutes := 3 require.Eventuallyf(t, func() bool { return len(mc.AllMetrics()) > entriesNum diff --git a/receiver/kubeletstatsreceiver/go.mod b/receiver/kubeletstatsreceiver/go.mod index 575fe02dfc41..5e08fe4eb304 100644 --- a/receiver/kubeletstatsreceiver/go.mod +++ b/receiver/kubeletstatsreceiver/go.mod @@ -20,6 +20,8 @@ require ( go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/receiver/otlpreceiver v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 k8s.io/api v0.28.4 k8s.io/apimachinery v0.28.4 @@ -92,8 +94,6 @@ require ( go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect diff --git a/receiver/kubeletstatsreceiver/internal/metadata/generated_status.go b/receiver/kubeletstatsreceiver/internal/metadata/generated_status.go index 464c8e8a8707..69c4917f6879 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/generated_status.go +++ b/receiver/kubeletstatsreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "kubeletstats" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/kubeletstatsreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/kubeletstatsreceiver") +} diff --git a/receiver/lokireceiver/go.mod b/receiver/lokireceiver/go.mod index e452fd81cda9..804a19921934 100644 --- a/receiver/lokireceiver/go.mod +++ b/receiver/lokireceiver/go.mod @@ -29,6 +29,8 @@ require ( go.opentelemetry.io/collector/config/confighttp v0.91.0 go.opentelemetry.io/collector/config/confignet v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 ) require ( @@ -79,8 +81,6 @@ require ( go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect diff --git a/receiver/lokireceiver/internal/metadata/generated_status.go b/receiver/lokireceiver/internal/metadata/generated_status.go index 9f065a21a9f3..81830681b00b 100644 --- a/receiver/lokireceiver/internal/metadata/generated_status.go +++ b/receiver/lokireceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "loki" LogsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/lokireceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/lokireceiver") +} diff --git a/receiver/memcachedreceiver/go.mod b/receiver/memcachedreceiver/go.mod index 7fcea454c145..5c511994eac4 100644 --- a/receiver/memcachedreceiver/go.mod +++ b/receiver/memcachedreceiver/go.mod @@ -16,6 +16,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -73,8 +75,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect golang.org/x/mod v0.14.0 // indirect diff --git a/receiver/memcachedreceiver/internal/metadata/generated_status.go b/receiver/memcachedreceiver/internal/metadata/generated_status.go index 2cccd525b394..7d22c62ad2af 100644 --- a/receiver/memcachedreceiver/internal/metadata/generated_status.go +++ b/receiver/memcachedreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "memcached" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/memcachedreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/memcachedreceiver") +} diff --git a/receiver/mongodbatlasreceiver/go.mod b/receiver/mongodbatlasreceiver/go.mod index 6320f9b3dde4..fa2c9a106de9 100644 --- a/receiver/mongodbatlasreceiver/go.mod +++ b/receiver/mongodbatlasreceiver/go.mod @@ -21,6 +21,8 @@ require ( go.opentelemetry.io/collector/extension v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -54,8 +56,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/receiver/mongodbatlasreceiver/internal/metadata/generated_status.go b/receiver/mongodbatlasreceiver/internal/metadata/generated_status.go index 081c2a41b5f9..69faf0e507d9 100644 --- a/receiver/mongodbatlasreceiver/internal/metadata/generated_status.go +++ b/receiver/mongodbatlasreceiver/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -11,3 +13,11 @@ const ( MetricsStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/mongodbatlasreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/mongodbatlasreceiver") +} diff --git a/receiver/mongodbreceiver/go.mod b/receiver/mongodbreceiver/go.mod index adc3509ddbc3..e8815c54ef87 100644 --- a/receiver/mongodbreceiver/go.mod +++ b/receiver/mongodbreceiver/go.mod @@ -20,6 +20,8 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -84,9 +86,7 @@ require ( go.opentelemetry.io/collector v0.91.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect - golang.org/x/crypto v0.15.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.18.0 // indirect diff --git a/receiver/mongodbreceiver/go.sum b/receiver/mongodbreceiver/go.sum index a5c79a24d550..6e91427968d3 100644 --- a/receiver/mongodbreceiver/go.sum +++ b/receiver/mongodbreceiver/go.sum @@ -258,8 +258,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= -golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 h1:FqrVOBQxQ8r/UwwXibI0KMolVhvFiGobSfdE33deHJM= golang.org/x/exp v0.0.0-20230711023510-fffb14384f22/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= diff --git a/receiver/mongodbreceiver/internal/metadata/generated_status.go b/receiver/mongodbreceiver/internal/metadata/generated_status.go index 890e4a845bc1..a883d449e5d0 100644 --- a/receiver/mongodbreceiver/internal/metadata/generated_status.go +++ b/receiver/mongodbreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "mongodb" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/mongodbreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/mongodbreceiver") +} diff --git a/receiver/mysqlreceiver/generated_component_test.go b/receiver/mysqlreceiver/generated_component_test.go new file mode 100644 index 000000000000..dc37f098a025 --- /dev/null +++ b/receiver/mysqlreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package mysqlreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/mysqlreceiver/go.mod b/receiver/mysqlreceiver/go.mod index 52bc455cb18d..6dc67c884258 100644 --- a/receiver/mysqlreceiver/go.mod +++ b/receiver/mysqlreceiver/go.mod @@ -18,6 +18,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -76,8 +78,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect golang.org/x/mod v0.14.0 // indirect diff --git a/receiver/mysqlreceiver/internal/metadata/generated_status.go b/receiver/mysqlreceiver/internal/metadata/generated_status.go index d9e2251a07eb..d1919504daf2 100644 --- a/receiver/mysqlreceiver/internal/metadata/generated_status.go +++ b/receiver/mysqlreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "mysql" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/mysqlreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/mysqlreceiver") +} diff --git a/receiver/mysqlreceiver/metadata.yaml b/receiver/mysqlreceiver/metadata.yaml index a82e65fa7bfc..34349e7f69ac 100644 --- a/receiver/mysqlreceiver/metadata.yaml +++ b/receiver/mysqlreceiver/metadata.yaml @@ -579,3 +579,6 @@ metrics: input_type: string monotonic: true aggregation_temporality: cumulative + +tests: + config: \ No newline at end of file diff --git a/receiver/namedpipereceiver/go.mod b/receiver/namedpipereceiver/go.mod index ebaa2b5e554a..94cb56b7f316 100644 --- a/receiver/namedpipereceiver/go.mod +++ b/receiver/namedpipereceiver/go.mod @@ -10,6 +10,8 @@ require ( go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -41,8 +43,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/pdata v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/receiver/namedpipereceiver/internal/metadata/generated_status.go b/receiver/namedpipereceiver/internal/metadata/generated_status.go index f8078b18c82e..3d006f004aa5 100644 --- a/receiver/namedpipereceiver/internal/metadata/generated_status.go +++ b/receiver/namedpipereceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "namedpipe" LogsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/namedpipereceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/namedpipereceiver") +} diff --git a/receiver/nginxreceiver/generated_component_test.go b/receiver/nginxreceiver/generated_component_test.go new file mode 100644 index 000000000000..7f5eccedd573 --- /dev/null +++ b/receiver/nginxreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package nginxreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/nginxreceiver/go.mod b/receiver/nginxreceiver/go.mod index d40ae2d1a250..5d9faa0b6b54 100644 --- a/receiver/nginxreceiver/go.mod +++ b/receiver/nginxreceiver/go.mod @@ -17,6 +17,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -87,8 +89,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect golang.org/x/mod v0.14.0 // indirect diff --git a/receiver/nginxreceiver/internal/metadata/generated_status.go b/receiver/nginxreceiver/internal/metadata/generated_status.go index 935ed605e106..01df7602840e 100644 --- a/receiver/nginxreceiver/internal/metadata/generated_status.go +++ b/receiver/nginxreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "nginx" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/nginxreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/nginxreceiver") +} diff --git a/receiver/nginxreceiver/metadata.yaml b/receiver/nginxreceiver/metadata.yaml index c5cd9aa4987f..4303ff3b32a1 100644 --- a/receiver/nginxreceiver/metadata.yaml +++ b/receiver/nginxreceiver/metadata.yaml @@ -55,3 +55,6 @@ metrics: monotonic: false aggregation_temporality: cumulative attributes: [state] + +tests: + config: diff --git a/receiver/nsxtreceiver/generated_component_test.go b/receiver/nsxtreceiver/generated_component_test.go new file mode 100644 index 000000000000..805fadf7203f --- /dev/null +++ b/receiver/nsxtreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package nsxtreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/nsxtreceiver/go.mod b/receiver/nsxtreceiver/go.mod index 1528285ed126..c0b0ab739db4 100644 --- a/receiver/nsxtreceiver/go.mod +++ b/receiver/nsxtreceiver/go.mod @@ -15,6 +15,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -56,8 +58,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/receiver/nsxtreceiver/internal/metadata/generated_status.go b/receiver/nsxtreceiver/internal/metadata/generated_status.go index 55bcfbc8bafa..98e7cc3d5ca8 100644 --- a/receiver/nsxtreceiver/internal/metadata/generated_status.go +++ b/receiver/nsxtreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "nsxt" MetricsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/nsxtreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/nsxtreceiver") +} diff --git a/receiver/nsxtreceiver/metadata.yaml b/receiver/nsxtreceiver/metadata.yaml index 08ba878f6dff..6a6d357c289d 100644 --- a/receiver/nsxtreceiver/metadata.yaml +++ b/receiver/nsxtreceiver/metadata.yaml @@ -112,3 +112,5 @@ metrics: value_type: int aggregation_temporality: cumulative enabled: true +tests: + config: \ No newline at end of file diff --git a/receiver/opencensusreceiver/generated_component_test.go b/receiver/opencensusreceiver/generated_component_test.go new file mode 100644 index 000000000000..6d090b1beb62 --- /dev/null +++ b/receiver/opencensusreceiver/generated_component_test.go @@ -0,0 +1,96 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package opencensusreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "traces", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + // TODO support lifecycle + t.SkipNow() + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/opencensusreceiver/go.mod b/receiver/opencensusreceiver/go.mod index 610dec758eff..d9ed1e01b271 100644 --- a/receiver/opencensusreceiver/go.mod +++ b/receiver/opencensusreceiver/go.mod @@ -23,6 +23,7 @@ require ( go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 go.opentelemetry.io/otel v1.21.0 + go.opentelemetry.io/otel/metric v1.21.0 go.opentelemetry.io/otel/sdk v1.21.0 go.opentelemetry.io/otel/trace v1.21.0 google.golang.org/grpc v1.60.0 @@ -74,7 +75,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/semconv v0.91.0 // indirect go.opentelemetry.io/otel/exporters/prometheus v0.44.1-0.20231201153405-6027c1ae76f2 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect diff --git a/receiver/opencensusreceiver/internal/metadata/generated_status.go b/receiver/opencensusreceiver/internal/metadata/generated_status.go index 3bea874298ae..d5c0349c5e93 100644 --- a/receiver/opencensusreceiver/internal/metadata/generated_status.go +++ b/receiver/opencensusreceiver/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -11,3 +13,11 @@ const ( MetricsStability = component.StabilityLevelBeta TracesStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/opencensusreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/opencensusreceiver") +} diff --git a/receiver/opencensusreceiver/metadata.yaml b/receiver/opencensusreceiver/metadata.yaml index 5ad4557b86e6..a59a4cfa08e0 100644 --- a/receiver/opencensusreceiver/metadata.yaml +++ b/receiver/opencensusreceiver/metadata.yaml @@ -13,3 +13,6 @@ status: - sumo codeowners: active: [open-telemetry/collector-approvers] +tests: + config: + skip_lifecycle: true \ No newline at end of file diff --git a/receiver/oracledbreceiver/generated_component_test.go b/receiver/oracledbreceiver/generated_component_test.go new file mode 100644 index 000000000000..ab8795745558 --- /dev/null +++ b/receiver/oracledbreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package oracledbreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/oracledbreceiver/internal/metadata/generated_status.go b/receiver/oracledbreceiver/internal/metadata/generated_status.go index 5374f367d479..0cdef17bbece 100644 --- a/receiver/oracledbreceiver/internal/metadata/generated_status.go +++ b/receiver/oracledbreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "oracledb" MetricsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/oracledbreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/oracledbreceiver") +} diff --git a/receiver/oracledbreceiver/metadata.yaml b/receiver/oracledbreceiver/metadata.yaml index ecb8b88538e2..d4d0be3ac398 100644 --- a/receiver/oracledbreceiver/metadata.yaml +++ b/receiver/oracledbreceiver/metadata.yaml @@ -251,4 +251,7 @@ metrics: monotonic: true value_type: int input_type: string - unit: "{gets}" \ No newline at end of file + unit: "{gets}" + +tests: + config: diff --git a/receiver/otlpjsonfilereceiver/generated_component_test.go b/receiver/otlpjsonfilereceiver/generated_component_test.go new file mode 100644 index 000000000000..f4fe062aaebb --- /dev/null +++ b/receiver/otlpjsonfilereceiver/generated_component_test.go @@ -0,0 +1,100 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package otlpjsonfilereceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "traces", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/otlpjsonfilereceiver/go.mod b/receiver/otlpjsonfilereceiver/go.mod index b1aad439db04..a1b2277cdfe9 100644 --- a/receiver/otlpjsonfilereceiver/go.mod +++ b/receiver/otlpjsonfilereceiver/go.mod @@ -11,6 +11,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 ) require ( @@ -40,8 +42,6 @@ require ( go.opentelemetry.io/collector/extension v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/net v0.18.0 // indirect diff --git a/receiver/otlpjsonfilereceiver/internal/metadata/generated_status.go b/receiver/otlpjsonfilereceiver/internal/metadata/generated_status.go index cbef087aadf0..20aae4cd14d2 100644 --- a/receiver/otlpjsonfilereceiver/internal/metadata/generated_status.go +++ b/receiver/otlpjsonfilereceiver/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( MetricsStability = component.StabilityLevelAlpha LogsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/otlpjsonfilereceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/otlpjsonfilereceiver") +} diff --git a/receiver/otlpjsonfilereceiver/metadata.yaml b/receiver/otlpjsonfilereceiver/metadata.yaml index e6ab3530249a..e7489cdbe3ab 100644 --- a/receiver/otlpjsonfilereceiver/metadata.yaml +++ b/receiver/otlpjsonfilereceiver/metadata.yaml @@ -6,4 +6,8 @@ status: alpha: [traces, metrics, logs] distributions: [contrib, sumo] codeowners: - active: [djaglowski, atoulme] \ No newline at end of file + active: [djaglowski, atoulme] +tests: + config: + include: + - "/tmp/*.log" diff --git a/receiver/podmanreceiver/generated_component_test.go b/receiver/podmanreceiver/generated_component_test.go new file mode 100644 index 000000000000..4648edb9b2ee --- /dev/null +++ b/receiver/podmanreceiver/generated_component_test.go @@ -0,0 +1,89 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package podmanreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + // TODO support lifecycle + t.SkipNow() + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/podmanreceiver/go.mod b/receiver/podmanreceiver/go.mod index 6ca7710767aa..dab49c821d41 100644 --- a/receiver/podmanreceiver/go.mod +++ b/receiver/podmanreceiver/go.mod @@ -11,9 +11,11 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 - golang.org/x/crypto v0.16.0 + golang.org/x/crypto v0.17.0 ) require ( @@ -36,8 +38,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/receiver/podmanreceiver/go.sum b/receiver/podmanreceiver/go.sum index 6e25580f02b1..6cd493a6f662 100644 --- a/receiver/podmanreceiver/go.sum +++ b/receiver/podmanreceiver/go.sum @@ -130,8 +130,8 @@ go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= diff --git a/receiver/podmanreceiver/internal/metadata/generated_status.go b/receiver/podmanreceiver/internal/metadata/generated_status.go index 5d5d7a8f46e6..3db39a5e22e4 100644 --- a/receiver/podmanreceiver/internal/metadata/generated_status.go +++ b/receiver/podmanreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "podman_stats" MetricsStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/podmanreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/podmanreceiver") +} diff --git a/receiver/podmanreceiver/metadata.yaml b/receiver/podmanreceiver/metadata.yaml index 348cc1c86537..4e83491c1fec 100644 --- a/receiver/podmanreceiver/metadata.yaml +++ b/receiver/podmanreceiver/metadata.yaml @@ -8,3 +8,6 @@ status: codeowners: active: [rogercoll] +tests: + config: + skip_lifecycle: true diff --git a/receiver/postgresqlreceiver/generated_component_test.go b/receiver/postgresqlreceiver/generated_component_test.go new file mode 100644 index 000000000000..93f1953abe03 --- /dev/null +++ b/receiver/postgresqlreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package postgresqlreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/postgresqlreceiver/go.mod b/receiver/postgresqlreceiver/go.mod index 7bdd069e8a78..976bf716c414 100644 --- a/receiver/postgresqlreceiver/go.mod +++ b/receiver/postgresqlreceiver/go.mod @@ -20,6 +20,8 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -79,8 +81,6 @@ require ( go.opentelemetry.io/collector v0.91.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.18.0 // indirect diff --git a/receiver/postgresqlreceiver/internal/metadata/generated_status.go b/receiver/postgresqlreceiver/internal/metadata/generated_status.go index 72987187142a..c99b7977ca0b 100644 --- a/receiver/postgresqlreceiver/internal/metadata/generated_status.go +++ b/receiver/postgresqlreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "postgresql" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/postgresqlreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/postgresqlreceiver") +} diff --git a/receiver/postgresqlreceiver/metadata.yaml b/receiver/postgresqlreceiver/metadata.yaml index a30e0624e9ee..33b99de51e3a 100644 --- a/receiver/postgresqlreceiver/metadata.yaml +++ b/receiver/postgresqlreceiver/metadata.yaml @@ -307,3 +307,5 @@ metrics: extended_documentation: | This metric requires WAL to be enabled with at least one replica. +tests: + config: diff --git a/receiver/prometheusreceiver/generated_component_test.go b/receiver/prometheusreceiver/generated_component_test.go new file mode 100644 index 000000000000..834b8917225f --- /dev/null +++ b/receiver/prometheusreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package prometheusreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/prometheusreceiver/go.mod b/receiver/prometheusreceiver/go.mod index 9fbe1f494e6f..612f464448f8 100644 --- a/receiver/prometheusreceiver/go.mod +++ b/receiver/prometheusreceiver/go.mod @@ -24,6 +24,8 @@ require ( go.opentelemetry.io/collector/processor/batchprocessor v0.91.0 go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 google.golang.org/protobuf v1.31.0 gopkg.in/yaml.v2 v2.4.0 @@ -182,14 +184,12 @@ require ( go.opentelemetry.io/otel/exporters/prometheus v0.44.1-0.20231201153405-6027c1ae76f2 // indirect go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.44.0 // indirect go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/sdk v1.21.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.16.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect diff --git a/receiver/prometheusreceiver/go.sum b/receiver/prometheusreceiver/go.sum index b056b002a3cc..cd562c122296 100644 --- a/receiver/prometheusreceiver/go.sum +++ b/receiver/prometheusreceiver/go.sum @@ -659,8 +659,8 @@ golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3 golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/receiver/prometheusreceiver/internal/metadata/generated_status.go b/receiver/prometheusreceiver/internal/metadata/generated_status.go index 793e897d7681..b96cf65f2bdf 100644 --- a/receiver/prometheusreceiver/internal/metadata/generated_status.go +++ b/receiver/prometheusreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "prometheus" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/prometheusreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/prometheusreceiver") +} diff --git a/receiver/prometheusreceiver/metadata.yaml b/receiver/prometheusreceiver/metadata.yaml index 4ee37783e0f9..a2a9e95bb17e 100644 --- a/receiver/prometheusreceiver/metadata.yaml +++ b/receiver/prometheusreceiver/metadata.yaml @@ -15,3 +15,8 @@ status: - liatrio codeowners: active: [Aneurysm9, dashpole] +tests: + config: + config: + scrape_configs: + - job_name: 'test' \ No newline at end of file diff --git a/receiver/pulsarreceiver/generated_component_test.go b/receiver/pulsarreceiver/generated_component_test.go new file mode 100644 index 000000000000..a79d6ed43ac7 --- /dev/null +++ b/receiver/pulsarreceiver/generated_component_test.go @@ -0,0 +1,103 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package pulsarreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "traces", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + // TODO support lifecycle + t.SkipNow() + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/pulsarreceiver/go.mod b/receiver/pulsarreceiver/go.mod index 56a74e3dc23b..0a02155b09ed 100644 --- a/receiver/pulsarreceiver/go.mod +++ b/receiver/pulsarreceiver/go.mod @@ -18,6 +18,8 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -67,11 +69,9 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.16.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/oauth2 v0.14.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/receiver/pulsarreceiver/go.sum b/receiver/pulsarreceiver/go.sum index 2ca90b95e4dc..432f6c02d239 100644 --- a/receiver/pulsarreceiver/go.sum +++ b/receiver/pulsarreceiver/go.sum @@ -454,8 +454,8 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/receiver/pulsarreceiver/internal/metadata/generated_status.go b/receiver/pulsarreceiver/internal/metadata/generated_status.go index 5002329249d4..8e040d2b292c 100644 --- a/receiver/pulsarreceiver/internal/metadata/generated_status.go +++ b/receiver/pulsarreceiver/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( TracesStability = component.StabilityLevelAlpha LogsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/pulsarreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/pulsarreceiver") +} diff --git a/receiver/pulsarreceiver/metadata.yaml b/receiver/pulsarreceiver/metadata.yaml index 680d4608233d..e90b33d89578 100644 --- a/receiver/pulsarreceiver/metadata.yaml +++ b/receiver/pulsarreceiver/metadata.yaml @@ -7,3 +7,6 @@ status: distributions: [contrib] codeowners: active: [dmitryax, dao-jun] +tests: + config: + skip_lifecycle: true diff --git a/receiver/purefareceiver/generated_component_test.go b/receiver/purefareceiver/generated_component_test.go new file mode 100644 index 000000000000..0fcba302b7cd --- /dev/null +++ b/receiver/purefareceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package purefareceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/purefareceiver/go.mod b/receiver/purefareceiver/go.mod index 882d05a180a4..bc44521f61b5 100644 --- a/receiver/purefareceiver/go.mod +++ b/receiver/purefareceiver/go.mod @@ -15,6 +15,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 ) @@ -142,11 +144,9 @@ require ( go.opentelemetry.io/collector/semconv v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/atomic v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect - golang.org/x/crypto v0.16.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect diff --git a/receiver/purefareceiver/go.sum b/receiver/purefareceiver/go.sum index 1db5f38b56d9..761c2f502787 100644 --- a/receiver/purefareceiver/go.sum +++ b/receiver/purefareceiver/go.sum @@ -600,8 +600,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/receiver/purefareceiver/internal/metadata/generated_status.go b/receiver/purefareceiver/internal/metadata/generated_status.go index 0e84e929033c..d1c878d0e344 100644 --- a/receiver/purefareceiver/internal/metadata/generated_status.go +++ b/receiver/purefareceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "purefa" MetricsStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/purefareceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/purefareceiver") +} diff --git a/receiver/purefareceiver/metadata.yaml b/receiver/purefareceiver/metadata.yaml index 6d2f2f3fb08f..18f1d6f5df2f 100644 --- a/receiver/purefareceiver/metadata.yaml +++ b/receiver/purefareceiver/metadata.yaml @@ -7,3 +7,6 @@ status: distributions: [contrib, sumo] codeowners: active: [jpkrohling, dgoscn, chrroberts-pure] + +tests: + config: diff --git a/receiver/purefbreceiver/generated_component_test.go b/receiver/purefbreceiver/generated_component_test.go new file mode 100644 index 000000000000..420f6b36983e --- /dev/null +++ b/receiver/purefbreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package purefbreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/purefbreceiver/go.mod b/receiver/purefbreceiver/go.mod index a7e3da62efdc..f433a9aca577 100644 --- a/receiver/purefbreceiver/go.mod +++ b/receiver/purefbreceiver/go.mod @@ -15,6 +15,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/extension v0.91.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 ) @@ -142,11 +144,9 @@ require ( go.opentelemetry.io/collector/semconv v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/atomic v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect - golang.org/x/crypto v0.16.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect diff --git a/receiver/purefbreceiver/go.sum b/receiver/purefbreceiver/go.sum index 1db5f38b56d9..761c2f502787 100644 --- a/receiver/purefbreceiver/go.sum +++ b/receiver/purefbreceiver/go.sum @@ -600,8 +600,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/receiver/purefbreceiver/internal/metadata/generated_status.go b/receiver/purefbreceiver/internal/metadata/generated_status.go index 18405043f96f..c9278be7e477 100644 --- a/receiver/purefbreceiver/internal/metadata/generated_status.go +++ b/receiver/purefbreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "purefb" MetricsStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/purefbreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/purefbreceiver") +} diff --git a/receiver/purefbreceiver/metadata.yaml b/receiver/purefbreceiver/metadata.yaml index 5c4c52d2612f..cf9a19b5fec7 100644 --- a/receiver/purefbreceiver/metadata.yaml +++ b/receiver/purefbreceiver/metadata.yaml @@ -7,3 +7,6 @@ status: distributions: [contrib, sumo] codeowners: active: [jpkrohling, dgoscn, chrroberts-pure] + +tests: + config: diff --git a/receiver/rabbitmqreceiver/generated_component_test.go b/receiver/rabbitmqreceiver/generated_component_test.go new file mode 100644 index 000000000000..9dfa06daabcb --- /dev/null +++ b/receiver/rabbitmqreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package rabbitmqreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/rabbitmqreceiver/go.mod b/receiver/rabbitmqreceiver/go.mod index 1428bd90216d..4ad77d247afd 100644 --- a/receiver/rabbitmqreceiver/go.mod +++ b/receiver/rabbitmqreceiver/go.mod @@ -15,6 +15,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -55,8 +57,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/receiver/rabbitmqreceiver/internal/metadata/generated_status.go b/receiver/rabbitmqreceiver/internal/metadata/generated_status.go index 0b838f884e9d..670cf57b741f 100644 --- a/receiver/rabbitmqreceiver/internal/metadata/generated_status.go +++ b/receiver/rabbitmqreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "rabbitmq" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/rabbitmqreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/rabbitmqreceiver") +} diff --git a/receiver/rabbitmqreceiver/metadata.yaml b/receiver/rabbitmqreceiver/metadata.yaml index 0b8770892f0d..930a680e6fba 100644 --- a/receiver/rabbitmqreceiver/metadata.yaml +++ b/receiver/rabbitmqreceiver/metadata.yaml @@ -80,3 +80,6 @@ metrics: value_type: int attributes: [message.state] enabled: true + +tests: + config: diff --git a/receiver/receivercreator/go.mod b/receiver/receivercreator/go.mod index 684e3642b413..1f839f8efa3f 100644 --- a/receiver/receivercreator/go.mod +++ b/receiver/receivercreator/go.mod @@ -17,6 +17,8 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -85,10 +87,8 @@ require ( go.opentelemetry.io/otel/exporters/prometheus v0.44.1-0.20231201153405-6027c1ae76f2 // indirect go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.44.0 // indirect go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/sdk v1.21.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/receiver/receivercreator/internal/metadata/generated_status.go b/receiver/receivercreator/internal/metadata/generated_status.go index 2d1d94d45487..38b0e84f697d 100644 --- a/receiver/receivercreator/internal/metadata/generated_status.go +++ b/receiver/receivercreator/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -12,3 +14,11 @@ const ( TracesStability = component.StabilityLevelAlpha MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol") +} diff --git a/receiver/redisreceiver/generated_component_test.go b/receiver/redisreceiver/generated_component_test.go new file mode 100644 index 000000000000..709139684d6c --- /dev/null +++ b/receiver/redisreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package redisreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/redisreceiver/go.mod b/receiver/redisreceiver/go.mod index c97299e9c6fd..9e9eac914181 100644 --- a/receiver/redisreceiver/go.mod +++ b/receiver/redisreceiver/go.mod @@ -17,6 +17,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -77,8 +79,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect golang.org/x/mod v0.14.0 // indirect diff --git a/receiver/redisreceiver/internal/metadata/generated_status.go b/receiver/redisreceiver/internal/metadata/generated_status.go index defca6ff527a..86fd27ad64c5 100644 --- a/receiver/redisreceiver/internal/metadata/generated_status.go +++ b/receiver/redisreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "redis" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/redisreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/redisreceiver") +} diff --git a/receiver/redisreceiver/metadata.yaml b/receiver/redisreceiver/metadata.yaml index b4ac8273884e..94a4d5fc2d85 100644 --- a/receiver/redisreceiver/metadata.yaml +++ b/receiver/redisreceiver/metadata.yaml @@ -344,3 +344,7 @@ metrics: gauge: value_type: int attributes: [db] + +tests: + config: + endpoint: localhost:6379 diff --git a/receiver/riakreceiver/generated_component_test.go b/receiver/riakreceiver/generated_component_test.go new file mode 100644 index 000000000000..4d8bdb05db5d --- /dev/null +++ b/receiver/riakreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package riakreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/riakreceiver/go.mod b/receiver/riakreceiver/go.mod index a1af37c5764f..0de9557ca361 100644 --- a/receiver/riakreceiver/go.mod +++ b/receiver/riakreceiver/go.mod @@ -15,6 +15,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -55,8 +57,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/receiver/riakreceiver/internal/metadata/generated_status.go b/receiver/riakreceiver/internal/metadata/generated_status.go index da3d0d68edf5..92edb4084b5c 100644 --- a/receiver/riakreceiver/internal/metadata/generated_status.go +++ b/receiver/riakreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "riak" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/riakreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/riakreceiver") +} diff --git a/receiver/riakreceiver/metadata.yaml b/receiver/riakreceiver/metadata.yaml index a199e9155e5a..7e37d272a5ea 100644 --- a/receiver/riakreceiver/metadata.yaml +++ b/receiver/riakreceiver/metadata.yaml @@ -80,3 +80,6 @@ metrics: value_type: int attributes: [operation] enabled: true + +tests: + config: diff --git a/receiver/saphanareceiver/go.mod b/receiver/saphanareceiver/go.mod index 4ef56bf6d287..08ea9bb44407 100644 --- a/receiver/saphanareceiver/go.mod +++ b/receiver/saphanareceiver/go.mod @@ -16,6 +16,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -44,9 +46,7 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect - golang.org/x/crypto v0.16.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/receiver/saphanareceiver/go.sum b/receiver/saphanareceiver/go.sum index cd266a2a0906..8c8a57a88de5 100644 --- a/receiver/saphanareceiver/go.sum +++ b/receiver/saphanareceiver/go.sum @@ -139,8 +139,8 @@ go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= diff --git a/receiver/saphanareceiver/internal/metadata/generated_status.go b/receiver/saphanareceiver/internal/metadata/generated_status.go index 3f9ead43d61c..44a6597ae7f8 100644 --- a/receiver/saphanareceiver/internal/metadata/generated_status.go +++ b/receiver/saphanareceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "saphana" MetricsStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/saphanareceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/saphanareceiver") +} diff --git a/receiver/sapmreceiver/generated_component_test.go b/receiver/sapmreceiver/generated_component_test.go new file mode 100644 index 000000000000..15b8424f106d --- /dev/null +++ b/receiver/sapmreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package sapmreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "traces", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/sapmreceiver/go.mod b/receiver/sapmreceiver/go.mod index fc0ebcbcde04..eeb2e73cef62 100644 --- a/receiver/sapmreceiver/go.mod +++ b/receiver/sapmreceiver/go.mod @@ -19,6 +19,8 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 ) require ( @@ -58,8 +60,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/net v0.19.0 // indirect diff --git a/receiver/sapmreceiver/internal/metadata/generated_status.go b/receiver/sapmreceiver/internal/metadata/generated_status.go index b623b108ae12..ba97ef60747a 100644 --- a/receiver/sapmreceiver/internal/metadata/generated_status.go +++ b/receiver/sapmreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "sapm" TracesStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/sapmreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/sapmreceiver") +} diff --git a/receiver/sapmreceiver/metadata.yaml b/receiver/sapmreceiver/metadata.yaml index e1307fbe30d8..d6ba89598d34 100644 --- a/receiver/sapmreceiver/metadata.yaml +++ b/receiver/sapmreceiver/metadata.yaml @@ -6,4 +6,7 @@ status: beta: [traces] distributions: [contrib, splunk, observiq, sumo] codeowners: - active: [atoulme] \ No newline at end of file + active: [atoulme] + +tests: + config: diff --git a/receiver/sapmreceiver/trace_receiver_test.go b/receiver/sapmreceiver/trace_receiver_test.go index 3c14e0af8683..05dbfb8de022 100644 --- a/receiver/sapmreceiver/trace_receiver_test.go +++ b/receiver/sapmreceiver/trace_receiver_test.go @@ -19,8 +19,6 @@ import ( "github.com/signalfx/sapm-proto/sapmprotocol" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/component" - "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/config/confighttp" "go.opentelemetry.io/collector/config/configtls" "go.opentelemetry.io/collector/consumer/consumertest" @@ -423,21 +421,3 @@ func TestAccessTokenPassthrough(t *testing.T) { }) } } - -// assertNoErrorHost implements a component.Host that asserts that there were no errors. -type assertNoErrorHost struct { - component.Host - *testing.T -} - -// newAssertNoErrorHost returns a new instance of assertNoErrorHost. -func newAssertNoErrorHost(t *testing.T) component.Host { - return &assertNoErrorHost{ - Host: componenttest.NewNopHost(), - T: t, - } -} - -func (aneh *assertNoErrorHost) ReportFatalError(err error) { - assert.NoError(aneh, err) -} diff --git a/receiver/signalfxreceiver/generated_component_test.go b/receiver/signalfxreceiver/generated_component_test.go new file mode 100644 index 000000000000..daf601d03d6b --- /dev/null +++ b/receiver/signalfxreceiver/generated_component_test.go @@ -0,0 +1,93 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package signalfxreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/signalfxreceiver/go.mod b/receiver/signalfxreceiver/go.mod index 52731ec51692..ac16f1647662 100644 --- a/receiver/signalfxreceiver/go.mod +++ b/receiver/signalfxreceiver/go.mod @@ -19,6 +19,8 @@ require ( go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -72,8 +74,6 @@ require ( go.opentelemetry.io/collector/semconv v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/receiver/signalfxreceiver/internal/metadata/generated_status.go b/receiver/signalfxreceiver/internal/metadata/generated_status.go index d1205b62b2b3..5a7f83a280af 100644 --- a/receiver/signalfxreceiver/internal/metadata/generated_status.go +++ b/receiver/signalfxreceiver/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -11,3 +13,11 @@ const ( MetricsStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/signalfxreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/signalfxreceiver") +} diff --git a/receiver/signalfxreceiver/metadata.yaml b/receiver/signalfxreceiver/metadata.yaml index 1ab2bb674571..598fa13bf08e 100644 --- a/receiver/signalfxreceiver/metadata.yaml +++ b/receiver/signalfxreceiver/metadata.yaml @@ -8,3 +8,6 @@ status: codeowners: active: ["dmitryax"] emeritus: + +tests: + config: diff --git a/receiver/signalfxreceiver/receiver_test.go b/receiver/signalfxreceiver/receiver_test.go index 3348163bd1fc..711007cc9dab 100644 --- a/receiver/signalfxreceiver/receiver_test.go +++ b/receiver/signalfxreceiver/receiver_test.go @@ -820,24 +820,6 @@ func (b badReqBody) Close() error { return nil } -// assertNoErrorHost implements a component.Host that asserts that there were no errors. -type assertNoErrorHost struct { - component.Host - *testing.T -} - -// newAssertNoErrorHost returns a new instance of assertNoErrorHost. -func newAssertNoErrorHost(t *testing.T) component.Host { - return &assertNoErrorHost{ - Host: componenttest.NewNopHost(), - T: t, - } -} - -func (aneh *assertNoErrorHost) ReportFatalError(err error) { - assert.NoError(aneh, err) -} - func strPtr(s string) *string { return &s } diff --git a/receiver/simpleprometheusreceiver/generated_component_test.go b/receiver/simpleprometheusreceiver/generated_component_test.go new file mode 100644 index 000000000000..865138395261 --- /dev/null +++ b/receiver/simpleprometheusreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package simpleprometheusreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/simpleprometheusreceiver/go.mod b/receiver/simpleprometheusreceiver/go.mod index 37d9046b3dfa..aa2454d18ca2 100644 --- a/receiver/simpleprometheusreceiver/go.mod +++ b/receiver/simpleprometheusreceiver/go.mod @@ -13,6 +13,8 @@ require ( go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 k8s.io/client-go v0.28.4 ) @@ -141,12 +143,10 @@ require ( go.opentelemetry.io/collector/semconv v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect - golang.org/x/crypto v0.16.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect diff --git a/receiver/simpleprometheusreceiver/go.sum b/receiver/simpleprometheusreceiver/go.sum index fb1a747f9e20..8d86951bc8ff 100644 --- a/receiver/simpleprometheusreceiver/go.sum +++ b/receiver/simpleprometheusreceiver/go.sum @@ -597,8 +597,8 @@ golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3 golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/receiver/simpleprometheusreceiver/internal/metadata/generated_status.go b/receiver/simpleprometheusreceiver/internal/metadata/generated_status.go index f00b1937abf6..cff80b1efaba 100644 --- a/receiver/simpleprometheusreceiver/internal/metadata/generated_status.go +++ b/receiver/simpleprometheusreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "prometheus_simple" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/simpleprometheusreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/simpleprometheusreceiver") +} diff --git a/receiver/simpleprometheusreceiver/metadata.yaml b/receiver/simpleprometheusreceiver/metadata.yaml index ee7e54472a10..1c02f3f64a86 100644 --- a/receiver/simpleprometheusreceiver/metadata.yaml +++ b/receiver/simpleprometheusreceiver/metadata.yaml @@ -7,3 +7,6 @@ status: distributions: [contrib, splunk, observiq, sumo] codeowners: active: [fatsheep9146] + +tests: + config: diff --git a/receiver/skywalkingreceiver/generated_component_test.go b/receiver/skywalkingreceiver/generated_component_test.go new file mode 100644 index 000000000000..6c9eef939cbf --- /dev/null +++ b/receiver/skywalkingreceiver/generated_component_test.go @@ -0,0 +1,93 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package skywalkingreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "traces", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/skywalkingreceiver/go.mod b/receiver/skywalkingreceiver/go.mod index 2abb8bcee81e..990c6c964b04 100644 --- a/receiver/skywalkingreceiver/go.mod +++ b/receiver/skywalkingreceiver/go.mod @@ -17,6 +17,8 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 google.golang.org/grpc v1.60.0 google.golang.org/protobuf v1.31.0 @@ -61,8 +63,6 @@ require ( go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/oauth2 v0.14.0 // indirect diff --git a/receiver/skywalkingreceiver/internal/metadata/generated_status.go b/receiver/skywalkingreceiver/internal/metadata/generated_status.go index 5c7e14dd2798..66fcb374c6b2 100644 --- a/receiver/skywalkingreceiver/internal/metadata/generated_status.go +++ b/receiver/skywalkingreceiver/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -11,3 +13,11 @@ const ( TracesStability = component.StabilityLevelBeta MetricsStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/skywalkingreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/skywalkingreceiver") +} diff --git a/receiver/skywalkingreceiver/metadata.yaml b/receiver/skywalkingreceiver/metadata.yaml index 43edd9e827a6..ffbef358da76 100644 --- a/receiver/skywalkingreceiver/metadata.yaml +++ b/receiver/skywalkingreceiver/metadata.yaml @@ -8,3 +8,9 @@ status: distributions: [contrib, sumo] codeowners: active: [JaredTan95] + +tests: + config: + protocols: + grpc: + endpoint: localhost:1234 \ No newline at end of file diff --git a/receiver/snmpreceiver/client.go b/receiver/snmpreceiver/client.go index dd4b30a49265..df2547960811 100644 --- a/receiver/snmpreceiver/client.go +++ b/receiver/snmpreceiver/client.go @@ -189,7 +189,7 @@ func (c *snmpClient) Close() error { // GetScalarData retrieves and returns scalar data from passed in scalar OIDs. // Note: These OIDs must all end in ".0" for the SNMP GET to work correctly func (c *snmpClient) GetScalarData(oids []string, scraperErrors *scrapererror.ScrapeErrors) []SNMPData { - scalarData := []SNMPData{} + var scalarData []SNMPData // Nothing to do if there are no OIDs if len(oids) == 0 { @@ -244,7 +244,7 @@ func (c *snmpClient) GetScalarData(oids []string, scraperErrors *scrapererror.Sc // GetIndexedData retrieves indexed metrics from passed in column OIDs. The returned data // is then also passed into the provided function. func (c *snmpClient) GetIndexedData(oids []string, scraperErrors *scrapererror.ScrapeErrors) []SNMPData { - indexedData := []SNMPData{} + var indexedData []SNMPData // Nothing to do if there are no OIDs if len(oids) == 0 { @@ -372,7 +372,7 @@ func (c *snmpClient) convertSnmpPDUToSnmpData(pdu gosnmp.SnmpPDU) SNMPData { // This is a convenience function to make working with SnmpPDU's easier - it // reduces the need for type assertions. A int64 is convenient, as SNMP can // return int32, uint32, and int64. -func (c snmpClient) toInt64(name string, value any) (int64, error) { +func (c *snmpClient) toInt64(name string, value any) (int64, error) { switch value := value.(type) { // shadow case uint: return int64(value), nil @@ -405,7 +405,7 @@ func (c snmpClient) toInt64(name string, value any) (int64, error) { // This is a convenience function to make working with SnmpPDU's easier - it // reduces the need for type assertions. A float64 is convenient, as SNMP can // return float32 and float64. -func (c snmpClient) toFloat64(name string, value any) (float64, error) { +func (c *snmpClient) toFloat64(name string, value any) (float64, error) { switch value := value.(type) { // shadow case float32: return float64(value), nil diff --git a/receiver/snmpreceiver/client_test.go b/receiver/snmpreceiver/client_test.go index 491b20d9a2d9..0f54b111c9f6 100644 --- a/receiver/snmpreceiver/client_test.go +++ b/receiver/snmpreceiver/client_test.go @@ -204,7 +204,7 @@ func TestGetScalarData(t *testing.T) { { desc: "No OIDs does nothing", testFunc: func(t *testing.T) { - expectedSNMPData := []SNMPData{} + var expectedSNMPData []SNMPData mockGoSNMP := new(mocks.MockGoSNMPWrapper) client := &snmpClient{ logger: zap.NewNop(), @@ -219,7 +219,6 @@ func TestGetScalarData(t *testing.T) { { desc: "GoSNMP Client failures adds error", testFunc: func(t *testing.T) { - expectedSNMPData := []SNMPData{} getError := errors.New("Bad GET") mockGoSNMP := new(mocks.MockGoSNMPWrapper) mockGoSNMP.On("Get", []string{"1"}).Return(nil, getError) @@ -233,13 +232,13 @@ func TestGetScalarData(t *testing.T) { returnedSNMPData := client.GetScalarData(oidSlice, &scraperErrors) expectedErr := fmt.Errorf("problem with getting scalar data: problem with SNMP GET for OIDs '%v': %w", oidSlice, getError) require.EqualError(t, scraperErrors.Combine(), expectedErr.Error()) - require.Equal(t, expectedSNMPData, returnedSNMPData) + require.Nil(t, returnedSNMPData) }, }, { desc: "GoSNMP Client timeout failures tries to reset connection", testFunc: func(t *testing.T) { - expectedSNMPData := []SNMPData{} + var expectedSNMPData []SNMPData getError := errors.New("request timeout (after 0 retries)") mockGoSNMP := new(mocks.MockGoSNMPWrapper) mockGoSNMP.On("Get", []string{"1"}).Return(nil, getError) @@ -261,7 +260,6 @@ func TestGetScalarData(t *testing.T) { { desc: "GoSNMP Client reset connection fails on connect adds error", testFunc: func(t *testing.T) { - expectedSNMPData := []SNMPData{} getError := errors.New("request timeout (after 0 retries)") mockGoSNMP := new(mocks.MockGoSNMPWrapper) mockGoSNMP.On("Get", []string{"1"}).Return(nil, getError) @@ -280,7 +278,7 @@ func TestGetScalarData(t *testing.T) { expectedErr2 := fmt.Errorf("problem with getting scalar data: problem connecting while trying to reset connection: %w", connectErr) expectedErr := fmt.Errorf(expectedErr1.Error() + "; " + expectedErr2.Error()) require.EqualError(t, scraperErrors.Combine(), expectedErr.Error()) - require.Equal(t, expectedSNMPData, returnedSNMPData) + require.Nil(t, returnedSNMPData) }, }, { @@ -321,7 +319,6 @@ func TestGetScalarData(t *testing.T) { { desc: "GoSNMP Client returned nil value does not return data", testFunc: func(t *testing.T) { - expectedSNMPData := []SNMPData{} mockGoSNMP := new(mocks.MockGoSNMPWrapper) pdu := gosnmp.SnmpPDU{ Value: nil, @@ -341,13 +338,12 @@ func TestGetScalarData(t *testing.T) { returnedSNMPData := client.GetScalarData(oidSlice, &scraperErrors) expectedErr := fmt.Errorf("problem with getting scalar data: data for OID '%s' not found", badOID) require.EqualError(t, scraperErrors.Combine(), expectedErr.Error()) - require.Equal(t, expectedSNMPData, returnedSNMPData) + require.Nil(t, returnedSNMPData) }, }, { desc: "GoSNMP Client returned unsupported type value does not return data", testFunc: func(t *testing.T) { - expectedSNMPData := []SNMPData{} mockGoSNMP := new(mocks.MockGoSNMPWrapper) pdu := gosnmp.SnmpPDU{ Value: true, @@ -367,7 +363,7 @@ func TestGetScalarData(t *testing.T) { returnedSNMPData := client.GetScalarData(oidSlice, &scraperErrors) expectedErr := fmt.Errorf("problem with getting scalar data: data for OID '%s' not a supported type", badOID) require.EqualError(t, scraperErrors.Combine(), expectedErr.Error()) - require.Equal(t, expectedSNMPData, returnedSNMPData) + require.Nil(t, returnedSNMPData) }, }, { @@ -462,7 +458,6 @@ func TestGetScalarData(t *testing.T) { { desc: "GoSNMP Client float data type with bad value adds error", testFunc: func(t *testing.T) { - expectedSNMPData := []SNMPData{} mockGoSNMP := new(mocks.MockGoSNMPWrapper) pdu1 := gosnmp.SnmpPDU{ Value: true, @@ -480,13 +475,12 @@ func TestGetScalarData(t *testing.T) { returnedSNMPData := client.GetScalarData(oidSlice, &scraperErrors) expectedErr := fmt.Errorf("problem with getting scalar data: data for OID '1' not a supported type") require.EqualError(t, scraperErrors.Combine(), expectedErr.Error()) - require.Equal(t, expectedSNMPData, returnedSNMPData) + require.Nil(t, returnedSNMPData) }, }, { desc: "GoSNMP Client float data type with bad string value adds error", testFunc: func(t *testing.T) { - expectedSNMPData := []SNMPData{} mockGoSNMP := new(mocks.MockGoSNMPWrapper) pdu1 := gosnmp.SnmpPDU{ Value: "bad", @@ -504,13 +498,12 @@ func TestGetScalarData(t *testing.T) { returnedSNMPData := client.GetScalarData(oidSlice, &scraperErrors) expectedErr := fmt.Errorf("problem with getting scalar data: data for OID '1' not a supported type") require.EqualError(t, scraperErrors.Combine(), expectedErr.Error()) - require.Equal(t, expectedSNMPData, returnedSNMPData) + require.Nil(t, returnedSNMPData) }, }, { desc: "GoSNMP Client int data type with bad value adds error", testFunc: func(t *testing.T) { - expectedSNMPData := []SNMPData{} mockGoSNMP := new(mocks.MockGoSNMPWrapper) pdu1 := gosnmp.SnmpPDU{ Value: float64(math.MaxFloat64), @@ -528,7 +521,7 @@ func TestGetScalarData(t *testing.T) { returnedSNMPData := client.GetScalarData(oidSlice, &scraperErrors) expectedErr := fmt.Errorf("problem with getting scalar data: data for OID '1' not a supported type") require.EqualError(t, scraperErrors.Combine(), expectedErr.Error()) - require.Equal(t, expectedSNMPData, returnedSNMPData) + require.Nil(t, returnedSNMPData) }, }, { @@ -575,7 +568,6 @@ func TestGetIndexedData(t *testing.T) { { desc: "No OIDs does nothing", testFunc: func(t *testing.T) { - expectedSNMPData := []SNMPData{} mockGoSNMP := new(mocks.MockGoSNMPWrapper) client := &snmpClient{ logger: zap.NewNop(), @@ -584,13 +576,12 @@ func TestGetIndexedData(t *testing.T) { var scraperErrors scrapererror.ScrapeErrors returnedSNMPData := client.GetIndexedData([]string{}, &scraperErrors) require.NoError(t, scraperErrors.Combine()) - require.Equal(t, expectedSNMPData, returnedSNMPData) + require.Nil(t, returnedSNMPData) }, }, { desc: "GoSNMP Client failures adds error", testFunc: func(t *testing.T) { - expectedSNMPData := []SNMPData{} walkError := errors.New("Bad WALK") mockGoSNMP := new(mocks.MockGoSNMPWrapper) mockGoSNMP.On("GetVersion", mock.Anything).Return(gosnmp.Version2c) @@ -604,13 +595,12 @@ func TestGetIndexedData(t *testing.T) { returnedSNMPData := client.GetIndexedData(oidSlice, &scraperErrors) expectedErr := fmt.Errorf("problem with getting indexed data: problem with SNMP WALK for OID '1': %w", walkError) require.EqualError(t, scraperErrors.Combine(), expectedErr.Error()) - require.Equal(t, expectedSNMPData, returnedSNMPData) + require.Nil(t, returnedSNMPData) }, }, { desc: "GoSNMP Client timeout failures tries to reset connection", testFunc: func(t *testing.T) { - expectedSNMPData := []SNMPData{} walkError := errors.New("request timeout (after 0 retries)") mockGoSNMP := new(mocks.MockGoSNMPWrapper) mockGoSNMP.On("GetVersion", mock.Anything).Return(gosnmp.Version2c) @@ -626,13 +616,12 @@ func TestGetIndexedData(t *testing.T) { returnedSNMPData := client.GetIndexedData(oidSlice, &scraperErrors) expectedErr := fmt.Errorf("problem with getting indexed data: problem with SNMP WALK for OID '1': %w", walkError) require.EqualError(t, scraperErrors.Combine(), expectedErr.Error()) - require.Equal(t, expectedSNMPData, returnedSNMPData) + require.Nil(t, returnedSNMPData) }, }, { desc: "GoSNMP Client reset connection fails on connect adds errors", testFunc: func(t *testing.T) { - expectedSNMPData := []SNMPData{} walkError := errors.New("request timeout (after 0 retries)") mockGoSNMP := new(mocks.MockGoSNMPWrapper) mockGoSNMP.On("GetVersion", mock.Anything).Return(gosnmp.Version2c) @@ -651,7 +640,7 @@ func TestGetIndexedData(t *testing.T) { expectedErr2 := fmt.Errorf("problem with getting indexed data: problem connecting while trying to reset connection: %w", connectErr) expectedErr := fmt.Errorf(expectedErr1.Error() + "; " + expectedErr2.Error()) require.EqualError(t, scraperErrors.Combine(), expectedErr.Error()) - require.Equal(t, expectedSNMPData, returnedSNMPData) + require.Nil(t, returnedSNMPData) }, }, { @@ -690,7 +679,6 @@ func TestGetIndexedData(t *testing.T) { { desc: "GoSNMP Client returned nil value does not return data", testFunc: func(t *testing.T) { - expectedSNMPData := []SNMPData{} mockGoSNMP := new(mocks.MockGoSNMPWrapper) mockGoSNMP.On("GetVersion", mock.Anything).Return(gosnmp.Version2c) badOID := "1.1" @@ -709,13 +697,12 @@ func TestGetIndexedData(t *testing.T) { returnedSNMPData := client.GetIndexedData(oidSlice, &scraperErrors) expectedErr := fmt.Errorf("problem with getting indexed data: data for OID '%s' not found", badOID) require.EqualError(t, scraperErrors.Combine(), expectedErr.Error()) - require.Equal(t, expectedSNMPData, returnedSNMPData) + require.Nil(t, returnedSNMPData) }, }, { desc: "GoSNMP Client returned unsupported type value does not return data", testFunc: func(t *testing.T) { - expectedSNMPData := []SNMPData{} mockGoSNMP := new(mocks.MockGoSNMPWrapper) mockGoSNMP.On("GetVersion", mock.Anything).Return(gosnmp.Version2c) badOID := "1.1" @@ -734,7 +721,7 @@ func TestGetIndexedData(t *testing.T) { returnedSNMPData := client.GetIndexedData(oidSlice, &scraperErrors) expectedErr := fmt.Errorf("problem with getting indexed data: data for OID '%s' not a supported type", badOID) require.EqualError(t, scraperErrors.Combine(), expectedErr.Error()) - require.Equal(t, expectedSNMPData, returnedSNMPData) + require.Nil(t, returnedSNMPData) }, }, { @@ -833,7 +820,6 @@ func TestGetIndexedData(t *testing.T) { { desc: "GoSNMP Client float data type with bad value adds error", testFunc: func(t *testing.T) { - expectedSNMPData := []SNMPData{} mockGoSNMP := new(mocks.MockGoSNMPWrapper) mockGoSNMP.On("GetVersion", mock.Anything).Return(gosnmp.Version2c) pdu := gosnmp.SnmpPDU{ @@ -850,13 +836,12 @@ func TestGetIndexedData(t *testing.T) { returnedSNMPData := client.GetIndexedData([]string{"1"}, &scraperErrors) expectedErr := fmt.Errorf("problem with getting indexed data: data for OID '1.1' not a supported type") require.EqualError(t, scraperErrors.Combine(), expectedErr.Error()) - require.Equal(t, expectedSNMPData, returnedSNMPData) + require.Nil(t, returnedSNMPData) }, }, { desc: "GoSNMP Client float data type with bad string value adds error", testFunc: func(t *testing.T) { - expectedSNMPData := []SNMPData{} mockGoSNMP := new(mocks.MockGoSNMPWrapper) mockGoSNMP.On("GetVersion", mock.Anything).Return(gosnmp.Version2c) pdu := gosnmp.SnmpPDU{ @@ -873,13 +858,12 @@ func TestGetIndexedData(t *testing.T) { returnedSNMPData := client.GetIndexedData([]string{"1"}, &scraperErrors) expectedErr := fmt.Errorf("problem with getting indexed data: data for OID '1.1' not a supported type") require.EqualError(t, scraperErrors.Combine(), expectedErr.Error()) - require.Equal(t, expectedSNMPData, returnedSNMPData) + require.Nil(t, returnedSNMPData) }, }, { desc: "GoSNMP Client int data type with bad value adds error", testFunc: func(t *testing.T) { - expectedSNMPData := []SNMPData{} mockGoSNMP := new(mocks.MockGoSNMPWrapper) mockGoSNMP.On("GetVersion", mock.Anything).Return(gosnmp.Version2c) pdu := gosnmp.SnmpPDU{ @@ -896,7 +880,7 @@ func TestGetIndexedData(t *testing.T) { returnedSNMPData := client.GetIndexedData([]string{"1"}, &scraperErrors) expectedErr := fmt.Errorf("problem with getting indexed data: data for OID '1.1' not a supported type") require.EqualError(t, scraperErrors.Combine(), expectedErr.Error()) - require.Equal(t, expectedSNMPData, returnedSNMPData) + require.Nil(t, returnedSNMPData) }, }, { diff --git a/receiver/snmpreceiver/generated_component_test.go b/receiver/snmpreceiver/generated_component_test.go new file mode 100644 index 000000000000..80832d62c8bf --- /dev/null +++ b/receiver/snmpreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package snmpreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/snmpreceiver/go.mod b/receiver/snmpreceiver/go.mod index f4de7e679615..5c26bcf96f13 100644 --- a/receiver/snmpreceiver/go.mod +++ b/receiver/snmpreceiver/go.mod @@ -15,6 +15,8 @@ require ( go.opentelemetry.io/collector/otelcol v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -107,10 +109,8 @@ require ( go.opentelemetry.io/otel/exporters/prometheus v0.44.1-0.20231201153405-6027c1ae76f2 // indirect go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.44.0 // indirect go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/sdk v1.21.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect diff --git a/receiver/snmpreceiver/internal/metadata/generated_status.go b/receiver/snmpreceiver/internal/metadata/generated_status.go index 439779d726fb..0c8652dfa96f 100644 --- a/receiver/snmpreceiver/internal/metadata/generated_status.go +++ b/receiver/snmpreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "snmp" MetricsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/snmpreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/snmpreceiver") +} diff --git a/receiver/snmpreceiver/metadata.yaml b/receiver/snmpreceiver/metadata.yaml index 204f1e9eadf3..aed9f3699602 100644 --- a/receiver/snmpreceiver/metadata.yaml +++ b/receiver/snmpreceiver/metadata.yaml @@ -6,4 +6,14 @@ status: alpha: [metrics] distributions: [contrib, sumo] codeowners: - active: [djaglowski, StefanKurek, tamir-michaeli] \ No newline at end of file + active: [djaglowski, StefanKurek, tamir-michaeli] + +tests: + config: + metrics: + m1: + unit: "1" + gauge: + value_type: int + scalar_oids: + - oid: ".1" diff --git a/receiver/snowflakereceiver/generated_component_test.go b/receiver/snowflakereceiver/generated_component_test.go new file mode 100644 index 000000000000..823c9014c3b3 --- /dev/null +++ b/receiver/snowflakereceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package snowflakereceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/snowflakereceiver/go.mod b/receiver/snowflakereceiver/go.mod index 2f6842f368a4..24e730ec9b7a 100644 --- a/receiver/snowflakereceiver/go.mod +++ b/receiver/snowflakereceiver/go.mod @@ -15,6 +15,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -83,15 +85,13 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect - golang.org/x/crypto v0.15.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sync v0.5.0 // indirect golang.org/x/sys v0.15.0 // indirect - golang.org/x/term v0.14.0 // indirect + golang.org/x/term v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.15.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect diff --git a/receiver/snowflakereceiver/go.sum b/receiver/snowflakereceiver/go.sum index f89b37ffdf14..7c4a8c4d94c5 100644 --- a/receiver/snowflakereceiver/go.sum +++ b/receiver/snowflakereceiver/go.sum @@ -253,8 +253,8 @@ go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= -golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 h1:FqrVOBQxQ8r/UwwXibI0KMolVhvFiGobSfdE33deHJM= golang.org/x/exp v0.0.0-20230711023510-fffb14384f22/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= @@ -294,8 +294,8 @@ golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.14.0 h1:LGK9IlZ8T9jvdy6cTdfKUCltatMFOehAQo9SRC46UQ8= -golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww= +golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= +golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= diff --git a/receiver/snowflakereceiver/internal/metadata/generated_status.go b/receiver/snowflakereceiver/internal/metadata/generated_status.go index a4a6286e70aa..02686bbe1ad1 100644 --- a/receiver/snowflakereceiver/internal/metadata/generated_status.go +++ b/receiver/snowflakereceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "snowflake" MetricsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/snowflakereceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/snowflakereceiver") +} diff --git a/receiver/snowflakereceiver/metadata.yaml b/receiver/snowflakereceiver/metadata.yaml index f3d31d3a0430..a81d14009e4f 100644 --- a/receiver/snowflakereceiver/metadata.yaml +++ b/receiver/snowflakereceiver/metadata.yaml @@ -313,3 +313,6 @@ metrics: gauge: value_type: int enabled: false + +tests: + config: diff --git a/receiver/solacereceiver/go.mod b/receiver/solacereceiver/go.mod index bb2086be9770..65669f17f0ad 100644 --- a/receiver/solacereceiver/go.mod +++ b/receiver/solacereceiver/go.mod @@ -17,6 +17,8 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/otel v1.21.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 google.golang.org/protobuf v1.31.0 ) @@ -39,8 +41,6 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/receiver/solacereceiver/internal/metadata/generated_status.go b/receiver/solacereceiver/internal/metadata/generated_status.go index d29fa4ce7ba0..ea4e1c54d4f6 100644 --- a/receiver/solacereceiver/internal/metadata/generated_status.go +++ b/receiver/solacereceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "solace" TracesStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/solacereceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/solacereceiver") +} diff --git a/receiver/splunkenterprisereceiver/generated_component_test.go b/receiver/splunkenterprisereceiver/generated_component_test.go new file mode 100644 index 000000000000..82544817215f --- /dev/null +++ b/receiver/splunkenterprisereceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package splunkenterprisereceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/splunkenterprisereceiver/go.mod b/receiver/splunkenterprisereceiver/go.mod index deeaa9eea97e..2a74d22fece8 100644 --- a/receiver/splunkenterprisereceiver/go.mod +++ b/receiver/splunkenterprisereceiver/go.mod @@ -16,6 +16,8 @@ require ( go.opentelemetry.io/collector/extension/auth v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -54,8 +56,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/receiver/splunkenterprisereceiver/internal/metadata/generated_status.go b/receiver/splunkenterprisereceiver/internal/metadata/generated_status.go index 9ab9965626b7..061ba0be1da7 100644 --- a/receiver/splunkenterprisereceiver/internal/metadata/generated_status.go +++ b/receiver/splunkenterprisereceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "splunkenterprise" MetricsStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/splunkenterprisereceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/splunkenterprisereceiver") +} diff --git a/receiver/splunkenterprisereceiver/metadata.yaml b/receiver/splunkenterprisereceiver/metadata.yaml index 9059a4f11841..8666de0743fb 100644 --- a/receiver/splunkenterprisereceiver/metadata.yaml +++ b/receiver/splunkenterprisereceiver/metadata.yaml @@ -105,3 +105,6 @@ metrics: gauge: value_type: int attributes: [splunk.queue.name] + +tests: + config: diff --git a/receiver/splunkhecreceiver/go.mod b/receiver/splunkhecreceiver/go.mod index 46cf96b78d91..46e4cbffc416 100644 --- a/receiver/splunkhecreceiver/go.mod +++ b/receiver/splunkhecreceiver/go.mod @@ -20,6 +20,8 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -61,8 +63,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/receiver/splunkhecreceiver/internal/metadata/generated_status.go b/receiver/splunkhecreceiver/internal/metadata/generated_status.go index 94372e4579b1..2ab0fedbeb10 100644 --- a/receiver/splunkhecreceiver/internal/metadata/generated_status.go +++ b/receiver/splunkhecreceiver/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -11,3 +13,11 @@ const ( MetricsStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/splunkhecreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/splunkhecreceiver") +} diff --git a/receiver/sqlqueryreceiver/generated_component_test.go b/receiver/sqlqueryreceiver/generated_component_test.go new file mode 100644 index 000000000000..14c5c455d92b --- /dev/null +++ b/receiver/sqlqueryreceiver/generated_component_test.go @@ -0,0 +1,93 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package sqlqueryreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/sqlqueryreceiver/go.mod b/receiver/sqlqueryreceiver/go.mod index 2a10addb2092..d9026e706479 100644 --- a/receiver/sqlqueryreceiver/go.mod +++ b/receiver/sqlqueryreceiver/go.mod @@ -22,6 +22,8 @@ require ( go.opentelemetry.io/collector/extension v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -125,9 +127,7 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect - golang.org/x/crypto v0.16.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect diff --git a/receiver/sqlqueryreceiver/go.sum b/receiver/sqlqueryreceiver/go.sum index e2f0f46401e7..2910ba5a8fc9 100644 --- a/receiver/sqlqueryreceiver/go.sum +++ b/receiver/sqlqueryreceiver/go.sum @@ -373,8 +373,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= diff --git a/receiver/sqlqueryreceiver/internal/metadata/generated_status.go b/receiver/sqlqueryreceiver/internal/metadata/generated_status.go index f1ed4309364b..c8ed5cda33d1 100644 --- a/receiver/sqlqueryreceiver/internal/metadata/generated_status.go +++ b/receiver/sqlqueryreceiver/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -11,3 +13,11 @@ const ( MetricsStability = component.StabilityLevelAlpha LogsStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/sqlqueryreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/sqlqueryreceiver") +} diff --git a/receiver/sqlqueryreceiver/metadata.yaml b/receiver/sqlqueryreceiver/metadata.yaml index 5094a3ab8b44..a4df60be3553 100644 --- a/receiver/sqlqueryreceiver/metadata.yaml +++ b/receiver/sqlqueryreceiver/metadata.yaml @@ -7,4 +7,7 @@ status: development: [logs] distributions: [contrib, splunk, observiq, sumo] codeowners: - active: [dmitryax, pmcollins] \ No newline at end of file + active: [dmitryax, pmcollins] + +tests: + config: diff --git a/receiver/sqlserverreceiver/go.mod b/receiver/sqlserverreceiver/go.mod index dd11664c748c..a823a775ea96 100644 --- a/receiver/sqlserverreceiver/go.mod +++ b/receiver/sqlserverreceiver/go.mod @@ -13,6 +13,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -40,8 +42,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/receiver/sqlserverreceiver/internal/metadata/generated_status.go b/receiver/sqlserverreceiver/internal/metadata/generated_status.go index b21d07ebe250..560b048eda86 100644 --- a/receiver/sqlserverreceiver/internal/metadata/generated_status.go +++ b/receiver/sqlserverreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "sqlserver" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/sqlserverreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/sqlserverreceiver") +} diff --git a/receiver/sshcheckreceiver/generated_component_test.go b/receiver/sshcheckreceiver/generated_component_test.go new file mode 100644 index 000000000000..5f20f4cb44db --- /dev/null +++ b/receiver/sshcheckreceiver/generated_component_test.go @@ -0,0 +1,89 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package sshcheckreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + // TODO support lifecycle + t.SkipNow() + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/sshcheckreceiver/go.mod b/receiver/sshcheckreceiver/go.mod index f9700c0cf511..e1c2a050aa49 100644 --- a/receiver/sshcheckreceiver/go.mod +++ b/receiver/sshcheckreceiver/go.mod @@ -16,7 +16,7 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 go.uber.org/multierr v1.11.0 - golang.org/x/crypto v0.16.0 + golang.org/x/crypto v0.17.0 ) require ( @@ -50,8 +50,8 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/receiver/sshcheckreceiver/go.sum b/receiver/sshcheckreceiver/go.sum index 5beb41a2bfc3..c6f6bc2b1848 100644 --- a/receiver/sshcheckreceiver/go.sum +++ b/receiver/sshcheckreceiver/go.sum @@ -139,8 +139,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= diff --git a/receiver/sshcheckreceiver/internal/metadata/generated_status.go b/receiver/sshcheckreceiver/internal/metadata/generated_status.go index 0b93ac586923..a122b3e84b47 100644 --- a/receiver/sshcheckreceiver/internal/metadata/generated_status.go +++ b/receiver/sshcheckreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "sshcheck" MetricsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/sshcheckreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/sshcheckreceiver") +} diff --git a/receiver/sshcheckreceiver/metadata.yaml b/receiver/sshcheckreceiver/metadata.yaml index ee1a963698b0..5c510dc5591a 100644 --- a/receiver/sshcheckreceiver/metadata.yaml +++ b/receiver/sshcheckreceiver/metadata.yaml @@ -65,3 +65,7 @@ metrics: monotonic: false unit: "{error}" attributes: [error.message] + +tests: + config: + skip_lifecycle: true \ No newline at end of file diff --git a/receiver/statsdreceiver/config_test.go b/receiver/statsdreceiver/config_test.go index ecfb38ecc0e6..b9d726e0baca 100644 --- a/receiver/statsdreceiver/config_test.go +++ b/receiver/statsdreceiver/config_test.go @@ -93,6 +93,7 @@ func TestValidate(t *testing.T) { noObjectNameErr = "must specify object id for all TimerHistogramMappings" statsdTypeNotSupportErr = "statsd_type is not a supported mapping for histogram and timing metrics: %s" observerTypeNotSupportErr = "observer_type is not supported for histogram and timing metrics: %s" + invalidHistogramErr = "histogram configuration requires observer_type: histogram" ) tests := []test{ @@ -160,7 +161,7 @@ func TestValidate(t *testing.T) { }, }, }, - expectedErr: "histogram configuration requires observer_type: histogram", + expectedErr: invalidHistogramErr, }, { name: "negativeAggregationInterval", @@ -170,7 +171,7 @@ func TestValidate(t *testing.T) { {StatsdType: "timing", ObserverType: "gauge"}, }, }, - expectedErr: "aggregation_interval must be a positive duration", + expectedErr: negativeAggregationIntervalErr, }, } diff --git a/receiver/statsdreceiver/generated_component_test.go b/receiver/statsdreceiver/generated_component_test.go new file mode 100644 index 000000000000..9459e2b072e6 --- /dev/null +++ b/receiver/statsdreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package statsdreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/statsdreceiver/go.mod b/receiver/statsdreceiver/go.mod index 65f594c9ba46..a15f721396c3 100644 --- a/receiver/statsdreceiver/go.mod +++ b/receiver/statsdreceiver/go.mod @@ -15,6 +15,8 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/otel v1.21.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 gonum.org/v1/gonum v0.14.0 @@ -39,8 +41,6 @@ require ( go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/receiver/statsdreceiver/internal/metadata/generated_status.go b/receiver/statsdreceiver/internal/metadata/generated_status.go index 64492ec32c5e..9d41088e3918 100644 --- a/receiver/statsdreceiver/internal/metadata/generated_status.go +++ b/receiver/statsdreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "statsd" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/statsdreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/statsdreceiver") +} diff --git a/receiver/statsdreceiver/internal/transport/client/client.go b/receiver/statsdreceiver/internal/transport/client/client.go index 710aecc5e491..8b9fd7f06ba3 100644 --- a/receiver/statsdreceiver/internal/transport/client/client.go +++ b/receiver/statsdreceiver/internal/transport/client/client.go @@ -7,33 +7,25 @@ import ( "fmt" "io" "net" + "strings" ) // StatsD defines the properties of a StatsD connection. type StatsD struct { - Host string - Port int - Conn io.Writer + transport string + address string + conn io.Writer } -// Transport is an enum to select the type of transport. -type Transport int - -const ( - // TCP Transport - TCP Transport = iota - // UDP Transport - UDP -) - // NewStatsD creates a new StatsD instance to support the need for testing // the statsdreceiver package and is not intended/tested to be used in production. -func NewStatsD(transport Transport, host string, port int) (*StatsD, error) { +func NewStatsD(transport string, address string) (*StatsD, error) { statsd := &StatsD{ - Host: host, - Port: port, + transport: transport, + address: address, } - err := statsd.connect(transport) + + err := statsd.connect() if err != nil { return nil, err } @@ -41,56 +33,46 @@ func NewStatsD(transport Transport, host string, port int) (*StatsD, error) { return statsd, nil } -// connect populates the StatsD.Conn -func (s *StatsD) connect(transport Transport) error { - if cl, ok := s.Conn.(io.Closer); ok { - err := cl.Close() +// connect populates the StatsD.conn +func (s *StatsD) connect() error { + switch s.transport { + case "udp": + udpAddr, err := net.ResolveUDPAddr(s.transport, s.address) if err != nil { return err } - } - - address := fmt.Sprintf("%s:%d", s.Host, s.Port) - - var err error - switch transport { - case TCP: - s.Conn, err = net.Dial("tcp", address) - if err != nil { - return err - } - case UDP: - var udpAddr *net.UDPAddr - udpAddr, err = net.ResolveUDPAddr("udp", address) + s.conn, err = net.DialUDP(s.transport, nil, udpAddr) if err != nil { return err } - s.Conn, err = net.DialUDP("udp", nil, udpAddr) + case "tcp": + var err error + s.conn, err = net.Dial(s.transport, s.address) if err != nil { return err } default: - return fmt.Errorf("unknown transport: %d", transport) + return fmt.Errorf("unknown/unsupported transport: %s", s.transport) } - return err + return nil } -// Disconnect closes the StatsD.Conn. +// Disconnect closes the StatsD.conn. func (s *StatsD) Disconnect() error { var err error - if cl, ok := s.Conn.(io.Closer); ok { + if cl, ok := s.conn.(io.Closer); ok { err = cl.Close() } - s.Conn = nil + s.conn = nil return err } // SendMetric sends the input metric to the StatsD connection. func (s *StatsD) SendMetric(metric Metric) error { - _, err := fmt.Fprint(s.Conn, metric.String()) + _, err := io.Copy(s.conn, strings.NewReader(metric.String())) if err != nil { - return err + return fmt.Errorf("send metric on test client: %w", err) } return nil } diff --git a/receiver/statsdreceiver/internal/transport/server.go b/receiver/statsdreceiver/internal/transport/server.go index 3064fbef6c23..0466d2861a2a 100644 --- a/receiver/statsdreceiver/internal/transport/server.go +++ b/receiver/statsdreceiver/internal/transport/server.go @@ -8,8 +8,6 @@ import ( "net" "go.opentelemetry.io/collector/consumer" - - "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/statsdreceiver/internal/protocol" ) var errNilListenAndServeParameters = errors.New("no parameter of ListenAndServe can be nil") @@ -21,7 +19,6 @@ type Server interface { // on the specific transport, and prepares the message to be processed by // the Parser and passed to the next consumer. ListenAndServe( - p protocol.Parser, mc consumer.Metrics, r Reporter, transferChan chan<- Metric, diff --git a/receiver/statsdreceiver/internal/transport/server_test.go b/receiver/statsdreceiver/internal/transport/server_test.go index c92f4b373397..a774c0fd4154 100644 --- a/receiver/statsdreceiver/internal/transport/server_test.go +++ b/receiver/statsdreceiver/internal/transport/server_test.go @@ -4,9 +4,9 @@ package transport import ( + "io" "net" "runtime" - "strconv" "sync" "testing" "time" @@ -16,65 +16,43 @@ import ( "go.opentelemetry.io/collector/consumer/consumertest" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/testutil" - "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/statsdreceiver/internal/protocol" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/statsdreceiver/internal/transport/client" ) func Test_Server_ListenAndServe(t *testing.T) { tests := []struct { - name string - transport string - buildServerFn func(addr string) (Server, error) - buildClientFn func(host string, port int) (*client.StatsD, error) + name string + transport Transport + buildServerFn func(transport Transport, addr string) (Server, error) + getFreeEndpointFn func(t testing.TB, transport string) string + buildClientFn func(transport string, address string) (*client.StatsD, error) }{ { - name: "udp", - transport: "udp", - buildServerFn: NewUDPServer, - buildClientFn: func(host string, port int) (*client.StatsD, error) { - return client.NewStatsD(client.UDP, host, port) - }, + name: "udp", + transport: UDP, + getFreeEndpointFn: testutil.GetAvailableLocalNetworkAddress, + buildServerFn: NewUDPServer, + buildClientFn: client.NewStatsD, }, { - name: "tcp", - transport: "tcp", - buildServerFn: NewTCPServer, - buildClientFn: func(host string, port int) (*client.StatsD, error) { - return client.NewStatsD(client.TCP, host, port) - }, + name: "tcp", + transport: TCP, + getFreeEndpointFn: testutil.GetAvailableLocalNetworkAddress, + buildServerFn: NewTCPServer, + buildClientFn: client.NewStatsD, }, } + for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - addr := testutil.GetAvailableLocalNetworkAddress(t, tt.transport) - - if tt.transport == "udp" { - // Endpoint should be free. - ln0, err := net.ListenPacket("udp", addr) - require.NoError(t, err) - require.NotNil(t, ln0) - - // Ensure that the endpoint wasn't something like ":0" by checking that a second listener will fail. - ln1, err := net.ListenPacket("udp", addr) - require.Error(t, err) - require.Nil(t, ln1) + addr := tt.getFreeEndpointFn(t, tt.name) + testFreeEndpoint(t, tt.name, addr) - // Unbind the local address so the mock UDP service can use it - err = ln0.Close() - require.NoError(t, err) - } - - srv, err := tt.buildServerFn(addr) + srv, err := tt.buildServerFn(tt.transport, addr) require.NoError(t, err) require.NotNil(t, srv) - host, portStr, err := net.SplitHostPort(addr) - require.NoError(t, err) - port, err := strconv.Atoi(portStr) - require.NoError(t, err) - mc := new(consumertest.MetricsSink) - p := &protocol.StatsDParser{} require.NoError(t, err) mr := NewMockReporter(1) transferChan := make(chan Metric, 10) @@ -83,12 +61,12 @@ func Test_Server_ListenAndServe(t *testing.T) { wgListenAndServe.Add(1) go func() { defer wgListenAndServe.Done() - assert.Error(t, srv.ListenAndServe(p, mc, mr, transferChan)) + assert.Error(t, srv.ListenAndServe(mc, mr, transferChan)) }() runtime.Gosched() - gc, err := tt.buildClientFn(host, port) + gc, err := tt.buildClientFn(tt.transport.String(), addr) require.NoError(t, err) require.NotNil(t, gc) err = gc.SendMetric(client.Metric{ @@ -115,3 +93,36 @@ func Test_Server_ListenAndServe(t *testing.T) { }) } } + +func testFreeEndpoint(t *testing.T, transport string, address string) { + t.Helper() + + var ln0, ln1 io.Closer + var err0, err1 error + + trans := NewTransport(transport) + require.NotEqual(t, trans, Transport("")) + + if trans.IsPacketTransport() { + // Endpoint should be free. + ln0, err0 = net.ListenPacket(transport, address) + ln1, err1 = net.ListenPacket(transport, address) + } + + if trans.IsStreamTransport() { + // Endpoint should be free. + ln0, err0 = net.Listen(transport, address) + ln1, err1 = net.Listen(transport, address) + } + + // Endpoint should be free. + require.NoError(t, err0) + require.NotNil(t, ln0) + + // Ensure that the endpoint wasn't something like ":0" by checking that a second listener will fail. + require.Error(t, err1) + require.Nil(t, ln1) + + // Unbind the local address so the mock UDP service can use it + require.NoError(t, ln0.Close()) +} diff --git a/receiver/statsdreceiver/internal/transport/tcp_server.go b/receiver/statsdreceiver/internal/transport/tcp_server.go index a464b1927c88..f776bcd88f04 100644 --- a/receiver/statsdreceiver/internal/transport/tcp_server.go +++ b/receiver/statsdreceiver/internal/transport/tcp_server.go @@ -6,43 +6,50 @@ package transport // import "github.com/open-telemetry/opentelemetry-collector-c import ( "bytes" "errors" + "fmt" "io" "net" "strings" "sync" "go.opentelemetry.io/collector/consumer" - - "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/statsdreceiver/internal/protocol" ) var errTCPServerDone = errors.New("server stopped") type tcpServer struct { - listener net.Listener - reporter Reporter - wg sync.WaitGroup - stopChan chan struct{} + listener net.Listener + reporter Reporter + wg sync.WaitGroup + transport Transport + stopChan chan struct{} } +// Ensure that Server is implemented on TCP Server. var _ Server = (*tcpServer)(nil) // NewTCPServer creates a transport.Server using TCP as its transport. -func NewTCPServer(addr string) (Server, error) { - l, err := net.Listen("tcp", addr) - if err != nil { - return nil, err +func NewTCPServer(transport Transport, address string) (Server, error) { + var tsrv tcpServer + var err error + + if !transport.IsStreamTransport() { + return nil, fmt.Errorf("NewTCPServer with %s: %w", transport.String(), ErrUnsupportedStreamTransport) } - t := tcpServer{ - listener: l, - stopChan: make(chan struct{}), + tsrv.transport = transport + tsrv.listener, err = net.Listen(transport.String(), address) + if err != nil { + return nil, fmt.Errorf("starting to listen %s socket: %w", transport.String(), err) } - return &t, nil + + tsrv.stopChan = make(chan struct{}) + return &tsrv, nil } -func (t *tcpServer) ListenAndServe(parser protocol.Parser, nextConsumer consumer.Metrics, reporter Reporter, transferChan chan<- Metric) error { - if parser == nil || nextConsumer == nil || reporter == nil { +// ListenAndServe starts the server ready to receive metrics. +func (t *tcpServer) ListenAndServe(nextConsumer consumer.Metrics, reporter Reporter, transferChan chan<- Metric) error { + if nextConsumer == nil || reporter == nil { return errNilListenAndServeParameters } @@ -71,6 +78,7 @@ LOOP: return errTCPServerDone } +// handleConn is helper that parses the buffer and split it line by line to be parsed upstream. func (t *tcpServer) handleConn(c net.Conn, transferChan chan<- Metric) { payload := make([]byte, 4096) var remainder []byte @@ -98,6 +106,7 @@ func (t *tcpServer) handleConn(c net.Conn, transferChan chan<- Metric) { } } +// Close closes the server. func (t *tcpServer) Close() error { close(t.stopChan) t.wg.Wait() diff --git a/receiver/statsdreceiver/internal/transport/transport.go b/receiver/statsdreceiver/internal/transport/transport.go new file mode 100644 index 000000000000..c065e30c746f --- /dev/null +++ b/receiver/statsdreceiver/internal/transport/transport.go @@ -0,0 +1,63 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package transport // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/statsdreceiver/internal/transport" + +import "errors" + +// Transport is a set of constants of the transport supported by this receiver. +type Transport string + +var ( + ErrUnsupportedTransport = errors.New("unsupported transport") + ErrUnsupportedPacketTransport = errors.New("unsupported Packet transport") + ErrUnsupportedStreamTransport = errors.New("unsupported Stream transport") +) + +const ( + UDP Transport = "udp" + UDP4 Transport = "udp4" + UDP6 Transport = "udp6" + TCP Transport = "tcp" + TCP4 Transport = "tcp4" + TCP6 Transport = "tcp6" +) + +// NewTransport creates a Transport based on the transport string or returns an empty Transport. +func NewTransport(ts string) Transport { + trans := Transport(ts) + switch trans { + case UDP, UDP4, UDP6: + return trans + case TCP, TCP4, TCP6: + return trans + } + return Transport("") +} + +// String casts the transport to a String if the Transport is supported. Return an empty Transport overwise. +func (trans Transport) String() string { + switch trans { + case UDP, UDP4, UDP6, TCP, TCP4, TCP6: + return string(trans) + } + return "" +} + +// IsPacketTransport returns true if the transport is packet based. +func (trans Transport) IsPacketTransport() bool { + switch trans { + case UDP, UDP4, UDP6: + return true + } + return false +} + +// IsStreamTransport returns true if the transport is stream based. +func (trans Transport) IsStreamTransport() bool { + switch trans { + case TCP, TCP4, TCP6: + return true + } + return false +} diff --git a/receiver/statsdreceiver/internal/transport/udp_server.go b/receiver/statsdreceiver/internal/transport/udp_server.go index 7a483ce61649..19ad0803d8fe 100644 --- a/receiver/statsdreceiver/internal/transport/udp_server.go +++ b/receiver/statsdreceiver/internal/transport/udp_server.go @@ -6,47 +6,49 @@ package transport // import "github.com/open-telemetry/opentelemetry-collector-c import ( "bytes" "errors" + "fmt" "io" "net" "strings" "go.opentelemetry.io/collector/consumer" - - "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/statsdreceiver/internal/protocol" ) type udpServer struct { packetConn net.PacketConn - reporter Reporter + transport Transport } +// Ensure that Server is implemented on UDP Server. var _ (Server) = (*udpServer)(nil) // NewUDPServer creates a transport.Server using UDP as its transport. -func NewUDPServer(addr string) (Server, error) { - packetConn, err := net.ListenPacket("udp", addr) - if err != nil { - return nil, err +func NewUDPServer(transport Transport, address string) (Server, error) { + if !transport.IsPacketTransport() { + return nil, fmt.Errorf("NewUDPServer with %s: %w", transport.String(), ErrUnsupportedPacketTransport) } - u := udpServer{ - packetConn: packetConn, + conn, err := net.ListenPacket(transport.String(), address) + if err != nil { + return nil, fmt.Errorf("starting to listen %s socket: %w", transport.String(), err) } - return &u, nil + + return &udpServer{ + packetConn: conn, + transport: transport, + }, nil } +// ListenAndServe starts the server ready to receive metrics. func (u *udpServer) ListenAndServe( - parser protocol.Parser, nextConsumer consumer.Metrics, reporter Reporter, transferChan chan<- Metric, ) error { - if parser == nil || nextConsumer == nil || reporter == nil { + if nextConsumer == nil || reporter == nil { return errNilListenAndServeParameters } - u.reporter = reporter - buf := make([]byte, 65527) // max size for udp packet body (assuming ipv6) for { n, addr, err := u.packetConn.ReadFrom(buf) @@ -56,7 +58,8 @@ func (u *udpServer) ListenAndServe( u.handlePacket(bufCopy, addr, transferChan) } if err != nil { - u.reporter.OnDebugf("UDP Transport (%s) - ReadFrom error: %v", + reporter.OnDebugf("%s Transport (%s) - ReadFrom error: %v", + u.transport, u.packetConn.LocalAddr(), err) var netErr net.Error @@ -70,10 +73,12 @@ func (u *udpServer) ListenAndServe( } } +// Close closes the server. func (u *udpServer) Close() error { return u.packetConn.Close() } +// handlePacket is helper that parses the buffer and split it line by line to be parsed upstream. func (u *udpServer) handlePacket( data []byte, addr net.Addr, diff --git a/receiver/statsdreceiver/metadata.yaml b/receiver/statsdreceiver/metadata.yaml index cd17f73b5133..d11d7b216244 100644 --- a/receiver/statsdreceiver/metadata.yaml +++ b/receiver/statsdreceiver/metadata.yaml @@ -6,4 +6,7 @@ status: beta: [metrics] distributions: [contrib, splunk, sumo, aws] codeowners: - active: [jmacd, dmitryax] \ No newline at end of file + active: [jmacd, dmitryax] + +tests: + config: diff --git a/receiver/statsdreceiver/receiver.go b/receiver/statsdreceiver/receiver.go index 3034fc561bbc..de61a6537ee7 100644 --- a/receiver/statsdreceiver/receiver.go +++ b/receiver/statsdreceiver/receiver.go @@ -68,12 +68,13 @@ func newReceiver( } func buildTransportServer(config Config) (transport.Server, error) { - // TODO: Add TCP/unix socket transport implementations - switch strings.ToLower(config.NetAddr.Transport) { - case "", "udp": - return transport.NewUDPServer(config.NetAddr.Endpoint) - case "tcp": - return transport.NewTCPServer(config.NetAddr.Endpoint) + // TODO: Add unix socket transport implementations + trans := transport.NewTransport(strings.ToLower(config.NetAddr.Transport)) + switch trans { + case transport.UDP, transport.UDP4, transport.UDP6: + return transport.NewUDPServer(trans, config.NetAddr.Endpoint) + case transport.TCP, transport.TCP4, transport.TCP6: + return transport.NewTCPServer(trans, config.NetAddr.Endpoint) } return nil, fmt.Errorf("unsupported transport %q", config.NetAddr.Transport) @@ -99,7 +100,7 @@ func (r *statsdReceiver) Start(ctx context.Context, host component.Host) error { return err } go func() { - if err := r.server.ListenAndServe(r.parser, r.nextConsumer, r.reporter, transferChan); err != nil { + if err := r.server.ListenAndServe(r.nextConsumer, r.reporter, transferChan); err != nil { if !errors.Is(err, net.ErrClosed) { host.ReportFatalError(err) } diff --git a/receiver/statsdreceiver/receiver_test.go b/receiver/statsdreceiver/receiver_test.go index 77f49c49008e..ec2b5cb90942 100644 --- a/receiver/statsdreceiver/receiver_test.go +++ b/receiver/statsdreceiver/receiver_test.go @@ -6,8 +6,6 @@ package statsdreceiver import ( "context" "errors" - "net" - "strconv" "testing" "time" @@ -113,19 +111,15 @@ func TestStatsdReceiver_Flush(t *testing.T) { } func Test_statsdreceiver_EndToEnd(t *testing.T) { - addr := testutil.GetAvailableLocalAddress(t) - host, portStr, err := net.SplitHostPort(addr) - require.NoError(t, err) - port, err := strconv.Atoi(portStr) - require.NoError(t, err) - tests := []struct { name string + addr string configFn func() *Config - clientFn func(t *testing.T) *client.StatsD + clientFn func(t *testing.T, addr string) *client.StatsD }{ { name: "default_config with 4s interval", + addr: testutil.GetAvailableLocalNetworkAddress(t, "udp"), configFn: func() *Config { return &Config{ NetAddr: confignet.NetAddr{ @@ -135,8 +129,8 @@ func Test_statsdreceiver_EndToEnd(t *testing.T) { AggregationInterval: 4 * time.Second, } }, - clientFn: func(t *testing.T) *client.StatsD { - c, err := client.NewStatsD(client.UDP, host, port) + clientFn: func(t *testing.T, addr string) *client.StatsD { + c, err := client.NewStatsD("udp", addr) require.NoError(t, err) return c }, @@ -145,7 +139,7 @@ func Test_statsdreceiver_EndToEnd(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { cfg := tt.configFn() - cfg.NetAddr.Endpoint = addr + cfg.NetAddr.Endpoint = tt.addr sink := new(consumertest.MetricsSink) rcv, err := newReceiver(receivertest.NewNopCreateSettings(), *cfg, sink) require.NoError(t, err) @@ -159,7 +153,7 @@ func Test_statsdreceiver_EndToEnd(t *testing.T) { assert.NoError(t, r.Shutdown(context.Background())) }() - statsdClient := tt.clientFn(t) + statsdClient := tt.clientFn(t, tt.addr) statsdMetric := client.Metric{ Name: "test.metric", diff --git a/receiver/syslogreceiver/generated_component_test.go b/receiver/syslogreceiver/generated_component_test.go new file mode 100644 index 000000000000..867d42b39bef --- /dev/null +++ b/receiver/syslogreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package syslogreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/syslogreceiver/go.mod b/receiver/syslogreceiver/go.mod index b206631137c9..592b74fb0b08 100644 --- a/receiver/syslogreceiver/go.mod +++ b/receiver/syslogreceiver/go.mod @@ -11,6 +11,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 ) require ( @@ -43,8 +45,6 @@ require ( go.opentelemetry.io/collector/extension v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/net v0.18.0 // indirect diff --git a/receiver/syslogreceiver/internal/metadata/generated_status.go b/receiver/syslogreceiver/internal/metadata/generated_status.go index 7b226c8c8706..44cfcd27eb85 100644 --- a/receiver/syslogreceiver/internal/metadata/generated_status.go +++ b/receiver/syslogreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "syslog" LogsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/syslogreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/syslogreceiver") +} diff --git a/receiver/syslogreceiver/metadata.yaml b/receiver/syslogreceiver/metadata.yaml index 2374df77559a..85cce455dcec 100644 --- a/receiver/syslogreceiver/metadata.yaml +++ b/receiver/syslogreceiver/metadata.yaml @@ -7,3 +7,9 @@ status: distributions: [contrib, splunk, observiq, sumo] codeowners: active: [djaglowski] + +tests: + config: + tcp: + listen_address: "localhost:0" + protocol: "rfc5424" diff --git a/receiver/tcplogreceiver/generated_component_test.go b/receiver/tcplogreceiver/generated_component_test.go new file mode 100644 index 000000000000..ec6079237ac2 --- /dev/null +++ b/receiver/tcplogreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package tcplogreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/tcplogreceiver/go.mod b/receiver/tcplogreceiver/go.mod index a7e59b18fcea..a2ad264294f8 100644 --- a/receiver/tcplogreceiver/go.mod +++ b/receiver/tcplogreceiver/go.mod @@ -9,6 +9,8 @@ require ( go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 ) require ( @@ -43,8 +45,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/pdata v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/net v0.18.0 // indirect diff --git a/receiver/tcplogreceiver/internal/metadata/generated_status.go b/receiver/tcplogreceiver/internal/metadata/generated_status.go index 9923ae161e9b..7ce1c6031dd2 100644 --- a/receiver/tcplogreceiver/internal/metadata/generated_status.go +++ b/receiver/tcplogreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "tcplog" LogsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/tcplogreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/tcplogreceiver") +} diff --git a/receiver/tcplogreceiver/metadata.yaml b/receiver/tcplogreceiver/metadata.yaml index 8f95bbe11e2f..16a13846b5b3 100644 --- a/receiver/tcplogreceiver/metadata.yaml +++ b/receiver/tcplogreceiver/metadata.yaml @@ -7,3 +7,7 @@ status: distributions: [contrib, splunk, observiq, sumo] codeowners: active: [djaglowski] + +tests: + config: + listen_address: "localhost:0" diff --git a/receiver/udplogreceiver/generated_component_test.go b/receiver/udplogreceiver/generated_component_test.go new file mode 100644 index 000000000000..eddde3ae2f6a --- /dev/null +++ b/receiver/udplogreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package udplogreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/udplogreceiver/go.mod b/receiver/udplogreceiver/go.mod index 677526ffe746..2017de4bfc03 100644 --- a/receiver/udplogreceiver/go.mod +++ b/receiver/udplogreceiver/go.mod @@ -9,6 +9,8 @@ require ( go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 ) require ( @@ -39,8 +41,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/pdata v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/net v0.18.0 // indirect diff --git a/receiver/udplogreceiver/internal/metadata/generated_status.go b/receiver/udplogreceiver/internal/metadata/generated_status.go index 152e240218de..9c3ccab41099 100644 --- a/receiver/udplogreceiver/internal/metadata/generated_status.go +++ b/receiver/udplogreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "udplog" LogsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/udplogreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/udplogreceiver") +} diff --git a/receiver/udplogreceiver/metadata.yaml b/receiver/udplogreceiver/metadata.yaml index a97e4062a039..174d176de961 100644 --- a/receiver/udplogreceiver/metadata.yaml +++ b/receiver/udplogreceiver/metadata.yaml @@ -6,4 +6,8 @@ status: alpha: [logs] distributions: [contrib, observiq, sumo, splunk] codeowners: - active: [djaglowski] \ No newline at end of file + active: [djaglowski] + +tests: + config: + listen_address: "localhost:0" diff --git a/receiver/vcenterreceiver/generated_component_test.go b/receiver/vcenterreceiver/generated_component_test.go new file mode 100644 index 000000000000..8b79f632ff41 --- /dev/null +++ b/receiver/vcenterreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package vcenterreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/vcenterreceiver/go.mod b/receiver/vcenterreceiver/go.mod index 0f33e40dd791..3fda3ccb59b6 100644 --- a/receiver/vcenterreceiver/go.mod +++ b/receiver/vcenterreceiver/go.mod @@ -18,6 +18,8 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -78,8 +80,6 @@ require ( go.opentelemetry.io/collector v0.91.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.18.0 // indirect diff --git a/receiver/vcenterreceiver/internal/metadata/generated_status.go b/receiver/vcenterreceiver/internal/metadata/generated_status.go index 090b6a5cfbcb..55e6ec944f65 100644 --- a/receiver/vcenterreceiver/internal/metadata/generated_status.go +++ b/receiver/vcenterreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "vcenter" MetricsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/vcenterreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/vcenterreceiver") +} diff --git a/receiver/vcenterreceiver/metadata.yaml b/receiver/vcenterreceiver/metadata.yaml index 3bbaefd58ac5..55cfebf3095b 100644 --- a/receiver/vcenterreceiver/metadata.yaml +++ b/receiver/vcenterreceiver/metadata.yaml @@ -421,3 +421,6 @@ metrics: gauge: value_type: double attributes: [] + +tests: + config: diff --git a/receiver/wavefrontreceiver/generated_component_test.go b/receiver/wavefrontreceiver/generated_component_test.go new file mode 100644 index 000000000000..ba0c42949b56 --- /dev/null +++ b/receiver/wavefrontreceiver/generated_component_test.go @@ -0,0 +1,89 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package wavefrontreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + // TODO support lifecycle + t.SkipNow() + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/wavefrontreceiver/go.mod b/receiver/wavefrontreceiver/go.mod index e7a4f82f80b5..9441a4e4ea93 100644 --- a/receiver/wavefrontreceiver/go.mod +++ b/receiver/wavefrontreceiver/go.mod @@ -13,6 +13,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 ) require ( @@ -35,8 +37,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/net v0.18.0 // indirect diff --git a/receiver/wavefrontreceiver/internal/metadata/generated_status.go b/receiver/wavefrontreceiver/internal/metadata/generated_status.go index 3391a063223a..9536a060f539 100644 --- a/receiver/wavefrontreceiver/internal/metadata/generated_status.go +++ b/receiver/wavefrontreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "wavefront" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/wavefrontreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/wavefrontreceiver") +} diff --git a/receiver/wavefrontreceiver/metadata.yaml b/receiver/wavefrontreceiver/metadata.yaml index 2ced88b5ae76..d6829633cbf2 100644 --- a/receiver/wavefrontreceiver/metadata.yaml +++ b/receiver/wavefrontreceiver/metadata.yaml @@ -8,3 +8,6 @@ status: codeowners: active: [samiura] +tests: + config: + skip_lifecycle: true diff --git a/receiver/webhookeventreceiver/generated_component_test.go b/receiver/webhookeventreceiver/generated_component_test.go new file mode 100644 index 000000000000..2414230af5b6 --- /dev/null +++ b/receiver/webhookeventreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package webhookeventreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "logs", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateLogsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/webhookeventreceiver/go.mod b/receiver/webhookeventreceiver/go.mod index c83e11ae1068..02312729fd05 100644 --- a/receiver/webhookeventreceiver/go.mod +++ b/receiver/webhookeventreceiver/go.mod @@ -12,6 +12,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -50,8 +52,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/receiver/webhookeventreceiver/internal/metadata/generated_status.go b/receiver/webhookeventreceiver/internal/metadata/generated_status.go index e0bb6684022d..21f22f088068 100644 --- a/receiver/webhookeventreceiver/internal/metadata/generated_status.go +++ b/receiver/webhookeventreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "webhookevent" LogsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/webhookeventreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/webhookeventreceiver") +} diff --git a/receiver/webhookeventreceiver/metadata.yaml b/receiver/webhookeventreceiver/metadata.yaml index a7c2d384a3ba..552b9167c333 100644 --- a/receiver/webhookeventreceiver/metadata.yaml +++ b/receiver/webhookeventreceiver/metadata.yaml @@ -8,3 +8,7 @@ status: codeowners: active: ["atoulme", "shalper2"] emeritus: + +tests: + config: + endpoint: 127.0.0.1:8088 diff --git a/receiver/windowseventlogreceiver/go.mod b/receiver/windowseventlogreceiver/go.mod index 8bbf69c2f8f3..52c2fcbe576e 100644 --- a/receiver/windowseventlogreceiver/go.mod +++ b/receiver/windowseventlogreceiver/go.mod @@ -10,6 +10,8 @@ require ( go.opentelemetry.io/collector/confmap v0.91.0 go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 golang.org/x/sys v0.15.0 ) @@ -40,8 +42,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/collector/pdata v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/net v0.18.0 // indirect diff --git a/receiver/windowseventlogreceiver/internal/metadata/generated_status.go b/receiver/windowseventlogreceiver/internal/metadata/generated_status.go index 7e14474db9f7..9bd1d0745cbc 100644 --- a/receiver/windowseventlogreceiver/internal/metadata/generated_status.go +++ b/receiver/windowseventlogreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "windowseventlog" LogsStability = component.StabilityLevelAlpha ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/windowseventlogreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/windowseventlogreceiver") +} diff --git a/receiver/windowsperfcountersreceiver/go.mod b/receiver/windowsperfcountersreceiver/go.mod index 0b5cb0c8503a..61a4fe738cba 100644 --- a/receiver/windowsperfcountersreceiver/go.mod +++ b/receiver/windowsperfcountersreceiver/go.mod @@ -12,6 +12,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 ) @@ -38,8 +40,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/receiver/windowsperfcountersreceiver/internal/metadata/generated_status.go b/receiver/windowsperfcountersreceiver/internal/metadata/generated_status.go index 6c7b3498afe4..9d64e7682bde 100644 --- a/receiver/windowsperfcountersreceiver/internal/metadata/generated_status.go +++ b/receiver/windowsperfcountersreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "windowsperfcounters" MetricsStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/windowsperfcountersreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/windowsperfcountersreceiver") +} diff --git a/receiver/zipkinreceiver/generated_component_test.go b/receiver/zipkinreceiver/generated_component_test.go new file mode 100644 index 000000000000..29e50744a760 --- /dev/null +++ b/receiver/zipkinreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package zipkinreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "traces", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/zipkinreceiver/go.mod b/receiver/zipkinreceiver/go.mod index a8b94fe18f30..aef69ccee703 100644 --- a/receiver/zipkinreceiver/go.mod +++ b/receiver/zipkinreceiver/go.mod @@ -15,6 +15,8 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/semconv v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 google.golang.org/protobuf v1.31.0 ) @@ -54,8 +56,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/net v0.19.0 // indirect diff --git a/receiver/zipkinreceiver/internal/metadata/generated_status.go b/receiver/zipkinreceiver/internal/metadata/generated_status.go index 7304d293cd3f..f06a4a308a90 100644 --- a/receiver/zipkinreceiver/internal/metadata/generated_status.go +++ b/receiver/zipkinreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "zipkin" TracesStability = component.StabilityLevelBeta ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/zipkinreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/zipkinreceiver") +} diff --git a/receiver/zipkinreceiver/metadata.yaml b/receiver/zipkinreceiver/metadata.yaml index 0228140f6fb5..e0c7eadb0b3d 100644 --- a/receiver/zipkinreceiver/metadata.yaml +++ b/receiver/zipkinreceiver/metadata.yaml @@ -16,3 +16,6 @@ status: - liatrio codeowners: active: [MovieStoreGuy, astencel-sumo, crobert-1] + +tests: + config: diff --git a/receiver/zookeeperreceiver/generated_component_test.go b/receiver/zookeeperreceiver/generated_component_test.go new file mode 100644 index 000000000000..da3140141258 --- /dev/null +++ b/receiver/zookeeperreceiver/generated_component_test.go @@ -0,0 +1,86 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package zookeeperreceiver + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/receivertest" + + "go.opentelemetry.io/collector/confmap/confmaptest" +) + +// assertNoErrorHost implements a component.Host that asserts that there were no errors. +type assertNoErrorHost struct { + component.Host + *testing.T +} + +var _ component.Host = (*assertNoErrorHost)(nil) + +// newAssertNoErrorHost returns a new instance of assertNoErrorHost. +func newAssertNoErrorHost(t *testing.T) component.Host { + return &assertNoErrorHost{ + componenttest.NewNopHost(), + t, + } +} + +func (aneh *assertNoErrorHost) ReportFatalError(err error) { + assert.NoError(aneh, err) +} + +func Test_ComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) + }{ + + { + name: "metrics", + createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { + return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, component.UnmarshalConfig(sub, cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + + t.Run(test.name+"-lifecycle", func(t *testing.T) { + + firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + host := newAssertNoErrorHost(t) + require.NoError(t, err) + require.NoError(t, firstRcvr.Start(context.Background(), host)) + require.NoError(t, firstRcvr.Shutdown(context.Background())) + secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) + require.NoError(t, err) + require.NoError(t, secondRcvr.Start(context.Background(), host)) + require.NoError(t, secondRcvr.Shutdown(context.Background())) + }) + } +} diff --git a/receiver/zookeeperreceiver/go.mod b/receiver/zookeeperreceiver/go.mod index 553a7b34d433..fb2851bed3c4 100644 --- a/receiver/zookeeperreceiver/go.mod +++ b/receiver/zookeeperreceiver/go.mod @@ -16,6 +16,8 @@ require ( go.opentelemetry.io/collector/consumer v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 + go.opentelemetry.io/otel/metric v1.21.0 + go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/zap v1.26.0 ) @@ -73,8 +75,6 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect golang.org/x/mod v0.14.0 // indirect diff --git a/receiver/zookeeperreceiver/internal/metadata/generated_status.go b/receiver/zookeeperreceiver/internal/metadata/generated_status.go index b19c024c2827..d3c5cf2350b9 100644 --- a/receiver/zookeeperreceiver/internal/metadata/generated_status.go +++ b/receiver/zookeeperreceiver/internal/metadata/generated_status.go @@ -4,9 +4,19 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( Type = "zookeeper" MetricsStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/zookeeperreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/zookeeperreceiver") +} diff --git a/receiver/zookeeperreceiver/metadata.yaml b/receiver/zookeeperreceiver/metadata.yaml index 0020aa2d72ee..9d86b310e2e1 100644 --- a/receiver/zookeeperreceiver/metadata.yaml +++ b/receiver/zookeeperreceiver/metadata.yaml @@ -153,3 +153,6 @@ metrics: unit: 1 gauge: value_type: int + +tests: + config: diff --git a/testbed/go.mod b/testbed/go.mod index 8024c7223a62..833ec4490663 100644 --- a/testbed/go.mod +++ b/testbed/go.mod @@ -243,7 +243,7 @@ require ( go.opentelemetry.io/otel/trace v1.21.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect go.uber.org/atomic v1.11.0 // indirect - golang.org/x/crypto v0.16.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect diff --git a/testbed/go.sum b/testbed/go.sum index 257f15ca1e3d..6f88e9b88c99 100644 --- a/testbed/go.sum +++ b/testbed/go.sum @@ -755,8 +755,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=