Skip to content

Commit

Permalink
api: add log,metric,span API to toolkit (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShyunnY authored Aug 29, 2024
1 parent ce40681 commit 02c27af
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 0 deletions.
37 changes: 37 additions & 0 deletions toolkit/log/api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Licensed to Apache Software Foundation (ASF) under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Apache Software Foundation (ASF) licenses this file to you 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

// Debug logs a message at DebugLevel
func Debug(msg string, keyValues ...string) {

}

// Info logs a message at InfoLevel
func Info(msg string, keyValues ...string) {

}

// Warn logs a message at DebugLevel
func Warn(msg string, keyValues ...string) {

}

// Error logs a message at ErrorLevel
func Error(msg string, keyValues ...string) {
}
33 changes: 33 additions & 0 deletions toolkit/metric/api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Licensed to Apache Software Foundation (ASF) under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Apache Software Foundation (ASF) licenses this file to you 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 metric

// NewCounter creates a new counter metrics.
func NewCounter(name string, opt ...MeterOpt) *CounterRef {
return &CounterRef{}
}

// NewGauge creates a new gauge metrics.
func NewGauge(name string, watcher func() float64, opts ...MeterOpt) *GaugeRef {
return &GaugeRef{}
}

// NewHistogram creates a new histogram metrics.
func NewHistogram(name string, steps []float64, opts ...MeterOpt) *Histogram {
return &Histogram{}
}
57 changes: 57 additions & 0 deletions toolkit/metric/metrics.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Licensed to Apache Software Foundation (ASF) under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Apache Software Foundation (ASF) licenses this file to you 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 metric

type CounterRef struct{}

// Get returns the current value of the counter.
func (c *CounterRef) Get() float64 {
return -1
}

// Inc increments the counter with value.
func (c *CounterRef) Inc(val float64) {}

type GaugeRef struct {
}

// Get returns the current value of the gauge.
func (g *GaugeRef) Get() float64 {
return -1
}

type Histogram struct {
}

// Observe find the value associate bucket and add 1.
func (h *Histogram) Observe(val float64) {

}

// ObserveWithCount find the value associate bucket and add specific count.
func (h *Histogram) ObserveWithCount(val float64, count int64) {

}

type MeterOpt struct {
}

// WithLabels Add labels for metric
func WithLabels(key, val string) MeterOpt {
return MeterOpt{}
}
20 changes: 20 additions & 0 deletions toolkit/trace/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@

package trace

type EventType string

const (
// DebugEventType Indicates the event type is "debug"
DebugEventType EventType = "debug"

// InfoEventType Indicates the event type is "info"
InfoEventType EventType = "info"

// WarnEventType Indicates the event type is "warn"
WarnEventType EventType = "warn"

// ErrorEventType Indicates the event type is "error"
ErrorEventType EventType = "error"
)

func (*SpanRef) PrepareAsync() {
}

Expand All @@ -29,3 +45,7 @@ func (*SpanRef) SetTag(key string, value string) {

func (*SpanRef) AddLog(...string) {
}

// AddEvent Add an event of the specified type to SpanRef.
func (*SpanRef) AddEvent(et EventType, event string) {
}

0 comments on commit 02c27af

Please sign in to comment.