1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15- package internal
15+ package observability
1616
1717// This file contains helpers that are useful to add observability
1818// with metrics and tracing using OpenCensus to the various pieces
@@ -31,22 +31,26 @@ import (
3131)
3232
3333var (
34- tagKeyReceiver , _ = tag .NewKey ("oc_receiver" )
3534 mReceiverReceivedSpans = stats .Int64 ("oc.io/receiver/received_spans" , "Counts the number of spans received by the receiver" , "1" )
3635 mReceiverDroppedSpans = stats .Int64 ("oc.io/receiver/dropped_spans" , "Counts the number of spans dropped by the receiver" , "1" )
3736
38- tagKeyExporter , _ = tag .NewKey ("oc_exporter" )
3937 mExporterReceivedSpans = stats .Int64 ("oc.io/exporter/received_spans" , "Counts the number of spans received by the exporter" , "1" )
4038 mExporterDroppedSpans = stats .Int64 ("oc.io/exporter/dropped_spans" , "Counts the number of spans received by the exporter" , "1" )
4139)
4240
41+ // TagKeyReceiver defines tag key for Receiver.
42+ var TagKeyReceiver , _ = tag .NewKey ("oc_receiver" )
43+
44+ // TagKeyExporter defines tag key for Exporter.
45+ var TagKeyExporter , _ = tag .NewKey ("oc_exporter" )
46+
4347// ViewReceiverReceivedSpans defines the view for the receiver received spans metric.
4448var ViewReceiverReceivedSpans = & view.View {
4549 Name : mReceiverReceivedSpans .Name (),
4650 Description : mReceiverReceivedSpans .Description (),
4751 Measure : mReceiverReceivedSpans ,
4852 Aggregation : view .Sum (),
49- TagKeys : []tag.Key {tagKeyReceiver },
53+ TagKeys : []tag.Key {TagKeyReceiver },
5054}
5155
5256// ViewReceiverDroppedSpans defines the view for the receiver dropped spans metric.
@@ -55,7 +59,7 @@ var ViewReceiverDroppedSpans = &view.View{
5559 Description : mReceiverDroppedSpans .Description (),
5660 Measure : mReceiverDroppedSpans ,
5761 Aggregation : view .Sum (),
58- TagKeys : []tag.Key {tagKeyReceiver },
62+ TagKeys : []tag.Key {TagKeyReceiver },
5963}
6064
6165// ViewExporterReceivedSpans defines the view for the exporter received spans metric.
@@ -64,7 +68,7 @@ var ViewExporterReceivedSpans = &view.View{
6468 Description : mExporterReceivedSpans .Description (),
6569 Measure : mExporterReceivedSpans ,
6670 Aggregation : view .Sum (),
67- TagKeys : []tag.Key {tagKeyReceiver , tagKeyExporter },
71+ TagKeys : []tag.Key {TagKeyReceiver , TagKeyExporter },
6872}
6973
7074// ViewExporterDroppedSpans defines the view for the exporter dropped spans metric.
@@ -73,7 +77,7 @@ var ViewExporterDroppedSpans = &view.View{
7377 Description : mExporterDroppedSpans .Description (),
7478 Measure : mExporterDroppedSpans ,
7579 Aggregation : view .Sum (),
76- TagKeys : []tag.Key {tagKeyReceiver , tagKeyExporter },
80+ TagKeys : []tag.Key {TagKeyReceiver , TagKeyExporter },
7781}
7882
7983// AllViews has the views for the metrics provided by the agent.
@@ -88,7 +92,7 @@ var AllViews = []*view.View{
8892// and returns the newly created context. For receivers that can receive multiple signals it is
8993// recommended to encode the signal as suffix (e.g. "oc_trace" and "oc_metrics").
9094func ContextWithReceiverName (ctx context.Context , receiverName string ) context.Context {
91- ctx , _ = tag .New (ctx , tag .Upsert (tagKeyReceiver , receiverName ))
95+ ctx , _ = tag .New (ctx , tag .Upsert (TagKeyReceiver , receiverName ))
9296 return ctx
9397}
9498
@@ -102,7 +106,7 @@ func RecordTraceReceiverMetrics(ctxWithTraceReceiverName context.Context, receiv
102106// and returns the newly created context. For exporters that can export multiple signals it is
103107// recommended to encode the signal as suffix (e.g. "oc_trace" and "oc_metrics").
104108func ContextWithExporterName (ctx context.Context , exporterName string ) context.Context {
105- ctx , _ = tag .New (ctx , tag .Upsert (tagKeyExporter , exporterName ))
109+ ctx , _ = tag .New (ctx , tag .Upsert (TagKeyExporter , exporterName ))
106110 return ctx
107111}
108112
0 commit comments