Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Automatically forward logs to OTEL #128

Open
jamesstocktonj1 opened this issue Nov 18, 2024 · 0 comments
Open

Feature: Automatically forward logs to OTEL #128

jamesstocktonj1 opened this issue Nov 18, 2024 · 0 comments

Comments

@jamesstocktonj1
Copy link
Contributor

Description

The default provider.New sets up the structured/text slog.Logger for use out of the box. These logs are printed to stderr and as per the host otel documentation these aren't exported to otel. The otel logger which is setup in the provider also doesn't forward them. I propose that if remote logs are enabled then the p.Logger should automatically forward them.

The library github.com/samber/slog-multi allows you to fanout to multiple slog.Handler. The code would look something like the following:

if hostData.OtelConfig.LogsEnabled() {
	// existing loggerProvider setup...
	logger = slog.New(slogmulti.Fanout(
		logger.Handler(),
		otelslog.NewHandler(
			"provider",
			otelslog.WithLoggerProvider(loggerProvider),
		),
	))
}

Would anyone have any objections to this or is it preferred for logs to be exported to otel manually?

@joonas joonas transferred this issue from wasmCloud/provider-sdk-go Jan 2, 2025
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

No branches or pull requests

1 participant