github.com/cloudwego/hertz@v0.9.3/pkg/common/tracer/traceinfo/interface.go (about)

     1  /*
     2   * Copyright 2022 CloudWeGo Authors
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *     http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  
    17  package traceinfo
    18  
    19  import (
    20  	"time"
    21  
    22  	"github.com/cloudwego/hertz/pkg/common/tracer/stats"
    23  )
    24  
    25  // HTTPStats is used to collect statistics about the HTTP.
    26  type HTTPStats interface {
    27  	Record(event stats.Event, status stats.Status, info string)
    28  	GetEvent(event stats.Event) Event
    29  	SendSize() int
    30  	SetSendSize(size int)
    31  	RecvSize() int
    32  	SetRecvSize(size int)
    33  	Error() error
    34  	SetError(err error)
    35  	Panicked() (bool, interface{})
    36  	SetPanicked(x interface{})
    37  	Level() stats.Level
    38  	SetLevel(level stats.Level)
    39  	Reset()
    40  }
    41  
    42  // Event is the abstraction of an event happened at a specific time.
    43  type Event interface {
    44  	Event() stats.Event
    45  	Status() stats.Status
    46  	Info() string
    47  	Time() time.Time
    48  	IsNil() bool
    49  }
    50  
    51  // TraceInfo contains the trace message in Hertz.
    52  type TraceInfo interface {
    53  	Stats() HTTPStats
    54  	Reset()
    55  }