Skip to content

Commit

Permalink
Merge branch 'master' into upgradedd
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed Jun 23, 2020
2 parents a33c367 + 64e2183 commit 5159c59
Show file tree
Hide file tree
Showing 83 changed files with 793 additions and 228 deletions.
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ jobs:
name: "Precommit and Coverage Report"
command: |
make ci
mv coverage.html $TEST_RESULTS/
find . -name 'coverage.html' > "${TEST_RESULTS}/coverage.lst"
tar -n -cf - -T "${TEST_RESULTS}/coverage.lst" | tar -C "${TEST_RESULTS}" -xvf -
- save_cache:
key: go-pkg-mod-{{ checksum "go.sum" }}
Expand Down
47 changes: 47 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/tools" # Location of package manifests
schedule:
interval: "daily"
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/exporters/metric/dogstatsd" # Location of package manifests
schedule:
interval: "daily"
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/exporters/metric/datadog" # Location of package manifests
schedule:
interval: "daily"
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/instrumentation/labstack/echo" # Location of package manifests
schedule:
interval: "daily"
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/instrumentation/go.mongodb.org/mongo-driver" # Location of package manifests
schedule:
interval: "daily"
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/instrumentation/gorilla/mux" # Location of package manifests
schedule:
interval: "daily"
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/instrumentation/gin-gonic/gin" # Location of package manifests
schedule:
interval: "daily"
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/instrumentation/macaron" # Location of package manifests
schedule:
interval: "daily"
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/instrumentation/runtime" # Location of package manifests
schedule:
interval: "daily"
28 changes: 28 additions & 0 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Dependabot-Tidier
on:
pull_request:
types: [ labeled ]

