Skip to content

Commit

Permalink
Init Logs Bridge API design
Browse files Browse the repository at this point in the history
  • Loading branch information
pellared committed Nov 17, 2023
1 parent a6f19fe commit c8fcf28
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 35 deletions.
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,15 @@ updates:
schedule:
interval: weekly
day: sunday
- package-ecosystem: gomod
directory: /log
labels:
- dependencies
- go
- Skip Changelog
schedule:
interval: weekly
day: sunday
- package-ecosystem: gomod
directory: /metric
labels:
Expand Down
51 changes: 51 additions & 0 deletions docs/design/log-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Logs Bridge API Design

Author: Robert Pająk

Tracking issue at [#4696](https://github.com/open-telemetry/opentelemetry-go/issues/4696).

## Abstract

<!-- A short summary of the proposal. -->

We propose adding a `go.opentelemetry.io/otel/log` Go module which will provide
[Logs Data Model](https://opentelemetry.io/docs/specs/otel/logs/data-model/)
and [Logs Bridge API](https://opentelemetry.io/docs/specs/otel/logs/data-model/).

## Background

<!-- An introduction of the necessary background and the problem being solved by the proposed change. -->

They key challenge is to create API which will be complaint with the specification
and be as performant as possible.

Performance is seen as one of the most imporatant charactristics of logging libraries in Go.

## Proposal

The design and benchmarks takes inspiration from [`slog`](https://pkg.go.dev/log/slog),
because for the Go team it was also critical to create API that would be fast
and interoperable with existing logging packages. [^1] [^2]

<!-- A precise statement of the proposed change. -->

## Rationale

<!-- A discussion of alternate approaches and the trade offs, advantages, and disadvantages of the specified approach. -->

## Compatibility

The backwards compatibility is achieved using the `embedded` design pattern
that is already used in Trace API and Metrics API.

## Implementation

<!-- A description of the steps in the implementation, who will do them, and when. -->

## Open issues (if applicable)

<!-- A discussion of issues relating to this proposal for which the author does not
know the solution. This section may be omitted if there are none. -->

[^1]: Jonathan Amsterdam, [The Go Blog: Structured Logging with slog](https://go.dev/blog/slog)
[^2]: Jonathan Amsterdam, [GopherCon Europe 2023: A Fast Structured Logging Package](https://www.youtube.com/watch?v=tC4Jt3i62ns)
35 changes: 0 additions & 35 deletions docs/design/logs.md

This file was deleted.

30 changes: 30 additions & 0 deletions log/bench_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package log_test

import "testing"

// These benchmarks are based on slog/internal/benchmarks.
// They have the following desirable properties:
//
// - They test a complete log record, from the user's call to its return.
//
// - The benchmarked code is run concurrently in multiple goroutines, to
// better simulate a real server (the most common environment for structured
// logs).
//
// - Some handlers are optimistic versions of real handlers, doing real-world
// tasks as fast as possible (and sometimes faster, in that an
// implementation may not be concurrency-safe). This gives us an upper bound
// on handler performance, so we can evaluate the (handler-independent) core
// activity of the package in an end-to-end context without concern that a
// slow handler implementation is skewing the results.
func BenchmarkEndToEnd(b *testing.B) {
// TODO: Replicate https://github.com/golang/go/blob/master/src/log/slog/internal/benchmarks/benchmarks_test.go
// Run benchmarks against a "noop.Logger" and "fastTextLogger" (based on fastTextHandler)
}
5 changes: 5 additions & 0 deletions log/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

// Package log provides the OpenTelemetry Logs Data Model and Bridge API.
package log // import "go.opentelemetry.io/otel/log"
8 changes: 8 additions & 0 deletions log/example_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package log_test

func Example() {
// Output:
}
3 changes: 3 additions & 0 deletions log/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module go.opentelemetry.io/otel/log

go 1.20
1 change: 1 addition & 0 deletions versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ module-sets:
- go.opentelemetry.io/otel/schema
excluded-modules:
- go.opentelemetry.io/otel/internal/tools
- go.opentelemetry.io/otel/log

0 comments on commit c8fcf28

Please sign in to comment.