Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into mx-psi/telemetrypro…
Browse files Browse the repository at this point in the history
…vider
  • Loading branch information
mx-psi committed Apr 29, 2022
2 parents f42add2 + 2acc422 commit 1eaafda
Show file tree
Hide file tree
Showing 341 changed files with 6,505 additions and 4,752 deletions.
2 changes: 1 addition & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ coverage:
target: 95%

ignore:
- "model/internal/data/protogen/**/*"
- "pdata/internal/data/protogen/**/*"
10 changes: 5 additions & 5 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ updates:
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "gomod"
directory: "/"
schedule:
Expand All @@ -27,6 +23,10 @@ updates:
schedule:
interval: "weekly"
- package-ecosystem: "gomod"
directory: "/model"
directory: "/pdata"
schedule:
interval: "weekly"
- package-ecosystem: "gomod"
directory: "/semconv"
schedule:
interval: "weekly"
58 changes: 57 additions & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,64 @@ jobs:
- name: Run Unit Tests With Coverage
run: make gotest-with-cover
- name: Upload coverage report
uses: codecov/codecov-action@v2.1.0
uses: codecov/codecov-action@v3
with:
file: ./coverage.txt
fail_ci_if_error: true
verbose: true
cross-build-collector:
needs: [setup-environment]
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
include:
# Go 1.15 dropped support for 32-bit binaries
# on macOS: https://go.dev/doc/go1.15
#- goos: darwin
# goarch: 386
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm64
- goos: linux
goarch: 386
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
- goos: windows
goarch: 386
- goos: windows
goarch: amd64

steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.17
- name: Setup Go Environment
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Cache Go
id: module-cache
uses: actions/cache@v3
with:
path: /home/runner/go/pkg/mod
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Cache Tools
id: tool-cache
uses: actions/cache@v3
with:
path: /home/runner/go/bin
key: tools-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod', './cmd/mdatagen/go.mod', './cmd/mdatagen/*.go') }}
- name: Build
env:
GOOS: ${{matrix.goos}}
GOARCH: ${{matrix.goarch}}
run: |
make otelcorecol
35 changes: 27 additions & 8 deletions .github/workflows/check-links.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,37 @@ on:
- 'cmd/builder/**'

jobs:
check-links:
changedfiles:
name: changed files
runs-on: ubuntu-latest
outputs:
md: ${{ steps.changes.outputs.md }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: gaurav-nelson/[email protected]
- name: Get changed files
id: changes
run: |
echo "::set-output name=md::$(git diff --name-only --diff-filter=ACMRTUXB origin/${{ github.event.pull_request.base.ref }} ${{ github.event.pull_request.head.sha }} | grep .md$ | xargs)"
check-links:
runs-on: ubuntu-latest
needs: changedfiles
if: ${{needs.changedfiles.outputs.md}}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
base-branch: 'main'
use-quiet-mode: 'yes'
use-verbose-mode: 'yes'
config-file: '.github/workflows/check_links_config.json'
check-modified-files-only: 'yes'
folder-path: ''
fetch-depth: 0

- name: Install markdown-link-check
run: npm install -g markdown-link-check

- name: Run markdown-link-check
run: |
markdown-link-check \
--verbose \
--config .github/workflows/check_links_config.json \
${{needs.changedfiles.outputs.md}}
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: go

- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
2 changes: 1 addition & 1 deletion .github/workflows/stale-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v4
- uses: actions/stale@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-pr-message: 'This PR was marked stale due to lack of activity. It will be closed in 14 days.'
Expand Down
8 changes: 8 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,16 @@ linters-settings:
- kilometre
- kilometres

depguard:
list-type: denylist
include-go-root: true
packages-with-error-message:
# See https://github.com/open-telemetry/opentelemetry-collector/issues/5200 for rationale
- sync/atomic: "Use go.uber.org/atomic instead of sync/atomic"

linters:
enable:
- depguard
- errcheck
- exportloopref
- gocritic
Expand Down
65 changes: 64 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,84 @@

### 🛑 Breaking changes 🛑

- Remove deprecated model module, everything is available in `pdata` and `semconv`. (#5281)
- Old versions of the module are still available, but no new versions will be released.

### 🚩 Deprecations 🚩

### 💡 Enhancements 💡

### 🧰 Bug fixes 🧰

## v0.50.0 Beta

### 🛑 Breaking changes 🛑

- Remove pdata deprecated funcs from 2 versions (v0.48.0) ago. (#5219)
- Remove non pdata deprecated funcs/structs (#5220)
- `pmetric.Exemplar.ValueType()` now returns new type `ExemplarValueType` (#5233)

### 🚩 Deprecations 🚩

- Deprecate `configunmarshaler` package, move it to internal (#5151)
- Deprecate all API in `model/semconv`. The package is moved to a new `semcomv` module (#5196)
- Deprecate access to `config.Retrieved` fields, use the newly added funcs to interact with the internal fields (#5198)
- Deprecate `p<signal>otlp.Request.Set<Logs|Metrics|Traces>` (#5234)
- `plogotlp.Request.SetLogs` func is deprecated in favor of `plogotlp.NewRequestFromLogs`
- `pmetricotlp.Request.SetMetrics` func is deprecated in favor of `pmetricotlp.NewRequestFromMetrics`
- `ptraceotlp.Request.SetTraces` func is deprecated in favor of `ptraceotlp.NewRequestFromTraces`
- `pmetric.NumberDataPoint.ValueType()` now returns new type `NumberDataPointValueType` (#5233)
- `pmetric.MetricValueType` is deprecated in favor of `NumberDataPointValueType`
- `pmetric.MetricValueTypeNone` is deprecated in favor of `NumberDataPointValueTypeNone`
- `pmetric.MetricValueTypeInt` is deprecated in favor of `NumberDataPointValueTypeInt`
- `pmetric.MetricValueTypeDouble` is deprecated in favor of `NumberDataPointValueTypeDouble`
- Deprecate `plog.LogRecord.SetName()` function (#5230)
- Deprecate global `featuregate` funcs in favor of `GetRegistry` and a public `Registry` type (#5160)

### 💡 Enhancements 💡

- Extend config.Map.Unmarshal hook to check map key string to any TextUnmarshaler not only ComponentID (#5244)
- Collector will no longer print error with stack trace when the collector is shutdown due to a context cancel. (#5258)

### 🧰 Bug fixes 🧰
- Fix translation from otlp.Request to pdata representation, changes to the returned pdata not all reflected to the otlp.Request (#5197)
- `exporterhelper` now properly consumes any remaining items on stop (#5203)
- `pdata`: Fix copying of `Value` with `ValueTypeBytes` type (#5267)
- `pdata`: Fix copying of metric fields of primitive items slice type (#5271)

## v0.49.0 Beta

### 🛑 Breaking changes 🛑

- Remove deprecated structs/funcs from previous versions (#5131)
- Do not set TraceProvider to global otel (#5138)
- Remove deprecated funcs from otlpgrpc (#5144)
- Add Scheme to MapProvider interface (#5068)
- Do not set MeterProvider to global otel (#5146)
- Make `InstrumentationLibrary<signal>ToScope` helper functions unexported (#5164)
- Remove Log's "ShortName" from logging exporter output (#5172)
- `exporter/otlp`: Retry RESOURCE_EXHAUSTED only if the server returns RetryInfo (#5147)

### 🚩 Deprecations 🚩

- All pdata related APIs from model (model/pdata, model/otlp and model/otlpgrpc) are deprecated in
favor of packages in the new pdata module separated by telemetry signal type (#5168)
- `model/pdata`, `model/otlp` -> `pdata/pcommon`, `pdata/plog`, `pdata/pmetric`, `pdata/ptrace`
- `model/otlpgrpc` -> `pdata/plog/plogotlp`, `pdata/pmetric/pmetricotlp`, `pdata/ptrace/ptraceotlp`
- Deprecate configmapprovider package, replace with mapconverter (#5167)
- Deprecate `service.MustNewConfigProvider` and `service.MustNewDefaultConfigProvider`in favor of `service.NewConfigProvider` (#4936)

### 💡 Enhancements 💡

- OTLP HTTP receiver will use HTTP/2 over TLS if client supports it (#5190)
- OTLP HTTP receiver will use HTTP/2 over TLS if client supports it (#5109)
- Add `ObservedTimestamp` field to `pdata.LogRecord` (#5171)

### 🧰 Bug fixes 🧰

- Setup the correct meter provider if telemetry.useOtelForInternalMetrics featuregate enabled (#5146)
- Fix pdata.Value.asRaw() to correctly return elements of Slice and Map type (#5153)
- Update pdata.Slice.asRaw() to return raw representation of Slice and Map elements (#5157)
- The codepath through the OTLP receiver for gRPC was not translating the InstrumentationLibrary* to Scope* (#5189)

## v0.48.0 Beta

Expand Down
19 changes: 10 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ reasonably fast reviews.

### When adding a new component

Consider submitting different PRs for (more details about adding new components
[here](#adding-new-components)) :
Consider submitting different PRs:

* First PR should include the overall structure of the new component:
* Readme, configuration, and factory implementation usually using the helper
Expand Down Expand Up @@ -225,10 +224,10 @@ To keep naming patterns consistent across the project, naming patterns are enfor
In order to simplify developing within the project, library recommendations have been set
and should be followed.

| Scenario | Recommended | Rationale |
|---------- |---------------------------------------------- |-------------------------------------------------------------------------------------------------------------------------- |
| Hashing | ["hashing/fnv"](https://pkg.go.dev/hash/fnv) | The project adopted this as the default hashing method due to the efficiency and is reasonable for non cryptographic use |
| Testing | Use `t.Parallel()` where possible | Enabling more test to be run in parallel will speed up the feedback process when working on the project. |
| Scenario | Recommended | Rationale |
|------------|------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------|
| Hashing | ["hashing/fnv"](https://pkg.go.dev/hash/fnv) | The project adopted this as the default hashing method due to the efficiency and is reasonable for non cryptographic use |
| Testing | Use `t.Parallel()` where possible | Enabling more test to be run in parallel will speed up the feedback process when working on the project. |


Within the project, there are some packages that are yet to follow the recommendations and are being address, however, any new code should adhere to the recommendations.
Expand Down Expand Up @@ -415,9 +414,11 @@ version (`vM.N+1`).
Deprecation notice SHOULD contain a version starting from which the deprecation takes effect for tracking purposes. For
example, if `GetFoo` function is going to be deprecated in `v0.45.0` version, it gets the following godoc line:

```go
// Deprecated: [v0.45.0] Use MustGetFoo instead.
func GetFoo() Bar {
```golang
package test

// Deprecated: [v0.45.0] Use MustDoFoo instead.
func DoFoo() {}
```

When deprecating a feature affecting end-users, consider first deprecating the feature in one version, then hiding it
Expand Down
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include ./Makefile.Common
# This is the code that we want to run lint, etc.
ALL_SRC := $(shell find . -name '*.go' \
-not -path './internal/tools/*' \
-not -path './model/internal/data/protogen/*' \
-not -path './pdata/internal/data/protogen/*' \
-not -path './service/internal/zpages/tmplgen/*' \
-type f | sort)

Expand Down Expand Up @@ -218,7 +218,6 @@ gendependabot: $(eval SHELL:=/bin/bash)
@echo "version: 2" >> ${DEPENDABOT_PATH}
@echo "updates:" >> ${DEPENDABOT_PATH}
$(MAKE) internal-gendependabot DIR="/" PACKAGE="github-actions"
$(MAKE) internal-gendependabot DIR="/" PACKAGE="docker"
$(MAKE) internal-gendependabot DIR="/" PACKAGE="gomod"
@set -e; for dir in $(ALL_MODULES); do \
$(MAKE) internal-gendependabot DIR=$${dir:1} PACKAGE="gomod"; \
Expand All @@ -227,7 +226,7 @@ gendependabot: $(eval SHELL:=/bin/bash)
# Definitions for ProtoBuf generation.

# The source directory for OTLP ProtoBufs.
OPENTELEMETRY_PROTO_SRC_DIR=model/internal/opentelemetry-proto
OPENTELEMETRY_PROTO_SRC_DIR=pdata/internal/opentelemetry-proto

# The SHA matching the current version of the proto to use
OPENTELEMETRY_PROTO_VERSION=v0.15.0
Expand All @@ -236,13 +235,13 @@ OPENTELEMETRY_PROTO_VERSION=v0.15.0
OPENTELEMETRY_PROTO_FILES := $(subst $(OPENTELEMETRY_PROTO_SRC_DIR)/,,$(wildcard $(OPENTELEMETRY_PROTO_SRC_DIR)/opentelemetry/proto/*/v1/*.proto $(OPENTELEMETRY_PROTO_SRC_DIR)/opentelemetry/proto/collector/*/v1/*.proto))

# Target directory to write generated files to.
PROTO_TARGET_GEN_DIR=model/internal/data/protogen
PROTO_TARGET_GEN_DIR=pdata/internal/data/protogen

# Go package name to use for generated files.
PROTO_PACKAGE=go.opentelemetry.io/collector/$(PROTO_TARGET_GEN_DIR)

# Intermediate directory used during generation.
PROTO_INTERMEDIATE_DIR=model/internal/.patched-otlp-proto
PROTO_INTERMEDIATE_DIR=pdata/internal/.patched-otlp-proto

DOCKER_PROTOBUF ?= otel/build-protobuf:0.9.0
PROTOC := docker run --rm -u ${shell id -u} -v${PWD}:${PWD} -w${PWD}/$(PROTO_INTERMEDIATE_DIR) ${DOCKER_PROTOBUF} --proto_path=${PWD}
Expand Down Expand Up @@ -290,24 +289,25 @@ genproto_sub:
# Generate structs, functions and tests for pdata package. Must be used after any changes
# to proto and after running `make genproto`
genpdata:
$(GOCMD) run model/internal/cmd/pdatagen/main.go
$(GOCMD) run pdata/internal/cmd/pdatagen/main.go
$(MAKE) fmt

# Generate semantic convention constants. Requires a clone of the opentelemetry-specification repo
gensemconv:
@[ "${SPECPATH}" ] || ( echo ">> env var SPECPATH is not set"; exit 1 )
@[ "${SPECTAG}" ] || ( echo ">> env var SPECTAG is not set"; exit 1 )
@echo "Generating semantic convention constants from specification version ${SPECTAG} at ${SPECPATH}"
semconvgen -o model/semconv/${SPECTAG} -t model/internal/semconv/template.j2 -s ${SPECTAG} -i ${SPECPATH}/semantic_conventions/resource -p conventionType=resource -f generated_resource.go
semconvgen -o model/semconv/${SPECTAG} -t model/internal/semconv/template.j2 -s ${SPECTAG} -i ${SPECPATH}/semantic_conventions/trace -p conventionType=trace -f generated_trace.go
semconvgen -o semconv/${SPECTAG} -t semconv/template.j2 -s ${SPECTAG} -i ${SPECPATH}/semantic_conventions/resource -p conventionType=resource -f generated_resource.go
semconvgen -o semconv/${SPECTAG} -t semconv/template.j2 -s ${SPECTAG} -i ${SPECPATH}/semantic_conventions/trace -p conventionType=trace -f generated_trace.go

# Checks that the HEAD of the contrib repo checked out in CONTRIB_PATH compiles
# against the current version of this repo.
.PHONY: check-contrib
check-contrib:
@echo Setting contrib at $(CONTRIB_PATH) to use this core checkout
@$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -replace go.opentelemetry.io/collector=$(CURDIR)"
@$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -replace go.opentelemetry.io/collector/model=$(CURDIR)/model"
@$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -replace go.opentelemetry.io/collector/pdata=$(CURDIR)/pdata"
@$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -replace go.opentelemetry.io/collector/semconv=$(CURDIR)/semconv"
@$(MAKE) -C $(CONTRIB_PATH) -j2 gotidy
@$(MAKE) -C $(CONTRIB_PATH) test
@echo Restoring contrib to no longer use this core checkout
Expand Down
4 changes: 2 additions & 2 deletions client/doc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ import (

"go.opentelemetry.io/collector/client"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/model/pdata"
"go.opentelemetry.io/collector/pdata/ptrace"
)

func Example_receiver() {
// Your receiver get a next consumer when it's constructed
var next consumer.Traces

// You'll convert the incoming data into pipeline data
td := pdata.NewTraces()
td := ptrace.NewTraces()

// You probably have a context with client metadata from your listener or
// scraper
Expand Down
Loading

0 comments on commit 1eaafda

Please sign in to comment.