Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into mvg/semconv/metrics…
Browse files Browse the repository at this point in the history
…-server/old
  • Loading branch information
MadVikingGod committed Aug 1, 2024
2 parents dcdc4c2 + 7ee1471 commit 1749252
Show file tree
Hide file tree
Showing 100 changed files with 2,212 additions and 636 deletions.
27 changes: 15 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,20 @@ jobs:
strategy:
matrix:
go-version: ["~1.22.4", "~1.21.12"]
os: [ubuntu-latest, macos-latest, windows-latest]
# GitHub Actions does not support arm* architectures on default
# runners. It is possible to accomplish this with a self-hosted runner
# if we want to add this in the future:
# https://docs.github.com/en/actions/hosting-your-own-runners/using-self-hosted-runners-in-a-workflow
arch: ["386", amd64]
exclude:
# Not a supported Go OS/architecture.
- os: macos-latest
arch: "386"
runs-on: ${{ matrix.os }}
platform:
- os: ubuntu-latest
arch: "386"
- os: ubuntu-latest
arch: amd64
- os: macos-13
arch: amd64
- os: macos-latest
arch: arm64
- os: windows-latest
arch: "386"
- os: windows-latest
arch: amd64
runs-on: ${{ matrix.platform.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -124,7 +127,7 @@ jobs:
cache-dependency-path: "**/go.sum"
- name: Run tests
env:
GOARCH: ${{ matrix.arch }}
GOARCH: ${{ matrix.platform.arch }}
run: make test-short

test-compatibility:
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/protect-released-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This action against that any PR targeting the main branch touches released
# sections in CHANGELOG file. If change to released CHANGELOG is required, like
# doing a release, add the \"Unlock Released Changelog\" label to disable this action.

name: Protect released changelog

on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
jobs:
protect-released-changelog:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.labels.*.name, 'Unlock Released Changelog')}}

steps:
- uses: actions/checkout@v4

- name: Protect the released changelog
run: |
./tools/verify_released_changelog.sh ${{ github.base_ref }}
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ linters:
disable-all: true
# Specifically enable linters we want to use.
enable:
- asasalint
- bodyclose
- depguard
- errcheck
- errorlint
Expand Down
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,23 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Added

