forked from open-telemetry/opentelemetry-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Eliminate Scope/ScopeID, separate API from SDK for metrics/stats (ope…
…n-telemetry#48) * Move scope.Active to trace.CurrentSpan * Remove scope / does not build * Global tracer * Checkpoint * Checkpoint * Add key/key.go for key.New * Comments * Remove more EventID and ScopeID * Use Handle to describe static objects * TODOs * Remove empty file * Remove singletons * Update TODOs * TODO about map update * Make stats package option aliases (like key has) * Rename experimental/streaming * streaming SDK builds w/ many TODOs * Get the examples building * Tidy up metric API / add interface check * Remove logic from the registry; this is now a placeholder
- Loading branch information
Showing
49 changed files
with
829 additions
and
1,075 deletions.
There are no files selected for viewing
This file was deleted.
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,171 @@ | ||
package core | ||
|
||
import ( | ||
"fmt" | ||
"unsafe" | ||
|
||
"github.com/open-telemetry/opentelemetry-go/api/registry" | ||
) | ||
|
||
type Key struct { | ||
Variable registry.Variable | ||
} | ||
|
||
type KeyValue struct { | ||
Key Key | ||
Value Value | ||
} | ||
|
||
type ValueType int | ||
|
||
type Value struct { | ||
Type ValueType | ||
Bool bool | ||
Int64 int64 | ||
Uint64 uint64 | ||
Float64 float64 | ||
String string | ||
Bytes []byte | ||
|
||
// TODO Lazy value type? | ||
} | ||
|
||
const ( | ||
INVALID ValueType = iota | ||
BOOL | ||
INT32 | ||
INT64 | ||
UINT32 | ||
UINT64 | ||
FLOAT32 | ||
FLOAT64 | ||
STRING | ||
BYTES | ||
) | ||
|
||
func (k Key) Bool(v bool) KeyValue { | ||
return KeyValue{ | ||
Key: k, | ||
Value: Value{ | ||
Type: BOOL, | ||
Bool: v, | ||
}, | ||
} | ||
} | ||
|
||
func (k Key) Int64(v int64) KeyValue { | ||
return KeyValue{ | ||
Key: k, | ||
Value: Value{ | ||
Type: INT64, | ||
Int64: v, | ||
}, | ||
} | ||
} | ||
|
||
func (k Key) Uint64(v uint64) KeyValue { | ||
return KeyValue{ | ||
Key: k, | ||
Value: Value{ | ||
Type: UINT64, | ||
Uint64: v, | ||
}, | ||
} | ||
} | ||
|
||
func (k Key) Float64(v float64) KeyValue { | ||
return KeyValue{ | ||
Key: k, | ||
Value: Value{ | ||
Type: FLOAT64, | ||
Float64: v, | ||
}, | ||
} | ||
} | ||
|
||
func (k Key) Int32(v int32) KeyValue { | ||
return KeyValue{ | ||
Key: k, | ||
Value: Value{ | ||
Type: INT32, | ||
Int64: int64(v), | ||
}, | ||
} | ||
} | ||
|
||
func (k Key) Uint32(v uint32) KeyValue { | ||
return KeyValue{ | ||
Key: k, | ||
Value: Value{ | ||
Type: UINT32, | ||
Uint64: uint64(v), | ||
}, | ||
} | ||
} | ||
|
||
func (k Key) Float32(v float32) KeyValue { | ||
return KeyValue{ | ||
Key: k, | ||
Value: Value{ | ||
Type: FLOAT32, | ||
Float64: float64(v), | ||
}, | ||
} | ||
} | ||
|
||
func (k Key) String(v string) KeyValue { | ||
return KeyValue{ | ||
Key: k, | ||
Value: Value{ | ||
Type: STRING, | ||
String: v, | ||
}, | ||
} | ||
} | ||
|
||
func (k Key) Bytes(v []byte) KeyValue { | ||
return KeyValue{ | ||
Key: k, | ||
Value: Value{ | ||
Type: BYTES, | ||
Bytes: v, | ||
}, | ||
} | ||
} | ||
|
||
func (k Key) Int(v int) KeyValue { | ||
if unsafe.Sizeof(v) == 4 { | ||
return k.Int32(int32(v)) | ||
} | ||
return k.Int64(int64(v)) | ||
} | ||
|
||
func (k Key) Uint(v uint) KeyValue { | ||
if unsafe.Sizeof(v) == 4 { | ||
return k.Uint32(uint32(v)) | ||
} | ||
return k.Uint64(uint64(v)) | ||
} | ||
|
||
func (k Key) Defined() bool { | ||
return k.Variable.Defined() | ||
} | ||
|
||
// TODO make this a lazy one-time conversion. | ||
func (v Value) Emit() string { | ||
switch v.Type { | ||
case BOOL: | ||
return fmt.Sprint(v.Bool) | ||
case INT32, INT64: | ||
return fmt.Sprint(v.Int64) | ||
case UINT32, UINT64: | ||
return fmt.Sprint(v.Uint64) | ||
case FLOAT32, FLOAT64: | ||
return fmt.Sprint(v.Float64) | ||
case STRING: | ||
return v.String | ||
case BYTES: | ||
return string(v.Bytes) | ||
} | ||
return "unknown" | ||
} |
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
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,23 @@ | ||
package key | ||
|
||
import ( | ||
"github.com/open-telemetry/opentelemetry-go/api/core" | ||
"github.com/open-telemetry/opentelemetry-go/api/registry" | ||
) | ||
|
||
type AnyValue struct{} | ||
|
||
func (AnyValue) String() string { | ||
return "AnyValue" | ||
} | ||
|
||
func New(name string, opts ...registry.Option) core.Key { | ||
return core.Key{ | ||
Variable: registry.Register(name, AnyValue{}, opts...), | ||
} | ||
} | ||
|
||
var ( | ||
WithDescription = registry.WithDescription | ||
WithUnit = registry.WithUnit | ||
) |
Oops, something went wrong.