trpc.group/trpc-go/trpc-go@v1.0.3/rpcz/attributes.go (about) 1 // 2 // 3 // Tencent is pleased to support the open source community by making tRPC available. 4 // 5 // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 // All rights reserved. 7 // 8 // If you have downloaded a copy of the tRPC source code from Tencent, 9 // please note that tRPC source code is licensed under the Apache 2.0 License, 10 // A copy of the Apache 2.0 License is included in this file. 11 // 12 // 13 14 package rpcz 15 16 import "strings" 17 18 // Attribute records attribute with (Name, Value) pair. 19 type Attribute struct { 20 // Name of Attribute. 21 Name string 22 // Value of Attribute. 23 Value interface{} 24 } 25 26 const ( 27 // TRPCAttributeRPCName is used to set the RPCName attribute of span. 28 TRPCAttributeRPCName = "__@*TRPCAttribute(RPCName)*@__" 29 // TRPCAttributeError is used to set the Error attribute of span. 30 TRPCAttributeError = "__@*TRPCAttribute(Error)*@__" 31 // TRPCAttributeResponseSize is used to set the ResponseSize attribute of span. 32 TRPCAttributeResponseSize = "__@*TRPCAttribute(ResponseSize)*@__" 33 // TRPCAttributeRequestSize is used to set the RequestSize attribute of span. 34 TRPCAttributeRequestSize = "__@*TRPCAttribute(RequestSize)*@__" 35 // TRPCAttributeFilterNames is used to set the FilterNames attribute of span. 36 TRPCAttributeFilterNames = "__@*TRPCAttribute(FilterNames)*@__" 37 38 // HTTPAttributeURL is used to set the URL attribute of span. 39 HTTPAttributeURL = "__@*HTTPAttribute(URL)*@__" 40 // HTTPAttributeRequestContentLength is used to set the Request's ContentLength attribute of span. 41 HTTPAttributeRequestContentLength = "__@*HTTPAttribute(RequestContentLength)*@__" 42 ) 43 44 func parsedTRPCAttribute(name string) string { 45 return strings.TrimSuffix(strings.TrimPrefix(name, "__@*TRPCAttribute("), ")*@__") 46 }