-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
583 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
module go.opentelemetry.io/otel/log | ||
|
||
go 1.20 | ||
|
||
require go.opentelemetry.io/otel v1.23.1 | ||
|
||
replace go.opentelemetry.io/otel/metric => ../metric | ||
|
||
replace go.opentelemetry.io/otel => ../ | ||
|
||
replace go.opentelemetry.io/otel/trace => ../trace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= | ||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,216 @@ | ||
// Copyright The OpenTelemetry 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. | ||
|
||
//go:generate stringer -type=Kind -trimprefix=Kind | ||
|
||
package log // import "go.opentelemetry.io/otel/log" | ||
|
||
// A Value represents a structured log value. | ||
type Value struct { | ||
// TODO: implement. | ||
} | ||
|
||
// Kind is the kind of a [Value]. | ||
type Kind int | ||
|
||
// Kind values. | ||
const ( | ||
KindEmpty Kind = iota | ||
KindBool | ||
KindFloat64 | ||
KindInt64 | ||
KindString | ||
KindBytes | ||
// TODO: determine if this should be renamed to "slice". | ||
KindList | ||
KindMap | ||
) | ||
|
||
// Kind returns the Kind of v. | ||
func (v Value) Kind() Kind { | ||
// TODO: implement. | ||
return KindEmpty | ||
} | ||
|
||
// StringValue returns a new [Value] for a string. | ||
func StringValue(v string) Value { | ||
// TODO: implement. | ||
return Value{} | ||
} | ||
|
||
// IntValue returns a [Value] for an int. | ||
func IntValue(v int) Value { | ||
// TODO: implement. | ||
return Value{} | ||
} | ||
|
||
// Int64Value returns a [Value] for an int64. | ||
func Int64Value(v int64) Value { | ||
// TODO: implement. | ||
return Value{} | ||
} | ||
|
||
// Float64Value returns a [Value] for a float64. | ||
func Float64Value(v float64) Value { | ||
// TODO: implement. | ||
return Value{} | ||
} | ||
|
||
// BoolValue returns a [Value] for a bool. | ||
func BoolValue(v bool) Value { //nolint:revive // Not a control flag. | ||
// TODO: implement. | ||
return Value{} | ||
} | ||
|
||
// BytesValue returns a [Value] for a byte slice. The passed slice must not be | ||
// changed after it is passed. | ||
func BytesValue(v []byte) Value { | ||
// TODO: implement. | ||
return Value{} | ||
} | ||
|
||
// ListValue returns a [Value] for a slice of [Value]. The passed slice must | ||
// not be changed after it is passed. | ||
func ListValue(vs ...Value) Value { | ||
// TODO: implement. | ||
return Value{} | ||
} | ||
|
||
// MapValue returns a new [Value] for a slice of key-value pairs. The passed | ||
// slice must not be changed after it is passed. | ||
func MapValue(kvs ...KeyValue) Value { | ||
// TODO: implement. | ||
return Value{} | ||
} | ||
|
||
// AsAny returns the value held by v as an any. | ||
func (v Value) AsAny() any { | ||
// TODO: implement | ||
return nil | ||
} | ||
|
||
// AsString returns the value held by v as a string. | ||
func (v Value) AsString() string { | ||
// TODO: implement | ||
return "" | ||
} | ||
|
||
// AsInt64 returns the value held by v as an int64. | ||
func (v Value) AsInt64() int64 { | ||
// TODO: implement | ||
return 0 | ||
} | ||
|
||
// AsBool returns the value held by v as a bool. | ||
func (v Value) AsBool() bool { | ||
// TODO: implement | ||
return false | ||
} | ||
|
||
// AsFloat64 returns the value held by v as a float64. | ||
func (v Value) AsFloat64() float64 { | ||
// TODO: implement | ||
return 0 | ||
} | ||
|
||
// AsBytes returns the value held by v as a []byte. | ||
func (v Value) AsBytes() []byte { | ||
// TODO: implement | ||
return nil | ||
} | ||
|
||
// AsList returns the value held by v as a []Value. | ||
func (v Value) AsList() []Value { | ||
// TODO: implement | ||
return nil | ||
} | ||
|
||
// AsMap returns the value held by v as a []KeyValue. | ||
func (v Value) AsMap() []KeyValue { | ||
// TODO: implement | ||
return nil | ||
} | ||
|
||
// Empty returns if v does not hold any value. | ||
func (v Value) Empty() bool { | ||
// TODO: implement | ||
return false | ||
} | ||
|
||
// Equal returns if v is equal to w. | ||
func (v Value) Equal(w Value) bool { | ||
// TODO: implement | ||
return false | ||
} | ||
|
||
// An KeyValue is a key-value pair used to represent a log attribute (a | ||
// superset of [go.opentelemetry.io/otel/attribute.KeyValue]) and map item. | ||
type KeyValue struct { | ||
Key string | ||
Value Value | ||
} | ||
|
||
// String returns an KeyValue for a string value. | ||
func String(key, value string) KeyValue { | ||
// TODO: implement | ||
return KeyValue{} | ||
} | ||
|
||
// Int64 returns an KeyValue for an int64 value. | ||
func Int64(key string, value int64) KeyValue { | ||
// TODO: implement | ||
return KeyValue{} | ||
} | ||
|
||
// Int returns an KeyValue for an int value. | ||
func Int(key string, value int) KeyValue { | ||
// TODO: implement | ||
return KeyValue{} | ||
} | ||
|
||
// Float64 returns an KeyValue for a float64 value. | ||
func Float64(key string, v float64) KeyValue { | ||
// TODO: implement | ||
return KeyValue{} | ||
} | ||
|
||
// Bool returns an KeyValue for a bool value. | ||
func Bool(key string, v bool) KeyValue { | ||
// TODO: implement | ||
return KeyValue{} | ||
} | ||
|
||
// Bytes returns an KeyValue for a []byte value. | ||
func Bytes(key string, v []byte) KeyValue { | ||
// TODO: implement | ||
return KeyValue{} | ||
} | ||
|
||
// List returns an KeyValue for a []Value value. | ||
func List(key string, args ...Value) KeyValue { | ||
// TODO: implement | ||
return KeyValue{} | ||
} | ||
|
||
// Map returns an KeyValue for a map value. | ||
func Map(key string, args ...KeyValue) KeyValue { | ||
// TODO: implement | ||
return KeyValue{} | ||
} | ||
|
||
// Equal returns if a is equal to b. | ||
func (a KeyValue) Equal(b KeyValue) bool { | ||
// TODO: implement | ||
return false | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Copyright The OpenTelemetry 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 log // import "go.opentelemetry.io/otel/log" | ||
|
||
import ( | ||
"context" | ||
|
||
"go.opentelemetry.io/otel/attribute" | ||
) | ||
|
||
// Logger emits log records. | ||
// | ||
// Warning: Methods may be added to this interface in minor releases. See | ||
// package documentation on API implementation for information on how to set | ||
// default behavior for unimplemented methods. | ||
type Logger interface { | ||
// TODO: embed an embedded type from otel/log/embedded. | ||
|
||
// Emit emits a log record. | ||
// | ||
// The record may be held by the implementation. Callers should not mutate | ||
// the record after passed. | ||
// | ||
// Implementations of this method need to be safe for a user to call | ||
// concurrently. | ||
Emit(ctx context.Context, record Record) | ||
} | ||
|
||
// LoggerOption applies configuration options to a [Logger]. | ||
type LoggerOption interface { | ||
// applyLogger is used to set a LoggerOption value of a LoggerConfig. | ||
applyLogger(LoggerConfig) LoggerConfig | ||
} | ||
|
||
// LoggerConfig contains options for a [Logger]. | ||
type LoggerConfig struct { | ||
// Ensure forward compatibility by explicitly making this not comparable. | ||
noCmp [0]func() //nolint: unused // This is indeed used. | ||
} | ||
|
||
// NewLoggerConfig returns a new [LoggerConfig] with all the opts applied. | ||
func NewLoggerConfig(opts ...LoggerOption) LoggerConfig { | ||
// TODO: implement. | ||
return LoggerConfig{} | ||
} | ||
|
||
// InstrumentationVersion returns the version of the library providing | ||
// instrumentation. | ||
func (cfg LoggerConfig) InstrumentationVersion() string { | ||
// TODO: implement. | ||
return "" | ||
} | ||
|
||
// InstrumentationAttributes returns the attributes associated with the library | ||
// providing instrumentation. | ||
func (cfg LoggerConfig) InstrumentationAttributes() attribute.Set { | ||
// TODO: implement. | ||
return attribute.NewSet() | ||
} | ||
|
||
// SchemaURL returns the schema URL of the library providing instrumentation. | ||
func (cfg LoggerConfig) SchemaURL() string { | ||
// TODO: implement. | ||
return "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright The OpenTelemetry 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 log // import "go.opentelemetry.io/otel/log" | ||
|
||
// LoggerProvider provides access to [Logger]. | ||
// | ||
// Warning: Methods may be added to this interface in minor releases. See | ||
// package documentation on API implementation for information on how to set | ||
// default behavior for unimplemented methods. | ||
type LoggerProvider interface { | ||
// TODO: embed an embedded type from otel/log/embedded. | ||
|
||
// Logger returns a new [Logger] with the provided name and configuration. | ||
// | ||
// If name is empty, implementations need to provide a default name. | ||
// | ||
// Implementations of this method need to be safe for a user to call | ||
// concurrently. | ||
Logger(name string, options ...LoggerOption) Logger | ||
} |
Oops, something went wrong.