github.com/vseinstrumentiru/lego@v1.0.2/internal/lego/transport/event/metrics/stats.go (about) 1 package metrics 2 3 import ( 4 "go.opencensus.io/stats" 5 "go.opencensus.io/stats/view" 6 "go.opencensus.io/tag" 7 ) 8 9 // NewPublisher supported for use in custom views. 10 var ( 11 PublisherPublishTime = stats.Float64( 12 "publish_time_seconds", 13 "The time that a publishing attempt (success or not) took in seconds", 14 stats.UnitMilliseconds, 15 ) 16 ) 17 18 // Subscriber supported for use in custom views. 19 var ( 20 SubscriberReceivedMessage = stats.Float64( 21 "subscriber_messages_received_total", 22 "The total number of messages received by the subscriber", 23 stats.UnitDimensionless, 24 ) 25 ) 26 27 // Subscriber supported for use in custom views. 28 var ( 29 HandlerExecutionTime = stats.Float64( 30 "handler_execution_time_seconds", 31 "The total time elapsed while executing the handler function in seconds", 32 stats.UnitMilliseconds, 33 ) 34 ) 35 36 // The following tags are applied to stats recorded by this package. 37 var ( 38 HandlerName, _ = tag.NewKey("handler_name") 39 40 PublisherName, _ = tag.NewKey("publisher_name") 41 42 SubscriberName, _ = tag.NewKey("subscriber_name") 43 44 Success, _ = tag.NewKey("success") 45 46 Acked, _ = tag.NewKey("acked") 47 ) 48 49 var ( 50 DefaultMillisecondsDistribution = view.Distribution(0.01, 0.05, 0.1, 0.3, 0.6, 0.8, 1, 2, 3, 4, 5, 6, 8, 10, 13, 16, 20, 25, 30, 40, 50, 65, 80, 100, 130, 160, 200, 250, 300, 400, 500, 650, 800, 1000, 2000, 5000, 10000, 20000, 50000, 100000) 51 DefaultMessageCountDistribution = view.Distribution(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536) 52 DefaultHandlerExecutionTimeDistribution = view.Distribution(0.0005, 0.001, 0.0025, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1) 53 ) 54 55 var ( 56 PublisherPublishTimeView = &view.View{ 57 Name: "publish_time_milliseconds", 58 Description: "The time that a publishing attempt (success or not) took in milliseconds", 59 Measure: PublisherPublishTime, 60 TagKeys: []tag.Key{PublisherName, HandlerName, Success}, 61 Aggregation: DefaultMillisecondsDistribution, 62 } 63 64 SubscriberReceivedMessageView = &view.View{ 65 Name: "subscriber_messages_received_total", 66 Description: "The total number of messages received by the subscriber", 67 Measure: SubscriberReceivedMessage, 68 TagKeys: []tag.Key{SubscriberName, HandlerName, Acked}, 69 Aggregation: view.Count(), 70 } 71 72 HandlerExecutionTimeView = &view.View{ 73 Name: "handler_execution_time_seconds", 74 Description: "The total time elapsed while executing the handler function in seconds", 75 Measure: HandlerExecutionTime, 76 TagKeys: []tag.Key{HandlerName, Success}, 77 Aggregation: DefaultHandlerExecutionTimeDistribution, 78 } 79 )