Skip to content

Commit

Permalink
Merge branch 'main' into otelecho/codeowner
Browse files Browse the repository at this point in the history
  • Loading branch information
pellared authored Oct 11, 2024
2 parents 3deb5cf + 45ba204 commit 2bf0544
Show file tree
Hide file tree
Showing 174 changed files with 3,190 additions and 3,503 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ jobs:
test-compatibility:
runs-on: ubuntu-latest
needs: [compatibility-test]
if: always()
steps:
- name: Test if compatibility-test workflow passed
run: |
echo ${{ needs.compatibility-test.result }}
test ${{ needs.compatibility-test.result }} == "success"
3 changes: 2 additions & 1 deletion .github/workflows/links-fail-fast.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
fail: true
args: --max-concurrency 5 --cache --max-cache-age 1d .
# TODO: Remove 429s exception once https://github.com/open-telemetry/opentelemetry-go-contrib/issues/6183 is resolved
args: --max-concurrency 5 --cache --max-cache-age 1d --accept 100..=103,200..=299,429 .
3 changes: 2 additions & 1 deletion .github/workflows/links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: --max-concurrency 1 --cache --max-cache-age 1d .
# TODO: Remove 429s exception once https://github.com/open-telemetry/opentelemetry-go-contrib/issues/6183 is resolved
args: --max-concurrency 1 --cache --max-cache-age 1d --accept 100..=103,200..=299,429 .