- Add the new `go.opentelemetry.io/contrib/instrgen` package to provide auto-generated source code instrumentation. (#3068, #3108)
- Support for stdoutlog exporter in `go.opentelemetry.io/contrib/config`. (#5850)
- Add macOS ARM64 platform to the compatibility testing suite. (#5868)
- The `go.opentelemetry.io/contrib/bridges/otelzap` module.
This module provides an OpenTelemetry logging bridge for `go.uber.org/zap`. (#5191)
- The `go.opentelemetry.io/contrib/config` package supports configuring `with_resource_constant_labels` for the prometheus exporter. (#5890)
- Add new runtime metrics to `go.opentelemetry.io/contrib/instrumentation/runtime`, which are still disabled by default. (#5870)
- Support for the `OTEL_HTTP_CLIENT_COMPATIBILITY_MODE=http/dup` environment variable in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp` to emit attributes for both the v1.20.0 and v1.26.0 semantic conventions. (#5401)
- The `go.opentelemetry.io/contrib/bridges/otelzerolog` module.
This module provides an OpenTelemetry logging bridge for `github.com/rs/zerolog`. (#5405)

### Removed

- The deprecated `go.opentelemetry.io/contrib/processors/baggagecopy` package is removed. (#5853)

<!-- Released section -->
<!-- Don't change this section unless doing release -->

## [1.28.0/0.53.0/0.22.0/0.8.0/0.3.0/0.1.0] - 2024-07-02

### Added
Expand Down Expand Up @@ -1132,6 +1142,8 @@ First official tagged release of `contrib` repository.
[0.7.0]: https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v0.7.0
[0.6.1]: https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v0.6.1

<!-- Released section ended -->

[Go 1.22]: https://go.dev/doc/go1.22
[Go 1.21]: https://go.dev/doc/go1.21
[Go 1.20]: https://go.dev/doc/go1.20
Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ bridges/otelslog @open-te
bridges/otellogrus/ @open-telemetry/go-approvers @dmathieu @pellared
bridges/prometheus/ @open-telemetry/go-approvers @dashpole
bridges/otelzap/ @open-telemetry/go-approvers @pellared @khushijain21
bridges/otelzerolog/ @open-telemetry/go-approvers @dmathieu @AkhigbeEromo

config/ @open-telemetry/go-approvers @MadVikingGod @pellared @codeboten

Expand Down
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,20 @@ stop ensuring compatibility with these versions in the following manner:

This project is tested on the following systems.

| OS | Go Version | Architecture |
| ------- | ---------- | ------------ |
| Ubuntu | 1.22 | amd64 |
| Ubuntu | 1.21 | amd64 |
| Ubuntu | 1.22 | 386 |
| Ubuntu | 1.21 | 386 |
| MacOS | 1.22 | amd64 |
| MacOS | 1.21 | amd64 |
| Windows | 1.22 | amd64 |
| Windows | 1.21 | amd64 |
| Windows | 1.22 | 386 |
| Windows | 1.21 | 386 |
| OS | Go Version | Architecture |
| -------- | ---------- | ------------ |
| Ubuntu | 1.22 | amd64 |
| Ubuntu | 1.21 | amd64 |
| Ubuntu | 1.22 | 386 |
| Ubuntu | 1.21 | 386 |
| macOS 13 | 1.22 | amd64 |
| macOS 13 | 1.21 | amd64 |
| macOS | 1.22 | arm64 |
| macOS | 1.21 | arm64 |
| Windows | 1.22 | amd64 |
| Windows | 1.21 | amd64 |
| Windows | 1.22 | 386 |
| Windows | 1.21 | 386 |

While this project should work for other systems, no compatibility guarantees
are made for those systems currently.
Expand Down
3 changes: 3 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ since the last release tag.
git --no-pager log --pretty=oneline "<last tag>..HEAD"
```

Make sure the new released section is under the comment for released section,
like `<!-- Released section -->`, so it is protected from being overwritten in the future.

Be sure to update all the appropriate links at the bottom of the file.

Finally, commit this change to your release branch.
Expand Down
10 changes: 5 additions & 5 deletions bridges/otellogrus/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
// The Level is transformed by using the static offset to the OpenTelemetry
// Severity types. For example:
//
// - [slog.LevelDebug] is transformed to [log.SeverityDebug]
// - [slog.LevelInfo] is transformed to [log.SeverityInfo]
// - [slog.LevelWarn] is transformed to [log.SeverityWarn]
// - [slog.LevelError] is transformed to [log.SeverityError]
// - [logrus.DebugLevel] is transformed to [log.SeverityDebug]
// - [logrus.InfoLevel] is transformed to [log.SeverityTrace4]
// - [logrus.WarnLevel] is transformed to [log.SeverityTrace3]
// - [logrus.ErrorLevel] is transformed to [log.SeverityTrace2]
//
// Attribute values are transformed based on their type into log attributes, or
// Field values are transformed based on their type into log attributes, or
// into a string value if there is no matching type.
//
// [OpenTelemetry]: https://opentelemetry.io/docs/concepts/signals/logs/
Expand Down
34 changes: 5 additions & 29 deletions bridges/otelslog/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import (
"fmt"
"log/slog"
"slices"
"sync"

"go.opentelemetry.io/otel/log"
"go.opentelemetry.io/otel/log/global"
Expand Down Expand Up @@ -180,8 +179,7 @@ func (h *Handler) convertRecord(r slog.Record) log.Record {
n := r.NumAttrs()
if h.group != nil {
if n > 0 {
buf, free := getKVBuffer()
defer free()
buf := newKVBuffer(n)
r.Attrs(buf.AddAttr)
record.AddAttributes(h.group.KeyValue(buf.KeyValues()...))
} else {
Expand All @@ -192,8 +190,7 @@ func (h *Handler) convertRecord(r slog.Record) log.Record {
}
}
} else if n > 0 {
buf, free := getKVBuffer()
defer free()
buf := newKVBuffer(n)
r.Attrs(buf.AddAttr)
record.AddAttributes(buf.KeyValues()...)
}
Expand Down Expand Up @@ -338,27 +335,6 @@ func (g *group) AddAttrs(attrs []slog.Attr) {
g.attrs.AddAttrs(attrs)
}

var kvBufferPool = sync.Pool{
New: func() any {
// Based on slog research (https://go.dev/blog/slog#performance), 95%
// of use-cases will use 5 or less attributes.
return newKVBuffer(5)
},
}

func getKVBuffer() (buf *kvBuffer, free func()) {
buf = kvBufferPool.Get().(*kvBuffer)
return buf, func() {
// TODO: limit returned size so the pool doesn't hold on to very large
// buffers. Idea is based on
// https://cs.opensource.google/go/x/exp/+/814bf88c:slog/internal/buffer/buffer.go;l=27-34

// Do not modify any previously held data.
buf.data = buf.data[:0:0]
kvBufferPool.Put(buf)
}
}

type kvBuffer struct {
data []log.KeyValue
}
Expand Down Expand Up @@ -451,9 +427,9 @@ func convertValue(v slog.Value) log.Value {
case slog.KindUint64:
return log.Int64Value(int64(v.Uint64()))
case slog.KindGroup:
buf, free := getKVBuffer()
defer free()
buf.AddAttrs(v.Group())
g := v.Group()
buf := newKVBuffer(len(g))
buf.AddAttrs(g)
return log.MapValue(buf.data...)
case slog.KindLogValuer:
return convertValue(v.Resolve())
Expand Down
Loading

0 comments on commit 1749252

Please sign in to comment.