@@ -46,6 +46,9 @@ const (
46
46
metricKeySeparator = string (byte (0 ))
47
47
48
48
defaultDimensionsCacheSize = 1000
49
+
50
+ metricLatency = "latency"
51
+ metricCallsTotal = "calls_total"
49
52
)
50
53
51
54
var defaultLatencyHistogramBucketsMs = []float64 {
@@ -317,11 +320,21 @@ func (p *processorImp) buildMetrics() pmetric.Metrics {
317
320
return m
318
321
}
319
322
323
+ // buildMetricName builds a metric name by concatenating the namespace and the metric name with an underscore.
324
+ // If the namespace is not empty, the namespace and metric name will be separated by an underscore.
325
+ // Otherwise, only the metric name will be returned.
326
+ func buildMetricName (namespace , metricName string ) string {
327
+ if namespace != "" {
328
+ return namespace + "_" + metricName
329
+ }
330
+ return metricName
331
+ }
332
+
320
333
// collectLatencyMetrics collects the raw latency metrics, writing the data
321
334
// into the given instrumentation library metrics.
322
335
func (p * processorImp ) collectLatencyMetrics (ilm pmetric.ScopeMetrics ) {
323
336
mLatency := ilm .Metrics ().AppendEmpty ()
324
- mLatency .SetName ("latency" )
337
+ mLatency .SetName (buildMetricName ( p . config . Namespace , metricLatency ) )
325
338
mLatency .SetUnit ("ms" )
326
339
mLatency .SetEmptyHistogram ().SetAggregationTemporality (p .config .GetAggregationTemporality ())
327
340
dps := mLatency .Histogram ().DataPoints ()
@@ -349,7 +362,7 @@ func (p *processorImp) collectLatencyMetrics(ilm pmetric.ScopeMetrics) {
349
362
// into the given instrumentation library metrics.
350
363
func (p * processorImp ) collectCallMetrics (ilm pmetric.ScopeMetrics ) {
351
364
mCalls := ilm .Metrics ().AppendEmpty ()
352
- mCalls .SetName ("calls_total" )
365
+ mCalls .SetName (buildMetricName ( p . config . Namespace , metricCallsTotal ) )
353
366
mCalls .SetEmptySum ().SetIsMonotonic (true )
354
367
mCalls .Sum ().SetAggregationTemporality (p .config .GetAggregationTemporality ())
355
368
dps := mCalls .Sum ().DataPoints ()
0 commit comments