Skip to content

Commit

Permalink
Merge branch 'main' into revert-6220-renovate/lycheeverse-lychee-acti…
Browse files Browse the repository at this point in the history
…on-2.x
  • Loading branch information
dmathieu authored Oct 11, 2024
2 parents f1e0dec + 5322670 commit 6e99819
Show file tree
Hide file tree
Showing 40 changed files with 456 additions and 2,356 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"
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ 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)

<!-- Released section -->
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
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
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
2 changes: 1 addition & 1 deletion detectors/aws/eks/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ require (
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20241009091222-67ed5848f094 // indirect
k8s.io/utils v0.0.0-20240921022957-49e7df575cb6 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/json v0.0.0-20241009153224-e386a8af8d30 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
4 changes: 2 additions & 2 deletions detectors/aws/eks/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ k8s.io/kube-openapi v0.0.0-20241009091222-67ed5848f094 h1:MErs8YA0abvOqJ8gIupA1T
k8s.io/kube-openapi v0.0.0-20241009091222-67ed5848f094/go.mod h1:7ioBJr1A6igWjsR2fxq2EZ0mlMwYLejazSIc2bzMp2U=
k8s.io/utils v0.0.0-20240921022957-49e7df575cb6 h1:MDF6h2H/h4tbzmtIKTuctcwZmY0tY9mD9fNT47QO6HI=
k8s.io/utils v0.0.0-20240921022957-49e7df575cb6/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/json v0.0.0-20241009153224-e386a8af8d30 h1:ObU1vgTtAle8WwCKgcDkPjLJYwlazQpIjzSA0asMhy4=
sigs.k8s.io/json v0.0.0-20241009153224-e386a8af8d30/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4=
sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08=
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
Expand Down
1 change: 0 additions & 1 deletion instrumentation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ The following instrumentation packages are provided for popular Go packages and
| [github.com/labstack/echo](./github.com/labstack/echo/otelecho) | ||
| [go.mongodb.org/mongo-driver](./go.mongodb.org/mongo-driver/mongo/otelmongo) | ||
| [google.golang.org/grpc](./google.golang.org/grpc/otelgrpc) |||
| [gopkg.in/macaron.v1](./gopkg.in/macaron.v1/otelmacaron) | ||
| [host](./host) || |
| [net/http](./net/http/otelhttp) |||
| [net/http/httptrace](./net/http/httptrace/otelhttptrace) | ||
Expand Down
61 changes: 0 additions & 61 deletions instrumentation/gopkg.in/macaron.v1/otelmacaron/config.go

This file was deleted.

15 changes: 0 additions & 15 deletions instrumentation/gopkg.in/macaron.v1/otelmacaron/doc.go

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

30 changes: 0 additions & 30 deletions instrumentation/gopkg.in/macaron.v1/otelmacaron/example/go.mod

This file was deleted.

Loading

0 comments on commit 6e99819

Please sign in to comment.