Skip to content

Conversation

@MrAlias
Copy link
Contributor

@MrAlias MrAlias commented Sep 11, 2024

  • Use the built in slog package to log instead of using logr.
  • Replace WithLogLevel with WithLogger
    • Allow users to provide a fully-customized logger with their handler of choice instead of imposing a choice on them.
  • Removes dependency on github.com/go-logr/zapr, go.uber.org/zap v1.27.0, and go.uber.org/multierr

Resolves #1104

Example Output

Raw:

{"time":"2024-09-11T17:29:35.700958753Z","level":"INFO","source":{"function":"go.opentelemetry.io/auto/internal/pkg/process.(*Analyzer).DiscoverProcessID","file":"/app/internal/pkg/process/discover.go","line":64},"msg":"found process","pid":754625}
{"time":"2024-09-11T17:29:35.723405405Z","level":"INFO","source":{"function":"go.opentelemetry.io/auto/internal/pkg/process.remoteAllocate.func1","file":"/app/internal/pkg/process/allocate.go","line":70},"msg":"Detaching from process","pid":754625}
{"time":"2024-09-11T17:29:35.723583269Z","level":"INFO","source":{"function":"go.opentelemetry.io/auto.NewInstrumentation","file":"/app/instrumentation.go","line":111},"msg":"target process analysis completed","pid":754625,"go_version":"1.23.1","dependencies":{"go.uber.org/multierr":"1.10.0","go.uber.org/zap":"1.27.0","std":"1.23.1"},"total_functions_found":2}
{"time":"2024-09-11T17:29:35.723973977Z","level":"INFO","source":{"function":"main.main","file":"/app/cli/main.go","line":134},"msg":"starting instrumentation..."}
{"time":"2024-09-11T17:29:35.731129749Z","level":"INFO","source":{"function":"go.opentelemetry.io/auto/internal/pkg/instrumentation.(*Manager).load","file":"/app/internal/pkg/instrumentation/manager.go","line":323},"msg":"loading probe","name":{"SpanKind":2,"InstrumentedPkg":"net/http"}}
{"time":"2024-09-11T17:29:36.079187915Z","level":"INFO","source":{"function":"go.opentelemetry.io/auto/internal/pkg/instrumentation.(*Manager).ConfigLoop","file":"/app/internal/pkg/instrumentation/manager.go","line":237},"msg":"Configuration provider closed, configuration updates will no longer be received"}
{"time":"2024-09-11T17:29:36.079275764Z","level":"INFO","source":{"function":"main.main.func3","file":"/app/cli/main.go","line":130},"msg":"instrumentation loaded successfully"}

Wrapped:

{
  "time": "2024-09-11T17:29:35.723973977Z",
  "level": "INFO",
  "source": {
    "function": "main.main",
    "file": "/app/cli/main.go",
    "line": 134
  },
  "msg": "starting instrumentation..."
},
{
  "time": "2024-09-11T17:29:35.731129749Z",
  "level": "INFO",
  "source": {
    "function": "go.opentelemetry.io/auto/internal/pkg/instrumentation.(*Manager).load",
    "file": "/app/internal/pkg/instrumentation/manager.go",
    "line": 323
  },
  "msg": "loading probe",
  "name": {
    "SpanKind": 2,
    "InstrumentedPkg": "net/http"
  }
},
{
  "time": "2024-09-11T17:29:36.079187915Z",
  "level": "INFO",
  "source": {
    "function": "go.opentelemetry.io/auto/internal/pkg/instrumentation.(*Manager).ConfigLoop",
    "file": "/app/internal/pkg/instrumentation/manager.go",
    "line": 237
  },
  "msg": "Configuration provider closed, configuration updates will no longer be received"
},
{
  "time": "2024-09-11T17:29:36.079275764Z",
  "level": "INFO",
  "source": {
    "function": "main.main.func3",
    "file": "/app/cli/main.go",
    "line": 130
  },
  "msg": "instrumentation loaded successfully"
}

@MrAlias MrAlias force-pushed the use-slog branch 10 times, most recently from 49a192b to 74f17c6 Compare September 11, 2024 17:13
@MrAlias MrAlias marked this pull request as ready for review September 11, 2024 17:35
@MrAlias MrAlias requested a review from a team September 11, 2024 17:35
Copy link
Contributor

@RonFed RonFed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great

@MrAlias MrAlias requested a review from a team as a code owner September 18, 2024 21:34
@MrAlias MrAlias merged commit effdec9 into open-telemetry:main Sep 18, 2024
@MrAlias MrAlias deleted the use-slog branch September 18, 2024 21:45
@MrAlias MrAlias added this to the v0.15.0-alpha milestone Oct 1, 2024
@MrAlias MrAlias mentioned this pull request Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Logging Is Closed-Off and Unconfigurable

2 participants