From 4146bd1403be895f9c1b1193e1aa177039c32001 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Dec 2022 07:38:06 -0800 Subject: [PATCH 1/4] Bump github.com/itchyny/gojq from 0.12.9 to 0.12.10 in /internal/tools (#3510) * Bump github.com/itchyny/gojq from 0.12.9 to 0.12.10 in /internal/tools Bumps [github.com/itchyny/gojq](https://github.com/itchyny/gojq) from 0.12.9 to 0.12.10. - [Release notes](https://github.com/itchyny/gojq/releases) - [Changelog](https://github.com/itchyny/gojq/blob/main/CHANGELOG.md) - [Commits](https://github.com/itchyny/gojq/compare/v0.12.9...v0.12.10) --- updated-dependencies: - dependency-name: github.com/itchyny/gojq dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update build-tools * Update golangci-lint * Run dependabot config gen Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tyler Yahn Co-authored-by: Tyler Yahn --- .github/dependabot.yml | 9 +++++ internal/tools/go.mod | 33 +++++++++--------- internal/tools/go.sum | 76 ++++++++++++++++++------------------------ 3 files changed, 58 insertions(+), 60 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index a38cf2d16b1..51a3c3eb726 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -10,6 +10,15 @@ updates: schedule: interval: weekly day: sunday + - package-ecosystem: docker + directory: / + labels: + - dependencies + - docker + - Skip Changelog + schedule: + interval: weekly + day: sunday - package-ecosystem: gomod directory: / labels: diff --git a/internal/tools/go.mod b/internal/tools/go.mod index cfa45b2bbef..d9ae24949e3 100644 --- a/internal/tools/go.mod +++ b/internal/tools/go.mod @@ -6,13 +6,13 @@ require ( github.com/client9/misspell v0.3.4 github.com/gogo/protobuf v1.3.2 github.com/golangci/golangci-lint v1.50.1 - github.com/itchyny/gojq v0.12.9 + github.com/itchyny/gojq v0.12.10 github.com/jcchavezs/porto v0.4.0 github.com/wadey/gocovmerge v0.0.0-20160331181800-b5bfa59ec0ad - go.opentelemetry.io/build-tools/crosslink v0.0.0-20220706175322-58de0d25b85c - go.opentelemetry.io/build-tools/dbotconf v0.0.0-20220706175322-58de0d25b85c - go.opentelemetry.io/build-tools/multimod v0.0.0-20220706175322-58de0d25b85c - go.opentelemetry.io/build-tools/semconvgen v0.0.0-20220706175322-58de0d25b85c + go.opentelemetry.io/build-tools/crosslink v0.3.0 + go.opentelemetry.io/build-tools/dbotconf v0.3.0 + go.opentelemetry.io/build-tools/multimod v0.3.0 + go.opentelemetry.io/build-tools/semconvgen v0.3.0 golang.org/x/tools v0.3.0 ) @@ -91,8 +91,8 @@ require ( github.com/hashicorp/hcl v1.0.0 // indirect github.com/hexops/gotextdiff v1.0.3 // indirect github.com/imdario/mergo v0.3.12 // indirect - github.com/inconshreveable/mousetrap v1.0.1 // indirect - github.com/itchyny/timefmt-go v0.1.4 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/itchyny/timefmt-go v0.1.5 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jgautheron/goconst v1.5.1 // indirect github.com/jingyugao/rowserrcheck v1.1.1 // indirect @@ -115,7 +115,7 @@ require ( github.com/matoous/godox v0.0.0-20210227103229-6504466cf951 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.16 // indirect - github.com/mattn/go-runewidth v0.0.13 // indirect + github.com/mattn/go-runewidth v0.0.14 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/mbilski/exhaustivestruct v1.2.0 // indirect github.com/mgechev/revive v1.2.4 // indirect @@ -127,7 +127,6 @@ require ( github.com/nishanths/exhaustive v0.8.3 // indirect github.com/nishanths/predeclared v0.2.2 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect - github.com/otiai10/copy v1.7.0 // indirect github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.5 // indirect github.com/phayes/checkstyle v0.0.0-20170904204023-bfd46e6a821d // indirect @@ -159,10 +158,10 @@ require ( github.com/sourcegraph/go-diff v0.6.1 // indirect github.com/spf13/afero v1.9.2 // indirect github.com/spf13/cast v1.5.0 // indirect - github.com/spf13/cobra v1.6.0 // indirect + github.com/spf13/cobra v1.6.1 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect - github.com/spf13/viper v1.13.0 // indirect + github.com/spf13/viper v1.14.0 // indirect github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect github.com/stbenjam/no-sprintf-host-port v0.1.1 // indirect github.com/stretchr/objx v0.5.0 // indirect @@ -181,18 +180,18 @@ require ( github.com/yagipy/maintidx v1.0.0 // indirect github.com/yeya24/promlinter v0.2.0 // indirect gitlab.com/bosi/decorder v0.2.3 // indirect - go.opentelemetry.io/build-tools v0.0.0-20220321164008-b8e03aff061a // indirect - go.uber.org/atomic v1.9.0 // indirect - go.uber.org/multierr v1.7.0 // indirect - go.uber.org/zap v1.21.0 // indirect + go.opentelemetry.io/build-tools v0.3.0 // indirect + go.uber.org/atomic v1.10.0 // indirect + go.uber.org/multierr v1.8.0 // indirect + go.uber.org/zap v1.24.0 // indirect golang.org/x/crypto v0.1.0 // indirect golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect golang.org/x/exp/typeparams v0.0.0-20220827204233-334a2380cb91 // indirect golang.org/x/mod v0.7.0 // indirect golang.org/x/net v0.2.0 // indirect golang.org/x/sync v0.1.0 // indirect - golang.org/x/sys v0.2.0 // indirect - golang.org/x/text v0.4.0 // indirect + golang.org/x/sys v0.3.0 // indirect + golang.org/x/text v0.5.0 // indirect google.golang.org/protobuf v1.28.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect diff --git a/internal/tools/go.sum b/internal/tools/go.sum index 01ce42ad7e2..4c2f1b835ed 100644 --- a/internal/tools/go.sum +++ b/internal/tools/go.sum @@ -81,7 +81,6 @@ github.com/ashanbrown/forbidigo v1.3.0/go.mod h1:vVW7PEdqEFqapJe95xHkTfB1+XvZXBF github.com/ashanbrown/makezero v1.1.1 h1:iCQ87C0V0vSyO+M9E/FZYbu65auqH0lnsOkf5FcB28s= github.com/ashanbrown/makezero v1.1.1/go.mod h1:i1bJLCRSCHOcOa9Y6MyF2FTfMZMFdHvxKHxgO5Z1axI= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -114,7 +113,6 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/cristalhq/acmd v0.8.1/go.mod h1:LG5oa43pE/BbxtfMoImHCQN++0Su7dzipdgBjMCBVDQ= @@ -320,13 +318,13 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1: github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc= github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/itchyny/gojq v0.12.9 h1:biKpbKwMxVYhCU1d6mR7qMr3f0Hn9F5k5YykCVb3gmM= -github.com/itchyny/gojq v0.12.9/go.mod h1:T4Ip7AETUXeGpD+436m+UEl3m3tokRgajd5pRfsR5oE= -github.com/itchyny/timefmt-go v0.1.4 h1:hFEfWVdwsEi+CY8xY2FtgWHGQaBaC3JeHd+cve0ynVM= -github.com/itchyny/timefmt-go v0.1.4/go.mod h1:nEP7L+2YmAbT2kZ2HfSs1d8Xtw9LY8D2stDBckWakZ8= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/itchyny/gojq v0.12.10 h1:6TcS0VYWS6wgntpF/4tnrzwdCMjiTxRAxIqZWfDsDQU= +github.com/itchyny/gojq v0.12.10/go.mod h1:o3FT8Gkbg/geT4pLI0tF3hvip5F3Y/uskjRz9OYa38g= +github.com/itchyny/timefmt-go v0.1.5 h1:G0INE2la8S6ru/ZI5JecgyzbbJNs5lG1RcBqa7Jm6GE= +github.com/itchyny/timefmt-go v0.1.5/go.mod h1:nEP7L+2YmAbT2kZ2HfSs1d8Xtw9LY8D2stDBckWakZ8= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jcchavezs/porto v0.4.0 h1:Zj7RligrxmDdKGo6fBO2xYAHxEgrVBfs1YAja20WbV4= @@ -364,7 +362,6 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxv github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -405,8 +402,8 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= -github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= +github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= @@ -441,14 +438,11 @@ github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6 github.com/onsi/ginkgo/v2 v2.1.4 h1:GNapqRSid3zijZ9H77KrgVG4/8KqiyRsxcSxe+7ApXY= github.com/onsi/gomega v1.20.0 h1:8W0cWlwFkflGPLltQvLRB7ZVD5HuP6ng320w2IS245Q= github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= -github.com/otiai10/copy v1.7.0 h1:hVoPiN+t+7d2nzzwMiDHPSOogsWAStewq3TwU05+clE= -github.com/otiai10/copy v1.7.0/go.mod h1:rmRl6QPdJj6EiUqXQ/4Nn2lLXoNQjFCQbbNrxgc/t3U= +github.com/otiai10/copy v1.9.0 h1:7KFNiCgZ91Ru4qW4CWPf/7jqtxLagGRmIxWldPP9VY4= github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= -github.com/otiai10/mint v1.3.3 h1:7JgpsBaN0uMkyju4tbYHu0mnM55hNKVYLsXmwr15NQI= -github.com/otiai10/mint v1.3.3/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml/v2 v2.0.5 h1:ipoSadvV8oGUjnUbMub59IDPPwfxF694nG/jwbMiyQg= @@ -546,15 +540,14 @@ github.com/spf13/afero v1.9.2 h1:j49Hj62F0n+DaZ1dDCvhABaPNSGNkt32oRFxI33IEMw= github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= -github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g= -github.com/spf13/cobra v1.6.0 h1:42a0n6jwCot1pUmomAp4T7DeMD+20LFv4Q54pxLf2LI= -github.com/spf13/cobra v1.6.0/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= +github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= +github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.13.0 h1:BWSJ/M+f+3nmdz9bxB+bWX28kkALN2ok11D0rSo8EJU= -github.com/spf13/viper v1.13.0/go.mod h1:Icm2xNL3/8uyh/wFuB1jI7TiTNKp8632Nwegu+zgdYw= +github.com/spf13/viper v1.14.0 h1:Rg7d3Lo706X9tHsJMUjdiwMpHB7W8WnSVOssIY+JElU= +github.com/spf13/viper v1.14.0/go.mod h1:WT//axPky3FdvXHzGw33dNdXXXfFQqmEalje+egj8As= github.com/ssgreg/nlreturn/v2 v2.2.1 h1:X4XDI7jstt3ySqGU86YGAURbxw3oTDPK9sPEi6YEwQ0= github.com/ssgreg/nlreturn/v2 v2.2.1/go.mod h1:E/iiPB78hV7Szg2YfRgyIrk1AD6JVMTRkkxBiELzh2I= github.com/stbenjam/no-sprintf-host-port v0.1.1 h1:tYugd/yrm1O0dV+ThCbaKZh195Dfm07ysF0U6JQXczc= @@ -572,7 +565,6 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.5/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= @@ -623,26 +615,24 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= -go.opentelemetry.io/build-tools v0.0.0-20220321164008-b8e03aff061a h1:yLxbGYl9MXOqD0o3unX/nJn+y+1loFNWZJWkfeguYV8= -go.opentelemetry.io/build-tools v0.0.0-20220321164008-b8e03aff061a/go.mod h1:gkLviEngQuoeD670EP1KA/Oj4i5oNAzb+pjkk+4ecaQ= -go.opentelemetry.io/build-tools/crosslink v0.0.0-20220706175322-58de0d25b85c h1:29qFnf/xOmEAGv7DwfLLnRejjIcksPdCw+Je0rIlj1Y= -go.opentelemetry.io/build-tools/crosslink v0.0.0-20220706175322-58de0d25b85c/go.mod h1:HI436k8NShByIY1P0z6IIrVByrJQ9//qnJTFocdY2nM= -go.opentelemetry.io/build-tools/dbotconf v0.0.0-20220706175322-58de0d25b85c h1:LCMy1QnOiursbSFlKYCGkfnSZfRiZgqGfypltWuWn/0= -go.opentelemetry.io/build-tools/dbotconf v0.0.0-20220706175322-58de0d25b85c/go.mod h1:IIF9IbxlzOnHM0E21vDeGSKHDYImShTJ4qTvKs4m+G4= -go.opentelemetry.io/build-tools/multimod v0.0.0-20220706175322-58de0d25b85c h1:NaZFvE0Vn3yWNnZxQEl5Zu6Fbl6xGxFy5eqOPi865Q8= -go.opentelemetry.io/build-tools/multimod v0.0.0-20220706175322-58de0d25b85c/go.mod h1:EOBbXCes6aVxWqvSy3v1AJD8vtC4++fW1UH5AB8W4uM= -go.opentelemetry.io/build-tools/semconvgen v0.0.0-20220706175322-58de0d25b85c h1:sdRLGv2B9aIRQdLLKlQ6RT/N5MOgsDI+UeYQqNP1g5I= -go.opentelemetry.io/build-tools/semconvgen v0.0.0-20220706175322-58de0d25b85c/go.mod h1:5ykZFab0x3jatwG5Rf2idlko5e5Z42XsyJLMg4h35bg= +go.opentelemetry.io/build-tools v0.3.0 h1:ehCOkLXOy/AryssN74PzCMya6MWoReFhygnyWGddC6Y= +go.opentelemetry.io/build-tools v0.3.0/go.mod h1:WewIEPPmfvHi9CvNXaAqfLHQRdv4bFpy7V5PTyMUQno= +go.opentelemetry.io/build-tools/crosslink v0.3.0 h1:XhhedQvxZTjbGQXAAqO7BNiVGIMArZzS2Lj5S+98w4M= +go.opentelemetry.io/build-tools/crosslink v0.3.0/go.mod h1:e+s2mLk6AI79HkvLrTa4SeM0oQ6ykFFeMyRCfLz0eX8= +go.opentelemetry.io/build-tools/dbotconf v0.3.0 h1:moQZLXl+lqPEkp3pfJxQWdQQ17DOzo4CMnEW0dJQWhc= +go.opentelemetry.io/build-tools/dbotconf v0.3.0/go.mod h1:gIOWVOWTrooqH3IrROAA8Lyv8HwnXfrhE2tbtyOgaHE= +go.opentelemetry.io/build-tools/multimod v0.3.0 h1:eCr6XYpEFA+VZ3aaD+81HEmgotP963sN/TjOAgx7A2k= +go.opentelemetry.io/build-tools/multimod v0.3.0/go.mod h1:I+OYyA29iAxaGhoxLvqgcYkOMQeKJ6R3sEn1YQNddlQ= +go.opentelemetry.io/build-tools/semconvgen v0.3.0 h1:ml4Rsej3E6u46TCtOMjmHDkCWin2fDx0xE9rdkH7Iu0= +go.opentelemetry.io/build-tools/semconvgen v0.3.0/go.mod h1:qsPYyE3sd1+ikaock1R9ftHc9IObqCIvRXTHWcg4Ta8= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= -go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= +go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= -go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= -go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.uber.org/multierr v1.7.0 h1:zaiO/rmgFjbmCXdSYJWQcdvOCsthmdaHfr3Gm2Kx4Ec= -go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= -go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8= -go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= +go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= +go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= +go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= +go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -828,8 +818,8 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0 h1:z85xZCsEl7bi/KwbNADeBYoOP0++7W1ipu+aGnpwzRM= @@ -841,8 +831,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM= +golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= From 9c61547163769696926915d8f4bb794608698f2a Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Wed, 7 Dec 2022 11:38:22 -0800 Subject: [PATCH 2/4] Remove the deprecated view package (#3520) * Remove the deprecated view package * Add change to changelog * Fix changelog header --- CHANGELOG.md | 4 + sdk/metric/view/doc.go | 23 -- sdk/metric/view/example_test.go | 196 ------------- sdk/metric/view/instrument.go | 32 --- sdk/metric/view/instrumentkind.go | 64 ----- sdk/metric/view/view.go | 236 ---------------- sdk/metric/view/view_test.go | 444 ------------------------------ 7 files changed, 4 insertions(+), 995 deletions(-) delete mode 100644 sdk/metric/view/doc.go delete mode 100644 sdk/metric/view/example_test.go delete mode 100644 sdk/metric/view/instrument.go delete mode 100644 sdk/metric/view/instrumentkind.go delete mode 100644 sdk/metric/view/view.go delete mode 100644 sdk/metric/view/view_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f130b8be10..c841901a7b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [Unreleased] +### Removed + +- The deprecated `go.opentelemetry.io/otel/sdk/metric/view` package is removed. (#3520) + ## [1.11.2/0.34.0] 2022-12-05 ### Added diff --git a/sdk/metric/view/doc.go b/sdk/metric/view/doc.go deleted file mode 100644 index c757b75bd35..00000000000 --- a/sdk/metric/view/doc.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package view provides types and functionality that customize the metric -// telemetry an SDK will produce. The View type is used when a Reader is -// registered with a MeterProvider in the go.opentelemetry.io/otel/sdk/metric -// package. See the WithReader option in that package for more information on -// how this registration takes place. -// -// Deprecated: Use Instrument, InstrumentKind, View, and NewView in -// go.opentelemetry.io/otel/sdk/metric instead. -package view // import "go.opentelemetry.io/otel/sdk/metric/view" diff --git a/sdk/metric/view/example_test.go b/sdk/metric/view/example_test.go deleted file mode 100644 index 76d99df6d45..00000000000 --- a/sdk/metric/view/example_test.go +++ /dev/null @@ -1,196 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package view // import "go.opentelemetry.io/otel/sdk/metric/view" - -import ( - "fmt" - - "go.opentelemetry.io/otel/sdk/instrumentation" - "go.opentelemetry.io/otel/sdk/metric/aggregation" -) - -func Example() { - // The "active-users" instrument created by the - // "github.com/super/noisy/instrumentation/package" your project includes - // has a bug, it records a measurment any time a user has any activity. - // This is causing a lot of strain on your program without providing any - // value to you. The next version of - // "github.com/super/noisy/instrumentation/package" corrects the - // instrumentation to only record a value when a user logs in, but it - // isn't out yet. - // - // Use a View to drop these measurments while you wait for the fix to come - // from upstream. - - v, err := New( - MatchInstrumentName("active-users"), - MatchInstrumentationScope(instrumentation.Scope{ - Name: "github.com/super/noisy/instrumentation/package", - Version: "v0.22.0", // Only match the problematic instrumentation version. - }), - WithSetAggregation(aggregation.Drop{}), - ) - if err != nil { - panic(err) - } - - // The SDK this view is registered with calls TransformInstrument when an - // instrument is created. Test that our fix will work as intended. - i, _ := v.TransformInstrument(Instrument{ - Name: "active-users", - Scope: instrumentation.Scope{ - Name: "github.com/super/noisy/instrumentation/package", - Version: "v0.22.0", - }, - Aggregation: aggregation.LastValue{}, - }) - fmt.Printf("Instrument{%q: %s}: %#v\n", i.Name, i.Scope.Version, i.Aggregation) - - // Also, ensure the next version will not be transformed. - _, ok := v.TransformInstrument(Instrument{ - Name: "active-users", - Scope: instrumentation.Scope{ - Name: "github.com/super/noisy/instrumentation/package", - Version: "v0.23.0", - }, - Aggregation: aggregation.LastValue{}, - }) - fmt.Printf("Instrument{\"active-users\": v0.23.0} matched: %t\n", ok) - // Output: - // - // Instrument{"active-users": v0.22.0}: aggregation.Drop{} - // Instrument{"active-users": v0.23.0} matched: false -} - -func ExampleMatchInstrumentName() { - v, err := New(MatchInstrumentName("request-*")) // Wildcard match. - if err != nil { - panic(err) - } - - for _, i := range []Instrument{ - {Name: "request-count"}, - {Name: "request-rate"}, - {Name: "latency"}, - } { - // The SDK calls TransformInstrument when an instrument is created. - _, ok := v.TransformInstrument(i) - fmt.Printf("Instrument{%q} matched: %t\n", i.Name, ok) - } - // Output: - // Instrument{"request-count"} matched: true - // Instrument{"request-rate"} matched: true - // Instrument{"latency"} matched: false -} - -func ExampleMatchInstrumentKind() { - v, err := New(MatchInstrumentKind(SyncCounter)) - if err != nil { - panic(err) - } - - for _, i := range []Instrument{ - {Name: "synchronous counter", Kind: SyncCounter}, - {Name: "synchronous histogram", Kind: SyncHistogram}, - {Name: "asynchronous counter", Kind: AsyncCounter}, - } { - // The SDK calls TransformInstrument when an instrument is created. - _, ok := v.TransformInstrument(i) - fmt.Printf("Instrument{%q} matched: %t\n", i.Name, ok) - } - // Output: - // Instrument{"synchronous counter"} matched: true - // Instrument{"synchronous histogram"} matched: false - // Instrument{"asynchronous counter"} matched: false -} - -func ExampleMatchInstrumentationScope() { - v, err := New(MatchInstrumentationScope(instrumentation.Scope{ - Name: "custom/instrumentation/package", - Version: "v0.22.0", // Only match this version of instrumentation. - })) - if err != nil { - panic(err) - } - - for _, i := range []Instrument{ - {Name: "v1.0.0 instrumentation", Scope: instrumentation.Scope{ - Name: "custom/instrumentation/package", - Version: "v1.0.0", - }}, - {Name: "v0.22.0 instrumentation", Scope: instrumentation.Scope{ - Name: "custom/instrumentation/package", - Version: "v0.22.0", - }}, - } { - // The SDK calls TransformInstrument when an instrument is created. - _, ok := v.TransformInstrument(i) - fmt.Printf("Instrument{%q} matched: %t\n", i.Name, ok) - } - // Output: - // Instrument{"v1.0.0 instrumentation"} matched: false - // Instrument{"v0.22.0 instrumentation"} matched: true -} - -func ExampleWithRename() { - v, err := New(MatchInstrumentName("bad-name"), WithRename("good-name")) - if err != nil { - panic(err) - } - - // The SDK calls TransformInstrument when an instrument is created. - i, _ := v.TransformInstrument(Instrument{Name: "bad-name"}) - fmt.Printf("Instrument{%q}\n", i.Name) - // Output: Instrument{"good-name"} -} - -func ExampleWithSetDescription() { - v, err := New( - MatchInstrumentName("requests"), - WithSetDescription("Number of requests received"), - ) - if err != nil { - panic(err) - } - - // The SDK calls TransformInstrument when an instrument is created. - i, _ := v.TransformInstrument(Instrument{ - Name: "requests", - Description: "incorrect description", - }) - fmt.Printf("Instrument{%q: %s}\n", i.Name, i.Description) - // Output: Instrument{"requests": Number of requests received} -} - -func ExampleWithSetAggregation() { - v, err := New(MatchInstrumentationScope(instrumentation.Scope{ - Name: "super/noisy/instrumentation/package", - }), WithSetAggregation(aggregation.Drop{})) - if err != nil { - panic(err) - } - - // The SDK calls TransformInstrument when an instrument is created. - i, _ := v.TransformInstrument(Instrument{ - Name: "active-users", - Scope: instrumentation.Scope{ - Name: "super/noisy/instrumentation/package", - Version: "v0.5.0", - }, - Aggregation: aggregation.LastValue{}, - }) - fmt.Printf("Instrument{%q}: %#v\n", i.Name, i.Aggregation) - // Output: Instrument{"active-users"}: aggregation.Drop{} -} diff --git a/sdk/metric/view/instrument.go b/sdk/metric/view/instrument.go deleted file mode 100644 index 77536de2114..00000000000 --- a/sdk/metric/view/instrument.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package view // import "go.opentelemetry.io/otel/sdk/metric/view" - -import ( - "go.opentelemetry.io/otel/sdk/instrumentation" - "go.opentelemetry.io/otel/sdk/metric/aggregation" -) - -// Instrument uniquely identifies an instrument within a meter. -// -// Deprecated: Use Instrument in go.opentelemetry.io/otel/sdk/metric instead. -type Instrument struct { - Scope instrumentation.Scope - - Name string - Description string - Kind InstrumentKind - Aggregation aggregation.Aggregation -} diff --git a/sdk/metric/view/instrumentkind.go b/sdk/metric/view/instrumentkind.go deleted file mode 100644 index 357117e334a..00000000000 --- a/sdk/metric/view/instrumentkind.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package view // import "go.opentelemetry.io/otel/sdk/metric/view" - -// InstrumentKind describes the kind of instrument a Meter can create. -// -// Deprecated: Use InstrumentKind in go.opentelemetry.io/otel/sdk/metric -// instead. -type InstrumentKind uint8 - -// These are all the instrument kinds supported by the SDK. -const ( - // undefinedInstrument is an uninitialized instrument kind, should not be used. - //nolint:deadcode,varcheck - undefinedInstrument InstrumentKind = iota - // SyncCounter is an instrument kind that records increasing values - // synchronously in application code. - // - // Deprecated: Use InstrumentKindSyncCounter in - // go.opentelemetry.io/otel/sdk/metric instead. - SyncCounter - // SyncUpDownCounter is an instrument kind that records increasing and - // decreasing values synchronously in application code. - // - // Deprecated: Use InstrumentKindSyncUpDownCounter in - // go.opentelemetry.io/otel/sdk/metric instead. - SyncUpDownCounter - // SyncHistogram is an instrument kind that records a distribution of - // values synchronously in application code. - // - // Deprecated: Use InstrumentKindSyncHistogram in - // go.opentelemetry.io/otel/sdk/metric instead. - SyncHistogram - // AsyncCounter is an instrument kind that records increasing values in an - // asynchronous callback. - // - // Deprecated: Use InstrumentKindAsyncCounter in - // go.opentelemetry.io/otel/sdk/metric instead. - AsyncCounter - // AsyncUpDownCounter is an instrument kind that records increasing and - // decreasing values in an asynchronous callback. - // - // Deprecated: Use InstrumentKindAsyncUpDownCounter in - // go.opentelemetry.io/otel/sdk/metric instead. - AsyncUpDownCounter - // AsyncGauge is an instrument kind that records current values in an - // asynchronous callback. - // - // Deprecated: Use InstrumentKindAsyncGauge in - // go.opentelemetry.io/otel/sdk/metric instead. - AsyncGauge -) diff --git a/sdk/metric/view/view.go b/sdk/metric/view/view.go deleted file mode 100644 index 3e432afb3f8..00000000000 --- a/sdk/metric/view/view.go +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package view // import "go.opentelemetry.io/otel/sdk/metric/view" - -import ( - "fmt" - "regexp" - "strings" - - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/internal/global" - "go.opentelemetry.io/otel/sdk/instrumentation" - "go.opentelemetry.io/otel/sdk/metric/aggregation" -) - -// View provides users with the flexibility to customize the metrics that are -// output by the SDK. A View can be used to ignore, change the name, -// description, and aggregation of, and customize which attribute(s) are to be -// reported by Instruments. -// -// An empty View will match all instruments, and do no transformations. -// -// Deprecated: Use View in go.opentelemetry.io/otel/sdk/metric instead. -type View struct { - instrumentName *regexp.Regexp - hasWildcard bool - scope instrumentation.Scope - instrumentKind InstrumentKind - - filter attribute.Filter - name string - description string - agg aggregation.Aggregation -} - -// New returns a new configured View. If there are any duplicate Options passed, -// the last one passed will take precedence. The unique, de-duplicated, -// Options are all applied to the View. An instrument needs to match all of -// the match Options passed for the View to be applied to it. Similarly, all -// transform operation Options are applied to matched Instruments. -// -// Deprecated: Use NewView in go.opentelemetry.io/otel/sdk/metric instead. -func New(opts ...Option) (View, error) { - v := View{} - - for _, opt := range opts { - v = opt.apply(v) - } - - emptyScope := instrumentation.Scope{} - if v.instrumentName == nil && - v.scope == emptyScope && - v.instrumentKind == undefinedInstrument { - return View{}, fmt.Errorf("must provide at least 1 match option") - } - - if v.hasWildcard && v.name != "" { - return View{}, fmt.Errorf("invalid view: view name specified for multiple instruments") - } - - return v, nil -} - -// TransformInstrument will check if an instrument matches this view -// and will convert it if it does. -func (v View) TransformInstrument(inst Instrument) (transformed Instrument, match bool) { - if !v.match(inst) { - return Instrument{}, false - } - if v.name != "" { - inst.Name = v.name - } - if v.description != "" { - inst.Description = v.description - } - if v.agg != nil { - inst.Aggregation = v.agg - } - return inst, true -} - -// AttributeFilter returns a function that returns only attributes specified by -// WithFilterAttributes. If no filter was provided nil is returned. -func (v View) AttributeFilter() func(attribute.Set) attribute.Set { - if v.filter == nil { - return nil - } - return func(input attribute.Set) attribute.Set { - out, _ := input.Filter(v.filter) - return out - } -} - -func (v View) matchName(name string) bool { - return v.instrumentName == nil || v.instrumentName.MatchString(name) -} - -func (v View) matchScopeName(name string) bool { - return v.scope.Name == "" || name == v.scope.Name -} - -func (v View) matchScopeVersion(version string) bool { - return v.scope.Version == "" || version == v.scope.Version -} - -func (v View) matchScopeSchemaURL(schemaURL string) bool { - return v.scope.SchemaURL == "" || schemaURL == v.scope.SchemaURL -} - -func (v View) matchInstrumentKind(kind InstrumentKind) bool { - return v.instrumentKind == undefinedInstrument || kind == v.instrumentKind -} - -func (v View) match(i Instrument) bool { - return v.matchName(i.Name) && - v.matchScopeName(i.Scope.Name) && - v.matchScopeSchemaURL(i.Scope.SchemaURL) && - v.matchScopeVersion(i.Scope.Version) && - v.matchInstrumentKind(i.Kind) -} - -// Option applies a configuration option value to a View. -type Option interface { - apply(View) View -} - -type optionFunc func(View) View - -func (f optionFunc) apply(v View) View { - return f(v) -} - -// MatchInstrumentName will match an instrument based on the its name. -// This will accept wildcards of * for zero or more characters, and ? for -// exactly one character. A name of "*" (default) will match all instruments. -func MatchInstrumentName(name string) Option { - return optionFunc(func(v View) View { - if strings.ContainsAny(name, "*?") { - v.hasWildcard = true - } - name = regexp.QuoteMeta(name) - name = "^" + name + "$" - name = strings.ReplaceAll(name, "\\?", ".") - name = strings.ReplaceAll(name, "\\*", ".*") - v.instrumentName = regexp.MustCompile(name) - return v - }) -} - -// MatchInstrumentKind with match an instrument based on the instrument's kind. -// The default is to match all instrument kinds. -func MatchInstrumentKind(kind InstrumentKind) Option { - return optionFunc(func(v View) View { - v.instrumentKind = kind - return v - }) -} - -// MatchInstrumentationScope will do an exact match on any -// instrumentation.Scope field that is non-empty (""). The default is to match all -// instrumentation scopes. -func MatchInstrumentationScope(scope instrumentation.Scope) Option { - return optionFunc(func(v View) View { - v.scope = scope - return v - }) -} - -// WithRename will rename the instrument the view matches. If not used or empty the -// instrument name will not be changed. Must be used with a non-wildcard -// instrument name match. The default does not change the instrument name. -func WithRename(name string) Option { - return optionFunc(func(v View) View { - v.name = name - return v - }) -} - -// WithSetDescription will change the description of the instruments the view -// matches to desc. If not used or empty the description will not be changed. -func WithSetDescription(desc string) Option { - return optionFunc(func(v View) View { - v.description = desc - return v - }) -} - -// WithFilterAttributes will select attributes that have a matching key. If not used -// or empty no filter will be applied. -func WithFilterAttributes(keys ...attribute.Key) Option { - return optionFunc(func(v View) View { - if len(keys) == 0 { - return v - } - filterKeys := map[attribute.Key]struct{}{} - for _, key := range keys { - filterKeys[key] = struct{}{} - } - - v.filter = attribute.Filter(func(kv attribute.KeyValue) bool { - _, ok := filterKeys[kv.Key] - return ok - }) - return v - }) -} - -// WithSetAggregation will use the aggregation a for matching instruments. If -// this option is not provided, the reader defined aggregation for the -// instrument will be used. -// -// If a is misconfigured, it will not be used and an error will be logged. -func WithSetAggregation(a aggregation.Aggregation) Option { - cpA := a.Copy() - if err := cpA.Err(); err != nil { - global.Error(err, "not using aggregation with view", "aggregation", a) - return optionFunc(func(v View) View { return v }) - } - - return optionFunc(func(v View) View { - v.agg = cpA - return v - }) -} diff --git a/sdk/metric/view/view_test.go b/sdk/metric/view/view_test.go deleted file mode 100644 index 92034345926..00000000000 --- a/sdk/metric/view/view_test.go +++ /dev/null @@ -1,444 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package view // import "go.opentelemetry.io/otel/sdk/metric/view" - -import ( - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/sdk/instrumentation" -) - -var matchInstrument = Instrument{ - Scope: instrumentation.Scope{ - Name: "bar", - Version: "v1.0.0", - SchemaURL: "stuff.test/", - }, - Name: "foo", - Kind: SyncCounter, - Description: "", -} - -var noMatchInstrument = Instrument{ - Scope: instrumentation.Scope{ - Name: "notfoo", - Version: "v0.x.0", - SchemaURL: "notstuff.test/", - }, - Name: "notstuff", - Description: "", - Kind: undefinedInstrument, -} - -var emptyDescription = Instrument{} - -func TestViewTransformInstrument(t *testing.T) { - tests := []struct { - name string - options []Option - match Instrument - notMatch Instrument - }{ - { - name: "instrument name", - options: []Option{ - MatchInstrumentName("foo"), - }, - match: matchInstrument, - notMatch: emptyDescription, - }, - { - name: "Scope name", - options: []Option{ - MatchInstrumentationScope(instrumentation.Scope{ - Name: "bar", - }), - }, - match: matchInstrument, - notMatch: emptyDescription, - }, - { - name: "Scope version", - options: []Option{ - MatchInstrumentationScope(instrumentation.Scope{ - Version: "v1.0.0", - }), - }, - - match: matchInstrument, - notMatch: emptyDescription, - }, - { - name: "Scope SchemaURL", - options: []Option{ - MatchInstrumentationScope(instrumentation.Scope{ - SchemaURL: "stuff.test/", - }), - }, - match: matchInstrument, - notMatch: emptyDescription, - }, { - name: "instrument kind", - options: []Option{ - MatchInstrumentKind(SyncCounter), - }, - match: matchInstrument, - notMatch: emptyDescription, - }, - { - name: "Expands *", - options: []Option{ - MatchInstrumentName("f*"), - }, - match: matchInstrument, - notMatch: emptyDescription, - }, - { - name: "composite literal name", - options: []Option{ - MatchInstrumentName("foo"), - MatchInstrumentationScope(instrumentation.Scope{ - Name: "bar", - Version: "v1.0.0", - SchemaURL: "stuff.test/", - }), - }, - match: matchInstrument, - notMatch: emptyDescription, - }, - { - name: "rename", - options: []Option{ - MatchInstrumentName("foo"), - WithRename("baz"), - }, - match: Instrument{ - Scope: instrumentation.Scope{ - Name: "bar", - Version: "v1.0.0", - SchemaURL: "stuff.test/", - }, - Name: "baz", - Description: "", - Kind: SyncCounter, - }, - notMatch: emptyDescription, - }, - { - name: "change description", - options: []Option{ - MatchInstrumentName("foo"), - WithSetDescription("descriptive stuff"), - }, - match: Instrument{ - Scope: instrumentation.Scope{ - Name: "bar", - Version: "v1.0.0", - SchemaURL: "stuff.test/", - }, - Name: "foo", - Description: "descriptive stuff", - Kind: SyncCounter, - }, - notMatch: emptyDescription, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - v, err := New(tt.options...) - require.NoError(t, err) - - t.Run("match", func(t *testing.T) { - got, match := v.TransformInstrument(matchInstrument) - assert.Equal(t, tt.match, got) - assert.True(t, match) - }) - - t.Run("does not match", func(t *testing.T) { - got, match := v.TransformInstrument(noMatchInstrument) - assert.Equal(t, tt.notMatch, got) - assert.False(t, match) - }) - }) - } -} - -func TestViewMatchName(t *testing.T) { - tests := []struct { - name string - matchName string - matches []string - notMatches []string - hasWildcard bool - }{ - { - name: "exact", - matchName: "foo", - matches: []string{"foo"}, - notMatches: []string{"foobar", "barfoo", "barfoobaz"}, - hasWildcard: false, - }, - { - name: "*", - matchName: "*", - matches: []string{"foo", "foobar", "barfoo", "barfoobaz", ""}, - notMatches: []string{}, - hasWildcard: true, - }, - { - name: "front ?", - matchName: "?foo", - matches: []string{"1foo", "afoo"}, - notMatches: []string{"foo", "foobar", "barfoo", "barfoobaz"}, - hasWildcard: true, - }, - { - name: "back ?", - matchName: "foo?", - matches: []string{"foo1", "fooz"}, - notMatches: []string{"foo", "foobar", "barfoo", "barfoobaz"}, - hasWildcard: true, - }, - { - name: "front *", - matchName: "*foo", - matches: []string{"foo", "barfoo"}, - notMatches: []string{"foobar", "barfoobaz"}, - hasWildcard: true, - }, - { - name: "back *", - matchName: "foo*", - matches: []string{"foo", "foobar"}, - notMatches: []string{"barfoo", "barfoobaz"}, - hasWildcard: true, - }, - { - name: "both *", - matchName: "*foo*", - matches: []string{"foo", "foobar", "barfoo", "barfoobaz"}, - notMatches: []string{"baz"}, - hasWildcard: true, - }, - { - name: "front **", - matchName: "**foo", - matches: []string{"foo", "barfoo", "1foo", "afoo"}, - notMatches: []string{"foobar", "barfoobaz", "baz", "foo1", "fooz"}, - hasWildcard: true, - }, - { - name: "back **", - matchName: "foo**", - matches: []string{"foo", "foobar", "foo1", "fooz"}, - notMatches: []string{"barfoo", "barfoobaz", "baz", "1foo", "afoo"}, - hasWildcard: true, - }, - { - name: "front *?", - matchName: "*?foo", - matches: []string{"barfoo", "1foo", "afoo"}, - notMatches: []string{"foo", "foobar", "barfoobaz", "baz", "foo1", "fooz"}, - hasWildcard: true, - }, - { - name: "front ?*", - matchName: "?*foo", - matches: []string{"barfoo", "1foo", "afoo"}, - notMatches: []string{"foo", "foobar", "barfoobaz", "baz", "foo1", "fooz"}, - hasWildcard: true, - }, - { - name: "back *?", - matchName: "foo*?", - matches: []string{"foobar", "foo1", "fooz"}, - notMatches: []string{"foo", "barfoo", "barfoobaz", "baz", "1foo", "afoo"}, - hasWildcard: true, - }, - { - name: "back ?*", - matchName: "foo?*", - matches: []string{"foobar", "foo1", "fooz"}, - notMatches: []string{"foo", "barfoo", "barfoobaz", "baz", "1foo", "afoo"}, - hasWildcard: true, - }, - { - name: "middle *", - matchName: "foo*bar", - matches: []string{"foobar", "foo1bar", "foomanybar"}, - notMatches: []string{"foo", "barfoo", "barfoobaz", "baz", "1foo", "afoo", "foo1", "fooz"}, - hasWildcard: true, - }, - { - name: "middle ?", - matchName: "foo?bar", - matches: []string{"foo1bar", "fooabar"}, - notMatches: []string{"foobar", "foo", "barfoo", "barfoobaz", "baz", "1foo", "afoo", "foo1", "fooz", "foomanybar"}, - hasWildcard: true, - }, - { - name: "meta chars", - matchName: ".+()|[]{}^$-_", - matches: []string{".+()|[]{}^$-_"}, // Note this is not a valid name. - notMatches: []string{"foobar", "foo", "barfoo", "barfoobaz", "baz", "1foo", "afoo", "foo1", "fooz", "foomanybar", "foo1bar", "fooabar"}, - hasWildcard: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - v, err := New(MatchInstrumentName(tt.matchName)) - require.NoError(t, err) - - t.Log(v.instrumentName.String()) - assert.Equal(t, tt.hasWildcard, v.hasWildcard) - for _, name := range tt.matches { - assert.Truef(t, v.matchName(name), "name: %s", name) - } - for _, name := range tt.notMatches { - assert.Falsef(t, v.matchName(name), "name: %s", name) - } - }) - } -} - -func TestViewAttributeFilterNoFilter(t *testing.T) { - v, err := New( - MatchInstrumentName("*"), - ) - require.NoError(t, err) - filter := v.AttributeFilter() - assert.Nil(t, filter) - - v, err = New( - MatchInstrumentName("*"), - WithFilterAttributes(), - ) - require.NoError(t, err) - filter = v.AttributeFilter() - assert.Nil(t, filter) - - v, err = New( - MatchInstrumentName("*"), - WithFilterAttributes([]attribute.Key{}...), - ) - require.NoError(t, err) - filter = v.AttributeFilter() - assert.Nil(t, filter) -} - -func TestViewAttributeFilter(t *testing.T) { - inputSet := attribute.NewSet( - attribute.String("foo", "bar"), - attribute.Int("power-level", 9001), - attribute.Float64("lifeUniverseEverything", 42.0), - ) - - tests := []struct { - name string - filter []attribute.Key - want attribute.Set - }{ - { - name: "Match 1", - filter: []attribute.Key{ - attribute.Key("power-level"), - }, - want: attribute.NewSet( - attribute.Int("power-level", 9001), - ), - }, - { - name: "Match 2", - filter: []attribute.Key{ - attribute.Key("foo"), - attribute.Key("lifeUniverseEverything"), - }, - want: attribute.NewSet( - attribute.Float64("lifeUniverseEverything", 42.0), - attribute.String("foo", "bar"), - ), - }, - { - name: "Don't match", - filter: []attribute.Key{ - attribute.Key("nothing"), - }, - want: attribute.NewSet(), - }, - { - name: "Match some", - filter: []attribute.Key{ - attribute.Key("power-level"), - attribute.Key("nothing"), - }, - want: attribute.NewSet( - attribute.Int("power-level", 9001), - ), - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - v, err := New( - MatchInstrumentName("*"), - WithFilterAttributes(tt.filter...), - ) - require.NoError(t, err) - filter := v.AttributeFilter() - require.NotNil(t, filter) - - got := filter(inputSet) - assert.Equal(t, got.Equivalent(), tt.want.Equivalent()) - }) - } -} - -func TestNewErrors(t *testing.T) { - tests := []struct { - name string - options []Option - }{ - { - name: "No Match Option", - options: []Option{}, - }, - { - name: "Match * with view name", - options: []Option{ - MatchInstrumentName("*"), - WithRename("newName"), - }, - }, - { - name: "Match expand * with view name", - options: []Option{ - MatchInstrumentName("old*"), - WithRename("newName"), - }, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got, err := New(tt.options...) - - assert.Equal(t, View{}, got) - assert.Error(t, err) - }) - } -} From 8644a79dcf1d57115111b457c70942796dfae0d8 Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Wed, 7 Dec 2022 12:41:50 -0800 Subject: [PATCH 3/4] Fix changelog header (#3521) Increment the removed header from previous release. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c841901a7b3..0486e8de8d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -62,7 +62,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Prevent duplicate Prometheus description, unit, and type. (#3469) - Prevents panic when using incorrect `attribute.Value.As[Type]Slice()`. (#3489) -## Removed +### Removed - The `go.opentelemetry.io/otel/exporters/otlp/otlpmetric.Client` interface is removed. (#3486) - The `go.opentelemetry.io/otel/exporters/otlp/otlpmetric.New` function is removed. Use the `otlpmetric[http|grpc].New` directly. (#3486) From 4e763472eee5ef03b97274694d2d1b07f0b3cd11 Mon Sep 17 00:00:00 2001 From: aniaan Date: Fri, 9 Dec 2022 00:04:43 +0800 Subject: [PATCH 4/4] feat(exporter): Jaeger and Zipkin exporter use `logr` as the logging interface (#3500) * feat(exporter): Jaeger and Zipkin exporter use `github.com/go-logr/logr` as the logging interface, and add the WithLogr option * fix(exporter): reuse code * fix(exporter): lint * fix(exporter): add comment * fix(changelog): update --- CHANGELOG.md | 1 + exporters/jaeger/agent.go | 5 ++-- exporters/jaeger/agent_test.go | 7 +++--- exporters/jaeger/go.mod | 4 ++-- exporters/jaeger/reconnecting_udp_client.go | 11 +++++---- .../jaeger/reconnecting_udp_client_test.go | 20 ++++++++-------- exporters/jaeger/uploader.go | 12 ++++++++++ exporters/zipkin/go.mod | 4 ++-- exporters/zipkin/zipkin.go | 24 +++++++++++++------ 9 files changed, 56 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0486e8de8d8..6cb2b592746 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - The `Temporality(view.InstrumentKind) metricdata.Temporality` and `Aggregation(view.InstrumentKind) aggregation.Aggregation` methods are added to the `"go.opentelemetry.io/otel/exporters/otlp/otlpmetric".Client` interface. (#3260) - The `WithTemporalitySelector` and `WithAggregationSelector` `ReaderOption`s have been changed to `ManualReaderOption`s in the `go.opentelemetry.io/otel/sdk/metric` package. (#3260) - The periodic reader in the `go.opentelemetry.io/otel/sdk/metric` package now uses the temporality and aggregation selectors from its configured exporter instead of accepting them as options. (#3260) +- Jaeger and Zipkin exporter use `github.com/go-logr/logr` as the logging interface, and add the `WithLogr` option. (#3497, #3500) ### Fixed diff --git a/exporters/jaeger/agent.go b/exporters/jaeger/agent.go index ed002b83f7a..a050020bb47 100644 --- a/exporters/jaeger/agent.go +++ b/exporters/jaeger/agent.go @@ -18,11 +18,12 @@ import ( "context" "fmt" "io" - "log" "net" "strings" "time" + "github.com/go-logr/logr" + genAgent "go.opentelemetry.io/otel/exporters/jaeger/internal/gen-go/agent" gen "go.opentelemetry.io/otel/exporters/jaeger/internal/gen-go/jaeger" "go.opentelemetry.io/otel/exporters/jaeger/internal/third_party/thrift/lib/go/thrift" @@ -58,7 +59,7 @@ type agentClientUDPParams struct { Host string Port string MaxPacketSize int - Logger *log.Logger + Logger logr.Logger AttemptReconnecting bool AttemptReconnectInterval time.Duration } diff --git a/exporters/jaeger/agent_test.go b/exporters/jaeger/agent_test.go index fdcd9bb74d6..95070341722 100644 --- a/exporters/jaeger/agent_test.go +++ b/exporters/jaeger/agent_test.go @@ -16,7 +16,6 @@ package jaeger import ( "context" - "log" "net" "testing" @@ -54,7 +53,7 @@ func TestNewAgentClientUDPWithParams(t *testing.T) { assert.Equal(t, 25000, agentClient.maxPacketSize) if assert.IsType(t, &reconnectingUDPConn{}, agentClient.connUDP) { - assert.Equal(t, (*log.Logger)(nil), agentClient.connUDP.(*reconnectingUDPConn).logger) + assert.Equal(t, emptyLogger, agentClient.connUDP.(*reconnectingUDPConn).logger) } assert.NoError(t, agentClient.Close()) @@ -77,7 +76,7 @@ func TestNewAgentClientUDPWithParamsDefaults(t *testing.T) { assert.Equal(t, udpPacketMaxLength, agentClient.maxPacketSize) if assert.IsType(t, &reconnectingUDPConn{}, agentClient.connUDP) { - assert.Equal(t, (*log.Logger)(nil), agentClient.connUDP.(*reconnectingUDPConn).logger) + assert.Equal(t, emptyLogger, agentClient.connUDP.(*reconnectingUDPConn).logger) } assert.NoError(t, agentClient.Close()) @@ -93,7 +92,7 @@ func TestNewAgentClientUDPWithParamsReconnectingDisabled(t *testing.T) { agentClient, err := newAgentClientUDP(agentClientUDPParams{ Host: host, Port: port, - Logger: nil, + Logger: emptyLogger, AttemptReconnecting: false, }) assert.NoError(t, err) diff --git a/exporters/jaeger/go.mod b/exporters/jaeger/go.mod index 0ee4a1cb2bc..c1d38fabe1f 100644 --- a/exporters/jaeger/go.mod +++ b/exporters/jaeger/go.mod @@ -3,6 +3,8 @@ module go.opentelemetry.io/otel/exporters/jaeger go 1.18 require ( + github.com/go-logr/logr v1.2.3 + github.com/go-logr/stdr v1.2.2 github.com/google/go-cmp v0.5.9 github.com/stretchr/testify v1.8.1 go.opentelemetry.io/otel v1.11.2 @@ -12,8 +14,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/go-logr/logr v1.2.3 // indirect - github.com/go-logr/stdr v1.2.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/stretchr/objx v0.5.0 // indirect golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8 // indirect diff --git a/exporters/jaeger/reconnecting_udp_client.go b/exporters/jaeger/reconnecting_udp_client.go index fa2c68ead42..88055c8a300 100644 --- a/exporters/jaeger/reconnecting_udp_client.go +++ b/exporters/jaeger/reconnecting_udp_client.go @@ -16,11 +16,12 @@ package jaeger // import "go.opentelemetry.io/otel/exporters/jaeger" import ( "fmt" - "log" "net" "sync" "sync/atomic" "time" + + "github.com/go-logr/logr" ) // reconnectingUDPConn is an implementation of udpConn that resolves hostPort every resolveTimeout, if the resolved address is @@ -32,7 +33,7 @@ type reconnectingUDPConn struct { hostPort string resolveFunc resolveFunc dialFunc dialFunc - logger *log.Logger + logger logr.Logger connMtx sync.RWMutex conn *net.UDPConn @@ -45,7 +46,7 @@ type dialFunc func(network string, laddr, raddr *net.UDPAddr) (*net.UDPConn, err // newReconnectingUDPConn returns a new udpConn that resolves hostPort every resolveTimeout, if the resolved address is // different than the current conn then the new address is dialed and the conn is swapped. -func newReconnectingUDPConn(hostPort string, bufferBytes int, resolveTimeout time.Duration, resolveFunc resolveFunc, dialFunc dialFunc, logger *log.Logger) (*reconnectingUDPConn, error) { +func newReconnectingUDPConn(hostPort string, bufferBytes int, resolveTimeout time.Duration, resolveFunc resolveFunc, dialFunc dialFunc, logger logr.Logger) (*reconnectingUDPConn, error) { conn := &reconnectingUDPConn{ hostPort: hostPort, resolveFunc: resolveFunc, @@ -65,8 +66,8 @@ func newReconnectingUDPConn(hostPort string, bufferBytes int, resolveTimeout tim } func (c *reconnectingUDPConn) logf(format string, args ...interface{}) { - if c.logger != nil { - c.logger.Printf(format, args...) + if c.logger != emptyLogger { + c.logger.Info(format, args...) } } diff --git a/exporters/jaeger/reconnecting_udp_client_test.go b/exporters/jaeger/reconnecting_udp_client_test.go index 43bfe512493..958f6400baf 100644 --- a/exporters/jaeger/reconnecting_udp_client_test.go +++ b/exporters/jaeger/reconnecting_udp_client_test.go @@ -88,7 +88,7 @@ func assertConnWritable(t *testing.T, conn udpConn, serverConn net.PacketConn) { _, err := conn.Write([]byte(expectedString)) require.NoError(t, err) - var buf = make([]byte, len(expectedString)) + buf := make([]byte, len(expectedString)) err = serverConn.SetReadDeadline(time.Now().Add(time.Second)) require.NoError(t, err) @@ -145,7 +145,7 @@ func waitForConnCondition(conn *reconnectingUDPConn, condition func(conn *reconn } func newMockUDPAddr(t *testing.T, port int) *net.UDPAddr { - var buf = make([]byte, 4) + buf := make([]byte, 4) // random is not seeded to ensure tests are deterministic (also doesnt matter if ip is valid) _, err := rand.Read(buf) require.NoError(t, err) @@ -177,7 +177,7 @@ func TestNewResolvedUDPConn(t *testing.T) { Return(clientConn, nil). Once() - conn, err := newReconnectingUDPConn(hostPort, udpPacketMaxLength, time.Hour, resolver.ResolveUDPAddr, dialer.DialUDP, nil) + conn, err := newReconnectingUDPConn(hostPort, udpPacketMaxLength, time.Hour, resolver.ResolveUDPAddr, dialer.DialUDP, emptyLogger) assert.NoError(t, err) require.NotNil(t, conn) @@ -212,7 +212,7 @@ func TestResolvedUDPConnWrites(t *testing.T) { Return(clientConn, nil). Once() - conn, err := newReconnectingUDPConn(hostPort, udpPacketMaxLength, time.Hour, resolver.ResolveUDPAddr, dialer.DialUDP, nil) + conn, err := newReconnectingUDPConn(hostPort, udpPacketMaxLength, time.Hour, resolver.ResolveUDPAddr, dialer.DialUDP, emptyLogger) assert.NoError(t, err) require.NotNil(t, conn) @@ -249,7 +249,7 @@ func TestResolvedUDPConnEventuallyDials(t *testing.T) { On("DialUDP", "udp", (*net.UDPAddr)(nil), mockUDPAddr). Return(clientConn, nil).Once() - conn, err := newReconnectingUDPConn(hostPort, udpPacketMaxLength, time.Millisecond*10, resolver.ResolveUDPAddr, dialer.DialUDP, nil) + conn, err := newReconnectingUDPConn(hostPort, udpPacketMaxLength, time.Millisecond*10, resolver.ResolveUDPAddr, dialer.DialUDP, emptyLogger) assert.NoError(t, err) require.NotNil(t, conn) @@ -300,7 +300,7 @@ func TestResolvedUDPConnNoSwapIfFail(t *testing.T) { On("DialUDP", "udp", (*net.UDPAddr)(nil), mockUDPAddr). Return(clientConn, nil).Once() - conn, err := newReconnectingUDPConn(hostPort, udpPacketMaxLength, time.Millisecond*10, resolver.ResolveUDPAddr, dialer.DialUDP, nil) + conn, err := newReconnectingUDPConn(hostPort, udpPacketMaxLength, time.Millisecond*10, resolver.ResolveUDPAddr, dialer.DialUDP, emptyLogger) assert.NoError(t, err) require.NotNil(t, conn) @@ -341,7 +341,7 @@ func TestResolvedUDPConnWriteRetry(t *testing.T) { On("DialUDP", "udp", (*net.UDPAddr)(nil), mockUDPAddr). Return(clientConn, nil).Once() - conn, err := newReconnectingUDPConn(hostPort, udpPacketMaxLength, time.Millisecond*10, resolver.ResolveUDPAddr, dialer.DialUDP, nil) + conn, err := newReconnectingUDPConn(hostPort, udpPacketMaxLength, time.Millisecond*10, resolver.ResolveUDPAddr, dialer.DialUDP, emptyLogger) assert.NoError(t, err) require.NotNil(t, conn) @@ -371,7 +371,7 @@ func TestResolvedUDPConnWriteRetryFails(t *testing.T) { dialer := mockDialer{} - conn, err := newReconnectingUDPConn(hostPort, udpPacketMaxLength, time.Millisecond*10, resolver.ResolveUDPAddr, dialer.DialUDP, nil) + conn, err := newReconnectingUDPConn(hostPort, udpPacketMaxLength, time.Millisecond*10, resolver.ResolveUDPAddr, dialer.DialUDP, emptyLogger) assert.NoError(t, err) require.NotNil(t, conn) @@ -428,7 +428,7 @@ func TestResolvedUDPConnChanges(t *testing.T) { On("DialUDP", "udp", (*net.UDPAddr)(nil), mockUDPAddr2). Return(clientConn2, nil).Once() - conn, err := newReconnectingUDPConn(hostPort, udpPacketMaxLength, time.Millisecond*10, resolver.ResolveUDPAddr, dialer.DialUDP, nil) + conn, err := newReconnectingUDPConn(hostPort, udpPacketMaxLength, time.Millisecond*10, resolver.ResolveUDPAddr, dialer.DialUDP, emptyLogger) assert.NoError(t, err) require.NotNil(t, conn) @@ -481,7 +481,7 @@ func TestResolvedUDPConnLoopWithoutChanges(t *testing.T) { Once() resolveTimeout := 500 * time.Millisecond - conn, err := newReconnectingUDPConn(hostPort, udpPacketMaxLength, resolveTimeout, resolver.ResolveUDPAddr, dialer.DialUDP, nil) + conn, err := newReconnectingUDPConn(hostPort, udpPacketMaxLength, resolveTimeout, resolver.ResolveUDPAddr, dialer.DialUDP, emptyLogger) assert.NoError(t, err) require.NotNil(t, conn) assert.Equal(t, mockUDPAddr, conn.destAddr) diff --git a/exporters/jaeger/uploader.go b/exporters/jaeger/uploader.go index 1bdb4de4f92..f65e3a6782a 100644 --- a/exporters/jaeger/uploader.go +++ b/exporters/jaeger/uploader.go @@ -23,6 +23,9 @@ import ( "net/http" "time" + "github.com/go-logr/logr" + "github.com/go-logr/stdr" + gen "go.opentelemetry.io/otel/exporters/jaeger/internal/gen-go/jaeger" "go.opentelemetry.io/otel/exporters/jaeger/internal/third_party/thrift/lib/go/thrift" ) @@ -112,8 +115,17 @@ func WithAgentPort(port string) AgentEndpointOption { }) } +var emptyLogger = logr.Logger{} + // WithLogger sets a logger to be used by agent client. +// WithLogger and WithLogr will overwrite each other. func WithLogger(logger *log.Logger) AgentEndpointOption { + return WithLogr(stdr.New(logger)) +} + +// WithLogr sets a logr.Logger to be used by agent client. +// WithLogr and WithLogger will overwrite each other. +func WithLogr(logger logr.Logger) AgentEndpointOption { return agentEndpointOptionFunc(func(o agentEndpointConfig) agentEndpointConfig { o.Logger = logger return o diff --git a/exporters/zipkin/go.mod b/exporters/zipkin/go.mod index b68d7ff3f1e..3cc8e8aa89c 100644 --- a/exporters/zipkin/go.mod +++ b/exporters/zipkin/go.mod @@ -3,6 +3,8 @@ module go.opentelemetry.io/otel/exporters/zipkin go 1.18 require ( + github.com/go-logr/logr v1.2.3 + github.com/go-logr/stdr v1.2.2 github.com/google/go-cmp v0.5.9 github.com/openzipkin/zipkin-go v0.4.1 github.com/stretchr/testify v1.8.1 @@ -13,8 +15,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/go-logr/logr v1.2.3 // indirect - github.com/go-logr/stdr v1.2.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect golang.org/x/sys v0.0.0-20221010170243-090e33056c14 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/exporters/zipkin/zipkin.go b/exporters/zipkin/zipkin.go index 93b027a1557..b21a0190c2d 100644 --- a/exporters/zipkin/zipkin.go +++ b/exporters/zipkin/zipkin.go @@ -25,6 +25,9 @@ import ( "net/url" "sync" + "github.com/go-logr/logr" + "github.com/go-logr/stdr" + sdktrace "go.opentelemetry.io/otel/sdk/trace" ) @@ -36,20 +39,20 @@ const ( type Exporter struct { url string client *http.Client - logger *log.Logger + logger logr.Logger stoppedMu sync.RWMutex stopped bool } -var ( - _ sdktrace.SpanExporter = &Exporter{} -) +var _ sdktrace.SpanExporter = &Exporter{} + +var emptyLogger = logr.Logger{} // Options contains configuration for the exporter. type config struct { client *http.Client - logger *log.Logger + logger logr.Logger } // Option defines a function that configures the exporter. @@ -64,7 +67,14 @@ func (fn optionFunc) apply(cfg config) config { } // WithLogger configures the exporter to use the passed logger. +// WithLogger and WithLogr will overwrite each other. func WithLogger(logger *log.Logger) Option { + return WithLogr(stdr.New(logger)) +} + +// WithLogr configures the exporter to use the passed logr.Logger. +// WithLogr and WithLogger will overwrite each other. +func WithLogr(logger logr.Logger) Option { return optionFunc(func(cfg config) config { cfg.logger = logger return cfg @@ -170,8 +180,8 @@ func (e *Exporter) Shutdown(ctx context.Context) error { } func (e *Exporter) logf(format string, args ...interface{}) { - if e.logger != nil { - e.logger.Printf(format, args...) + if e.logger != emptyLogger { + e.logger.Info(format, args) } }