-
Notifications
You must be signed in to change notification settings - Fork 578
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup initial folder structure and build. (#3)
* Setup initial folder structure and build. * fix review comments.
- Loading branch information
Showing
14 changed files
with
748 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
docker: | ||
- image: circleci/golang:1.13 | ||
|
||
environment: | ||
TEST_RESULTS: /tmp/test-results # path to where test results will be saved | ||
|
||
steps: | ||
- checkout | ||
- run: mkdir -p $TEST_RESULTS # create the test results directory | ||
|
||
- restore_cache: # restores saved cache if no changes are detected since last run | ||
keys: | ||
- go-pkg-mod-{{ checksum "go.sum" }} | ||
|
||
- run: | ||
name: "Precommit and Coverage Report" | ||
command: | | ||
make ci | ||
mv coverage.html $TEST_RESULTS/ | ||
- save_cache: | ||
key: go-pkg-mod-{{ checksum "go.sum" }} | ||
paths: | ||
- "/go/pkg/mod" | ||
|
||
- store_artifacts: | ||
path: /tmp/test-results | ||
destination: opentelemetry-go-contrib-test-output | ||
|
||
- store_test_results: | ||
path: /tmp/test-results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,10 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
.DS_Store | ||
Thumbs.db | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
.tools/ | ||
.idea/ | ||
.vscode/ | ||
*.iml | ||
*.so | ||
coverage.* | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
# Contributing to opentelemetry-go-contrib | ||
|
||
The Go special interest group (SIG) meets regularly. See the | ||
OpenTelemetry | ||
[community](https://github.com/open-telemetry/community#golang-sdk) | ||
repo for information on this and other language SIGs. | ||
|
||
See the [public meeting | ||
notes](https://docs.google.com/document/d/1A63zSWX0x2CyCK_LoNhmQC4rqhLpYXJzXbEPDUQ2n6w/edit#heading=h.9tngw7jdwd6b) | ||
for a summary description of past meetings. To request edit access, | ||
join the meeting or get in touch on | ||
[Gitter](https://gitter.im/open-telemetry/opentelemetry-go). | ||
|
||
## Development | ||
|
||
There are some generated files checked into the repo. To make sure | ||
that the generated files are up-to-date, run `make` (or `make | ||
precommit` - the `precommit` target is the default). | ||
|
||
The `precommit` target also fixes the formatting of the code and | ||
checks the status of the go module files. | ||
|
||
If after running `make precommit` the output of `git status` contains | ||
`nothing to commit, working tree clean` then it means that everything | ||
is up-to-date and properly formatted. | ||
|
||
## Pull Requests | ||
|
||
### How to Send Pull Requests | ||
|
||
Everyone is welcome to contribute code to `opentelemetry-go-contrib` via | ||
GitHub pull requests (PRs). | ||
|
||
To create a new PR, fork the project in GitHub and clone the upstream | ||
repo: | ||
|
||
```sh | ||
$ git clone https://github.com/open-telemetry/opentelemetry-go | ||
``` | ||
This would put the project in the `opentelemetry-go-contrib` directory in | ||
current working directory. | ||
|
||
Enter the newly created directory and add your fork as a new remote: | ||
|
||
```sh | ||
$ git remote add <YOUR_FORK> [email protected]:<YOUR_GITHUB_USERNAME>/opentelemetry-go | ||
``` | ||
|
||
Check out a new branch, make modifications, run linters and tests, and | ||
push the branch to your fork: | ||
|
||
```sh | ||
$ git checkout -b <YOUR_BRANCH_NAME> | ||
# edit files | ||
$ make precommit | ||
$ git add -p | ||
$ git commit | ||
$ git push <YOUR_FORK> <YOUR_BRANCH_NAME> | ||
``` | ||
|
||
Open a pull request against the main `opentelemetry-go-contrib` repo. | ||
|
||
### How to Receive Comments | ||
|
||
* If the PR is not ready for review, please put `[WIP]` in the title, | ||
tag it as `work-in-progress`, or mark it as | ||
[`draft`](https://github.blog/2019-02-14-introducing-draft-pull-requests/). | ||
* Make sure CLA is signed and CI is clear. | ||
|
||
### How to Get PRs Merged | ||
|
||
A PR is considered to be **ready to merge** when: | ||
|
||
* It has received two approvals from Collaborators/Maintainers (at | ||
different companies). | ||
* Major feedbacks are resolved. | ||
* It has been open for review for at least one working day. This gives | ||
people reasonable time to review. | ||
* Trivial change (typo, cosmetic, doc, etc.) doesn't have to wait for | ||
one day. | ||
* Urgent fix can take exception as long as it has been actively | ||
communicated. | ||
|
||
Any Collaborator/Maintainer can merge the PR once it is **ready to | ||
merge**. | ||
|
||
## Style Guide | ||
|
||
* Make sure to run `make precommit` - this will find and fix the code | ||
formatting. | ||
|
||
## Adding a new Contrib package | ||
|
||
To add a new contrib package follow an existing one. An empty Sample plugin | ||
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**) | ||
|
||
#### Example | ||
- plugins/gorm/trace | ||
- plugins/kafka/metrics | ||
|
||
## Approvers and Maintainers | ||
|
||
Approvers: | ||
|
||
- [Isobel Redelmeier](https://github.com/iredelmeier), LightStep | ||
- [Krzesimir Nowak](https://github.com/krnowak), Kinvolk | ||
- [Liz Fong-Jones](https://github.com/lizthegrey), Honeycomb | ||
- [Gustavo Silva Paiva](https://github.com/paivagustavo), Stilingue | ||
- [Ted Young](https://github.com/tedsuo), LightStep | ||
- [Tyler Yahn](https://github.com/MrAlias), New Relic | ||
|
||
Maintainers: | ||
|
||
- [Josh MacDonald](https://github.com/jmacd), LightStep | ||
- [Rahul Patel](https://github.com/rghetia), Google | ||
|
||
### Become an Approver or a Maintainer | ||
|
||
See the [community membership document in OpenTelemetry community | ||
repo](https://github.com/open-telemetry/community/blob/master/community-membership.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
TOOLS_MOD_DIR := ./tools | ||
|
||
# All source code and documents. Used in spell check. | ||
ALL_DOCS := $(shell find . -name '*.md' -type f | sort) | ||
# All directories with go.mod files related to opentelemetry library. Used for building, testing and linting. | ||
ALL_GO_MOD_DIRS := $(filter-out $(TOOLS_MOD_DIR), $(shell find . -type f -name 'go.mod' -exec dirname {} \; | sort)) | ||
ALL_COVERAGE_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {} \; | egrep -v '^./example|^$(TOOLS_MOD_DIR)' | sort) | ||
|
||
|
||
# Mac OS Catalina 10.5.x doesn't support 386. Hence skip 386 test | ||
SKIP_386_TEST = false | ||
UNAME_S := $(shell uname -s) | ||
ifeq ($(UNAME_S),Darwin) | ||
SW_VERS := $(shell sw_vers -productVersion) | ||
ifeq ($(shell echo $(SW_VERS) | egrep '^(10.1[5-9]|1[1-9]|[2-9])'), $(SW_VERS)) | ||
SKIP_386_TEST = true | ||
endif | ||
endif | ||
|
||
|
||
GOTEST_MIN = go test -v -timeout 30s | ||
GOTEST = $(GOTEST_MIN) -race | ||
GOTEST_WITH_COVERAGE = $(GOTEST) -coverprofile=coverage.txt -covermode=atomic | ||
|
||
.DEFAULT_GOAL := precommit | ||
|
||
.PHONY: precommit | ||
|
||
TOOLS_DIR := $(abspath ./.tools) | ||
|
||
$(TOOLS_DIR)/golangci-lint: $(TOOLS_MOD_DIR)/go.mod $(TOOLS_MOD_DIR)/go.sum $(TOOLS_MOD_DIR)/tools.go | ||
cd $(TOOLS_MOD_DIR) && \ | ||
go build -o $(TOOLS_DIR)/golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint | ||
|
||
$(TOOLS_DIR)/misspell: $(TOOLS_MOD_DIR)/go.mod $(TOOLS_MOD_DIR)/go.sum $(TOOLS_MOD_DIR)/tools.go | ||
cd $(TOOLS_MOD_DIR) && \ | ||
go build -o $(TOOLS_DIR)/misspell github.com/client9/misspell/cmd/misspell | ||
|
||
$(TOOLS_DIR)/stringer: $(TOOLS_MOD_DIR)/go.mod $(TOOLS_MOD_DIR)/go.sum $(TOOLS_MOD_DIR)/tools.go | ||
cd $(TOOLS_MOD_DIR) && \ | ||
go build -o $(TOOLS_DIR)/stringer golang.org/x/tools/cmd/stringer | ||
|
||
precommit: generate build lint test | ||
|
||
.PHONY: test-with-coverage | ||
test-with-coverage: | ||
set -e; for dir in $(ALL_COVERAGE_MOD_DIRS); do \ | ||
echo "go test ./... + coverage in $${dir}"; \ | ||
(cd "$${dir}" && \ | ||
$(GOTEST_WITH_COVERAGE) ./... && \ | ||
go tool cover -html=coverage.txt -o coverage.html); \ | ||
done | ||
|
||
.PHONY: ci | ||
ci: precommit check-clean-work-tree test-with-coverage test-386 | ||
|
||
.PHONY: check-clean-work-tree | ||
check-clean-work-tree: | ||
@if ! git diff --quiet; then \ | ||
echo; \ | ||
echo 'Working tree is not clean, did you forget to run "make precommit"?'; \ | ||
echo; \ | ||
git status; \ | ||
exit 1; \ | ||
fi | ||
|
||
.PHONY: build | ||
build: | ||
# TODO: Fix this on windows. | ||
set -e; for dir in $(ALL_GO_MOD_DIRS); do \ | ||
echo "compiling all packages in $${dir}"; \ | ||
(cd "$${dir}" && \ | ||
go build ./... && \ | ||
go test -run xxxxxMatchNothingxxxxx ./... >/dev/null); \ | ||
done | ||
|
||
.PHONY: test | ||
test: | ||
set -e; for dir in $(ALL_GO_MOD_DIRS); do \ | ||
echo "go test ./... + race in $${dir}"; \ | ||
(cd "$${dir}" && \ | ||
$(GOTEST) ./...); \ | ||
done | ||
|
||
.PHONY: test-386 | ||
test-386: | ||
if [ $(SKIP_386_TEST) = true ] ; then \ | ||
echo "skipping the test for GOARCH 386 as it is not supported on the current OS"; \ | ||
else \ | ||
set -e; for dir in $(ALL_GO_MOD_DIRS); do \ | ||
echo "go test ./... GOARCH 386 in $${dir}"; \ | ||
(cd "$${dir}" && \ | ||
GOARCH=386 $(GOTEST_MIN) ./...); \ | ||
done; \ | ||
fi | ||
|
||
.PHONY: lint | ||
lint: $(TOOLS_DIR)/golangci-lint $(TOOLS_DIR)/misspell | ||
set -e; for dir in $(ALL_GO_MOD_DIRS); do \ | ||
echo "golangci-lint in $${dir}"; \ | ||
(cd "$${dir}" && \ | ||
$(TOOLS_DIR)/golangci-lint run --fix && \ | ||
$(TOOLS_DIR)/golangci-lint run); \ | ||
done | ||
$(TOOLS_DIR)/misspell -w $(ALL_DOCS) | ||
set -e; for dir in $(ALL_GO_MOD_DIRS) $(TOOLS_MOD_DIR); do \ | ||
echo "go mod tidy in $${dir}"; \ | ||
(cd "$${dir}" && \ | ||
go mod tidy); \ | ||
done | ||
|
||
generate: $(TOOLS_DIR)/stringer | ||
PATH="$(TOOLS_DIR):$${PATH}" go generate ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
# opentelemetry-go-contrib | ||
|
||
This repo contains packages that facilitates instrumenting libraries with Opentelemetry for | ||
distributed tracing and monitoring. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2020, 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 sample contains a sample plugin for OpenTelemetry distributed tracing. | ||
package trace // import "github.com/open-telemetry/opentelemetry-go-contrib/plugins/sample/trace" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2020, 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 trace_test | ||
|
||
import ( | ||
"github.com/open-telemetry/opentelemetry-go-contrib/plugins/sample/trace" | ||
) | ||
|
||
func ExampleRegister() { | ||
// Register with Sample plugin | ||
_ = trace.Register() | ||
|
||
// Output: | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module github.com/open-telemetry/opentelemetry-go-contrib/plugins/sample/trace | ||
|
||
go 1.13 | ||
|
||
require github.com/stretchr/testify v1.5.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= | ||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= | ||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2020, 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 trace | ||
|
||
// Register enables instrumenting an imaginary Sample application using Sample plugin. | ||
func Register() error { | ||
// Do something so to enable tracing in the application. | ||
return nil | ||
} |
Oops, something went wrong.