- name: Create Issue From File
if: steps.lychee.outputs.exit_code != 0
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Move examples from `go.opentelemetry.io/otel` to this repository under `examples` directory. (#6158)
- Support yaml/json struct tags for generated code in `go.opentelemetry.io/contrib/config`. (#5433)
- Add support for parsing YAML configuration via `ParseYAML` in `go.opentelemetry.io/contrib/config`. (#5433)
- Add support for temporality preference configuration in `go.opentelemetry.io/contrib/config`. (#5860)

### Changed

Expand All @@ -25,13 +26,19 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Fixed

- Possible nil dereference panic in `go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace`. (#5965)
- `logrus.Level` transformed to appropriate `log.Severity` in `go.opentelemetry.io/contrib/bridges/otellogrus`. (#6191)

### Removed

- The `Minimum` field of the `LogProcessor` in `go.opentelemetry.io/contrib/processors/minsev` is removed.
Use `NewLogProcessor` to configure this setting. (#6116)
- The deprecated `go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron` package is removed. (#6186)
- The deprecated `go.opentelemetry.io/contrib/samplers/aws/xray` package is removed. (#6187)

### Changed

- Updated `go.opentelemetry.io/contrib/config` to use the [v0.3.0](https://github.com/open-telemetry/opentelemetry-configuration/releases/tag/v0.3.0) release of schema which includes backwards incompatible changes. (#6126)

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

Expand Down
1 change: 0 additions & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ instrumentation/github.com/gorilla/mux/otelmux/ @open-te
instrumentation/github.com/labstack/echo/otelecho/ @open-telemetry/go-approvers @scorpionknifes
instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo/ @open-telemetry/go-approvers
instrumentation/google.golang.org/grpc/otelgrpc/ @open-telemetry/go-approvers @dashpole
instrumentation/gopkg.in/macaron.v1/otelmacaron/ @open-telemetry/go-approvers

instrumentation/host/ @open-telemetry/go-approvers @dmathieu
instrumentation/net/http/httptrace/otelhttptrace/ @open-telemetry/go-approvers @dmathieu
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ update-all-otel-deps:
OPENTELEMETRY_CONFIGURATION_JSONSCHEMA_SRC_DIR=tmp/opentelememetry-configuration

# The SHA matching the current version of the opentelemetry-configuration schema to use
OPENTELEMETRY_CONFIGURATION_JSONSCHEMA_VERSION=v0.2.0
OPENTELEMETRY_CONFIGURATION_JSONSCHEMA_VERSION=v0.3.0

# Cleanup temporary directory
genjsonschema-cleanup:
Expand All @@ -326,6 +326,7 @@ genjsonschema: genjsonschema-cleanup $(GOJSONSCHEMA)
--capitalization OTLP \
--struct-name-from-title \
--package config \
--only-models \
--output ${GENERATED_CONFIG} \
${OPENTELEMETRY_CONFIGURATION_JSONSCHEMA_SRC_DIR}/schema/opentelemetry_configuration.json
@echo Modify jsonschema generated files.
Expand Down
2 changes: 1 addition & 1 deletion bridges/otellogrus/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ require (
go.opentelemetry.io/otel v1.30.0 // indirect
go.opentelemetry.io/otel/metric v1.30.0 // indirect
go.opentelemetry.io/otel/trace v1.30.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/sys v0.26.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
4 changes: 2 additions & 2 deletions bridges/otellogrus/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ go.opentelemetry.io/otel/metric v1.30.0/go.mod h1:aXTfST94tswhWEb+5QjlSqG+cZlmyX
go.opentelemetry.io/otel/trace v1.30.0 h1:7UBkkYzeg3C7kQX8VAidWh2biiQbtAKjyIML8dQ9wmc=
go.opentelemetry.io/otel/trace v1.30.0/go.mod h1:5EyKqTzzmyqB9bwtCCq6pDLktPK6fmGf/Dph+8VI02o=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
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.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down
38 changes: 31 additions & 7 deletions bridges/otellogrus/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
// set.
// - Fields are transformed and set as the attributes.
//
// The Level is transformed by using the static offset to the OpenTelemetry
// The Level is transformed to the OpenTelemetry
// Severity types. For example:
//
// - [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]
// - [logrus.InfoLevel] is transformed to [log.SeverityInfo]
// - [logrus.WarnLevel] is transformed to [log.SeverityWarn]
// - [logrus.ErrorLevel] is transformed to [log.SeverityError]
// - [logrus.FatalLevel] is transformed to [log.SeverityFatal]
// - [logrus.PanicLevel] is transformed to [log.SeverityFatal4]
//
// Field values are transformed based on their type into log attributes, or
// into a string value if there is no matching type.
Expand Down Expand Up @@ -164,9 +166,7 @@ func (h *Hook) convertEntry(e *logrus.Entry) log.Record {
var record log.Record
record.SetTimestamp(e.Time)
record.SetBody(log.StringValue(e.Message))

const sevOffset = logrus.Level(log.SeverityDebug) - logrus.DebugLevel
record.SetSeverity(log.Severity(e.Level + sevOffset))
record.SetSeverity(convertSeverity(e.Level))
record.AddAttributes(convertFields(e.Data)...)

return record
Expand All @@ -183,6 +183,30 @@ func convertFields(fields logrus.Fields) []log.KeyValue {
return kvs
}

func convertSeverity(level logrus.Level) log.Severity {
switch level {
case logrus.PanicLevel:
// PanicLevel is not supported by OpenTelemetry, use Fatal4 as the highest severity.
return log.SeverityFatal4
case logrus.FatalLevel:
return log.SeverityFatal
case logrus.ErrorLevel:
return log.SeverityError
case logrus.WarnLevel:
return log.SeverityWarn
case logrus.InfoLevel:
return log.SeverityInfo
case logrus.DebugLevel:
return log.SeverityDebug
case logrus.TraceLevel:
return log.SeverityTrace
default:
// If the level is not recognized, use SeverityUndefined as the lowest severity.
// we should never reach this point as logrus only uses the above levels.
return log.SeverityUndefined
}
}

func convertValue(v interface{}) log.Value {
switch v := v.(type) {
case bool:
Expand Down
76 changes: 71 additions & 5 deletions bridges/otellogrus/hook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func TestHookFire(t *testing.T) {

wantRecords: map[string][]log.Record{
name: {
buildRecord(log.StringValue(""), time.Time{}, 0, nil),
buildRecord(log.StringValue(""), time.Time{}, log.SeverityFatal4, nil),
},
},
},
Expand All @@ -173,18 +173,84 @@ func TestHookFire(t *testing.T) {
},
wantRecords: map[string][]log.Record{
name: {
buildRecord(log.StringValue(""), now, 0, nil),
buildRecord(log.StringValue(""), now, log.SeverityFatal4, nil),
},
},
},
{
name: "emits a log entry with severity level",
name: "emits a log entry with panic severity level",
entry: &logrus.Entry{
Level: logrus.PanicLevel,
},
wantRecords: map[string][]log.Record{
name: {
buildRecord(log.StringValue(""), time.Time{}, log.SeverityFatal4, nil),
},
},
},
{
name: "emits a log entry with fatal severity level",
entry: &logrus.Entry{
Level: logrus.FatalLevel,
},
wantRecords: map[string][]log.Record{
name: {
buildRecord(log.StringValue(""), time.Time{}, log.SeverityTrace1, nil),
buildRecord(log.StringValue(""), time.Time{}, log.SeverityFatal, nil),
},
},
},
{
name: "emits a log entry with error severity level",
entry: &logrus.Entry{
Level: logrus.ErrorLevel,
},
wantRecords: map[string][]log.Record{
name: {
buildRecord(log.StringValue(""), time.Time{}, log.SeverityError, nil),
},
},
},
{
name: "emits a log entry with warn severity level",
entry: &logrus.Entry{
Level: logrus.WarnLevel,
},
wantRecords: map[string][]log.Record{
name: {
buildRecord(log.StringValue(""), time.Time{}, log.SeverityWarn, nil),
},
},
},
{
name: "emits a log entry with info severity level",
entry: &logrus.Entry{
Level: logrus.InfoLevel,
},
wantRecords: map[string][]log.Record{
name: {
buildRecord(log.StringValue(""), time.Time{}, log.SeverityInfo, nil),
},
},
},
{
name: "emits a log entry with info severity level",
entry: &logrus.Entry{
Level: logrus.DebugLevel,
},
wantRecords: map[string][]log.Record{
name: {
buildRecord(log.StringValue(""), time.Time{}, log.SeverityDebug, nil),
},
},
},
{
name: "emits a log entry with info severity level",
entry: &logrus.Entry{
Level: logrus.TraceLevel,
},
wantRecords: map[string][]log.Record{
name: {
buildRecord(log.StringValue(""), time.Time{}, log.SeverityTrace, nil),
},
},
},
Expand All @@ -197,7 +263,7 @@ func TestHookFire(t *testing.T) {
},
wantRecords: map[string][]log.Record{
name: {
buildRecord(log.StringValue(""), time.Time{}, 0, []log.KeyValue{
buildRecord(log.StringValue(""), time.Time{}, log.SeverityFatal4, []log.KeyValue{
log.String("hello", "world"),
}),
},
Expand Down
4 changes: 2 additions & 2 deletions bridges/prometheus/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ require (
github.com/rogpeppe/go-internal v1.13.1 // indirect
go.opentelemetry.io/otel/metric v1.30.0 // indirect
go.opentelemetry.io/otel/trace v1.30.0 // indirect
golang.org/x/sys v0.25.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
golang.org/x/sys v0.26.0 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
8 changes: 4 additions & 4 deletions bridges/prometheus/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ go.opentelemetry.io/otel/sdk/metric v1.30.0 h1:QJLT8Pe11jyHBHfSAgYH7kEmT24eX792j
go.opentelemetry.io/otel/sdk/metric v1.30.0/go.mod h1:waS6P3YqFNzeP01kuo/MBBYqaoBJl7efRQHOaydhy1Y=
go.opentelemetry.io/otel/trace v1.30.0 h1:7UBkkYzeg3C7kQX8VAidWh2biiQbtAKjyIML8dQ9wmc=
go.opentelemetry.io/otel/trace v1.30.0/go.mod h1:5EyKqTzzmyqB9bwtCCq6pDLktPK6fmGf/Dph+8VI02o=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
Expand Down
8 changes: 8 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,11 @@ func ParseYAML(file []byte) (*OpenTelemetryConfiguration, error) {

return &cfg, nil
}

func toStringMap(pairs []NameStringValuePair) map[string]string {
output := make(map[string]string)
for _, v := range pairs {
output[v.Name] = *v.Value
}
return output
}
Loading

0 comments on commit 2bf0544

Please sign in to comment.