diff --git a/version/example_test.go b/version/example_test.go new file mode 100644 index 00000000..570dd73e --- /dev/null +++ b/version/example_test.go @@ -0,0 +1,26 @@ +// Copyright 2024 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package version_test + +import ( + "github.com/prometheus/common/promslog" + "github.com/prometheus/common/version" +) + +// ExampleSlog mirrors the documented usage of version.Slog and keeps it +// compiling, so the example in the godoc cannot drift from the real API. +func ExampleSlog() { + logger := promslog.New(&promslog.Config{}) + logger.Info("Starting Prometheus Server", version.Slog()...) +} diff --git a/version/info.go b/version/info.go index 112f3552..f70636de 100644 --- a/version/info.go +++ b/version/info.go @@ -82,7 +82,7 @@ func BuildContext() string { // Slog returns a slice of strings for use with structured logging. // // Example: -// logger := promslog.New(promslog.Config{}) +// logger := promslog.New(&promslog.Config{}) // logger.Info("Starting Prometheus Server", version.Slog()...) func Slog() []any { return []any{