storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/pkg/trace/trace.go (about) 1 /* 2 * MinIO Cloud Storage, (C) 2019 MinIO, Inc. 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 trace 18 19 import ( 20 "net/http" 21 "time" 22 ) 23 24 // Type indicates the type of the tracing Info 25 type Type int 26 27 const ( 28 // HTTP tracing (MinIO S3 & Internode) 29 HTTP Type = iota 30 // OS tracing (Golang os package calls) 31 OS 32 // Storage tracing (MinIO Storage Layer) 33 Storage 34 ) 35 36 // Info - represents a trace record, additionally 37 // also reports errors if any while listening on trace. 38 type Info struct { 39 TraceType Type `json:"type"` 40 41 NodeName string `json:"nodename"` 42 FuncName string `json:"funcname"` 43 Time time.Time `json:"time"` 44 45 ReqInfo RequestInfo `json:"request"` 46 RespInfo ResponseInfo `json:"response"` 47 CallStats CallStats `json:"stats"` 48 49 StorageStats StorageStats `json:"storageStats"` 50 OSStats OSStats `json:"osStats"` 51 } 52 53 // StorageStats statistics on MinIO Storage layer calls 54 type StorageStats struct { 55 Path string `json:"path"` 56 Duration time.Duration `json:"duration"` 57 } 58 59 // OSStats statistics on operating system specific calls. 60 type OSStats struct { 61 Path string `json:"path"` 62 Duration time.Duration `json:"duration"` 63 } 64 65 // CallStats records request stats 66 type CallStats struct { 67 InputBytes int `json:"inputbytes"` 68 OutputBytes int `json:"outputbytes"` 69 Latency time.Duration `json:"latency"` 70 TimeToFirstByte time.Duration `json:"timetofirstbyte"` 71 } 72 73 // RequestInfo represents trace of http request 74 type RequestInfo struct { 75 Time time.Time `json:"time"` 76 Proto string `json:"proto"` 77 Method string `json:"method"` 78 Path string `json:"path,omitempty"` 79 RawQuery string `json:"rawquery,omitempty"` 80 Headers http.Header `json:"headers,omitempty"` 81 Body []byte `json:"body,omitempty"` 82 Client string `json:"client"` 83 } 84 85 // ResponseInfo represents trace of http request 86 type ResponseInfo struct { 87 Time time.Time `json:"time"` 88 Headers http.Header `json:"headers,omitempty"` 89 Body []byte `json:"body,omitempty"` 90 StatusCode int `json:"statuscode,omitempty"` 91 }