diff --git a/.chloggen/awsmef_reduceResourceLogging.yaml b/.chloggen/awsmef_reduceResourceLogging.yaml new file mode 100755 index 000000000000..c45cf8310c0d --- /dev/null +++ b/.chloggen/awsmef_reduceResourceLogging.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: awsemfexporter + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Logs relating to the start and finish of processing metrics have been reduced to debug level + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [29337] + +# (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] diff --git a/.chloggen/datadogreceiver-api-v02-traces.yaml b/.chloggen/datadogreceiver-api-v02-traces.yaml new file mode 100755 index 000000000000..9917488114df --- /dev/null +++ b/.chloggen/datadogreceiver-api-v02-traces.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: datadogreceiver + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: "The datadogreceiver supports the new datadog protocol that is sent by the datadog agent API/v0.2/traces." + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [27045] + +# (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/feat-26990-cfgmetadatagen.yaml b/.chloggen/feat-26990-cfgmetadatagen.yaml new file mode 100755 index 000000000000..384d19d9d908 --- /dev/null +++ b/.chloggen/feat-26990-cfgmetadatagen.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: configschema + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Generate metadata for connectors. + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [26990] + +# (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/metric-conversion-context.yaml b/.chloggen/metric-conversion-context.yaml new file mode 100755 index 000000000000..27772a727518 --- /dev/null +++ b/.chloggen/metric-conversion-context.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: processor/transform + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Convert between sum and gauge in metric context when alpha feature gate `processor.transform.ConvertBetweenSumAndGaugeMetricContext` enabled + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [20773] + +# (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] diff --git a/.github/workflows/scripts/add-component-options.sh b/.github/workflows/scripts/add-component-options.sh deleted file mode 100755 index 372d72024c5f..000000000000 --- a/.github/workflows/scripts/add-component-options.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env sh -# -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 -# -# Takes the list of components from the CODEOWNERS file and inserts them -# as a YAML list in a GitHub issue template, then prints out the resulting -# contents. -# -# Note that this is script is intended to be POSIX-compliant since it is -# intended to also be called from the Makefile on developer machines, -# which aren't guaranteed to have Bash or a GNU userland installed. - -if [ -z "${FILE}" ]; then - echo 'FILE is empty, please ensure it is set.' - exit 1 -fi - -CUR_DIRECTORY=$(dirname "$0") - -# Get the line number for text within a file -get_line_number() { - text=$1 - file=$2 - - grep -n "${text}" "${file}" | awk '{ print $1 }' | grep -oE '[0-9]+' -} - -LABELS="" - -START_LINE=$(get_line_number '# Start Collector components list' "${FILE}") -END_LINE=$(get_line_number '# End Collector components list' "${FILE}") -TOTAL_LINES=$(wc -l "${FILE}" | awk '{ print $1 }') - -head -n "${START_LINE}" "${FILE}" -for COMPONENT in $(sh "${CUR_DIRECTORY}/get-components.sh"); do - TYPE=$(echo "${COMPONENT}" | cut -f1 -d'/') - REST=$(echo "${COMPONENT}" | cut -f2- -d'/' | sed "s%${TYPE}/%/%" | sed "s%${TYPE}\$%%") - LABEL="" - - if [ -z "${TYPE}" ] | [ -z "${REST}" ]; then - LABEL="${COMPONENT}" - else - LABEL="${TYPE}/${REST}" - fi - - LABELS="${LABELS}${LABEL}\n" -done -printf "${LABELS}" | sort | awk '{ printf " - %s\n",$1 }' -tail -n $((TOTAL_LINES-END_LINE+1)) "${FILE}" - diff --git a/Makefile b/Makefile index e9737e3a5171..e6c40f8d8f0b 100644 --- a/Makefile +++ b/Makefile @@ -146,7 +146,7 @@ DEPENDABOT_PATH=".github/dependabot.yml" .PHONY: gendependabot gendependabot: cd cmd/githubgen && $(GOCMD) install . - githubgen -dependabot + githubgen dependabot # Define a delegation target for each module @@ -398,10 +398,5 @@ genconfigdocs: .PHONY: generate-gh-issue-templates generate-gh-issue-templates: - for FILE in bug_report feature_request other; do \ - YAML_FILE=".github/ISSUE_TEMPLATE/$${FILE}.yaml"; \ - TMP_FILE=".github/ISSUE_TEMPLATE/$${FILE}.yaml.tmp"; \ - cat "$${YAML_FILE}" > "$${TMP_FILE}"; \ - FILE="$${TMP_FILE}" ./.github/workflows/scripts/add-component-options.sh > "$${YAML_FILE}"; \ - rm "$${TMP_FILE}"; \ - done + cd cmd/githubgen && $(GOCMD) install . + githubgen issue-templates diff --git a/cmd/configschema/cfgmetadatagen/cfgmetadatagen/cli.go b/cmd/configschema/cfgmetadatagen/cfgmetadatagen/cli.go index 6fc9a20a09b1..426c3f7394a5 100644 --- a/cmd/configschema/cfgmetadatagen/cfgmetadatagen/cli.go +++ b/cmd/configschema/cfgmetadatagen/cfgmetadatagen/cli.go @@ -31,7 +31,7 @@ func GenerateFiles(factories otelcol.Factories, sourceDir string, outputDir stri func writeComponentYAML(yw metadataWriter, cfg configschema.CfgInfo, dr configschema.DirResolver) error { fields, err := configschema.ReadFields(reflect.ValueOf(cfg.CfgInstance), dr) if err != nil { - return fmt.Errorf("error reading fields for component: %w", err) + return fmt.Errorf("error reading fields for component %v/%v: %w", cfg.Group, cfg.Type, err) } yamlBytes, err := yaml.Marshal(fields) if err != nil { diff --git a/cmd/configschema/configs.go b/cmd/configschema/configs.go index 62bd9f00a87a..e59b904b2779 100644 --- a/cmd/configschema/configs.go +++ b/cmd/configschema/configs.go @@ -113,6 +113,16 @@ func GetCfgInfo(components otelcol.Factories, componentType, componentName strin Group: componentType, CfgInstance: f.CreateDefaultConfig(), }, nil + case connector: + f := components.Connectors[t] + if f == nil { + return CfgInfo{}, fmt.Errorf("unknown %s name %q", componentType, componentName) + } + return CfgInfo{ + Type: f.Type(), + Group: componentType, + CfgInstance: f.CreateDefaultConfig(), + }, nil case extension: f := components.Extensions[t] if f == nil { diff --git a/cmd/configschema/go.mod b/cmd/configschema/go.mod index e1c7eb3a46a9..d265184b4dae 100644 --- a/cmd/configschema/go.mod +++ b/cmd/configschema/go.mod @@ -235,7 +235,7 @@ require ( github.com/DataDog/sketches-go v1.4.3 // indirect github.com/DataDog/zstd v1.5.2 // indirect github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962 // indirect - github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.20.0 // indirect + github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.21.0 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector v0.45.0 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector/googlemanagedprometheus v0.45.0 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.21.0 // indirect @@ -310,7 +310,7 @@ require ( github.com/digitalocean/godo v1.104.1 // 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.1-0.20210727194412-58542c764a11 // indirect + github.com/docker/go-connections v0.4.1-0.20231110212414-fa09c952e3ea // indirect github.com/docker/go-units v0.5.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.5.0 // indirect @@ -324,7 +324,7 @@ require ( github.com/envoyproxy/go-control-plane v0.11.1 // indirect github.com/envoyproxy/protoc-gen-validate v1.0.2 // indirect github.com/euank/go-kmsg-parser v2.0.0+incompatible // indirect - github.com/facebook/time v0.0.0-20220713225404-f7a0d7702d50 // indirect + github.com/facebook/time v0.0.0-20231108195549-620e14e718fb // indirect github.com/fatih/color v1.15.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/form3tech-oss/jwt-go v3.2.5+incompatible // indirect @@ -471,6 +471,12 @@ require ( github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect github.com/nginxinc/nginx-prometheus-exporter v0.8.1-0.20201110005315-f5a5f8086c19 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/connector/countconnector v0.89.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/connector/datadogconnector v0.89.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/connector/exceptionsconnector v0.89.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector v0.89.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/connector/servicegraphconnector v0.89.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector v0.89.0 // indirect github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awskinesisexporter v0.89.0 // indirect github.com/open-telemetry/opentelemetry-collector-contrib/exporter/datadogexporter v0.89.0 // indirect github.com/open-telemetry/opentelemetry-collector-contrib/exporter/f5cloudexporter v0.89.0 // indirect @@ -570,7 +576,7 @@ require ( github.com/shopspring/decimal v1.3.1 // indirect github.com/signalfx/com_signalfx_metrics_protobuf v0.0.3 // indirect github.com/signalfx/sapm-proto v0.13.0 // indirect - github.com/sijms/go-ora/v2 v2.7.20 // indirect + github.com/sijms/go-ora/v2 v2.7.22 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/snowflakedb/gosnowflake v1.6.25 // indirect github.com/soheilhy/cmux v0.1.5 // indirect @@ -626,6 +632,7 @@ require ( go.opentelemetry.io/collector/config/internal v0.89.0 // indirect go.opentelemetry.io/collector/confmap v0.89.0 // indirect go.opentelemetry.io/collector/connector v0.89.0 // indirect + go.opentelemetry.io/collector/connector/forwardconnector v0.89.0 // indirect go.opentelemetry.io/collector/consumer v0.89.0 // indirect go.opentelemetry.io/collector/exporter/debugexporter v0.89.0 // indirect go.opentelemetry.io/collector/exporter/loggingexporter v0.89.0 // indirect @@ -1132,3 +1139,12 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/azure replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/collectd => ../../internal/collectd + +replace ( + github.com/open-telemetry/opentelemetry-collector-contrib/connector/countconnector => ../../connector/countconnector + github.com/open-telemetry/opentelemetry-collector-contrib/connector/datadogconnector => ../../connector/datadogconnector + github.com/open-telemetry/opentelemetry-collector-contrib/connector/exceptionsconnector => ../../connector/exceptionsconnector + github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector => ../../connector/routingconnector + github.com/open-telemetry/opentelemetry-collector-contrib/connector/servicegraphconnector => ../../connector/servicegraphconnector + github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector => ../../connector/spanmetricsconnector +) diff --git a/cmd/configschema/go.sum b/cmd/configschema/go.sum index 016589669c12..7c0c07003fc2 100644 --- a/cmd/configschema/go.sum +++ b/cmd/configschema/go.sum @@ -200,8 +200,8 @@ github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962 h1:KeNholpO2xKjgaaSyd+DyQRrsQjhbSeS7qe4nEw8aQw= github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962/go.mod h1:kC29dT1vFpj7py2OvG1khBdQpo3kInWP+6QipLbdngo= -github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.20.0 h1:tk85AYGwOf6VNtoOQi8w/kVDi2vmPxp3/OU2FsUpdcA= -github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.20.0/go.mod h1:Xx0VKh7GJ4si3rmElbh19Mejxz68ibWg/J30ZOMrqzU= +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/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector v0.45.0 h1:jYuZ3VSmHtR/OE4ZNlhgaWefopMKh8kxHMITQ7hXB0s= github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector v0.45.0/go.mod h1:b8EPYWl+yGWfPDP2P1slOiJkimNOQMD34szyZt1G0+s= github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector/googlemanagedprometheus v0.45.0 h1:Kim3EFONcbm78LF3B/EPFegmsKtFYBNcoJ89ubBPblw= @@ -219,7 +219,6 @@ github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0 github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g= -github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= 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= @@ -500,8 +499,8 @@ github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m3 github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v24.0.7+incompatible h1:Wo6l37AuwP3JaMnZa226lzVXGA3F9Ig1seQen0cKYlM= github.com/docker/docker v24.0.7+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docker/go-connections v0.4.1-0.20210727194412-58542c764a11 h1:IPrmumsT9t5BS7XcPhgsCTlkWbYg80SEXUzDpReaU6Y= -github.com/docker/go-connections v0.4.1-0.20210727194412-58542c764a11/go.mod h1:a6bNUGTbQBsY6VRHTr4h/rkOXjl244DyRD0tx3fgq4Q= +github.com/docker/go-connections v0.4.1-0.20231110212414-fa09c952e3ea h1:+4n+kUVbPdu6qMI9SUnSKMC+D50gNW4L7Lhk9tI2lVo= +github.com/docker/go-connections v0.4.1-0.20231110212414-fa09c952e3ea/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= 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= @@ -550,8 +549,8 @@ github.com/euank/go-kmsg-parser v2.0.0+incompatible/go.mod h1:MhmAMZ8V4CYH4ybgdR github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww= -github.com/facebook/time v0.0.0-20220713225404-f7a0d7702d50 h1:3fALCgsB+zI8Bxlv4ph4lCgt1CEQHIdU5sWxbkaMkuc= -github.com/facebook/time v0.0.0-20220713225404-f7a0d7702d50/go.mod h1:IQmM+Ezbn5X7gpDO0IjKU5RmW9xT1a19dLp+NbivoXE= +github.com/facebook/time v0.0.0-20231108195549-620e14e718fb h1:5sihTI/ZuTyL9vudiEnP0kcNLZIv9TQwRlZ1x0bc33E= +github.com/facebook/time v0.0.0-20231108195549-620e14e718fb/go.mod h1:O8nuAUhv2TubINRTU9kKPsqOoQtUts0Q81yac6PlQfE= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= @@ -1404,8 +1403,8 @@ github.com/signalfx/com_signalfx_metrics_protobuf v0.0.3 h1:32k2QLgsKhcEs55q4REP github.com/signalfx/com_signalfx_metrics_protobuf v0.0.3/go.mod h1:gJrXWi7wSGXfiC7+VheQaz+ypdCt5SmZNL+BRxUe7y4= github.com/signalfx/sapm-proto v0.13.0 h1:yEkp1+MAU4vZvnJMp56uhVlRjlvCK7KQjBg0g2Apw8k= github.com/signalfx/sapm-proto v0.13.0/go.mod h1:C72HjeCW5v0Llk6pIVJ/ZH8A5GbiZpCCSkE1dSlpWxY= -github.com/sijms/go-ora/v2 v2.7.20 h1:Q+/zNx3DMgytXMAvIbt/pUJcYj2jMRv/2Zg1DDlWhTY= -github.com/sijms/go-ora/v2 v2.7.20/go.mod h1:EHxlY6x7y9HAsdfumurRfTd+v8NrEOTR3Xl4FWlH6xk= +github.com/sijms/go-ora/v2 v2.7.22 h1:B2mSLhDDWTgsjdM0d/O7iJn041cBy5z7fA8sR082vCg= +github.com/sijms/go-ora/v2 v2.7.22/go.mod h1:EHxlY6x7y9HAsdfumurRfTd+v8NrEOTR3Xl4FWlH6xk= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= @@ -1607,6 +1606,8 @@ go.opentelemetry.io/collector/confmap v0.89.0 h1:N5Vg1+FXEFBHHlGIPg4OSlM9uTHjCI7 go.opentelemetry.io/collector/confmap v0.89.0/go.mod h1:D8FMPvuihtVxwXaz/qp5q9X2lq9l97QyjfsdZD1spmc= go.opentelemetry.io/collector/connector v0.89.0 h1:2v7RgaLrlGmvHV1BjG133MswZ2BhH77vTHOLa4/Tqm0= go.opentelemetry.io/collector/connector v0.89.0/go.mod h1:z82Yw0wZarpva9byeqByb3+eZSZ35DMdNRkjFgMm0S0= +go.opentelemetry.io/collector/connector/forwardconnector v0.89.0 h1:L2SjHTu2PtGJG9pHIBTlzWR5YnkApcR/5u3jgxa+XIM= +go.opentelemetry.io/collector/connector/forwardconnector v0.89.0/go.mod h1:s0hVBjug/iwc9Fw6QlcKFZ5ezeqFfp3uK9IgS5cZNhc= go.opentelemetry.io/collector/consumer v0.89.0 h1:MteKhkudX2L1ylbtdpSazO8SwyHSxl6fUEElc0rRLDQ= go.opentelemetry.io/collector/consumer v0.89.0/go.mod h1:aOaoi6R0qVvfHu0pEPCzSE74gIPNJoCQM8Ml4Bc9NHE= go.opentelemetry.io/collector/exporter v0.89.0 h1:8sYpJdKDQ2RuYOPKDsMz/lMJqp4WEWZgfJzyn9IgOag= diff --git a/cmd/configschema/resolver_test.go b/cmd/configschema/resolver_test.go index f74fe4759741..f19f76d1cc9b 100644 --- a/cmd/configschema/resolver_test.go +++ b/cmd/configschema/resolver_test.go @@ -1,10 +1,6 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -// Skip tests on Windows temporarily, see https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/11451 -//go:build !windows -// +build !windows - package configschema import ( @@ -48,7 +44,7 @@ func TestTypeToPackagePath_Local(t *testing.T) { func TestTypeToPackagePath_External(t *testing.T) { packageDir := testTypeToPackagePath(t, otlpreceiver.Config{}) - assert.Contains(t, packageDir, "pkg/mod/go.opentelemetry.io/collector/receiver@") + assert.Contains(t, packageDir, filepath.Join("pkg", "mod", "go.opentelemetry.io", "collector", "receiver@")) } func TestTypeToPackagePath_Error(t *testing.T) { @@ -59,7 +55,7 @@ func TestTypeToPackagePath_Error(t *testing.T) { func TestTypeToProjectPath(t *testing.T) { dir := testDR().ReflectValueToProjectPath(reflect.ValueOf(&redisreceiver.Config{})) - assert.Equal(t, "../../receiver/redisreceiver", dir) + assert.Equal(t, filepath.Join("..", "..", "receiver", "redisreceiver"), dir) } func TestTypetoProjectPath_External(t *testing.T) { diff --git a/cmd/githubgen/codeowners.go b/cmd/githubgen/codeowners.go new file mode 100644 index 000000000000..f53c64b91ca0 --- /dev/null +++ b/cmd/githubgen/codeowners.go @@ -0,0 +1,195 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 +package main + +import ( + "context" + "fmt" + "os" + "path/filepath" + "sort" + "strings" + + "github.com/google/go-github/v53/github" +) + +const allowlistHeader = `# Code generated by githubgen. DO NOT EDIT. +##################################################### +# +# List of components in OpenTelemetry Collector Contrib +# waiting on owners to be assigned +# +##################################################### +# +# Learn about membership in OpenTelemetry community: +# https://github.com/open-telemetry/community/blob/main/community-membership.md +# +# +# Learn about CODEOWNERS file format: +# https://help.github.com/en/articles/about-code-owners +# + +## +# NOTE: New components MUST have a codeowner. Add new components to the CODEOWNERS file instead of here. +## + +## COMMON & SHARED components +internal/common + +` + +const unmaintainedHeader = ` + +## UNMAINTAINED components +## The Github issue template generation code needs this to generate the corresponding labels. + +` + +const codeownersHeader = `# Code generated by githubgen. DO NOT EDIT. +##################################################### +# +# List of approvers for OpenTelemetry Collector Contrib +# +##################################################### +# +# Learn about membership in OpenTelemetry community: +# https://github.com/open-telemetry/community/blob/main/community-membership.md +# +# +# Learn about CODEOWNERS file format: +# https://help.github.com/en/articles/about-code-owners +# +# NOTE: Lines should be entered in the following format: +# /.. +# extension/oauth2clientauthextension/ @open-telemetry/collector-contrib-approvers @pavankrish123 @jpkrohling +# Path separator and minimum of 1 space between component path and owners is +# important for validation steps +# + +* @open-telemetry/collector-contrib-approvers +` + +type codeownersGenerator struct { +} + +func (cg codeownersGenerator) generate(data *githubData) error { + allowlistData, err := os.ReadFile(data.allowlistFilePath) + if err != nil { + return err + } + allowlistLines := strings.Split(string(allowlistData), "\n") + + allowlist := make(map[string]struct{}, len(allowlistLines)) + for _, line := range allowlistLines { + allowlist[line] = struct{}{} + } + var missingCodeowners []string + var duplicateCodeowners []string + members, err := getGithubMembers() + if err != nil { + return err + } + for _, codeowner := range data.codeowners { + _, present := members[codeowner] + + if !present { + _, allowed := allowlist[codeowner] + allowed = allowed || strings.HasPrefix(codeowner, "open-telemetry/") + if !allowed { + missingCodeowners = append(missingCodeowners, codeowner) + } + } else if _, ok := allowlist[codeowner]; ok { + duplicateCodeowners = append(duplicateCodeowners, codeowner) + } + } + if len(missingCodeowners) > 0 { + sort.Strings(missingCodeowners) + return fmt.Errorf("codeowners are not members: %s", strings.Join(missingCodeowners, ", ")) + } + if len(duplicateCodeowners) > 0 { + sort.Strings(duplicateCodeowners) + return fmt.Errorf("codeowners members duplicate in allowlist: %s", strings.Join(duplicateCodeowners, ", ")) + } + + codeowners := codeownersHeader + deprecatedList := "## DEPRECATED components\n" + unmaintainedList := "\n## UNMAINTAINED components\n" + + unmaintainedCodeowners := unmaintainedHeader + currentFirstSegment := "" +LOOP: + for _, key := range data.folders { + m := data.components[key] + for stability := range m.Status.Stability { + if stability == unmaintainedStatus { + unmaintainedList += key + "/\n" + unmaintainedCodeowners += fmt.Sprintf("%s/%s @open-telemetry/collector-contrib-approvers \n", key, strings.Repeat(" ", data.maxLength-len(key))) + continue LOOP + } + if stability == "deprecated" && (m.Status.Codeowners == nil || len(m.Status.Codeowners.Active) == 0) { + deprecatedList += key + "/\n" + } + } + + if m.Status.Codeowners != nil { + parts := strings.Split(key, string(os.PathSeparator)) + firstSegment := parts[0] + if firstSegment != currentFirstSegment { + currentFirstSegment = firstSegment + codeowners += "\n" + } + owners := "" + for _, owner := range m.Status.Codeowners.Active { + owners += " " + owners += "@" + owner + } + codeowners += fmt.Sprintf("%s/%s @open-telemetry/collector-contrib-approvers%s\n", key, strings.Repeat(" ", data.maxLength-len(key)), owners) + } + } + + err = os.WriteFile(filepath.Join(".github", "CODEOWNERS"), []byte(codeowners+unmaintainedCodeowners), 0600) + if err != nil { + return err + } + err = os.WriteFile(filepath.Join(".github", "ALLOWLIST"), []byte(allowlistHeader+deprecatedList+unmaintainedList), 0600) + if err != nil { + return err + } + return nil +} + +func getGithubMembers() (map[string]struct{}, error) { + githubToken := os.Getenv("GITHUB_TOKEN") + if githubToken == "" { + return nil, fmt.Errorf("Set the environment variable `GITHUB_TOKEN` to a PAT token to authenticate") + } + client := github.NewTokenClient(context.Background(), githubToken) + var allUsers []*github.User + pageIndex := 0 + for { + users, resp, err := client.Organizations.ListMembers(context.Background(), "open-telemetry", + &github.ListMembersOptions{ + PublicOnly: false, + ListOptions: github.ListOptions{ + PerPage: 50, + Page: pageIndex, + }, + }, + ) + if err != nil { + return nil, err + } + defer resp.Body.Close() + if len(users) == 0 { + break + } + allUsers = append(allUsers, users...) + pageIndex++ + } + + usernames := make(map[string]struct{}, len(allUsers)) + for _, u := range allUsers { + usernames[*u.Login] = struct{}{} + } + return usernames, nil +} diff --git a/cmd/githubgen/dependabot.go b/cmd/githubgen/dependabot.go new file mode 100644 index 000000000000..b5ad2eb8d111 --- /dev/null +++ b/cmd/githubgen/dependabot.go @@ -0,0 +1,115 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 +package main + +import ( + "bytes" + "fmt" + "os" + "path/filepath" + "sort" + "strings" + + "gopkg.in/yaml.v3" +) + +const ( + maxDependabotUpdates = 220 + dependabotHeader = `# File generated by "make gendependabot"; DO NOT EDIT. + +` +) + +type dependabotSchedule struct { + Interval yaml.Node `yaml:"interval"` + Day yaml.Node `yaml:"day"` +} + +type dependabotUpdate struct { + PackageEcosystem yaml.Node `yaml:"package-ecosystem"` + Directory yaml.Node `yaml:"directory"` + Schedule dependabotSchedule `yaml:"schedule"` + Priority int `yaml:"-"` +} + +type dependabotData struct { + Version int `yaml:"version"` + Updates []dependabotUpdate `yaml:"updates"` +} + +func makePriority(status *Status) int { + // not an internal component such as pkg/**, and no distributions: + if (status.Class == "receiver" || status.Class == "processor" || status.Class == "exporter" || status.Class == "connector" || status.Class == "extension" || status.Class == "cmd") && + len(status.Distributions) == 0 && status.Class != "" { + return 1 + } + // start with a score of 2 + maxScore := 2 + for stability := range status.Stability { + switch stability { + case "deprecated": // stay with 2 + case "unmaintained": + return 1 + case "alpha": + if maxScore < 3 { + maxScore = 3 + } + case "beta": + if maxScore < 4 { + maxScore = 4 + } + case "stable": + if maxScore < 5 { + maxScore = 5 + } + } + } + return maxScore +} + +func newDependabotUpdate(directory string, priority int) dependabotUpdate { + return dependabotUpdate{ + PackageEcosystem: yaml.Node{Value: "gomod", Style: yaml.DoubleQuotedStyle, Kind: yaml.ScalarNode}, + Directory: yaml.Node{Value: "/" + directory, Style: yaml.DoubleQuotedStyle, Kind: yaml.ScalarNode}, + Schedule: dependabotSchedule{ + Interval: yaml.Node{Value: "weekly", Style: yaml.DoubleQuotedStyle, Kind: yaml.ScalarNode}, + Day: yaml.Node{Value: "wednesday", Style: yaml.DoubleQuotedStyle, Kind: yaml.ScalarNode}, + }, + Priority: priority, + } +} + +type dependabotGenerator struct { +} + +func (dg dependabotGenerator) generate(data *githubData) error { + dependabotData := data.dependabotData + sort.Slice(dependabotData.Updates, func(i, j int) bool { + return dependabotData.Updates[i].Priority > dependabotData.Updates[j].Priority + }) + removed := dependabotData.Updates[maxDependabotUpdates:] + dependabotData.Updates = dependabotData.Updates[:maxDependabotUpdates] + if len(removed) > 0 { + sort.Slice(removed, func(i, j int) bool { + return strings.Compare(removed[i].Directory.Value, removed[j].Directory.Value) < 0 + }) + fmt.Printf("The following modules were not added to Dependabot to keep within limits of %d\n", maxDependabotUpdates) + for _, update := range removed { + fmt.Printf(" - %q\n", update.Directory.Value) + } + } + + sort.Slice(dependabotData.Updates, func(i, j int) bool { + return strings.Compare(dependabotData.Updates[i].Directory.Value, dependabotData.Updates[j].Directory.Value) < 0 + }) + + var yamlContents bytes.Buffer + encoder := yaml.NewEncoder(&yamlContents) + encoder.SetIndent(2) + err := encoder.Encode(dependabotData) + if err != nil { + return err + } + err = os.WriteFile(filepath.Join(".github", "dependabot.yml"), append([]byte(dependabotHeader), yamlContents.Bytes()...), 0600) + return err +} diff --git a/cmd/githubgen/issuetemplates.go b/cmd/githubgen/issuetemplates.go new file mode 100644 index 000000000000..91f6ede0534b --- /dev/null +++ b/cmd/githubgen/issuetemplates.go @@ -0,0 +1,66 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 +package main + +import ( + "bytes" + "os" + "path/filepath" + "regexp" + "sort" + "strings" +) + +const ( + startComponentList = `# Start Collector components list` + endComponentList = `# End Collector components list` +) + +func folderToShortName(folder string) string { + if folder == "internal/coreinternal" { + return "internal/core" + } + path := strings.Split(folder, "/") + switch path[0] { + case "receiver", "exporter", "extension", "processor", "connector": + path[1] = strings.TrimSuffix(strings.TrimSuffix(strings.TrimSuffix(strings.TrimSuffix(strings.TrimSuffix(strings.TrimSuffix(path[1], "internal"), "extension"), "exporter"), "connector"), "processor"), "receiver") + path[len(path)-1] = strings.TrimSuffix(strings.TrimSuffix(strings.TrimSuffix(strings.TrimSuffix(strings.TrimSuffix(strings.TrimSuffix(path[len(path)-1], "internal"), "extension"), "exporter"), "connector"), "processor"), "receiver") + default: + } + + return strings.Join(path, "/") +} + +type issueTemplatesGenerator struct { +} + +func (itg issueTemplatesGenerator) generate(data *githubData) error { + shortNames := make([]string, len(data.folders)) + for i, f := range data.folders { + shortNames[i] = folderToShortName(f) + } + sort.Strings(shortNames) + replacement := []byte(startComponentList + "\n - " + strings.Join(shortNames, "\n - ") + "\n " + endComponentList) + issuesFolder := filepath.Join(".github", "ISSUE_TEMPLATE") + entries, err := os.ReadDir(issuesFolder) + if err != nil { + return err + } + for _, e := range entries { + templateContents, err := os.ReadFile(filepath.Join(issuesFolder, e.Name())) + if err != nil { + return err + } + matchOldContent := regexp.MustCompile("(?s)" + startComponentList + ".*" + endComponentList) + oldContent := matchOldContent.FindSubmatch(templateContents) + if len(oldContent) > 0 { + templateContents = bytes.ReplaceAll(templateContents, oldContent[0], replacement) + err = os.WriteFile(filepath.Join(issuesFolder, e.Name()), templateContents, 0600) + if err != nil { + return err + } + } + + } + return nil +} diff --git a/cmd/githubgen/main.go b/cmd/githubgen/main.go index 7de47722cd4a..56696d21245a 100644 --- a/cmd/githubgen/main.go +++ b/cmd/githubgen/main.go @@ -4,7 +4,6 @@ package main import ( - "bytes" "context" "flag" "fmt" @@ -13,163 +12,59 @@ import ( "os" "path/filepath" "sort" - "strings" - "gopkg.in/yaml.v3" - - "github.com/google/go-github/v53/github" "go.opentelemetry.io/collector/confmap/provider/fileprovider" ) -const maxDependabotUpdates = 220 - -const codeownersHeader = `# Code generated by githubgen. DO NOT EDIT. -##################################################### -# -# List of approvers for OpenTelemetry Collector Contrib -# -##################################################### -# -# Learn about membership in OpenTelemetry community: -# https://github.com/open-telemetry/community/blob/main/community-membership.md -# -# -# Learn about CODEOWNERS file format: -# https://help.github.com/en/articles/about-code-owners -# -# NOTE: Lines should be entered in the following format: -# /.. -# extension/oauth2clientauthextension/ @open-telemetry/collector-contrib-approvers @pavankrish123 @jpkrohling -# Path separator and minimum of 1 space between component path and owners is -# important for validation steps -# - -* @open-telemetry/collector-contrib-approvers -` - -const unmaintainedHeader = ` - -## UNMAINTAINED components -## The Github issue template generation code needs this to generate the corresponding labels. - -` - -const allowlistHeader = `# Code generated by githubgen. DO NOT EDIT. -##################################################### -# -# List of components in OpenTelemetry Collector Contrib -# waiting on owners to be assigned -# -##################################################### -# -# Learn about membership in OpenTelemetry community: -# https://github.com/open-telemetry/community/blob/main/community-membership.md -# -# -# Learn about CODEOWNERS file format: -# https://help.github.com/en/articles/about-code-owners -# - -## -# NOTE: New components MUST have a codeowner. Add new components to the CODEOWNERS file instead of here. -## - -## COMMON & SHARED components -internal/common - -` - -const dependabotHeader = `# File generated by "make gendependabot"; DO NOT EDIT. - -` - const unmaintainedStatus = "unmaintained" +type generator interface { + generate(data *githubData) error +} + // Generates files specific to Github or Dependabot according to status metadata: // .github/CODEOWNERS // .github/ALLOWLIST // .github/dependabot.yml +// .github/ISSUE_TEMPLATES/*.yaml (list of components) func main() { folder := flag.String("folder", ".", "folder investigated for codeowners") allowlistFilePath := flag.String("allowlist", "cmd/githubgen/allowlist.txt", "path to a file containing an allowlist of members outside the OpenTelemetry organization") - dependabotOnly := flag.Bool("dependabot", false, "only generate dependabot entries") flag.Parse() - if err := run(*folder, *allowlistFilePath, *dependabotOnly); err != nil { - log.Fatal(err) - } -} - -type DependabotSchedule struct { - Interval yaml.Node `yaml:"interval"` - Day yaml.Node `yaml:"day"` -} - -type DependabotUpdate struct { - PackageEcosystem yaml.Node `yaml:"package-ecosystem"` - Directory yaml.Node `yaml:"directory"` - Schedule DependabotSchedule `yaml:"schedule"` - Priority int `yaml:"-"` -} - -type DependabotData struct { - Version int `yaml:"version"` - Updates []DependabotUpdate `yaml:"updates"` -} - -func makePriority(status *Status) int { - // not an internal component such as pkg/**, and no distributions: - if (status.Class == "receiver" || status.Class == "processor" || status.Class == "exporter" || status.Class == "connector" || status.Class == "extension" || status.Class == "cmd") && - len(status.Distributions) == 0 && status.Class != "" { - return 1 - } - // start with a score of 2 - maxScore := 2 - for stability := range status.Stability { - switch stability { - case "deprecated": // stay with 2 - case "unmaintained": - return 1 - case "alpha": - if maxScore < 3 { - maxScore = 3 - } - case "beta": - if maxScore < 4 { - maxScore = 4 - } - case "stable": - if maxScore < 5 { - maxScore = 5 - } + var generators []generator + for _, arg := range flag.Args() { + switch arg { + case "issue-templates": + generators = append(generators, issueTemplatesGenerator{}) + case "dependabot": + generators = append(generators, dependabotGenerator{}) + case "codeowners": + generators = append(generators, codeownersGenerator{}) + default: + panic(fmt.Sprintf("Unknown generator: %s", arg)) } } - return maxScore -} - -func newDependabotUpdate(directory string, priority int) DependabotUpdate { - return DependabotUpdate{ - PackageEcosystem: yaml.Node{Value: "gomod", Style: yaml.DoubleQuotedStyle, Kind: yaml.ScalarNode}, - Directory: yaml.Node{Value: "/" + directory, Style: yaml.DoubleQuotedStyle, Kind: yaml.ScalarNode}, - Schedule: DependabotSchedule{ - Interval: yaml.Node{Value: "weekly", Style: yaml.DoubleQuotedStyle, Kind: yaml.ScalarNode}, - Day: yaml.Node{Value: "wednesday", Style: yaml.DoubleQuotedStyle, Kind: yaml.ScalarNode}, - }, - Priority: priority, + if len(generators) == 0 { + generators = []generator{issueTemplatesGenerator{}, dependabotGenerator{}, codeownersGenerator{}} + } + if err := run(*folder, *allowlistFilePath, generators); err != nil { + log.Fatal(err) } } -type Codeowners struct { +type codeowners struct { // Active codeowners Active []string `mapstructure:"active"` // Emeritus codeowners Emeritus []string `mapstructure:"emeritus"` } + type Status struct { Stability map[string][]string `mapstructure:"stability"` Distributions []string `mapstructure:"distributions"` Class string `mapstructure:"class"` Warnings []string `mapstructure:"warnings"` - Codeowners *Codeowners `mapstructure:"codeowners"` + Codeowners *codeowners `mapstructure:"codeowners"` } type metadata struct { // Type of the component. @@ -180,6 +75,15 @@ type metadata struct { Status *Status `mapstructure:"status"` } +type githubData struct { + folders []string + codeowners []string + allowlistFilePath string + maxLength int + components map[string]metadata + dependabotData *dependabotData +} + func loadMetadata(filePath string) (metadata, error) { cp, err := fileprovider.New().Retrieve(context.Background(), "file:"+filePath, nil) if err != nil { @@ -199,13 +103,13 @@ func loadMetadata(filePath string) (metadata, error) { return md, nil } -func run(folder string, allowlistFilePath string, dependabotOnly bool) error { +func run(folder string, allowlistFilePath string, generators []generator) error { components := map[string]metadata{} var foldersList []string - dependabotData := &DependabotData{ + dependabotData := &dependabotData{ Version: 2, - Updates: []DependabotUpdate{ + Updates: []dependabotUpdate{ newDependabotUpdate("", 5), }, } @@ -221,7 +125,7 @@ func run(folder string, allowlistFilePath string, dependabotOnly bool) error { return nil } currentFolder := filepath.Dir(path) - key := currentFolder + "/" + key := currentFolder components[key] = m foldersList = append(foldersList, key) _, err = os.Stat(filepath.Join(currentFolder, "go.mod")) @@ -249,165 +153,27 @@ func run(folder string, allowlistFilePath string, dependabotOnly bool) error { if err != nil { return err } - if !dependabotOnly { - if err = generateCodeownersFiles(foldersList, allCodeowners, allowlistFilePath, components, maxLength); err != nil { - return err - } - } - - sort.Slice(dependabotData.Updates, func(i, j int) bool { - return dependabotData.Updates[i].Priority > dependabotData.Updates[j].Priority - }) - removed := dependabotData.Updates[maxDependabotUpdates:] - dependabotData.Updates = dependabotData.Updates[:maxDependabotUpdates] - if len(removed) > 0 { - sort.Slice(removed, func(i, j int) bool { - return strings.Compare(removed[i].Directory.Value, removed[j].Directory.Value) < 0 - }) - fmt.Printf("The following modules were not added to Dependabot to keep within limits of %d\n", maxDependabotUpdates) - for _, update := range removed { - fmt.Printf(" - %q\n", update.Directory.Value) - } - } - - sort.Slice(dependabotData.Updates, func(i, j int) bool { - return strings.Compare(dependabotData.Updates[i].Directory.Value, dependabotData.Updates[j].Directory.Value) < 0 - }) - - var yamlContents bytes.Buffer - encoder := yaml.NewEncoder(&yamlContents) - encoder.SetIndent(2) - err = encoder.Encode(dependabotData) - if err != nil { - return err - } - err = os.WriteFile(filepath.Join(".github", "dependabot.yml"), append([]byte(dependabotHeader), yamlContents.Bytes()...), 0600) - if err != nil { - return err - } - - return nil -} -func generateCodeownersFiles(foldersList []string, allCodeowners map[string]struct{}, allowlistFilePath string, components map[string]metadata, maxLength int) error { - allowlistData, err := os.ReadFile(allowlistFilePath) - if err != nil { - return err - } - allowlistLines := strings.Split(string(allowlistData), "\n") - - allowlist := make(map[string]struct{}, len(allowlistLines)) - for _, line := range allowlistLines { - allowlist[line] = struct{}{} - } sort.Strings(foldersList) - var missingCodeowners []string - var duplicateCodeowners []string - members, err := getGithubMembers() - if err != nil { - return err + codeownersList := make([]string, 0, len(allCodeowners)) + for c := range allCodeowners { + codeownersList = append(codeownersList, c) } - for codeowner := range allCodeowners { - _, present := members[codeowner] + sort.Strings(codeownersList) - if !present { - _, allowed := allowlist[codeowner] - allowed = allowed || strings.HasPrefix(codeowner, "open-telemetry/") - if !allowed { - missingCodeowners = append(missingCodeowners, codeowner) - } - } else if _, ok := allowlist[codeowner]; ok { - duplicateCodeowners = append(duplicateCodeowners, codeowner) - } - } - if len(missingCodeowners) > 0 { - sort.Strings(missingCodeowners) - return fmt.Errorf("codeowners are not members: %s", strings.Join(missingCodeowners, ", ")) + data := &githubData{ + folders: foldersList, + codeowners: codeownersList, + allowlistFilePath: allowlistFilePath, + maxLength: maxLength, + components: components, + dependabotData: dependabotData, } - if len(duplicateCodeowners) > 0 { - sort.Strings(duplicateCodeowners) - return fmt.Errorf("codeowners members duplicate in allowlist: %s", strings.Join(duplicateCodeowners, ", ")) - } - - codeowners := codeownersHeader - deprecatedList := "## DEPRECATED components\n" - unmaintainedList := "\n## UNMAINTAINED components\n" - unmaintainedCodeowners := unmaintainedHeader - currentFirstSegment := "" -LOOP: - for _, key := range foldersList { - m := components[key] - for stability := range m.Status.Stability { - if stability == unmaintainedStatus { - unmaintainedList += key + "\n" - unmaintainedCodeowners += fmt.Sprintf("%s%s @open-telemetry/collector-contrib-approvers \n", key, strings.Repeat(" ", maxLength-len(key))) - continue LOOP - } - if stability == "deprecated" && (m.Status.Codeowners == nil || len(m.Status.Codeowners.Active) == 0) { - deprecatedList += key + "\n" - } - } - - if m.Status.Codeowners != nil { - parts := strings.Split(key, string(os.PathSeparator)) - firstSegment := parts[0] - if firstSegment != currentFirstSegment { - currentFirstSegment = firstSegment - codeowners += "\n" - } - owners := "" - for _, owner := range m.Status.Codeowners.Active { - owners += " " - owners += "@" + owner - } - codeowners += fmt.Sprintf("%s%s @open-telemetry/collector-contrib-approvers%s\n", key, strings.Repeat(" ", maxLength-len(key)), owners) + for _, g := range generators { + if err = g.generate(data); err != nil { + return err } } - - err = os.WriteFile(filepath.Join(".github", "CODEOWNERS"), []byte(codeowners+unmaintainedCodeowners), 0600) - if err != nil { - return err - } - err = os.WriteFile(filepath.Join(".github", "ALLOWLIST"), []byte(allowlistHeader+deprecatedList+unmaintainedList), 0600) - if err != nil { - return err - } return nil } - -func getGithubMembers() (map[string]struct{}, error) { - githubToken := os.Getenv("GITHUB_TOKEN") - if githubToken == "" { - return nil, fmt.Errorf("Set the environment variable `GITHUB_TOKEN` to a PAT token to authenticate") - } - client := github.NewTokenClient(context.Background(), githubToken) - var allUsers []*github.User - pageIndex := 0 - for { - users, resp, err := client.Organizations.ListMembers(context.Background(), "open-telemetry", - &github.ListMembersOptions{ - PublicOnly: false, - ListOptions: github.ListOptions{ - PerPage: 50, - Page: pageIndex, - }, - }, - ) - if err != nil { - return nil, err - } - defer resp.Body.Close() - if len(users) == 0 { - break - } - allUsers = append(allUsers, users...) - pageIndex++ - } - - usernames := make(map[string]struct{}, len(allUsers)) - for _, u := range allUsers { - usernames[*u.Login] = struct{}{} - } - return usernames, nil -} diff --git a/cmd/opampsupervisor/go.mod b/cmd/opampsupervisor/go.mod index b2124e6fab6f..e5b74fab348b 100644 --- a/cmd/opampsupervisor/go.mod +++ b/cmd/opampsupervisor/go.mod @@ -3,7 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/cmd/opampsuperv go 1.20 require ( - github.com/cenkalti/backoff/v4 v4.2.0 + github.com/cenkalti/backoff/v4 v4.2.1 github.com/knadh/koanf/parsers/yaml v0.1.0 github.com/knadh/koanf/providers/file v0.1.0 github.com/knadh/koanf/providers/rawbytes v0.1.0 diff --git a/cmd/opampsupervisor/go.sum b/cmd/opampsupervisor/go.sum index 6e739d2c16a8..7b1abb4d7ef9 100644 --- a/cmd/opampsupervisor/go.sum +++ b/cmd/opampsupervisor/go.sum @@ -1,5 +1,5 @@ -github.com/cenkalti/backoff/v4 v4.2.0 h1:HN5dHm3WBOgndBH6E8V0q2jIYIR3s9yglV8k/+MN3u4= -github.com/cenkalti/backoff/v4 v4.2.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +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/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/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= diff --git a/cmd/otelcontribcol/go.mod b/cmd/otelcontribcol/go.mod index bbd117459816..06627d87f673 100644 --- a/cmd/otelcontribcol/go.mod +++ b/cmd/otelcontribcol/go.mod @@ -278,7 +278,7 @@ require ( github.com/DataDog/sketches-go v1.4.3 // indirect github.com/DataDog/zstd v1.5.2 // indirect github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962 // indirect - github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.20.0 // indirect + github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.21.0 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector v0.45.0 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector/googlemanagedprometheus v0.45.0 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.21.0 // indirect @@ -353,7 +353,7 @@ require ( github.com/digitalocean/godo v1.104.1 // 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.1-0.20210727194412-58542c764a11 // indirect + github.com/docker/go-connections v0.4.1-0.20231110212414-fa09c952e3ea // indirect github.com/docker/go-units v0.5.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.5.0 // indirect @@ -367,7 +367,7 @@ require ( github.com/envoyproxy/go-control-plane v0.11.1 // indirect github.com/envoyproxy/protoc-gen-validate v1.0.2 // indirect github.com/euank/go-kmsg-parser v2.0.0+incompatible // indirect - github.com/facebook/time v0.0.0-20220713225404-f7a0d7702d50 // indirect + github.com/facebook/time v0.0.0-20231108195549-620e14e718fb // indirect github.com/fatih/color v1.15.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/form3tech-oss/jwt-go v3.2.5+incompatible // indirect @@ -595,7 +595,7 @@ require ( github.com/shopspring/decimal v1.3.1 // indirect github.com/signalfx/com_signalfx_metrics_protobuf v0.0.3 // indirect github.com/signalfx/sapm-proto v0.13.0 // indirect - github.com/sijms/go-ora/v2 v2.7.20 // indirect + github.com/sijms/go-ora/v2 v2.7.22 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/snowflakedb/gosnowflake v1.6.25 // indirect github.com/soheilhy/cmux v0.1.5 // indirect diff --git a/cmd/otelcontribcol/go.sum b/cmd/otelcontribcol/go.sum index 2ba40f2ddcbd..041e767524d8 100644 --- a/cmd/otelcontribcol/go.sum +++ b/cmd/otelcontribcol/go.sum @@ -199,8 +199,8 @@ github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962 h1:KeNholpO2xKjgaaSyd+DyQRrsQjhbSeS7qe4nEw8aQw= github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962/go.mod h1:kC29dT1vFpj7py2OvG1khBdQpo3kInWP+6QipLbdngo= -github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.20.0 h1:tk85AYGwOf6VNtoOQi8w/kVDi2vmPxp3/OU2FsUpdcA= -github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.20.0/go.mod h1:Xx0VKh7GJ4si3rmElbh19Mejxz68ibWg/J30ZOMrqzU= +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/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector v0.45.0 h1:jYuZ3VSmHtR/OE4ZNlhgaWefopMKh8kxHMITQ7hXB0s= github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector v0.45.0/go.mod h1:b8EPYWl+yGWfPDP2P1slOiJkimNOQMD34szyZt1G0+s= github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector/googlemanagedprometheus v0.45.0 h1:Kim3EFONcbm78LF3B/EPFegmsKtFYBNcoJ89ubBPblw= @@ -218,7 +218,6 @@ github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0 github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= -github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= 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= @@ -499,8 +498,8 @@ github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m3 github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v24.0.7+incompatible h1:Wo6l37AuwP3JaMnZa226lzVXGA3F9Ig1seQen0cKYlM= github.com/docker/docker v24.0.7+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docker/go-connections v0.4.1-0.20210727194412-58542c764a11 h1:IPrmumsT9t5BS7XcPhgsCTlkWbYg80SEXUzDpReaU6Y= -github.com/docker/go-connections v0.4.1-0.20210727194412-58542c764a11/go.mod h1:a6bNUGTbQBsY6VRHTr4h/rkOXjl244DyRD0tx3fgq4Q= +github.com/docker/go-connections v0.4.1-0.20231110212414-fa09c952e3ea h1:+4n+kUVbPdu6qMI9SUnSKMC+D50gNW4L7Lhk9tI2lVo= +github.com/docker/go-connections v0.4.1-0.20231110212414-fa09c952e3ea/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= 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= @@ -549,8 +548,8 @@ github.com/euank/go-kmsg-parser v2.0.0+incompatible/go.mod h1:MhmAMZ8V4CYH4ybgdR github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww= -github.com/facebook/time v0.0.0-20220713225404-f7a0d7702d50 h1:3fALCgsB+zI8Bxlv4ph4lCgt1CEQHIdU5sWxbkaMkuc= -github.com/facebook/time v0.0.0-20220713225404-f7a0d7702d50/go.mod h1:IQmM+Ezbn5X7gpDO0IjKU5RmW9xT1a19dLp+NbivoXE= +github.com/facebook/time v0.0.0-20231108195549-620e14e718fb h1:5sihTI/ZuTyL9vudiEnP0kcNLZIv9TQwRlZ1x0bc33E= +github.com/facebook/time v0.0.0-20231108195549-620e14e718fb/go.mod h1:O8nuAUhv2TubINRTU9kKPsqOoQtUts0Q81yac6PlQfE= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= @@ -1401,8 +1400,8 @@ github.com/signalfx/com_signalfx_metrics_protobuf v0.0.3 h1:32k2QLgsKhcEs55q4REP github.com/signalfx/com_signalfx_metrics_protobuf v0.0.3/go.mod h1:gJrXWi7wSGXfiC7+VheQaz+ypdCt5SmZNL+BRxUe7y4= github.com/signalfx/sapm-proto v0.13.0 h1:yEkp1+MAU4vZvnJMp56uhVlRjlvCK7KQjBg0g2Apw8k= github.com/signalfx/sapm-proto v0.13.0/go.mod h1:C72HjeCW5v0Llk6pIVJ/ZH8A5GbiZpCCSkE1dSlpWxY= -github.com/sijms/go-ora/v2 v2.7.20 h1:Q+/zNx3DMgytXMAvIbt/pUJcYj2jMRv/2Zg1DDlWhTY= -github.com/sijms/go-ora/v2 v2.7.20/go.mod h1:EHxlY6x7y9HAsdfumurRfTd+v8NrEOTR3Xl4FWlH6xk= +github.com/sijms/go-ora/v2 v2.7.22 h1:B2mSLhDDWTgsjdM0d/O7iJn041cBy5z7fA8sR082vCg= +github.com/sijms/go-ora/v2 v2.7.22/go.mod h1:EHxlY6x7y9HAsdfumurRfTd+v8NrEOTR3Xl4FWlH6xk= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= diff --git a/exporter/awsemfexporter/emf_exporter.go b/exporter/awsemfexporter/emf_exporter.go index 193a0068db1a..4b482399affc 100644 --- a/exporter/awsemfexporter/emf_exporter.go +++ b/exporter/awsemfexporter/emf_exporter.go @@ -91,7 +91,7 @@ func (emf *emfExporter) pushMetricsData(_ context.Context, md pmetric.Metrics) e }) } } - emf.config.logger.Info("Start processing resource metrics", zap.Any("labels", labels)) + emf.config.logger.Debug("Start processing resource metrics", zap.Any("labels", labels)) groupedMetrics := make(map[any]*groupedMetric) defaultLogStream := fmt.Sprintf("otel-stream-%s", emf.collectorID) @@ -142,7 +142,7 @@ func (emf *emfExporter) pushMetricsData(_ context.Context, md pmetric.Metrics) e } } - emf.config.logger.Info("Finish processing resource metrics", zap.Any("labels", labels)) + emf.config.logger.Debug("Finish processing resource metrics", zap.Any("labels", labels)) return nil } diff --git a/exporter/datadogexporter/go.mod b/exporter/datadogexporter/go.mod index d3b7b959f470..bba9c4a5f98e 100644 --- a/exporter/datadogexporter/go.mod +++ b/exporter/datadogexporter/go.mod @@ -14,7 +14,7 @@ require ( github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.8.1 github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.8.1 github.com/DataDog/sketches-go v1.4.3 - github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.20.0 + github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.21.0 github.com/aws/aws-sdk-go v1.47.10 github.com/cenkalti/backoff/v4 v4.2.1 github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/ecsutil v0.89.0 diff --git a/exporter/datadogexporter/go.sum b/exporter/datadogexporter/go.sum index 0adc1835791e..1e9c78a0a035 100644 --- a/exporter/datadogexporter/go.sum +++ b/exporter/datadogexporter/go.sum @@ -92,8 +92,8 @@ github.com/DataDog/sketches-go v1.4.3 h1:ZB9nijteJRFUQixkQfatCqASartGNfiolIlMiEv github.com/DataDog/sketches-go v1.4.3/go.mod h1:XR0ns2RtEEF09mDKXiKZiQg+nfZStrq1ZuL1eezeZe0= github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= -github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.20.0 h1:tk85AYGwOf6VNtoOQi8w/kVDi2vmPxp3/OU2FsUpdcA= -github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.20.0/go.mod h1:Xx0VKh7GJ4si3rmElbh19Mejxz68ibWg/J30ZOMrqzU= +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.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= 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= diff --git a/exporter/datadogexporter/integrationtest/go.mod b/exporter/datadogexporter/integrationtest/go.mod index 8d352a005ba9..975f2a489f89 100644 --- a/exporter/datadogexporter/integrationtest/go.mod +++ b/exporter/datadogexporter/integrationtest/go.mod @@ -49,7 +49,7 @@ require ( github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.8.1 // indirect github.com/DataDog/sketches-go v1.4.3 // indirect github.com/DataDog/zstd v1.5.2 // indirect - github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.20.0 // indirect + 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.0 // indirect github.com/aws/aws-sdk-go v1.47.10 // indirect diff --git a/exporter/datadogexporter/integrationtest/go.sum b/exporter/datadogexporter/integrationtest/go.sum index ffe39a7a469d..a730e1aa0592 100644 --- a/exporter/datadogexporter/integrationtest/go.sum +++ b/exporter/datadogexporter/integrationtest/go.sum @@ -89,8 +89,8 @@ github.com/DataDog/sketches-go v1.4.3 h1:ZB9nijteJRFUQixkQfatCqASartGNfiolIlMiEv github.com/DataDog/sketches-go v1.4.3/go.mod h1:XR0ns2RtEEF09mDKXiKZiQg+nfZStrq1ZuL1eezeZe0= github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= -github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.20.0 h1:tk85AYGwOf6VNtoOQi8w/kVDi2vmPxp3/OU2FsUpdcA= -github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.20.0/go.mod h1:Xx0VKh7GJ4si3rmElbh19Mejxz68ibWg/J30ZOMrqzU= +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.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= 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= diff --git a/exporter/googlecloudexporter/go.mod b/exporter/googlecloudexporter/go.mod index 296eaac7052f..ed1c3e36b37c 100644 --- a/exporter/googlecloudexporter/go.mod +++ b/exporter/googlecloudexporter/go.mod @@ -3,7 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/exporter/google go 1.20 require ( - github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector v0.44.1-0.20231113185509-337c81d87781 + github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector v0.45.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.89.0 go.opentelemetry.io/collector/confmap v0.89.0 @@ -19,8 +19,8 @@ require ( cloud.google.com/go/longrunning v0.5.2 // indirect cloud.google.com/go/monitoring v1.16.1 // indirect cloud.google.com/go/trace v1.10.2 // indirect - github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.20.0 // indirect - github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.44.0 // indirect + github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.21.0 // indirect + github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.45.0 // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect diff --git a/exporter/googlecloudexporter/go.sum b/exporter/googlecloudexporter/go.sum index 7261afc871cb..f45ce70720ab 100644 --- a/exporter/googlecloudexporter/go.sum +++ b/exporter/googlecloudexporter/go.sum @@ -15,13 +15,13 @@ cloud.google.com/go/trace v1.10.2 h1:80Rh4JSqJLfe/xGNrpyO4MQxiFDXcHG1XrsevfmrIRQ cloud.google.com/go/trace v1.10.2/go.mod h1:NPXemMi6MToRFcSxRl2uDnu/qAlAQ3oULUphcHGh1vA= 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/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector v0.44.1-0.20231113185509-337c81d87781 h1:tI/JgbDUBFpVCgawBboIxIV4OCcXsXSQDx5IvA7rsag= -github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector v0.44.1-0.20231113185509-337c81d87781/go.mod h1:Y8A+tRfM4DfIY2ODAyzSrxHmaxL3wWERfLy6PAthDpI= -github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.20.0 h1:uY/4lpbbFG73TgzmJoB7XMyFIheII95hlfH62uC+oS0= -github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.20.0/go.mod h1:qaUEgkhkSlCNIu9/XD4y19vnbwKskfz2ep6Utf2A57c= -github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/cloudmock v0.44.0 h1:ew7SfeajMJ3I4iXA1LERYY62fGCKO4TjVPw5QTPt47k= -github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.44.0 h1:GjWPDY9PUlNWwTI95L/lktUp35BLtzBoBElH314eafM= -github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.44.0/go.mod h1:qkFPtMouQjW5ugdHIOthiTbweVHUTqbS0Qsu55KqXks= +github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector v0.45.0 h1:jYuZ3VSmHtR/OE4ZNlhgaWefopMKh8kxHMITQ7hXB0s= +github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector v0.45.0/go.mod h1:b8EPYWl+yGWfPDP2P1slOiJkimNOQMD34szyZt1G0+s= +github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.21.0 h1:OEgjQy1rH4Fbn5IpuI9d0uhLl+j6DkDvh9Q2Ucd6GK8= +github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.21.0/go.mod h1:EUfJ8lb3pjD8VasPPwqIvG2XVCE6DOT8tY5tcwbWA+A= +github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/cloudmock v0.45.0 h1:/BF7rO6PYcmFoyJrq6HA3LqQpFSQei9aNuO1fvV3OqU= +github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.45.0 h1:o/Nf55GfyLwGDaHkVAkRGgBXeExce73L6N9w2PZTB3k= +github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.45.0/go.mod h1:qkFPtMouQjW5ugdHIOthiTbweVHUTqbS0Qsu55KqXks= 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/extension/observer/dockerobserver/go.mod b/extension/observer/dockerobserver/go.mod index fa0f0d5b6744..3770a752c6e1 100644 --- a/extension/observer/dockerobserver/go.mod +++ b/extension/observer/dockerobserver/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/docker/docker v24.0.7+incompatible - github.com/docker/go-connections v0.4.1-0.20210727194412-58542c764a11 + github.com/docker/go-connections v0.4.1-0.20231110212414-fa09c952e3ea github.com/open-telemetry/opentelemetry-collector-contrib/extension/observer v0.89.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.89.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/docker v0.89.0 diff --git a/extension/observer/dockerobserver/go.sum b/extension/observer/dockerobserver/go.sum index b9f007480110..c1167c5b7293 100644 --- a/extension/observer/dockerobserver/go.sum +++ b/extension/observer/dockerobserver/go.sum @@ -4,7 +4,6 @@ github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9 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/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= 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/Microsoft/hcsshim v0.11.1 h1:hJ3s7GbWlGK4YVV92sO88BQSyF4ZLVy7/awqOlPxFbA= @@ -31,8 +30,8 @@ github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m3 github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v24.0.7+incompatible h1:Wo6l37AuwP3JaMnZa226lzVXGA3F9Ig1seQen0cKYlM= github.com/docker/docker v24.0.7+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docker/go-connections v0.4.1-0.20210727194412-58542c764a11 h1:IPrmumsT9t5BS7XcPhgsCTlkWbYg80SEXUzDpReaU6Y= -github.com/docker/go-connections v0.4.1-0.20210727194412-58542c764a11/go.mod h1:a6bNUGTbQBsY6VRHTr4h/rkOXjl244DyRD0tx3fgq4Q= +github.com/docker/go-connections v0.4.1-0.20231110212414-fa09c952e3ea h1:+4n+kUVbPdu6qMI9SUnSKMC+D50gNW4L7Lhk9tI2lVo= +github.com/docker/go-connections v0.4.1-0.20231110212414-fa09c952e3ea/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= 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= @@ -70,7 +69,6 @@ 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/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= @@ -104,7 +102,6 @@ github.com/opencontainers/runc v1.1.5 h1:L44KXEpKmfWDcS02aeGm8QNTFXTo2D+8MYGDIJ/ github.com/opencontainers/runc v1.1.5/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opencontainers/selinux v1.10.0/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -121,12 +118,10 @@ github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg 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/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= 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= @@ -194,10 +189,8 @@ 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.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/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-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/extension/pprofextension/README.md b/extension/pprofextension/README.md index 6b3a35891cca..2f7a4a061a3c 100644 --- a/extension/pprofextension/README.md +++ b/extension/pprofextension/README.md @@ -48,3 +48,60 @@ extensions: The full list of settings exposed for this exporter are documented [here](./config.go) with detailed sample configurations [here](./testdata/config.yaml). + + +### Go Profiling with pprof basics + +The profiler can be used to improve a program. +The most common usage is a CPU profile, which determines where the program spends the most time while actively consuming resources. +After generating a profile, we can interpret it in different ways. +Go's _pprof_ offers a text, visualization, or web-based analysis. +To collect a meaningful profile, it should run on an idle machine and if that is not possible, it is best to generate the profile several times to get consistent results. + +The profiler stops the program multiple times per second and collects information (such as program counters) at that point in time. +This is called a sample, and a profile is a collection of those samples. + +#### Generating a profile +The extension enables the collection of profiling data expected by _pprof_. +To generate a profile, include the extension in your program and run it to start the server. +If you are using the default config, it will listen on `localhost:1777`. +To save a CPU profile on your machine, run `go tool pprof http://localhost:1777/debug/pprof/profile\?seconds\=30`. +This will enter the interactive mode of _pprof_, where you can analyze the profile. + +There are different endpoints for other types of profiles. +For instance, the memory can be analyzed using `go tool pprof http://localhost:1777/debug/pprof/heap`. +To see all available profiles, visit `http://localhost:1777/debug/pprof/` in your browser. + +#### Analyzing a profile + +After running the above command to save the profile, _pprof_ will enter the interactive mode. +From here, the profiles can be analyzed. + +Use the command `web` to open an image of the complete call graph in your browser. +Each box corresponds to a function in the program, and it is sized according to the number of samples in which this function was running. +This means, if the box of a function is bigger, it was executed more often than a function in a smaller box. +The arrows between boxes show the connectivity of the functions. +If there is an arrow from box A to B, A called B. +The numbers along the edges represent how often that call happened. +This includes every call of a recursive function. +The color of the edges also represents that number. +A red edge means more resources were used, whereas grey indicates the used resources were close to zero. + +However, the complete call graph can be a bit noisy. +A good place to start breaking it down is using the `topN` command. +It will show you the top `N` nodes, consuming the most resources. +The output is a table, where the first two columns show the number and percentage of total samples where the function was running (`flat`). +The third column shows the total percentage, for instance stating that function X was running in 20% of the samples. +The two remaining columns show the cumulative (`cum`) numbers of the profile. + +From here, the results can be filtered. +Choose one of the top consuming functions which you would like to analyze. +_pprof_ uses a regex-based search to filter for functions matching the input. +Type `web ` to show the call graph for this specific function. +The image in your browser should now be more clear and less cluttered. + +The `list` command is also useful. +Type `list ` to see the source code of your function, annotated with the resource consumption (`flat` and `cum` columns like in the `topN` command). +If you prefer to view it in your browser, use the `weblist ` command instead. +In this view, you can see which line exactly used the most resources and start to improve it. + diff --git a/go.mod b/go.mod index 9692c7da02ae..757446a4076c 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,12 @@ module github.com/open-telemetry/opentelemetry-collector-contrib go 1.20 require ( + github.com/open-telemetry/opentelemetry-collector-contrib/connector/countconnector v0.89.0 + github.com/open-telemetry/opentelemetry-collector-contrib/connector/datadogconnector v0.89.0 + github.com/open-telemetry/opentelemetry-collector-contrib/connector/exceptionsconnector v0.89.0 + github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector v0.89.0 + github.com/open-telemetry/opentelemetry-collector-contrib/connector/servicegraphconnector v0.89.0 + github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector v0.89.0 github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter v0.89.0 github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awscloudwatchlogsexporter v0.89.0 github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsemfexporter v0.89.0 @@ -164,6 +170,8 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsperfcountersreceiver v0.89.0 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.89.0 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zookeeperreceiver v0.89.0 + go.opentelemetry.io/collector/connector v0.89.0 + go.opentelemetry.io/collector/connector/forwardconnector v0.89.0 go.opentelemetry.io/collector/exporter v0.89.0 go.opentelemetry.io/collector/exporter/debugexporter v0.89.0 go.opentelemetry.io/collector/exporter/loggingexporter v0.89.0 @@ -249,7 +257,7 @@ require ( github.com/DataDog/sketches-go v1.4.3 // indirect github.com/DataDog/zstd v1.5.2 // indirect github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962 // indirect - github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.20.0 // indirect + github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.21.0 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector v0.45.0 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector/googlemanagedprometheus v0.45.0 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.21.0 // indirect @@ -325,7 +333,7 @@ require ( github.com/digitalocean/godo v1.104.1 // 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.1-0.20210727194412-58542c764a11 // indirect + github.com/docker/go-connections v0.4.1-0.20231110212414-fa09c952e3ea // indirect github.com/docker/go-units v0.5.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.5.0 // indirect @@ -339,7 +347,7 @@ require ( github.com/envoyproxy/go-control-plane v0.11.1 // indirect github.com/envoyproxy/protoc-gen-validate v1.0.2 // indirect github.com/euank/go-kmsg-parser v2.0.0+incompatible // indirect - github.com/facebook/time v0.0.0-20220713225404-f7a0d7702d50 // indirect + github.com/facebook/time v0.0.0-20231108195549-620e14e718fb // indirect github.com/fatih/color v1.15.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/form3tech-oss/jwt-go v3.2.5+incompatible // indirect @@ -572,7 +580,7 @@ require ( github.com/shopspring/decimal v1.3.1 // indirect github.com/signalfx/com_signalfx_metrics_protobuf v0.0.3 // indirect github.com/signalfx/sapm-proto v0.13.0 // indirect - github.com/sijms/go-ora/v2 v2.7.20 // indirect + github.com/sijms/go-ora/v2 v2.7.22 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/snowflakedb/gosnowflake v1.6.25 // indirect github.com/soheilhy/cmux v0.1.5 // indirect @@ -630,7 +638,6 @@ require ( go.opentelemetry.io/collector/config/configtls v0.89.0 // indirect go.opentelemetry.io/collector/config/internal v0.89.0 // indirect go.opentelemetry.io/collector/confmap v0.89.0 // indirect - go.opentelemetry.io/collector/connector v0.89.0 // indirect go.opentelemetry.io/collector/consumer v0.89.0 // indirect go.opentelemetry.io/collector/extension/auth v0.89.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0-rcv0018 // indirect @@ -1136,3 +1143,12 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/azure replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ./pkg/golden replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/collectd => ./internal/collectd + +replace ( + github.com/open-telemetry/opentelemetry-collector-contrib/connector/countconnector => ./connector/countconnector + github.com/open-telemetry/opentelemetry-collector-contrib/connector/datadogconnector => ./connector/datadogconnector + github.com/open-telemetry/opentelemetry-collector-contrib/connector/exceptionsconnector => ./connector/exceptionsconnector + github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector => ./connector/routingconnector + github.com/open-telemetry/opentelemetry-collector-contrib/connector/servicegraphconnector => ./connector/servicegraphconnector + github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector => ./connector/spanmetricsconnector +) diff --git a/go.sum b/go.sum index 695436113160..64b402ea031b 100644 --- a/go.sum +++ b/go.sum @@ -204,8 +204,8 @@ github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962 h1:KeNholpO2xKjgaaSyd+DyQRrsQjhbSeS7qe4nEw8aQw= github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962/go.mod h1:kC29dT1vFpj7py2OvG1khBdQpo3kInWP+6QipLbdngo= -github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.20.0 h1:tk85AYGwOf6VNtoOQi8w/kVDi2vmPxp3/OU2FsUpdcA= -github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.20.0/go.mod h1:Xx0VKh7GJ4si3rmElbh19Mejxz68ibWg/J30ZOMrqzU= +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/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector v0.45.0 h1:jYuZ3VSmHtR/OE4ZNlhgaWefopMKh8kxHMITQ7hXB0s= github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector v0.45.0/go.mod h1:b8EPYWl+yGWfPDP2P1slOiJkimNOQMD34szyZt1G0+s= github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector/googlemanagedprometheus v0.45.0 h1:Kim3EFONcbm78LF3B/EPFegmsKtFYBNcoJ89ubBPblw= @@ -505,8 +505,8 @@ github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m3 github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v24.0.7+incompatible h1:Wo6l37AuwP3JaMnZa226lzVXGA3F9Ig1seQen0cKYlM= 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-connections v0.4.1-0.20231110212414-fa09c952e3ea h1:+4n+kUVbPdu6qMI9SUnSKMC+D50gNW4L7Lhk9tI2lVo= +github.com/docker/go-connections v0.4.1-0.20231110212414-fa09c952e3ea/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= 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= @@ -555,8 +555,8 @@ github.com/euank/go-kmsg-parser v2.0.0+incompatible/go.mod h1:MhmAMZ8V4CYH4ybgdR github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww= -github.com/facebook/time v0.0.0-20220713225404-f7a0d7702d50 h1:3fALCgsB+zI8Bxlv4ph4lCgt1CEQHIdU5sWxbkaMkuc= -github.com/facebook/time v0.0.0-20220713225404-f7a0d7702d50/go.mod h1:IQmM+Ezbn5X7gpDO0IjKU5RmW9xT1a19dLp+NbivoXE= +github.com/facebook/time v0.0.0-20231108195549-620e14e718fb h1:5sihTI/ZuTyL9vudiEnP0kcNLZIv9TQwRlZ1x0bc33E= +github.com/facebook/time v0.0.0-20231108195549-620e14e718fb/go.mod h1:O8nuAUhv2TubINRTU9kKPsqOoQtUts0Q81yac6PlQfE= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= @@ -1408,8 +1408,8 @@ github.com/signalfx/com_signalfx_metrics_protobuf v0.0.3 h1:32k2QLgsKhcEs55q4REP github.com/signalfx/com_signalfx_metrics_protobuf v0.0.3/go.mod h1:gJrXWi7wSGXfiC7+VheQaz+ypdCt5SmZNL+BRxUe7y4= github.com/signalfx/sapm-proto v0.13.0 h1:yEkp1+MAU4vZvnJMp56uhVlRjlvCK7KQjBg0g2Apw8k= github.com/signalfx/sapm-proto v0.13.0/go.mod h1:C72HjeCW5v0Llk6pIVJ/ZH8A5GbiZpCCSkE1dSlpWxY= -github.com/sijms/go-ora/v2 v2.7.20 h1:Q+/zNx3DMgytXMAvIbt/pUJcYj2jMRv/2Zg1DDlWhTY= -github.com/sijms/go-ora/v2 v2.7.20/go.mod h1:EHxlY6x7y9HAsdfumurRfTd+v8NrEOTR3Xl4FWlH6xk= +github.com/sijms/go-ora/v2 v2.7.22 h1:B2mSLhDDWTgsjdM0d/O7iJn041cBy5z7fA8sR082vCg= +github.com/sijms/go-ora/v2 v2.7.22/go.mod h1:EHxlY6x7y9HAsdfumurRfTd+v8NrEOTR3Xl4FWlH6xk= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= @@ -1611,6 +1611,8 @@ go.opentelemetry.io/collector/confmap v0.89.0 h1:N5Vg1+FXEFBHHlGIPg4OSlM9uTHjCI7 go.opentelemetry.io/collector/confmap v0.89.0/go.mod h1:D8FMPvuihtVxwXaz/qp5q9X2lq9l97QyjfsdZD1spmc= go.opentelemetry.io/collector/connector v0.89.0 h1:2v7RgaLrlGmvHV1BjG133MswZ2BhH77vTHOLa4/Tqm0= go.opentelemetry.io/collector/connector v0.89.0/go.mod h1:z82Yw0wZarpva9byeqByb3+eZSZ35DMdNRkjFgMm0S0= +go.opentelemetry.io/collector/connector/forwardconnector v0.89.0 h1:L2SjHTu2PtGJG9pHIBTlzWR5YnkApcR/5u3jgxa+XIM= +go.opentelemetry.io/collector/connector/forwardconnector v0.89.0/go.mod h1:s0hVBjug/iwc9Fw6QlcKFZ5ezeqFfp3uK9IgS5cZNhc= go.opentelemetry.io/collector/consumer v0.89.0 h1:MteKhkudX2L1ylbtdpSazO8SwyHSxl6fUEElc0rRLDQ= go.opentelemetry.io/collector/consumer v0.89.0/go.mod h1:aOaoi6R0qVvfHu0pEPCzSE74gIPNJoCQM8Ml4Bc9NHE= go.opentelemetry.io/collector/exporter v0.89.0 h1:8sYpJdKDQ2RuYOPKDsMz/lMJqp4WEWZgfJzyn9IgOag= diff --git a/internal/components/components.go b/internal/components/components.go index 2555806fd655..42fa66662f2e 100644 --- a/internal/components/components.go +++ b/internal/components/components.go @@ -4,6 +4,8 @@ package components // import "github.com/open-telemetry/opentelemetry-collector-contrib/internal/components" import ( + "go.opentelemetry.io/collector/connector" + "go.opentelemetry.io/collector/connector/forwardconnector" "go.opentelemetry.io/collector/exporter" "go.opentelemetry.io/collector/exporter/debugexporter" "go.opentelemetry.io/collector/exporter/loggingexporter" @@ -19,6 +21,12 @@ import ( "go.opentelemetry.io/collector/receiver" "go.opentelemetry.io/collector/receiver/otlpreceiver" + "github.com/open-telemetry/opentelemetry-collector-contrib/connector/countconnector" + "github.com/open-telemetry/opentelemetry-collector-contrib/connector/datadogconnector" + "github.com/open-telemetry/opentelemetry-collector-contrib/connector/exceptionsconnector" + "github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector" + "github.com/open-telemetry/opentelemetry-collector-contrib/connector/servicegraphconnector" + "github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awscloudwatchlogsexporter" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsemfexporter" @@ -385,5 +393,19 @@ func Components() (otelcol.Factories, error) { return otelcol.Factories{}, err } + connectors := []connector.Factory{ + forwardconnector.NewFactory(), + countconnector.NewFactory(), + datadogconnector.NewFactory(), + exceptionsconnector.NewFactory(), + routingconnector.NewFactory(), + servicegraphconnector.NewFactory(), + spanmetricsconnector.NewFactory(), + } + factories.Connectors, err = connector.MakeFactoryMap(connectors...) + if err != nil { + return otelcol.Factories{}, err + } + return factories, nil } diff --git a/pkg/resourcetotelemetry/resource_to_telemetry.go b/pkg/resourcetotelemetry/resource_to_telemetry.go index 67852f4d1015..48a8e6a41641 100644 --- a/pkg/resourcetotelemetry/resource_to_telemetry.go +++ b/pkg/resourcetotelemetry/resource_to_telemetry.go @@ -107,6 +107,7 @@ func addAttributesToExponentialHistogramDataPoints(ps pmetric.ExponentialHistogr } func joinAttributeMaps(from, to pcommon.Map) { + to.EnsureCapacity(from.Len() + to.Len()) from.Range(func(k string, v pcommon.Value) bool { v.CopyTo(to.PutEmpty(k)) return true diff --git a/pkg/resourcetotelemetry/resource_to_telemetry_test.go b/pkg/resourcetotelemetry/resource_to_telemetry_test.go index 1d244582cd0a..123434ecdcdb 100644 --- a/pkg/resourcetotelemetry/resource_to_telemetry_test.go +++ b/pkg/resourcetotelemetry/resource_to_telemetry_test.go @@ -3,9 +3,11 @@ package resourcetotelemetry import ( + "fmt" "testing" "github.com/stretchr/testify/assert" + "go.opentelemetry.io/collector/pdata/pcommon" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" ) @@ -65,3 +67,71 @@ func TestConvertResourceToAttributesAllDataTypesEmptyDataPoint(t *testing.T) { assert.Equal(t, 0, md.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(6).ExponentialHistogram().DataPoints().At(0).Attributes().Len()) } + +func BenchmarkJoinAttributes(b *testing.B) { + type args struct { + from int + to int + } + tests := []struct { + name string + args args + }{ + { + name: "merge 10 into 10", + args: args{ + from: 10, + to: 10, + }, + }, + { + name: "merge 10 into 20", + args: args{ + from: 10, + to: 20, + }, + }, + { + name: "merge 20 into 10", + args: args{ + from: 20, + to: 10, + }, + }, + { + name: "merge 30 into 10", + args: args{ + from: 30, + to: 10, + }, + }, + { + name: "merge 10 into 30", + args: args{ + from: 10, + to: 30, + }, + }, + } + b.ReportAllocs() + for _, tt := range tests { + b.Run(tt.name, func(b *testing.B) { + b.ResetTimer() + from := initMetricAttributes(tt.args.from, 0) + for i := 0; i < b.N; i++ { + to := initMetricAttributes(tt.args.to, tt.args.from) + joinAttributeMaps(from, to) + } + }) + } + +} + +func initMetricAttributes(capacity int, idx int) pcommon.Map { + dest := pcommon.NewMap() + dest.EnsureCapacity(capacity) + for i := 0; i < capacity; i++ { + dest.PutStr(fmt.Sprintf("label-name-for-index-%d", i+idx), fmt.Sprintf("label-value-for-index-%d", i+idx)) + } + return dest +} diff --git a/processor/resourcedetectionprocessor/go.mod b/processor/resourcedetectionprocessor/go.mod index 0a9a02bd60fc..d534d1b94eb9 100644 --- a/processor/resourcedetectionprocessor/go.mod +++ b/processor/resourcedetectionprocessor/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( cloud.google.com/go/compute/metadata v0.2.3 - github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.20.0 + github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.21.0 github.com/aws/aws-sdk-go v1.47.10 github.com/google/go-cmp v0.6.0 github.com/hashicorp/consul/api v1.25.1 diff --git a/processor/resourcedetectionprocessor/go.sum b/processor/resourcedetectionprocessor/go.sum index 1f4e028bba2f..7de30cdcb5e7 100644 --- a/processor/resourcedetectionprocessor/go.sum +++ b/processor/resourcedetectionprocessor/go.sum @@ -38,8 +38,8 @@ github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBp 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/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.20.0 h1:tk85AYGwOf6VNtoOQi8w/kVDi2vmPxp3/OU2FsUpdcA= -github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.20.0/go.mod h1:Xx0VKh7GJ4si3rmElbh19Mejxz68ibWg/J30ZOMrqzU= +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/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= diff --git a/processor/transformprocessor/go.mod b/processor/transformprocessor/go.mod index 375bf46d17be..45ddd5281db0 100644 --- a/processor/transformprocessor/go.mod +++ b/processor/transformprocessor/go.mod @@ -3,11 +3,13 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/processor/trans go 1.20 require ( + github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.89.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl v0.89.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.89.0 go.opentelemetry.io/collector/confmap v0.89.0 go.opentelemetry.io/collector/consumer v0.89.0 + go.opentelemetry.io/collector/featuregate v1.0.0-rcv0018 go.opentelemetry.io/collector/pdata v1.0.0-rcv0018 go.opentelemetry.io/collector/processor v0.89.0 go.uber.org/multierr v1.11.0 @@ -37,7 +39,6 @@ require ( go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/collector v0.89.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.89.0 // indirect - go.opentelemetry.io/collector/featuregate v1.0.0-rcv0018 // 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 @@ -66,3 +67,5 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/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/common => ../../internal/common diff --git a/processor/transformprocessor/internal/metrics/func_convert_gauge_to_sum.go b/processor/transformprocessor/internal/metrics/func_convert_gauge_to_sum.go index 640d26d2f063..3c3a5100dc3c 100644 --- a/processor/transformprocessor/internal/metrics/func_convert_gauge_to_sum.go +++ b/processor/transformprocessor/internal/metrics/func_convert_gauge_to_sum.go @@ -10,7 +10,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/ottldatapoint" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/ottlmetric" ) type convertGaugeToSumArguments struct { @@ -18,11 +18,11 @@ type convertGaugeToSumArguments struct { Monotonic bool } -func newConvertGaugeToSumFactory() ottl.Factory[ottldatapoint.TransformContext] { +func newConvertGaugeToSumFactory() ottl.Factory[ottlmetric.TransformContext] { return ottl.NewFactory("convert_gauge_to_sum", &convertGaugeToSumArguments{}, createConvertGaugeToSumFunction) } -func createConvertGaugeToSumFunction(_ ottl.FunctionContext, oArgs ottl.Arguments) (ottl.ExprFunc[ottldatapoint.TransformContext], error) { +func createConvertGaugeToSumFunction(_ ottl.FunctionContext, oArgs ottl.Arguments) (ottl.ExprFunc[ottlmetric.TransformContext], error) { args, ok := oArgs.(*convertGaugeToSumArguments) if !ok { @@ -32,7 +32,7 @@ func createConvertGaugeToSumFunction(_ ottl.FunctionContext, oArgs ottl.Argument return convertGaugeToSum(args.StringAggTemp, args.Monotonic) } -func convertGaugeToSum(stringAggTemp string, monotonic bool) (ottl.ExprFunc[ottldatapoint.TransformContext], error) { +func convertGaugeToSum(stringAggTemp string, monotonic bool) (ottl.ExprFunc[ottlmetric.TransformContext], error) { var aggTemp pmetric.AggregationTemporality switch stringAggTemp { case "delta": @@ -43,7 +43,7 @@ func convertGaugeToSum(stringAggTemp string, monotonic bool) (ottl.ExprFunc[ottl return nil, fmt.Errorf("unknown aggregation temporality: %s", stringAggTemp) } - return func(_ context.Context, tCtx ottldatapoint.TransformContext) (any, error) { + return func(_ context.Context, tCtx ottlmetric.TransformContext) (any, error) { metric := tCtx.GetMetric() if metric.Type() != pmetric.MetricTypeGauge { return nil, nil diff --git a/processor/transformprocessor/internal/metrics/func_convert_gauge_to_sum_datapoint.go b/processor/transformprocessor/internal/metrics/func_convert_gauge_to_sum_datapoint.go new file mode 100644 index 000000000000..dab12e96d094 --- /dev/null +++ b/processor/transformprocessor/internal/metrics/func_convert_gauge_to_sum_datapoint.go @@ -0,0 +1,58 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package metrics // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor/internal/metrics" + +import ( + "context" + "fmt" + + "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/ottldatapoint" +) + +func newConvertDatapointGaugeToSumFactory() ottl.Factory[ottldatapoint.TransformContext] { + return ottl.NewFactory("convert_gauge_to_sum", &convertGaugeToSumArguments{}, createConvertDatapointGaugeToSumFunction) +} + +func createConvertDatapointGaugeToSumFunction(_ ottl.FunctionContext, oArgs ottl.Arguments) (ottl.ExprFunc[ottldatapoint.TransformContext], error) { + // use the same args as in metric context + args, ok := oArgs.(*convertGaugeToSumArguments) + + if !ok { + return nil, fmt.Errorf("ConvertGaugeToSumFactory args must be of type *ConvertGaugeToSumArguments") + } + + return convertDatapointGaugeToSum(args.StringAggTemp, args.Monotonic) +} + +func convertDatapointGaugeToSum(stringAggTemp string, monotonic bool) (ottl.ExprFunc[ottldatapoint.TransformContext], error) { + var aggTemp pmetric.AggregationTemporality + switch stringAggTemp { + case "delta": + aggTemp = pmetric.AggregationTemporalityDelta + case "cumulative": + aggTemp = pmetric.AggregationTemporalityCumulative + default: + return nil, fmt.Errorf("unknown aggregation temporality: %s", stringAggTemp) + } + + return func(_ context.Context, tCtx ottldatapoint.TransformContext) (any, error) { + metric := tCtx.GetMetric() + if metric.Type() != pmetric.MetricTypeGauge { + return nil, nil + } + + dps := metric.Gauge().DataPoints() + + metric.SetEmptySum().SetAggregationTemporality(aggTemp) + metric.Sum().SetIsMonotonic(monotonic) + + // Setting the data type removed all the data points, so we must copy them back to the metric. + dps.CopyTo(metric.Sum().DataPoints()) + + return nil, nil + }, nil +} diff --git a/processor/transformprocessor/internal/metrics/func_convert_gauge_to_sum_datapoint_test.go b/processor/transformprocessor/internal/metrics/func_convert_gauge_to_sum_datapoint_test.go new file mode 100644 index 000000000000..e0a030a3bc8c --- /dev/null +++ b/processor/transformprocessor/internal/metrics/func_convert_gauge_to_sum_datapoint_test.go @@ -0,0 +1,149 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package metrics + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/pmetric" + + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/ottldatapoint" +) + +func Test_convertDatapointGaugeToSum(t *testing.T) { + gaugeInput := pmetric.NewMetric() + + dp1 := gaugeInput.SetEmptyGauge().DataPoints().AppendEmpty() + dp1.SetIntValue(10) + + dp2 := gaugeInput.Gauge().DataPoints().AppendEmpty() + dp2.SetDoubleValue(14.5) + + sumInput := pmetric.NewMetric() + sumInput.SetEmptySum() + + histogramInput := pmetric.NewMetric() + histogramInput.SetEmptyHistogram() + + expoHistogramInput := pmetric.NewMetric() + expoHistogramInput.SetEmptyHistogram() + + summaryInput := pmetric.NewMetric() + summaryInput.SetEmptySummary() + + tests := []struct { + name string + stringAggTemp string + monotonic bool + input pmetric.Metric + want func(pmetric.Metric) + }{ + { + name: "convert gauge to cumulative sum", + stringAggTemp: "cumulative", + monotonic: false, + input: gaugeInput, + want: func(metric pmetric.Metric) { + gaugeInput.CopyTo(metric) + + dps := gaugeInput.Gauge().DataPoints() + + metric.SetEmptySum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + metric.Sum().SetIsMonotonic(false) + + dps.CopyTo(metric.Sum().DataPoints()) + }, + }, + { + name: "convert gauge to delta sum", + stringAggTemp: "delta", + monotonic: true, + input: gaugeInput, + want: func(metric pmetric.Metric) { + gaugeInput.CopyTo(metric) + + dps := gaugeInput.Gauge().DataPoints() + + metric.SetEmptySum().SetAggregationTemporality(pmetric.AggregationTemporalityDelta) + metric.Sum().SetIsMonotonic(true) + + dps.CopyTo(metric.Sum().DataPoints()) + }, + }, + { + name: "noop for sum", + stringAggTemp: "delta", + monotonic: true, + input: sumInput, + want: func(metric pmetric.Metric) { + sumInput.CopyTo(metric) + }, + }, + { + name: "noop for histogram", + stringAggTemp: "delta", + monotonic: true, + input: histogramInput, + want: func(metric pmetric.Metric) { + histogramInput.CopyTo(metric) + }, + }, + { + name: "noop for exponential histogram", + stringAggTemp: "delta", + monotonic: true, + input: expoHistogramInput, + want: func(metric pmetric.Metric) { + expoHistogramInput.CopyTo(metric) + }, + }, + { + name: "noop for summary", + stringAggTemp: "delta", + monotonic: true, + input: summaryInput, + want: func(metric pmetric.Metric) { + summaryInput.CopyTo(metric) + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + metric := pmetric.NewMetric() + tt.input.CopyTo(metric) + + ctx := ottldatapoint.NewTransformContext(pmetric.NewNumberDataPoint(), metric, pmetric.NewMetricSlice(), pcommon.NewInstrumentationScope(), pcommon.NewResource()) + + exprFunc, _ := convertDatapointGaugeToSum(tt.stringAggTemp, tt.monotonic) + + _, err := exprFunc(nil, ctx) + assert.Nil(t, err) + + expected := pmetric.NewMetric() + tt.want(expected) + + assert.Equal(t, expected, metric) + }) + } +} + +func Test_convertDatapointGaugeToSum_validation(t *testing.T) { + tests := []struct { + name string + stringAggTemp string + }{ + { + name: "invalid aggregation temporality", + stringAggTemp: "not a real aggregation temporality", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + _, err := convertDatapointGaugeToSum(tt.stringAggTemp, true) + assert.Error(t, err, "unknown aggregation temporality: not a real aggregation temporality") + }) + } +} diff --git a/processor/transformprocessor/internal/metrics/func_convert_gauge_to_sum_test.go b/processor/transformprocessor/internal/metrics/func_convert_gauge_to_sum_test.go index a3ab17d94ce7..61b74bee5b7e 100644 --- a/processor/transformprocessor/internal/metrics/func_convert_gauge_to_sum_test.go +++ b/processor/transformprocessor/internal/metrics/func_convert_gauge_to_sum_test.go @@ -10,7 +10,7 @@ import ( "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/pmetric" - "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/ottldatapoint" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/ottlmetric" ) func Test_convertGaugeToSum(t *testing.T) { @@ -115,7 +115,7 @@ func Test_convertGaugeToSum(t *testing.T) { metric := pmetric.NewMetric() tt.input.CopyTo(metric) - ctx := ottldatapoint.NewTransformContext(pmetric.NewNumberDataPoint(), metric, pmetric.NewMetricSlice(), pcommon.NewInstrumentationScope(), pcommon.NewResource()) + ctx := ottlmetric.NewTransformContext(metric, pmetric.NewMetricSlice(), pcommon.NewInstrumentationScope(), pcommon.NewResource()) exprFunc, _ := convertGaugeToSum(tt.stringAggTemp, tt.monotonic) diff --git a/processor/transformprocessor/internal/metrics/func_convert_sum_to_gauge.go b/processor/transformprocessor/internal/metrics/func_convert_sum_to_gauge.go index 5166795b8730..f4763e65c9e5 100644 --- a/processor/transformprocessor/internal/metrics/func_convert_sum_to_gauge.go +++ b/processor/transformprocessor/internal/metrics/func_convert_sum_to_gauge.go @@ -9,19 +9,19 @@ 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/ottldatapoint" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/ottlmetric" ) -func newConvertSumToGaugeFactory() ottl.Factory[ottldatapoint.TransformContext] { +func newConvertSumToGaugeFactory() ottl.Factory[ottlmetric.TransformContext] { return ottl.NewFactory("convert_sum_to_gauge", nil, createConvertSumToGaugeFunction) } -func createConvertSumToGaugeFunction(_ ottl.FunctionContext, _ ottl.Arguments) (ottl.ExprFunc[ottldatapoint.TransformContext], error) { +func createConvertSumToGaugeFunction(_ ottl.FunctionContext, _ ottl.Arguments) (ottl.ExprFunc[ottlmetric.TransformContext], error) { return convertSumToGauge() } -func convertSumToGauge() (ottl.ExprFunc[ottldatapoint.TransformContext], error) { - return func(_ context.Context, tCtx ottldatapoint.TransformContext) (any, error) { +func convertSumToGauge() (ottl.ExprFunc[ottlmetric.TransformContext], error) { + return func(_ context.Context, tCtx ottlmetric.TransformContext) (any, error) { metric := tCtx.GetMetric() if metric.Type() != pmetric.MetricTypeSum { return nil, nil diff --git a/processor/transformprocessor/internal/metrics/func_convert_sum_to_gauge_datapoint.go b/processor/transformprocessor/internal/metrics/func_convert_sum_to_gauge_datapoint.go new file mode 100644 index 000000000000..ca2f09c8a121 --- /dev/null +++ b/processor/transformprocessor/internal/metrics/func_convert_sum_to_gauge_datapoint.go @@ -0,0 +1,37 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package metrics // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor/internal/metrics" + +import ( + "context" + + "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/ottldatapoint" +) + +func newConvertDatapointSumToGaugeFactory() ottl.Factory[ottldatapoint.TransformContext] { + return ottl.NewFactory("convert_sum_to_gauge", nil, createDatapointConvertSumToGaugeFunction) +} + +func createDatapointConvertSumToGaugeFunction(_ ottl.FunctionContext, _ ottl.Arguments) (ottl.ExprFunc[ottldatapoint.TransformContext], error) { + return convertDatapointSumToGauge() +} + +func convertDatapointSumToGauge() (ottl.ExprFunc[ottldatapoint.TransformContext], error) { + return func(_ context.Context, tCtx ottldatapoint.TransformContext) (any, error) { + metric := tCtx.GetMetric() + if metric.Type() != pmetric.MetricTypeSum { + return nil, nil + } + + dps := metric.Sum().DataPoints() + + // Setting the data type removed all the data points, so we must copy them back to the metric. + dps.CopyTo(metric.SetEmptyGauge().DataPoints()) + + return nil, nil + }, nil +} diff --git a/processor/transformprocessor/internal/metrics/func_convert_sum_to_gauge_datapoint_test.go b/processor/transformprocessor/internal/metrics/func_convert_sum_to_gauge_datapoint_test.go new file mode 100644 index 000000000000..3c6af3787f2f --- /dev/null +++ b/processor/transformprocessor/internal/metrics/func_convert_sum_to_gauge_datapoint_test.go @@ -0,0 +1,99 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package metrics + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/pmetric" + + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/ottldatapoint" +) + +func Test_convertDatapointSumToGauge(t *testing.T) { + sumInput := pmetric.NewMetric() + + dp1 := sumInput.SetEmptySum().DataPoints().AppendEmpty() + dp1.SetIntValue(10) + + dp2 := sumInput.Sum().DataPoints().AppendEmpty() + dp2.SetDoubleValue(14.5) + + gaugeInput := pmetric.NewMetric() + gaugeInput.SetEmptyGauge() + + histogramInput := pmetric.NewMetric() + histogramInput.SetEmptyHistogram() + + expoHistogramInput := pmetric.NewMetric() + expoHistogramInput.SetEmptyExponentialHistogram() + + summaryInput := pmetric.NewMetric() + summaryInput.SetEmptySummary() + + tests := []struct { + name string + input pmetric.Metric + want func(pmetric.Metric) + }{ + { + name: "convert sum to gauge", + input: sumInput, + want: func(metric pmetric.Metric) { + sumInput.CopyTo(metric) + + dps := sumInput.Sum().DataPoints() + dps.CopyTo(metric.SetEmptyGauge().DataPoints()) + }, + }, + { + name: "noop for gauge", + input: gaugeInput, + want: func(metric pmetric.Metric) { + gaugeInput.CopyTo(metric) + }, + }, + { + name: "noop for histogram", + input: histogramInput, + want: func(metric pmetric.Metric) { + histogramInput.CopyTo(metric) + }, + }, + { + name: "noop for exponential histogram", + input: expoHistogramInput, + want: func(metric pmetric.Metric) { + expoHistogramInput.CopyTo(metric) + }, + }, + { + name: "noop for summary", + input: summaryInput, + want: func(metric pmetric.Metric) { + summaryInput.CopyTo(metric) + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + metric := pmetric.NewMetric() + tt.input.CopyTo(metric) + + ctx := ottldatapoint.NewTransformContext(pmetric.NewNumberDataPoint(), metric, pmetric.NewMetricSlice(), pcommon.NewInstrumentationScope(), pcommon.NewResource()) + + exprFunc, _ := convertDatapointSumToGauge() + + _, err := exprFunc(nil, ctx) + assert.Nil(t, err) + + expected := pmetric.NewMetric() + tt.want(expected) + + assert.Equal(t, expected, metric) + }) + } +} diff --git a/processor/transformprocessor/internal/metrics/func_convert_sum_to_gauge_test.go b/processor/transformprocessor/internal/metrics/func_convert_sum_to_gauge_test.go index 38a597541e77..9b4c7962619f 100644 --- a/processor/transformprocessor/internal/metrics/func_convert_sum_to_gauge_test.go +++ b/processor/transformprocessor/internal/metrics/func_convert_sum_to_gauge_test.go @@ -10,7 +10,7 @@ import ( "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/pmetric" - "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/ottldatapoint" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/ottlmetric" ) func Test_convertSumToGauge(t *testing.T) { @@ -83,7 +83,7 @@ func Test_convertSumToGauge(t *testing.T) { metric := pmetric.NewMetric() tt.input.CopyTo(metric) - ctx := ottldatapoint.NewTransformContext(pmetric.NewNumberDataPoint(), metric, pmetric.NewMetricSlice(), pcommon.NewInstrumentationScope(), pcommon.NewResource()) + ctx := ottlmetric.NewTransformContext(metric, pmetric.NewMetricSlice(), pcommon.NewInstrumentationScope(), pcommon.NewResource()) exprFunc, _ := convertSumToGauge() diff --git a/processor/transformprocessor/internal/metrics/functions.go b/processor/transformprocessor/internal/metrics/functions.go index 708b14489d0b..5c993ff3d417 100644 --- a/processor/transformprocessor/internal/metrics/functions.go +++ b/processor/transformprocessor/internal/metrics/functions.go @@ -4,22 +4,37 @@ package metrics // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor/internal/metrics" import ( + "go.opentelemetry.io/collector/featuregate" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/ottldatapoint" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/ottlmetric" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/ottlfuncs" ) +var useConvertBetweenSumAndGaugeMetricContext = featuregate.GlobalRegistry().MustRegister( + "processor.transform.ConvertBetweenSumAndGaugeMetricContext", + featuregate.StageAlpha, + featuregate.WithRegisterDescription("When enabled will use metric context for conversion between sum and gauge"), +) + func DataPointFunctions() map[string]ottl.Factory[ottldatapoint.TransformContext] { functions := ottlfuncs.StandardFuncs[ottldatapoint.TransformContext]() datapointFunctions := ottl.CreateFactoryMap[ottldatapoint.TransformContext]( - newConvertSumToGaugeFactory(), - newConvertGaugeToSumFactory(), newConvertSummarySumValToSumFactory(), newConvertSummaryCountValToSumFactory(), ) + if !useConvertBetweenSumAndGaugeMetricContext.IsEnabled() { + for _, f := range []ottl.Factory[ottldatapoint.TransformContext]{ + newConvertDatapointSumToGaugeFactory(), + newConvertDatapointGaugeToSumFactory(), + } { + datapointFunctions[f.Name()] = f + } + } + for k, v := range datapointFunctions { functions[k] = v } @@ -35,9 +50,18 @@ func MetricFunctions() map[string]ottl.Factory[ottlmetric.TransformContext] { newExtractCountMetricFactory(), ) + if useConvertBetweenSumAndGaugeMetricContext.IsEnabled() { + for _, f := range []ottl.Factory[ottlmetric.TransformContext]{ + newConvertSumToGaugeFactory(), + newConvertGaugeToSumFactory(), + } { + metricFunctions[f.Name()] = f + } + } + for k, v := range metricFunctions { functions[k] = v - } + return functions } diff --git a/processor/transformprocessor/internal/metrics/functions_test.go b/processor/transformprocessor/internal/metrics/functions_test.go index fd48a31d2666..95af5438e944 100644 --- a/processor/transformprocessor/internal/metrics/functions_test.go +++ b/processor/transformprocessor/internal/metrics/functions_test.go @@ -9,6 +9,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/testutil" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/ottldatapoint" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/ottlmetric" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/ottlfuncs" @@ -16,8 +17,8 @@ import ( func Test_DataPointFunctions(t *testing.T) { expected := ottlfuncs.StandardFuncs[ottldatapoint.TransformContext]() - expected["convert_sum_to_gauge"] = newConvertSumToGaugeFactory() - expected["convert_gauge_to_sum"] = newConvertGaugeToSumFactory() + expected["convert_sum_to_gauge"] = newConvertDatapointSumToGaugeFactory() + expected["convert_gauge_to_sum"] = newConvertDatapointGaugeToSumFactory() expected["convert_summary_sum_val_to_sum"] = newConvertSummarySumValToSumFactory() expected["convert_summary_count_val_to_sum"] = newConvertSummaryCountValToSumFactory() @@ -31,8 +32,12 @@ func Test_DataPointFunctions(t *testing.T) { func Test_MetricFunctions(t *testing.T) { expected := ottlfuncs.StandardFuncs[ottlmetric.TransformContext]() + expected["convert_sum_to_gauge"] = newConvertSumToGaugeFactory() + expected["convert_gauge_to_sum"] = newConvertGaugeToSumFactory() expected["extract_sum_metric"] = newExtractSumMetricFactory() expected["extract_count_metric"] = newExtractCountMetricFactory() + + defer testutil.SetFeatureGateForTest(t, useConvertBetweenSumAndGaugeMetricContext, true)() actual := MetricFunctions() require.Equal(t, len(expected), len(actual)) for k := range actual { diff --git a/receiver/chronyreceiver/go.mod b/receiver/chronyreceiver/go.mod index 48a65b20b990..4edfad8427a6 100644 --- a/receiver/chronyreceiver/go.mod +++ b/receiver/chronyreceiver/go.mod @@ -3,7 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/receiver/chrony go 1.20 require ( - github.com/facebook/time v0.0.0-20220713225404-f7a0d7702d50 + github.com/facebook/time v0.0.0-20231108195549-620e14e718fb github.com/google/go-cmp v0.6.0 github.com/stretchr/testify v1.8.4 github.com/tilinna/clock v1.1.0 diff --git a/receiver/chronyreceiver/go.sum b/receiver/chronyreceiver/go.sum index cbc9156d963f..d0f8ad878617 100644 --- a/receiver/chronyreceiver/go.sum +++ b/receiver/chronyreceiver/go.sum @@ -13,8 +13,8 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF 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/facebook/time v0.0.0-20220713225404-f7a0d7702d50 h1:3fALCgsB+zI8Bxlv4ph4lCgt1CEQHIdU5sWxbkaMkuc= -github.com/facebook/time v0.0.0-20220713225404-f7a0d7702d50/go.mod h1:IQmM+Ezbn5X7gpDO0IjKU5RmW9xT1a19dLp+NbivoXE= +github.com/facebook/time v0.0.0-20231108195549-620e14e718fb h1:5sihTI/ZuTyL9vudiEnP0kcNLZIv9TQwRlZ1x0bc33E= +github.com/facebook/time v0.0.0-20231108195549-620e14e718fb/go.mod h1:O8nuAUhv2TubINRTU9kKPsqOoQtUts0Q81yac6PlQfE= github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= diff --git a/receiver/datadogreceiver/go.mod b/receiver/datadogreceiver/go.mod index f8bb904dfccc..cc08d17fa044 100644 --- a/receiver/datadogreceiver/go.mod +++ b/receiver/datadogreceiver/go.mod @@ -14,6 +14,7 @@ require ( go.opentelemetry.io/collector/receiver v0.89.0 go.opentelemetry.io/collector/semconv v0.89.0 go.uber.org/multierr v1.11.0 + google.golang.org/protobuf v1.31.0 ) require ( @@ -64,7 +65,6 @@ require ( 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 - google.golang.org/protobuf v1.31.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/receiver/datadogreceiver/receiver.go b/receiver/datadogreceiver/receiver.go index 51ef2cbb706b..b80498d5fe67 100644 --- a/receiver/datadogreceiver/receiver.go +++ b/receiver/datadogreceiver/receiver.go @@ -52,6 +52,7 @@ func (ddr *datadogReceiver) Start(_ context.Context, host component.Host) error ddmux.HandleFunc("/v0.4/traces", ddr.handleTraces) ddmux.HandleFunc("/v0.5/traces", ddr.handleTraces) ddmux.HandleFunc("/v0.7/traces", ddr.handleTraces) + ddmux.HandleFunc("/api/v0.2/traces", ddr.handleTraces) var err error ddr.server, err = ddr.config.HTTPServerSettings.ToServer( @@ -88,22 +89,25 @@ func (ddr *datadogReceiver) handleTraces(w http.ResponseWriter, req *http.Reques defer func(spanCount *int) { ddr.tReceiver.EndTracesOp(obsCtx, "datadog", *spanCount, err) }(&spanCount) - var ddTraces *pb.TracerPayload + var ddTraces []*pb.TracerPayload ddTraces, err = handlePayload(req) if err != nil { http.Error(w, "Unable to unmarshal reqs", http.StatusBadRequest) ddr.params.Logger.Error("Unable to unmarshal reqs") return } - - otelTraces := toTraces(ddTraces, req) - spanCount = otelTraces.SpanCount() - err = ddr.nextConsumer.ConsumeTraces(obsCtx, otelTraces) - if err != nil { - http.Error(w, "Trace consumer errored out", http.StatusInternalServerError) - ddr.params.Logger.Error("Trace consumer errored out") - } else { - _, _ = w.Write([]byte("OK")) + for _, ddTrace := range ddTraces { + otelTraces := toTraces(ddTrace, req) + spanCount = otelTraces.SpanCount() + err = ddr.nextConsumer.ConsumeTraces(obsCtx, otelTraces) + if err != nil { + http.Error(w, "Trace consumer errored out", http.StatusInternalServerError) + ddr.params.Logger.Error("Trace consumer errored out") + return + } } + + _, _ = w.Write([]byte("OK")) + } diff --git a/receiver/datadogreceiver/translator.go b/receiver/datadogreceiver/translator.go index cd9bc38c2bba..eda82b511c23 100644 --- a/receiver/datadogreceiver/translator.go +++ b/receiver/datadogreceiver/translator.go @@ -19,6 +19,7 @@ import ( "go.opentelemetry.io/collector/pdata/ptrace" semconv "go.opentelemetry.io/collector/semconv/v1.16.0" "go.uber.org/multierr" + "google.golang.org/protobuf/proto" ) const ( @@ -192,7 +193,9 @@ func putBuffer(buffer *bytes.Buffer) { bufferPool.Put(buffer) } -func handlePayload(req *http.Request) (tp *pb.TracerPayload, err error) { +func handlePayload(req *http.Request) (tp []*pb.TracerPayload, err error) { + var tracerPayloads []*pb.TracerPayload + defer func() { _, errs := io.Copy(io.Discard, req.Body) err = multierr.Combine(err, errs, req.Body.Close()) @@ -206,8 +209,11 @@ func handlePayload(req *http.Request) (tp *pb.TracerPayload, err error) { return nil, err } var tracerPayload pb.TracerPayload - _, err = tracerPayload.UnmarshalMsg(buf.Bytes()) - return &tracerPayload, err + if _, err = tracerPayload.UnmarshalMsg(buf.Bytes()); err != nil { + return nil, err + } + + tracerPayloads = append(tracerPayloads, &tracerPayload) case strings.HasPrefix(req.URL.Path, "/v0.5"): buf := getBuffer() defer putBuffer(buf) @@ -215,37 +221,60 @@ func handlePayload(req *http.Request) (tp *pb.TracerPayload, err error) { return nil, err } var traces pb.Traces - err = traces.UnmarshalMsgDictionary(buf.Bytes()) - return &pb.TracerPayload{ + + if err = traces.UnmarshalMsgDictionary(buf.Bytes()); err != nil { + return nil, err + } + + tracerPayload := &pb.TracerPayload{ LanguageName: req.Header.Get("Datadog-Meta-Lang"), LanguageVersion: req.Header.Get("Datadog-Meta-Lang-Version"), TracerVersion: req.Header.Get("Datadog-Meta-Tracer-Version"), Chunks: traceChunksFromTraces(traces), - }, err + } + tracerPayloads = append(tracerPayloads, tracerPayload) + case strings.HasPrefix(req.URL.Path, "/v0.1"): var spans []pb.Span if err = json.NewDecoder(req.Body).Decode(&spans); err != nil { return nil, err } - return &pb.TracerPayload{ + tracerPayload := &pb.TracerPayload{ LanguageName: req.Header.Get("Datadog-Meta-Lang"), LanguageVersion: req.Header.Get("Datadog-Meta-Lang-Version"), TracerVersion: req.Header.Get("Datadog-Meta-Tracer-Version"), Chunks: traceChunksFromSpans(spans), - }, nil + } + tracerPayloads = append(tracerPayloads, tracerPayload) + case strings.HasPrefix(req.URL.Path, "/api/v0.2"): + buf := getBuffer() + defer putBuffer(buf) + if _, err = io.Copy(buf, req.Body); err != nil { + return nil, err + } + + var agentPayload pb.AgentPayload + if err = proto.Unmarshal(buf.Bytes(), &agentPayload); err != nil { + return nil, err + } + + return agentPayload.TracerPayloads, err default: var traces pb.Traces if err = decodeRequest(req, &traces); err != nil { return nil, err } - return &pb.TracerPayload{ + tracerPayload := &pb.TracerPayload{ LanguageName: req.Header.Get("Datadog-Meta-Lang"), LanguageVersion: req.Header.Get("Datadog-Meta-Lang-Version"), TracerVersion: req.Header.Get("Datadog-Meta-Tracer-Version"), Chunks: traceChunksFromTraces(traces), - }, err + } + tracerPayloads = append(tracerPayloads, tracerPayload) } + + return tracerPayloads, nil } func decodeRequest(req *http.Request, dest *pb.Traces) (err error) { diff --git a/receiver/datadogreceiver/translator_test.go b/receiver/datadogreceiver/translator_test.go index 472e05fc07ad..983ff0bf5f8a 100644 --- a/receiver/datadogreceiver/translator_test.go +++ b/receiver/datadogreceiver/translator_test.go @@ -5,6 +5,7 @@ package datadogreceiver // import "github.com/open-telemetry/opentelemetry-colle import ( "bytes" + "fmt" "io" "net/http" "testing" @@ -13,6 +14,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" vmsgp "github.com/vmihailenco/msgpack/v4" + "google.golang.org/protobuf/proto" ) var data = [2]any{ @@ -57,6 +59,16 @@ var data = [2]any{ }, } +func getTraces(t *testing.T) (traces pb.Traces) { + payload, err := vmsgp.Marshal(&data) + assert.NoError(t, err) + if err2 := traces.UnmarshalMsgDictionary(payload); err2 != nil { + t.Fatal(err) + } + return traces + +} + func TestTracePayloadV05Unmarshalling(t *testing.T) { var traces pb.Traces @@ -65,6 +77,7 @@ func TestTracePayloadV05Unmarshalling(t *testing.T) { require.NoError(t, traces.UnmarshalMsgDictionary(payload), "Must not error when marshaling content") req, _ := http.NewRequest(http.MethodPost, "/v0.5/traces", io.NopCloser(bytes.NewReader(payload))) + translated := toTraces(&pb.TracerPayload{ LanguageName: req.Header.Get("Datadog-Meta-Lang"), LanguageVersion: req.Header.Get("Datadog-Meta-Lang-Version"), @@ -84,12 +97,7 @@ func TestTracePayloadV05Unmarshalling(t *testing.T) { } func TestTracePayloadV07Unmarshalling(t *testing.T) { - var traces pb.Traces - payload, err := vmsgp.Marshal(&data) - assert.NoError(t, err) - if err2 := traces.UnmarshalMsgDictionary(payload); err2 != nil { - t.Fatal(err2) - } + traces := getTraces(t) apiPayload := pb.TracerPayload{ LanguageName: "1", LanguageVersion: "1", @@ -100,7 +108,9 @@ func TestTracePayloadV07Unmarshalling(t *testing.T) { bytez, _ := apiPayload.MarshalMsg(reqBytes) req, _ := http.NewRequest(http.MethodPost, "/v0.7/traces", io.NopCloser(bytes.NewReader(bytez))) - translated, _ := handlePayload(req) + translatedPayloads, _ := handlePayload(req) + assert.Equal(t, len(translatedPayloads), 1, "Expected one translated payload") + translated := translatedPayloads[0] span := translated.GetChunks()[0].GetSpans()[0] assert.NotNil(t, span) assert.Equal(t, 4, len(span.GetMeta()), "missing attributes") @@ -126,3 +136,45 @@ func BenchmarkTranslatorv07(b *testing.B) { } b.StopTimer() } + +func TestTracePayloadApiV02Unmarshalling(t *testing.T) { + traces := getTraces(t) + agentPayload := agentPayloadFromTraces(&traces) + + bytez, _ := proto.Marshal(&agentPayload) + req, _ := http.NewRequest(http.MethodPost, "/api/v0.2/traces", io.NopCloser(bytes.NewReader(bytez))) + + translatedPayloads, _ := handlePayload(req) + assert.Equal(t, len(translatedPayloads), 2, "Expected two translated payload") + for _, translated := range translatedPayloads { + assert.NotNil(t, translated) + assert.Equal(t, 1, len(translated.Chunks)) + assert.Equal(t, 1, len(translated.Chunks[0].Spans)) + span := translated.Chunks[0].Spans[0] + + assert.NotNil(t, span) + assert.Equal(t, 4, len(span.Meta), "missing attributes") + assert.Equal(t, "my-service", span.Meta["service.name"]) + assert.Equal(t, "my-name", span.Name) + assert.Equal(t, "my-resource", span.Resource) + } +} + +func agentPayloadFromTraces(traces *pb.Traces) (agentPayload pb.AgentPayload) { + numberOfTraces := 2 + var tracerPayloads []*pb.TracerPayload + for i := 0; i < numberOfTraces; i++ { + payload := &pb.TracerPayload{ + LanguageName: fmt.Sprintf("%d", i), + LanguageVersion: fmt.Sprintf("%d", i), + Chunks: traceChunksFromTraces(*traces), + TracerVersion: fmt.Sprintf("%d", i), + } + tracerPayloads = append(tracerPayloads, payload) + } + + return pb.AgentPayload{ + TracerPayloads: tracerPayloads, + } + +} diff --git a/receiver/oracledbreceiver/go.mod b/receiver/oracledbreceiver/go.mod index 8a4569a2fd8d..059f7ff61fd0 100644 --- a/receiver/oracledbreceiver/go.mod +++ b/receiver/oracledbreceiver/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/google/go-cmp v0.6.0 - github.com/sijms/go-ora/v2 v2.7.20 + github.com/sijms/go-ora/v2 v2.7.22 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.89.0 go.opentelemetry.io/collector/confmap v0.89.0 diff --git a/receiver/oracledbreceiver/go.sum b/receiver/oracledbreceiver/go.sum index deda4618d3e5..1d05b42641c1 100644 --- a/receiver/oracledbreceiver/go.sum +++ b/receiver/oracledbreceiver/go.sum @@ -81,8 +81,8 @@ github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lne github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI= github.com/prometheus/statsd_exporter v0.22.7 h1:7Pji/i2GuhK6Lu7DHrtTkFmNBCudCPT1pX2CziuyQR0= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/sijms/go-ora/v2 v2.7.20 h1:Q+/zNx3DMgytXMAvIbt/pUJcYj2jMRv/2Zg1DDlWhTY= -github.com/sijms/go-ora/v2 v2.7.20/go.mod h1:EHxlY6x7y9HAsdfumurRfTd+v8NrEOTR3Xl4FWlH6xk= +github.com/sijms/go-ora/v2 v2.7.22 h1:B2mSLhDDWTgsjdM0d/O7iJn041cBy5z7fA8sR082vCg= +github.com/sijms/go-ora/v2 v2.7.22/go.mod h1:EHxlY6x7y9HAsdfumurRfTd+v8NrEOTR3Xl4FWlH6xk= github.com/stretchr/objx v0.1.0/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/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= diff --git a/receiver/sqlqueryreceiver/go.mod b/receiver/sqlqueryreceiver/go.mod index 315f928a07fd..80fdfa47954e 100644 --- a/receiver/sqlqueryreceiver/go.mod +++ b/receiver/sqlqueryreceiver/go.mod @@ -12,7 +12,7 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.89.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.89.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza v0.89.0 - github.com/sijms/go-ora/v2 v2.7.20 + github.com/sijms/go-ora/v2 v2.7.22 github.com/snowflakedb/gosnowflake v1.6.25 github.com/stretchr/testify v1.8.4 github.com/testcontainers/testcontainers-go v0.26.0 diff --git a/receiver/sqlqueryreceiver/go.sum b/receiver/sqlqueryreceiver/go.sum index 4953dd459c4a..b3e38d447582 100644 --- a/receiver/sqlqueryreceiver/go.sum +++ b/receiver/sqlqueryreceiver/go.sum @@ -296,8 +296,8 @@ github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg 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/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/sijms/go-ora/v2 v2.7.20 h1:Q+/zNx3DMgytXMAvIbt/pUJcYj2jMRv/2Zg1DDlWhTY= -github.com/sijms/go-ora/v2 v2.7.20/go.mod h1:EHxlY6x7y9HAsdfumurRfTd+v8NrEOTR3Xl4FWlH6xk= +github.com/sijms/go-ora/v2 v2.7.22 h1:B2mSLhDDWTgsjdM0d/O7iJn041cBy5z7fA8sR082vCg= +github.com/sijms/go-ora/v2 v2.7.22/go.mod h1:EHxlY6x7y9HAsdfumurRfTd+v8NrEOTR3Xl4FWlH6xk= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= diff --git a/renovate.json b/renovate.json index 4784a0a49e54..b0a17b5fabc2 100644 --- a/renovate.json +++ b/renovate.json @@ -32,6 +32,26 @@ "matchManagers": ["github-actions"], "groupName": "github-actions deps" }, + { + "matchManagers": ["gomod"], + "matchSourceUrlPrefixes": ["https://github.com/aws"], + "groupName": "All github.com/aws packages" + }, + { + "matchManagers": ["gomod"], + "matchSourceUrlPrefixes": ["https://github.com/azure"], + "groupName": "All github.com/azure packages" + }, + { + "matchManagers": ["gomod"], + "matchSourceUrlPrefixes": ["https://github.com/datadog"], + "groupName": "All github.com/datadog packages" + }, + { + "matchManagers": ["gomod"], + "matchSourceUrlPrefixes": ["https://github.com/googlecloudplatform"], + "groupName": "All github.com/googlecloudplatform packages" + }, { "matchManagers": ["gomod"], "matchUpdateTypes": ["minor", "major"] diff --git a/testbed/datareceivers/jaeger.go b/testbed/datareceivers/jaeger.go index e52790d2c52a..3cdaf704bbec 100644 --- a/testbed/datareceivers/jaeger.go +++ b/testbed/datareceivers/jaeger.go @@ -52,13 +52,15 @@ func (jr *jaegerDataReceiver) Stop() error { func (jr *jaegerDataReceiver) GenConfigYAMLStr() string { // Note that this generates an exporter config for agent. + // The Jaeger exporter is no longer supported, therefore + // we export data using OTLP instead return fmt.Sprintf(` - jaeger: + otlp/jaeger: endpoint: "127.0.0.1:%d" tls: insecure: true`, jr.Port) } func (jr *jaegerDataReceiver) ProtocolName() string { - return "jaeger" + return "otlp/jaeger" } diff --git a/testbed/testbed/test_case.go b/testbed/testbed/test_case.go index 24801797bca2..2bed52bb39be 100644 --- a/testbed/testbed/test_case.go +++ b/testbed/testbed/test_case.go @@ -114,7 +114,7 @@ func NewTestCase( tc.LoadGenerator, err = NewLoadGenerator(dataProvider, sender) require.NoError(t, err, "Cannot create generator") - tc.MockBackend = NewMockBackend(tc.composeTestResultFileName("backend.log"), receiver) + tc.MockBackend = NewMockBackend(tc.ComposeTestResultFileName("backend.log"), receiver) tc.MockBackend.WithDecisionFunc(tc.decision) go tc.logStats() @@ -122,7 +122,7 @@ func NewTestCase( return &tc } -func (tc *TestCase) composeTestResultFileName(fileName string) string { +func (tc *TestCase) ComposeTestResultFileName(fileName string) string { fileName, err := filepath.Abs(path.Join(tc.resultDir, fileName)) require.NoError(tc.t, err, "Cannot resolve %s", fileName) return fileName @@ -131,7 +131,7 @@ func (tc *TestCase) composeTestResultFileName(fileName string) string { // StartAgent starts the agent and redirects its standard output and standard error // to "agent.log" file located in the test directory. func (tc *TestCase) StartAgent(args ...string) { - logFileName := tc.composeTestResultFileName("agent.log") + logFileName := tc.ComposeTestResultFileName("agent.log") startParams := StartParams{ Name: "Agent", diff --git a/testbed/tests/scenarios.go b/testbed/tests/scenarios.go index 1991353fc524..e61f1032064f 100644 --- a/testbed/tests/scenarios.go +++ b/testbed/tests/scenarios.go @@ -179,6 +179,70 @@ func Scenario10kItemsPerSecond( tc.ValidateData() } +// Scenario10kItemsPerSecondAlternateBackend runs 10k data items/sec test using specified sender and receiver protocols. +// The only difference from Scenario10kItemsPerSecond is that this method can be used to specify a different backend. This +// is useful when testing components for which there is no exporter that emits the same format as the receiver format. +func Scenario10kItemsPerSecondAlternateBackend( + t *testing.T, + sender testbed.DataSender, + receiver testbed.DataReceiver, + backend testbed.DataReceiver, + resourceSpec testbed.ResourceSpec, + resultsSummary testbed.TestResultsSummary, + processors map[string]string, + extensions map[string]string, +) { + resultDir, err := filepath.Abs(path.Join("results", t.Name())) + require.NoError(t, err) + + options := testbed.LoadOptions{ + DataItemsPerSecond: 10_000, + ItemsPerBatch: 100, + Parallel: 1, + } + agentProc := testbed.NewChildProcessCollector() + + configStr := createConfigYaml(t, sender, receiver, resultDir, processors, extensions) + fmt.Println(configStr) + configCleanup, err := agentProc.PrepareConfig(configStr) + require.NoError(t, err) + defer configCleanup() + + dataProvider := testbed.NewPerfTestDataProvider(options) + tc := testbed.NewTestCase( + t, + dataProvider, + sender, + receiver, + agentProc, + &testbed.PerfTestValidator{}, + resultsSummary, + testbed.WithResourceLimits(resourceSpec), + ) + defer tc.Stop() + + // for some scenarios, the mockbackend isn't the same as the receiver + // therefore, the backend must be initialized with the correct receiver + tc.MockBackend = testbed.NewMockBackend(tc.ComposeTestResultFileName("backend.log"), backend) + + tc.StartBackend() + tc.StartAgent() + + tc.StartLoad(options) + + tc.Sleep(tc.Duration) + + tc.StopLoad() + + tc.WaitFor(func() bool { return tc.LoadGenerator.DataItemsSent() > 0 }, "load generator started") + tc.WaitFor(func() bool { return tc.LoadGenerator.DataItemsSent() == tc.MockBackend.DataItemsReceived() }, + "all data items received") + + tc.StopAgent() + + tc.ValidateData() +} + // TestCase for Scenario1kSPSWithAttrs func. type TestCase struct { attrCount int diff --git a/testbed/tests/syslog_integration_test.go b/testbed/tests/syslog_integration_test.go index 04195a0105c3..49d59eb5cc8f 100644 --- a/testbed/tests/syslog_integration_test.go +++ b/testbed/tests/syslog_integration_test.go @@ -145,6 +145,12 @@ service: }) require.NoError(t, err) + t.Cleanup(func() { + stopped, e := collector.Stop() + require.NoError(t, e) + require.True(t, stopped) + }) + // prepare data message := "" diff --git a/testbed/tests/trace_test.go b/testbed/tests/trace_test.go index a5a560f6adcd..4a9c818fcac6 100644 --- a/testbed/tests/trace_test.go +++ b/testbed/tests/trace_test.go @@ -37,15 +37,6 @@ func TestTrace10kSPS(t *testing.T) { receiver testbed.DataReceiver resourceSpec testbed.ResourceSpec }{ - { - "JaegerGRPC", - datasenders.NewJaegerGRPCDataSender(testbed.DefaultHost, testbed.GetAvailablePort(t)), - datareceivers.NewJaegerDataReceiver(testbed.GetAvailablePort(t)), - testbed.ResourceSpec{ - ExpectedMaxCPU: 40, - ExpectedMaxRAM: 100, - }, - }, { "OpenCensus", datasenders.NewOCTraceDataSender(testbed.DefaultHost, testbed.GetAvailablePort(t)), @@ -159,6 +150,28 @@ func TestTrace10kSPS(t *testing.T) { } } +func TestTrace10kSPSJaegerGRPC(t *testing.T) { + port := testbed.GetAvailablePort(t) + receiver := datareceivers.NewJaegerDataReceiver(port) + Scenario10kItemsPerSecondAlternateBackend( + t, + datasenders.NewJaegerGRPCDataSender(testbed.DefaultHost, testbed.GetAvailablePort(t)), + receiver, + testbed.NewOTLPDataReceiver(port), + testbed.ResourceSpec{ + ExpectedMaxCPU: 40, + ExpectedMaxRAM: 100, + }, + performanceResultsSummary, + map[string]string{ + "batch": ` + batch: +`, + }, + nil, + ) +} + func TestTraceNoBackend10kSPS(t *testing.T) { limitProcessors := map[string]string{