jobs:
mod_tidier:
if: ${{ contains(github.event.pull_request.labels.*.name, 'dependencies') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- uses: actions/setup-go@v2
with:
go-version: '^1.14.0'
- uses: evantorrie/mott-the-tidier@v1-beta
id: modtidy
with:
gomods: '**/go.mod'
gosum_only: true
- uses: stefanzweifel/git-auto-commit-action@v4
id: autocommit
with:
commit_message: Auto-fix go.sum changes in dependent modules
- name: changes
run: |
echo "Changes detected: ${{ steps.autocommit.outputs.changes_detected }}"
14 changes: 7 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,26 +91,26 @@ merge**.

## Adding a new Contrib package

To add a new contrib package follow an existing one. An empty Sample plugin
To add a new contrib package follow an existing one. An empty Sample instrumentation
provides base structure with an example and a test. Each contrib package
should be its own module. A contrib package may contain more than one go package.

### Folder Structure
- plugins/\<plugin-package> (**Common**)
- plugins/\<plugin-package>/trace (**specific to trace**)
- plugins/\<plugin-package>/metrics (**specific to metrics**)
- instrumentation/\<instrumentation-package> (**Common**)
- instrumentation/\<instrumentation-package>/trace (**specific to trace**)
- instrumentation/\<instrumentation-package>/metrics (**specific to metrics**)

#### Example
- plugins/gorm/trace
- plugins/kafka/metrics
- instrumentation/gorm/trace
- instrumentation/kafka/metrics

## Approvers and Maintainers

Approvers:

- [Liz Fong-Jones](https://github.com/lizthegrey), Honeycomb
- [Gustavo Silva Paiva](https://github.com/paivagustavo), Stilingue
- [Evan Torrie](https://github.com/evantorrie), Comcast
- [Evan Torrie](https://github.com/evantorrie), Verizon Media
- [Anthony Mirabella](https://github.com/Aneurysm9), Centene

Maintainers:
Expand Down
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# opentelemetry-go-contrib
# OpenTelemetry-Go Contrib

This repo contains packages that facilitates instrumenting libraries with Opentelemetry for
distributed tracing and monitoring.
[![Circle CI](https://circleci.com/gh/open-telemetry/opentelemetry-go-contrib.svg?style=svg)](https://circleci.com/gh/open-telemetry/opentelemetry-go-contrib)
[![Docs](https://godoc.org/go.opentelemetry.io/contrib?status.svg)](https://pkg.go.dev/go.opentelemetry.io/contrib)
[![Go Report Card](https://goreportcard.com/badge/go.opentelemetry.io/contrib)](https://goreportcard.com/report/go.opentelemetry.io/contrib)
[![Gitter](https://badges.gitter.im/open-telemetry/opentelemetry-go.svg)](https://gitter.im/open-telemetry/opentelemetry-go?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

Collection of 3rd-party instrumentation and exporters for [OpenTelemetry-Go](https://github.com/open-telemetry/opentelemetry-go).

## Contents

- [Instrumentation](./instrumentation/): Packages providing OpenTelemetry instrumentation for 3rd-party libraries.
- [Exporters](./exporters/): Packages providing OpenTelemetry exporters for 3rd-party telemetry systems.

## Contributing

For information on how to contribute, consult [the contributing guidelines](./CONTRIBUTING.md)
141 changes: 141 additions & 0 deletions bump_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#!/usr/bin/env bash

# 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.

#
# This script is used for
# a) creating a new tagged release of go.opentelemetry.io/contrib
# b) bumping the referenced version of go.opentelemetry.io/otel
#
# The options can be used together or individually.
#
set -e

help() {
printf "\n"
printf "Usage: %s [-o otel_tag] [-t tag]\n" "$0"
printf "\t-o Otel release tag. Update all go.mod to reference go.opentelemetry.io/otel <otel_tag>.\n"
printf "\t-t New unreleased tag. Update all go.mod with this tag.\n"
exit 1 # Exit script after printing help
}

while getopts "t:o:" opt
do
case "$opt" in
t ) TAG="$OPTARG" ;;
o ) OTEL_TAG="$OPTARG" ;;
? ) help ;; # Print help
esac
done

declare -r SEMVER_REGEX="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(\\-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$"

validate_tag() {
local tag_=$1
if [[ "${tag_}" =~ ${SEMVER_REGEX} ]]; then
printf "%s is valid semver tag.\n" "${tag_}"
else
printf "%s is not a valid semver tag.\n" "${tag_}"
return 1
fi
}

# Print help in case parameters are empty
if [[ -z "$TAG" && -z "$OTEL_TAG" ]]
then
printf "At least one of '-o' or '-t' must be specified.\n"
help
fi


## Validate tags first
if [ -n "${OTEL_TAG}" ]; then
validate_tag "${OTEL_TAG}" || exit $?
# check that OTEL_TAG is a currently released tag for go.opentelemetry.io/otel
TMPDIR=$(mktemp -d "/tmp/otel-contrib.XXXXXX") || exit 1
trap "rm -fr ${TMPDIR}" EXIT
(cd "${TMPDIR}" && go mod init tagtest)
# requires go 1.14 for support of '-modfile'
if ! go get -modfile="${TMPDIR}/go.mod" -d -v "go.opentelemetry.io/otel@${OTEL_TAG}"; then
printf "go.opentelemetry.io/otel %s does not exist. Please supply a valid tag\n" "${OTEL_TAG}"
exit 1
fi
fi
if [ -n "${TAG}" ]; then
validate_tag "${TAG}" || exit $?
TAG_FOUND=$(git tag --list "${TAG}")
if [[ ${TAG_FOUND} = "${TAG}" ]] ; then
printf "Tag %s already exists\n" "${TAG}"
exit 1
fi
fi

cd "$(dirname "$0")"

if ! git diff --quiet; then \
printf "Working tree is not clean, can't proceed\n"
git status
git diff
exit 1
fi

declare BRANCH_NAME=pre_release_${TAG}
if [ -z "${TAG}" ]; then
BRANCH_NAME=bump_otel_${OTEL_TAG}
fi

patch_gomods() {
local pkg_=$1
local tag_=$2
# now do the same for all the directories underneath
PACKAGE_DIRS=$(find . -mindepth 2 -type f -name 'go.mod' -exec dirname {} \; | egrep -v 'tools' | sed 's|^\.\/||' | sort)
# quote any '.' characters in the pkg name
local quoted_pkg_=${pkg_//./\\.}
for dir in $PACKAGE_DIRS; do
cp "${dir}/go.mod" "${dir}/go.mod.bak"
sed "s|${quoted_pkg_}\([^ ]*\) v[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*[^0-9]*.*$|${pkg_}\1 ${tag_}|" "${dir}/go.mod.bak" >"${dir}/go.mod"
rm -f "${dir}/go.mod.bak"
done
}

# branch off from existing master
git checkout -b "${BRANCH_NAME}" master

# Update go.mods
if [ -n "${OTEL_TAG}" ]; then
# first update the top most module
go get "go.opentelemetry.io/otel@${OTEL_TAG}"
patch_gomods go.opentelemetry.io/otel "${OTEL_TAG}"
fi

if [ -n "${TAG}" ]; then
patch_gomods go.opentelemetry.io/contrib "${TAG}"
fi

git diff
# Run lint to update go.sum
make lint

# Add changes and commit.
git add .
make ci
declare COMMIT_MSG="Prepare for releasing $TAG"
if [ -z "${TAG}" ]; then
COMMIT_MSG="Bumping otel version to ${OTEL_TAG}"
fi
git commit -m "${COMMIT_MSG}"

printf "Now run following to verify the changes.\ngit diff master\n"
printf "\nThen push the changes to upstream\n"
2 changes: 1 addition & 1 deletion doc.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This package provides all of its functionality through its
// submodules. The submodules in the exporters directory provide
// implementations for trace and metric exporters for third-party
// collectors, and submodules in the plugins directory provide the
// collectors, and submodules in the instrumentation directory provide the
// instrumentation for the popular go libraries.
package contrib
6 changes: 5 additions & 1 deletion exporters/metric/datadog/datadog.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func NewExporter(opts Options) (*Exporter, error) {
if opts.MetricNameFormatter == nil {
opts.MetricNameFormatter = defaultFormatter
}
client, err := statsd.New(opts.StatsAddr)
client, err := statsd.New(opts.StatsAddr, opts.StatsDOptions...)
if err != nil {
return nil, err
}
Expand All @@ -52,6 +52,9 @@ type Options struct {
// MetricNameFormatter lets you customize the metric name that gets sent to
// datadog before exporting
MetricNameFormatter func(namespace, name string) string

// StatsD specific Options
StatsDOptions []statsd.Option
}

// Exporter forwards metrics to a DataDog agent
Expand All @@ -68,6 +71,7 @@ func defaultFormatter(namespace, name string) string {

func (e *Exporter) Export(ctx context.Context, cs export.CheckpointSet) error {
return cs.ForEach(func(r export.Record) error {
// TODO: Use the Resource() method
agg := r.Aggregator()
name := e.sanitizeMetricName(r.Descriptor().LibraryName(), r.Descriptor().Name())
itr := label.NewMergeIterator(r.Resource().LabelSet(), r.Labels())
Expand Down
4 changes: 3 additions & 1 deletion exporters/metric/datadog/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"time"

"github.com/DataDog/datadog-go/statsd"
"github.com/DataDog/sketches-go/ddsketch"

"go.opentelemetry.io/contrib/exporters/metric/datadog"
Expand All @@ -18,7 +19,8 @@ func ExampleExporter() {
selector := simple.NewWithSketchDistribution(ddsketch.NewDefaultConfig())
integrator := integrator.New(selector, false)
exp, err := datadog.NewExporter(datadog.Options{
Tags: []string{"env:dev"},
Tags: []string{"env:dev"},
StatsDOptions: []statsd.Option{statsd.WithoutTelemetry()},
})
if err != nil {
panic(err)
Expand Down
2 changes: 1 addition & 1 deletion exporters/metric/datadog/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module go.opentelemetry.io/contrib/exporters/metric/datadog
go 1.14

require (
github.com/DataDog/datadog-go v3.5.0+incompatible
github.com/DataDog/datadog-go v3.7.2+incompatible
github.com/DataDog/sketches-go v0.0.0-20190923095040-43f19ad77ff7
go.opentelemetry.io/otel v0.6.0
)
4 changes: 2 additions & 2 deletions exporters/metric/datadog/go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/DataDog/datadog-go v3.5.0+incompatible h1:AShr9cqkF+taHjyQgcBcQUt/ZNK+iPq4ROaZwSX5c/U=
github.com/DataDog/datadog-go v3.5.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/DataDog/datadog-go v3.7.2+incompatible h1:o4QtYjBU/rG58VPh8Ne6F65YiMY5/v5q4WdY/HvRYMQ=
github.com/DataDog/datadog-go v3.7.2+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/DataDog/sketches-go v0.0.0-20190923095040-43f19ad77ff7 h1:qELHH0AWCvf98Yf+CNIJx9vOZOfHFDDzgDRYsnNk/vs=
github.com/DataDog/sketches-go v0.0.0-20190923095040-43f19ad77ff7/go.mod h1:Q5DbzQ+3AkgGwymQO7aZFNP7ns2lZKGtvRBzRXfdi60=
github.com/benbjohnson/clock v1.0.0 h1:78Jk/r6m4wCi6sndMpty7A//t4dw/RW5fV4ZgDVfX1w=
Expand Down
Loading

0 comments on commit 5159c59

Please sign in to comment.